UFO: Alien Invasion
Loading...
Searching...
No Matches
g_inventory.h File Reference
#include "g_local.h"
Include dependency graph for g_inventory.h:
This graph shows which files directly or indirectly include this file:

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.
EdictG_GetFloorItems (Edict *ent) __attribute__((nonnull))
 Prepares a list of items on the floor at given entity position.
bool G_InventoryRemoveItemByID (const char *itemID, Edict *ent, containerIndex_t index)
 Removes one particular item from a given container.
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.
void G_InventoryToFloor (Edict *ent)
 Move items to adjacent locations if the containers on the current floor edict are full.
void G_ReadItem (Item *item, const invDef_t **container, int *x, int *y)
 Read item from the network buffer.
void G_WriteItem (const Item &item, const containerIndex_t contId, int x, int y)
 Write an item to the network buffer.
void G_SendInventory (playermask_t player_mask, const Edict &ent)
 Sends whole inventory through the network buffer.

Function Documentation

◆ G_AddItemToFloor()

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_t::inv, INVDEF, and INVSH_GetItemByIDSilent().

Referenced by SP_misc_item().

◆ G_GetEquipDefByID()

const equipDef_t * G_GetEquipDefByID ( const char * equipID)

Definition at line 31 of file g_inventory.cpp.

References gi, i, equipDef_t::id, and Q_streq.

Referenced by G_GetEquipmentForAISpawn().

◆ G_GetFloorItemFromPos()

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().

◆ G_GetFloorItems()

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(), TEST_F(), and TEST_F().

◆ G_InventoryRemoveItemByID()

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_t::id, character_t::inv, INVDEF, Q_streq, and Edict::visflags.

Referenced by G_MissionThink().

◆ G_InventoryToFloor()

void G_InventoryToFloor ( Edict * ent)

Move items to adjacent locations if the containers on the current floor edict are full.

Move the whole given inventory to the floor and destroy the items that do not fit there.

Parameters
[in]entPointer to an Edict being an actor.
See also
G_ActorDie

Definition at line 221 of file g_inventory.cpp.

References Edict::chr, CID_ARMOUR, CID_FLOOR, CID_IMPLANT, CID_MAX, Item::def(), G_CheckVis(), G_EventInventoryDelete(), G_EventPerish(), G_GetFloorItems(), G_InventoryDropToFloorCheck(), G_SpawnFloor(), G_VisFlagsReset(), G_VisToPM(), game, Item::getAmount(), Edict::getContainer(), Edict::getIdNum(), Item::getNext(), Inventory::getNextCont(), Item::getX(), Item::getY(), gi, Container::id, objDef_t::id, character_t::inv, INVDEF, NONE, Edict::pos, Edict::resetContainer(), Edict::setFloor(), and Edict::visflags.

Referenced by G_ActorDieOrStun(), TEST_F(), TEST_F(), and TEST_F().

◆ G_ReadItem()

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 gi, INVDEF, isValidContId(), m, NONE, Item::rotated, Item::setAmmoDef(), Item::setAmmoLeft(), Item::setAmount(), and Item::setDef().

Referenced by G_ClientReadInventory(), and G_ClientSkipActorInfo().

◆ G_SendInventory()

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_t::inv, and INVDEF.

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

◆ G_WriteItem()

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_t::idx, NONE, and Item::rotated.

Referenced by G_ActorInvMove(), and G_SendInventory().