Freeciv-3.4
Loading...
Searching...
No Matches
savecompat.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__SAVECOMPAT_H
14#define FC__SAVECOMPAT_H
15
16/* utility */
17#include "rand.h"
18
19/* server */
20#include "srv_main.h"
21
22struct section_file;
23struct extra_type;
24struct base_type;
25struct road_type;
26
28
44
45struct loaddata {
47 const char *secfile_options;
50
51 struct {
52 const char **order;
53 size_t size;
55 /* loaded in sg_load_savefile(); needed in sg_load_player() */
56 struct {
57 const char **order;
58 size_t size;
60 /* loaded in sg_load_savefile(); needed in sg_load_player() */
61 struct {
62 const char **order;
63 size_t size;
65 /* loaded in sg_load_savefile(); needed in sg_load_player() */
66 struct {
67 const char **order;
68 size_t size;
70 /* loaded in sg_load_savefile(); needed in sg_load_player() */
71 struct {
72 const char **order;
73 size_t size;
75 /* loaded in sg_load_savefile(); needed in sg_load_map(), ... */
76 struct {
77 struct extra_type **order;
78 size_t size;
80 /* loaded in sg_load_savefile(); needed in sg_load_players_basic() */
81 struct {
82 struct multiplier **order;
83 size_t size;
85 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
86 * Deprecated in 3.0 (savegame3.c) */
87 struct {
89 size_t size;
91 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
92 * Deprecated in 3.0 (savegame3.c) */
93 struct {
94 struct base_type **order;
95 size_t size;
97 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
98 * Deprecated in 3.0 (savegame3.c) */
99 struct {
100 struct road_type **order;
101 size_t size;
103 /* loaded in sg_load_savefile(); needed in sg_load_(), ... */
104 struct {
106 size_t size;
108 /* loaded in sg_load_savefile(); needed in sg_load_player_main(), ... */
109 /* Deprecated in 3.0 (savegame3.c) Still saved up to 3.1. */
110 struct {
112 size_t size;
114 /* loaded in sg_load_savefile(); needed in sg_load_player_unit(), ... */
115 struct {
117 size_t size;
119 /* loaded in sg_load_savefile(); needed in sg_load_player_unit(), ... */
120 struct {
122 size_t size;
124 /* loaded in sg_load_savefile(); needed in sg_load_player_unit(), ... */
125 struct {
127 size_t size;
129 struct {
130 enum city_options *order;
131 size_t size;
133
134 /* loaded in sg_load_game(); needed in sg_load_random(), ... */
136
137 /* loaded in sg_load_random(); needed in sg_load_sanitycheck() */
139
140 /* loaded in sg_load_map_worked(); needed in sg_load_player_cities() */
142};
143
144#define log_sg log_error
145/* Fixing known problems from older savegame formats */
146#define log_sgfix log_normal
147
148#define sg_check_ret(...) \
149 if (!sg_success) { \
150 return; \
151 }
152
153#define sg_check_ret_val(_val) \
154 if (!sg_success) { \
155 return _val; \
156 }
157
158#define sg_warn(condition, message, ...) \
159 if (!(condition)) { \
160 log_sg(message, ## __VA_ARGS__); \
161 }
162
163#define sg_warn_ret(condition, message, ...) \
164 if (!(condition)) { \
165 log_sg(message, ## __VA_ARGS__); \
166 return; \
167 }
168
169#define sg_warn_ret_val(condition, _val, message, ...) \
170 if (!(condition)) { \
171 log_sg(message, ## __VA_ARGS__); \
172 return _val; \
173 }
174
175#define sg_failure_ret(condition, message, ...) \
176 if (!(condition)) { \
177 log_sg(message, ## __VA_ARGS__); \
178 sg_success = FALSE; \
179 sg_check_ret(); \
180 }
181
182#define sg_failure_ret_val(condition, _val, message, ...) \
183 if (!(condition)) { \
184 log_sg(message, ## __VA_ARGS__); \
185 sg_success = FALSE; \
186 sg_check_ret_val(_val); \
187 }
188
189/* Resist urge to write version numbers with leading zero; "030?0?00",
190 * as that makes compiler to consider them octal. */
191#define sg_regr(fixversion, message, ...) \
192 if (loading->full_version >= fixversion) { \
193 log_sg(message, ## __VA_ARGS__); \
194 } else { \
195 log_sgfix(message, ## __VA_ARGS__); \
196 }
197
201int current_compat_ver(void);
202
203#define hex_chars "0123456789abcdef"
204
205char bin2ascii_hex(int value, int halfbyte_wanted);
206int ascii_hex2bin(char ch, int halfbyte);
207
208int char2num(char ch);
209
212struct extra_type *special_extra_get(int spe);
213
214struct extra_type *resource_by_identifier(const char identifier);
215
216enum ai_level ai_level_convert(int old_level);
217enum barbarian_type barb_type_convert(int old_type);
218
219/* Old savegames might have padding up to this amount of trade routes */
220#define MAX_TRADE_ROUTES_OLD 5
221
222#endif /* FC__SAVECOMPAT_H */
char * incite_cost
Definition comments.c:77
int action_id
Definition fc_types.h:250
GType type
Definition repodlgs.c:1313
const char * name
Definition inputfile.c:127
struct extra_type * resource_by_identifier(const char identifier)
Definition savecompat.c:335
int current_compat_ver(void)
Definition savecompat.c:233
tile_special_type
Definition savecompat.h:29
@ S_MINE
Definition savecompat.h:31
@ S_HUT
Definition savecompat.h:33
@ S_FALLOUT
Definition savecompat.h:35
@ S_POLLUTION
Definition savecompat.h:32
@ S_OLD_RIVER
Definition savecompat.h:42
@ S_FARMLAND
Definition savecompat.h:34
@ S_OLD_ROAD
Definition savecompat.h:40
@ S_LAST
Definition savecompat.h:38
@ S_IRRIGATION
Definition savecompat.h:30
@ S_OLD_RAILROAD
Definition savecompat.h:41
enum barbarian_type barb_type_convert(int old_type)
char bin2ascii_hex(int value, int halfbyte_wanted)
Definition savecompat.c:243
int char2num(char ch)
Definition savecompat.c:279
void sg_load_compat(struct loaddata *loading, enum sgf_version format_class)
Definition savecompat.c:154
sgf_version
Definition savecompat.h:27
@ SAVEGAME_2
Definition savecompat.h:27
@ SAVEGAME_3
Definition savecompat.h:27
enum ai_level ai_level_convert(int old_level)
int ascii_hex2bin(char ch, int halfbyte)
Definition savecompat.c:255
struct extra_type * special_extra_get(int spe)
Definition savecompat.c:320
enum tile_special_type special_by_rule_name(const char *name)
Definition savecompat.c:294
void sg_load_post_load_compat(struct loaddata *loading, enum sgf_version format_class)
Definition savecompat.c:205
const char * special_rule_name(enum tile_special_type type)
Definition savecompat.c:310
size_t size
Definition specvec.h:72
struct loaddata::@103 improvement
const char * secfile_options
Definition savecompat.h:47
struct loaddata::@112 specialist
int version
Definition savecompat.h:48
struct specialist ** order
Definition savecompat.h:105
enum tile_special_type * order
Definition savecompat.h:88
RANDOM_STATE rstate
Definition savecompat.h:138
struct road_type ** order
Definition savecompat.h:100
int full_version
Definition savecompat.h:49
enum city_options * order
Definition savecompat.h:130
struct loaddata::@106 trait
size_t size
Definition savecompat.h:53
enum action_decision * order
Definition savecompat.h:121
struct base_type ** order
Definition savecompat.h:94
struct extra_type ** order
Definition savecompat.h:77
struct loaddata::@113 ds_t
struct loaddata::@109 special
struct loaddata::@105 activities
struct loaddata::@108 multiplier
struct multiplier ** order
Definition savecompat.h:82
struct loaddata::@116 ssa
enum server_states server_state
Definition savecompat.h:135
struct loaddata::@115 act_dec
struct loaddata::@110 base
const char ** order
Definition savecompat.h:52
struct loaddata::@111 road
struct loaddata::@114 action
struct loaddata::@107 extra
int * worked_tiles
Definition savecompat.h:141
action_id * order
Definition savecompat.h:116
struct loaddata::@104 technology
enum diplstate_type * order
Definition savecompat.h:111
struct loaddata::@102 counter
struct loaddata::@117 coptions
struct section_file * file
Definition savecompat.h:46
enum server_side_agent * order
Definition savecompat.h:126