149#ifdef FREECIV_TESTMATIC
150#define SAVE_DUMMY_TURN_CHANGE_TIME 1
166#define SAVE_MAP_CHAR(ptile, GET_XY_CHAR, secfile, secpath, ...) \
168 char _line[wld.map.xsize + 1]; \
169 int _nat_x, _nat_y; \
171 for (_nat_y = 0; _nat_y < wld.map.ysize; _nat_y++) { \
172 for (_nat_x = 0; _nat_x < wld.map.xsize; _nat_x++) { \
173 struct tile *ptile = native_pos_to_tile(&(wld.map), _nat_x, _nat_y); \
174 fc_assert_action(ptile != NULL, continue); \
175 _line[_nat_x] = (GET_XY_CHAR); \
176 sg_failure_ret(fc_isprint(_line[_nat_x] & 0x7f), \
177 "Trying to write invalid map data at position " \
178 "(%d, %d) for path %s: '%c' (%d)", _nat_x, _nat_y, \
179 secpath, _line[_nat_x], _line[_nat_x]); \
181 _line[wld.map.xsize] = '\0'; \
182 secfile_insert_str(secfile, _line, secpath, ## __VA_ARGS__, _nat_y); \
213#define LOAD_MAP_CHAR(ch, ptile, SET_XY_CHAR, secfile, secpath, ...) \
215 int _nat_x, _nat_y; \
216 bool _printed_warning = FALSE; \
217 for (_nat_y = 0; _nat_y < wld.map.ysize; _nat_y++) { \
218 const char *_line = secfile_lookup_str(secfile, secpath, \
219 ## __VA_ARGS__, _nat_y); \
220 if (NULL == _line) { \
222 fc_snprintf(buf, sizeof(buf), secpath, ## __VA_ARGS__, _nat_y); \
223 log_verbose("Line not found='%s'", buf); \
224 _printed_warning = TRUE; \
226 } else if (strlen(_line) != wld.map.xsize) { \
228 fc_snprintf(buf, sizeof(buf), secpath, ## __VA_ARGS__, _nat_y); \
229 log_verbose("Line too short (expected %d got " SIZE_T_PRINTF \
230 ")='%s'", wld.map.xsize, strlen(_line), buf); \
231 _printed_warning = TRUE; \
234 for (_nat_x = 0; _nat_x < wld.map.xsize; _nat_x++) { \
235 const char ch = _line[_nat_x]; \
236 struct tile *ptile = native_pos_to_tile(&(wld.map), _nat_x, _nat_y); \
240 if (_printed_warning) { \
242 log_sg(_("Saved game contains incomplete map data. This can" \
243 " happen with old saved games, or it may indicate an" \
244 " invalid saved game file. Proceed at your own risk.")); \
249#define halfbyte_iterate_extras(e, num_extras_types) \
252 for (e = 0; 4 * e < (num_extras_types); e++) {
254#define halfbyte_iterate_extras_end \
279 const char *save_reason,
291static enum direction8
char2dir(
char dir);
292static char dir2char(
enum direction8 dir);
295static char *
quote_block(
const void *
const data,
int length);
296static int unquote_block(
const char *
const quoted_,
void *dest,
299 struct worklist *pwl,
const char *path, ...);
302 int max_length,
const char *path, ...);
311 const char *path,
int plrno);
361 struct city *pcity,
const char *citystr,
362 int wlist_max_length);
366 const char *citystr);
371 int orders_max_length,
372 const char *unitstr);
382 const char *citystr);
447 bool was_send_city_suppressed, was_send_tile_suppressed;
512 const char *save_reason,
568 struct loaddata *loading = calloc(1,
sizeof(*loading));
659 struct savedata *saving = calloc(1,
sizeof(*saving));
742 return DIR8_SOUTHWEST;
746 return DIR8_SOUTHEAST;
752 return DIR8_NORTHWEST;
756 return DIR8_NORTHEAST;
760 return direction8_invalid();
800 case ACTIVITY_POLLUTION:
806 case ACTIVITY_IRRIGATE:
808 case ACTIVITY_CULTIVATE:
810 case ACTIVITY_FORTIFIED:
812 case ACTIVITY_SENTRY:
814 case ACTIVITY_PILLAGE:
818 case ACTIVITY_EXPLORE:
820 case ACTIVITY_TRANSFORM:
822 case ACTIVITY_FORTIFYING:
824 case ACTIVITY_FALLOUT:
828 case ACTIVITY_GEN_ROAD:
830 case ACTIVITY_CONVERT:
832 case ACTIVITY_OLD_ROAD:
833 case ACTIVITY_FORTRESS:
834 case ACTIVITY_OLD_RAILROAD:
835 case ACTIVITY_AIRBASE:
836 case ACTIVITY_UNKNOWN:
837 case ACTIVITY_PATROL_UNUSED:
852 enum unit_activity a;
854 for (a = 0; a < ACTIVITY_LAST; a++) {
857 if (activity == achar) {
863 return ACTIVITY_LAST;
872 char *buffer =
fc_malloc(length * 3 + 10);
876 sprintf(buffer,
"%d:", length);
877 offset = strlen(buffer);
879 for (i = 0; i < length; i++) {
880 sprintf(buffer + offset,
"%02x ", ((
unsigned char *) data)[i]);
894 int i, length, parsed, tmp;
896 const char *quoted = quoted_;
898 parsed = sscanf(quoted,
"%d", &length);
901 log_error(
_(
"Syntax error in attribute block."));
905 if (length > dest_length) {
909 quoted = strchr(quoted,
':');
911 if (quoted == NULL) {
912 log_error(
_(
"Syntax error in attribute block."));
918 for (i = 0; i < length; i++) {
919 tmp = strtol(quoted, &endptr, 16);
921 if ((endptr - quoted) != 2
923 || (tmp & 0xff) != tmp) {
924 log_error(
_(
"Syntax error in attribute block."));
928 ((
unsigned char *) dest)[i] = tmp;
940 struct worklist *pwl,
const char *path, ...)
956 "%s.wl_length", path_str);
958 for (i = 0; i < pwl->
length; i++) {
966 if (pwl->
entries[i].
kind == universals_n_invalid()) {
967 log_sg(
"%s.wl_value%d: unknown \"%s\" \"%s\".", path_str, i, kind,
975 for (; i < wlist_max_length; i++) {
987 int max_length,
const char *path, ...)
1001 for (i = 0; i < pwl->
length; i++) {
1004 "%s.wl_kind%d", path_str, i);
1006 "%s.wl_value%d", path_str, i);
1013 for (i = pwl->
length ; i < max_length; i++) {
1076 const char *pch = strchr(
hex_chars, ch);
1078 if (!pch || ch ==
'\0') {
1079 log_sg(
"Unknown hex value: '%c' (%d)", ch, ch);
1085 for (i = 0; i < 4; i++) {
1088 if (pextra == NULL) {
1091 if ((bin & (1 << i))
1109 for (i = 0; i < 4; i++) {
1140 if (pterrain->identifier_load == ch) {
1145 log_fatal(
"Unknown terrain identifier '%c' in savegame.", ch);
1169 const char *path,
int plrno)
1171 char path_with_name[128];
1175 fc_snprintf(path_with_name,
sizeof(path_with_name),
1196 "%s: unknown technology \"%s\".", path_with_name,
name);
1207 char path_with_name[128];
1210 fc_snprintf(path_with_name,
sizeof(path_with_name),
1244 const char *terr_name;
1245 bool ruleset_datafile;
1246 bool current_ruleset_rejected;
1261 ruleset_datafile =
FALSE;
1263 ruleset_datafile =
TRUE;
1266 current_ruleset_rejected =
FALSE;
1268 const char *req_caps;
1271 ruleset_datafile)) {
1278 "scenario.ruleset_caps");
1285 log_normal(
_(
"Scenario requires ruleset capabilities: %s"), req_caps);
1289 log_error(
_(
"Current ruleset %s not compatible with the scenario %s."
1290 " Trying to switch to the ruleset specified by the"
1294 current_ruleset_rejected =
TRUE;
1299 || current_ruleset_rejected) {
1300 const char *
ruleset, *alt_dir;
1304 "savefile.rulesetdir");
1313 log_verbose(
"Savegame specified ruleset '%s'. Really loading '%s'.",
1318 "savefile.ruleset_alt_dir");
1323 _(
"Failed to load either of rulesets '%s' or '%s' "
1324 "needed for savegame."),
1328 _(
"Failed to load ruleset '%s' needed for savegame."),
1333 if (current_ruleset_rejected) {
1349 const struct strvec **path;
1350 const char *found = NULL;
1354 for (path = paths; found == NULL && *path != NULL; path++) {
1360 if (found == NULL) {
1367 if (secfile == NULL) {
1368 log_error(
_(
"Failed to load scenario luadata file %s.luadata"),
1381 "savefile.last_updated_as_year");
1386 "savefile.improvement_size");
1390 "savefile.improvement_vector");
1392 "Failed to load improvement order: %s",
1399 "savefile.technology_size");
1403 "savefile.technology_vector");
1405 "Failed to load technology order: %s",
1412 "savefile.activities_size");
1416 "savefile.activities_vector");
1418 "Failed to load activity order: %s",
1425 "savefile.trait_size");
1429 "savefile.trait_vector");
1431 "Failed to load trait order: %s",
1438 "savefile.extras_size");
1440 const char **modname;
1445 "savefile.extras_vector");
1447 "Failed to load extras order: %s",
1450 "Number of extras defined by the ruleset (= %d) are "
1451 "lower than the number in the savefile (= %d).",
1454 nmod = 4 * ((loading->
extra.
size + 3) / 4);
1456 for (j = 0; j < loading->
extra.
size; j++) {
1460 for (; j < nmod; j++) {
1468 "savefile.multipliers_size");
1470 const char **modname;
1474 "savefile.multipliers_vector");
1476 "Failed to load multipliers order: %s",
1485 log_verbose(
"Multiplier \"%s\" in savegame but not in ruleset, "
1486 "discarding", modname[j]);
1495 "savefile.specialists_size");
1497 const char **modname;
1502 "savefile.specialists_vector");
1504 "Failed to load specialists order: %s",
1507 "Number of specialists defined by the ruleset (= %d) are "
1508 "lower than the number in the savefile (= %d).",
1520 for (; j < nmod; j++) {
1530 for (j = 0; j < i; j++) {
1532 "savefile.diplstate_type_vector,%d", j);
1538 "savefile.action_size");
1541 "Failed to load action order: %s",
1545 const char **modname;
1549 "savefile.action_vector");
1560 log_sg(
"Unknown action \'%s\'", modname[j]);
1571 "savefile.action_decision_size");
1574 "Failed to load action decision order: %s",
1578 const char **modname;
1582 "savefile.action_decision_vector");
1588 loading->
act_dec.
order[j] = action_decision_by_name(modname[j],
1598 "savefile.server_side_agent_size");
1601 "Failed to load server side agent order: %s",
1605 const char **modname;
1609 "savefile.server_side_agent_list");
1614 for (j = 0; j < loading->
ssa.
size; j++) {
1615 loading->
ssa.
order[j] = server_side_agent_by_name(modname[j],
1627 for (j = 0; j < i; j++) {
1633 pterr->identifier_load =
'\0';
1638 "savefile.terrident%d.name", i)) != NULL) {
1641 if (pterr != NULL) {
1643 "savefile.terrident%d.identifier", i);
1647 log_error(
"Identifier for unknown terrain type %s.", terr_name);
1654 if (pterr != pterr2 && pterr->identifier_load !=
'\0') {
1655 sg_failure_ret((pterr->identifier_load != pterr2->identifier_load),
1656 "%s and %s share a saved identifier",
1706 "savefile.improvement_size");
1715 "savefile.improvement_vector");
1722 "savefile.technology_size");
1731 "savefile.technology_vector");
1736 "savefile.activities_size");
1737 if (ACTIVITY_LAST > 0) {
1738 const char **modname;
1743 modname =
fc_calloc(ACTIVITY_LAST,
sizeof(*modname));
1745 for (j = 0; j < ACTIVITY_LAST; j++) {
1746 modname[i++] = unit_activity_name(j);
1751 "savefile.activities_vector");
1757 "savefile.specialists_size");
1759 const char **modname;
1769 "savefile.specialists_vector");
1776 "savefile.trait_size");
1778 const char **modname;
1782 modname =
fc_calloc(TRAIT_COUNT,
sizeof(*modname));
1784 for (tr = trait_begin(), j = 0; tr != trait_end(); tr = trait_next(tr), j++) {
1785 modname[j] = trait_name(tr);
1789 "savefile.trait_vector");
1795 "savefile.extras_size");
1797 const char **modname;
1808 "savefile.extras_vector");
1814 "savefile.multipliers_size");
1816 const char **modname;
1826 "savefile.multipliers_vector");
1832 "savefile.diplstate_type_size");
1834 const char **modname;
1838 modname =
fc_calloc(DS_LAST,
sizeof(*modname));
1840 for (j = 0; j < DS_LAST; j++) {
1841 modname[i++] = diplstate_type_name(j);
1846 "savefile.diplstate_type_vector");
1852 "savefile.city_options_size");
1853 if (CITYO_LAST > 0) {
1854 const char **modname;
1858 modname =
fc_calloc(CITYO_LAST,
sizeof(*modname));
1860 for (j = 0; j < CITYO_LAST; j++) {
1861 modname[i++] = city_options_name(j);
1866 "savefile.city_options_vector");
1872 "savefile.action_size");
1874 const char **modname;
1886 "savefile.action_vector");
1892 "savefile.action_decision_size");
1893 if (ACT_DEC_COUNT > 0) {
1894 const char **modname;
1898 modname =
fc_calloc(ACT_DEC_COUNT,
sizeof(*modname));
1900 for (j = 0; j < ACT_DEC_COUNT; j++) {
1901 modname[i++] = action_decision_name(j);
1906 "savefile.action_decision_vector");
1912 "savefile.server_side_agent_size");
1913 if (SSA_COUNT > 0) {
1914 const char **modname;
1918 modname =
fc_calloc(SSA_COUNT,
sizeof(*modname));
1920 for (j = 0; j < SSA_COUNT; j++) {
1921 modname[i++] = server_side_agent_name(j);
1926 "savefile.server_side_agent_list");
1958 "savefile.options");
1978 "ruledata.government%d.name", i));
1984 "ruledata.government%d.changes", i);
2003 "game.server_state");
2015 "game.meta_patches");
2024 "game.meta_server"));
2051 log_sg(
"Invalid AI level \"%s\". "
2052 "Changed to \"%s\".",
level,
2070 "game.phase_mode_stored");
2093 "game.timeoutintinc");
2099 "game.timeoutincmult");
2102 "game.timeoutcounter");
2131 "game.global_advances");
2134 "Invalid length of 'game.global_advances' ("
2135 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
2139 "Undefined value '%c' within 'game.global_advances'.",
2141 if (
str[i] ==
'1') {
2145 if (padvance != NULL) {
2170 "ruledata.government%d", set_count++);
2175 "%s.changes", path);
2184 enum server_states srv_state;
2195 srv_state = S_S_INITIAL;
2200 "game.server_state");
2206 "game.phase_seconds");
2210 "game.meta_patches");
2223 "game.phase_mode_stored");
2232 "game.timeoutintinc");
2236 "game.timeoutincmult");
2238 "game.timeoutcounter");
2243 "game.year_0_hack");
2246 "game.globalwarming");
2250 "game.warminglevel");
2253 "game.nuclearwinter");
2257 "game.coolinglevel");
2264 "game.random_seed");
2271 global_advances[i] =
'\0';
2282#ifndef SAVE_DUMMY_TURN_CHANGE_TIME
2284 "game.last_turn_change_time");
2287 "game.last_turn_change_time");
2291 "game.save_players");
2293 if (srv_state != S_S_INITIAL) {
2298 ainames[i] = ait->name;
2330 for (i = 0; i < 8; i++) {
2333 sscanf(
str,
"%8x %8x %8x %8x %8x %8x %8x", &loading->
rstate.
v[7*i],
2371 for (i = 0; i < 8; i++) {
2375 "%8x %8x %8x %8x %8x %8x %8x", rstate.
v[7 * i],
2376 rstate.
v[7 * i + 1], rstate.
v[7 * i + 2],
2377 rstate.
v[7 * i + 3], rstate.
v[7 * i + 4],
2378 rstate.
v[7 * i + 5], rstate.
v[7 * i + 6]);
2432 sg_failure_ret(29099 <= game_version,
"Saved game is too old, at least "
2433 "version 2.90.99 required.");
2446 if (buf[0] !=
'\0') {
2451 "scenario.authors");
2452 if (buf[0] !=
'\0') {
2459 "scenario.description");
2460 if (buf[0] !=
'\0') {
2471 "scenario.startpos_nations");
2474 "scenario.prevent_new_cities");
2477 "scenario.lake_flooding");
2480 "scenario.handmade");
2483 "scenario.allow_ai_type_fallback");
2487 "scenario.ruleset_locked");
2490 "scenario.datafile");
2491 if (buf[0] !=
'\0') {
2498 "Invalid scenario definition (server state '%s' and "
2509 struct entry *mod_entry;
2515 game_version = MAJOR_VERSION * 1000000 + MINOR_VERSION * 10000 + PATCH_VERSION * 100;
2516#ifdef EMERGENCY_VERSION
2517 game_version += EMERGENCY_VERSION;
2535 "scenario.authors");
2542 "scenario.description");
2549 "scenario.startpos_nations");
2552 "scenario.prevent_new_cities");
2555 "scenario.lake_flooding");
2558 "scenario.handmade");
2562 "scenario.allow_ai_type_fallback");
2567 "scenario.datafile");
2570 "scenario.ruleset_locked");
2573 "scenario.ruleset_caps");
2692 "map.have_resources");
2737 const char *spec_sprite;
2746 if (NULL != ptile->spec_sprite) {
2747 ptile->spec_sprite =
fc_strdup(spec_sprite);
2749 if (label != NULL) {
2772 if (ptile->spec_sprite) {
2776 if (ptile->label != NULL) {
2794 loading->
file,
"map.e%02d_%04d", j);
2827 for (l = 0; l < 4; l++) {
2835 saving->
file,
"map.e%02d_%04d", j);
2848 const char SEPARATOR =
'#';
2849 const char *nation_names;
2852 int i, startpos_count;
2860 if (0 == startpos_count) {
2865 for (i = 0; i < startpos_count; i++) {
2868 "map.startpos%d.y", i)) {
2869 log_sg(
"Warning: Undefined coordinates for startpos %d", i);
2874 if (NULL == ptile) {
2875 log_error(
"Start position native coordinates (%d, %d) do not exist "
2881 "map.startpos%d.exclude", i);
2886 "map.startpos%d.nations", i);
2887 if (NULL != nation_names &&
'\0' != nation_names[0]) {
2888 const size_t size = strlen(nation_names) + 1;
2889 char buf[
size], *start, *end;
2891 memcpy(buf, nation_names,
size);
2892 for (start = buf - 1; NULL != start; start = end) {
2894 if ((end = strchr(start, SEPARATOR))) {
2915 log_verbose(
"Number of starts (%d) are lower than rules.max_players "
2916 "(%d), lowering rules.max_players.",
2933 const char SEPARATOR =
'#';
2944 "map.startpos_count");
2956 "map.startpos%d.exclude", i);
2963 nation_names[0] =
'\0';
2965 if (
'\0' == nation_names[0]) {
2967 sizeof(nation_names));
2974 "map.startpos%d.nations", i);
3002 "map.owner%04d", y);
3004 "map.source%04d", y);
3006 "map.eowner%04d", y);
3009 "map.placing%04d", y);
3012 "map.infra_turns%04d", y);
3013 const char *ptr1 = buffer1;
3014 const char *ptr2 = buffer2;
3015 const char *ptr3 = buffer3;
3016 const char *ptr_placing = buffer_placing;
3017 const char *ptr_turns = buffer_turns;
3030 struct player *eowner = NULL;
3035 scanin(&ptr1,
",", token1,
sizeof(token1));
3037 "Map size not correct (map.owner%d).", y);
3038 if (strcmp(token1,
"-") == 0) {
3042 "Got map owner %s in (%d, %d).", token1, x, y);
3046 scanin(&ptr2,
",", token2,
sizeof(token2));
3048 "Map size not correct (map.source%d).", y);
3049 if (strcmp(token2,
"-") == 0) {
3053 "Got map source %s in (%d, %d).", token2, x, y);
3057 scanin(&ptr3,
",", token3,
sizeof(token3));
3059 "Map size not correct (map.eowner%d).", y);
3060 if (strcmp(token3,
"-") == 0) {
3064 "Got base owner %s in (%d, %d).", token3, x, y);
3068 if (ptr_placing != NULL) {
3069 scanin(&ptr_placing,
",", token_placing,
sizeof(token_placing));
3071 "Map size not correct (map.placing%d).", y);
3072 if (strcmp(token_placing,
"-") == 0) {
3076 "Got placing extra %s in (%d, %d).", token_placing, x, y);
3083 if (ptr_turns != NULL) {
3084 scanin(&ptr_turns,
",", token_turns,
sizeof(token_turns));
3086 "Map size not correct (map.infra_turns%d).", y);
3088 "Got infra_turns %s in (%d, %d).", token_turns, x, y);
3133 strcat(line, token);
3154 strcat(line, token);
3176 strcat(line, token);
3198 strcat(line, token);
3220 strcat(line, token);
3240 "City worked map not loaded!");
3248 const char *ptr = buffer;
3251 "Savegame corrupt - map line %d not found.", y);
3257 scanin(&ptr,
",", token,
sizeof(token));
3259 "Savegame corrupt - map size not correct.");
3260 if (strcmp(token,
"-") == 0) {
3264 "Savegame corrupt - got tile worked by city "
3265 "id=%s in (%d, %d).", token, x, y);
3298 if (pcity == NULL) {
3303 strcat(line, token);
3327 "game.save_known")) {
3332 for (l = 0; l <
lines; l++) {
3333 for (j = 0; j < 8; j++) {
3334 for (i = 0; i < 4; i++) {
3341 loading->
file,
"map.k%02d_%04d", l * 8 + j);
3398 |= (1u << (p % 32));
3403 for (l = 0; l <
lines; l++) {
3404 for (j = 0; j < 8; j++) {
3405 for (i = 0; i < 4; i++) {
3412 saving->
file,
"map.k%02d_%04d", l * 8 + j);
3439 bool shuffle_loaded =
TRUE;
3452 "players.destroyed_wonders");
3455 "Invalid length for 'players.destroyed_wonders' ("
3456 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
")",
3460 "Undefined value '%c' within "
3461 "'players.destroyed_wonders'.",
str[k]);
3463 if (
str[k] ==
'1') {
3475 "players.identity_number_used");
3502 log_sg(
"Game has started, yet player %d has no color defined.",
3506 log_verbose(
"No color defined for player %d.", pslot_id);
3541 "player%d.multiplier%d.val",
3547 log_verbose(
"Player %d had illegal value for multiplier \"%s\": "
3548 "was %d, clamped to %d", pslot_id,
3556 "player%d.multiplier%d.target",
3562 log_verbose(
"Player %d had illegal value for multiplier_target "
3563 " \"%s\": was %d, clamped to %d", pslot_id,
3570 "player%d.multiplier%d.changed",
3578 "player%d.border_vision",
3585 "(%d) from the loaded game does not match the number of "
3597 "Invalid team definition for player %s (nb %d).",
3613 "players.shuffled_player_%d", 0) >= 0) {
3616 int shuffled_players[
slots];
3617 bool shuffled_player_set[
slots];
3619 for (i = 0; i <
slots; i++) {
3621 shuffled_player_set[i] =
FALSE;
3624 shuffled_players[i] = -1;
3628 for (i = 0; i < plrcount; i++) {
3631 "players.shuffled_player_%d", i);
3633 if (shuffle == -1) {
3634 log_sg(
"Missing player shuffle information (index %d) "
3635 "- reshuffle player list!", i);
3636 shuffle_loaded =
FALSE;
3638 }
else if (shuffled_player_set[shuffle]) {
3639 log_sg(
"Player shuffle %d used two times "
3640 "- reshuffle player list!", shuffle);
3641 shuffle_loaded =
FALSE;
3645 shuffled_player_set[shuffle] =
TRUE;
3648 shuffled_players[i] = shuffle;
3651 if (shuffle_loaded) {
3653 int shuffle_index = plrcount;
3655 for (i = 0; i <
slots; i++) {
3656 if (!shuffled_player_set[i]) {
3657 shuffled_players[shuffle_index++] = i;
3662 "Invalid player shuffle data!");
3670 log_debug(
"[load shuffle] id: %3d => slot: %3d | slot %3d: %s",
3671 plrid, shuffled_players[plrid], plrid,
3672 shuffled_player_set[plrid] ?
"is used" :
"-");
3681 if (!shuffle_loaded) {
3711 if (
is_ai(pplayer)) {
3712 log_normal(
_(
"%s has been added as %s level AI-controlled player "
3714 ai_level_translated_name(pplayer->ai_common.skill_level),
3717 log_normal(
_(
"%s has been added as human player."),
3740 log_sg(
_(
"%s had invalid nation; changing to %s."),
3756 log_sg(
"Illegal alliance structure detected: "
3757 "%s alliance to %s reduced to peace treaty.",
3771 pcity->server.illness
3773 &(pcity->illness_trade), NULL);
3799 BV_CLR_ALL(pplayer->server.really_gives_vision);
3809 "player%d.diplstate%d.gives_shared_vision", plr1, plr2)) {
3821 if (pplayer1 != pplayer2
3825 _(
"%s did not give shared vision to team member %s."),
3831 _(
"%s did not give shared vision to team member %s."),
3851 log_sg(
"%s doing illegal activity in savegame!",
3853 log_sg(
"Activity: %s, Target: %s, Tile: (%d, %d), Terrain: %s",
3897 char destroyed[
B_LAST+1];
3909 "players.destroyed_wonders");
3913 "players.identity_number_used");
3920 "players.shuffled_player_%d", i);
3949 const char *barb_str;
3962 "player%d.username", plrno));
3964 "player%d.unassigned_user", plrno),
3968 "player%d.orig_username", plrno));
3971 "player%d.ranked_username",
3974 "player%d.unassigned_ranked", plrno),
3977 "player%d.delegation_username",
3987 for (i = 0; i < nval; i++) {
3988 const char *sval = slist[i];
3989 enum plr_flag_id fid = plr_flag_id_by_name(sval,
fc_strcasecmp);
3991 sg_failure_ret(plr_flag_id_is_valid(fid),
"Invalid player flag \"%s\".", sval);
4000 if (plr->
nation != NULL) {
4008 sg_failure_ret(gov != NULL,
"Player%d: unsupported government \"%s\".",
4014 "player%d.target_government_name", plrno);
4022 "player%d.revolution_finishes", plrno);
4026 "player%d.got_first_city", plrno),
4038 fc_snprintf(buf,
sizeof(buf),
"player%d.diplstate%d", plrno, i);
4042 diplstate_type,
"%s.current", buf);
4045 diplstate_type,
"%s.closest", buf);
4048 "%s.first_contact_turn", buf);
4053 "%s.has_reason_to_cancel", buf);
4056 "%s.contact_turns_left", buf);
4070 fc_snprintf(buf,
sizeof(buf),
"player%d.ai%d", plrno,
4079 "player%d.adv.wonder_city",
4091 "player%d.ai.level", plrno);
4100 log_sg(
"Player%d: Invalid AI level \"%s\". "
4101 "Changed to \"%s\".", plrno,
level,
4107 "player%d.ai.barb_type", plrno);
4111 log_sg(
"Player%d: Invalid barbarian type \"%s\". "
4112 "Changed to \"None\".", plrno, barb_str);
4133 if (style == NULL) {
4135 log_sg(
"Player%d: unsupported city_style_name \"%s\". "
4142 "player%d.idle_turns", plrno),
4145 if (!strcmp(
"male", kind)) {
4151 "player%d.is_alive", plrno),
4154 "player%d.turns_alive", plrno),
4157 "player%d.last_war", plrno),
4160 "player%d.phase_done", plrno);
4162 "player%d.gold", plrno),
4165 "player%d.rates.tax", plrno),
4168 "player%d.rates.science", plrno),
4171 "player%d.rates.luxury", plrno),
4174 "player%d.infrapts",
4178 "player%d.research.bulbs_last_turn", plrno);
4182 for (i = 0; i < loading->
trait.
size; i++) {
4185 if (trait_is_valid(tr)) {
4194 "player%d.trait%d.mod", plrno, i),
4206 "player%d.achievement_count", plrno);
4209 for (i = 0; i < count; i++) {
4215 "player%d.achievement%d.name", plrno, i);
4219 "Unknown achievement \"%s\".",
name);
4222 "player%d.achievement%d.first",
4227 "Multiple players listed as first to get achievement \"%s\".",
4242 "score%d.happy", plrno);
4245 "score%d.content", plrno);
4248 "score%d.unhappy", plrno);
4251 "score%d.angry", plrno);
4262 "score%d.specialists%d", plrno, i);
4267 "score%d.wonders", plrno);
4270 "score%d.techs", plrno);
4273 "score%d.techout", plrno);
4276 "score%d.landarea", plrno);
4279 "score%d.settledarea", plrno);
4282 "score%d.population", plrno);
4285 "score%d.cities", plrno);
4288 "score%d.units", plrno);
4291 "score%d.pollution", plrno);
4294 "score%d.literacy", plrno);
4297 "score%d.bnp", plrno);
4300 "score%d.mfg", plrno);
4303 "score%d.spaceship", plrno);
4306 "score%d.units_built", plrno);
4309 "score%d.units_killed", plrno);
4312 "score%d.units_lost", plrno);
4315 "score%d.culture", plrno);
4318 "score%d.total", plrno);
4327 fc_snprintf(prefix,
sizeof(prefix),
"player%d.spaceship", plrno);
4331 "%s.state", prefix),
4337 "%s.structurals", prefix),
4340 "%s.components", prefix),
4343 "%s.modules", prefix),
4349 "%s.propulsion", prefix),
4352 "%s.habitation", prefix),
4355 "%s.life_support", prefix),
4358 "%s.solar_panels", prefix),
4365 "Undefined value '%c' within '%s.structure'.", st[i],
4368 if (!(st[i] ==
'0')) {
4374 "%s.launch_year", prefix),
4388 "Invalid length for 'player%d.lost_wonders' ("
4389 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
")",
4393 "Undefined value '%c' within "
4394 "'player%d.lost_wonders'.", plrno,
str[k]);
4396 if (
str[k] ==
'1') {
4420 const char *flag_names[PLRF_COUNT];
4427 for (i = 0; i < PLRF_COUNT; i++) {
4429 flag_names[set_count++] = plr_flag_id_name(i);
4434 "player%d.flags", plrno);
4437 "player%d.ai_type", plrno);
4439 "player%d.name", plrno);
4441 "player%d.username", plrno);
4443 "player%d.unassigned_user", plrno);
4444 if (plr->
rgb != NULL) {
4449 log_sg(
"Game has started, yet player %d has no color defined.", plrno);
4453 "player%d.ranked_username", plrno);
4455 "player%d.unassigned_ranked", plrno);
4457 "player%d.orig_username", plrno);
4461 "player%d.delegation_username", plrno);
4463 "player%d.nation", plrno);
4465 "player%d.team_no", plrno);
4469 "player%d.government_name", plrno);
4474 "player%d.target_government_name", plrno);
4478 "player%d.style_by_name", plrno);
4481 "player%d.idle_turns", plrno);
4484 "player%d.kind", plrno);
4487 "player%d.kind", plrno);
4490 "player%d.is_alive", plrno);
4492 "player%d.turns_alive", plrno);
4494 "player%d.last_war", plrno);
4496 "player%d.phase_done", plrno);
4505 fc_snprintf(buf,
sizeof(buf),
"player%d.diplstate%d", plrno, i);
4508 diplstate_type,
"%s.current", buf);
4510 diplstate_type,
"%s.closest", buf);
4512 "%s.first_contact_turn", buf);
4514 "%s.turns_left", buf);
4516 "%s.has_reason_to_cancel", buf);
4518 "%s.contact_turns_left", buf);
4522 "%s.gives_shared_vision", buf);
4529 "player%d.ai%d.love", plrno, i);
4534 "player%d.adv.wonder_city", plrno);
4541 for (k = 0; k < i; k++) {
4543 "player%d.multiplier%d.val", plrno, k);
4545 "player%d.multiplier%d.target", plrno, k);
4547 "player%d.multiplier%d.changed", plrno, k);
4551 "player%d.ai.level", plrno);
4553 "player%d.ai.barb_type", plrno);
4555 "player%d.gold", plrno);
4557 "player%d.rates.tax", plrno);
4559 "player%d.rates.science", plrno);
4561 "player%d.rates.luxury", plrno);
4563 "player%d.infrapts", plrno);
4565 "player%d.research.bulbs_last_turn", plrno);
4572 for (tr = trait_begin(), j = 0; tr != trait_end(); tr = trait_next(tr), j++) {
4574 "player%d.trait%d.val", plrno, j);
4576 "player%d.trait%d.mod", plrno, j);
4587 "player%d.achievement%d.name", plrno, j);
4588 if (pach->first == plr) {
4590 "player%d.achievement%d.first", plrno, j);
4593 "player%d.achievement%d.first", plrno, j);
4601 "player%d.achievement_count", plrno);
4605 "player%d.got_first_city", plrno);
4607 "player%d.revolution_finishes", plrno);
4611 "score%d.happy", plrno);
4613 "score%d.content", plrno);
4615 "score%d.unhappy", plrno);
4617 "score%d.angry", plrno);
4620 "score%d.specialists%d", plrno, sp);
4623 "score%d.wonders", plrno);
4625 "score%d.techs", plrno);
4627 "score%d.techout", plrno);
4629 "score%d.landarea", plrno);
4631 "score%d.settledarea", plrno);
4633 "score%d.population", plrno);
4635 "score%d.cities", plrno);
4637 "score%d.units", plrno);
4639 "score%d.pollution", plrno);
4641 "score%d.literacy", plrno);
4643 "score%d.bnp", plrno);
4645 "score%d.mfg", plrno);
4647 "score%d.spaceship", plrno);
4649 "score%d.units_built", plrno);
4651 "score%d.units_killed", plrno);
4653 "score%d.units_lost", plrno);
4655 "score%d.culture", plrno);
4657 "score%d.total", plrno);
4667 fc_snprintf(buf,
sizeof(buf),
"player%d.spaceship", plrno);
4670 "%s.structurals", buf);
4672 "%s.components", buf);
4679 "%s.life_support", buf);
4681 "%s.solar_panels", buf);
4690 "%s.launch_year", buf);
4707 "player%d.lost_wonders", plrno);
4711 "player%d.history", plrno);
4713 "player%d.hut_count", plrno);
4716 "player%d.border_vision", plrno);
4727 int wlist_max_length = 0;
4733 "player%d.ncities", plrno),
4736 if (!plr->
is_alive && ncities > 0) {
4737 log_sg(
"'player%d.ncities' = %d for dead player!", plrno, ncities);
4747 for (i = 0; i < ncities; i++) {
4749 "player%d.c%d.wl_length",
4752 wlist_max_length =
MAX(wlist_max_length, wl_length);
4756 for (i = 0; i < ncities; i++) {
4760 fc_snprintf(buf,
sizeof(buf),
"player%d.c%d", plrno, i);
4787 city_list_append(plr->
cities, pcity);
4790 tasks_handled =
FALSE;
4791 for (i = 0; !tasks_handled; i++) {
4793 struct city *pcity = NULL;
4798 if (city_id != -1) {
4802 if (pcity != NULL) {
4816 "Unknown workertask activity %s",
str);
4820 if (strcmp(
"-",
str)) {
4824 "Unknown workertask target %s",
str);
4828 if (ptask->
act == ACTIVITY_IRRIGATE) {
4829 ptask->
act = ACTIVITY_CULTIVATE;
4830 }
else if (ptask->
act == ACTIVITY_MINE) {
4831 ptask->
act = ACTIVITY_MINE;
4836 "player%d.task%d.want", plrno, i);
4838 worker_task_list_append(pcity->
task_reqs, ptask);
4840 tasks_handled =
TRUE;
4849 struct city *pcity,
const char *citystr,
4850 int wlist_max_length)
4853 const char *kind, *
name, *
str;
4854 int id, i, repair, sp_count = 0, workers = 0, value;
4857 const char *stylename;
4868 "%s has invalid center tile (%d, %d)",
4871 "%s duplicates city (%d, %d)", citystr,
nat_x,
nat_y);
4875 "%s.name", citystr));
4881 "%s.original", citystr);
4891 "Invalid city size: %d, set to %d", value,
size);
4904 for (i = 0; partner != 0; i++) {
4907 const char *good_str;
4911 trade_route_list_append(pcity->
routes, proute);
4916 "No traderoute direction found for %s", citystr);
4919 "Illegal route direction %s",
dir);
4922 "No good found for %s", citystr);
4925 "Illegal good %s", good_str);
4929 "%s.traderoute%d", citystr, i + 1);
4939 "%s.food_stock", citystr),
4942 "%s.shield_stock", citystr),
4957 "%s.anarchy", citystr),
4965 "%s.turn_founded", citystr),
4973 "%s.turn_last_built", citystr),
4982 "%s.currently_building: unknown \"%s\" \"%s\".",
4983 citystr, kind,
name);
4986 "%s.current_want", citystr);
4999 "%s.changed_from: unknown \"%s\" \"%s\".",
5000 citystr, kind,
name);
5004 "%s.before_change_shields", citystr);
5007 "%s.caravan_shields", citystr);
5010 "%s.disbanded_shields", citystr);
5013 "%s.last_turns_shield_surplus",
5017 "%s.style", citystr);
5018 if (stylename != NULL) {
5023 if (pcity->
style < 0) {
5038 "Invalid length of '%s.improvements' ("
5039 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
5043 "Undefined value '%c' within '%s.improvements'.",
5046 if (
str[i] ==
'1') {
5057 "No worked tiles map defined.");
5072 log_sg(
"[%s] '%s' (%d, %d) has worker outside current radius "
5093 if (NULL != pwork) {
5094 log_sg(
"[%s] city center of '%s' (%d,%d) [%d] is worked by '%s' "
5103 log_sg(
"[%s] city center of '%s' (%d,%d) [%d] is empty; repairing",
5115 log_sg(
"[%s] size mismatch for '%s' (%d,%d): size [%d] != "
5116 "(workers [%d] - free worked tiles [%d]) + specialists [%d]",
5129 for (i = 0; i < CITYO_LAST; i++) {
5139 "%s.rally_point_length", citystr);
5144 const char *rally_orders, *rally_dirs, *rally_activities;
5150 "%s.rally_point_persistent", citystr);
5153 "%s.rally_point_vigilant", citystr);
5157 "%s.rally_point_orders", citystr);
5160 "%s.rally_point_dirs", citystr);
5163 "%s.rally_point_activities", citystr);
5165 for (i = 0; i <
len; i++) {
5168 if (rally_orders[i] ==
'\0' || rally_dirs[i] ==
'\0'
5169 || rally_activities[i] ==
'\0') {
5170 log_sg(
"Invalid rally point.");
5181 "%s.rally_point_action_vec,%d",
5184 if (unconverted >= 0 && unconverted < loading->
action.size) {
5189 log_sg(
"Invalid action id in order for city rally point %d",
5198 "%s.rally_point_tgt_vec,%d",
5202 "%s.rally_point_sub_tgt_vec,%d",
5221 "%s.rally_point_tgt_vec", citystr);
5223 "%s.rally_point_sub_tgt_vec", citystr);
5230 "%s.cma_enabled", citystr);
5234 for (i = 0; i <
O_LAST; i++) {
5236 loading->
file, 0,
"%s.cma_minimal_surplus,%d", citystr, i);
5238 loading->
file, 0,
"%s.cma_factor,%d", citystr, i);
5242 loading->
file,
FALSE,
"%s.max_growth", citystr);
5244 loading->
file,
FALSE,
"%s.require_happy", citystr);
5246 loading->
file,
FALSE,
"%s.allow_disorder", citystr);
5248 loading->
file,
FALSE,
"%s.allow_specialists", citystr);
5250 loading->
file, 0,
"%s.happy_factor", citystr);
5255 for (i = 0; i <
O_LAST; i++) {
5257 "%s.cma_minimal_surplus,%d", citystr, i);
5259 "%s.cma_factor,%d", citystr, i);
5286 const char *citystr)
5296 "%s.citizen%d", citystr,
5299 log_sg(
"Citizens of an invalid nation for %s (player slot %d)!",
5306 "Invalid value for citizens of player %d in %s: %d.",
5319 log_sg(
"City size and number of citizens does not match in %s "
5334 int wlist_max_length = 0, rally_point_max_length = 0, routes_max = 0;
5343 "player%d.ncities", plrno);
5361 if (pcity->worklist.length > wlist_max_length) {
5362 wlist_max_length = pcity->worklist.length;
5365 if (pcity->rally_point.length > rally_point_max_length) {
5366 rally_point_max_length = pcity->rally_point.length;
5370 if (routes > routes_max) {
5371 routes_max = routes;
5387 char impr_buf[
B_LAST + 1];
5391 fc_snprintf(buf,
sizeof(buf),
"player%d.c%d", plrno, i);
5400 if (pcity->original != NULL) {
5402 "%s.original", buf);
5419 "%s.route_direction%d", buf, j);
5421 "%s.route_good%d", buf, j);
5426 for (; j < routes_max; j++) {
5429 "%s.route_direction%d", buf, j);
5431 "%s.route_good%d", buf, j);
5456 "%s.turn_last_built", buf);
5462 "%s.currently_building_kind", buf);
5464 "%s.currently_building_name", buf);
5466 if (pcity->production.kind == VUT_IMPROVEMENT) {
5470 "%s.current_want", buf);
5473 "%s.current_want", buf);
5477 "%s.changed_from_kind", buf);
5479 "%s.changed_from_name", buf);
5482 "%s.before_change_shields", buf);
5484 "%s.caravan_shields", buf);
5486 "%s.disbanded_shields", buf);
5488 "%s.last_turns_shield_surplus", buf);
5496 "player%d.c%d.city_radius_sq", plrno, i);
5510 "Invalid size of the improvement vector (%s.improvements: "
5511 SIZE_T_PRINTF
" < " SIZE_T_PRINTF
").", buf,
5512 strlen(impr_buf),
sizeof(impr_buf));
5518 for (j = 0; j < CITYO_LAST; j++) {
5520 "%s.option%d", buf, j);
5537 "%s.rally_point_length", buf);
5538 if (pcity->rally_point.length) {
5539 int len = pcity->rally_point.length;
5540 char orders[
len + 1], dirs[
len + 1], activities[
len + 1];
5543 int sub_targets[
len];
5546 "%s.rally_point_persistent", buf);
5548 "%s.rally_point_vigilant", buf);
5550 for (j = 0; j <
len; j++) {
5551 orders[j] =
order2char(pcity->rally_point.orders[j].order);
5553 activities[j] =
'?';
5557 switch (pcity->rally_point.orders[j].order) {
5560 dirs[j] =
dir2char(pcity->rally_point.orders[j].dir);
5563 sub_targets[j] = pcity->rally_point.orders[j].sub_target;
5568 actions[j] = pcity->rally_point.orders[j].action;
5569 targets[j] = pcity->rally_point.orders[j].target;
5570 sub_targets[j] = pcity->rally_point.orders[j].sub_target;
5577 orders[
len] = dirs[
len] = activities[
len] =
'\0';
5582 "%s.rally_point_activities", buf);
5585 "%s.rally_point_action_vec", buf);
5588 for (j =
len; j < rally_point_max_length; j++) {
5594 "%s.rally_point_tgt_vec", buf);
5597 for (j =
len; j < rally_point_max_length; j++) {
5599 "%s.rally_point_tgt_vec,%d", buf, j);
5603 "%s.rally_point_sub_tgt_vec", buf);
5606 for (j =
len; j < rally_point_max_length; j++) {
5629 for (j = 1; j < rally_point_max_length; j++) {
5637 for (j = 1; j < rally_point_max_length; j++) {
5639 "%s.rally_point_tgt_vec,%d", buf, j);
5645 for (j = 1; j < rally_point_max_length; j++) {
5652 "%s.cma_enabled", buf);
5653 if (pcity->cm_parameter) {
5655 pcity->cm_parameter->minimal_surplus,
O_LAST,
5656 "%s.cma_minimal_surplus", buf);
5658 pcity->cm_parameter->factor,
O_LAST,
5659 "%s.cma_factor", buf);
5661 "%s.max_growth", buf);
5663 "%s.require_happy", buf);
5665 "%s.allow_disorder", buf);
5667 pcity->cm_parameter->allow_specialists,
5668 "%s.allow_specialists", buf);
5670 "%s.happy_factor", buf);
5674 memset(zeros, 0,
sizeof(zeros));
5676 "%s.cma_minimal_surplus", buf);
5678 "%s.cma_factor", buf);
5700 "player%d.task%d.activity",
5702 if (ptask->tgt != NULL) {
5704 "player%d.task%d.target",
5708 "player%d.task%d.target",
5725 size_t orders_max_length;
5731 "player%d.nunits", plrno),
5733 if (!plr->
is_alive && nunits > 0) {
5734 log_sg(
"'player%d.nunits' = %d for dead player!", plrno, nunits);
5738 orders_max_length = 0;
5740 for (i = 0; i < nunits; i++) {
5742 "player%d.u%d.orders_length",
5745 orders_max_length =
MAX(orders_max_length, ol_length);
5748 for (i = 0; i < nunits; i++) {
5756 fc_snprintf(buf,
sizeof(buf),
"player%d.u%d", plrno, i);
5798 int orders_max_length,
5799 const char *unitstr)
5801 enum unit_activity activity;
5807 const char *facing_str;
5826 "%s.facing", unitstr);
5827 if (facing_str[0] !=
'x') {
5831 enum direction8 facing =
char2dir(facing_str[0]);
5833 if (direction8_is_valid(facing)) {
5836 log_error(
"Illegal unit orientation '%s'", facing_str);
5844 "%s.nationality", unitstr);
5852 "%s.homecity", unitstr),
FALSE,
5855 "%s.moves", unitstr),
FALSE,
5858 "%s.fuel", unitstr),
FALSE,
5861 "%s.activity", unitstr),
FALSE,
5868 "%s.born", unitstr);
5871 "%s.activity_tgt", unitstr);
5873 if (extra_id != -2) {
5874 if (extra_id >= 0 && extra_id < loading->extra.size) {
5877 }
else if (activity == ACTIVITY_IRRIGATE) {
5887 }
else if (activity == ACTIVITY_MINE) {
5905 "%s.activity_count", unitstr),
FALSE,
5910 "%s.changed_from", unitstr);
5913 "%s.changed_from_tgt", unitstr),
FALSE,
5916 if (extra_id >= 0 && extra_id < loading->extra.size) {
5924 "%s.changed_from_count", unitstr);
5931 if (activity == ACTIVITY_SENTRY) {
5951 "%s.done_moving", unitstr);
5954 "%s.battlegroup", unitstr);
5957 "%s.go", unitstr)) {
5961 "%s.goto_x", unitstr),
FALSE,
5964 "%s.goto_y", unitstr),
FALSE,
5973 sg_regr(3010600,
"Unit %d on goto without goto_tile. Aborting goto.",
5989 "%s.server_side_agent",
5991 if (unconverted >= 0 && unconverted < loading->ssa.size) {
5995 log_sg(
"Invalid server side agent %d for unit %d",
6002 "%s.hp", unitstr),
FALSE,
6013 "%s.paradropped", unitstr);
6015 if (
str[0] !=
'\0') {
6033 "%s.action_decision", unitstr),
6036 if (unconverted >= 0 && unconverted < loading->act_dec.size) {
6041 log_sg(
"Invalid action decision want for unit %d",
punit->
id);
6051 "%s.action_decision_tile_x", unitstr)
6053 "%s.action_decision_tile_y", unitstr)) {
6072 "%s.orders_length", unitstr);
6075 const char *orders_unitstr, *dir_unitstr, *act_unitstr;
6082 "%s.orders_index", unitstr);
6085 "%s.orders_repeat", unitstr);
6088 "%s.orders_vigilant", unitstr);
6092 "%s.orders_list", unitstr);
6095 "%s.dir_list", unitstr);
6098 "%s.activity_list", unitstr);
6102 for (j = 0; j <
len; j++) {
6104 bool action_wants_extra =
FALSE;
6107 if (orders_unitstr[j] ==
'\0' || dir_unitstr[j] ==
'\0'
6108 || act_unitstr[j] ==
'\0') {
6109 log_sg(
"Invalid unit orders.");
6121 if (unconverted >= 0 && unconverted < loading->
action.size) {
6126 log_sg(
"Invalid action id in order for unit %d",
punit->
id);
6135 && !direction8_is_valid(
order->dir))
6139 &&
order->activity == ACTIVITY_LAST)) {
6153 "%s.sub_tgt_vec,%d",
6163 log_sg(
"Cannot find building %d for %s to %s",
6168 order->sub_target = order_sub_tgt;
6173 if (order_sub_tgt ==
A_NONE
6177 log_sg(
"Cannot find tech %d for %s to steal",
6181 order->sub_target = order_sub_tgt;
6185 case ASTK_EXTRA_NOT_THERE:
6187 action_wants_extra =
TRUE;
6192 "Specified sub target for action %d unsupported.",
6198 "Bad action action %d.",
6206 enum unit_activity act;
6208 if (order_sub_tgt < 0 || order_sub_tgt >= loading->
extra.
size) {
6210 log_sg(
"Cannot find extra %d for %s to build",
6216 order->sub_target = order_sub_tgt;
6220 if (action_wants_extra) {
6223 act =
order->activity;
6226 if (unit_activity_is_valid(act)
6238 if (order_sub_tgt != -1) {
6239 log_sg(
"Unexpected sub_target %d (expected %d) for order type %d",
6240 order_sub_tgt, -1,
order->order);
6246 for (; j < orders_max_length; j++) {
6248 "%s.action_vec,%d", unitstr, j);
6250 "%s.tgt_vec,%d", unitstr, j);
6252 "%s.sub_tgt_vec,%d", unitstr, j);
6277 for (j = 1; j < orders_max_length; j++) {
6279 "%s.action_vec,%d", unitstr, j);
6281 "%s.tgt_vec,%d", unitstr, j);
6283 "%s.sub_tgt_vec,%d", unitstr, j);
6306 "player%d.nunits", plrno),
6308 if (!plr->
is_alive && nunits > 0) {
6309 log_sg(
"'player%d.nunits' = %d for dead player!", plrno, nunits);
6313 for (i = 0; i < nunits; i++) {
6314 int id_unit, id_trans;
6324 "player%d.u%d.transported_by",
6326 if (id_trans == -1) {
6335#ifndef FREECIV_NDEBUG
6352 int longest_order = 0;
6359 "player%d.nunits", plrno);
6365 if (longest_order < punit->
orders.length) {
6373 char dirbuf[2] =
" ";
6377 fc_snprintf(buf,
sizeof(buf),
"player%d.u%d", plrno, i);
6388 "%s.nationality", buf);
6394 "%s.type_by_name", buf);
6398 "%s.activity_count", buf);
6403 "%s.activity_tgt", buf);
6407 "%s.changed_from", buf);
6409 "%s.changed_from_count", buf);
6414 "%s.changed_from_tgt", buf);
6418 "%s.done_moving", buf);
6424 "%s.battlegroup", buf);
6439 "%s.server_side_agent", buf);
6447 "%s.ord_city", buf);
6450 "%s.paradropped", buf);
6453 "%s.transported_by", buf);
6456 "%s.carrying", buf);
6462 "%s.action_decision", buf);
6470 "%s.action_decision_tile_x", buf);
6472 "%s.action_decision_tile_y", buf);
6476 "%s.action_decision_tile_x", buf);
6478 "%s.action_decision_tile_y", buf);
6486 char orders_buf[
len + 1], dir_buf[
len + 1];
6487 char act_buf[
len + 1];
6488 int action_buf[
len];
6490 int sub_tgt_vec[
len];
6496 "%s.orders_index", buf);
6498 "%s.orders_repeat", buf);
6500 "%s.orders_vigilant", buf);
6502 for (j = 0; j <
len; j++) {
6507 sub_tgt_vec[j] = -1;
6528 orders_buf[
len] = dir_buf[
len] = act_buf[
len] =
'\0';
6535 "%s.action_vec", buf);
6538 for (j = last_order; j < longest_order; j++) {
6546 for (j = last_order; j < longest_order; j++) {
6551 "%s.sub_tgt_vec", buf);
6554 for (j = last_order; j < longest_order; j++) {
6575 for (j = 1; j < longest_order; j++) {
6581 for (j = 1; j < longest_order; j++) {
6587 for (j = 1; j < longest_order; j++) {
6615 loading->
file, 0,
"player%d.attribute_v2_block_length", plrno);
6618 log_sg(
"player%d.attribute_v2_block_length=%d too small", plrno,
6621 }
else if (MAX_ATTRIBUTE_BLOCK < plr->attribute_block.length) {
6622 log_sg(
"player%d.attribute_v2_block_length=%d too big (max %d)",
6629#ifndef FREECIV_NDEBUG
6630 size_t actual_length;
6635 "player%d.attribute_v2_block_length_quoted",
6639 "player%d.attribute_v2_block_parts", plrno),
6645 for (part_nr = 0; part_nr <
parts; part_nr++) {
6646 const char *current =
6648 "player%d.attribute_v2_block_data.part%d",
6651 log_sg(
"attribute_v2_block_parts=%d actual=%d",
parts, part_nr);
6654 log_debug(
"attribute_v2_block_length_quoted=%d"
6655 " have=" SIZE_T_PRINTF
" part=" SIZE_T_PRINTF,
6656 quoted_length, strlen(quoted), strlen(current));
6657 fc_assert(strlen(quoted) + strlen(current) <= quoted_length);
6658 strcat(quoted, current);
6661 "attribute_v2_block_length_quoted=%d"
6662 " actual=" SIZE_T_PRINTF,
6663 quoted_length, strlen(quoted));
6665#ifndef FREECIV_NDEBUG
6692#define PART_SIZE (3*256)
6693#define PART_ADJUST (3)
6697 int current_part_nr;
6700 char *quoted_at = strchr(quoted,
':');
6701 size_t bytes_left = strlen(quoted);
6702 size_t bytes_at_colon = 1 + (quoted_at - quoted);
6703 size_t bytes_adjust = bytes_at_colon %
PART_ADJUST;
6706 "player%d.attribute_v2_block_length", plrno);
6708 "player%d.attribute_v2_block_length_quoted", plrno);
6713 if ((bytes_left - bytes_adjust) >
PART_SIZE) {
6721 "player%d.attribute_v2_block_parts", plrno);
6724 size_t size_of_current_part =
PART_SIZE + bytes_adjust;
6727 memcpy(
part, quoted, size_of_current_part);
6728 part[size_of_current_part] =
'\0';
6730 "player%d.attribute_v2_block_data.part%d",
6732 bytes_left -= size_of_current_part;
6733 quoted_at = "ed[size_of_current_part];
6734 current_part_nr = 1;
6737 current_part_nr = 0;
6740 for (; current_part_nr <
parts; current_part_nr++) {
6741 size_t size_of_current_part =
MIN(bytes_left,
PART_SIZE);
6743 memcpy(
part, quoted_at, size_of_current_part);
6744 part[size_of_current_part] =
'\0';
6746 "player%d.attribute_v2_block_data.part%d",
6749 bytes_left -= size_of_current_part;
6750 quoted_at = "ed_at[size_of_current_part];
6768 "player%d.dc_total", plrno);
6770 bool someone_alive =
FALSE;
6777 if (pteam_member->is_alive) {
6778 someone_alive =
TRUE;
6783 if (!someone_alive) {
6789 if (-1 == total_ncities
6792 "game.save_private_map")) {
6807 if (NULL != pcity) {
6821 "player%d.map_t%04d", plrno);
6828 loading->
file,
"player%d.map_e%02d_%04d", plrno, j);
6855 const char *ptr = buffer;
6856 const char *ptr2 = buffer2;
6859 "Savegame corrupt - map line %d not found.", y);
6866 scanin(&ptr,
",", token,
sizeof(token));
6868 "Savegame corrupt - map size not correct.");
6869 if (strcmp(token,
"-") == 0) {
6873 "Savegame corrupt - got tile owner=%s in (%d, %d).",
6878 scanin(&ptr2,
",", token2,
sizeof(token2));
6880 "Savegame corrupt - map size not correct.");
6881 if (strcmp(token2,
"-") == 0) {
6885 "Savegame corrupt - got extras owner=%s in (%d, %d).",
6894 for (i = 0; i < 4; i++) {
6900 loading->
file,
"player%d.map_u%02d_%04d", plrno, i);
6905 loading->
file,
"player%d.map_u%02d_%04d", plrno, i);
6910 for (i = 0; i < total_ncities; i++) {
6913 fc_snprintf(buf,
sizeof(buf),
"player%d.dc%d", plrno, i);
6922 log_sg(
"Skipping seen city %d for player %d.", i, plrno);
6923 if (pdcity != NULL) {
6937 if (NULL != pcity) {
6955 const char *citystr)
6961 const char *stylename;
6962 enum capital_type cap;
6973 "%s invalid tile (%d,%d)", citystr,
nat_x,
nat_y);
6980 "%s has invalid owner (%d); skipping.", citystr,
id);
6986 "%s has invalid id (%d); skipping.", citystr,
id);
6989 "%s.size", citystr),
6993 "Invalid city size: %d; set to %d.",
size, city_size);
7001 "Invalid length of '%s.improvements' ("
7002 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
7006 "Undefined value '%c' within '%s.improvements'.",
7009 if (
str[i] ==
'1') {
7019 "%s.name", citystr);
7021 if (vname != NULL) {
7026 "%s.occupied", citystr);
7028 "%s.walls", citystr);
7030 "%s.happy", citystr);
7032 "%s.unhappy", citystr);
7034 "%s.style", citystr);
7035 if (stylename != NULL) {
7040 if (pdcity->
style < 0) {
7045 "%s.city_image", citystr);
7048 "%s.capital", citystr),
7051 if (capital_type_is_valid(cap)) {
7054 pdcity->
capital = CAPITAL_NOT;
7079 saving->
file,
"player%d.map_t%04d", plrno);
7094 if (plrtile == NULL || plrtile->
owner == NULL) {
7100 strcat(line, token);
7118 if (plrtile == NULL || plrtile->
extras_owner == NULL) {
7124 strcat(line, token);
7139 for (l = 0; l < 4; l++) {
7151 saving->
file,
"player%d.map_e%02d_%04d", plrno, j);
7155 for (i = 0; i < 4; i++) {
7160 saving->
file,
"player%d.map_u%02d_%04d", plrno, i);
7167 char impr_buf[
B_LAST + 1];
7170 fc_snprintf(buf,
sizeof(buf),
"player%d.dc%d", plrno, i);
7186 "%s.occupied", buf);
7205 "Invalid size of the improvement vector (%s.improvements: "
7206 SIZE_T_PRINTF
" < " SIZE_T_PRINTF
" ).",
7207 buf, strlen(impr_buf),
sizeof(impr_buf));
7209 if (pdcity->
name != NULL) {
7234 int *vlist_research;
7236 vlist_research = NULL;
7247 for (i = 0; i < count; i++) {
7249 "research.r%d.number", i),
7253 "Invalid research number %d in 'research.r%d.number'",
7257 "research.r%d.goal", i);
7260 "research.r%d.techs", i),
7264 "research.r%d.futuretech", i),
7268 "research.r%d.bulbs", i),
7272 "research.r%d.bulbs_before", i),
7275 "research.r%d.saved", i);
7277 "research.r%d.now", i);
7280 "research.r%d.got_tech", i),
7287 "research.r%d.got_tech_multi",
7293 "Invalid length of 'research.r%d.done' ("
7294 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
7298 "Undefined value '%c' within 'research.r%d.done'.",
7301 if (
str[j] ==
'1') {
7317 "research.r%d.vbs", i);
7319 for (tn = 0; tn < count_res; tn++) {
7322 if (padvance != NULL) {
7324 = vlist_research[tn];
7344 int *vlist_research;
7346 vlist_research = NULL;
7353 "research.r%d.number", i);
7355 i, presearch->tech_goal);
7357 "research.r%d.techs", i);
7359 "research.r%d.futuretech", i);
7361 "research.r%d.bulbs_before", i);
7365 vlist_research[j] = presearch->inventions[j].bulbs_researched_saved;
7369 "research.r%d.vbs", i);
7370 if (vlist_research) {
7371 free(vlist_research);
7375 i, presearch->researching_saved);
7377 "research.r%d.bulbs", i);
7379 i, presearch->researching);
7381 "research.r%d.got_tech", i);
7383 "research.r%d.got_tech_multi", i);
7389 == TECH_KNOWN ?
'1' :
'0');
7447 "treaty%d.plr0", tidx)) != NULL ;
7459 if (p0 == NULL || p1 == NULL) {
7460 log_error(
"Treaty between unknown players %s and %s", plr0, plr1);
7465 treaty_list_prepend(
treaties, ptreaty);
7468 "treaty%d.clause%d.type",
7469 tidx, cidx)) != NULL ;
7474 if (!clause_type_is_valid(
type)) {
7475 log_error(
"Invalid clause type \"%s\"", ct);
7477 struct player *pgiver = NULL;
7487 log_error(
"Clause giver %s is not participant of the treaty"
7488 "between %s and %s", plrx, plr0, plr1);
7491 if (pgiver != NULL) {
7495 "treaty%d.clause%d.value",
7506 "treaty%d.accept0", tidx);
7508 "treaty%d.accept1", tidx);
7525 fc_snprintf(tpath,
sizeof(tpath),
"treaty%d", tidx++);
7535 fc_snprintf(cpath,
sizeof(cpath),
"%s.clause%d", tpath, cidx++);
7601 int mapdef_count, i;
7613 log_verbose(
"Saved map image definitions: %d.", mapdef_count);
7615 if (0 >= mapdef_count) {
7619 for (i = 0; i < mapdef_count; i++) {
7624 log_verbose(
"[Mapimg %4d] Missing definition.", i);
7629 log_error(
"Invalid map image definition %4d: %s.", i, p);
7680 log_verbose(
"Max players lower than current players, fixing");
7689 log_sg(
"Removing %s unferried %s in %s at (%d, %d)",
7726 log_error(
"[city id: %d] Bad worker task %d.",
7727 pcity->id, ptask->act);
7728 worker_task_list_remove(pcity->task_reqs, ptask);
7742 log_error(
"[city id: %d] Unused worked tile at (%d, %d).",
7753 if (presearch->researching !=
A_UNSET
7757 != TECH_PREREQS_KNOWN))) {
7758 log_sg(
_(
"%s had invalid researching technology."),
7760 presearch->researching =
A_UNSET;
7762 if (presearch->tech_goal !=
A_UNSET
7768 log_sg(
_(
"%s had invalid technology goal."),
7770 presearch->tech_goal =
A_UNSET;
7775 if (presearch->techs_researched !=
techs) {
7777 _(
"%s had finished researches count wrong."),
7779 presearch->techs_researched =
techs;
7785 int unique_count[
U_LAST];
7787 memset(unique_count, 0,
sizeof(unique_count));
7795 log_sg(
_(
"%s has multiple units of type %s though it should be possible "
7796 "to have only one."),
7818 if (0 == strlen(
server.game_identifier)
7822 sizeof(
server.game_identifier));
bool achievement_player_has(const struct achievement *pach, const struct player *pplayer)
const char * achievement_rule_name(struct achievement *pach)
struct achievement * achievement_by_rule_name(const char *name)
#define achievements_iterate_end
#define achievements_iterate(_ach_)
static struct action * actions[MAX_NUM_ACTIONS]
const char * action_id_name_translation(action_id act_id)
struct action * action_by_rule_name(const char *name)
const char * action_id_rule_name(action_id act_id)
bool action_id_exists(const action_id act_id)
#define action_id_get_sub_target_kind(act_id)
#define action_id_get_activity(act_id)
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)
int ai_type_get_count(void)
#define CALL_FUNC_EACH_AI(_func,...)
#define CALL_PLR_AI_FUNC(_func, _player,...)
#define ai_type_iterate_end
#define ai_type_iterate(NAME_ai)
void ai_traits_init(struct player *pplayer)
void dbv_clr_all(struct dbv *pdbv)
#define BV_ISSET(bv, bit)
bool has_capabilities(const char *us, const char *them)
citizens citizens_nation_get(const struct city *pcity, const struct player_slot *pslot)
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)
const char * city_style_rule_name(const int style)
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 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)
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)
#define treaty_list_iterate(list, p)
#define treaty_list_iterate_end
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 clause_list_iterate_end
#define clause_list_iterate(clauselist, pclause)
#define MAX_NUM_PLAYER_SLOTS
#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_of_player(const struct player *pplayer)
const char * government_rule_name(const struct government *pgovern)
struct government * government_by_rule_name(const char *name)
#define governments_iterate(NAME_pgov)
#define governments_iterate_end
void idex_register_unit(struct world *iworld, struct unit *punit)
void idex_register_city(struct world *iworld, struct city *pcity)
struct impr_type * improvement_by_number(const Impr_type_id id)
bool great_wonder_is_destroyed(const struct impr_type *pimprove)
bool wonder_is_lost(const struct player *pplayer, const struct impr_type *pimprove)
const char * improvement_rule_name(const struct impr_type *pimprove)
Impr_type_id improvement_index(const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
struct impr_type * improvement_by_rule_name(const char *name)
Impr_type_id improvement_count(void)
#define improvement_iterate_end
#define improvement_iterate(_p)
void adv_city_free(struct city *pcity)
void adv_city_alloc(struct city *pcity)
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#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)
struct tile * startpos_tile(const struct startpos *psp)
bool startpos_allows_all(const struct startpos *psp)
const struct nation_hash * startpos_raw_nations(const struct startpos *psp)
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_is_excluding(const struct startpos *psp)
bool startpos_allow(struct startpos *psp, struct nation_type *pnation)
#define map_startpos_iterate(NAME_psp)
#define map_startpos_iterate_end
#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)
struct vision_site * map_get_player_city(const struct tile *ptile, const struct player *pplayer)
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_id2str(int id, char *str, size_t str_len)
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)
Multiplier_type_id multiplier_count(void)
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)
static struct nation_type * nations
const char * nation_plural_for_player(const struct player *pplayer)
#define nation_hash_iterate(nationhash, pnation)
#define nation_hash_iterate_end
#define NO_NATION_SELECTED
void event_cache_load(struct section_file *file, const char *section)
void event_cache_save(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)
int player_slot_index(const struct player_slot *pslot)
struct player * player_by_name(const char *name)
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
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
bool gives_shared_vision(const struct player *me, const struct player *them)
#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)
const char * player_delegation_get(const struct player *pplayer)
void fit_nationset_to_players(void)
#define shuffled_players_iterate_end
#define shuffled_players_iterate(NAME_pplayer)
bool fc_rand_is_init(void)
RANDOM_STATE fc_rand_state(void)
void fc_rand_set_state(RANDOM_STATE state)
struct section_file * secfile_load(const char *filename, bool allow_duplicates)
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,...)
bool entry_str_set_gt_marking(struct entry *pentry, bool gt_marking)
const char * secfile_lookup_str(const struct section_file *secfile, const char *path,...)
int * secfile_lookup_int_vec(const struct section_file *secfile, size_t *dim, 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_insert_int(secfile, value, path,...)
#define secfile_insert_enum(secfile, enumerator, specenum_type, path,...)
#define secfile_insert_int_vec(secfile, values, dim, path,...)
#define secfile_lookup_enum_default(secfile, defval, specenum_type, path,...)
#define secfile_insert_str_vec(secfile, strings, dim, path,...)
#define secfile_entry_ignore(_sfile_, _fmt_,...)
#define secfile_insert_str(secfile, string, path,...)
#define secfile_insert_bool(secfile, value, path,...)
#define secfile_replace_str(secfile, string, path,...)
struct history_report * history_report_get(void)
const char * universal_rule_name(const struct universal *psource)
const char * universal_type_rule_name(const struct universal *psource)
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 research_number(const struct research *presearch)
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,...)
void rgbcolor_save(struct section_file *file, const struct rgbcolor *prgbcolor, char *path,...)
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)
int current_compat_ver(void)
char bin2ascii_hex(int value, int halfbyte_wanted)
void sg_load_compat(struct loaddata *loading, enum sgf_version format_class)
int ascii_hex2bin(char ch, int halfbyte)
void sg_load_post_load_compat(struct loaddata *loading, enum sgf_version format_class)
#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,...)
void savegame3_save(struct section_file *sfile, const char *save_reason, bool scenario)
static void sg_save_history(struct savedata *saving)
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 worklist_save(struct section_file *file, const struct worklist *pwl, int max_length, const char *path,...)
static void sg_load_map_known(struct loaddata *loading)
static void sg_load_map_owner(struct loaddata *loading)
static void sg_extras_set(bv_extras *extras, char ch, struct extra_type **idx)
static char * quote_block(const void *const data, int length)
#define halfbyte_iterate_extras_end
#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)
static void sg_save_map_tiles_extras(struct savedata *saving)
static void sg_save_map_worked(struct savedata *saving)
static void sg_save_players(struct savedata *saving)
#define LOAD_MAP_CHAR(ch, ptile, SET_XY_CHAR, secfile, secpath,...)
static void sg_save_player_cities(struct savedata *saving, struct player *plr)
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 bool sg_load_player_unit(struct loaddata *loading, struct player *plr, struct unit *punit, int orders_max_length, const char *unitstr)
static struct savedata * savedata_new(struct section_file *file, const char *save_reason, bool scenario)
static void sg_load_savefile(struct loaddata *loading)
static enum unit_activity char2activity(char activity)
static void unit_ordering_calc(void)
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)
static char terrain2char(const struct terrain *pterrain)
static void sg_save_random(struct savedata *saving)
static void sg_save_map_startpos(struct savedata *saving)
static void sg_load_researches(struct loaddata *loading)
static void sg_load_map_worked(struct loaddata *loading)
#define SAVE_MAP_CHAR(ptile, GET_XY_CHAR, secfile, secpath,...)
static void sg_save_savefile_options(struct savedata *saving, const char *option)
static void sg_load_random(struct loaddata *loading)
static void sg_save_savefile(struct savedata *saving)
static void sg_load_player_units_transport(struct loaddata *loading, struct player *plr)
static void sg_load_history(struct loaddata *loading)
static void sg_save_treaties(struct savedata *saving)
static void sg_save_map_owner(struct savedata *saving)
static void sg_save_researches(struct savedata *saving)
static void savegame3_save_real(struct section_file *file, const char *save_reason, bool scenario)
static void sg_load_script(struct loaddata *loading)
static void sg_load_scenario(struct loaddata *loading)
static void sg_load_game(struct loaddata *loading)
static void savedata_destroy(struct savedata *saving)
static void sg_load_player_main(struct loaddata *loading, struct player *plr)
static char order2char(enum unit_orders order)
static void sg_load_treaties(struct loaddata *loading)
static void sg_save_scenario(struct savedata *saving)
static void sg_save_player_units(struct savedata *saving, struct player *plr)
static void sg_save_ruledata(struct savedata *saving)
static Tech_type_id technology_load(struct section_file *file, const char *path, int plrno)
static void sg_save_player_vision(struct savedata *saving, struct player *plr)
static enum direction8 char2dir(char dir)
static struct terrain * char2terrain(char ch)
static char sg_extras_get(bv_extras extras, struct extra_type *presource, const int *idx)
static void sg_save_sanitycheck(struct savedata *saving)
static void sg_load_mapimg(struct loaddata *loading)
static void sg_load_player_attributes(struct loaddata *loading, struct player *plr)
static void sg_save_player_attributes(struct savedata *saving, struct player *plr)
static void sg_load_ruledata(struct loaddata *loading)
static void sg_save_map(struct savedata *saving)
static void sg_load_player_vision(struct loaddata *loading, struct player *plr)
static void sg_save_map_tiles(struct savedata *saving)
static void worklist_load(struct section_file *file, int wlist_max_length, struct worklist *pwl, const char *path,...)
static void sg_save_mapimg(struct savedata *saving)
static const char savefile_options_default[]
static char dir2char(enum direction8 dir)
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)
static void technology_save(struct section_file *file, const char *path, int plrno, Tech_type_id tech)
static void sg_save_event_cache(struct savedata *saving)
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)
void savegame3_load(struct section_file *file)
static void sg_save_game(struct savedata *saving)
static void sg_save_player_main(struct savedata *saving, struct player *plr)
static void sg_save_script(struct savedata *saving)
static void sg_save_settings(struct savedata *saving)
static void sg_save_map_known(struct savedata *saving)
void script_server_state_save(struct section_file *file)
void script_server_state_load(struct section_file *file)
void settings_game_load(struct section_file *file, const char *section)
void settings_game_save(struct section_file *file, const char *section)
struct setting_list * level[OLEVELS_NUM]
const char * fileinfoname(const struct strvec *dirs, const char *filename)
bool str_to_int(const char *str, int *pint)
const struct strvec * get_scenario_dirs(void)
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)
struct specialist * specialist_by_number(const Specialist_type_id id)
Specialist_type_id specialist_index(const struct specialist *sp)
const char * specialist_rule_name(const struct specialist *sp)
Specialist_type_id specialist_count(void)
#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)
enum server_states server_state(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
struct unit_order * orders
struct city::@16 rally_point
int before_change_shields
citizens specialists[SP_MAX]
struct city::@17::@19 server
struct cm_parameter * cm_parameter
struct universal changed_from
struct unit_list * units_supported
struct civ_game::@30::@34::@36 save_options
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]
int additional_phase_seconds
struct section_file * luadata
struct packet_scenario_info scenario
struct timer * phase_timer
char * ruleset_capabilities
struct civ_map::@41::@43 server
enum map_generator generator
int minimal_surplus[O_LAST]
char title[REPORT_TITLESIZE]
char body[REPORT_BODYSIZE]
const char * secfile_options
struct loaddata::@111 act_dec
struct loaddata::@104 multiplier
struct loaddata::@110 action
struct loaddata::@112 ssa
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 version[MAX_LEN_NAME]
char alt_dir[MAX_LEN_NAME]
char description[MAX_LEN_CONTENT]
char datafile[MAX_LEN_NAME]
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 extra_type * resource
struct city_list * cities
struct player_ai ai_common
struct government * target_government
char username[MAX_LEN_NAME]
struct government * government
const struct ai_type * ai
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_researched_saved
int bulbs_researching_saved
struct research::research_invention inventions[A_ARRAY_SIZE]
Tech_type_id researching_saved
struct section_file * file
char secfile_options[512]
char metaserver_addr[256]
struct extra_type * placing
struct goods_type * goods
enum unit_activity activity
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 goods_type * carrying
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,...)
size_t fc_strlcpy(char *dest, const char *src, size_t n)
int fc_strcasecmp(const char *str0, const char *str1)
int cat_snprintf(char *str, size_t n, const char *format,...)
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_)
#define sz_strlcat(dest, src)
int team_index(const struct team *pteam)
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)
struct advance * advance_by_number(const Tech_type_id atype)
bool is_future_tech(Tech_type_id tech)
struct advance * valid_advance_by_number(const Tech_type_id id)
const char * advance_rule_name(const struct advance *padvance)
Tech_type_id advance_index(const struct advance *padvance)
struct advance * advance_by_rule_name(const char *name)
Tech_type_id advance_number(const struct advance *padvance)
#define advance_index_iterate_end
#define advance_iterate(_start, _p)
#define advance_iterate_end
#define advance_index_iterate(_start, _index)
struct terrain * terrain_by_rule_name(const char *name)
char terrain_identifier(const struct terrain *pterrain)
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
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 timer * timer_new(enum timer_timetype type, enum timer_use use)
void timer_destroy(struct timer *t)
void timer_start(struct timer *t)
void timer_stop(struct timer *t)
double timer_read_seconds(struct timer *t)
int city_num_trade_routes(const struct city *pcity)
struct goods_type * goods_by_rule_name(const char *name)
const char * goods_rule_name(struct goods_type *pgood)
struct goods_type * goods_by_number(Goods_type_id id)
#define trade_routes_iterate_end
#define trade_routes_iterate(c, proute)
const struct impr_type * building
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 player * unit_nationality(const struct unit *punit)
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
const char * freeciv_datafile_version(void)
void vision_site_size_set(struct vision_site *psite, citizens size)
citizens vision_site_size_get(const struct vision_site *psite)
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)
#define vision_site_owner(v)
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)