Freeciv-3.3
Loading...
Searching...
No Matches
srv_main.h
Go to the documentation of this file.
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.
7
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
15
16/* utility */
17#include "log.h" /* enum log_level */
18#include "net_types.h" /* announce_type */
19
20/* common */
21#include "fc_types.h"
22#include "game.h"
23
24struct conn_list;
25
27 /* metaserver information */
29 char metaserver_addr[256];
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) */
39 /* the log level */
41 /* filenames */
44 char load_filename[512]; /* FIXME: may not be long enough? use MAX_PATH? */
48 char *ruleset;
49 char serverid[256];
50 /* quit if there no players after a given time interval */
52 /* exit the server on game ending */
54 /* authentication options */
55 bool fcdb_enabled; /* defaults to FALSE */
56 char *fcdb_conf; /* freeciv database configuration file */
57 bool auth_enabled; /* defaults to FALSE */
58 bool auth_allow_guests; /* defaults to FALSE */
59 bool auth_allow_newusers; /* defaults to FALSE */
61 int fatal_assertions; /* default to -1 (disabled). */
62};
63
64/* used in savegame values */
65#define SPECENUM_NAME server_states
66#define SPECENUM_VALUE0 S_S_INITIAL
67#define SPECENUM_VALUE1 S_S_RUNNING
68#define SPECENUM_VALUE2 S_S_OVER
69#include "specenum_gen.h"
70
71#define IDENTITY_NUMBER_SIZE 250000
73
74/* Structure for holding global server data.
75 *
76 * TODO: Lots more variables could be added here. */
77extern struct civserver {
80
81 /* this counter creates all the city and unit numbers used.
82 * arbitrarily starts at 101, but wraps to 1.
83 * use identity_number()
84 */
85#define IDENTITY_NUMBER_SKIP (100)
87
90
91
92void init_game_seed(void);
93void srv_init(void);
94void fc__noreturn srv_main(void);
95void fc__noreturn server_quit(void);
96void save_game_auto(const char *save_reason, enum autosave_type type);
97
100
101void check_for_full_turn_done(void);
102bool check_for_game_over(void);
103bool game_was_started(void);
104
111
112bool server_packet_input(struct connection *pconn, void *packet, int type);
113void start_game(void);
114const char *pick_random_player_name(const struct nation_type *pnation);
115void player_nation_defaults(struct player *pplayer, struct nation_type *pnation,
116 bool set_name);
117void send_all_info(struct conn_list *dest);
118
119void identity_number_release(int id);
120void identity_number_reserve(int id);
121int identity_number(void);
123void server_game_free(void);
124const char *aifill(int amount);
125
126extern struct server_arguments srvarg;
127
128extern bool force_end_of_sniff;
129
131
132#endif /* FC__SRV_MAIN_H */
#define BV_DEFINE(name, bits)
Definition bitvector.h:140
char * incite_cost
Definition comments.c:76
int server_setting_id
Definition fc_types.h:778
#define MAX_LEN_GAME_IDENTIFIER
Definition fc_types.h:71
autosave_type
Definition game.h:59
GType type
Definition repodlgs.c:1313
const char * name
Definition inputfile.c:127
log_level
Definition log.h:29
announce_type
Definition net_types.h:53
void server_game_init(bool keep_ruleset_value)
Definition srv_main.c:3497
const char * pick_random_player_name(const struct nation_type *pnation)
Definition srv_main.c:2844
void identity_number_release(int id)
Definition srv_main.c:2027
void player_nation_defaults(struct player *pplayer, struct nation_type *pnation, bool set_name)
Definition srv_main.c:2621
struct civserver server
bool force_end_of_sniff
Definition srv_main.c:193
void start_game(void)
Definition srv_main.c:1878
const char * aifill(int amount)
Definition srv_main.c:2506
void save_game_auto(const char *save_reason, enum autosave_type type)
Definition srv_main.c:1837
void set_server_state(enum server_states newstate)
Definition srv_main.c:346
const char * server_ss_name_get(server_setting_id id)
Definition srv_main.c:3670
bool game_was_started(void)
Definition srv_main.c:354
void identity_number_reserve(int id)
Definition srv_main.c:2035
struct server_arguments srvarg
Definition srv_main.c:181
#define IDENTITY_NUMBER_SIZE
Definition srv_main.h:71
void fc__noreturn srv_main(void)
Definition srv_main.c:3566
bool server_ss_val_bool_get(server_setting_id id)
Definition srv_main.c:3700
int identity_number(void)
Definition srv_main.c:2061
server_setting_id server_ss_by_name(const char *name)
Definition srv_main.c:3655
void check_for_full_turn_done(void)
Definition srv_main.c:2256
void srv_init(void)
Definition srv_main.c:232
bool server_packet_input(struct connection *pconn, void *packet, int type)
Definition srv_main.c:2092
int server_ss_val_int_get(server_setting_id id)
Definition srv_main.c:3715
unsigned int server_ss_val_bitwise_get(server_setting_id id)
Definition srv_main.c:3730
void send_all_info(struct conn_list *dest)
Definition srv_main.c:730
void init_game_seed(void)
Definition srv_main.c:208
void fc__noreturn server_quit(void)
Definition srv_main.c:1915
void update_nations_with_startpos(void)
Definition srv_main.c:2311
enum sset_type server_ss_type_get(server_setting_id id)
Definition srv_main.c:3685
bool check_for_game_over(void)
Definition srv_main.c:368
enum server_states server_state(void)
Definition srv_main.c:338
void server_game_free(void)
Definition srv_main.c:3521
unsigned identity_number
Definition srv_main.h:86
char game_identifier[MAX_LEN_GAME_IDENTIFIER]
Definition srv_main.h:88
int nbarbarians
Definition srv_main.h:79
int playable_nations
Definition srv_main.h:78
bool metaconnection_persistent
Definition srv_main.h:30
char * bind_addr
Definition srv_main.h:34
enum log_level loglevel
Definition srv_main.h:40
char metaserver_addr[256]
Definition srv_main.h:29
char * scenarios_pathname
Definition srv_main.h:47
enum announce_type announce
Definition srv_main.h:60
char load_filename[512]
Definition srv_main.h:44
char * fcdb_conf
Definition srv_main.h:56
bool auth_allow_guests
Definition srv_main.h:58
char * saves_pathname
Definition srv_main.h:46
char * log_filename
Definition srv_main.h:42
char * ranklog_filename
Definition srv_main.h:43
bool metaserver_no_send
Definition srv_main.h:28
char * bind_meta_addr
Definition srv_main.h:38
unsigned short int metaserver_port
Definition srv_main.h:32
bool auth_allow_newusers
Definition srv_main.h:59
char * script_filename
Definition srv_main.h:45
char serverid[256]
Definition srv_main.h:49
char identity_name[256]
Definition srv_main.h:31
#define fc__noreturn
Definition support.h:125