Obj already extracted?

Posted by Dace K on Sun 19 Mar 2006 08:44 AM — 3 posts, 14,708 views.

Canada #0
I've added a check in one function to take an object automatically from a players's container worn in a certain location if it's there.


separate_obj(ammo);
get_obj( ch, ammo, container, FALSE );


So far, so good. The line after that, though,
equip_char( ch, ammo, WEAR_HOLD );

keeps returning the error message (Log: [*****] BUG: equip_char: obj not being carried by ch!) if the char already had an identical item to the one he's getting from the container.

Further down, the object is extracted, but again an error message pops up, this time reading: Log: [*****] BUG: extract_obj: obj 107 already extracted!

This works fine, however, when there is no duplicates of this item in the char's inventory.

Any ideas?
USA #1
The problem, I think, is that get_obj calls obj_to_char which will group the object into the player's inventory. Once the object is grouped, it might destroy the object 'ammo' because it grouped it with the identical copy. So, equip_char will fail to find the object in the char's inventory, and extract_obj will be unhappy because the object is already scheduled for extraction.
Canada #2
Ah, I see. Easy fix then, thanks.