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)
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
27 enum sgf_version
{ SAVEGAME_2
, SAVEGAME_3
};
29 enum tile_special_type
{
37 /* internal values not saved */
48 struct section_file
*file
;
49 const char *secfile_options
;
52 /* loaded in sg_load_savefile(); needed in sg_load_player() */
57 /* loaded in sg_load_savefile(); needed in sg_load_player() */
62 /* loaded in sg_load_savefile(); needed in sg_load_player() */
67 /* loaded in sg_load_savefile(); needed in sg_load_player() */
72 /* loaded in sg_load_savefile(); needed in sg_load_map(), ... */
74 struct extra_type
**order
;
77 /* loaded in sg_load_savefile(); needed in sg_load_players_basic() */
79 struct multiplier
**order
;
82 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
83 * Deprecated in 3.0 (savegame3.c) */
85 enum tile_special_type
*order
;
88 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
89 * Deprecated in 3.0 (savegame3.c) */
91 struct base_type
**order
;
94 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
95 * Deprecated in 3.0 (savegame3.c) */
97 struct road_type
**order
;
100 /* loaded in sg_load_savefile(); needed in sg_load_(), ... */
102 struct specialist
**order
;
105 /* loaded in sg_load_savefile(); needed in sg_load_player_main(), ... */
107 enum diplstate_type
*order
;
110 /* loaded in sg_load_savefile(); needed in sg_load_player_unit(), ... */
112 enum gen_action
*order
;
115 /* loaded in sg_load_savefile(); needed in sg_load_player_unit(), ... */
117 enum action_decision
*order
;
121 /* loaded in sg_load_game(); needed in sg_load_random(), ... */
122 enum server_states server_state
;
124 /* loaded in sg_load_random(); needed in sg_load_sanitycheck() */
127 /* loaded in sg_load_map_worked(); needed in sg_load_player_cities() */
131 #define log_sg log_error
133 #define sg_check_ret(...) \
137 #define sg_check_ret_val(_val) \
142 #define sg_warn(condition, message, ...) \
143 if (!(condition)) { \
144 log_sg(message, ## __VA_ARGS__); \
146 #define sg_warn_ret(condition, message, ...) \
147 if (!(condition)) { \
148 log_sg(message, ## __VA_ARGS__); \
151 #define sg_warn_ret_val(condition, _val, message, ...) \
152 if (!(condition)) { \
153 log_sg(message, ## __VA_ARGS__); \
157 #define sg_failure_ret(condition, message, ...) \
158 if (!(condition)) { \
159 sg_success = FALSE; \
160 log_sg(message, ## __VA_ARGS__); \
163 #define sg_failure_ret_val(condition, _val, message, ...) \
164 if (!(condition)) { \
165 sg_success = FALSE; \
166 log_sg(message, ## __VA_ARGS__); \
167 sg_check_ret_val(_val); \
170 void sg_load_compat(struct loaddata
*loading
, enum sgf_version format_class
);
171 int current_compat_ver(void);
173 #define hex_chars "0123456789abcdef"
175 char bin2ascii_hex(int value
, int halfbyte_wanted
);
176 int ascii_hex2bin(char ch
, int halfbyte
);
178 enum tile_special_type
special_by_rule_name(const char *name
);
179 const char *special_rule_name(enum tile_special_type type
);
180 struct extra_type
*special_extra_get(int spe
);
182 struct extra_type
*resource_by_identifier(const char identifier
);
184 enum ai_level
ai_level_convert(int old_level
);
185 enum barbarian_type
barb_type_convert(int old_type
);
187 #define ORDER_OLD_BUILD_CITY (-1)
188 #define ORDER_OLD_DISBAND (-2)
189 #define ORDER_OLD_BUILD_WONDER (-3)
190 #define ORDER_OLD_TRADE_ROUTE (-4)
191 #define ORDER_OLD_HOMECITY (-5)
192 int sg_order_to_action(int order
, struct unit
*act_unit
,
193 struct tile
*tgt_tile
);
195 #endif /* FC__SAVECOMPAT_H */