home · contact · privacy
Server: Fix determinism bug in thingproliferation.
[plomrogue] / roguelike-server
index ff799fb74a36d86eedaf6cb51b5cebaa2e0c8444..94f540b4bffa7e4a2c3bbf07b95024965a0b587c 100755 (executable)
@@ -498,12 +498,10 @@ def update_map_memory(t, age_map=True):
         t["T_MEMDEPTHMAP"] = bytearray(b' ' * (world_db["MAP_LENGTH"] ** 2))
     ord_v = ord("v")
     ord_0 = ord("0")
-    ord_space = ord(" ")
     for pos in [pos for pos in range(world_db["MAP_LENGTH"] ** 2)
                 if ord_v == t["fovmap"][pos]]:
         t["T_MEMDEPTHMAP"][pos] = ord_0
-        if ord_space == t["T_MEMMAP"][pos]:
-            t["T_MEMMAP"][pos] = world_db["MAP"][pos]
+        t["T_MEMMAP"][pos] = world_db["MAP"][pos]
     if age_map:
         age_some_memdepthmap_on_nonfov_cells()
     t["T_MEMTHING"] = [mt for mt in t["T_MEMTHING"]
@@ -632,7 +630,6 @@ def actor_move(t):
                                      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])
         hitted = [id for id in world_db["Things"]
                   if world_db["Things"][id] != t
                   if world_db["Things"][id]["T_LIFEPOINTS"]
@@ -651,6 +648,7 @@ def actor_move(t):
                                                 " wounds you.\n")
             decrement_lifepoints(world_db["Things"][hit_id])
             return
+        passable = "." == chr(world_db["MAP"][pos])
     dir = [dir for dir in directions_db
            if directions_db[dir] == chr(t["T_ARGUMENT"])][0]
     if passable:
@@ -736,7 +734,7 @@ def thingproliferation(t, prol_map):
     prolscore = world_db["ThingTypes"][t["T_TYPE"]]["TT_PROLIFERATE"]
     if prolscore and (1 == prolscore or 1 == (rand.next() % prolscore)):
         candidates = []
-        for dir in [directions_db[key] for key in directions_db]:
+        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]
                                                       * world_db["MAP_LENGTH"]