home · contact · privacy
Server: Simplify rule for when to update worldstate file.
[plomrogue] / src / server / init.c
index 766d92e26bd5f56064fcede85824c5c08b262e3e..dd6ee15408a70a83b37a76b338e76878d475888c 100644 (file)
@@ -13,7 +13,8 @@
 #include <time.h> /* time() */
 #include <unistd.h> /* optarg, getopt(), access(), unlink(), getpid() */
 #include "../common/readwrite.h" /* try_fopen(), try_fclose(), textfile_width(),
-                                  * try_fgets(), try_fwrite()
+                                  * try_fgets(), try_fwrite(),
+                                  * detect_atomic_leftover()
                                   */
 #include "../common/rexit.h" /* exit_err(), exit_trouble() */
 #include "../common/try_malloc.h" /* try_malloc() */
@@ -101,7 +102,7 @@ extern void setup_server_io()
     world.file_out = try_fopen(s[S_PATH_OUT], "w", f_name);
     world.server_test = try_malloc(10 + 1 + 10 + 1 + 1, f_name);
     test = sprintf(world.server_test, "%d %d\n", getpid(), (int) time(0));
-    exit_trouble(test < 0, f_name, "sprintf()");
+    exit_trouble(test < 0, f_name, s[S_FCN_SPRINTF]);
     try_fwrite(world.server_test, strlen(world.server_test), 1,
                world.file_out, f_name);
     fflush(world.file_out);
@@ -126,7 +127,7 @@ extern void remake_world()
     world.log = NULL;      /* thing_actions.c's update_log() checks for this. */
     world.seed_map = world.seed;
     free_things(world.things);
-    world.last_update_turn = 0;
+    world.do_update = 1;
     remake_map();
     struct ThingType * tt;
     for (tt = world.thing_types; NULL != tt; tt = tt->next)
@@ -162,6 +163,8 @@ extern void remake_world()
 extern void run_game()
 {
     char * f_name = "run_game()";
+    detect_atomic_leftover(s[S_PATH_SAVE]);
+    detect_atomic_leftover(s[S_PATH_RECORD]);
     if (world.replay)
     {
         replay_game();
@@ -188,7 +191,7 @@ extern void run_game()
         char * command = s[S_CMD_MAKE_WORLD];
         char * msg = try_malloc(strlen(command) + 1 + 11 + 1, f_name);
         int test = sprintf(msg, "%s %d", command, (int) time(NULL));
-        exit_trouble(test < 0, f_name, "sprintf()");
+        exit_trouble(test < 0, f_name, s[S_FCN_SPRINTF]);
         obey_msg(msg, 1);
         free(msg);
     }