156#define SAVE_MAP_CHAR(ptile, GET_XY_CHAR, secfile, secpath, ...) \
158 char _line[wld.map.xsize + 1]; \
159 int _nat_x, _nat_y; \
161 for (_nat_y = 0; _nat_y < wld.map.ysize; _nat_y++) { \
162 for (_nat_x = 0; _nat_x < wld.map.xsize; _nat_x++) { \
163 struct tile *ptile = native_pos_to_tile(&(wld.map), _nat_x, _nat_y); \
164 fc_assert_action(ptile != NULL, continue); \
165 _line[_nat_x] = (GET_XY_CHAR); \
166 sg_failure_ret(fc_isprint(_line[_nat_x] & 0x7f), \
167 "Trying to write invalid map data at position " \
168 "(%d, %d) for path %s: '%c' (%d)", _nat_x, _nat_y, \
169 secpath, _line[_nat_x], _line[_nat_x]); \
171 _line[wld.map.xsize] = '\0'; \
172 secfile_insert_str(secfile, _line, secpath, ## __VA_ARGS__, _nat_y); \
203#define LOAD_MAP_CHAR(ch, ptile, SET_XY_CHAR, secfile, secpath, ...) \
205 int _nat_x, _nat_y; \
206 bool _printed_warning = FALSE; \
207 for (_nat_y = 0; _nat_y < wld.map.ysize; _nat_y++) { \
208 const char *_line = secfile_lookup_str(secfile, secpath, \
209 ## __VA_ARGS__, _nat_y); \
210 if (NULL == _line) { \
212 fc_snprintf(buf, sizeof(buf), secpath, ## __VA_ARGS__, _nat_y); \
213 log_verbose("Line not found='%s'", buf); \
214 _printed_warning = TRUE; \
216 } else if (strlen(_line) != wld.map.xsize) { \
218 fc_snprintf(buf, sizeof(buf), secpath, ## __VA_ARGS__, _nat_y); \
219 log_verbose("Line too short (expected %d got " SIZE_T_PRINTF \
220 ")='%s'", wld.map.xsize, strlen(_line), buf); \
221 _printed_warning = TRUE; \
224 for (_nat_x = 0; _nat_x < wld.map.xsize; _nat_x++) { \
225 const char ch = _line[_nat_x]; \
226 struct tile *ptile = native_pos_to_tile(&(wld.map), _nat_x, _nat_y); \
230 if (_printed_warning) { \
232 log_sg(_("Saved game contains incomplete map data. This can" \
233 " happen with old saved games, or it may indicate an" \
234 " invalid saved game file. Proceed at your own risk.")); \
239#define halfbyte_iterate_extras(e, num_extras_types) \
242 for (e = 0; 4 * e < (num_extras_types); e++) {
244#define halfbyte_iterate_extras_end \
249#define halfbyte_iterate_special(s, num_specials_types) \
251 enum tile_special_type s; \
252 for (s = 0; 4 * s < (num_specials_types); s++) {
254#define halfbyte_iterate_special_end \
259#define halfbyte_iterate_bases(b, num_bases_types) \
262 for (b = 0; 4 * b < (num_bases_types); b++) {
264#define halfbyte_iterate_bases_end \
269#define halfbyte_iterate_roads(r, num_roads_types) \
272 for (r = 0; 4 * r < (num_roads_types); r++) {
274#define halfbyte_iterate_roads_end \
280#define ORDER_OLD_BUILD_CITY (-1)
281#define ORDER_OLD_DISBAND (-2)
282#define ORDER_OLD_BUILD_WONDER (-3)
283#define ORDER_OLD_TRADE_ROUTE (-4)
284#define ORDER_OLD_HOMECITY (-5)
290static enum direction8
char2dir(
char dir);
293static int unquote_block(
const char *
const quoted_,
void *dest,
296 struct worklist *pwl,
const char *path, ...);
301 bool rivers_overlay);
307 const char *path,
int plrno);
330 bool rivers_overlay);
345 struct city *pcity,
const char *citystr,
346 int wlist_max_length);
350 const char *citystr);
355 const char *unitstr);
365 const char *citystr);
390 bool was_send_city_suppressed, was_send_tile_suppressed;
458 struct loaddata *loading = calloc(1,
sizeof(*loading));
599 return DIR8_SOUTHWEST;
603 return DIR8_SOUTHEAST;
609 return DIR8_NORTHWEST;
613 return DIR8_NORTHEAST;
617 return direction8_invalid();
628 case ACTIVITY_POLLUTION:
630 case ACTIVITY_OLD_ROAD:
634 case ACTIVITY_IRRIGATE:
636 case ACTIVITY_FORTIFIED:
638 case ACTIVITY_FORTRESS:
640 case ACTIVITY_SENTRY:
642 case ACTIVITY_OLD_RAILROAD:
644 case ACTIVITY_PILLAGE:
648 case ACTIVITY_EXPLORE:
650 case ACTIVITY_TRANSFORM:
652 case ACTIVITY_AIRBASE:
654 case ACTIVITY_FORTIFYING:
656 case ACTIVITY_FALLOUT:
660 case ACTIVITY_GEN_ROAD:
662 case ACTIVITY_CONVERT:
664 case ACTIVITY_UNKNOWN:
665 case ACTIVITY_PATROL_UNUSED:
666 case ACTIVITY_CULTIVATE:
682 enum unit_activity a;
684 for (a = 0; a < ACTIVITY_LAST; a++) {
687 if (activity == achar) {
693 return ACTIVITY_LAST;
704 int i, length, parsed, tmp;
706 const char *quoted = quoted_;
708 parsed = sscanf(quoted,
"%d", &length);
711 log_error(
_(
"Syntax error in attribute block."));
715 if (length > dest_length) {
719 quoted = strchr(quoted,
':');
721 if (quoted == NULL) {
722 log_error(
_(
"Syntax error in attribute block."));
728 for (i = 0; i < length; i++) {
729 tmp = strtol(quoted, &endptr, 16);
731 if ((endptr - quoted) != 2
733 || (tmp & 0xff) != tmp) {
734 log_error(
_(
"Syntax error in attribute block."));
738 ((
unsigned char *) dest)[i] = tmp;
750 struct worklist *pwl,
const char *path, ...)
766 "%s.wl_length", path_str);
768 for (i = 0; i < pwl->
length; i++) {
776 if (pwl->
entries[i].
kind == universals_n_invalid()) {
777 log_sg(
"%s.wl_value%d: unknown \"%s\" \"%s\".", path_str, i, kind,
785 for (; i < wlist_max_length; i++) {
821 if (!pch || ch ==
'\0') {
822 log_sg(
"Unknown hex value: '%c' (%d)", ch, ch);
828 for (i = 0; i < 4; i++) {
831 if (pextra == NULL) {
855 if (!pch || ch ==
'\0') {
856 log_sg(
"Unknown hex value: '%c' (%d)", ch, ch);
862 for (i = 0; i < 4; i++) {
883 if (bin & (1 << i)) {
907 enum extra_cause cause = EC_COUNT;
915 cause = EC_IRRIGATION;
921 cause = EC_POLLUTION;
934 if (cause != EC_COUNT) {
950 && (cause != EC_BASE || pterr->
base_time != 0)
951 && (cause != EC_ROAD || pterr->
road_time != 0)) {
990 if (!pch || ch ==
'\0') {
991 log_sg(
"Unknown hex value: '%c' (%d)", ch, ch);
997 for (i = 0; i < 4; i++) {
1000 if (pbase == NULL) {
1003 if (bin & (1 << i)) {
1019 const char *pch = strchr(
hex_chars, ch);
1021 if (!pch || ch ==
'\0') {
1022 log_sg(
"Unknown hex value: '%c' (%d)", ch, ch);
1028 for (i = 0; i < 4; i++) {
1031 if (proad == NULL) {
1034 if (bin & (1 << i)) {
1065 if (pterrain->identifier == ch) {
1070 log_fatal(
"Unknown terrain identifier '%c' in savegame.", ch);
1082 const char *path,
int plrno)
1084 char path_with_name[128];
1088 fc_snprintf(path_with_name,
sizeof(path_with_name),
1109 "%s: unknown technology \"%s\".", path_with_name,
name);
1125 "savefile.rulesetdir");
1133 if (version >= 30) {
1142 log_verbose(
"Savegame specified ruleset '%s'. Really loading '%s'.",
1158 const char *terr_name;
1175 "savefile.last_updated_as_year");
1180 "savefile.improvement_size");
1184 "savefile.improvement_vector");
1186 "Failed to load improvement order: %s",
1193 "savefile.technology_size");
1197 "savefile.technology_vector");
1199 "Failed to load technology order: %s",
1206 "savefile.activities_size");
1210 "savefile.activities_vector");
1212 "Failed to load activity order: %s",
1219 "savefile.trait_size");
1223 "savefile.trait_vector");
1225 "Failed to load trait order: %s",
1232 "savefile.extras_size");
1234 const char **modname;
1239 "savefile.extras_vector");
1241 "Failed to load extras order: %s",
1244 "Number of extras defined by the ruleset (= %d) are "
1245 "lower than the number in the savefile (= %d).",
1248 nmod = 4 * ((loading->
extra.
size + 3) / 4);
1250 for (j = 0; j < loading->
extra.
size; j++) {
1254 for (; j < nmod; j++) {
1262 "savefile.multipliers_size");
1264 const char **modname;
1268 "savefile.multipliers_vector");
1270 "Failed to load multipliers order: %s",
1279 log_verbose(
"Multiplier \"%s\" in savegame but not in ruleset, "
1280 "discarding", modname[j]);
1289 "savefile.specials_size");
1291 const char **modname;
1296 "savefile.specials_vector");
1298 "Failed to load specials order: %s",
1326 for (; j < nmod; j++) {
1334 "savefile.bases_size");
1336 const char **modname;
1341 "savefile.bases_vector");
1343 "Failed to load bases order: %s",
1346 nmod = 4 * ((loading->
base.
size + 3) / 4);
1348 for (j = 0; j < loading->
base.
size; j++) {
1353 "Unknown base type %s in savefile.",
1356 if (pextra != NULL) {
1363 for (; j < nmod; j++) {
1371 "savefile.roads_size");
1373 const char **modname;
1378 "savefile.roads_vector");
1380 "Failed to load roads order: %s",
1383 "Number of roads defined by the ruleset (= %d) are "
1384 "lower than the number in the savefile (= %d).",
1387 nmod = 4 * ((loading->
road.
size + 3) / 4);
1389 for (j = 0; j < loading->
road.
size; j++) {
1392 if (pextra != NULL) {
1399 for (; j < nmod; j++) {
1407 "savefile.specialists_size");
1409 const char **modname;
1414 "savefile.specialists_vector");
1416 "Failed to load specialists order: %s",
1419 "Number of specialists defined by the ruleset (= %d) are "
1420 "lower than the number in the savefile (= %d).",
1432 for (; j < nmod; j++) {
1440 "savefile.diplstate_type_size");
1443 "Failed to load diplomatic state type order: %s",
1447 const char **modname;
1451 "savefile.diplstate_type_vector");
1456 for (j = 0; j < loading->
ds_t.
size; j++) {
1457 loading->
ds_t.
order[j] = diplstate_type_by_name(modname[j],
1469 for (j = 0; j < i; j++) {
1475 pterr->identifier_load =
'\0';
1480 "savefile.terrident%d.name", i)) != NULL) {
1483 if (pterr != NULL) {
1485 "savefile.terrident%d.identifier", i);
1489 log_error(
"Identifier for unknown terrain type %s.", terr_name);
1496 if (pterr != pterr2 && pterr->identifier_load !=
'\0') {
1497 sg_failure_ret((pterr->identifier_load != pterr2->identifier_load),
1498 "%s and %s share a saved identifier",
1522 "ruledata.government%d.name", i));
1528 "ruledata.government%d.changes", i);
1550 sg_failure_ret(20299 <= game_version,
"Saved game is too old, at least "
1551 "version 2.2.99 required.");
1559 "game.server_state");
1568 "game.meta_patches");
1577 "game.meta_server"));
1596 if (
level != NULL) {
1611 "game.skill_level"));
1618 "game.phase_mode_stored");
1632 "game.timeoutintinc");
1638 "game.timeoutincmult");
1641 "game.timeoutcounter");
1670 "game.global_advances");
1673 "Invalid length of 'game.global_advances' ("
1674 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
1678 "Undefined value '%c' within 'game.global_advances'.",
1680 if (
str[i] ==
'1') {
1684 if (padvance != NULL) {
1735 for (i = 0; i < 8; i++) {
1738 sscanf(
str,
"%8x %8x %8x %8x %8x %8x %8x", &loading->
rstate.
v[7*i],
1782 bool lake_flood_default;
1803 if (buf[0] !=
'\0') {
1808 "scenario.authors");
1809 if (buf[0] !=
'\0') {
1816 "scenario.description");
1817 if (buf[0] !=
'\0') {
1829 "scenario.startpos_nations");
1833 "scenario.prevent_new_cities");
1834 if (loading->
version < 20599) {
1837 lake_flood_default =
FALSE;
1841 lake_flood_default =
TRUE;
1845 "scenario.lake_flooding");
1848 "scenario.handmade");
1851 "scenario.allow_ai_type_fallback");
1857 "Invalid scenario definition (server state '%s' and "
1998 const char *spec_sprite;
2007 if (NULL != ptile->spec_sprite) {
2008 ptile->spec_sprite =
fc_strdup(spec_sprite);
2010 if (label != NULL) {
2027 loading->
file,
"map.e%02d_%04d", j);
2043 loading->
file,
"map.b%02d_%04d", j);
2059 loading->
file,
"map.r%02d_%04d", j);
2067 bool rivers_overlay)
2090 loading->
file,
"map.spe%02d_%04d", j);
2103 loading->
file,
"map.res%04d");
2107 if (NULL == ptile->resource) {
2129 const char SEPARATOR =
'#';
2130 const char *nation_names;
2133 int i, startpos_count;
2141 if (0 == startpos_count) {
2146 for (i = 0; i < startpos_count; i++) {
2149 "map.startpos%d.y", i)) {
2150 log_sg(
"Warning: Undefined coordinates for startpos %d", i);
2155 if (NULL == ptile) {
2156 log_error(
"Start position native coordinates (%d, %d) do not exist "
2162 "map.startpos%d.exclude", i);
2167 "map.startpos%d.nations", i);
2168 if (NULL != nation_names &&
'\0' != nation_names[0]) {
2169 const size_t size = strlen(nation_names) + 1;
2170 char buf[
size], *start, *end;
2172 memcpy(buf, nation_names,
size);
2173 for (start = buf - 1; NULL != start; start = end) {
2175 if ((end = strchr(start, SEPARATOR))) {
2196 log_verbose(
"Number of starts (%d) are lower than rules.max_players "
2197 "(%d), lowering rules.max_players.",
2216 struct player *eowner = NULL;
2229 "map.owner%04d", y);
2231 "map.source%04d", y);
2233 "map.eowner%04d", y);
2234 const char *ptr1 = buffer1;
2235 const char *ptr2 = buffer2;
2236 const char *ptr3 = buffer3;
2251 scanin(&ptr1,
",", token1,
sizeof(token1));
2253 "Map size not correct (map.owner%d).", y);
2254 if (strcmp(token1,
"-") == 0) {
2258 "Got map owner %s in (%d, %d).", token1, x, y);
2262 scanin(&ptr2,
",", token2,
sizeof(token2));
2264 "Map size not correct (map.source%d).", y);
2265 if (strcmp(token2,
"-") == 0) {
2269 "Got map source %s in (%d, %d).", token2, x, y);
2274 scanin(&ptr3,
",", token3,
sizeof(token3));
2276 "Map size not correct (map.eowner%d).", y);
2277 if (strcmp(token3,
"-") == 0) {
2281 "Got base owner %s in (%d, %d).", token3, x, y);
2306 "City worked map not loaded!");
2314 const char *ptr = buffer;
2317 "Savegame corrupt - map line %d not found.", y);
2323 scanin(&ptr,
",", token,
sizeof(token));
2325 "Savegame corrupt - map size not correct.");
2326 if (strcmp(token,
"-") == 0) {
2330 "Savegame corrupt - got tile worked by city "
2331 "id=%s in (%d, %d).", token, x, y);
2354 "game.save_known")) {
2359 for (l = 0; l <
lines; l++) {
2360 for (j = 0; j < 8; j++) {
2361 for (i = 0; i < 4; i++) {
2368 loading->
file,
"map.k%02d_%04d", l * 8 + j);
2411 bool shuffle_loaded =
TRUE;
2424 "players.destroyed_wonders");
2427 "Invalid length for 'players.destroyed_wonders' ("
2428 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
")",
2432 "Undefined value '%c' within "
2433 "'players.destroyed_wonders'.",
str[k]);
2435 if (
str[k] ==
'1') {
2448 "players.identity_number_used");
2477 log_sg(
"Game has started, yet player %d has no color defined.",
2481 log_verbose(
"No color defined for player %d.", pslot_id);
2516 "player%d.multiplier%d.val",
2522 log_verbose(
"Player %d had illegal value for multiplier \"%s\": "
2523 "was %d, clamped to %d", pslot_id,
2531 "player%d.multiplier%d.target",
2537 log_verbose(
"Player %d had illegal value for multiplier_target "
2538 "\"%s\": was %d, clamped to %d", pslot_id,
2551 "player%d.border_vision",
2558 "(%d) from the loaded game does not match the number of "
2570 "Invalid team definition for player %s (nb %d).",
2586 "players.shuffled_player_%d", 0) >= 0) {
2589 int shuffled_players[
slots];
2590 bool shuffled_player_set[
slots];
2592 for (i = 0; i <
slots; i++) {
2594 shuffled_player_set[i] =
FALSE;
2597 shuffled_players[i] = -1;
2601 for (i = 0; i < plrcount; i++) {
2604 "players.shuffled_player_%d", i);
2606 if (shuffle == -1) {
2607 log_sg(
"Missing player shuffle information (index %d) "
2608 "- reshuffle player list!", i);
2609 shuffle_loaded =
FALSE;
2611 }
else if (shuffled_player_set[shuffle]) {
2612 log_sg(
"Player shuffle %d used two times "
2613 "- reshuffle player list!", shuffle);
2614 shuffle_loaded =
FALSE;
2618 shuffled_player_set[shuffle] =
TRUE;
2621 shuffled_players[i] = shuffle;
2624 if (shuffle_loaded) {
2626 int shuffle_index = plrcount;
2628 for (i = 0; i <
slots; i++) {
2629 if (!shuffled_player_set[i]) {
2630 shuffled_players[shuffle_index++] = i;
2635 "Invalid player shuffle data!");
2643 log_debug(
"[load shuffle] id: %3d => slot: %3d | slot %3d: %s",
2644 plrid, shuffled_players[plrid], plrid,
2645 shuffled_player_set[plrid] ?
"is used" :
"-");
2654 if (!shuffle_loaded) {
2684 if (
is_ai(pplayer)) {
2685 log_normal(
_(
"%s has been added as %s level AI-controlled player "
2687 ai_level_translated_name(pplayer->ai_common.skill_level),
2690 log_normal(
_(
"%s has been added as human player."),
2714 log_sg(
_(
"%s had invalid nation; changing to %s."),
2730 log_sg(
"Illegal alliance structure detected: "
2731 "%s alliance to %s reduced to peace treaty.",
2745 pcity->server.illness
2747 &(pcity->illness_trade), NULL);
2773 BV_CLR_ALL(pplayer->server.really_gives_vision);
2784 "player%d.diplstate%d.gives_shared_vision", plr1, plr2)) {
2796 if (pplayer1 != pplayer2
2800 _(
"%s did not give shared vision to team member %s."),
2806 _(
"%s did not give shared vision to team member %s."),
2826 log_sg(
"%s doing illegal activity in savegame!",
2828 log_sg(
"Activity: %s, Target: %s, Tile: (%d, %d), Terrain: %s",
2863 const char *barb_str;
2875 "player%d.username", plrno));
2877 "player%d.unassigned_user", plrno),
2881 "player%d.orig_username",
2885 "player%d.ranked_username",
2888 "player%d.unassigned_ranked", plrno),
2891 "player%d.delegation_username",
2901 for (i = 0; i < nval; i++) {
2902 const char *sval = slist[i];
2903 enum plr_flag_id fid = plr_flag_id_by_name(sval,
fc_strcasecmp);
2905 sg_failure_ret(plr_flag_id_is_valid(fid),
"Invalid player flag \"%s\".", sval);
2914 if (plr->
nation != NULL) {
2922 sg_failure_ret(gov != NULL,
"Player%d: unsupported government \"%s\".",
2928 "player%d.target_government_name", plrno);
2936 "player%d.revolution_finishes", plrno);
2940 "player%d.got_first_city", plrno),
2953 fc_snprintf(buf,
sizeof(buf),
"player%d.diplstate%d", plrno, i);
2957 if (unconverted >= 0 && unconverted < loading->ds_t.size) {
2961 log_sg(
"No valid diplomatic state type between players %d and %d",
2969 if (unconverted >= 0 && unconverted < loading->ds_t.size) {
2973 log_sg(
"No valid diplomatic max_state between players %d and %d",
2981 "%s.first_contact_turn", buf);
2986 "%s.has_reason_to_cancel", buf);
2989 "%s.contact_turns_left", buf);
3003 fc_snprintf(buf,
sizeof(buf),
"player%d.ai%d", plrno,
3020 "player%d.ai.level", plrno);
3021 if (
level != NULL) {
3036 "player%d.ai.skill_level",
3041 "player%d.ai.barb_type", plrno);
3045 log_sg(
"Player%d: Invalid barbarian type \"%s\". "
3046 "Changed to \"None\".", plrno, barb_str);
3073 if (style == NULL) {
3075 log_sg(
"Player%d: unsupported city_style_name \"%s\". "
3082 "player%d.idle_turns", plrno),
3085 "player%d.is_male", plrno);
3087 "player%d.is_alive", plrno),
3090 "player%d.turns_alive", plrno),
3093 "player%d.last_war", plrno),
3096 "player%d.phase_done", plrno);
3098 "player%d.gold", plrno),
3101 "player%d.rates.tax", plrno),
3104 "player%d.rates.science", plrno),
3107 "player%d.rates.luxury", plrno),
3111 "player%d.research.bulbs_last_turn", plrno);
3115 for (i = 0; i < loading->
trait.
size; i++) {
3118 if (trait_is_valid(tr)) {
3127 "player%d.trait%d.mod", plrno, i),
3139 "player%d.achievement_count", plrno);
3142 for (i = 0; i < count; i++) {
3148 "player%d.achievement%d.name", plrno, i);
3152 "Unknown achievement \"%s\".",
name);
3155 "player%d.achievement%d.first",
3160 "Multiple players listed as first to get achievement \"%s\".",
3175 "score%d.happy", plrno);
3178 "score%d.content", plrno);
3181 "score%d.unhappy", plrno);
3184 "score%d.angry", plrno);
3195 "score%d.specialists%d", plrno, i);
3200 "score%d.wonders", plrno);
3203 "score%d.techs", plrno);
3206 "score%d.techout", plrno);
3209 "score%d.landarea", plrno);
3212 "score%d.settledarea", plrno);
3215 "score%d.population", plrno);
3218 "score%d.cities", plrno);
3221 "score%d.units", plrno);
3224 "score%d.pollution", plrno);
3227 "score%d.literacy", plrno);
3230 "score%d.bnp", plrno);
3233 "score%d.mfg", plrno);
3236 "score%d.spaceship", plrno);
3239 "score%d.units_built", plrno);
3242 "score%d.units_killed", plrno);
3245 "score%d.units_lost", plrno);
3248 "score%d.culture", plrno);
3251 "score%d.total", plrno);
3260 fc_snprintf(prefix,
sizeof(prefix),
"player%d.spaceship", plrno);
3264 "%s.state", prefix),
3270 "%s.structurals", prefix),
3273 "%s.components", prefix),
3276 "%s.modules", prefix),
3282 "%s.propulsion", prefix),
3285 "%s.habitation", prefix),
3288 "%s.life_support", prefix),
3291 "%s.solar_panels", prefix),
3298 "Undefined value '%c' within '%s.structure'.", st[i],
3301 if (!(st[i] ==
'0')) {
3307 "%s.launch_year", prefix),
3321 "Invalid length for 'player%d.lost_wonders' ("
3322 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
")",
3326 "Undefined value '%c' within "
3327 "'player%d.lost_wonders'.", plrno,
str[k]);
3329 if (
str[k] ==
'1') {
3354 int wlist_max_length = 0;
3360 "player%d.ncities", plrno),
3363 if (!plr->
is_alive && ncities > 0) {
3364 log_sg(
"'player%d.ncities' = %d for dead player!", plrno, ncities);
3374 for (i = 0; i < ncities; i++) {
3376 "player%d.c%d.wl_length",
3379 wlist_max_length =
MAX(wlist_max_length, wl_length);
3383 for (i = 0; i < ncities; i++) {
3387 fc_snprintf(buf,
sizeof(buf),
"player%d.c%d", plrno, i);
3414 city_list_append(plr->
cities, pcity);
3417 tasks_handled =
FALSE;
3418 for (i = 0; !tasks_handled; i++) {
3420 struct city *pcity = NULL;
3425 if (city_id != -1) {
3429 if (pcity != NULL) {
3443 "Unknown workertask activity %s",
str);
3447 if (strcmp(
"-",
str)) {
3451 "Unknown workertask target %s",
str);
3457 "player%d.task%d.want", plrno, i);
3459 worker_task_list_append(pcity->
task_reqs, ptask);
3461 tasks_handled =
TRUE;
3470 struct city *pcity,
const char *citystr,
3471 int wlist_max_length)
3474 const char *kind, *
name, *
str;
3475 int id, i, repair, sp_count = 0, workers = 0, value;
3478 const char *stylename;
3487 "%s has invalid center tile (%d, %d)",
3490 "%s duplicates city (%d, %d)", citystr,
nat_x,
nat_y);
3494 "%s.name", citystr));
3500 "%s.original", citystr);
3510 "Invalid city size: %d, set to %d", value,
size);
3524 "%s.traderoute%d", citystr, i);
3530 proute->
dir = RDIR_BIDIRECTIONAL;
3533 trade_route_list_append(pcity->
routes, proute);
3538 "%s.food_stock", citystr),
3541 "%s.shield_stock", citystr),
3556 "%s.anarchy", citystr),
3579 "%s.turn_last_built", citystr),
3588 "%s.currently_building: unknown \"%s\" \"%s\".",
3589 citystr, kind,
name);
3597 "%s.changed_from: unknown \"%s\" \"%s\".",
3598 citystr, kind,
name);
3602 "%s.before_change_shields", citystr);
3605 "%s.caravan_shields", citystr);
3608 "%s.disbanded_shields", citystr);
3611 "%s.last_turns_shield_surplus",
3615 "%s.style", citystr);
3616 if (stylename != NULL) {
3621 if (pcity->
style < 0) {
3636 "Invalid length of '%s.improvements' ("
3637 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
3641 "Undefined value '%c' within '%s.improvements'.",
3644 if (
str[i] ==
'1') {
3655 "No worked tiles map defined.");
3670 log_sg(
"[%s] '%s' (%d, %d) has worker outside current radius "
3691 if (NULL != pwork) {
3692 log_sg(
"[%s] city center of '%s' (%d,%d) [%d] is worked by '%s' "
3701 log_sg(
"[%s] city center of '%s' (%d,%d) [%d] is empty; repairing",
3713 log_sg(
"[%s] size mismatch for '%s' (%d,%d): size [%d] != "
3714 "(workers [%d] - free worked tiles [%d]) + specialists [%d]",
3727 for (i = 0; i < CITYO_LAST; i++) {
3745 const char *citystr)
3755 "%s.citizen%d", citystr,
3758 log_sg(
"Citizens of an invalid nation for %s (player slot %d)!",
3765 "Invalid value for citizens of player %d in %s: %d.",
3778 log_sg(
"City size and number of citizens does not match in %s "
3799 "player%d.nunits", plrno),
3801 if (!plr->
is_alive && nunits > 0) {
3802 log_sg(
"'player%d.nunits' = %d for dead player!", plrno, nunits);
3806 for (i = 0; i < nunits; i++) {
3814 fc_snprintf(buf,
sizeof(buf),
"player%d.u%d", plrno, i);
3869 struct tile *tgt_tile)
3879 return ACTION_JOIN_CITY;
3882 return ACTION_FOUND_CITY;
3886 return ACTION_HELP_WONDER;
3889 return ACTION_TRADE_ROUTE;
3897 return ACTION_DISBAND_UNIT_RECOVER;
3899 return ACTION_HOME_CITY;
3911 const char *unitstr)
3913 enum unit_activity activity;
3924 const char *facing_str;
3943 "%s.facing", unitstr);
3944 if (facing_str[0] !=
'x') {
3948 enum direction8 facing =
char2dir(facing_str[0]);
3950 if (direction8_is_valid(facing)) {
3953 log_error(
"Illegal unit orientation '%s'", facing_str);
3961 "%s.nationality", unitstr);
3969 "%s.homecity", unitstr),
FALSE,
3972 "%s.moves", unitstr),
FALSE,
3975 "%s.fuel", unitstr),
FALSE,
3978 "%s.activity", unitstr),
FALSE,
3985 "%s.born", unitstr);
3988 "%s.activity_tgt", unitstr);
3990 if (extra_id != -2) {
3991 if (extra_id >= 0 && extra_id < loading->extra.size) {
3994 }
else if (activity == ACTIVITY_IRRIGATE) {
4004 }
else if (activity == ACTIVITY_MINE) {
4020 "%s.activity_base", unitstr);
4021 if (base_id >= 0 && base_id < loading->
base.size) {
4025 "%s.activity_road", unitstr);
4026 if (road_id >= 0 && road_id < loading->
road.size) {
4033 "%s.activity_target", unitstr);
4034 if (tgt_no >= 0 && tgt_no < loading->special.size) {
4049 if (activity == ACTIVITY_OLD_ROAD) {
4050 activity = ACTIVITY_GEN_ROAD;
4052 }
else if (activity == ACTIVITY_OLD_RAILROAD) {
4053 activity = ACTIVITY_GEN_ROAD;
4062 if (activity == ACTIVITY_BASE) {
4066 log_sg(
"Cannot find base %d for %s to build",
4070 }
else if (activity == ACTIVITY_GEN_ROAD) {
4074 log_sg(
"Cannot find road %d for %s to build",
4078 }
else if (activity == ACTIVITY_PILLAGE) {
4083 }
else if (pbase != NULL) {
4085 }
else if (proad != NULL) {
4094 }
else if (activity == ACTIVITY_IRRIGATE) {
4104 }
else if (activity == ACTIVITY_MINE) {
4114 }
else if (activity == ACTIVITY_POLLUTION) {
4124 }
else if (activity == ACTIVITY_FALLOUT) {
4140 "%s.activity_count", unitstr),
FALSE,
4145 "%s.changed_from", unitstr);
4148 "%s.changed_from_tgt", unitstr);
4150 if (extra_id != -2) {
4151 if (extra_id >= 0 && extra_id < loading->extra.size) {
4161 "%s.changed_from_target", unitstr);
4164 "%s.changed_from_base", unitstr);
4167 "%s.changed_from_road", unitstr);
4169 if (road_id == -1) {
4183 if (base_id >= 0 && base_id < loading->
base.size) {
4185 }
else if (road_id >= 0 && road_id < loading->
road.size) {
4187 }
else if (cfspe !=
S_LAST) {
4238 "%s.changed_from_count", unitstr);
4245 if (activity == ACTIVITY_SENTRY) {
4264 "%s.done_moving", unitstr);
4267 "%s.battlegroup", unitstr);
4270 "%s.go", unitstr)) {
4274 "%s.goto_x", unitstr),
FALSE,
4277 "%s.goto_y", unitstr),
FALSE,
4295 "%s.ai", unitstr),
FALSE,
4297 if (ai_controlled) {
4305 "%s.hp", unitstr),
FALSE,
4316 "%s.paradropped", unitstr);
4333 ACT_DEC_NOTHING, action_decision,
4334 "%s.action_decision_want", unitstr);
4341 "%s.action_decision_tile_x", unitstr)
4343 "%s.action_decision_tile_y", unitstr)) {
4360 "%s.orders_length", unitstr);
4363 const char *orders_unitstr, *dir_unitstr, *act_unitstr;
4364 const char *tgt_unitstr;
4365 const char *base_unitstr = NULL;
4366 const char *road_unitstr = NULL;
4375 "%s.orders_index", unitstr);
4378 "%s.orders_repeat", unitstr);
4381 "%s.orders_vigilant", unitstr);
4385 "%s.orders_list", unitstr);
4388 "%s.dir_list", unitstr);
4391 "%s.activity_list", unitstr);
4395 if (tgt_unitstr == NULL) {
4404 for (j = 0; j <
len; j++) {
4407 if (orders_unitstr[j] ==
'\0' || dir_unitstr[j] ==
'\0'
4408 || act_unitstr[j] ==
'\0') {
4409 log_sg(
"Invalid unit orders.");
4423 && !direction8_is_valid(
order->dir))
4425 &&
order->activity == ACTIVITY_LAST)) {
4442 if (tgt_unitstr[j] !=
'?') {
4443 extra_id =
char2num(tgt_unitstr[j]);
4445 if (extra_id < 0 || extra_id >= loading->
extra.
size) {
4446 log_sg(
"Cannot find extra %d for %s to build",
4450 order->sub_target = extra_id;
4458 if (base_unitstr && base_unitstr[j] !=
'?'
4459 &&
order->activity == ACTIVITY_BASE) {
4460 base_id =
char2num(base_unitstr[j]);
4462 if (base_id < 0 || base_id >= loading->
base.
size) {
4463 log_sg(
"Cannot find base %d for %s to build",
4471 }
else if (road_unitstr && road_unitstr[j] !=
'?'
4472 &&
order->activity == ACTIVITY_GEN_ROAD) {
4473 road_id =
char2num(road_unitstr[j]);
4475 if (road_id < 0 || road_id >= loading->
road.
size) {
4476 log_sg(
"Cannot find road %d for %s to build",
4487 if (
order->activity == ACTIVITY_OLD_ROAD) {
4488 order->activity = ACTIVITY_GEN_ROAD;
4491 }
else if (
order->activity == ACTIVITY_OLD_RAILROAD) {
4492 order->activity = ACTIVITY_GEN_ROAD;
4530 "player%d.nunits", plrno),
4532 if (!plr->
is_alive && nunits > 0) {
4533 log_sg(
"'player%d.nunits' = %d for dead player!", plrno, nunits);
4537 for (i = 0; i < nunits; i++) {
4538 int id_unit, id_trans;
4548 "player%d.u%d.transported_by",
4550 if (id_trans == -1) {
4559#ifndef FREECIV_NDEBUG
4588 loading->
file, 0,
"player%d.attribute_v2_block_length", plrno);
4591 log_sg(
"player%d.attribute_v2_block_length=%d too small", plrno,
4594 }
else if (MAX_ATTRIBUTE_BLOCK < plr->attribute_block.length) {
4595 log_sg(
"player%d.attribute_v2_block_length=%d too big (max %d)",
4602#ifndef FREECIV_NDEBUG
4603 size_t actual_length;
4608 "player%d.attribute_v2_block_length_quoted",
4612 "player%d.attribute_v2_block_parts", plrno),
4618 for (part_nr = 0; part_nr <
parts; part_nr++) {
4619 const char *current =
4621 "player%d.attribute_v2_block_data.part%d",
4624 log_sg(
"attribute_v2_block_parts=%d actual=%d",
parts, part_nr);
4627 log_debug(
"attribute_v2_block_length_quoted=%d"
4628 " have=" SIZE_T_PRINTF
" part=" SIZE_T_PRINTF,
4629 quoted_length, strlen(quoted), strlen(current));
4630 fc_assert(strlen(quoted) + strlen(current) <= quoted_length);
4631 strcat(quoted, current);
4634 "attribute_v2_block_length_quoted=%d"
4635 " actual=" SIZE_T_PRINTF,
4636 quoted_length, strlen(quoted));
4638#ifndef FREECIV_NDEBUG
4658 "player%d.dc_total", plrno);
4660 bool someone_alive =
FALSE;
4667 if (pteam_member->is_alive) {
4668 someone_alive =
TRUE;
4673 if (!someone_alive) {
4680 || -1 == total_ncities
4683 "game.save_private_map")) {
4698 if (NULL != pcity) {
4712 "player%d.map_t%04d", plrno);
4718 "player%d.map_res%04d", plrno);
4728 loading->
file,
"player%d.map_e%02d_%04d", plrno, j);
4736 loading->
file,
"player%d.map_spe%02d_%04d", plrno, j);
4744 loading->
file,
"player%d.map_b%02d_%04d", plrno, j);
4754 loading->
file,
"player%d.map_r%02d_%04d", plrno, j);
4770 const char *ptr = buffer;
4771 const char *ptr2 = buffer2;
4774 "Savegame corrupt - map line %d not found.", y);
4781 scanin(&ptr,
",", token,
sizeof(token));
4783 "Savegame corrupt - map size not correct.");
4784 if (strcmp(token,
"-") == 0) {
4788 "Savegame corrupt - got tile owner=%s in (%d, %d).",
4794 scanin(&ptr2,
",", token2,
sizeof(token2));
4796 "Savegame corrupt - map size not correct.");
4797 if (strcmp(token2,
"-") == 0) {
4801 "Savegame corrupt - got extras owner=%s in (%d, %d).",
4814 for (i = 0; i < 4; i++) {
4820 loading->
file,
"player%d.map_u%02d_%04d", plrno, i);
4825 loading->
file,
"player%d.map_u%02d_%04d", plrno, i);
4830 for (i = 0; i < total_ncities; i++) {
4833 fc_snprintf(buf,
sizeof(buf),
"player%d.dc%d", plrno, i);
4842 log_sg(
"Skipping seen city %d for player %d.", i, plrno);
4843 if (pdcity != NULL) {
4857 if (NULL != pcity) {
4875 const char *citystr)
4881 const char *stylename;
4892 "%s invalid tile (%d,%d)", citystr,
nat_x,
nat_y);
4899 "%s has invalid owner (%d); skipping.", citystr,
id);
4905 "%s has invalid id (%d); skipping.", citystr,
id);
4908 "%s.size", citystr),
4912 "Invalid city size: %d; set to %d.",
size, city_size);
4920 "Invalid length of '%s.improvements' ("
4921 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
4925 "Undefined value '%c' within '%s.improvements'.",
4928 if (
str[i] ==
'1') {
4939 "%s.name", citystr);
4941 if (vname != NULL) {
4946 "%s.occupied", citystr);
4948 "%s.walls", citystr);
4950 "%s.happy", citystr);
4952 "%s.unhappy", citystr);
4954 "%s.style", citystr);
4955 if (stylename != NULL) {
4960 if (pdcity->
style < 0) {
4965 "%s.city_image", citystr);
4967 pdcity->
capital = CAPITAL_NOT;
4997 for (i = 0; i < count; i++) {
4999 "research.r%d.number", i),
5003 "Invalid research number %d in 'research.r%d.number'",
5007 "research.r%d.goal", i);
5010 "research.r%d.techs", i),
5014 "research.r%d.futuretech", i),
5018 "research.r%d.bulbs", i),
5022 "research.r%d.bulbs_before", i),
5025 "research.r%d.saved", i);
5027 "research.r%d.now", i);
5030 "research.r%d.got_tech", i),
5036 "Invalid length of 'research.r%d.done' ("
5037 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
5041 "Undefined value '%c' within 'research.r%d.done'.",
5044 if (
str[j] ==
'1') {
5095 "treaty%d.plr0", tidx)) != NULL ;
5107 if (p0 == NULL || p1 == NULL) {
5108 log_error(
"Treaty between unknown players %s and %s", plr0, plr1);
5113 treaty_list_prepend(
treaties, ptreaty);
5116 "treaty%d.clause%d.type",
5117 tidx, cidx)) != NULL ;
5122 if (!clause_type_is_valid(
type)) {
5123 log_error(
"Invalid clause type \"%s\"", ct);
5125 struct player *pgiver = NULL;
5135 log_error(
"Clause giver %s is not participant of the treaty"
5136 "between %s and %s", plrx, plr0, plr1);
5139 if (pgiver != NULL) {
5143 "treaty%d.clause%d.value",
5154 "treaty%d.accept0", tidx);
5156 "treaty%d.accept1", tidx);
5203 int mapdef_count, i;
5215 log_verbose(
"Saved map image definitions: %d.", mapdef_count);
5217 if (0 >= mapdef_count) {
5221 for (i = 0; i < mapdef_count; i++) {
5226 log_verbose(
"[Mapimg %4d] Missing definition.", i);
5231 log_error(
"Invalid map image definition %4d: %s.", i, p);
5261 log_verbose(
"Max players lower than current players, fixing");
5270 log_sg(
"Removing %s unferried %s in %s at (%d, %d)",
5307 log_error(
"[city id: %d] Bad worker task %d.",
5308 pcity->id, ptask->act);
5309 worker_task_list_remove(pcity->task_reqs, ptask);
5323 log_error(
"[city id: %d] Unused worked tile at (%d, %d).",
5334 if (presearch->researching !=
A_UNSET
5338 != TECH_PREREQS_KNOWN))) {
5339 log_sg(
_(
"%s had invalid researching technology."),
5341 presearch->researching =
A_UNSET;
5343 if (presearch->tech_goal !=
A_UNSET
5349 log_sg(
_(
"%s had invalid technology goal."),
5351 presearch->tech_goal =
A_UNSET;
5356 if (presearch->techs_researched !=
techs) {
5358 _(
"%s had finished researches count wrong."),
5360 presearch->techs_researched =
techs;
5379 if (0 == strlen(
server.game_identifier)
5383 sizeof(
server.game_identifier));
5388 int unique_count[
U_LAST];
5390 memset(unique_count, 0,
sizeof(unique_count));
5398 log_sg(
_(
"%s has multiple units of type %s though it should be possible "
5399 "to have only one."),
struct achievement * achievement_by_rule_name(const char *name)
void building_advisor(struct player *pplayer)
bool adv_data_phase_init(struct player *pplayer, bool is_new_phase)
void adv_data_phase_done(struct player *pplayer)
const char * ai_name(const struct ai_type *ai)
#define CALL_FUNC_EACH_AI(_func,...)
#define CALL_PLR_AI_FUNC(_func, _player,...)
void ai_traits_init(struct player *pplayer)
Base_type_id base_number(const struct base_type *pbase)
struct extra_type * base_extra_get(const struct base_type *pbase)
struct base_type * get_base_by_gui_type(enum base_gui_type type, const struct unit *punit, const struct tile *ptile)
struct base_type * base_by_number(const Base_type_id id)
void dbv_clr_all(struct dbv *pdbv)
bool has_capability(const char *cap, const char *capstr)
void citizens_nation_set(struct city *pcity, const struct player_slot *pslot, citizens count)
citizens citizens_count(const struct city *pcity)
void citizens_init(struct city *pcity)
void citizens_update(struct city *pcity, struct player *plr)
void city_map_radius_sq_set(struct city *pcity, int radius_sq)
void city_name_set(struct city *pcity, const char *new_name)
const char * city_name_get(const struct city *pcity)
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
void city_size_set(struct city *pcity, citizens size)
void city_add_improvement(struct city *pcity, const struct impr_type *pimprove)
void destroy_city_virtual(struct city *pcity)
int city_style_by_rule_name(const char *s)
#define cities_iterate_end
#define city_list_iterate(citylist, pcity)
#define city_tile(_pcity_)
#define cities_iterate(pcity)
#define CITY_MAP_MAX_RADIUS_SQ
static citizens city_size_get(const struct city *pcity)
#define output_type_iterate(output)
#define city_owner(_pcity_)
#define FREE_WORKED_TILES
#define city_list_iterate_end
#define city_tile_iterate(_nmap, _radius_sq, _city_tile, _tile)
#define city_tile_iterate_end
#define output_type_iterate_end
void auto_arrange_workers(struct city *pcity)
void city_repair_size(struct city *pcity, int change)
bool city_refresh(struct city *pcity)
static void road(QVariant data1, QVariant data2)
static void base(QVariant data1, QVariant data2)
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
void set_ai_level_directer(struct player *pplayer, enum ai_level level)
static struct treaty_list * treaties
struct treaty_list * get_all_treaties(void)
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val, struct player *client_player)
#define IDENTITY_NUMBER_ZERO
struct unit * game_unit_by_number(int id)
void initialize_globals(void)
struct city * game_city_by_number(int id)
#define GAME_DEFAULT_TIMEOUTINTINC
#define GAME_DEFAULT_SCORETURN
#define GAME_DEFAULT_TIMEOUTINT
#define GAME_DEFAULT_TIMEOUTINCMULT
#define GAME_DEFAULT_TIMEOUTINC
#define GAME_DEFAULT_RULESETDIR
#define GAME_DEFAULT_TIMEOUTCOUNTER
#define GAME_DEFAULT_PHASE_MODE
#define GAME_HARDCODED_DEFAULT_SKILL_LEVEL
struct government * government_by_rule_name(const char *name)
void idex_register_unit(struct world *iworld, struct unit *punit)
void idex_register_city(struct world *iworld, struct city *pcity)
Impr_type_id improvement_index(const struct impr_type *pimprove)
struct impr_type * improvement_by_rule_name(const char *name)
void adv_city_free(struct city *pcity)
void adv_city_alloc(struct city *pcity)
#define fc_assert_msg(condition, message,...)
#define log_verbose(message,...)
#define fc_assert(condition)
#define log_fatal(message,...)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
#define log_normal(message,...)
#define log_error(message,...)
bool startpos_disallow(struct startpos *psp, struct nation_type *pnation)
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
struct startpos * map_startpos_new(struct tile *ptile)
void map_init_topology(struct civ_map *nmap)
void main_map_allocate(void)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
int map_startpos_count(void)
struct tile * native_pos_to_tile(const struct civ_map *nmap, int nat_x, int nat_y)
bool startpos_allow(struct startpos *psp, struct nation_type *pnation)
#define whole_map_iterate(_map, _tile)
#define index_to_native_pos(pnat_x, pnat_y, mindex)
#define whole_map_iterate_end
void assign_continent_numbers(void)
void player_map_init(struct player *pplayer)
void update_player_tile_last_seen(struct player *pplayer, struct tile *ptile)
void map_claim_ownership(struct tile *ptile, struct player *powner, struct tile *psource, bool claim_bases)
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
bool send_tile_suppression(bool now)
bool really_gives_vision(struct player *me, struct player *them)
void map_know_and_see_all(struct player *pplayer)
bool update_player_tile_knowledge(struct player *pplayer, struct tile *ptile)
void tile_claim_bases(struct tile *ptile, struct player *powner)
void map_set_known(struct tile *ptile, struct player *pplayer)
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
void change_playertile_site(struct player_tile *ptile, struct vision_site *new_site)
void map_calculate_borders(void)
void give_shared_vision(struct player *pfrom, struct player *pto)
struct player_tile * map_get_player_tile(const struct tile *ptile, const struct player *pplayer)
bool mapimg_define(const char *maparg, bool check)
bool mapimg_delete(int id)
#define fc_calloc(n, esz)
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
const char * multiplier_rule_name(const struct multiplier *pmul)
struct multiplier * multiplier_by_rule_name(const char *name)
Multiplier_type_id multiplier_index(const struct multiplier *pmul)
#define multipliers_iterate(_mul_)
#define multipliers_iterate_end
const char * nation_rule_name(const struct nation_type *pnation)
struct nation_type * nation_of_player(const struct player *pplayer)
struct nation_type * nation_by_rule_name(const char *name)
const char * nation_plural_for_player(const struct player *pplayer)
#define NO_NATION_SELECTED
void event_cache_load(struct section_file *file, const char *section)
bool player_slot_is_used(const struct player_slot *pslot)
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
struct player * player_by_number(const int player_id)
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
int player_slot_count(void)
struct player_slot * player_slot_by_number(int player_id)
int player_number(const struct player *pplayer)
enum dipl_reason pplayer_can_make_treaty(const struct player *p1, const struct player *p2, enum diplstate_type treaty)
const char * player_name(const struct player *pplayer)
int player_slot_max_used_number(void)
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
int player_slot_index(const struct player_slot *pslot)
struct player * player_by_name(const char *name)
struct city * player_city_by_number(const struct player *pplayer, int city_id)
int player_index(const struct player *pplayer)
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
struct player_slot * slots
#define players_iterate_end
@ DIPL_ALLIANCE_PROBLEM_THEM
@ DIPL_ALLIANCE_PROBLEM_US
#define players_iterate(_pplayer)
#define MAX_ATTRIBUTE_BLOCK
#define player_list_iterate(playerlist, pplayer)
static bool is_barbarian(const struct player *pplayer)
#define player_slots_iterate(_pslot)
#define player_list_iterate_end
#define players_iterate_alive_end
#define player_slots_iterate_end
#define players_iterate_alive(_pplayer)
void server_player_set_name(struct player *pplayer, const char *name)
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
int normal_player_count(void)
void player_limit_to_max_rates(struct player *pplayer)
struct nation_type * pick_a_nation(const struct nation_list *choices, bool ignore_conflicts, bool needs_startpos, enum barbarian_type barb_type)
void set_shuffled_players(int *shuffled_players)
void player_delegation_set(struct player *pplayer, const char *username)
void shuffle_players(void)
void server_remove_player(struct player *pplayer)
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
void assign_player_colors(void)
void fit_nationset_to_players(void)
RANDOM_STATE fc_rand_state(void)
void fc_rand_set_state(RANDOM_STATE state)
const char * secfile_error(void)
bool secfile_lookup_int(const struct section_file *secfile, int *ival, const char *path,...)
const char ** secfile_lookup_str_vec(const struct section_file *secfile, size_t *dim, const char *path,...)
struct entry * secfile_entry_lookup(const struct section_file *secfile, const char *path,...)
const char * secfile_lookup_str(const struct section_file *secfile, const char *path,...)
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
struct entry * secfile_entry_by_path(const struct section_file *secfile, const char *path)
struct section * secfile_section_lookup(const struct section_file *secfile, const char *path,...)
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
bool secfile_lookup_bool(const struct section_file *secfile, bool *bval, const char *path,...)
#define secfile_lookup_enum_default(secfile, defval, specenum_type, path,...)
#define secfile_entry_ignore(_sfile_, _fmt_,...)
struct history_report * history_report_get(void)
bool are_reqs_active(const struct req_context *context, const struct player *other_player, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
struct universal universal_by_rule_name(const char *kind, const char *value)
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
const char * research_name_translation(const struct research *presearch)
enum tech_state research_invention_set(struct research *presearch, Tech_type_id tech, enum tech_state value)
struct research * research_by_number(int number)
int recalculate_techs_researched(const struct research *presearch)
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
void research_update(struct research *presearch)
#define researches_iterate(_presearch)
#define researches_iterate_end
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
bool rgbcolor_load(struct section_file *file, struct rgbcolor **prgbcolor, char *path,...)
struct extra_type * road_extra_get(const struct road_type *proad)
Road_type_id road_number(const struct road_type *proad)
struct road_type * road_by_number(Road_type_id id)
struct road_type * road_by_compat_special(enum road_compat compat)
bool load_rulesets(const char *restore, const char *alt, bool compat_mode, rs_conversion_logger logger, bool act, bool buffer_script, bool load_luadata)
#define sanity_check_city(x)
struct extra_type * resource_by_identifier(const char identifier)
void set_unit_activity_road(struct unit *punit, Road_type_id road)
void sg_load_compat(struct loaddata *loading, enum sgf_version format_class)
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)
struct extra_type * special_extra_get(int spe)
enum tile_special_type special_by_rule_name(const char *name)
void sg_load_post_load_compat(struct loaddata *loading, enum sgf_version format_class)
const char * special_rule_name(enum tile_special_type type)
#define sg_check_ret(...)
#define sg_warn(condition, message,...)
#define sg_failure_ret_val(condition, _val, message,...)
#define sg_failure_ret(condition, message,...)
#define sg_regr(fixversion, message,...)
#define sg_warn_ret_val(condition, _val, message,...)
static void unit_ordering_apply(void)
static void sg_load_players_basic(struct loaddata *loading)
static struct loaddata * loaddata_new(struct section_file *file)
static void sg_load_map_known(struct loaddata *loading)
#define halfbyte_iterate_roads_end
static struct extra_type * char2resource(char c)
static void sg_load_map_owner(struct loaddata *loading)
static void sg_extras_set(bv_extras *extras, char ch, struct extra_type **idx)
static void sg_bases_set(bv_extras *extras, char ch, struct base_type **idx)
#define halfbyte_iterate_extras_end
static void sg_load_map_tiles_roads(struct loaddata *loading)
#define halfbyte_iterate_extras(e, num_extras_types)
static void sg_load_map(struct loaddata *loading)
static enum unit_orders char2order(char order)
static int unquote_block(const char *const quoted_, void *dest, int dest_length)
#define LOAD_MAP_CHAR(ch, ptile, SET_XY_CHAR, secfile, secpath,...)
static void sg_load_player_city_citizens(struct loaddata *loading, struct player *plr, struct city *pcity, const char *citystr)
static void sg_load_player_cities(struct loaddata *loading, struct player *plr)
static void sg_load_map_tiles(struct loaddata *loading)
static char activity2char(enum unit_activity activity)
static void sg_load_savefile(struct loaddata *loading)
static enum unit_activity char2activity(char activity)
static bool sg_load_player_unit(struct loaddata *loading, struct player *plr, struct unit *punit, const char *unitstr)
static bool sg_load_player_city(struct loaddata *loading, struct player *plr, struct city *pcity, const char *citystr, int wlist_max_length)
static void sg_load_settings(struct loaddata *loading)
static void sg_load_player_units(struct loaddata *loading, struct player *plr)
#define halfbyte_iterate_special(s, num_specials_types)
void savegame2_load(struct section_file *file)
static void sg_load_researches(struct loaddata *loading)
#define halfbyte_iterate_bases_end
static void sg_load_map_worked(struct loaddata *loading)
static void sg_load_random(struct loaddata *loading)
#define halfbyte_iterate_special_end
#define halfbyte_iterate_bases(b, num_bases_types)
static void sg_load_player_units_transport(struct loaddata *loading, struct player *plr)
static void sg_load_history(struct loaddata *loading)
#define ORDER_OLD_BUILD_WONDER
static void sg_load_map_tiles_specials(struct loaddata *loading, bool rivers_overlay)
static void sg_load_script(struct loaddata *loading)
static void sg_load_scenario(struct loaddata *loading)
static void sg_load_ruleset(struct loaddata *loading)
static void sg_load_game(struct loaddata *loading)
static void sg_load_player_main(struct loaddata *loading, struct player *plr)
static void sg_load_treaties(struct loaddata *loading)
static void sg_roads_set(bv_extras *extras, char ch, struct road_type **idx)
static Tech_type_id technology_load(struct section_file *file, const char *path, int plrno)
static enum direction8 char2dir(char dir)
static void sg_load_map_tiles_resources(struct loaddata *loading)
#define ORDER_OLD_BUILD_CITY
static struct terrain * char2terrain(char ch)
#define ORDER_OLD_DISBAND
static void sg_load_mapimg(struct loaddata *loading)
#define ORDER_OLD_HOMECITY
static void sg_load_player_attributes(struct loaddata *loading, struct player *plr)
static void sg_load_ruledata(struct loaddata *loading)
static void sg_load_player_vision(struct loaddata *loading, struct player *plr)
static void worklist_load(struct section_file *file, int wlist_max_length, struct worklist *pwl, const char *path,...)
static bool sg_load_player_vision_city(struct loaddata *loading, struct player *plr, struct vision_site *pdcity, const char *citystr)
static void sg_load_map_startpos(struct loaddata *loading)
static void loaddata_destroy(struct loaddata *loading)
static void sg_load_players(struct loaddata *loading)
#define ORDER_OLD_TRADE_ROUTE
static void sg_load_map_tiles_extras(struct loaddata *loading)
static void sg_load_sanitycheck(struct loaddata *loading)
static void sg_load_event_cache(struct loaddata *loading)
static void sg_load_map_tiles_bases(struct loaddata *loading)
static void sg_special_set(struct tile *ptile, bv_extras *extras, char ch, const enum tile_special_type *idx, bool rivers_overlay)
static int sg_order_to_action(int order, struct unit *act_unit, struct tile *tgt_tile)
#define halfbyte_iterate_roads(r, num_roads_types)
void calc_civ_score(struct player *pplayer)
void script_server_state_load(struct section_file *file)
void settings_game_load(struct section_file *file, const char *section)
struct setting_list * level[OLEVELS_NUM]
bool str_to_int(const char *str, int *pint)
bool is_base64url(const char *s)
char scanin(const char **buf, char *delimiters, char *dest, int size)
void randomize_base64url_string(char *s, size_t n)
#define CLIP(lower, current, upper)
void spaceship_calc_derived(struct player_spaceship *ship)
void spaceship_init(struct player_spaceship *ship)
#define NUM_SS_STRUCTURALS
struct specialist * specialist_by_rule_name(const char *name)
Specialist_type_id specialist_index(const struct specialist *sp)
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
#define DEFAULT_SPECIALIST
void server_game_init(bool keep_ruleset_value)
const char * aifill(int amount)
bool game_was_started(void)
void identity_number_reserve(int id)
struct server_arguments srvarg
void init_game_seed(void)
void update_nations_with_startpos(void)
void server_game_free(void)
struct worker_task_list * task_reqs
struct built_status built[B_LAST]
int last_turns_shield_surplus
bv_city_options city_options
struct trade_route_list * routes
struct universal production
int before_change_shields
citizens specialists[SP_MAX]
struct city::@17::@19 server
struct universal changed_from
struct unit_list * units_supported
struct civ_game::@30::@34 server
struct packet_scenario_description scenario_desc
struct packet_ruleset_control control
struct packet_game_info info
char rulesetdir[MAX_LEN_NAME]
struct packet_scenario_info scenario
struct civ_map::@41::@43 server
enum map_generator generator
char title[REPORT_TITLESIZE]
char body[REPORT_BODYSIZE]
const char * secfile_options
struct loaddata::@107 road
struct loaddata::@106 base
struct loaddata::@104 multiplier
struct loaddata::@109 ds_t
struct loaddata::@105 special
enum server_states server_state
struct loaddata::@100 technology
struct loaddata::@108 specialist
struct loaddata::@101 activities
struct loaddata::@102 trait
struct loaddata::@99 improvement
struct loaddata::@103 extra
struct section_file * file
int great_wonder_owners[B_LAST]
bool global_advances[A_LAST]
enum ai_level skill_level
enum phase_mode_type phase_mode
char description[MAX_LEN_CONTENT]
bool allow_ai_type_fallback
char authors[MAX_LEN_PACKET/3]
enum ai_level skill_level
enum barbarian_type barbarian_type
int love[MAX_NUM_PLAYER_SLOTS]
enum diplstate_type max_state
char has_reason_to_cancel
bv_spaceship_structure structure
enum spaceship_state state
struct player * extras_owner
struct city_list * cities
struct player_ai ai_common
struct government * target_government
char username[MAX_LEN_NAME]
struct government * government
char ranked_username[MAX_LEN_NAME]
struct player_economic economic
struct player_spaceship spaceship
struct attribute_block_s attribute_block
struct player_score score
struct multiplier_value multipliers[MAX_NUM_MULTIPLIERS]
struct nation_type * nation
struct nation_style * style
struct player::@69::@71 server
char orig_username[MAX_LEN_NAME]
int bulbs_researching_saved
Tech_type_id researching_saved
char metaserver_addr[256]
struct goods_type * goods
enum action_decision action_decision_want
enum unit_activity activity
struct extra_type * changed_from_target
struct extra_type * activity_target
enum unit_activity changed_from
struct player * nationality
struct unit::@80::@83 server
struct tile * action_decision_tile
enum server_side_agent ssa_controller
enum capital_type capital
struct universal entries[MAX_LEN_WORKLIST]
int city_style(struct city *pcity)
struct nation_style * style_by_rule_name(const char *name)
struct nation_style * style_by_number(int id)
const char * style_rule_name(const struct nation_style *pstyle)
int fc_snprintf(char *str, size_t n, const char *format,...)
int fc_strcasecmp(const char *str0, const char *str1)
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
#define sz_strlcpy(dest, src)
#define RETURN_VALUE_AFTER_EXIT(_val_)
struct team_slot * team_slot_by_number(int team_id)
bool team_add_player(struct player *pplayer, struct team *pteam)
struct team * team_new(struct team_slot *tslot)
const struct player_list * team_members(const struct team *pteam)
bool is_future_tech(Tech_type_id tech)
struct advance * valid_advance_by_number(const Tech_type_id id)
struct advance * advance_by_rule_name(const char *name)
Tech_type_id advance_number(const struct advance *padvance)
struct terrain * terrain_by_rule_name(const char *name)
const char * terrain_rule_name(const struct terrain *pterrain)
bool terrain_has_resource(const struct terrain *pterrain, const struct extra_type *presource)
#define terrain_type_iterate(_p)
#define TERRAIN_UNKNOWN_IDENTIFIER
#define terrain_type_iterate_end
#define RESOURCE_NONE_IDENTIFIER
#define RESOURCE_NULL_IDENTIFIER
bool tile_has_claimable_base(const struct tile *ptile, const struct unit_type *punittype)
void tile_virtual_destroy(struct tile *vtile)
struct tile * tile_virtual_new(const struct tile *ptile)
bool tile_set_label(struct tile *ptile, const char *label)
void tile_set_resource(struct tile *ptile, struct extra_type *presource)
struct city * tile_city(const struct tile *ptile)
void tile_set_worked(struct tile *ptile, struct city *pcity)
#define tile_worked(_tile)
#define tile_terrain(_tile)
#define tile_has_extra(ptile, pextra)
#define tile_owner(_tile)
struct goods_type * goods_by_number(Goods_type_id id)
void free_unit_orders(struct unit *punit)
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
void set_unit_activity(struct unit *punit, enum unit_activity new_activity)
struct unit * unit_transport_get(const struct unit *pcargo)
bool can_unit_continue_current_activity(const struct civ_map *nmap, struct unit *punit)
void set_unit_activity_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type *new_target)
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
bool unit_order_list_is_sane(const struct civ_map *nmap, int length, const struct unit_order *orders)
void unit_virtual_destroy(struct unit *punit)
void unit_tile_set(struct unit *punit, struct tile *ptile)
void unit_list_sort_ord_map(struct unit_list *punitlist)
void unit_list_sort_ord_city(struct unit_list *punitlist)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_safe(unitlist, _unit)
#define unit_list_iterate_end
#define unit_list_iterate_safe_end
const struct unit_type * unit_type_get(const struct unit *punit)
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
struct unit_type * unit_type_by_rule_name(const char *name)
const char * unit_rule_name(const struct unit *punit)
int utype_veteran_levels(const struct unit_type *punittype)
Unit_type_id utype_index(const struct unit_type *punittype)
const char * utype_name_translation(const struct unit_type *punittype)
static bool utype_has_flag(const struct unit_type *punittype, int flag)
#define unit_type_iterate(_p)
#define unit_type_iterate_end
void vision_site_size_set(struct vision_site *psite, citizens size)
struct vision * vision_new(struct player *pplayer, struct tile *ptile)
bool vision_reveal_tiles(struct vision *vision, bool reveal_tiles)
struct vision_site * vision_site_new(int identity, struct tile *location, struct player *owner)
void vision_site_destroy(struct vision_site *psite)
bool worker_task_is_sane(struct worker_task *ptask)
#define worker_task_list_iterate(tasklist, ptask)
#define worker_task_list_iterate_end
void worklist_init(struct worklist *pwl)