1 /* src/server/main.c */
3 #include <stdio.h> /* printf() */
4 #include <stdlib.h> /* exit() */
5 #include "../common/err_try_fgets.h" /* set_err_try_fgets_delim() */
6 #include "../common/rexit.h" /* exit_err, set_cleanup_func() */
7 #include "cleanup.h" /* set_cleanup_flag(), cleanup() */
8 #include "init.h" /* run_game(), obey_argv(), obey_argv(), setup_server_io(),
9 * init_map_and_map_object_configs()
11 #include "world.h" /* struct World */
19 int main(int argc, char ** argv)
21 /* So error exits also go through the server's cleanup() function. */
22 set_cleanup_func(cleanup);
24 /* Init settings from command line / hard-coded values. Print start info. */
25 obey_argv(argc, argv);
28 char * printf_err = "Trouble in main() with printf().";
29 int test = printf("Starting plomrogue-server.\n");
30 exit_err(-1 == test, printf_err);
33 test = printf("Replay mode. Auto-replaying up to turn %d.\n",
35 exit_err(-1 == test, printf_err);
38 world.path_map_obj_defs = "confserver/defs";
39 world.path_map_obj_acts = "confserver/map_object_actions";
40 world.path_worldstate = "server/worldstate";
41 world.path_out = "server/out";
42 world.path_in = "server/in";
43 world.path_record = "record";
44 world.tmp_suffix = "_tmp";
45 set_err_try_fgets_delim("%%\n");
47 /* Init map, map object configurations and server i/o files. */
48 init_map_and_map_objects_configs();
51 /* Enter play or replay mode loops, then leave properly. */