| 124 | } |
| 125 | |
| 126 | void 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: |
no test coverage detected