27 #include "../common/common.h"
28 #include "../game/inventory.h"
80 ASSERT_TRUE(
nullptr != od);
83 ASSERT_TRUE(
nullptr != container);
102 ASSERT_TRUE(
nullptr != od);
105 ASSERT_TRUE(
nullptr != container);
124 const invDef_t* container, *containerTo;
128 ASSERT_TRUE(
nullptr != od);
131 ASSERT_TRUE(
nullptr != container);
138 ASSERT_TRUE(
nullptr != addedItem);
143 ASSERT_TRUE(
nullptr != containerTo);
148 ASSERT_TRUE(inv.
containsItem(containerTo->id, &item) ==
true);
155 const invDef_t* container, *containerFrom;
159 ASSERT_TRUE(
nullptr != od);
162 ASSERT_TRUE(
nullptr != container);
169 ASSERT_TRUE(
nullptr != addedItem);
174 ASSERT_TRUE(
nullptr != ad);
179 ASSERT_TRUE(
nullptr != containerFrom);
184 ASSERT_TRUE(
nullptr != addedItem);
198 ASSERT_TRUE(
nullptr != ad);
202 ASSERT_TRUE(inv.
containsItem(containerFrom->
id, &ammoFrom) ==
false);
205 ASSERT_TRUE(
nullptr != addedItem);
207 ASSERT_TRUE(inv.
containsItem(containerFrom->
id, &ammoFrom) ==
true);
211 ASSERT_TRUE(inv.
containsItem(containerFrom->
id, &ammoFrom) ==
false);
229 ASSERT_TRUE(
nullptr != od);
232 ASSERT_TRUE(
nullptr != container);
236 ASSERT_TRUE(addedItem ==
true);
240 ASSERT_TRUE(addedItem ==
false);
243 ASSERT_TRUE(
nullptr != container);
246 ASSERT_TRUE(
nullptr != od);
249 ASSERT_TRUE(addedItem ==
true);
252 ASSERT_TRUE(
nullptr != container);
258 ASSERT_TRUE(addedItem ==
true);
260 ASSERT_TRUE(addedItem ==
true);
262 ASSERT_TRUE(addedItem ==
true);
263 for (
int j = 0; j < od->
numAmmos; j++) {
265 ASSERT_TRUE(addedItem ==
true);
267 ASSERT_TRUE(addedItem ==
true);
269 ASSERT_TRUE(addedItem ==
true);
271 ASSERT_TRUE(addedItem ==
true);
273 ASSERT_TRUE(addedItem ==
true);
275 ASSERT_TRUE(addedItem ==
true);
287 ASSERT_TRUE(
nullptr != od);
290 ASSERT_TRUE(
nullptr != 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.
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)
TEST_F(InventoryTest, ItemAdd)
#define Mem_PoolAlloc(size, pool, tagNum)
inventory_action_t moveInInventory(Inventory *const inv, const invDef_t *from, Item *item, const invDef_t *to, int tx, int ty, int *TU, Item **icp)
Conditions for moving items between containers.
static bool testAddSingle(Inventory *inv, const objDef_t *od, const invDef_t *container)
static void ResetInventoryList(void)
void Com_ParseScripts(bool onlyServer)
const struct objDef_s * ammos[MAX_AMMOS_PER_OBJDEF]
Defines all attributes of objects used in the inventory.
bool containsItem(const containerIndex_t contId, const Item *const item) const
Searches if there is a specific item already in the inventory&container.
static void * AllocInventoryMemory(size_t size)
item instance data, with linked list capability
static void FreeInventory(void *data)
inventory definition with all its containers
static void FreeAllInventory(void)
void initInventory(const char *name, const csi_t *csi, const inventoryImport_t *import)
Initializes the inventory definition by linking the ->next pointers properly.
const invDef_t * INVSH_GetInventoryDefinitionByID(const char *id)
memPool_t * com_genericPool
static InventoryInterface i
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.
static void TearDownTestCase()
static void SetUpTestCase()
#define Mem_FreeTag(pool, tagNum)
void setAmmoDef(const objDef_t *od)
inventory definition for our menus
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
GLsizei const GLvoid * data
void destroyInventoryInterface(void)
static const int TAG_INVENTORY
static const inventoryImport_t inventoryImport
bool removeFromInventory(Inventory *const inv, const invDef_t *container, Item *fItem) __attribute__((warn_unused_result))