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)
271 if (index < 0 || index >= CSI->
numODs)
272 Sys_Error(
"Invalid object index given: %i", index);
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;
481 if (w >= SHAPE_SMALL_MAX_HEIGHT) {
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];
669 return &CSI->
ids[
id];
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]);
static uint32_t INVSH_ShapeSetBit(uint32_t shape, const int x, const int y)
Sets one bit in a shape to true/1.
#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.
#define VectorCopy(src, dest)
const objDef_t * _itemDef
Item()
Item constructor with all default values.
const objDef_t * getReactionFireWeaponType() const
Checks whether this item is a reaction fire enabled weapon.
void Sys_Error(const char *error,...)
void setAmmoLeft(int value)
const implantDef_t * INVSH_GetImplantByIDSilent(const char *id)
Returns the implant that belongs to the given id or nullptr if it wasn't found.
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 isCraftItem() const
Checks whether a given item is an aircraftitem item.
void getShotOrigin(const vec3_t from, const vec3_t dir, bool crouching, vec3_t shotOrigin) const
const fireDef_t * getFastestFireDef() const
bool isBaseDefenceItem() const
Checks whether the item is a basedefence item.
this is a fire definition for our weapons/ammo
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...
weaponFireDefIndex_t weapFdsIdx
Item * getContainer2(const containerIndex_t idx) const
void addClip(const Item *item)
Combine the rounds of partially used clips.
const fireDef_t * getFiredefs() const
Returns the firedefinitions for a given weapon/ammo.
Item * getLeftHandContainer() const
bool isRightDef() const
Checks whether the inventory definition is the right Hand.
const objDef_t * def(void) const
const vec4_t dvecs[PATHFINDING_DIRECTIONS]
invDef_t ids[MAX_INVDEFS]
bool isLeftDef() const
Checks whether a given inventory definition is of special type.
fireDef_t fd[MAX_WEAPONS_PER_OBJDEF][MAX_FIREDEFS_PER_WEAPON]
int countItems() const
Count the number of items in the inventory (without temp containers)
static int cacheCheckToInventory
void Com_Printf(const char *const fmt,...)
Item * getHeadgear() const
bool isSameAs(const Item *const other) const
Check if the (physical) information of 2 items is exactly the same.
Defines all attributes of objects used in the inventory.
bool holdsReactionFireWeapon() const
Checks if there is a weapon in the hands that can be used for reaction fire.
int getWeight() const
Return the weight of an item.
implantDef_t implants[MAX_IMPLANTS]
Item * getFloorContainer() const
bool containsItem(const containerIndex_t contId, const Item *const item) const
Searches if there is a specific item already in the inventory&container.
int AngleToDir(int angle)
Returns the index of array directionAngles[DIRECTIONS] whose value is the closest to angle...
Item * findInContainer(const containerIndex_t contId, const Item *const item) const
Searches a specific item in the inventory&container.
item instance data, with linked list capability
void getFirstShapePosition(int *const x, int *const y) const
Calculates the first "true" bit in the shape and returns its position in the item.
Item * getHolsterContainer() const
inventory definition with all its containers
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.
fireDefIndex_t numFiredefs[MAX_WEAPONS_PER_OBJDEF]
#define SHAPE_BIG_MAX_WIDTH
32 bit mask
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.
Item * getRightHandContainer() const
QGL_EXTERN GLuint GLsizei GLsizei * length
The csi structure is the client-server-information structure which contains all the static data neede...
int getWeight() const
Get the weight of the items in the given inventory (excluding those in temp containers).
#define MAX_WEAPONS_PER_OBJDEF
const invDef_t * INVSH_GetInventoryDefinitionByID(const char *id)
#define MAX_FIREDEFS_PER_WEAPON
#define SHAPE_SMALL_MAX_WIDTH
The max width and height of an item-shape.
int canHoldItem(const invDef_t *container, const objDef_t *od, const int x, const int y, const Item *ignoredItem) const
uint32_t getShapeRotated() const
Rotates a shape definition 90 degree to the left (CCW)
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.
const invDef_t * def() const
int countItems() const
Count the number of items in the Container.
Item * getEquipContainer() const
Item * getNextItem(const Item *prev) const
const implantDef_t * INVSH_GetImplantForObjDef(const objDef_t *od)
const Container & getContainer(const containerIndex_t idx) const
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. ...
int32_t weaponFireDefIndex_t
Container _containers[MAX_CONTAINERS]
uint32_t shape[SHAPE_BIG_MAX_HEIGHT]
bool isLoadableInWeapon(const objDef_s *weapon) const
Checks if an item can be used to reload a weapon.
bool isFloorDef() const
Checks whether the inventory definition is the floor.
const Container * getNextCont(const Container *prev, bool inclTemp=false) const
int numItems[MAX_OBJDEFS]
void setAmmoDef(const objDef_t *od)
int getNumFiredefs() const
void setFloorContainer(Item *cont)
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 * getImplantContainer() const
bool isHeldTwoHanded() const
bool isArmourDef() const
Checks whether a given inventory definition is of special type.
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).
const objDef_t * ammoDef(void) const
inventory definition for our menus
void setAmount(int value)
byte numItemsLoose[MAX_OBJDEFS]
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.
objDef_t ods[MAX_OBJDEFS]
bool isEquipDef() const
Checks whether a given inventory definition is of special type.
const fireDef_t * getSlowestFireDef() const
Get the firedef that uses the most TU for this item.
const Container * _getNextCont(const Container *prev) const
void INVSH_InitCSI(const csi_t *import)
Initializes client server shared data pointer. This works because the client and the server are both ...
const struct objDef_s * item
#define SHAPE_SMALL_MAX_HEIGHT
void setContainer(const containerIndex_t idx, Item *cont)
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.
const struct objDef_s * weapons[MAX_WEAPONS_PER_OBJDEF]
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...