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

Method Take

ogsr_engine/xrGame/Inventory.cpp:126–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126void CInventory::Take(CGameObject* pObj, bool bNotActivate, bool strict_placement)
127{
128 CInventoryItem* pIItem = smart_cast<CInventoryItem*>(pObj);
129 VERIFY(pIItem);
130
131 if (pIItem->m_pCurrentInventory)
132 {
133 Msg("! ERROR CInventory::Take but object has m_pCurrentInventory");
134 Msg("! Inventory Owner is [%d]", GetOwner()->object_id());
135 Msg("! Object Inventory Owner is [%d]", pIItem->m_pCurrentInventory->GetOwner()->object_id());
136
137 CObject* p = pObj->H_Parent();
138 if (p)
139 Msg("! object parent is [%s] [%d]", p->cName().c_str(), p->ID());
140 }
141
142 R_ASSERT(CanTakeItem(pIItem));
143
144 pIItem->m_pCurrentInventory = this;
145 pIItem->SetDropManual(FALSE);
146
147 m_all.push_back(pIItem);
148 m_allMap.emplace(pIItem->object().cNameSect(), pIItem);
149
150 if (!strict_placement)
151 pIItem->m_eItemPlace = eItemPlaceUndefined;
152
153 bool result = false;
154 switch (pIItem->m_eItemPlace)
155 {
156 case eItemPlaceBelt:
157 result = Belt(pIItem);
158 if (!result)
159 {
160 Msg("!![%s] cant put in belt item [%s], moving to ruck...", __FUNCTION__, pIItem->object().cName().c_str());
161 pIItem->m_eItemPlace = eItemPlaceRuck;
162 R_ASSERT(Ruck(pIItem));
163 }
164
165 break;
166 case eItemPlaceRuck: result = Ruck(pIItem);
167#ifdef DEBUG
168 if (!result)
169 Msg("cant put in ruck item %s", *pIItem->object().cName());
170#endif
171
172 break;
173 case eItemPlaceSlot:
174 if (smart_cast<CActor*>(m_pOwner) && Device.dwPrecacheFrame && m_iActiveSlot == NO_ACTIVE_SLOT && m_iNextActiveSlot == NO_ACTIVE_SLOT)
175 bNotActivate = true;
176 result = Slot(pIItem, bNotActivate);
177#ifdef DEBUG
178 if (!result)
179 Msg("cant slot in ruck item %s", *pIItem->object().cName());
180#endif
181
182 break;
183 default:

Callers 5

OnEventMethod · 0.80
OnEventMethod · 0.80
OnEventMethod · 0.80
OnEventMethod · 0.80
OnEventMethod · 0.80

Calls 15

MsgFunction · 0.85
SlotClass · 0.85
CanPutInSlotFunction · 0.85
InvalidateStateFunction · 0.85
SetDropManualMethod · 0.80
emplaceMethod · 0.80
SetSlotMethod · 0.80
RuckDefaultMethod · 0.80
object_idMethod · 0.45
GetOwnerMethod · 0.45
c_strMethod · 0.45
cNameMethod · 0.45

Tested by

no test coverage detected