39 gi.DPrintf(
"Could not find the equipment with the id: '%s'\n", equipID);
85 if (item !=
nullptr &&
Q_streq(item->
id, itemID)) {
88 gi.Error(
"Could not remove item '%s' from inventory %i",
89 ic->
def()->
id, container);
123 gi.Error(
"Could not remove virtual item '%s' from inventory %i",
124 ic->
def()->
id, container);
144 gi.DPrintf(
"Could not find item '%s'\n", itemID);
163 static bool G_InventoryPlaceItemAdjacent (
Edict* ent)
169 Edict* floorAdjacent =
nullptr;
179 if (!floorAdjacent) {
202 if (i < DIRECTIONS) {
259 for (ic = ent->
getContainer(container); ic; ic = next) {
269 gi.Error(
"Could not remove item '%s' from inventory %i of entity %i",
273 gi.Error(
"Could not add item '%s' from inventory %i of entity %i to floor container",
276 G_InventoryPlaceItemAdjacent(ent);
304 gi.ReadFormat(
"sbsbbbbs", &t, &ammoleft, &m, &containerID, x, y, &item->
rotated, &amount);
309 gi.Error(
"Item index out of bounds: %i", t);
314 gi.Error(
"Ammo index out of bounds: %i", m);
321 *container =
INVDEF(containerID);
323 gi.Error(
"container id is out of bounds: %i", containerID);
371 const Item* item =
nullptr;
Edict * G_SpawnFloor(const pos3_t pos)
Spawns a new entity at the floor.
const objDef_t * INVSH_GetItemByIDSilent(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
bool tryAddToInventory(Inventory *const inv, const Item *const item, const invDef_t *container)
Tries to add an item to a container (in the inventory inv).
void setAmmoLeft(int value)
void G_CheckVis(Edict *check, const vischeckflags_t visFlags)
Check if the edict appears/perishes for the other teams. If they appear for other teams...
Edict * G_GetEdictFromPos(const pos3_t pos, const entity_type_t type)
Searches an edict of the given type at the given grid location.
Misc utility functions for game module.
bool G_InventoryRemoveItemByID(const char *itemID, Edict *ent, containerIndex_t container)
Removes one particular item from a given container.
static bool G_InventoryDropToFloorCheck(Edict *ent, containerIndex_t container)
Checks whether the given container contains items that should be dropped to the floor. Also removes virtual items.
unsigned int playermask_t
const objDef_t * def(void) const
const vec4_t dvecs[PATHFINDING_DIRECTIONS]
equipDef_t eds[MAX_EQUIPDEFS]
void G_SendInventory(playermask_t playerMask, const Edict &ent)
Sends whole inventory through the network buffer.
void setDef(const objDef_t *objDef)
Defines all attributes of objects used in the inventory.
Item * getContainer(const containerIndex_t idx) const
item instance data, with linked list capability
void G_InventoryToFloor(Edict *ent)
Move items to adjacent locations if the containers on the current floor edict are full...
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 setFloor(const Edict *other)
#define Vector2Set(v, x, y)
void G_ReadItem(Item *item, const invDef_t **container, int *x, int *y)
Read item from the network buffer.
Edict * G_GetFloorItemFromPos(const pos3_t pos)
Callback to G_GetEdictFromPos() for given position, used to get items from position.
playermask_t G_VisToPM(teammask_t teamMask)
Converts vis mask to player mask.
#define INVDEF(containerID)
int countItems() const
Count the number of items in the Container.
const equipDef_t * G_GetEquipDefByID(const char *equipID)
Item * getNextItem(const Item *prev) const
void G_WriteItem(const Item &item, const containerIndex_t contId, int x, int y)
Write an item to the network buffer.
Item * addToInventory(Inventory *const inv, const Item *const item, const invDef_t *container, int x, int y, int amount) __attribute__((warn_unused_result))
Add an item to a specified container in a given inventory.
bool G_AddItemToFloor(const pos3_t pos, const char *itemID)
Adds a new item to an existing or new floor container edict at the given grid location.
void G_VisFlagsReset(Edict &ent)
void G_EventInventoryDelete(const Edict &ent, playermask_t playerMask, const containerIndex_t containerId, int x, int y)
Tell the client to remove the item from the container.
const Container * getNextCont(const Container *prev, bool inclTemp=false) const
Brings new objects into the world.
void setAmmoDef(const objDef_t *od)
void setFloorContainer(Item *cont)
void G_EventPerish(const Edict &ent)
Send an event to all clients that are seeing the given edict, that it just has disappeared.
void G_EventInventoryAdd(const Edict &ent, playermask_t playerMask, int itemAmount)
Tell the client to add the item from the container.
const objDef_t * ammoDef(void) const
inventory definition for our menus
#define Vector2Copy(src, dest)
#define DIRECTIONS
Number of angles from a position (2-dimensional)
void setAmount(int value)
bool isValidContId(const containerIndex_t id)
objDef_t ods[MAX_OBJDEFS]
Edict * G_GetFloorItems(Edict *ent)
Prepares a list of items on the floor at given entity position.
void resetContainer(const containerIndex_t idx)
Interface for g_client.cpp.
bool removeFromInventory(Inventory *const inv, const invDef_t *container, Item *fItem) __attribute__((warn_unused_result))