UFO: Alien Invasion
|
inventory definition with all its containers More...
#include <inv_shared.h>
Public Member Functions | |
Inventory () | |
virtual | ~Inventory () |
void | init () |
const Container & | getContainer (const containerIndex_t idx) const |
Item * | getContainer2 (const containerIndex_t idx) const |
void | setContainer (const containerIndex_t idx, Item *cont) |
void | resetContainer (const containerIndex_t idx) |
void | resetTempContainers () |
bool | containsItem (const containerIndex_t contId, const Item *const item) const |
Searches if there is a specific item already in the inventory&container. More... | |
Item * | getArmour () const |
Item * | getHeadgear () const |
Item * | getRightHandContainer () const |
Item * | getLeftHandContainer () const |
Item * | getHolsterContainer () const |
Item * | getEquipContainer () const |
Item * | getImplantContainer () const |
Item * | getFloorContainer () const |
void | setFloorContainer (Item *cont) |
void | findSpace (const invDef_t *container, const Item *item, int *const px, int *const py, const Item *ignoredItem) const |
Finds space for item in inv at container. More... | |
Item * | findInContainer (const containerIndex_t contId, const Item *const item) const |
Searches a specific item in the inventory&container. More... | |
Item * | getItemAtPos (const invDef_t *container, const int x, const int y) const |
Searches if there is an item at location (x,y) in a container. More... | |
int | getWeight () const |
Get the weight of the items in the given inventory (excluding those in temp containers). More... | |
int | canHoldItem (const invDef_t *container, const objDef_t *od, const int x, const int y, const Item *ignoredItem) const |
bool | canHoldItemWeight (containerIndex_t from, containerIndex_t to, const Item &item, int maxWeight) const |
Check that adding an item to the inventory won't exceed the max permitted weight. More... | |
bool | holdsReactionFireWeapon () const |
Checks if there is a weapon in the hands that can be used for reaction fire. More... | |
const Container * | getNextCont (const Container *prev, bool inclTemp=false) const |
int | countItems () const |
Count the number of items in the inventory (without temp containers) More... | |
Protected Member Functions | |
const Container * | _getNextCont (const Container *prev) const |
Protected Attributes | |
Container | _containers [MAX_CONTAINERS] |
inventory definition with all its containers
Definition at line 525 of file inv_shared.h.
Inventory::Inventory | ( | ) |
Definition at line 692 of file inv_shared.cpp.
References init().
|
inlinevirtual |
Definition at line 534 of file inv_shared.h.
Definition at line 710 of file inv_shared.cpp.
References _containers, and CID_MAX.
Referenced by getNextCont().
int Inventory::canHoldItem | ( | const invDef_t * | container, |
const objDef_t * | od, | ||
const int | x, | ||
const int | y, | ||
const Item * | ignoredItem | ||
) | const |
[in] | container | The index of the container in the inventory to check the item in. |
[in] | od | The type of item to check in the inventory. |
[in] | x | The x value in the container (1 << x in the shape bitmask) |
[in] | y | The y value in the container (SHAPE_BIG_MAX_HEIGHT is the max) |
[in] | ignoredItem | You can ignore one item in the container (most often the currently dragged one). Use nullptr if you want to check against all items in the container. |
< Return INV_FITS_BOTH if both if statements where true above.
< We are returning with status true (1) if the item does not fit at all - unlikely but not impossible.
< Return INV_FITS_BOTH if both if statements where true above.
Definition at line 761 of file inv_shared.cpp.
References invDef_s::all, invDef_s::armour, CID_LEFT, CID_RIGHT, Com_DPrintf(), containsItem(), DEBUG_SHARED, objDef_s::fireTwoHanded, getContainer2(), objDef_s::getShapeRotated(), objDef_s::headgear, invDef_s::headgear, objDef_s::holdTwoHanded, invDef_s::id, objDef_s::implant, invDef_s::implant, INV_DOES_NOT_FIT, INV_FITS, INV_FITS_ONLY_ROTATED, INVSH_CheckToInventory_shape(), objDef_s::isArmour(), invDef_s::isEquipDef(), invDef_s::isFloorDef(), Item::isHeldTwoHanded(), invDef_s::isLeftDef(), invDef_s::isRightDef(), invDef_s::scroll, objDef_s::shape, invDef_s::single, and invDef_s::unique.
Referenced by InventoryInterface::addToInventory(), findSpace(), InventoryInterface::moveInInventory(), uiContainerNode::onDndMove(), InventoryInterface::tryAddToInventory(), UI_ContainerNodeDrawDropPreview(), and UI_ContainerNodeDrawFreeSpace().
bool Inventory::canHoldItemWeight | ( | containerIndex_t | from, |
containerIndex_t | to, | ||
const Item & | item, | ||
int | maxWeight | ||
) | const |
Check that adding an item to the inventory won't exceed the max permitted weight.
[in] | from | Index of the container the item comes from. |
[in] | to | Index of the container the item is being placed. |
[in] | item | The item that is being added. |
[in] | maxWeight | The max permitted weight. |
true
if it is Ok to add the item false
otherwise. Definition at line 919 of file inv_shared.cpp.
References getArmour(), Item::getWeight(), getWeight(), csi_s::ids, Item::isArmour(), and invDef_s::temp.
Referenced by CL_ActorInvMove(), G_ActorInvMove(), G_ClientReadInventory(), GAME_LoadInventory(), and INV_MoveItem().
|
inline |
Searches if there is a specific item already in the inventory&container.
[in] | contId | Container in the inventory. |
[in] | item | The item to search for. |
Definition at line 572 of file inv_shared.h.
References findInContainer().
Referenced by canHoldItem(), uiContainerNode::onDndMove(), and TEST_F().
int Inventory::countItems | ( | ) | const |
Count the number of items in the inventory (without temp containers)
Definition at line 741 of file inv_shared.cpp.
References Container::countItems(), and getNextCont().
Referenced by GAME_NetSendInventory().
Item * Inventory::findInContainer | ( | const containerIndex_t | contId, |
const Item *const | searchItem | ||
) | const |
Searches a specific item in the inventory&container.
[in] | contId | Container in the inventory. |
[in] | searchItem | The item to search for. |
nullptr
. Definition at line 1001 of file inv_shared.cpp.
References getContainer(), Container::getNextItem(), and Item::isSameAs().
Referenced by containsItem(), and G_ActorInvMove().
void Inventory::findSpace | ( | const invDef_t * | container, |
const Item * | item, | ||
int *const | px, | ||
int *const | py, | ||
const Item * | ignoredItem | ||
) | const |
Finds space for item in inv at container.
[in] | item | The item to check the space for |
[in] | container | The container to search in |
[out] | px | The x position in the container |
[out] | py | The y position in the container |
[in] | ignoredItem | You can ignore one item in the container (most often the currently dragged one). Use nullptr if you want to check against all items in the container. |
Definition at line 876 of file inv_shared.cpp.
References cacheCheckToInventory, canHoldItem(), Com_DPrintf(), DEBUG_SHARED, Item::def(), objDef_s::id, INV_DOES_NOT_FIT, INV_FITS, invDef_s::name, NONE, invDef_s::scroll, SHAPE_BIG_MAX_HEIGHT, SHAPE_BIG_MAX_WIDTH, and objDef_s::type.
Referenced by InventoryInterface::addToInventory(), G_ActorInvMove(), InventoryInterface::moveInInventory(), uiContainerNode::onDndMove(), InventoryInterface::tryAddToInventory(), and UI_ContainerNodeAddItem().
Item * Inventory::getArmour | ( | ) | const |
Definition at line 990 of file inv_shared.cpp.
References CID_ARMOUR, and getContainer2().
Referenced by canHoldItemWeight(), CHRSH_CharGetBody(), CHRSH_CharGetHead(), GAME_CollectItems(), and Edict::getArmour().
|
inline |
Definition at line 537 of file inv_shared.h.
Referenced by CP_CleanupContainerWeapons(), findInContainer(), getContainer2(), getItemAtPos(), INVSH_CheckToInventory_shape(), InventoryInterface::moveInInventory(), and UI_ContainerNodeDrawGrid().
|
inline |
Definition at line 546 of file inv_shared.h.
References Container::_invList, and getContainer().
Referenced by InventoryInterface::addInvList(), InventoryInterface::addToInventory(), canHoldItem(), CL_ActorGetContainerForReload(), CL_ActorReload(), CP_CleanupContainerWeapons(), CP_SetEquipContainer(), InventoryInterface::emptyContainer(), GAME_NetSendInventory(), getArmour(), Edict::getContainer(), getEquipContainer(), getFloorContainer(), getHeadgear(), getHolsterContainer(), getImplantContainer(), getItemAtPos(), getLeftHandContainer(), getRightHandContainer(), HUD_WeaponCanBeReloaded(), INV_SearchInInventoryWithFilter(), InventoryInterface::PackAmmoAndWeapon(), InventoryInterface::removeFromInventory(), and UI_ContainerNodeDrawSingle().
Item * Inventory::getEquipContainer | ( | ) | const |
Definition at line 980 of file inv_shared.cpp.
References CID_EQUIP, and getContainer2().
Referenced by GAME_ActorSelect_f(), and UI_ContainerNodeUpdateEquipment().
Item * Inventory::getFloorContainer | ( | ) | const |
Definition at line 975 of file inv_shared.cpp.
References CID_FLOOR, and getContainer2().
Referenced by Edict::getFloor(), and le_s::getFloorContainer().
Item * Inventory::getHeadgear | ( | ) | const |
Definition at line 965 of file inv_shared.cpp.
References CID_HEADGEAR, and getContainer2().
Referenced by CL_ActorUseHeadgear_f(), G_PrepareShot(), HUD_UpdateActorFireMode(), and HUD_UpdateButtons().
Item * Inventory::getHolsterContainer | ( | ) | const |
Definition at line 970 of file inv_shared.cpp.
References CID_HOLSTER, and getContainer2().
Referenced by CL_GetSkillIndicator().
Item * Inventory::getImplantContainer | ( | ) | const |
Definition at line 985 of file inv_shared.cpp.
References CID_IMPLANT, and getContainer2().
Searches if there is an item at location (x,y) in a container.
[in] | container | Container in the inventory. |
[in] | x/y | Position in the container that you want to check. |
Definition at line 844 of file inv_shared.cpp.
References getContainer(), getContainer2(), Container::getNextItem(), invDef_s::id, INVSH_ShapeCheckPosition(), invDef_s::name, invDef_s::scroll, invDef_s::single, and Sys_Error().
Referenced by CL_ActorInvMove(), CL_InvAmmo(), CL_InvDel(), CL_InvReload(), G_ActorInvMove(), G_ClientAction(), INV_LoadWeapon(), InventoryInterface::moveInInventory(), uiContainerNode::onDndFinished(), uiContainerNode::onDndMove(), and UI_ContainerNodeGetItemAtPosition().
Item * Inventory::getLeftHandContainer | ( | ) | const |
Definition at line 960 of file inv_shared.cpp.
References CID_LEFT, and getContainer2().
Referenced by CL_ActorCvars(), le_s::getHandItem(), Edict::getHandItem(), le_s::getLeftHandItem(), Edict::getLeftHandItem(), holdsReactionFireWeapon(), and UI_ContainerNodeDrawSingle().
Definition at line 722 of file inv_shared.cpp.
References _containers, _getNextCont(), CID_EQUIP, and CID_FLOOR.
Referenced by AI_SearchGrenade(), AII_CarriedItems(), AIR_TransferItemsCarriedByCharacterToBase(), AM_MoveCharacterInventoryIntoItemCargo(), countItems(), InventoryInterface::destroyInventory(), E_RemoveInventoryFromStorage(), G_ActorReload(), G_ClientCanReload(), G_ClientGetWeaponFromInventory(), G_InventoryToFloor(), G_MissionTouch(), G_SendInventory(), GAME_SaveInventory(), InventoryInterface::GetInventoryState(), getWeight(), HUD_UpdateActorLoad_f(), INV_UpdateActorLoad_f(), resetTempContainers(), TEST_F(), and TR_Add_f().
Item * Inventory::getRightHandContainer | ( | ) | const |
Definition at line 955 of file inv_shared.cpp.
References CID_RIGHT, and getContainer2().
Referenced by CL_ActorCvars(), CL_GetSkillIndicator(), CP_CleanupAircraftTeam(), CP_CleanupTeam(), le_s::getHandItem(), Edict::getHandItem(), le_s::getRightHandItem(), Edict::getRightHandItem(), holdsReactionFireWeapon(), and UI_ContainerNodeDrawSingle().
int Inventory::getWeight | ( | ) | const |
Get the weight of the items in the given inventory (excluding those in temp containers).
Definition at line 937 of file inv_shared.cpp.
References getNextCont(), Container::getNextItem(), and Item::getWeight().
Referenced by canHoldItemWeight(), G_ActorCalculateMaxTU(), G_ClientAssignDefaultActorValues(), G_UpdateCarriedWeight(), InventoryInterface::GetInventoryState(), HUD_UpdateActorLoad_f(), and INV_UpdateActorLoad_f().
bool Inventory::holdsReactionFireWeapon | ( | ) | const |
Checks if there is a weapon in the hands that can be used for reaction fire.
Definition at line 1016 of file inv_shared.cpp.
References getLeftHandContainer(), and getRightHandContainer().
Referenced by G_ReactionFireCanBeEnabled(), HUD_ToggleReaction_f(), and HUD_UpdateButtons().
Definition at line 703 of file inv_shared.cpp.
References _containers, CID_MAX, i, and OBJZERO.
Referenced by B_LoadXML(), InventoryInterface::destroyInventory(), GAME_GetEquipment(), le_s::init(), character_s::init(), and Inventory().
|
inline |
Definition at line 554 of file inv_shared.h.
References Container::_invList.
Referenced by CP_SetEquipContainer(), InventoryInterface::emptyContainer(), GAME_ActorSelect_f(), Edict::resetContainer(), and resetTempContainers().
|
inline |
Definition at line 557 of file inv_shared.h.
References Container::def(), getNextCont(), Container::id, resetContainer(), and invDef_s::temp.
Referenced by GAME_SendCurrentTeamSpawningInfo().
|
inline |
Definition at line 550 of file inv_shared.h.
References Container::_invList.
Referenced by InventoryInterface::addInvList(), CP_SetEquipContainer(), GAME_ActorSelect_f(), InventoryInterface::removeFromInventory(), setFloorContainer(), and UI_ContainerNodeUpdateEquipment().
Definition at line 950 of file inv_shared.cpp.
References CID_FLOOR, and setContainer().
Referenced by le_s::resetFloor(), Edict::resetFloor(), le_s::setFloor(), Edict::setFloor(), and le_s::setFloorContainer().
|
protected |
Definition at line 527 of file inv_shared.h.
Referenced by _getNextCont(), getNextCont(), and init().