Just as a note to everyone working with items (and before I try to roll out some documentation soon), the functions inv_add() and inv_rm() in inventory.c now ensure that the item is consistently aware of the inventory it is in (via fields of and i).
This exclusivity means that an item can only be in one inventory at once. As far as I know, this was never a feature, so it shouldn't cause problems. (In fact, a SIGSEGV was fixed by enforcing this case.) The practical implications of this for developers working with inventories are:
Calling inv_add() will remove an item from the previous inventory, if it exists. Do NOT attempt to call inv_rm() on the item afterward, because you will remove it from the inventory you just transferred it to.
inv_rm() arguments should be ancillary now. When I get the chance, I will change the definition to this:
void inv_rm(item *);
...since the item now contains all the information required about where it is and in what inventory. Removing an item thusly, without an inventory, will not fail; thus, this operation should be safe.
Again, I will reflect these in the documentation when I get a chance. Get used to using them thusly; I think they're improved :D
Just as a note to everyone working with items (and before I try to roll out some documentation soon), the functions
inv_add()
andinv_rm()
ininventory.c
now ensure that the item is consistently aware of the inventory it is in (via fieldsof
andi
).This exclusivity means that an item can only be in one inventory at once. As far as I know, this was never a feature, so it shouldn't cause problems. (In fact, a SIGSEGV was fixed by enforcing this case.) The practical implications of this for developers working with inventories are:
inv_add()
will remove an item from the previous inventory, if it exists. Do NOT attempt to callinv_rm()
on the item afterward, because you will remove it from the inventory you just transferred it to.inv_rm()
arguments should be ancillary now. When I get the chance, I will change the definition to this:void inv_rm(item *);
...since the item now contains all the information required about where it is and in what inventory. Removing an item thusly, without an inventory, will not fail; thus, this operation should be safe.
Again, I will reflect these in the documentation when I get a chance. Get used to using them thusly; I think they're improved :D