home · contact · privacy
Server: Always display consumables on top of stack of inanimate objects.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 16 Aug 2014 18:14:31 +0000 (20:14 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 16 Aug 2014 18:14:31 +0000 (20:14 +0200)
TODO
src/server/io.c
src/server/things.h

diff --git a/TODO b/TODO
index 3953ade3de9644653294e458e2db34ef1c8c44ef..a5eb09432b8f8b604ace9f715fc6f9a1e9196343 100644 (file)
--- a/TODO
+++ b/TODO
@@ -9,10 +9,6 @@ BOTH SERVER/CLIENT:
 - make server and client communicate by specific world state info requests 
   in server/out, replacing server/worldstate
 
-SERVER
-
-- fix: AI knows about consumables not on top of stack while player doesn't
-
 CLIENT:
 
 - re-work unnecessary complex command / keybinding / server message mapping
index 947c1468b48711d998e875bb76924e6a0da3d03d..14b5e48efaa79016d21269336c765eef7707b051 100644 (file)
@@ -59,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);
 
@@ -314,20 +316,22 @@ static char * build_visible_map(struct Thing * player)
             }
         }
         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 (   'v'==player->fov_map[t->pos.y*world.map.length+t->pos.x]
-                    && (   (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;
+                    }
                 }
             }
         }
index 4c21c451f6d3730ae5c2eecded046daa4173431b..ea37a81487160471b85bd8746c270380b1fc4de7 100644 (file)
@@ -18,7 +18,7 @@ struct Thing
     uint8_t id;                  /* individual thing's unique identifier */
     struct Thing * owns;         /* chain of things owned / in inventory */
     struct yx_uint8 pos;         /* coordinate on map */
-    char * fov_map;              /* map of the thing's field of view */
+    char * fov_map;              /* thing's FOV map; 'v':visible, 'H':hidden */
     char * mem_map;              /* map knowledge of thing by FOV and memory */
     uint8_t type;                /* ID of appropriate thing definition */
     uint8_t lifepoints;          /* 0: thing is inanimate; >0: hitpoints */