g_inventory.c File Reference

#include "g_local.h"
Include dependency graph for g_inventory.c:

Go to the source code of this file.

Functions

edict_tG_GetFloorItemsFromPos (const pos3_t pos)
 Callback to G_GetEdictFromPos() for given position, used to get items from position.
edict_tG_GetFloorItems (edict_t *ent)
 Prepares a list of items on the floor at given entity position.
qboolean G_InventoryRemoveItemByID (const char *itemID, edict_t *ent, containerIndex_t container)
 Removes one particular item from a given container.
static qboolean G_InventoryDropToFloorCheck (edict_t *ent, containerIndex_t container)
 Checks whether the given container contains items that should be dropped to the floor.
qboolean 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_t *ent)
 Move items to adjacent locations if the containers on the current floor edict are full.
void G_ReadItem (item_t *item, invDef_t **container, int *x, int *y)
 Read item from the network buffer.
void G_WriteItem (const item_t *item, const invDef_t *container, int x, int y)
 Write an item to the network buffer.
void G_SendInventory (unsigned int playerMask, const edict_t *ent)
 Sends whole inventory through the network buffer.

Detailed Description

Definition in file g_inventory.c.


Function Documentation

qboolean 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:
pos The grid location to spawn the item on the floor
itemID The item to spawn

Definition at line 125 of file g_inventory.c.

References edict_s::chr, game_import_t::csi, G_GetFloorItemsFromPos(), G_SpawnFloor(), game, gi, character_s::i, game_locals_t::i, csi_s::idFloor, INVDEF, INVSH_GetItemByIDSilent(), NONE_AMMO, qfalse, item_s::t, and inventoryInterface_s::TryAddToInventory.

Referenced by SP_misc_item().

edict_t* G_GetFloorItems ( edict_t ent  ) 

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

Parameters:
[in] ent Pointer to an entity being an actor.
Returns:
pointer to edict_t being a floor (with items) or NULL in case no items were found on the edict grid position.

Definition at line 43 of file g_inventory.c.

References FLOOR, G_GetFloorItemsFromPos(), and edict_s::pos.

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

edict_t* G_GetFloorItemsFromPos ( const pos3_t  pos  ) 

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

Parameters:
[in] pos A position for which items are wanted.
See also:
G_GetFloorItems

Definition at line 32 of file g_inventory.c.

References ET_ITEM, and G_GetEdictFromPos().

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

static qboolean G_InventoryDropToFloorCheck ( edict_t ent,
containerIndex_t  container 
) [static]

Checks whether the given container contains items that should be dropped to the floor.

Parameters:
[in,out] ent The entity to check the inventory containers for
[in] container The container of the entity inventory to check
Returns:
true if there are items that should be dropped to floor, false otherwise

Definition at line 90 of file g_inventory.c.

References check, edict_s::chr, CONTAINER, game_import_t::csi, game, gi, character_s::i, game_locals_t::i, objDef_s::id, csi_s::idArmour, INVDEF, objDef_s::isVirtual, invList_s::item, invList_s::next, next, qfalse, qtrue, inventoryInterface_s::RemoveFromInventory, and item_s::t.

Referenced by G_InventoryToFloor().

qboolean G_InventoryRemoveItemByID ( const char *  itemID,
edict_t ent,
containerIndex_t  container 
)

Removes one particular item from a given container.

Parameters:
itemID The id of the item to remove
ent The edict that holds the inventory to remove the item from
container The 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 64 of file g_inventory.c.

References edict_s::chr, CONTAINER, G_EventInventoryDelete(), G_VisToPM(), game, gi, character_s::i, game_locals_t::i, objDef_s::id, INVDEF, invList_s::item, invList_s::next, qfalse, qtrue, inventoryInterface_s::RemoveFromInventory, item_s::t, edict_s::visflags, invList_s::x, and invList_s::y.

Referenced by G_MissionThink().

void G_InventoryToFloor ( edict_t 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] ent Pointer to an edict_t being an actor.
See also:
G_ActorDie

Definition at line 205 of file g_inventory.c.

References inventoryInterface_s::AddToInventory, item_s::amount, edict_s::chr, CONTAINER, game_import_t::csi, FLOOR, G_CheckVis(), G_EventPerish(), G_GetFloorItems(), G_InventoryDropToFloorCheck(), G_SpawnFloor(), game, gi, character_s::i, game_locals_t::i, objDef_s::id, csi_s::idArmour, csi_s::idFloor, INVDEF, invList_s::item, invList_s::next, next, NONE, edict_s::number, csi_s::numIDs, edict_s::pos, qtrue, inventoryInterface_s::RemoveFromInventory, item_s::t, and edict_s::visflags.

Referenced by G_ActorDieOrStun().

void G_ReadItem ( item_t item,
invDef_t **  container,
int *  x,
int *  y 
)

Read item from the network buffer.

Parameters:
[in,out] item item_t being send through net.
[in,out] container Container which is being updated with item sent.
[in] x Position of item in given container.
[in] y Position of item in given container.
See also:
CL_NetReceiveItem
EV_INV_TRANSFER

Definition at line 286 of file g_inventory.c.

References item_s::a, item_s::amount, game_import_t::csi, gi, INVDEF, item_s::m, m, NONE, csi_s::numODs, csi_s::ods, item_s::rotated, and item_s::t.

Referenced by G_ClientReadInventory().

void G_SendInventory ( unsigned int  playerMask,
const edict_t ent 
)

Sends whole inventory through the network buffer.

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

Definition at line 334 of file g_inventory.c.

References CONTAINER, game_import_t::csi, G_EventInventoryAdd(), G_WriteItem(), gi, INVDEF, invList_s::item, invList_s::next, csi_s::numIDs, item_s::t, invList_s::x, and invList_s::y.

Referenced by G_AppearPerishEvent(), and G_MatchSendResults().

void G_WriteItem ( const item_t item,
const invDef_t container,
int  x,
int  y 
)

Write an item to the network buffer.

Parameters:
[in,out] item item_t being send through net.
[in,out] container Container which is being updated with item sent.
[in] x Position of item in given container.
[in] y Position of item in given container.
See also:
CL_NetReceiveItem
EV_INV_TRANSFER

Definition at line 320 of file g_inventory.c.

References item_s::a, item_s::amount, gi, invDef_s::id, objDef_s::idx, item_s::m, NONE, item_s::rotated, and item_s::t.

Referenced by G_ActorInvMove(), and G_SendInventory().


Generated by  doxygen 1.6.2