Freeciv-3.2
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 struct {
54 const char **order;
55 size_t size;
57 /* loaded in sg_load_savefile(); needed in sg_load_player() */
58 struct {
59 const char **order;
60 size_t size;
62 /* loaded in sg_load_savefile(); needed in sg_load_player() */
63 struct {
64 const char **order;
65 size_t size;
67 /* loaded in sg_load_savefile(); needed in sg_load_player() */
68 struct {
69 const char **order;
70 size_t size;
72 /* loaded in sg_load_savefile(); needed in sg_load_player() */
73 struct {
74 const char **order;
75 size_t size;
77 /* loaded in sg_load_savefile(); needed in sg_load_map(), ... */
78 struct {
79 struct extra_type **order;
80 size_t size;
82 /* loaded in sg_load_savefile(); needed in sg_load_players_basic() */
83 struct {
84 struct multiplier **order;
85 size_t size;
87 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
88 * Deprecated in 3.0 (savegame3.c) */
89 struct {
91 size_t size;
93 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
94 * Deprecated in 3.0 (savegame3.c) */
95 struct {
96 struct base_type **order;
97 size_t size;
99 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
100 * Deprecated in 3.0 (savegame3.c) */
101 struct {
102 struct road_type **order;
103 size_t size;
105 /* loaded in sg_load_savefile(); needed in sg_load_(), ... */
106 struct {
108 size_t size;
110 /* loaded in sg_load_savefile(); needed in sg_load_player_main(), ... */
111 /* Deprecated in 3.0 (savegame3.c) Still saved up to 3.1. */
112 struct {
114 size_t size;
116 /* loaded in sg_load_savefile(); needed in sg_load_player_unit(), ... */
117 struct {
119 size_t size;
121 /* loaded in sg_load_savefile(); needed in sg_load_player_unit(), ... */
122 struct {
124 size_t size;
126 /* loaded in sg_load_savefile(); needed in sg_load_player_unit(), ... */
127 struct {
129 size_t size;
131 struct {
132 enum city_options *order;
133 size_t size;
135
136 /* loaded in sg_load_game(); needed in sg_load_random(), ... */
138
139 /* loaded in sg_load_random(); needed in sg_load_sanitycheck() */
141
142 /* loaded in sg_load_map_worked(); needed in sg_load_player_cities() */
144};
145
146#define log_sg log_error
147/* Fixing known problems from older savegame formats */
148#define log_sgfix log_normal
149
150#define sg_check_ret(...) \
151 if (!sg_success) { \
152 return; \
153 }
154
155#define sg_check_ret_val(_val) \
156 if (!sg_success) { \
157 return _val; \
158 }
159
160#define sg_warn(condition, message, ...) \
161 if (!(condition)) { \
162 log_sg(message, ## __VA_ARGS__); \
163 }
164
165#define sg_warn_ret(condition, message, ...) \
166 if (!(condition)) { \
167 log_sg(message, ## __VA_ARGS__); \
168 return; \
169 }
170
171#define sg_warn_ret_val(condition, _val, message, ...) \
172 if (!(condition)) { \
173 log_sg(message, ## __VA_ARGS__); \
174 return _val; \
175 }
176
177#define sg_failure_ret(condition, message, ...) \
178 if (!(condition)) { \
179 log_sg(message, ## __VA_ARGS__); \
180 sg_success = FALSE; \
181 sg_check_ret(); \
182 }
183
184#define sg_failure_ret_val(condition, _val, message, ...) \
185 if (!(condition)) { \
186 log_sg(message, ## __VA_ARGS__); \
187 sg_success = FALSE; \
188 sg_check_ret_val(_val); \
189 }
190
191/* Resist urge to write version numbers with leading zero; "030?0?00",
192 * as that makes compiler to consider them octal. */
193#define sg_regr(fixversion, message, ...) \
194 if (loading->full_version >= fixversion) { \
195 log_sg(message, ## __VA_ARGS__); \
196 } else { \
197 log_sgfix(message, ## __VA_ARGS__); \
198 }
199
203int current_compat_ver(void);
204
205#define hex_chars "0123456789abcdef"
206
207char bin2ascii_hex(int value, int halfbyte_wanted);
208int ascii_hex2bin(char ch, int halfbyte);
209
210int char2num(char ch);
211
214struct extra_type *special_extra_get(int spe);
215
216struct extra_type *resource_by_identifier(const char identifier);
217
218enum ai_level ai_level_convert(int old_level);
219enum barbarian_type barb_type_convert(int old_type);
220
221/* Old savegames might have padding up to this amount of trade routes */
222#define MAX_TRADE_ROUTES_OLD 5
223
224#endif /* FC__SAVECOMPAT_H */
char * incite_cost
Definition comments.c:75
int action_id
Definition fc_types.h:389
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:306
int current_compat_ver(void)
Definition savecompat.c:205
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)
char bin2ascii_hex(int value, int halfbyte_wanted)
Definition savecompat.c:215
int char2num(char ch)
Definition savecompat.c:251
void sg_load_compat(struct loaddata *loading, enum sgf_version format_class)
Definition savecompat.c:138
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:227
struct extra_type * special_extra_get(int spe)
Definition savecompat.c:292
enum tile_special_type special_by_rule_name(const char *name)
Definition savecompat.c:266
void sg_load_post_load_compat(struct loaddata *loading, enum sgf_version format_class)
Definition savecompat.c:183
const char * special_rule_name(enum tile_special_type type)
Definition savecompat.c:282
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:107
enum tile_special_type * order
Definition savecompat.h:90
struct loaddata::@111 act_dec
RANDOM_STATE rstate
Definition savecompat.h:140
struct loaddata::@107 road
struct loaddata::@106 base
struct loaddata::@98 counter
struct loaddata::@104 multiplier
struct road_type ** order
Definition savecompat.h:102
struct loaddata::@113 coptions
int full_version
Definition savecompat.h:51
enum city_options * order
Definition savecompat.h:132
size_t size
Definition savecompat.h:55
enum action_decision * order
Definition savecompat.h:123
struct loaddata::@109 ds_t
struct base_type ** order
Definition savecompat.h:96
struct loaddata::@110 action
struct loaddata::@112 ssa
struct extra_type ** order
Definition savecompat.h:79
struct loaddata::@105 special
struct multiplier ** order
Definition savecompat.h:84
enum server_states server_state
Definition savecompat.h:137
struct loaddata::@100 technology
struct loaddata::@108 specialist
const char ** order
Definition savecompat.h:54
struct loaddata::@101 activities
struct loaddata::@102 trait
struct loaddata::@99 improvement
int * worked_tiles
Definition savecompat.h:143
action_id * order
Definition savecompat.h:118
struct loaddata::@103 extra
enum diplstate_type * order
Definition savecompat.h:113
struct section_file * file
Definition savecompat.h:48
enum server_side_agent * order
Definition savecompat.h:128