version 1.36 | | version 1.37 |
---|
| | |
/* | | /* |
* static char *rcsid_object_c = | | * static char *rcsid_object_c = |
* "$Id: object.c,v 1.36 2001/08/05 05:07:20 mwedel Exp $"; | | * "$Id: object.c,v 1.37 2001/08/05 22:34:04 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
object *decrease_ob_nr (object *op, int i) | | object *decrease_ob_nr (object *op, int i) |
{ | | { |
object *tmp; | | object *tmp; |
| | player *pl; |
| | |
if (i == 0) /* objects with op->nrof require this check */ | | if (i == 0) /* objects with op->nrof require this check */ |
return op; | | return op; |
| | |
} | | } |
else if (op->env != NULL) | | else if (op->env != NULL) |
{ | | { |
| | /* is this object in the players inventory, or sub container |
| | * therein? |
| | */ |
tmp = is_player_inv (op->env); | | tmp = is_player_inv (op->env); |
| | /* nope. Is this a container the player has opened? |
| | * If so, set tmp to that player. |
| | * IMO, searching through all the players will mostly |
| | * likely be quicker than following op->env to the map, |
| | * and then searching the map for a player. |
| | */ |
| | if (!tmp) { |
| | for (pl=first_player; pl; pl=pl->next) |
| | if (pl->ob->container == op->env) break; |
| | if (pl) tmp=pl->ob; |
| | else tmp=NULL; |
| | } |
| | |
if (i < op->nrof) { | | if (i < op->nrof) { |
sub_weight (op->env, op->weight * i); | | sub_weight (op->env, op->weight * i); |
op->nrof -= i; | | op->nrof -= i; |