Freeciv-3.1
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
46
47struct loaddata {
49 const char *secfile_options;
52
53 /* loaded in sg_load_savefile(); needed in sg_load_player() */
54 struct {
55 const char **order;
56 size_t size;
58 /* loaded in sg_load_savefile(); needed in sg_load_player() */
59 struct {
60 const char **order;
61 size_t size;
63 /* loaded in sg_load_savefile(); needed in sg_load_player() */
64 struct {
65 const char **order;
66 size_t size;
68 /* loaded in sg_load_savefile(); needed in sg_load_player() */
69 struct {
70 const char **order;
71 size_t size;
73 /* loaded in sg_load_savefile(); needed in sg_load_map(), ... */
74 struct {
75 struct extra_type **order;
76 size_t size;
78 /* loaded in sg_load_savefile(); needed in sg_load_players_basic() */
79 struct {
80 struct multiplier **order;
81 size_t size;
83 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
84 * Deprecated in 3.0 (savegame3.c) */
85 struct {
87 size_t size;
89 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
90 * Deprecated in 3.0 (savegame3.c) */
91 struct {
92 struct base_type **order;
93 size_t size;
95 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
96 * Deprecated in 3.0 (savegame3.c) */
97 struct {
98 struct road_type **order;
99 size_t size;
101 /* loaded in sg_load_savefile(); needed in sg_load_(), ... */
102 struct {
104 size_t size;
106 /* loaded in sg_load_savefile(); needed in sg_load_player_main(), ... */
107 struct {
108 enum diplstate_type *order;
109 size_t size;
111 /* loaded in sg_load_savefile(); needed in sg_load_player_unit(), ... */
112 struct {
114 size_t size;
116 /* loaded in sg_load_savefile(); needed in sg_load_player_unit(), ... */
117 struct {
118 enum action_decision *order;
119 size_t size;
121 /* loaded in sg_load_savefile(); needed in sg_load_player_unit(), ... */
122 struct {
123 enum server_side_agent *order;
124 size_t size;
126
127 /* loaded in sg_load_game(); needed in sg_load_random(), ... */
128 enum server_states server_state;
129
130 /* loaded in sg_load_random(); needed in sg_load_sanitycheck() */
132
133 /* loaded in sg_load_map_worked(); needed in sg_load_player_cities() */
135};
136
137#define log_sg log_error
138/* Fixing known problems from older savegame formats */
139#define log_sgfix log_normal
140
141#define sg_check_ret(...) \
142 if (!sg_success) { \
143 return; \
144 }
145
146#define sg_check_ret_val(_val) \
147 if (!sg_success) { \
148 return _val; \
149 }
150
151#define sg_warn(condition, message, ...) \
152 if (!(condition)) { \
153 log_sg(message, ## __VA_ARGS__); \
154 }
155
156#define sg_warn_ret(condition, message, ...) \
157 if (!(condition)) { \
158 log_sg(message, ## __VA_ARGS__); \
159 return; \
160 }
161
162#define sg_warn_ret_val(condition, _val, message, ...) \
163 if (!(condition)) { \
164 log_sg(message, ## __VA_ARGS__); \
165 return _val; \
166 }
167
168#define sg_failure_ret(condition, message, ...) \
169 if (!(condition)) { \
170 log_sg(message, ## __VA_ARGS__); \
171 sg_success = FALSE; \
172 sg_check_ret(); \
173 }
174
175#define sg_failure_ret_val(condition, _val, message, ...) \
176 if (!(condition)) { \
177 log_sg(message, ## __VA_ARGS__); \
178 sg_success = FALSE; \
179 sg_check_ret_val(_val); \
180 }
181
182/* Resist urge to write version numbers with leading zero; "030?0?00",
183 * as that makes compiler to consider them octal. */
184#define sg_regr(fixversion, message, ...) \
185 if (loading->full_version >= fixversion) { \
186 log_sg(message, ## __VA_ARGS__); \
187 } else { \
188 log_sgfix(message, ## __VA_ARGS__); \
189 }
190
191void sg_load_compat(struct loaddata *loading, enum sgf_version format_class);
192void sg_load_post_load_compat(struct loaddata *loading,
193 enum sgf_version format_class);
194int current_compat_ver(void);
195
196#define hex_chars "0123456789abcdef"
197
198char bin2ascii_hex(int value, int halfbyte_wanted);
199int ascii_hex2bin(char ch, int halfbyte);
200
201int char2num(char ch);
202
205struct extra_type *special_extra_get(int spe);
206
207struct extra_type *resource_by_identifier(const char identifier);
208
209enum ai_level ai_level_convert(int old_level);
210enum barbarian_type barb_type_convert(int old_type);
211
214
215#endif /* FC__SAVECOMPAT_H */
static void road(QVariant data1, QVariant data2)
Definition dialogs.cpp:2819
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:2840
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
int Road_type_id
Definition fc_types.h:354
int action_id
Definition fc_types.h:359
int Base_type_id
Definition fc_types.h:353
GType type
Definition repodlgs.c:1312
const char * name
Definition inputfile.c:127
struct extra_type * resource_by_identifier(const char identifier)
Definition savecompat.c:300
int current_compat_ver(void)
Definition savecompat.c:199
tile_special_type
Definition savecompat.h:29
@ S_MINE
Definition savecompat.h:31
@ S_OLD_FORTRESS
Definition savecompat.h:40
@ S_OLD_AIRBASE
Definition savecompat.h:41
@ S_HUT
Definition savecompat.h:33
@ S_FALLOUT
Definition savecompat.h:35
@ S_POLLUTION
Definition savecompat.h:32
@ S_OLD_RIVER
Definition savecompat.h:44
@ S_FARMLAND
Definition savecompat.h:34
@ S_OLD_ROAD
Definition savecompat.h:42
@ S_LAST
Definition savecompat.h:38
@ S_IRRIGATION
Definition savecompat.h:30
@ S_OLD_RAILROAD
Definition savecompat.h:43
enum barbarian_type barb_type_convert(int old_type)
void set_unit_activity_road(struct unit *punit, Road_type_id road)
char bin2ascii_hex(int value, int halfbyte_wanted)
Definition savecompat.c:209
int char2num(char ch)
Definition savecompat.c:245
void sg_load_compat(struct loaddata *loading, enum sgf_version format_class)
Definition savecompat.c:132
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)
void set_unit_activity_base(struct unit *punit, Base_type_id base)
int ascii_hex2bin(char ch, int halfbyte)
Definition savecompat.c:221
struct extra_type * special_extra_get(int spe)
Definition savecompat.c:286
enum tile_special_type special_by_rule_name(const char *name)
Definition savecompat.c:260
void sg_load_post_load_compat(struct loaddata *loading, enum sgf_version format_class)
Definition savecompat.c:177
const char * special_rule_name(enum tile_special_type type)
Definition savecompat.c:276
size_t size
Definition specvec.h:72
const char * secfile_options
Definition savecompat.h:49
int version
Definition savecompat.h:50
struct specialist ** order
Definition savecompat.h:103
enum tile_special_type * order
Definition savecompat.h:86
struct loaddata::@111 act_dec
RANDOM_STATE rstate
Definition savecompat.h:131
struct loaddata::@107 road
struct loaddata::@106 base
struct loaddata::@104 multiplier
struct road_type ** order
Definition savecompat.h:98
int full_version
Definition savecompat.h:51
size_t size
Definition savecompat.h:56
enum action_decision * order
Definition savecompat.h:118
struct loaddata::@109 ds_t
struct base_type ** order
Definition savecompat.h:92
struct loaddata::@110 action
struct loaddata::@112 ssa
struct extra_type ** order
Definition savecompat.h:75
struct loaddata::@105 special
struct multiplier ** order
Definition savecompat.h:80
enum server_states server_state
Definition savecompat.h:128
struct loaddata::@100 technology
struct loaddata::@108 specialist
const char ** order
Definition savecompat.h:55
struct loaddata::@101 activities
struct loaddata::@102 trait
struct loaddata::@99 improvement
int * worked_tiles
Definition savecompat.h:134
action_id * order
Definition savecompat.h:113
struct loaddata::@103 extra
enum diplstate_type * order
Definition savecompat.h:108
struct section_file * file
Definition savecompat.h:48
enum server_side_agent * order
Definition savecompat.h:123
Definition unit.h:138