Fixed the way Qt-client popup_terrain_info() checks for empty string.
[freeciv.git] / server / savecompat.h
blob4c950ead2c2e4ab47e6de865856132299a3d936e
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__SAVECOMPAT_H
14 #define FC__SAVECOMPAT_H
16 /* utility */
17 #include "rand.h"
19 /* server */
20 #include "srv_main.h"
22 struct section_file;
23 struct extra_type;
24 struct base_type;
25 struct road_type;
27 enum tile_special_type {
28 S_IRRIGATION,
29 S_MINE,
30 S_POLLUTION,
31 S_HUT,
32 S_FARMLAND,
33 S_FALLOUT,
35 /* internal values not saved */
36 S_LAST,
38 S_OLD_FORTRESS,
39 S_OLD_AIRBASE,
40 S_OLD_ROAD,
41 S_OLD_RAILROAD,
42 S_OLD_RIVER
45 struct loaddata {
46 struct section_file *file;
47 const char *secfile_options;
48 int version;
50 /* loaded in sg_load_savefile(); needed in sg_load_player() */
51 struct {
52 const char **order;
53 size_t size;
54 } improvement;
55 /* loaded in sg_load_savefile(); needed in sg_load_player() */
56 struct {
57 const char **order;
58 size_t size;
59 } technology;
60 /* loaded in sg_load_savefile(); needed in sg_load_player() */
61 struct {
62 const char **order;
63 size_t size;
64 } trait;
65 /* loaded in sg_load_savefile(); needed in sg_load_map(), ... */
66 struct {
67 struct extra_type **order;
68 size_t size;
69 } extra;
70 /* loaded in sg_load_savefile(); needed in sg_load_players_basic() */
71 struct {
72 struct multiplier **order;
73 size_t size;
74 } multiplier;
75 /* loaded in sg_load_savefile(); needed in sg_load_map(), ... */
76 struct {
77 enum tile_special_type *order;
78 size_t size;
79 } special;
80 /* loaded in sg_load_savefile(); needed in sg_load_map(), ... */
81 struct {
82 struct base_type **order;
83 size_t size;
84 } base;
85 /* loaded in sg_load_savefile(); needed in sg_load_map(), ... */
86 struct {
87 struct road_type **order;
88 size_t size;
89 } road;
90 /* loaded in sg_load_savefile(); needed in sg_load_(), ... */
91 struct {
92 struct specialist **order;
93 size_t size;
94 } specialist;
95 /* loaded in sg_load_savefile(); needed in sg_load_player_main(), ... */
96 struct {
97 enum diplstate_type *order;
98 size_t size;
99 } ds_t;
101 /* loaded in sg_load_game(); needed in sg_load_random(), ... */
102 enum server_states server_state;
104 /* loaded in sg_load_random(); needed in sg_load_sanitycheck() */
105 RANDOM_STATE rstate;
107 /* loaded in sg_load_map_worked(); needed in sg_load_player_cities() */
108 int *worked_tiles;
111 #define log_sg log_error
113 #define sg_check_ret(...) \
114 if (!sg_success) { \
115 return; \
117 #define sg_check_ret_val(_val) \
118 if (!sg_success) { \
119 return _val; \
122 #define sg_warn(condition, message, ...) \
123 if (!(condition)) { \
124 log_sg(message, ## __VA_ARGS__); \
126 #define sg_warn_ret(condition, message, ...) \
127 if (!(condition)) { \
128 log_sg(message, ## __VA_ARGS__); \
129 return; \
131 #define sg_warn_ret_val(condition, _val, message, ...) \
132 if (!(condition)) { \
133 log_sg(message, ## __VA_ARGS__); \
134 return _val; \
137 #define sg_failure_ret(condition, message, ...) \
138 if (!(condition)) { \
139 sg_success = FALSE; \
140 log_sg(message, ## __VA_ARGS__); \
141 sg_check_ret(); \
143 #define sg_failure_ret_val(condition, _val, message, ...) \
144 if (!(condition)) { \
145 sg_success = FALSE; \
146 log_sg(message, ## __VA_ARGS__); \
147 sg_check_ret_val(_val); \
150 void sg_load_compat(struct loaddata *loading);
151 int current_compat_ver(void);
153 #define hex_chars "0123456789abcdef"
155 char bin2ascii_hex(int value, int halfbyte_wanted);
156 int ascii_hex2bin(char ch, int halfbyte);
158 enum tile_special_type special_by_rule_name(const char *name);
159 const char *special_rule_name(enum tile_special_type type);
161 enum ai_level ai_level_convert(int old_level);
162 enum barbarian_type barb_type_convert(int old_type);
164 #endif /* FC__SAVECOMPAT_H */