UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
g_inventory.h File Reference
#include "g_local.h"

Go to the source code of this file.

Functions

const equipDef_tG_GetEquipDefByID (const char *equipID)
 
EdictG_GetFloorItemFromPos (const pos3_t pos)
 Callback to G_GetEdictFromPos() for given position, used to get items from position. More...
 
EdictG_GetFloorItems (Edict *ent) __attribute__((nonnull))
 Prepares a list of items on the floor at given entity position. More...
 
bool G_InventoryRemoveItemByID (const char *itemID, Edict *ent, containerIndex_t index)
 Removes one particular item from a given container. More...
 
bool G_AddItemToFloor (const pos3_t pos, const char *itemID)
 Adds a new item to an existing or new floor container edict at the given grid location. More...
 
void G_InventoryToFloor (Edict *ent)
 Move items to adjacent locations if the containers on the current floor edict are full. More...
 
void G_ReadItem (Item *item, const invDef_t **container, int *x, int *y)
 Read item from the network buffer. More...
 
void G_WriteItem (const Item &item, const containerIndex_t contId, int x, int y)
 Write an item to the network buffer. More...
 
void G_SendInventory (playermask_t player_mask, const Edict &ent)
 Sends whole inventory through the network buffer. More...
 

Function Documentation

bool G_AddItemToFloor ( const pos3_t  pos,
const char *  itemID 
)

Adds a new item to an existing or new floor container edict at the given grid location.

Parameters
posThe grid location to spawn the item on the floor
itemIDThe item to spawn

Definition at line 140 of file g_inventory.cpp.

References Edict::chr, CID_FLOOR, G_GetFloorItemFromPos(), G_SpawnFloor(), game, gi, character_s::inv, INVDEF, game_locals_s::invi, INVSH_GetItemByIDSilent(), and InventoryInterface::tryAddToInventory().

Referenced by SP_misc_item().

const equipDef_t* G_GetEquipDefByID ( const char *  equipID)

Definition at line 31 of file g_inventory.cpp.

References game_import_s::csi, csi_s::eds, gi, i, equipDef_s::id, csi_s::numEDs, and Q_streq.

Referenced by G_GetEquipmentForAISpawn().

Edict* G_GetFloorItemFromPos ( const pos3_t  pos)

Callback to G_GetEdictFromPos() for given position, used to get items from position.

Parameters
[in]posA position for which items are wanted.
See also
G_GetFloorItems

Definition at line 48 of file g_inventory.cpp.

References ET_ITEM, and G_GetEdictFromPos().

Referenced by G_AddItemToFloor(), G_GetFloorItems(), G_SpawnItemOnFloor(), and TEST_F().

Edict* G_GetFloorItems ( Edict ent)

Prepares a list of items on the floor at given entity position.

Parameters
[in]entPointer to an entity being an actor.
Returns
pointer to Edict being a floor (with items) or nullptr in case no items were found on the edict grid position.

Definition at line 59 of file g_inventory.cpp.

References G_GetFloorItemFromPos(), Edict::pos, Edict::resetFloor(), and Edict::setFloor().

Referenced by G_ActorInvMove(), G_ActorRevitalise(), G_ClientMove(), G_InventoryToFloor(), G_MissionThink(), G_SpawnItemOnFloor(), and TEST_F().

bool G_InventoryRemoveItemByID ( const char *  itemID,
Edict ent,
containerIndex_t  container 
)

Removes one particular item from a given container.

Parameters
itemIDThe id of the item to remove
entThe edict that holds the inventory to remove the item from
containerThe container in the inventory of the edict to remove the searched item from.
Returns
true if the removal was successful, false otherwise.

Definition at line 80 of file g_inventory.cpp.

References Edict::chr, Item::def(), G_EventInventoryDelete(), G_VisToPM(), game, Edict::getContainer(), Item::getNext(), Item::getX(), Item::getY(), gi, objDef_s::id, character_s::inv, INVDEF, game_locals_s::invi, Q_streq, InventoryInterface::removeFromInventory(), and Edict::visflags.

Referenced by G_MissionThink().

void G_InventoryToFloor ( Edict ent)
void G_ReadItem ( Item item,
const invDef_t **  container,
int x,
int y 
)

Read item from the network buffer.

Parameters
[in,out]itemThe Item being send through net.
[in,out]containerContainer which is being updated with item sent.
[in]x,yPosition of item in given container.
See also
CL_NetReceiveItem
EV_INV_TRANSFER

Definition at line 297 of file g_inventory.cpp.

References game_import_s::csi, gi, INVDEF, isValidContId(), m, NONE, csi_s::numODs, csi_s::ods, Item::rotated, Item::setAmmoDef(), Item::setAmmoLeft(), Item::setAmount(), and Item::setDef().

Referenced by G_ClientReadInventory(), and G_ClientSkipActorInfo().

void G_SendInventory ( playermask_t  playerMask,
const Edict ent 
)

Sends whole inventory through the network buffer.

Parameters
[in]playerMaskThe player mask to determine which clients should receive the event (G_VisToPM(ent->visflags)).
[in]entPointer to an actor or floor container with inventory to send.
See also
G_AppearPerishEvent
CL_InvAdd

Definition at line 347 of file g_inventory.cpp.

References Edict::chr, Container::countItems(), Item::def(), G_EventEnd(), G_EventInventoryAdd(), G_IsItem, G_WriteItem(), Inventory::getNextCont(), Container::getNextItem(), Item::getX(), Item::getY(), Container::id, character_s::inv, and INVDEF.

Referenced by G_AppearPerishEvent(), G_EventActorAppear(), and G_VisMakeEverythingVisible().

void G_WriteItem ( const Item item,
const containerIndex_t  contId,
int  x,
int  y 
)

Write an item to the network buffer.

Parameters
[in,out]itemThe Item being send through net.
[in,out]contIdContainer which is being updated with item sent.
[in]x,yPosition of item in given container.
See also
CL_NetReceiveItem
EV_INV_TRANSFER

Definition at line 334 of file g_inventory.cpp.

References Item::ammoDef(), Item::def(), Item::getAmmoLeft(), Item::getAmount(), gi, objDef_s::idx, NONE, and Item::rotated.

Referenced by G_ActorInvMove(), and G_SendInventory().