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

Method Slot

ogsr_engine/xrGame/Inventory.cpp:329–386  ·  view source on GitHub ↗

положить вещь в слот

Source from the content-addressed store, hash-verified

327
328//положить вещь в слот
329bool CInventory::Slot(PIItem pIItem, bool bNotActivate)
330{
331 VERIFY(pIItem);
332 // Msg("To Slot %s[%d]", *pIItem->object().cName(), pIItem->object().ID());
333
334 if (!CanPutInSlot(pIItem))
335 {
336 /*
337 Msg("there is item %s[%d,%x] in slot %d[%d,%x]",
338 *m_slots[pIItem->GetSlot()].m_pIItem->object().cName(),
339 m_slots[pIItem->GetSlot()].m_pIItem->object().ID(),
340 m_slots[pIItem->GetSlot()].m_pIItem,
341 pIItem->GetSlot(),
342 pIItem->object().ID(),
343 pIItem);
344 */
345 if (m_slots[pIItem->GetSlot()].m_pIItem == pIItem && !bNotActivate)
346 Activate(pIItem->GetSlot());
347
348 return false;
349 }
350
351 /*
352 Вещь была в слоте. Да, такое может быть :).
353 Тут необходимо проверять именно так, потому что
354 GetSlot вернет новый слот, а не старый. Real Wolf.
355 */
356 for (u32 i = 0; i < m_slots.size(); i++)
357 if (m_slots[i].m_pIItem == pIItem)
358 {
359 if (i == m_iActiveSlot)
360 Activate(NO_ACTIVE_SLOT);
361 m_slots[i].m_pIItem = NULL;
362 break;
363 }
364
365 m_slots[pIItem->GetSlot()].m_pIItem = pIItem;
366
367 //удалить из рюкзака или пояса
368 TIItemContainer::iterator it = std::find(m_ruck.begin(), m_ruck.end(), pIItem);
369 if (m_ruck.end() != it)
370 m_ruck.erase(it);
371 it = std::find(m_belt.begin(), m_belt.end(), pIItem);
372 if (m_belt.end() != it)
373 m_belt.erase(it);
374
375 if ((m_iActiveSlot == pIItem->GetSlot() || (m_iActiveSlot == NO_ACTIVE_SLOT && m_iNextActiveSlot == NO_ACTIVE_SLOT)) && !bNotActivate)
376 Activate(pIItem->GetSlot());
377
378 auto PrevPlace = pIItem->m_eItemPlace;
379 pIItem->m_eItemPlace = eItemPlaceSlot;
380 m_pOwner->OnItemSlot(pIItem, PrevPlace);
381 pIItem->OnMoveToSlot();
382
383 pIItem->object().processing_activate();
384
385 return true;
386}

Callers 7

OnEventMethod · 0.45
PutNextToSlotMethod · 0.45
TrySwitchGrenadeMethod · 0.45
initializeMethod · 0.45
executeMethod · 0.45
MoveToSlotMethod · 0.45
ToSlotMethod · 0.45

Calls 11

CanPutInSlotFunction · 0.85
processing_activateMethod · 0.80
findFunction · 0.50
GetSlotMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
OnItemSlotMethod · 0.45
OnMoveToSlotMethod · 0.45
objectMethod · 0.45

Tested by

no test coverage detected