102 if (x < 0 || y < 0) {
111 const uint32_t itemRowShifted = itemRow << x;
114 if (itemRowShifted >> x != itemRow)
124 if (itemRowShifted & shape[y +
i])
149 Sys_Error(
"INVSH_CheckToInventory_shape: No scrollable container will ever use this. This type does not support grid-packing!");
158 mask[j] = ~container->
shape[j];
162 Item* item =
nullptr;
163 while ((item = cont.getNextItem(item))) {
164 if (ignoredItem == item)
286 Com_Printf(
"INVSH_GetItemByID: Item \"%s\" not found.\n",
id);
298 Com_Printf(
"INVSH_GetImplantForObjDef: could not get implant for %s\n", od->
id);
330 Com_Printf(
"INVSH_GetImplantByID: Implant \"%s\" not found.\n",
id);
388 Sys_Error(
"FIRESH_GetFiredef: weapFdsIdx out of bounds [%i] for item '%s'", weapFdsIdx, obj->
id);
390 Sys_Error(
"FIRESH_GetFiredef: fdIdx out of bounds [%i] for item '%s'", fdIdx, obj->
id);
417 Com_Printf(
"INVSH_CheckShape: Bad x or y value: (x=%i, y=%i)\n", x, y);
421 const uint32_t row = shape[y];
422 const int position = powf(2.0
f, (
float)x);
423 if ((row & position) == 0)
440 if (shape & (1 <<
i))
458 Com_Printf(
"INVSH_ShapeSetBit: Bad x or y value: (x=%i, y=%i)\n", x,y);
474 uint32_t shapeNew = 0;
541 if (other ==
nullptr)
591 return &ammodef->
fd[
i][0];
615 if (fdArray ==
nullptr)
619 if (fdArray[
i].time > fdArray[slowest].time)
622 return &fdArray[slowest];
628 int fastestTime = 999;
631 if (fdArray ==
nullptr)
634 for (
int i = 0;
i < fdCount; ++
i)
635 if (fastestTime > fdArray[
i].time) {
636 fastestTime = fdArray[
i].
time;
640 return fastest == -1 ?
nullptr : &fdArray[fastest];
684 Item* item =
nullptr;
768 if (!container->
armour && !container->
all) {
775 }
else if (container->
armour) {
817 Com_DPrintf(
DEBUG_SHARED,
"canHoldItem: INFO: Moving to 'single' container but item would not fit normally.\n");
853 Sys_Error(
"getItemAtPos: Scrollable containers (%i:%s) are not supported by this function.", container->
id, container->
name);
857 Item* item =
nullptr;
891 const int checkedTo =
canHoldItem(container, item->
def(), x, y, ignoredItem);
930 return (maxWeight < 0 || maxWeight * WEIGHT_FACTOR >= invWeight + itemWeight);
942 Item* item =
nullptr;
1004 Item* item =
nullptr;
1055 const float x = dvec[1];
1056 const float y = -dvec[0];
1057 const float length = sqrt(dvec[0] * dvec[0] + dvec[1] * dvec[1]);
Item * getEquipContainer() const
static uint32_t INVSH_ShapeSetBit(uint32_t shape, const int x, const int y)
Sets one bit in a shape to true/1.
const objDef_t * def(void) const
int getNumFiredefs() const
#define SHAPE_BIG_MAX_HEIGHT
defines the max height of an inventory container
const objDef_t * INVSH_GetItemByIDSilent(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
const objDef_t * getReactionFireWeaponType() const
Checks whether this item is a reaction fire enabled weapon.
bool isArmourDef() const
Checks whether a given inventory definition is of special type.
#define VectorCopy(src, dest)
void Sys_Error(const char *error,...)
uint32_t getShapeRotated() const
Rotates a shape definition 90 degree to the left (CCW)
const implantDef_t * INVSH_GetImplantByIDSilent(const char *id)
Returns the implant that belongs to the given id or nullptr if it wasn't found.
Item * getLeftHandContainer() const
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
bool isFloorDef() const
Checks whether the inventory definition is the floor.
bool canHoldItemWeight(containerIndex_t from, containerIndex_t to, const Item &item, int maxWeight) const
Check that adding an item to the inventory won't exceed the max permitted weight. ...
bool isSameAs(const Item *const other) const
Check if the (physical) information of 2 items is exactly the same.
void setFloorContainer(Item *cont)
Item * getRightHandContainer() const
int INVSH_ShapeSize(const uint32_t shape)
Counts the used bits in a shape (item shape).
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...
Container _containers[MAX_CONTAINERS]
bool isEquipDef() const
Checks whether a given inventory definition is of special type.
const fireDef_t * getFiredefs() const
Returns the firedefinitions for a given weapon/ammo.
void setContainer(const containerIndex_t idx, Item *cont)
int canHoldItem(const invDef_t *container, const objDef_t *od, const int x, const int y, const Item *ignoredItem) const
Item * getItemAtPos(const invDef_t *container, const int x, const int y) const
Searches if there is an item at location (x,y) in a container.
Item * getNextItem(const Item *prev) const
Item * findInContainer(const containerIndex_t contId, const Item *const item) const
Searches a specific item in the inventory&container.
Item * getHeadgear() const
const vec4_t dvecs[PATHFINDING_DIRECTIONS]
void getShotOrigin(const vec3_t from, const vec3_t dir, bool crouching, vec3_t shotOrigin) const
Item()
Item constructor with all default values.
uint32_t shape[SHAPE_BIG_MAX_HEIGHT]
static int cacheCheckToInventory
void Com_Printf(const char *const fmt,...)
const objDef_t * ammoDef(void) const
inventory definition for our menus
const fireDef_t * getFastestFireDef() const
bool isBaseDefenceItem() const
Checks whether the item is a basedefence item.
bool isLoadableInWeapon(const objDef_s *weapon) const
Checks if an item can be used to reload a weapon.
int AngleToDir(int angle)
Returns the index of array directionAngles[DIRECTIONS] whose value is the closest to angle...
Item * getFloorContainer() const
const Container * _getNextCont(const Container *prev) const
bool isLeftDef() const
Checks whether a given inventory definition is of special type.
const invDef_t * def() const
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/...
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.
void setAmount(int value)
void setAmmoDef(const objDef_t *od)
#define SHAPE_BIG_MAX_WIDTH
32 bit mask
QGL_EXTERN GLuint GLsizei GLsizei * length
void addClip(const Item *item)
Combine the rounds of partially used clips.
#define MAX_WEAPONS_PER_OBJDEF
const invDef_t * INVSH_GetInventoryDefinitionByID(const char *id)
#define MAX_FIREDEFS_PER_WEAPON
bool isHeldTwoHanded() const
Item * getImplantContainer() const
int countItems() const
Count the number of items in the inventory (without temp containers)
byte numItemsLoose[MAX_OBJDEFS]
#define SHAPE_SMALL_MAX_WIDTH
The max width and height of an item-shape.
item instance data, with linked list capability
bool isRightDef() const
Checks whether the inventory definition is the right Hand.
Item * getContainer2(const containerIndex_t idx) const
const implantDef_t * INVSH_GetImplantByID(const char *id)
Returns the implant that belongs to the given id or nullptr if it wasn't found.
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
int numItems[MAX_OBJDEFS]
implantDef_t implants[MAX_IMPLANTS]
int countItems() const
Count the number of items in the Container.
invDef_t ids[MAX_INVDEFS]
const Container * getNextCont(const Container *prev, bool inclTemp=false) const
int getWeight() const
Return the weight of an item.
const struct objDef_s * weapons[MAX_WEAPONS_PER_OBJDEF]
objDef_t ods[MAX_OBJDEFS]
const implantDef_t * INVSH_GetImplantForObjDef(const objDef_t *od)
int32_t weaponFireDefIndex_t
void findSpace(const invDef_t *container, const Item *item, int *const px, int *const py, const Item *ignoredItem) const
Finds space for item in inv at container.
void getFirstShapePosition(int *const x, int *const y) const
Calculates the first "true" bit in the shape and returns its position in the item.
The csi structure is the client-server-information structure which contains all the static data neede...
bool holdsReactionFireWeapon() const
Checks if there is a weapon in the hands that can be used for reaction fire.
weaponFireDefIndex_t weapFdsIdx
fireDefIndex_t numFiredefs[MAX_WEAPONS_PER_OBJDEF]
inventory definition with all its containers
const Container & getContainer(const containerIndex_t idx) const
Defines all attributes of objects used in the inventory.
int getWeight() const
Get the weight of the items in the given inventory (excluding those in temp containers).
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).
this is a fire definition for our weapons/ammo
bool containsItem(const containerIndex_t contId, const Item *const item) const
Searches if there is a specific item already in the inventory&container.
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
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.
Item * getHolsterContainer() const
fireDef_t fd[MAX_WEAPONS_PER_OBJDEF][MAX_FIREDEFS_PER_WEAPON]
void INVSH_InitCSI(const csi_t *import)
Initializes client server shared data pointer. This works because the client and the server are both ...
const objDef_t * _itemDef
const fireDef_t * getSlowestFireDef() const
Get the firedef that uses the most TU for this item.
void setAmmoLeft(int value)
#define SHAPE_SMALL_MAX_HEIGHT
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.
bool isCraftItem() const
Checks whether a given item is an aircraftitem item.
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' ty...