home · contact · privacy
Eliminated some potential problems for alternative game map sizes.
[plomrogue] / src / server / main.c
index 6cf6b413bc7c92215cd4b4ecd1386d28d6f88575..64d4434943867fb7a36d7b60da2759dae675dd41 100644 (file)
@@ -5,6 +5,7 @@
 #include <stdlib.h> /* exit() */
 #include <sys/stat.h> /* mkfifo(), mkdir() */
 #include <unistd.h> /* access() */
+#include "../common/err_try_fgets.h" /* set_err_try_fgets_delim() */
 #include "../common/rexit.h" /* exit_err, exit_trouble(), set_cleanup_func() */
 #include "cleanup.h" /* set_cleanup_flag(), cleanup() */
 #include "init.h" /* run_game(), obey_argv() */
@@ -40,10 +41,25 @@ int main(int argc, char ** argv)
             exit_err(-1 == test, printf_err);
         }
     }
+    world.path_map_obj_defs = "confserver/defs";
+    world.path_map_obj_acts = "confserver/map_object_actions";
     world.path_in     = "server/in";
     world.path_out    = "server/out";
     world.path_record = "record";
     world.tmp_suffix  = "_tmp";
+    set_err_try_fgets_delim("%%\n");
+
+    /* Set map geometry. */
+    world.map.size.x = 64;
+    world.map.size.y = 64;
+    world.map.dist_orthogonal = 5;
+    world.map.dist_diagonal   = 7;
+
+    /* Check existence of config files. */
+    char * err_mod = "No map object definitions file.";
+    char * err_moa = "No map object actions file.";
+    exit_err(access(world.path_map_obj_defs, F_OK), err_mod);
+    exit_err(access(world.path_map_obj_acts, F_OK), err_moa);
 
     /* Treat world.path_in file as server process lock file. */
     char * err = "Found pre-existing input fifo file. This indicates another "
@@ -55,8 +71,8 @@ int main(int argc, char ** argv)
     set_cleanup_flag(CLEANUP_FIFO);
 
     /* Init from config files map object (action) definitions. */
-    init_map_object_defs("confserver/defs");
-    init_map_object_actions("confserver/map_object_actions");
+    init_map_object_defs();
+    init_map_object_actions();
 
     /* Enter play or replay mode loops, then leave properly. */
     run_game();