civ2civ3: improve README.civ2civ3 text.
[freeciv.git] / server / savecompat.h
blob3d56f9a26c770384a4dc8ba967f5e66225a4a951
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 sgf_version { SAVEGAME_2, SAVEGAME_3 };
29 enum tile_special_type {
30 S_IRRIGATION,
31 S_MINE,
32 S_POLLUTION,
33 S_HUT,
34 S_FARMLAND,
35 S_FALLOUT,
37 /* internal values not saved */
38 S_LAST,
40 S_OLD_FORTRESS,
41 S_OLD_AIRBASE,
42 S_OLD_ROAD,
43 S_OLD_RAILROAD,
44 S_OLD_RIVER
47 struct loaddata {
48 struct section_file *file;
49 const char *secfile_options;
50 int version;
52 /* loaded in sg_load_savefile(); needed in sg_load_player() */
53 struct {
54 const char **order;
55 size_t size;
56 } improvement;
57 /* loaded in sg_load_savefile(); needed in sg_load_player() */
58 struct {
59 const char **order;
60 size_t size;
61 } technology;
62 /* loaded in sg_load_savefile(); needed in sg_load_player() */
63 struct {
64 const char **order;
65 size_t size;
66 } activities;
67 /* loaded in sg_load_savefile(); needed in sg_load_player() */
68 struct {
69 const char **order;
70 size_t size;
71 } trait;
72 /* loaded in sg_load_savefile(); needed in sg_load_map(), ... */
73 struct {
74 struct extra_type **order;
75 size_t size;
76 } extra;
77 /* loaded in sg_load_savefile(); needed in sg_load_players_basic() */
78 struct {
79 struct multiplier **order;
80 size_t size;
81 } multiplier;
82 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
83 * Deprecated in 3.0 (savegame3.c) */
84 struct {
85 enum tile_special_type *order;
86 size_t size;
87 } special;
88 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
89 * Deprecated in 3.0 (savegame3.c) */
90 struct {
91 struct base_type **order;
92 size_t size;
93 } base;
94 /* loaded in sg_load_savefile(); needed in sg_load_map(), ...
95 * Deprecated in 3.0 (savegame3.c) */
96 struct {
97 struct road_type **order;
98 size_t size;
99 } road;
100 /* loaded in sg_load_savefile(); needed in sg_load_(), ... */
101 struct {
102 struct specialist **order;
103 size_t size;
104 } specialist;
105 /* loaded in sg_load_savefile(); needed in sg_load_player_main(), ... */
106 struct {
107 enum diplstate_type *order;
108 size_t size;
109 } ds_t;
110 /* loaded in sg_load_savefile(); needed in sg_load_player_unit(), ... */
111 struct {
112 enum gen_action *order;
113 size_t size;
114 } action;
115 /* loaded in sg_load_savefile(); needed in sg_load_player_unit(), ... */
116 struct {
117 enum action_decision *order;
118 size_t size;
119 } act_dec;
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() */
125 RANDOM_STATE rstate;
127 /* loaded in sg_load_map_worked(); needed in sg_load_player_cities() */
128 int *worked_tiles;
131 #define log_sg log_error
133 #define sg_check_ret(...) \
134 if (!sg_success) { \
135 return; \
137 #define sg_check_ret_val(_val) \
138 if (!sg_success) { \
139 return _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__); \
149 return; \
151 #define sg_warn_ret_val(condition, _val, message, ...) \
152 if (!(condition)) { \
153 log_sg(message, ## __VA_ARGS__); \
154 return _val; \
157 #define sg_failure_ret(condition, message, ...) \
158 if (!(condition)) { \
159 sg_success = FALSE; \
160 log_sg(message, ## __VA_ARGS__); \
161 sg_check_ret(); \
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 */