MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / InventoryRemoveObject

Function InventoryRemoveObject

Descent3/Inventory.cpp:1517–1535  ·  view source on GitHub ↗

Checks for an object in any of the players inventorys and removes it

Source from the content-addressed store, hash-verified

1515
1516// Checks for an object in any of the players inventorys and removes it
1517void InventoryRemoveObject(int objhandle) {
1518 object *obj = ObjGet(objhandle);
1519 ASSERT(obj);
1520 if (!obj)
1521 return;
1522
1523 if (!(obj->flags & OF_INPLAYERINVENTORY)) // not in the player's inventory
1524 return;
1525
1526 // go through all the players and look for the object
1527 for (int i = 0; i < MAX_PLAYERS; i++) {
1528 if (Players[i].inventory.CheckItem(objhandle, -1)) {
1529 // this player has it!!
1530 mprintf(0, "INVEN: Removing dead object from %d\n", i);
1531 Players[i].inventory.Remove(objhandle, -1);
1532 return;
1533 }
1534 }
1535}

Callers 1

ObjDeleteDeadFunction · 0.85

Calls 3

ObjGetFunction · 0.85
CheckItemMethod · 0.80
RemoveMethod · 0.80

Tested by

no test coverage detected