MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / OnEvent

Method OnEvent

ogsr_engine/xrGame/Car.cpp:1666–1718  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1664#undef _USE_MATH_DEFINES
1665
1666void CCar::OnEvent(NET_Packet& P, u16 type)
1667{
1668 inherited::OnEvent(P, type);
1669 CExplosive::OnEvent(P, type);
1670
1671 //обработка сообщений, нужных для работы с багажником машины
1672 u16 id;
1673 switch (type)
1674 {
1675 case GE_OWNERSHIP_TAKE:
1676 case GE_TRANSFER_TAKE: {
1677 P.r_u16(id);
1678 CObject* O = Level().Objects.net_Find(id);
1679 if (GetInventory()->CanTakeItem(smart_cast<CInventoryItem*>(O)))
1680 {
1681 O->H_SetParent(this);
1682 GetInventory()->Take(smart_cast<CGameObject*>(O), false, false);
1683 }
1684 else
1685 {
1686 if (!O || !O->H_Parent() || (this != O->H_Parent()))
1687 return;
1688 NET_Packet _P;
1689 u_EventGen(_P, GE_OWNERSHIP_REJECT, ID());
1690 _P.w_u16(u16(O->ID()));
1691 u_EventSend(_P);
1692 }
1693 }
1694 break;
1695 case GE_OWNERSHIP_REJECT:
1696 case GE_TRANSFER_REJECT: {
1697 P.r_u16(id);
1698 CObject* O = Level().Objects.net_Find(id);
1699
1700 if (!O)
1701 {
1702 Msg("! [%s] Error: No object to reject/sell [%u]", __FUNCTION__, id);
1703 break;
1704 }
1705
1706 bool just_before_destroy = !P.r_eof() && P.r_u8();
1707 bool dont_create_shell = (type == GE_TRADE_SELL) || (type == GE_TRANSFER_REJECT) || just_before_destroy;
1708
1709 O->SetTmpPreDestroy(just_before_destroy);
1710
1711 if (GetInventory()->DropItem(smart_cast<CGameObject*>(O)))
1712 {
1713 O->H_SetParent(0, dont_create_shell);
1714 }
1715 }
1716 break;
1717 }
1718}
1719
1720void CCar::ResetScriptData(void* P) { CScriptEntity::ResetScriptData(P); }
1721

Callers 1

Process_eventMethod · 0.45

Calls 12

OnEventFunction · 0.85
GetInventoryFunction · 0.85
IDFunction · 0.85
MsgFunction · 0.85
CanTakeItemMethod · 0.80
H_SetParentMethod · 0.80
TakeMethod · 0.80
r_eofMethod · 0.80
r_u16Method · 0.45
w_u16Method · 0.45
r_u8Method · 0.45
DropItemMethod · 0.45

Tested by

no test coverage detected