home · contact · privacy
Server/py: Fix memdepthmapping bug.
[plomrogue] / plomrogue-server.py
index d9ea68d14c55b7b7895d655dc664ba7398c14c69..a44f751313a057e04c432f5ba48df264a9d4e222 100755 (executable)
@@ -204,8 +204,10 @@ def save_world():
 
     string = ""
     for key in world_db:
-        if dict != type(world_db[key]) and key != "MAP":
+        if dict != type(world_db[key]) and key != "MAP" and \
+           key != "WORLD_ACTIVE" and key != "SEED_MAP":
             string = string + key + " " + str(world_db[key]) + "\n"
+    string = string + "SEED_MAP " + str(world_db["SEED_MAP"]) + "\n"
     string = string + helper("ThingActions", "TA_ID")
     string = string + helper("ThingTypes", "TT_ID", {"TT_CORPSE_ID": False})
     for id in world_db["ThingTypes"]:
@@ -476,7 +478,7 @@ def update_map_memory(t):
                 t["T_MEMMAP"][pos] = world_db["MAP"][pos]
             continue
         if ord('0') <= t["T_MEMDEPTHMAP"][pos] \
-           and ord('9') >= t["T_MEMDEPTHMAP"][pos] \
+           and ord('9') > t["T_MEMDEPTHMAP"][pos] \
            and not rand.next() % (2 ** (t["T_MEMDEPTHMAP"][pos] - 48)):
             t["T_MEMDEPTHMAP"][pos] += 1
     for mt in [mt for mt in t["T_MEMTHING"]
@@ -572,7 +574,7 @@ def decrement_lifepoints(t):
 
 def mv_yx_in_dir_legal(dir, y, x):
     """Wrapper around libpr.mv_yx_in_dir_legal to simplify its use."""
-    dir_c = chr(dir).encode("ascii")[0]
+    dir_c = dir.encode("ascii")[0]
     test = libpr.mv_yx_in_dir_legal_wrap(dir_c, y, x)
     if -1 == test:
         raise RuntimeError("Too much wrapping in mv_yx_in_dir_legal_wrap()!")
@@ -588,7 +590,8 @@ def actor_wait(t):
 def actor_move(t):
     """If passable, move/collide(=attack) thing into T_ARGUMENT's direction."""
     passable = False
-    move_result = mv_yx_in_dir_legal(t["T_ARGUMENT"], t["T_POSY"], t["T_POSX"])
+    move_result = mv_yx_in_dir_legal(chr(t["T_ARGUMENT"]),
+                                     t["T_POSY"], t["T_POSX"])
     if 1 == move_result[0]:
         pos = (move_result[1] * world_db["MAP_LENGTH"]) + move_result[2]
         passable = "." == chr(world_db["MAP"][pos])
@@ -1388,9 +1391,9 @@ commands_db = {
 """World state database. With sane default values. (Randomness is in rand.)"""
 world_db = {
     "TURN": 0,
+    "MAP_LENGTH": 64,
     "SEED_MAP": 0,
     "PLAYER_TYPE": 0,
-    "MAP_LENGTH": 64,
     "WORLD_ACTIVE": 0,
     "ThingActions": {},
     "ThingTypes": {},