UFO: Alien Invasion
Loading...
Searching...
No Matches
Item Class Reference

item instance data, with linked list capability More...

#include <inv_shared.h>

Collaboration diagram for Item:
Collaboration graph

Public Member Functions

 Item ()
 Item constructor with all default values.
 Item (const objDef_t *_itemDef, const objDef_t *ammo=nullptr, int ammoLeft=0)
 Item constructor with the 3 most often changed attributes.
void setNext (Item *nx)
void setX (const int val)
void setY (const int val)
void setAmmoDef (const objDef_t *od)
void setAmount (int value)
void setAmmoLeft (int value)
void setDef (const objDef_t *objDef)
ItemgetNext () const
int getX () const
int getY () const
const objDef_tammoDef (void) const
int getAmount () const
int getAmmoLeft () const
const objDef_tdef (void) const
bool isHeldTwoHanded () const
bool isReloadable () const
bool mustReload () const
bool isWeapon () const
bool isArmour () const
bool isSameAs (const Item *const other) const
 Check if the (physical) information of 2 items is exactly the same.
void addAmount (int value)
int getWeight () const
 Return the weight of an item.
void getFirstShapePosition (int *const x, int *const y) const
 Calculates the first "true" bit in the shape and returns its position in the item.
const objDef_tgetReactionFireWeaponType () const
 Checks whether this item is a reaction fire enabled weapon.
const fireDef_tgetFiredefs () const
 Returns the firedefinitions for a given weapon/ammo.
int getNumFiredefs () const
const fireDef_tgetSlowestFireDef () const
 Get the firedef that uses the most TU for this item.
const fireDef_tgetFastestFireDef () const

Data Fields

int rotated

Private Attributes

const objDef_t_itemDef
const objDef_t_ammoDef
Item_next
int _x
int _y
int _amount
int _ammoLeft

Detailed Description

item instance data, with linked list capability

Note
the item and ammo indices are transfered as shorts over the net - a value of NONE means that there is no item - e.g. a value of NONE for the ammo means, that there is no ammo loaded or assigned to this weapon

Definition at line 402 of file inv_shared.h.

Constructor & Destructor Documentation

◆ Item() [1/2]

Item::Item ( )

Item constructor with all default values.

Definition at line 497 of file inv_shared.cpp.

References _itemDef, _next, _x, _y, NONE_AMMO, rotated, setAmmoDef(), setAmmoLeft(), and setAmount().

Referenced by getNext(), isSameAs(), and setNext().

◆ Item() [2/2]

Item::Item ( const objDef_t * _itemDef,
const objDef_t * ammo = nullptr,
int ammoLeft = 0 )

Item constructor with the 3 most often changed attributes.

Definition at line 508 of file inv_shared.cpp.

References _itemDef, _next, _x, _y, rotated, setAmmoDef(), setAmmoLeft(), and setAmount().

Member Function Documentation

◆ addAmount()

void Item::addAmount ( int value)
inline

Definition at line 497 of file inv_shared.h.

References _amount.

Referenced by InventoryInterface::addToInventory(), and InventoryInterface::removeFromInventory().

◆ ammoDef()

◆ def()

const objDef_t * Item::def ( void ) const
inline

Definition at line 469 of file inv_shared.h.

References _itemDef.

Referenced by equipDef_t::addClip(), InventoryInterface::addToInventory(), AI_FindBestFiredef(), AI_SearchGrenade(), AII_CarriedItems(), AIL_roundsleft(), AIL_weapontype(), AIR_GetStorageRoom(), AIR_MoveEmployeeInventoryIntoStorage(), AIR_TransferItemsCarriedByCharacterToBase(), AM_MoveCharacterInventoryIntoItemCargo(), CHRSH_CharGetBody(), CHRSH_CharGetHead(), CL_ActorCvars(), CL_ActorGetMuzzle(), CL_ActorReload(), CL_GetSkillIndicator(), CL_InvAdd(), CL_InvReload(), CL_NetReceiveItem(), CP_AddWeaponAmmo(), CP_CleanupAircraftTeam(), CP_CleanupContainerWeapons(), CP_CleanupTeam(), uiBaseInventoryNode::draw(), uiContainerNode::draw(), uiItemNode::draw(), E_RemoveInventoryFromStorage(), InventoryInterface::EquipActorMelee(), Inventory::findSpace(), G_ActorGetTUForReactionFire(), G_ActorInvMove(), G_ActorReload(), G_ApplyProtection(), G_ClientCanReload(), G_ClientGetWeaponFromInventory(), G_ClientReadInventory(), G_ClientShoot(), G_EventActorAppear(), G_EventInventoryReload(), G_InventoryDropToFloorCheck(), G_InventoryRemoveItemByID(), G_InventoryToFloor(), G_MissionThink(), G_MissionTouch(), G_SendInventory(), G_ShootGrenade(), G_ShootSingle(), G_ShotMorale(), G_WriteItem(), GAME_CollectItems(), GAME_LoadInventory(), GAME_LoadItem(), GAME_NetSendItem(), GAME_SaveItem(), getFiredefs(), getNumFiredefs(), getReactionFireWeaponType(), getWeight(), HUD_CheckReload(), HUD_CheckShooting(), HUD_DisplayActions(), HUD_GetFireDefinitionForHand(), HUD_GetMinimumTUsForUsage(), HUD_UpdateActor(), HUD_UpdateActorCvar(), HUD_UpdateActorFireMode(), HUD_UpdateActorLoad_f(), HUD_UpdateActorStats(), HUD_WeaponCanBeReloaded(), INV_LoadWeapon(), INV_UnloadWeapon(), INVSH_CheckToInventory_shape(), INVSH_ShapeCheckPosition(), isSameAs(), LE_BiggestItem(), InventoryInterface::moveInInventory(), uiContainerNode::onDndFinished(), uiContainerNode::onDndMove(), InventoryInterface::PackAmmoAndWeapon(), InventoryInterface::removeFromInventory(), TEST_F(), TEST_F(), TR_Add_f(), InventoryInterface::tryAddToInventory(), UI_BaseInventoryNodeDrawItems(), UI_ContainerNodeAutoPlaceItem(), UI_ContainerNodeDrawDropPreview(), UI_ContainerNodeDrawFreeSpace(), UI_ContainerNodeDrawGrid(), UI_ContainerNodeDrawSingle(), UI_ContainerNodeUpdateEquipment(), UI_DrawItem(), and UI_GetItemTooltip().

◆ getAmmoLeft()

◆ getAmount()

◆ getFastestFireDef()

const fireDef_t * Item::getFastestFireDef ( ) const

◆ getFiredefs()

◆ getFirstShapePosition()

void Item::getFirstShapePosition ( int *const x,
int *const y ) const

Calculates the first "true" bit in the shape and returns its position in the item.

Note
Use this to get the first "grab-able" grid-location of an item (not in the container !).
Parameters
[out]xThe x location inside the item.
[out]yThe x location inside the item.
See also
canHoldItem

Definition at line 557 of file inv_shared.cpp.

References getX(), getY(), INVSH_ShapeCheckPosition(), NONE, and SHAPE_SMALL_MAX_HEIGHT.

Referenced by CL_ActorReload(), G_ActorInvMove(), and INV_LoadWeapon().

◆ getNext()

◆ getNumFiredefs()

int Item::getNumFiredefs ( ) const

◆ getReactionFireWeaponType()

const objDef_t * Item::getReactionFireWeaponType ( ) const

Checks whether this item is a reaction fire enabled weapon.

Note
The item is supposed to be in the right or left hand
Returns
nullptr if no reaction fire enabled weapon, the reaction fire enabled object otherwise.

Definition at line 649 of file inv_shared.cpp.

References def(), getFiredefs(), and fireDef_t::reaction.

Referenced by G_ReactionFireSettingsSetDefault().

◆ getSlowestFireDef()

const fireDef_t * Item::getSlowestFireDef ( ) const

Get the firedef that uses the most TU for this item.

Returns
The firedef that uses the most TU for this item or nullptr.

Definition at line 610 of file inv_shared.cpp.

References getFiredefs(), i, and MAX_FIREDEFS_PER_WEAPON.

Referenced by InventoryInterface::EquipActorNormal().

◆ getWeight()

int Item::getWeight ( ) const

Return the weight of an item.

Returns
The weight of the given item including any ammo loaded.

Definition at line 522 of file inv_shared.cpp.

References ammoDef(), def(), getAmmoLeft(), and objDef_t::weight.

Referenced by Inventory::canHoldItemWeight(), InventoryInterface::EquipActorNormal(), Inventory::getWeight(), and InventoryInterface::PackAmmoAndWeapon().

◆ getX()

◆ getY()

◆ isArmour()

bool Item::isArmour ( ) const
inline

◆ isHeldTwoHanded()

◆ isReloadable()

bool Item::isReloadable ( ) const
inline

◆ isSameAs()

bool Item::isSameAs ( const Item *const other) const

Check if the (physical) information of 2 items is exactly the same.

Parameters
[in]otherSecond item to compare.
Returns
true if they are identical or false otherwise.

Definition at line 536 of file inv_shared.cpp.

References ammoDef(), def(), getAmmoLeft(), and Item().

Referenced by InventoryInterface::addToInventory(), and Inventory::findInContainer().

◆ isWeapon()

◆ mustReload()

bool Item::mustReload ( ) const
inline
Note
!mustReload() is not equivalent to 'usable' e.g. medikits are not reloadable, but they do have ammo

Definition at line 483 of file inv_shared.h.

References getAmmoLeft(), and isReloadable().

Referenced by AI_ActorThink(), AI_GetItemFromInventory(), AI_SearchGrenade(), G_ClientGetWeaponFromInventory(), ReactionFire::getFireDef(), HUD_CheckShooting(), HUD_UpdateActorFireMode(), and UI_DrawItem().

◆ setAmmoDef()

◆ setAmmoLeft()

◆ setAmount()

void Item::setAmount ( int value)
inline

◆ setDef()

void Item::setDef ( const objDef_t * objDef)
inline

◆ setNext()

void Item::setNext ( Item * nx)
inline

◆ setX()

void Item::setX ( const int val)
inline

◆ setY()

void Item::setY ( const int val)
inline

Field Documentation

◆ _ammoDef

const objDef_t* Item::_ammoDef
private

Pointer to ammo definition.

Definition at line 404 of file inv_shared.h.

Referenced by ammoDef(), and setAmmoDef().

◆ _ammoLeft

int Item::_ammoLeft
private

Number of ammo rounds left - see NONE_AMMO

Definition at line 410 of file inv_shared.h.

Referenced by getAmmoLeft(), and setAmmoLeft().

◆ _amount

int Item::_amount
private

The amount of items of this type on the same x and y location in the container

Definition at line 409 of file inv_shared.h.

Referenced by addAmount(), getAmount(), and setAmount().

◆ _itemDef

const objDef_t* Item::_itemDef
private

The weapon definition.

Definition at line 403 of file inv_shared.h.

Referenced by def(), isArmour(), isHeldTwoHanded(), isReloadable(), isWeapon(), Item(), Item(), and setDef().

◆ _next

Item* Item::_next
private

Next entry in this list.

Definition at line 405 of file inv_shared.h.

Referenced by getNext(), Item(), Item(), and setNext().

◆ _x

int Item::_x
private

Definition at line 406 of file inv_shared.h.

Referenced by getX(), Item(), Item(), and setX().

◆ _y

int Item::_y
private

Position (aka origin location) of the item in the container/invlist.

Note
ATTENTION Do not use this to get an item by comparing it against a x/y value. The shape as defined in the Item may be empty at this location!

Definition at line 406 of file inv_shared.h.

Referenced by getY(), Item(), Item(), and setY().

◆ rotated

int Item::rotated

If the item is currently displayed rotated (true or 1) or not (false or 0)

Note
don't change this to anything smaller than 4 bytes - the network parsing functions are expecting this to be at least 4 bytes

Definition at line 412 of file inv_shared.h.

Referenced by InventoryInterface::addToInventory(), CL_NetReceiveItem(), G_ActorInvMove(), G_ReadItem(), G_WriteItem(), GAME_LoadItem(), GAME_NetSendItem(), GAME_SaveItem(), INVSH_CheckToInventory_shape(), INVSH_ShapeCheckPosition(), Item(), Item(), InventoryInterface::moveInInventory(), uiContainerNode::onDndFinished(), InventoryInterface::tryAddToInventory(), UI_ContainerNodeDrawDropPreview(), and UI_DrawItem().


The documentation for this class was generated from the following files: