home · contact · privacy
Load last world state from save file, not from re-stepping record file.
[plomrogue] / src / server / main.c
1 /* src/server/main.c */
2
3 #include <stdio.h> /* printf() */
4 #include <stdlib.h> /* exit() */
5 #include "../common/rexit.h" /* exit_err, set_cleanup_func() */
6 #include "cleanup.h" /* set_cleanup_flag(), cleanup() */
7 #include "configfile.h" /* read_config_file() */
8 #include "hardcoded_strings.h" /* s */
9 #include "init.h" /* run_game(), obey_argv(), obey_argv(), setup_server_io() */
10 #include "world.h" /* struct World */
11
12
13
14 struct World world;
15
16
17
18 int main(int argc, char ** argv)
19 {
20     /* So error exits also go through the server's cleanup() function. */
21     set_cleanup_func(cleanup);
22
23     /* Init settings from command line / hard-coded values. Print start info. */
24     init_strings();
25     obey_argv(argc, argv);
26     if (world.is_verbose)
27     {
28         char * printf_err = "Trouble in main() with printf().";
29         int test = printf("Starting plomrogue-server.\n");
30         exit_err(-1 == test, printf_err);
31         if (world.replay)
32         {
33             test = printf("Replay mode. Auto-replaying up to turn %d.\n",
34                          world.replay);
35             exit_err(-1 == test, printf_err);
36         }
37     }
38
39     /* Init config file and server i/o files. */
40     read_config_file();
41     setup_server_io();
42
43     /* Enter play or replay mode loops, then leave properly. */
44     run_game();
45     cleanup();
46     exit(EXIT_SUCCESS);
47 }