Changes to handling of obstructive terrain; no more listing every wall type!
authorMartin Read <martin@blackswordsonics.com>
Tue, 12 Nov 2013 15:36:59 +0000 (15:36 +0000)
committerMartin Read <martin@blackswordsonics.com>
Tue, 12 Nov 2013 15:36:59 +0000 (15:36 +0000)
combat.cc
map.cc
map.hh
monsters.cc
u.cc

index 86571a9..3d4cc58 100644 (file)
--- a/combat.cc
+++ b/combat.cc
@@ -188,10 +188,9 @@ int ushootm(Offset step)
                 return 0;
             }
         }
-        else if ((lvl.terrain_at(c) == WALL) || (lvl.terrain_at(c) == HARDWALL) ||
-                 (lvl.terrain_at(c) == DOOR))
+        else if (terrain_blocks_missiles(lvl.terrain_at(c)))
         {
-            print_msg("Your %s hits the %s.\n", (wep->obj_id == PO_CROSSBOW) ? "bolt" : "arrow", (lvl.terrain_at(c) == DOOR) ? "door" : "wall");
+            print_msg("Your %s hits the %s.\n", (wep->obj_id == PO_CROSSBOW) ? "bolt" : "arrow", terrain_props[lvl.terrain_at(c)].name);
             return 0;
         }
     }
diff --git a/map.cc b/map.cc
index 2b96705..4156bea 100644 (file)
--- a/map.cc
+++ b/map.cc
@@ -529,8 +529,8 @@ Terrain_props terrain_props[NUM_TERRAINS] =
     { "bone floor", '.', "·", Gcol_white, 0 },
     { "altar", '_', "_", Gcol_l_grey, 0 },
     { "stairs", '>', ">", Gcol_l_grey, 0 },
-    { "lava", '}', "}", Gcol_red, TFLAG_fire_hazard },
-    { "water", '}', "}", Gcol_blue, TFLAG_drown_hazard },
+    { "lava", '}', "", Gcol_red, TFLAG_fire_hazard },
+    { "water", '}', "", Gcol_blue, TFLAG_drown_hazard },
 };
 
 bool terrain_opacity[NUM_TERRAINS] =
@@ -544,5 +544,15 @@ bool terrain_is_opaque(Terrain terr)
     return terrain_props[terr].flags & TFLAG_opaque;
 }
 
+bool terrain_blocks_beings(Terrain terr)
+{
+    return terrain_props[terr].flags & TFLAG_block_beings;
+}
+
+bool terrain_blocks_missiles(Terrain terr)
+{
+    return terrain_props[terr].flags & TFLAG_block_missile;
+}
+
 /* map.c */
 // vim:cindent:ts=8:sw=4:expandtab
diff --git a/map.hh b/map.hh
index b364121..ccfe36c 100644 (file)
--- a/map.hh
+++ b/map.hh
@@ -80,6 +80,8 @@ struct Terrain_props
     uint32_t flags;
 };
 
+extern Terrain_props terrain_props[NUM_TERRAINS];
+
 #define TFLAG_opaque        0x00000001u
 #define TFLAG_block_beings  0x00000002u
 #define TFLAG_block_ether   0x00000004u
@@ -123,6 +125,8 @@ extern void populate_level(void);
 extern void inject_player(void);
 extern void look_around_you(void);
 extern bool terrain_is_opaque(Terrain terr);
+extern bool terrain_blocks_beings(Terrain terr);
+extern bool terrain_blocks_missiles(Terrain terr);
 #endif
 
 /* map.h */
index b100656..0629cda 100644 (file)
@@ -254,11 +254,15 @@ bool Mon::can_pass(Coord c) const
         return true;
     }
     terr = lvl.terrain_at(c);
-    switch (terr)
+    if (terrain_blocks_beings(terr))
     {
-    case WALL:
-    case HARDWALL:
+        /* Let's *not* stuff all the wall types into a switch, eh? */
         return false;
+    }
+    /* Keep the switch, so that we can maintain a convenient distinction
+     * between floor hazards and volumetric hazards. */
+    switch (terr)
+    {
     case LAVA:
         if (!can_fly() && !resists(DT_FIRE))
         {
@@ -426,13 +430,14 @@ int knockback_mon(int mon, Offset step, bool cansee, bool by_you)
         }
         return 0;
     }
-    switch (terr)
+    if (terrain_blocks_beings(terr))
     {
-    case WALL:
-    case HARDWALL:
         print_mon_name(mon, 3);
         print_msg(" is slammed against the wall.\n");
         return 0;
+    }
+    switch (terr)
+    {
     case LAVA:
         if (mptr->can_fly())
         {
diff --git a/u.cc b/u.cc
index a7dec2c..3a7b82d 100644 (file)
--- a/u.cc
+++ b/u.cc
@@ -109,10 +109,18 @@ Action_cost move_player(Offset delta)
     switch (lvl.terrain_at(c))
     {
     case WALL:
-    case HARDWALL:
+    case MASONRY_WALL:
+    case AMETHYST_WALL:
+    case IRON_WALL:
+    case SKIN_WALL:
+    case BONE_WALL:
         print_msg("You cannot go there.\n");
         return Cost_none;
     case FLOOR:
+    case AMETHYST_FLOOR:
+    case IRON_FLOOR:
+    case SKIN_FLOOR:
+    case BONE_FLOOR:
     case DOOR:
     case STAIRS:
     case ALTAR: