Fix division by zero when unit activity rate is zero
[freeciv.git] / server / srv_main.h
blob339442d78c13fed8643a5125c584deff0d1be5e8
1 /***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
13 #ifndef FC__SRV_MAIN_H
14 #define FC__SRV_MAIN_H
16 /* utility */
17 #include "log.h" /* enum log_level */
18 #include "net_types.h" /* announce_type */
20 /* common */
21 #include "fc_types.h"
22 #include "game.h"
24 struct conn_list;
26 struct server_arguments {
27 /* metaserver information */
28 bool metaserver_no_send;
29 char metaserver_addr[256];
30 bool metaconnection_persistent;
31 char identity_name[256];
32 unsigned short int metaserver_port;
33 /* address this server is to listen on (NULL => INADDR_ANY) */
34 char *bind_addr;
35 /* this server's listen port */
36 int port;
37 /* address to bind when connecting to the metaserver (NULL => bind_addr) */
38 char *bind_meta_addr;
39 /* the log level */
40 enum log_level loglevel;
41 /* filenames */
42 char *log_filename;
43 char *ranklog_filename;
44 char load_filename[512]; /* FIXME: may not be long enough? use MAX_PATH? */
45 char *script_filename;
46 char *saves_pathname;
47 char *scenarios_pathname;
48 char serverid[256];
49 /* quit if there no players after a given time interval */
50 int quitidle;
51 /* exit the server on game ending */
52 bool exit_on_end;
53 /* authentication options */
54 bool fcdb_enabled; /* defaults to FALSE */
55 char *fcdb_conf; /* freeciv database configuration file */
56 bool auth_enabled; /* defaults to FALSE */
57 bool auth_allow_guests; /* defaults to FALSE */
58 bool auth_allow_newusers; /* defaults to FALSE */
59 enum announce_type announce;
60 int fatal_assertions; /* default to -1 (disabled). */
63 /* used in savegame values */
64 #define SPECENUM_NAME server_states
65 #define SPECENUM_VALUE0 S_S_INITIAL
66 #define SPECENUM_VALUE1 S_S_RUNNING
67 #define SPECENUM_VALUE2 S_S_OVER
68 #include "specenum_gen.h"
70 /* Structure for holding global server data.
72 * TODO: Lots more variables could be added here. */
73 extern struct civserver {
74 int playable_nations;
75 int nbarbarians;
77 /* this counter creates all the city and unit numbers used.
78 * arbitrarily starts at 101, but at 65K wraps to 1.
79 * use identity_number()
81 #define IDENTITY_NUMBER_SKIP (100)
82 unsigned short identity_number;
84 char game_identifier[MAX_LEN_GAME_IDENTIFIER];
85 } server;
88 void init_game_seed(void);
89 void srv_init(void);
90 void srv_main(void);
91 void server_quit(void);
92 void save_game_auto(const char *save_reason, enum autosave_type type);
94 enum server_states server_state(void);
95 void set_server_state(enum server_states newstate);
97 void check_for_full_turn_done(void);
98 bool check_for_game_over(void);
99 bool game_was_started(void);
101 bool server_packet_input(struct connection *pconn, void *packet, int type);
102 void start_game(void);
103 void save_game(const char *orig_filename, const char *save_reason,
104 bool scenario);
105 const char *pick_random_player_name(const struct nation_type *pnation);
106 void player_nation_defaults(struct player *pplayer, struct nation_type *pnation,
107 bool set_name);
108 void send_all_info(struct conn_list *dest);
110 void identity_number_release(int id);
111 void identity_number_reserve(int id);
112 int identity_number(void);
113 void server_game_init(void);
114 void server_game_free(void);
115 const char *aifill(int amount);
117 extern struct server_arguments srvarg;
119 extern bool force_end_of_sniff;
121 void update_nations_with_startpos(void);
123 #endif /* FC__SRV_MAIN_H */