home · contact · privacy
Server: Always display consumables on top of stack of inanimate objects.
[plomrogue] / src / server / io.c
index 485313a4bff954f0da115d30ff12061af993f32b..14b5e48efaa79016d21269336c765eef7707b051 100644 (file)
@@ -17,7 +17,6 @@
 #include "../common/rexit.h" /* exit_trouble() */
 #include "../common/try_malloc.h" /* try_malloc() */
 #include "cleanup.h" /* set_cleanup_flag() */
-#include "field_of_view.h" /* VISIBLE */
 #include "hardcoded_strings.h" /* s */
 #include "things.h" /* Thing, ThingType, ThingAction, get_thing_type(),
                      * get_player()
@@ -60,7 +59,9 @@ static void write_value_as_line(uint32_t value, FILE * file);
 static void write_inventory(struct Thing * player, FILE * file);
 
 /* Return map cells sequence as visible to the "player", with invisible cells as
- * whitespace. Super-impose over visible map cells things positioned there.
+ * whitespace. Super-impose over visible map cells things positioned there,
+ * with animate things overwriting inanimate things, and inanimate consumable
+ * things overwriting inanimate non-consumable things.
  */
 static char * build_visible_map(struct Thing * player);
 
@@ -309,27 +310,28 @@ static char * build_visible_map(struct Thing * player)
         uint32_t pos_i;
         for (pos_i = 0; pos_i < map_size; pos_i++)
         {
-            if (player->fov_map[pos_i] & VISIBLE)
+            if (player->fov_map[pos_i] == 'v')
             {
                 visible_map[pos_i] = world.map.cells[pos_i];
             }
         }
         struct Thing * t;
-        struct ThingType * tt;
         char c;
         uint8_t i;
-        for (i = 0; i < 2; i++)
+        for (i = 0; i < 3; i++)
         {
             for (t = world.things; t != 0; t = t->next)
             {
-                if (   (  player->fov_map[t->pos.y * world.map.length +t->pos.x]
-                        & VISIBLE)
-                    && (   (0 == i && 0 == t->lifepoints)
-                        || (1 == i && 0 < t->lifepoints)))
+                if ('v'==player->fov_map[t->pos.y*world.map.length+t->pos.x])
                 {
-                    tt = get_thing_type(t->type);
-                    c = tt->char_on_map;
-                    visible_map[t->pos.y * world.map.length + t->pos.x] = c;
+                    struct ThingType * tt = get_thing_type(t->type);
+                    if (   (0 == i && !t->lifepoints && !tt->consumable)
+                        || (1 == i && !t->lifepoints &&  tt->consumable)
+                        || (2 == i &&  t->lifepoints))
+                    {
+                        c = tt->char_on_map;
+                        visible_map[t->pos.y * world.map.length + t->pos.x] = c;
+                    }
                 }
             }
         }