home · contact · privacy
Re-insert map existence check in command_worldactive().
[plomrogue] / roguelike-server
index 5b37324c0d5f203c4efdacf28a7989c333a1f797..e723339a46bdad1e0c121cdb1b41e69537c9f77d 100755 (executable)
@@ -139,7 +139,8 @@ def obey(command, prefix, replay=False, do_record=False):
                 if time.time() > io_db["save_wait"] + 15:
                     atomic_write(io_db["path_record"], io_db["record_chunk"],
                                  do_append=True)
-                    save_world()
+                    if world_db["WORLD_ACTIVE"]:
+                        save_world()
                     io_db["record_chunk"] = ""
                     io_db["save_wait"] = time.time()
             io_db["worldstate_updateable"] = world_db["WORLD_ACTIVE"]
@@ -1116,7 +1117,8 @@ def command_ping():
 def command_quit():
     """Abort server process."""
     if None == opts.replay:
-        save_world()
+        if world_db["WORLD_ACTIVE"]:
+            save_world()
         atomic_write(io_db["path_record"], io_db["record_chunk"], do_append=True)
     raise SystemExit("received QUIT command")
 
@@ -1283,10 +1285,9 @@ def command_worldactive(worldactive_string):
     """Toggle world_db["WORLD_ACTIVE"] if possible.
 
     An active world can always be set inactive. An inactive world can only be
-    set active with a "wait" ThingAction, and a player Thing (of ID 0). On
-    activation, rebuild all Things' FOVs, and the player's map memory.
+    set active with a "wait" ThingAction, and a player Thing (of ID 0), and a
+    map. On activation, rebuild all Things' FOVs, and the player's map memory.
     """
-    # In original version, map existence was also tested (unnecessarily?).
     val = integer_test(worldactive_string, 0, 1)
     if val:
         if 0 != world_db["WORLD_ACTIVE"]:
@@ -1305,7 +1306,7 @@ def command_worldactive(worldactive_string):
                 if 0 == Thing:
                     player_exists = True
                     break
-            if wait_exists and player_exists:
+            if wait_exists and player_exists and "MAP" in world_db:
                 for id in world_db["Things"]:
                     if world_db["Things"][id]["T_LIFEPOINTS"]:
                         build_fov_map(world_db["Things"][id])