From: Christian Heller Date: Sat, 1 Feb 2014 03:31:17 +0000 (+0100) Subject: Ensure that multiple inanimate objects on a map cell are always treated as a X-Git-Tag: tce~846 X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/pick_tasks?a=commitdiff_plain;h=0255432b4e8d3a7b3aec71c4e43e7fb063c45833;p=plomrogue Ensure that multiple inanimate objects on a map cell are always treated as a stack, to the topmost one is picked up first. --- diff --git a/src/server/map_object_actions.c b/src/server/map_object_actions.c index 561a2e2..0cbc1bf 100644 --- a/src/server/map_object_actions.c +++ b/src/server/map_object_actions.c @@ -364,12 +364,13 @@ extern void actor_drop(struct MapObj * mo) extern void actor_pick(struct MapObj * mo) { - struct MapObj * picked; - for (picked = world.map_objs; NULL != picked; picked = picked->next) + struct MapObj * picked = NULL; + struct MapObj * mo_i; + for (mo_i = world.map_objs; NULL != mo_i; mo_i = mo_i->next) { - if (picked != mo && yx_uint16_cmp(&picked->pos, &mo->pos)) + if (mo_i != mo && yx_uint16_cmp(&mo_i->pos, &mo->pos)) { - break; + picked = mo_i; } } if (NULL != picked) diff --git a/src/server/map_object_actions.h b/src/server/map_object_actions.h index d3b88a3..1eca591 100644 --- a/src/server/map_object_actions.h +++ b/src/server/map_object_actions.h @@ -46,7 +46,7 @@ extern void actor_move(struct MapObj * mo); /* Actor "mo" tries to drop from inventory object indexed by number mo->args. */ extern void actor_drop(struct MapObj * mo); -/* Actor "mo" tries to pick up object from ground into its inventory. */ +/* Actor "mo" tries to pick up topmost object from ground into its inventory. */ extern void actor_pick(struct MapObj * mo); /* Actor "mo" tries to use inventory object indexed by number mo->args.