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"
Go to the source code of this file.
Functions | |
const equipDef_t * | INV_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_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). | |
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] |
General actor related inventory function for are used in every game mode.
Definition in file cl_inventory.c.
CASSERT | ( | lengthof(filterTypeNames) | = =MAX_FILTERTYPES |
) |
static qboolean INV_EquipmentDefSanityCheck | ( | void | ) | [static] |
Make sure equipment definitions used to generate teams are proper.
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.
[in] | name | An id taken from scripts. |
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 | ) |
Definition at line 222 of file cl_inventory.c.
References FILTER_S_ARMOUR, FILTER_S_HEAVY, FILTER_S_MISC, FILTER_S_PRIMARY, FILTER_S_SECONDARY, objDef_s::id, INV_IsArmour, objDef_s::isHeavy, objDef_s::isMisc, objDef_s::isPrimary, objDef_s::isSecondary, and Sys_Error().
Referenced by INV_LoadWeapon(), and INV_UpdateObject_f().
const char* INV_GetFilterType | ( | const int | id | ) |
[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.
[in] | filterTypeID | Filter type name so search for. |
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 | |||
) |
Checks if the given object/item matched the given filter type.
[in] | obj | A pointer to an objDef_t item. |
[in] | filterType | Filter type to check against. |
Definition at line 248 of file cl_inventory.c.
References Com_Printf(), FILTER_AIRCRAFT, FILTER_CRAFTITEM, FILTER_DISASSEMBLY, FILTER_DUMMY, FILTER_ENSURE_32BIT, FILTER_S_ARMOUR, FILTER_S_HEAVY, FILTER_S_MISC, FILTER_S_PRIMARY, FILTER_S_SECONDARY, FILTER_UGVITEM, INV_IsArmour, INV_IsCraftItem(), INV_ItemMatchesFilter(), objDef_s::isDummy, objDef_s::isHeavy, objDef_s::isMisc, objDef_s::isPrimary, objDef_s::isSecondary, objDef_s::isUGVitem, MAX_FILTERTYPES, MAX_SOLDIER_FILTERTYPES, objDef_s::numWeapons, qfalse, qtrue, objDef_s::type, and objDef_s::weapons.
Referenced by BS_BuyType(), BS_MarketScroll_f(), INV_EquipmentDefSanityCheck(), INV_ItemMatchesFilter(), INVSH_SearchInInventoryWithFilter(), PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), PR_UpdateProductionList(), and UI_ContainerItemIteratorNext().
void INV_LoadWeapon | ( | invList_t * | weapon, | |
inventory_t * | inv, | |||
const invDef_t * | srcContainer, | |||
const invDef_t * | destContainer | |||
) |
Load a weapon with ammo.
[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.
[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. |
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.
[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. |
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).
[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). |
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().
const char* filterTypeNames[MAX_FILTERTYPES] [static] |
{ "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.
Definition at line 356 of file cl_inventory.c.