| 27 | #pragma todo("KRodin: заменить на прямые вызовы вместо этих всратых ивентов!") |
| 28 | |
| 29 | void CActor::OnEvent(NET_Packet& P, u16 type) |
| 30 | { |
| 31 | inherited::OnEvent(P, type); |
| 32 | CInventoryOwner::OnEvent(P, type); |
| 33 | |
| 34 | u16 id; |
| 35 | switch (type) |
| 36 | { |
| 37 | case GE_TRADE_BUY: |
| 38 | case GE_OWNERSHIP_TAKE: |
| 39 | case GE_TRANSFER_TAKE: { |
| 40 | P.r_u16(id); |
| 41 | CObject* O = Level().Objects.net_Find(id); |
| 42 | if (!O) |
| 43 | { |
| 44 | Msg("! Error: No object to take/buy [%d]", id); |
| 45 | break; |
| 46 | } |
| 47 | |
| 48 | CFoodItem* pFood = smart_cast<CFoodItem*>(O); |
| 49 | if (pFood) |
| 50 | pFood->m_eItemPlace = eItemPlaceRuck; |
| 51 | |
| 52 | CGameObject* _GO = smart_cast<CGameObject*>(O); |
| 53 | |
| 54 | if (inventory().CanTakeItem(smart_cast<CInventoryItem*>(_GO))) |
| 55 | { |
| 56 | O->H_SetParent(smart_cast<CObject*>(this)); |
| 57 | |
| 58 | inventory().Take(_GO, false, true); |
| 59 | |
| 60 | CUIGameSP* pGameSP = NULL; |
| 61 | CUI* ui = HUD().GetUI(); |
| 62 | if (ui && ui->UIGame()) |
| 63 | { |
| 64 | pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame()); |
| 65 | if (Level().CurrentViewEntity() == this) |
| 66 | HUD().GetUI()->UIGame()->ReInitShownUI(); |
| 67 | }; |
| 68 | |
| 69 | //добавить отсоединенный аддон в инвентарь |
| 70 | if (pGameSP) |
| 71 | { |
| 72 | if (pGameSP->MainInputReceiver() == pGameSP->InventoryMenu) |
| 73 | { |
| 74 | pGameSP->InventoryMenu->AddItemToBag(smart_cast<CInventoryItem*>(O)); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | else |
| 79 | { |
| 80 | NET_Packet _P; |
| 81 | u_EventGen(_P, GE_OWNERSHIP_REJECT, ID()); |
| 82 | _P.w_u16(u16(O->ID())); |
| 83 | u_EventSend(_P); |
| 84 | } |
| 85 | } |
| 86 | break; |
nothing calls this directly
no test coverage detected