MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / getItem

Method getItem

src/Savegame/BattleUnit.cpp:1675–1700  ·  view source on GitHub ↗

* Checks if there's an inventory item in * the specified inventory position. * @param slot Inventory slot. * @param x X position in slot. * @param y Y position in slot. * @return Item in the slot, or NULL if none. */

Source from the content-addressed store, hash-verified

1673 * @return Item in the slot, or NULL if none.
1674 */
1675BattleItem *BattleUnit::getItem(RuleInventory *slot, int x, int y) const
1676{
1677 // Soldier items
1678 if (slot->getType() != INV_GROUND)
1679 {
1680 for (std::vector<BattleItem*>::const_iterator i = _inventory.begin(); i != _inventory.end(); ++i)
1681 {
1682 if ((*i)->getSlot() == slot && (*i)->occupiesSlot(x, y))
1683 {
1684 return *i;
1685 }
1686 }
1687 }
1688 // Ground items
1689 else if (_tile != 0)
1690 {
1691 for (std::vector<BattleItem*>::const_iterator i = _tile->getInventory()->begin(); i != _tile->getInventory()->end(); ++i)
1692 {
1693 if ((*i)->occupiesSlot(x, y))
1694 {
1695 return *i;
1696 }
1697 }
1698 }
1699 return 0;
1700}
1701
1702/**
1703 * Checks if there's an inventory item in

Callers 12

loadMethod · 0.45
loadMethod · 0.45
getUsedStoresMethod · 0.45
getIgnoredStoresMethod · 0.45
getUsedContainmentMethod · 0.45
setupDefensesMethod · 0.45
getClipsLoadedMethod · 0.45
stepMethod · 0.45
loadMethod · 0.45
rearmMethod · 0.45

Calls 5

occupiesSlotMethod · 0.80
getTypeMethod · 0.45
getSlotMethod · 0.45
getInventoryMethod · 0.45
getIdMethod · 0.45

Tested by

no test coverage detected