From 0255432b4e8d3a7b3aec71c4e43e7fb063c45833 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sat, 1 Feb 2014 04:31:17 +0100
Subject: [PATCH] Ensure that multiple inanimate objects on a map cell are
 always treated as a stack, to the topmost one is picked up first.

---
 src/server/map_object_actions.c | 9 +++++----
 src/server/map_object_actions.h | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

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.
-- 
2.30.2