cl_inventory.c File Reference

General actor related inventory function for are used in every game mode. More...

#include "client.h"
#include "cl_inventory.h"
#include "cl_inventory_callbacks.h"
#include "../shared/parse.h"
Include dependency graph for cl_inventory.c:

Go to the source code of this file.

Functions

const equipDef_tINV_GetEquipmentDefinitionByID (const char *name)
 Gets equipment definition by id.
qboolean INV_MoveItem (inventory_t *inv, const invDef_t *toContainer, int px, int py, const invDef_t *fromContainer, invList_t *fItem)
 Move item between containers.
void INV_LoadWeapon (invList_t *weapon, inventory_t *inv, const invDef_t *srcContainer, const invDef_t *destContainer)
 Load a weapon with ammo.
qboolean INV_UnloadWeapon (invList_t *weapon, inventory_t *inv, const invDef_t *container)
 Unload a weapon and put the ammo in a container.
static qboolean INV_EquipmentDefSanityCheck (void)
 Make sure equipment definitions used to generate teams are proper.
itemFilterTypes_t INV_GetFilterFromItem (const objDef_t *obj)
qboolean INV_ItemMatchesFilter (const objDef_t *obj, const itemFilterTypes_t filterType)
 Checks if the given object/item matched the given filter type.
invList_tINVSH_SearchInInventoryWithFilter (const inventory_t *const i, const invDef_t *container, int x, int y, objDef_t *item, const itemFilterTypes_t filterType)
 Searches if there is an item at location (x/y) in a scrollable container. You can also provide an item to search for directly (x/y is ignored in that case).
 CASSERT (lengthof(filterTypeNames)==MAX_FILTERTYPES)
itemFilterTypes_t INV_GetFilterTypeID (const char *filterTypeID)
 Searches for a filter type name (as used in console functions) and returns the matching itemFilterTypes_t enum.
const char * INV_GetFilterType (const int id)
void INV_InitStartup (void)

Variables

static const char * filterTypeNames [MAX_FILTERTYPES]

Detailed Description

General actor related inventory function for are used in every game mode.

Note:
Inventory functions prefix: INV_

Definition in file cl_inventory.c.


Function Documentation

CASSERT ( lengthof(filterTypeNames = =MAX_FILTERTYPES  ) 
static qboolean INV_EquipmentDefSanityCheck ( void   )  [static]

Make sure equipment definitions used to generate teams are proper.

Note:
Check that the sum of all probabilities is smaller or equal to 100 for a weapon type.
See also:
INVSH_EquipActor

Definition at line 167 of file cl_inventory.c.

References Com_Printf(), csi, objDef_s::deplete, csi_s::eds, FILTER_S_ARMOUR, FILTER_S_HEAVY, FILTER_S_PRIMARY, FILTER_S_SECONDARY, objDef_s::fireTwoHanded, INV_ItemMatchesFilter(), INVSH_GetItemByIDX(), equipDef_s::name, csi_s::numEDs, equipDef_s::numItems, csi_s::numODs, qfalse, qtrue, objDef_s::reload, and objDef_s::weapon.

Referenced by INV_InitStartup().

const equipDef_t* INV_GetEquipmentDefinitionByID ( const char *  name  ) 

Gets equipment definition by id.

Collecting items functions.

Parameters:
[in] name An id taken from scripts.
Returns:
Found equipDef_t or NULL if no equipment definition found.

Definition at line 41 of file cl_inventory.c.

References Com_Error(), csi, csi_s::eds, ERR_DROP, i, equipDef_s::name, and csi_s::numEDs.

Referenced by B_InitialEquipment(), B_SetUpFirstBase(), BS_InitMarket(), GAME_MP_AutoTeam(), GAME_SK_ChangeEquip_f(), GAME_SK_Start_f(), GAME_Spawn(), and MP_GetEquipment().

itemFilterTypes_t INV_GetFilterFromItem ( const objDef_t obj  ) 
const char* INV_GetFilterType ( const int  id  ) 
Parameters:
[in] id The filter type index

Definition at line 398 of file cl_inventory.c.

References MAX_FILTERTYPES.

Referenced by BS_BuyAircraft_f(), BS_BuyType_f(), and PR_ProductionType_f().

itemFilterTypes_t INV_GetFilterTypeID ( const char *  filterTypeID  ) 

Searches for a filter type name (as used in console functions) and returns the matching itemFilterTypes_t enum.

Parameters:
[in] filterTypeID Filter type name so search for.
See also:
filterTypeNames.

Definition at line 375 of file cl_inventory.c.

References FILTER_S_PRIMARY, and MAX_FILTERTYPES.

Referenced by BS_BuyType_f(), and PR_ProductionType_f().

void INV_InitStartup ( void   ) 

Definition at line 405 of file cl_inventory.c.

References Cmd_AddCommand(), INV_EquipmentDefSanityCheck(), and INV_InitCallbacks().

Referenced by CL_InitLocal().

qboolean INV_ItemMatchesFilter ( const objDef_t obj,
const itemFilterTypes_t  filterType 
)
void INV_LoadWeapon ( invList_t weapon,
inventory_t inv,
const invDef_t srcContainer,
const invDef_t destContainer 
)

Load a weapon with ammo.

Parameters:
[in] weapon Pointer to weapon to load.
[in] inv Pointer to inventory where the change happen.
[in] srcContainer Pointer to inventorydef where to search ammo.
[in] destContainer Pointer to inventorydef where the weapon is.

Definition at line 94 of file cl_inventory.c.

References objDef_s::ammos, i, INV_GetFilterFromItem(), INV_MoveItem(), INVSH_SearchInInventoryWithFilter(), invList_s::item, NONE, item_s::t, invList_s::x, and invList_s::y.

Referenced by UI_ContainerNodeAutoPlace(), and UI_ContainerNodeDNDFinished().

qboolean INV_MoveItem ( inventory_t inv,
const invDef_t toContainer,
int  px,
int  py,
const invDef_t fromContainer,
invList_t fItem 
)

Move item between containers.

Parameters:
[in] inv Pointer to the list where the item is currently in.
[in] toContainer Pointer to target container, to place the item in.
[in] px target x position in the toContainer container.
[in] py target y position in the toContainer container.
[in] fromContainer Pointer to source container, the item is in.
[in] fItem Pointer to item being moved.
Note:
If you set px or py to -1/NONE the item is automatically placed on
a free spot in the targetContainer
Returns:
qtrue if the move was successful.

Definition at line 64 of file cl_inventory.c.

References cls, client_static_s::i, IA_ARMOUR, IA_MOVE, inventoryInterface_s::MoveInInventory, qfalse, qtrue, SHAPE_BIG_MAX_HEIGHT, and SHAPE_BIG_MAX_WIDTH.

Referenced by INV_LoadWeapon(), UI_ContainerNodeAutoPlace(), and UI_ContainerNodeDNDFinished().

qboolean INV_UnloadWeapon ( invList_t weapon,
inventory_t inv,
const invDef_t container 
)

Unload a weapon and put the ammo in a container.

Parameters:
[in] weapon Pointer (invList_t) to weapon to unload ammo.
[in] inv Pointer (inventory_t) to inventory where the change happen.
[in] container Pointer (invDef_t) to inventorydef where to put the removed ammo.
Returns:
true if the unload was successful, false otherwise

Definition at line 119 of file cl_inventory.c.

References item_s::a, inventoryInterface_s::AddToInventory, cls, client_static_s::i, invList_s::item, item_s::m, NONE, NONE_AMMO, qfalse, and qtrue.

Referenced by UI_ContainerNodeAutoPlace(), and UI_ContainerNodeDNDFinished().

invList_t* INVSH_SearchInInventoryWithFilter ( const inventory_t *const   i,
const invDef_t container,
int  x,
int  y,
objDef_t item,
const itemFilterTypes_t  filterType 
)

Searches if there is an item at location (x/y) in a scrollable container. You can also provide an item to search for directly (x/y is ignored in that case).

Note:
x = x-th item in a row, y = row. i.e. x/y does not equal the "grid" coordinates as used in those containers.
Parameters:
[in] i Pointer to the inventory where we will search.
[in] container Container in the inventory.
[in] x/y Position in the scrollable container that you want to check. Ignored if "item" is set.
[in] item The item to search. Will ignore "x" and "y" if set, it'll also search invisible items.
[in] filterType Enum definition of type (types of items for filtering purposes).
Returns:
invList_t Pointer to the invList_t/item that is located at x/y or equals "item".
See also:
INVSH_SearchInInventory

Definition at line 334 of file cl_inventory.c.

References inventory_s::c, invDef_s::id, INV_ItemMatchesFilter(), invList_s::item, MAX_FILTERTYPES, invList_s::next, and item_s::t.

Referenced by INV_LoadWeapon(), and UI_ContainerNodeGetExistingItem().


Variable Documentation

const char* filterTypeNames[MAX_FILTERTYPES] [static]
Initial value:
 {
    "primary",      
    "secondary",    
    "heavy",        
    "misc",         
    "armour",       
    "",             
    "craftitem",    
    "ugvitem",      
    "aircraft",     
    "dummy",        
    "disassembly"   
}

Names of the filter types as used in console function. e.g. in .ufo files.

See also:
inv_shared.h:itemFilterTypes_t

Definition at line 356 of file cl_inventory.c.


Generated by  doxygen 1.6.2