home · contact · privacy
Server: Read in former "config" data as normal server god commands.
[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 "hardcoded_strings.h" /* s */
8 #include "init.h" /* run_game(), obey_argv(), obey_argv(), setup_server_io() */
9 #include "world.h" /* struct World */
10
11
12
13 struct World world;
14
15
16
17 int main(int argc, char ** argv)
18 {
19     /* So error exits also go through the server's cleanup() function. */
20     set_cleanup_func(cleanup);
21
22     /* Init settings from command line / hard-coded values. Print start info. */
23     init_strings();
24     obey_argv(argc, argv);
25     if (world.is_verbose)
26     {
27         char * printf_err = "Trouble in main() with printf().";
28         int test = printf("Starting plomrogue-server.\n");
29         exit_err(-1 == test, printf_err);
30         if (world.replay)
31         {
32             test = printf("Replay mode. Auto-replaying up to turn %d.\n",
33                           world.replay);
34             exit_err(-1 == test, printf_err);
35         }
36     }
37     world.map.length = 64;                      /* Just a sane default value. */
38
39     /* Init server i/o, Enter play or replay mode loops, then leave properly. */
40     setup_server_io();
41     run_game();
42     cleanup();
43     exit(EXIT_SUCCESS);
44 }