UFO: Alien Invasion
|
Common object-, inventory-, container- and firemode-related functions. More...
#include "q_shared.h"
Go to the source code of this file.
Functions | |
void | INVSH_InitCSI (const csi_t *import) |
Initializes client server shared data pointer. This works because the client and the server are both using exactly the same pointer. More... | |
static bool | INVSH_CheckShapeCollision (const uint32_t *shape, const uint32_t itemShape, const int x, const int y) |
Will check if the item-shape is colliding with something else in the container-shape at position x/y. More... | |
static bool | INVSH_CheckToInventory_shape (const Inventory *const inv, const invDef_t *container, const uint32_t itemShape, const int x, const int y, const Item *ignoredItem) |
Checks if an item-shape can be put into a container at a certain position... ignores any 'special' types of containers. More... | |
static bool | INVSH_CheckShapeSmall (const uint32_t shape, const int x, const int y) |
Checks the shape if there is a 1-bit on the position x/y. More... | |
static bool | INVSH_ShapeCheckPosition (const Item *item, const int x, const int y) |
Check if a position in a container is used by an item (i.e. collides with the shape). More... | |
const objDef_t * | INVSH_GetItemByIDSilent (const char *id) |
Returns the item that belongs to the given id or nullptr if it wasn't found. More... | |
const objDef_t * | INVSH_GetItemByIDX (int index) |
Returns the item that belongs to the given index or nullptr if the index is invalid. More... | |
const objDef_t * | INVSH_GetItemByID (const char *id) |
Returns the item that belongs to the given id or nullptr if it wasn't found. More... | |
const implantDef_t * | INVSH_GetImplantForObjDef (const objDef_t *od) |
const implantDef_t * | INVSH_GetImplantByIDSilent (const char *id) |
Returns the implant that belongs to the given id or nullptr if it wasn't found. More... | |
const implantDef_t * | INVSH_GetImplantByID (const char *id) |
Returns the implant that belongs to the given id or nullptr if it wasn't found. More... | |
const invDef_t * | INVSH_GetInventoryDefinitionByID (const char *id) |
const fireDef_t * | FIRESH_GetFiredef (const objDef_t *obj, const weaponFireDefIndex_t weapFdsIdx, const fireDefIndex_t fdIdx) |
Get the fire definitions for a given object. More... | |
void | INVSH_MergeShapes (uint32_t *shape, const uint32_t itemShape, const int x, const int y) |
Will merge the second shape (=itemShape) into the first one (=big container shape) on the position x/y. More... | |
bool | INVSH_CheckShape (const uint32_t *shape, const int x, const int y) |
Checks the shape if there is a 1-bit on the position x/y. More... | |
int | INVSH_ShapeSize (const uint32_t shape) |
Counts the used bits in a shape (item shape). More... | |
static uint32_t | INVSH_ShapeSetBit (uint32_t shape, const int x, const int y) |
Sets one bit in a shape to true/1. More... | |
Variables | |
static const csi_t * | CSI |
static int | cacheCheckToInventory = INV_DOES_NOT_FIT |
Common object-, inventory-, container- and firemode-related functions.
Definition in file inv_shared.cpp.
const fireDef_t* FIRESH_GetFiredef | ( | const objDef_t * | obj, |
const weaponFireDefIndex_t | weapFdsIdx, | ||
const fireDefIndex_t | fdIdx | ||
) |
Get the fire definitions for a given object.
[in] | obj | The object to get the firedef for |
[in] | weapFdsIdx | the weapon index in the fire definition array |
[in] | fdIdx | the fire definition index for the weapon (given by weapFdsIdx ) |
Definition at line 385 of file inv_shared.cpp.
References objDef_s::fd, objDef_s::id, MAX_FIREDEFS_PER_WEAPON, MAX_WEAPONS_PER_OBJDEF, and Sys_Error().
Referenced by CL_ActorDoShoot(), CL_ActorDoShootTime(), CL_ActorDoThrow(), CL_ActorShootHidden(), CL_ActorShootHiddenTime(), and HUD_UpdateActorFireMode().
Checks the shape if there is a 1-bit on the position x/y.
[in] | shape | Pointer to 'uint32_t shape[SHAPE_BIG_MAX_HEIGHT]' |
[in] | x | The x value in the container (1 << x in the shape bitmask) |
[in] | y | The y value in the container (SHAPE_BIG_MAX_HEIGHT is the max) |
Definition at line 414 of file inv_shared.cpp.
References Com_Printf(), f, SHAPE_BIG_MAX_HEIGHT, and SHAPE_BIG_MAX_WIDTH.
Referenced by UI_ContainerNodeDrawFreeSpace().
|
static |
Will check if the item-shape is colliding with something else in the container-shape at position x/y.
[in] | shape | The shape of the container [SHAPE_BIG_MAX_HEIGHT] |
[in] | itemShape | The shape of the item [SHAPE_SMALL_MAX_HEIGHT] |
[in] | x | The x value in the container (1 << x in the shape bitmask) |
[in] | y | The y value in the container (SHAPE_BIG_MAX_HEIGHT is the max) |
Definition at line 99 of file inv_shared.cpp.
References Com_DPrintf(), DEBUG_SHARED, i, SHAPE_BIG_MAX_HEIGHT, SHAPE_SMALL_MAX_HEIGHT, and SHAPE_SMALL_MAX_WIDTH.
Referenced by INVSH_CheckToInventory_shape().
Checks the shape if there is a 1-bit on the position x/y.
[in] | shape | The shape to check in. (8x4) |
[in] | x | The x value in the shape (1 << x in the shape bitmask) |
[in] | y | The y value in the shape (SHAPE_SMALL_MAX_HEIGHT is the max) |
Definition at line 188 of file inv_shared.cpp.
References SHAPE_SMALL_MAX_HEIGHT, and SHAPE_SMALL_MAX_WIDTH.
Referenced by objDef_s::getShapeRotated(), and INVSH_ShapeCheckPosition().
|
static |
Checks if an item-shape can be put into a container at a certain position... ignores any 'special' types of containers.
[in] | inv | The inventory |
[in] | container | The container (index) to look into. |
[in] | itemShape | The shape info of an item to fit into the container. |
[in] | x | The x value in the container (1 << x in the shape bitmask) |
[in] | y | The y value in the container (SHAPE_BIG_MAX_HEIGHT is the max) |
[in] | ignoredItem | You can ignore one item in the container (most often the currently dragged one). Use nullptr if you want to check against all items in the container. |
Definition at line 142 of file inv_shared.cpp.
References cacheCheckToInventory, Item::def(), Inventory::getContainer(), objDef_s::getShapeRotated(), Item::getX(), Item::getY(), invDef_s::id, INVSH_CheckShapeCollision(), INVSH_MergeShapes(), Item::rotated, invDef_s::scroll, objDef_s::shape, invDef_s::shape, SHAPE_BIG_MAX_HEIGHT, SHAPE_BIG_MAX_WIDTH, and Sys_Error().
Referenced by Inventory::canHoldItem().
const implantDef_t* INVSH_GetImplantByID | ( | const char * | id | ) |
Returns the implant that belongs to the given id or nullptr
if it wasn't found.
[in] | id | the implant id in our implant definition array (csi.implants) |
Definition at line 326 of file inv_shared.cpp.
References Com_Printf(), and INVSH_GetImplantByIDSilent().
Referenced by GAME_LoadCharacter().
const implantDef_t* INVSH_GetImplantByIDSilent | ( | const char * | id | ) |
Returns the implant that belongs to the given id or nullptr
if it wasn't found.
[in] | id | the implant id in our implant definition array (csi.implants) |
Definition at line 307 of file inv_shared.cpp.
References i, implantDef_s::id, csi_s::implants, csi_s::numImplants, and Q_streq.
Referenced by INVSH_GetImplantByID().
const implantDef_t* INVSH_GetImplantForObjDef | ( | const objDef_t * | od | ) |
Definition at line 291 of file inv_shared.cpp.
References Com_Printf(), i, objDef_s::id, csi_s::implants, implantDef_s::item, and csi_s::numImplants.
Referenced by HOS_ImplantDetails_f().
const invDef_t* INVSH_GetInventoryDefinitionByID | ( | const char * | id | ) |
Searched an inventory container by a given container id
[in] | id | ID or name of the inventory container to search for |
nullptr
if not found Definition at line 340 of file inv_shared.cpp.
References CID_MAX, i, csi_s::ids, invDef_s::name, and Q_streq.
Referenced by uiBaseInventoryNode::onLoaded(), uiContainerNode::onLoaded(), and TEST_F().
const objDef_t* INVSH_GetItemByID | ( | const char * | id | ) |
Returns the item that belongs to the given id or nullptr
if it wasn't found.
[in] | id | the item id in our object definition array (csi.ods) |
Definition at line 282 of file inv_shared.cpp.
References Com_Printf(), and INVSH_GetItemByIDSilent().
Referenced by AII_AddAmmoToSlot(), AII_AddItemToSlot(), AIM_AircraftEquipAddItem_f(), AIM_AutoEquipAircraft(), AIM_CheckTechnologyIntoSlot(), AIM_CrafttypeFilter(), AIM_SelectableCraftItem(), AIM_UpdateAircraftItemList(), AIR_ParseAircraft(), AIR_Refuel(), AIRFIGHT_LoadXML(), B_AntimatterInBase(), B_LoadStorageXML(), B_UpdateAntimatterCap(), BDEF_AddItem_f(), BS_Buy_f(), BS_BuyUGV(), BS_FillMarket_f(), BS_LoadXML(), BS_SellUGV(), BS_SetAutosell_f(), BS_ShowInfo_f(), Com_AddObjectLinks(), Com_ParseEquipment(), Com_ParseImplant(), Com_ParseTeam(), COMP_ParseComponents(), CP_CleanupAircraftTeam(), CP_CleanupTeam(), GAME_AppendTeamMember(), GAME_LoadItem(), GAME_LoadTeam(), PR_LoadXML(), PR_RequirementsInfo(), RS_AssignTechLinks(), TEST_F(), TR_Add_f(), TR_CargoList(), TR_FillItems(), TR_List_f(), UP_Article(), UP_DrawAssociatedAmmo(), and UP_ResearchedLinkClick_f().
const objDef_t* INVSH_GetItemByIDSilent | ( | const char * | id | ) |
Returns the item that belongs to the given id or nullptr
if it wasn't found.
[in] | id | the item id in our object definition array (csi.ods) |
Definition at line 249 of file inv_shared.cpp.
References i, objDef_s::id, csi_s::numODs, csi_s::ods, and Q_streq.
Referenced by ItemCargo::add(), AIM_UpdateItemDescription(), B_AddAntimatter(), BDEF_SelectItem_f(), Com_ParseImplant(), Com_ParseItem(), COMP_ParseComponents(), CP_AddItemAsCollected_f(), uiItemNode::draw(), G_AddItemToFloor(), INVSH_GetItemByID(), TEST_F(), and UP_TechGetsDisplayed().
Returns the item that belongs to the given index or nullptr
if the index is invalid.
Definition at line 266 of file inv_shared.cpp.
References index, NONE, csi_s::numODs, csi_s::ods, and Sys_Error().
Referenced by AII_GetCraftitemTechsByType(), B_SaveStorageXML(), BS_InitMarket(), BS_SaveXML(), CAP_UpdateStorageCap(), CL_ActorDoShoot(), CL_ActorDoShootTime(), CL_ActorDoThrow(), CL_ActorReactionFireChange(), CL_ActorShootHidden(), CL_ActorShootHiddenTime(), CL_AddActorWeapon(), CL_InvAmmo(), CL_InvReload(), CL_NetReceiveItem(), CL_ViewPrecacheModels(), Com_AddObjectLinks(), CP_AddWeaponAmmo(), CP_CampaignRunMarket(), CP_ItemsSanityCheck(), InventoryInterface::EquipActorNormal(), G_ClientAction(), G_ClientInitActorStates(), GAME_SaveTeam(), HOS_ImplantDetails_f(), HUD_ShotReserve_f(), INV_EquipmentDefSanityCheck(), INV_UpdateObject_f(), LE_GetAnim(), InventoryInterface::PackAmmoAndWeapon(), RS_InitTree(), S_PrecacheSamples(), TEST_F(), TR_FillItems(), UI_BaseInventoryNodeDrawItems(), UI_BaseInventoryNodeGetItem(), UI_ContainerItemIteratorNext(), UI_ContainerNodeUpdateEquipment(), and UP_Article().
Initializes client server shared data pointer. This works because the client and the server are both using exactly the same pointer.
[in] | import | The client server interface pointer |
Definition at line 39 of file inv_shared.cpp.
Referenced by Com_ParseScripts(), G_Init(), and GAME_CP_InitStartup().
Will merge the second shape (=itemShape) into the first one (=big container shape) on the position x/y.
[in] | shape | The shape of the container [SHAPE_BIG_MAX_HEIGHT]' |
[in] | itemShape | The shape of the item [SHAPE_SMALL_MAX_HEIGHT] |
[in] | x | The x value in the container (1 << x in the shape bitmask) |
[in] | y | The y value in the container (SHAPE_BIG_MAX_HEIGHT is the max) |
Definition at line 402 of file inv_shared.cpp.
References i, SHAPE_BIG_MAX_HEIGHT, SHAPE_SMALL_MAX_HEIGHT, and SHAPE_SMALL_MAX_WIDTH.
Referenced by INVSH_CheckToInventory_shape(), and UI_ContainerNodeDrawFreeSpace().
Check if a position in a container is used by an item (i.e. collides with the shape).
[in] | item | A pointer to the Item in question. |
[in] | x,y | The location in the container. |
Definition at line 203 of file inv_shared.cpp.
References Item::def(), objDef_s::getShapeRotated(), Item::getX(), Item::getY(), INVSH_CheckShapeSmall(), Item::rotated, and objDef_s::shape.
Referenced by Item::getFirstShapePosition(), and Inventory::getItemAtPos().
Sets one bit in a shape to true/1.
[in] | shape | The shape to modify. (8x4) |
[in] | x | The x (width) position of the bit to set. |
[in] | y | The y (height) position of the bit to set. |
Definition at line 455 of file inv_shared.cpp.
References Com_Printf(), SHAPE_SMALL_MAX_HEIGHT, and SHAPE_SMALL_MAX_WIDTH.
Referenced by objDef_s::getShapeRotated().
int INVSH_ShapeSize | ( | const uint32_t | shape | ) |
Counts the used bits in a shape (item shape).
[in] | shape | The shape to count the bits in. |
Definition at line 435 of file inv_shared.cpp.
References i, SHAPE_SMALL_MAX_HEIGHT, and SHAPE_SMALL_MAX_WIDTH.
Referenced by LE_BiggestItem().
|
static |
Definition at line 89 of file inv_shared.cpp.
Referenced by Inventory::findSpace(), and INVSH_CheckToInventory_shape().
|
static |
Definition at line 30 of file inv_shared.cpp.