home · contact · privacy
Server: Make list of symbols of passable fields configurable.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 22 Feb 2016 00:54:10 +0000 (01:54 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 22 Feb 2016 00:54:10 +0000 (01:54 +0100)
libplomrogue.c
server/actions.py
server/ai.py
server/config/world_data.py
server/world.py

index d0b15a10bc5d260f4fcf1fc75af6551863e01157..d0b656b657f23c225cd0fafe140dcfe92660ca6c 100644 (file)
@@ -600,7 +600,8 @@ extern void age_some_memdepthmap_on_nonfov_cells(char * memdepthmap,
     }
 }
 
-extern uint8_t set_cells_passable_on_memmap_to_65534_on_scoremap(char * mem_map)
+extern uint8_t set_cells_passable_on_memmap_to_65534_on_scoremap(char * mem_map,
+                                                  const char * symbols_passable)
 {
     if (!score_map)
     {
@@ -610,7 +611,7 @@ extern uint8_t set_cells_passable_on_memmap_to_65534_on_scoremap(char * mem_map)
     uint16_t pos;
     for (pos = 0; pos < map_size; pos++)
     {
-        if ('.' == mem_map[pos])
+        if (NULL != strchr(symbols_passable, mem_map[pos]))
         {
             score_map[pos] = 65534;
         }
index 849b02661174b41df67658fe92ffddadfd5558d6..6393a0ff249bc0c91e360252c27986688baec0c8 100644 (file)
@@ -17,7 +17,7 @@ def actor_move(t):
     """If passable, move/collide(=attack) thing into T_ARGUMENT's direction."""
     from server.world import build_fov_map, decrement_lifepoints
     from server.utils import mv_yx_in_dir_legal
-    from server.config.world_data import directions_db
+    from server.config.world_data import directions_db, symbols_passable
     passable = False
     move_result = mv_yx_in_dir_legal(chr(t["T_ARGUMENT"]),
                                      t["T_POSY"], t["T_POSX"])
@@ -39,7 +39,7 @@ def actor_move(t):
                 log(hitter_name +" WOUNDS you.")
             decrement_lifepoints(world_db["Things"][hit_id])
             return
-        passable = "." == chr(world_db["MAP"][pos])
+        passable = chr(world_db["MAP"][pos]) in symbols_passable
     dir = [dir for dir in directions_db
            if directions_db[dir] == chr(t["T_ARGUMENT"])][0]
     if passable:
index 3212be0c09020816370aba309d1b7404b9df3c0b..88b087939f5ca2cd49c428f30fe1420b110c36c1 100644 (file)
@@ -33,6 +33,7 @@ def get_dir_to_target(t, filter):
     "s": memory map cell with greatest-reachable degree of unexploredness
     """
     from server.utils import rand, libpr, c_pointer_to_bytearray
+    from server.config.world_data import symbols_passable
 
     def zero_score_map_where_char_on_memdepthmap(c):
         # OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
@@ -112,13 +113,13 @@ def get_dir_to_target(t, filter):
 
     def set_cells_passable_on_memmap_to_65534_on_scoremap():
         # OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
-        # ord_dot = ord(".")
         # memmap = t["T_MEMMAP"]
         # for i in [i for i in range(world_db["MAP_LENGTH"] ** 2)
-        #            if ord_dot == memmap[i]]:
+        #            if memmap[i] in symbols_passable]:
         #     set_map_score(i, 65534) # i.e. 65535-1
         map = c_pointer_to_bytearray(t["T_MEMMAP"])
-        if libpr.set_cells_passable_on_memmap_to_65534_on_scoremap(map):
+        if libpr.set_cells_passable_on_memmap_to_65534_on_scoremap(map,
+                    symbols_passable):
             raise RuntimeError("No score map allocated for set_cells_passable"
                                "_on_memmap_to_65534_on_scoremap().")
 
index 193da78a4367286e575b0fb4eb77010f0764b608..97725a3a1fe2f157d9543d33682b0f0cef4041b0 100644 (file)
@@ -32,3 +32,5 @@ thing_defaults = {
         "T_MEMDEPTHMAP": False,
         "fovmap": False
 }
+
+symbols_passable = "."
index a05a010dc4636310e4c95b259862b802c07119af..480ea28f424c30335434803f97993cd8c8639602 100644 (file)
@@ -8,7 +8,7 @@ def thingproliferation(t, prol_map):
     """To chance of 1/TT_PROLIFERATE, create t offspring in open neighbor cell.
 
     Naturally only works with TT_PROLIFERATE > 0. The neighbor cell must be be
-    marked '.' in prol_map. If there are several map cell candidates, one is
+    marked "." in prol_map. If there are several map cell candidates, one is
     selected randomly.
     """
     from server.config.world_data import directions_db
@@ -18,7 +18,7 @@ def thingproliferation(t, prol_map):
         candidates = []
         for dir in [directions_db[key] for key in sorted(directions_db.keys())]:
             mv_result = mv_yx_in_dir_legal(dir, t["T_POSY"], t["T_POSX"])
-            if mv_result[0] and  ord('.') == prol_map[mv_result[1]
+            if mv_result[0] and  ord(".") == prol_map[mv_result[1]
                                                       * world_db["MAP_LENGTH"]
                                                       + mv_result[2]]:
                 candidates.append((mv_result[1], mv_result[2]))
@@ -235,6 +235,7 @@ def make_world(seed):
     of ID = world["PLAYER_TYPE"]. Place Things randomly, and actors not on each
     other. Init player's memory map. Write "NEW_WORLD" line to out file.
     """
+    from server.config.world_data import symbols_passable
 
     def free_pos():
         i = 0
@@ -243,7 +244,8 @@ def make_world(seed):
             while 1:
                 y = rand.next() % world_db["MAP_LENGTH"]
                 x = rand.next() % world_db["MAP_LENGTH"]
-                if "." == chr(world_db["MAP"][y * world_db["MAP_LENGTH"] + x]):
+                if chr(world_db["MAP"][y * world_db["MAP_LENGTH"] + x]) in \
+                    symbols_passable:
                     break
                 i += 1
                 if i == 65535: