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");
+ /* 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 "
"roguelike-server may be running. It should be killed first.";
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();
-extern void init_map_object_actions(char * path)
+extern void init_map_object_actions()
{
char * f_name = "init_map_object_actions()";
- FILE * file = try_fopen(path, "r", f_name);
+ FILE * file = try_fopen(world.path_map_obj_acts, "r", f_name);
uint16_t linemax = textfile_sizes(file, NULL);
char line[linemax + 1];
struct MapObjAct ** moa_ptr_ptr = &world.map_obj_acts;
-/* Init MapObjAct chain at world.map_obj_acts from file at "path". */
-extern void init_map_object_actions(char * path);
+/* Init MapObjAct chain at world.map_obj_acts. */
+extern void init_map_object_actions();
/* Free MapObjAct * chain starting at "moa". */
extern void free_map_object_actions(struct MapObjAct * moa);
-extern void init_map_object_defs(char * filename)
+extern void init_map_object_defs()
{
char * f_name = "init_map_object_defs()";
char * context = "Failed reading map object definitions file. ";
char * err_toolarge = "Value is too large.";
char * err_uniq = "Declaration of ID already used.";
- FILE * file = try_fopen(filename, "r", f_name);
+ FILE * file = try_fopen(world.path_map_obj_defs, "r", f_name);
uint16_t linemax = textfile_sizes(file, NULL);
struct MapObjDef ** last_mod_ptr_ptr = &world.map_obj_defs;
char line[linemax + 1];
-/* Initialize map object definitions chain from file at path "filename". */
-extern void init_map_object_defs(char * filename);
+/* Initialize map object definitions chain. */
+extern void init_map_object_defs();
/* Free map object definitions chain starting at "mod_start". */
extern void free_map_object_defs(struct MapObjDef * mod_start);
char * path_in; /* Fifo to receive command messages. */
char * path_out; /* File to write the game state as visible to clients.*/
char * path_record; /* Record file from which to read the game history. */
+ char * path_map_obj_defs; /* path for map object definitions config file */
+ char * path_map_obj_acts; /* path for map object actions config file */
char * tmp_suffix; /* Appended to paths of files for their tmp versions. */
char * queue; /* Stores un-processed messages received via input fifo. */
uint32_t queue_size;/* Length of .queue sequence of \0-terminated strings.*/