Inventory

The player's inventory is located in client_persistant_t. It is referenced through the gclient_t's pers attribute. The inventory is an array of integers that represent the number of items of different item types. That is, the index in the array is the item type, which corresponds to the index in the global itemlist. Finding an item in the inventory is the same as finding it in the global itemlist and then using the index of itemlist as the index in the inventory.

Note that the weapons are also items in the inventory and the global itemlist.

Items in the inventory can be picked up, used, dropped and selected. client_persistant_t has an attribute, selected_item to help the DLL with this. When an item is found its contents is represented by the data in itemlist. This means that a clip always contains the same quantity of bullets. The inventory is increased at the position for items of type bullet when you find a clip. Functions for item handling can be found in g_items.c.