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);
1170 const char *path,
int plrno)
1172 char path_with_name[128];
1176 fc_snprintf(path_with_name,
sizeof(path_with_name),
1197 "%s: unknown technology \"%s\".", path_with_name,
name);
1208 char path_with_name[128];
1211 fc_snprintf(path_with_name,
sizeof(path_with_name),
1245 const char *terr_name;
1246 bool ruleset_datafile;
1247 bool current_ruleset_rejected;
1262 ruleset_datafile =
FALSE;
1264 ruleset_datafile =
TRUE;
1267 current_ruleset_rejected =
FALSE;
1269 const char *req_caps;
1272 ruleset_datafile)) {
1279 "scenario.ruleset_caps");
1286 log_normal(
_(
"Scenario requires ruleset capabilities: %s"), req_caps);
1290 log_error(
_(
"Current ruleset %s not compatible with the scenario %s."
1291 " Trying to switch to the ruleset specified by the"
1295 current_ruleset_rejected =
TRUE;
1300 || current_ruleset_rejected) {
1301 const char *
ruleset, *alt_dir;
1305 "savefile.rulesetdir");
1314 log_verbose(
"Savegame specified ruleset '%s'. Really loading '%s'.",
1319 "savefile.ruleset_alt_dir");
1324 _(
"Failed to load either of rulesets '%s' or '%s' "
1325 "needed for savegame."),
1329 _(
"Failed to load ruleset '%s' needed for savegame."),
1334 if (current_ruleset_rejected) {
1350 const struct strvec **path;
1351 const char *found = NULL;
1355 for (path = paths; found == NULL && *path != NULL; path++) {
1361 if (found == NULL) {
1368 if (secfile == NULL) {
1369 log_error(
_(
"Failed to load scenario luadata file %s.luadata"),
1382 "savefile.last_updated_as_year");
1387 "savefile.improvement_size");
1391 "savefile.improvement_vector");
1393 "Failed to load improvement order: %s",
1400 "savefile.technology_size");
1404 "savefile.technology_vector");
1406 "Failed to load technology order: %s",
1413 "savefile.activities_size");
1417 "savefile.activities_vector");
1419 "Failed to load activity order: %s",
1426 "savefile.trait_size");
1430 "savefile.trait_vector");
1432 "Failed to load trait order: %s",
1439 "savefile.extras_size");
1441 const char **modname;
1446 "savefile.extras_vector");
1448 "Failed to load extras order: %s",
1451 "Number of extras defined by the ruleset (= %d) are "
1452 "lower than the number in the savefile (= %d).",
1455 nmod = 4 * ((loading->
extra.
size + 3) / 4);
1457 for (j = 0; j < loading->
extra.
size; j++) {
1461 for (; j < nmod; j++) {
1469 "savefile.multipliers_size");
1471 const char **modname;
1475 "savefile.multipliers_vector");
1477 "Failed to load multipliers order: %s",
1486 log_verbose(
"Multiplier \"%s\" in savegame but not in ruleset, "
1487 "discarding", modname[j]);
1496 "savefile.specialists_size");
1498 const char **modname;
1503 "savefile.specialists_vector");
1505 "Failed to load specialists order: %s",
1508 "Number of specialists defined by the ruleset (= %d) are "
1509 "lower than the number in the savefile (= %d).",
1521 for (; j < nmod; j++) {
1531 for (j = 0; j < i; j++) {
1533 "savefile.diplstate_type_vector,%d", j);
1539 "savefile.action_size");
1542 "Failed to load action order: %s",
1546 const char **modname;
1550 "savefile.action_vector");
1561 log_sg(
"Unknown action \'%s\'", modname[j]);
1572 "savefile.action_decision_size");
1575 "Failed to load action decision order: %s",
1579 const char **modname;
1583 "savefile.action_decision_vector");
1589 loading->
act_dec.
order[j] = action_decision_by_name(modname[j],
1599 "savefile.server_side_agent_size");
1602 "Failed to load server side agent order: %s",
1606 const char **modname;
1610 "savefile.server_side_agent_list");
1615 for (j = 0; j < loading->
ssa.
size; j++) {
1616 loading->
ssa.
order[j] = server_side_agent_by_name(modname[j],
1628 for (j = 0; j < i; j++) {
1634 pterr->identifier_load =
'\0';
1639 "savefile.terrident%d.name", i)) != NULL) {
1642 if (pterr != NULL) {
1644 "savefile.terrident%d.identifier", i);
1648 log_error(
"Identifier for unknown terrain type %s.", terr_name);
1655 if (pterr != pterr2 && pterr->identifier_load !=
'\0') {
1656 sg_failure_ret((pterr->identifier_load != pterr2->identifier_load),
1657 "%s and %s share a saved identifier",
1707 "savefile.improvement_size");
1716 "savefile.improvement_vector");
1723 "savefile.technology_size");
1732 "savefile.technology_vector");
1737 "savefile.activities_size");
1738 if (ACTIVITY_LAST > 0) {
1739 const char **modname;
1744 modname =
fc_calloc(ACTIVITY_LAST,
sizeof(*modname));
1746 for (j = 0; j < ACTIVITY_LAST; j++) {
1747 modname[i++] = unit_activity_name(j);
1752 "savefile.activities_vector");
1758 "savefile.specialists_size");
1760 const char **modname;
1770 "savefile.specialists_vector");
1777 "savefile.trait_size");
1779 const char **modname;
1783 modname =
fc_calloc(TRAIT_COUNT,
sizeof(*modname));
1785 for (tr = trait_begin(), j = 0; tr != trait_end(); tr = trait_next(tr), j++) {
1786 modname[j] = trait_name(tr);
1790 "savefile.trait_vector");
1796 "savefile.extras_size");
1798 const char **modname;
1809 "savefile.extras_vector");
1815 "savefile.multipliers_size");
1817 const char **modname;
1827 "savefile.multipliers_vector");
1833 "savefile.diplstate_type_size");
1835 const char **modname;
1839 modname =
fc_calloc(DS_LAST,
sizeof(*modname));
1841 for (j = 0; j < DS_LAST; j++) {
1842 modname[i++] = diplstate_type_name(j);
1847 "savefile.diplstate_type_vector");
1853 "savefile.city_options_size");
1854 if (CITYO_LAST > 0) {
1855 const char **modname;
1859 modname =
fc_calloc(CITYO_LAST,
sizeof(*modname));
1861 for (j = 0; j < CITYO_LAST; j++) {
1862 modname[i++] = city_options_name(j);
1867 "savefile.city_options_vector");
1873 "savefile.action_size");
1875 const char **modname;
1887 "savefile.action_vector");
1893 "savefile.action_decision_size");
1894 if (ACT_DEC_COUNT > 0) {
1895 const char **modname;
1899 modname =
fc_calloc(ACT_DEC_COUNT,
sizeof(*modname));
1901 for (j = 0; j < ACT_DEC_COUNT; j++) {
1902 modname[i++] = action_decision_name(j);
1907 "savefile.action_decision_vector");
1913 "savefile.server_side_agent_size");
1914 if (SSA_COUNT > 0) {
1915 const char **modname;
1919 modname =
fc_calloc(SSA_COUNT,
sizeof(*modname));
1921 for (j = 0; j < SSA_COUNT; j++) {
1922 modname[i++] = server_side_agent_name(j);
1927 "savefile.server_side_agent_list");
1959 "savefile.options");
1979 "ruledata.government%d.name", i));
1985 "ruledata.government%d.changes", i);
2004 "game.server_state");
2016 "game.meta_patches");
2025 "game.meta_server"));
2052 log_sg(
"Invalid AI level \"%s\". "
2053 "Changed to \"%s\".",
level,
2071 "game.phase_mode_stored");
2094 "game.timeoutintinc");
2100 "game.timeoutincmult");
2103 "game.timeoutcounter");
2132 "game.global_advances");
2135 "Invalid length of 'game.global_advances' ("
2136 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
2140 "Undefined value '%c' within 'game.global_advances'.",
2142 if (
str[i] ==
'1') {
2146 if (padvance != NULL) {
2171 "ruledata.government%d", set_count++);
2176 "%s.changes", path);
2185 enum server_states srv_state;
2196 srv_state = S_S_INITIAL;
2201 "game.server_state");
2207 "game.phase_seconds");
2211 "game.meta_patches");
2224 "game.phase_mode_stored");
2233 "game.timeoutintinc");
2237 "game.timeoutincmult");
2239 "game.timeoutcounter");
2244 "game.year_0_hack");
2247 "game.globalwarming");
2251 "game.warminglevel");
2254 "game.nuclearwinter");
2258 "game.coolinglevel");
2265 "game.random_seed");
2272 global_advances[i] =
'\0';
2283#ifndef SAVE_DUMMY_TURN_CHANGE_TIME
2285 "game.last_turn_change_time");
2288 "game.last_turn_change_time");
2292 "game.save_players");
2294 if (srv_state != S_S_INITIAL) {
2299 ainames[i] = ait->name;
2331 for (i = 0; i < 8; i++) {
2334 sscanf(
str,
"%8x %8x %8x %8x %8x %8x %8x", &loading->
rstate.
v[7*i],
2372 for (i = 0; i < 8; i++) {
2376 "%8x %8x %8x %8x %8x %8x %8x", rstate.
v[7 * i],
2377 rstate.
v[7 * i + 1], rstate.
v[7 * i + 2],
2378 rstate.
v[7 * i + 3], rstate.
v[7 * i + 4],
2379 rstate.
v[7 * i + 5], rstate.
v[7 * i + 6]);
2433 sg_failure_ret(29099 <= game_version,
"Saved game is too old, at least "
2434 "version 2.90.99 required.");
2447 if (buf[0] !=
'\0') {
2452 "scenario.authors");
2453 if (buf[0] !=
'\0') {
2460 "scenario.description");
2461 if (buf[0] !=
'\0') {
2472 "scenario.startpos_nations");
2475 "scenario.prevent_new_cities");
2478 "scenario.lake_flooding");
2481 "scenario.handmade");
2484 "scenario.allow_ai_type_fallback");
2488 "scenario.ruleset_locked");
2491 "scenario.datafile");
2492 if (buf[0] !=
'\0') {
2499 "Invalid scenario definition (server state '%s' and "
2510 struct entry *mod_entry;
2516 game_version = MAJOR_VERSION * 1000000 + MINOR_VERSION * 10000 + PATCH_VERSION * 100;
2517#ifdef EMERGENCY_VERSION
2518 game_version += EMERGENCY_VERSION;
2536 "scenario.authors");
2543 "scenario.description");
2550 "scenario.startpos_nations");
2553 "scenario.prevent_new_cities");
2556 "scenario.lake_flooding");
2559 "scenario.handmade");
2563 "scenario.allow_ai_type_fallback");
2568 "scenario.datafile");
2571 "scenario.ruleset_locked");
2574 "scenario.ruleset_caps");
2690 "map.have_resources");
2735 const char *spec_sprite;
2744 if (NULL != ptile->spec_sprite) {
2745 ptile->spec_sprite =
fc_strdup(spec_sprite);
2747 if (label != NULL) {
2770 if (ptile->spec_sprite) {
2774 if (ptile->label != NULL) {
2792 loading->
file,
"map.e%02d_%04d", j);
2825 for (l = 0; l < 4; l++) {
2833 saving->
file,
"map.e%02d_%04d", j);
2846 const char SEPARATOR =
'#';
2847 const char *nation_names;
2850 int i, startpos_count;
2858 if (0 == startpos_count) {
2863 for (i = 0; i < startpos_count; i++) {
2866 "map.startpos%d.y", i)) {
2867 log_sg(
"Warning: Undefined coordinates for startpos %d", i);
2872 if (NULL == ptile) {
2873 log_error(
"Start position native coordinates (%d, %d) do not exist "
2879 "map.startpos%d.exclude", i);
2884 "map.startpos%d.nations", i);
2885 if (NULL != nation_names &&
'\0' != nation_names[0]) {
2886 const size_t size = strlen(nation_names) + 1;
2887 char buf[
size], *start, *end;
2889 memcpy(buf, nation_names,
size);
2890 for (start = buf - 1; NULL != start; start = end) {
2892 if ((end = strchr(start, SEPARATOR))) {
2913 log_verbose(
"Number of starts (%d) are lower than rules.max_players "
2914 "(%d), lowering rules.max_players.",
2931 const char SEPARATOR =
'#';
2942 "map.startpos_count");
2954 "map.startpos%d.exclude", i);
2961 nation_names[0] =
'\0';
2963 if (
'\0' == nation_names[0]) {
2965 sizeof(nation_names));
2972 "map.startpos%d.nations", i);
3000 "map.owner%04d", y);
3002 "map.source%04d", y);
3004 "map.eowner%04d", y);
3007 "map.placing%04d", y);
3010 "map.infra_turns%04d", y);
3011 const char *ptr1 = buffer1;
3012 const char *ptr2 = buffer2;
3013 const char *ptr3 = buffer3;
3014 const char *ptr_placing = buffer_placing;
3015 const char *ptr_turns = buffer_turns;
3028 struct player *eowner = NULL;
3033 scanin(&ptr1,
",", token1,
sizeof(token1));
3035 "Map size not correct (map.owner%d).", y);
3036 if (strcmp(token1,
"-") == 0) {
3040 "Got map owner %s in (%d, %d).", token1, x, y);
3044 scanin(&ptr2,
",", token2,
sizeof(token2));
3046 "Map size not correct (map.source%d).", y);
3047 if (strcmp(token2,
"-") == 0) {
3051 "Got map source %s in (%d, %d).", token2, x, y);
3055 scanin(&ptr3,
",", token3,
sizeof(token3));
3057 "Map size not correct (map.eowner%d).", y);
3058 if (strcmp(token3,
"-") == 0) {
3062 "Got base owner %s in (%d, %d).", token3, x, y);
3066 if (ptr_placing != NULL) {
3067 scanin(&ptr_placing,
",", token_placing,
sizeof(token_placing));
3069 "Map size not correct (map.placing%d).", y);
3070 if (strcmp(token_placing,
"-") == 0) {
3074 "Got placing extra %s in (%d, %d).", token_placing, x, y);
3081 if (ptr_turns != NULL) {
3082 scanin(&ptr_turns,
",", token_turns,
sizeof(token_turns));
3084 "Map size not correct (map.infra_turns%d).", y);
3086 "Got infra_turns %s in (%d, %d).", token_turns, x, y);
3131 strcat(line, token);
3152 strcat(line, token);
3174 strcat(line, token);
3196 strcat(line, token);
3218 strcat(line, token);
3238 "City worked map not loaded!");
3246 const char *ptr = buffer;
3249 "Savegame corrupt - map line %d not found.", y);
3255 scanin(&ptr,
",", token,
sizeof(token));
3257 "Savegame corrupt - map size not correct.");
3258 if (strcmp(token,
"-") == 0) {
3262 "Savegame corrupt - got tile worked by city "
3263 "id=%s in (%d, %d).", token, x, y);
3296 if (pcity == NULL) {
3301 strcat(line, token);
3325 "game.save_known")) {
3329 for (l = 0; l <
lines; l++) {
3330 for (j = 0; j < 8; j++) {
3331 for (i = 0; i < 4; i++) {
3338 loading->
file,
"map.k%02d_%04d", l * 8 + j);
3395 |= (1u << (p % 32));
3400 for (l = 0; l <
lines; l++) {
3401 for (j = 0; j < 8; j++) {
3402 for (i = 0; i < 4; i++) {
3409 saving->
file,
"map.k%02d_%04d", l * 8 + j);
3436 bool shuffle_loaded =
TRUE;
3449 "players.destroyed_wonders");
3452 "Invalid length for 'players.destroyed_wonders' ("
3453 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
")",
3457 "Undefined value '%c' within "
3458 "'players.destroyed_wonders'.",
str[k]);
3460 if (
str[k] ==
'1') {
3472 "players.identity_number_used");
3499 log_sg(
"Game has started, yet player %d has no color defined.",
3503 log_verbose(
"No color defined for player %d.", pslot_id);
3538 "player%d.multiplier%d.val",
3544 log_verbose(
"Player %d had illegal value for multiplier \"%s\": "
3545 "was %d, clamped to %d", pslot_id,
3553 "player%d.multiplier%d.target",
3559 log_verbose(
"Player %d had illegal value for multiplier_target "
3560 " \"%s\": was %d, clamped to %d", pslot_id,
3567 "player%d.multiplier%d.changed",
3575 "player%d.border_vision",
3582 "(%d) from the loaded game does not match the number of "
3594 "Invalid team definition for player %s (nb %d).",
3610 "players.shuffled_player_%d", 0) >= 0) {
3613 int shuffled_players[
slots];
3614 bool shuffled_player_set[
slots];
3616 for (i = 0; i <
slots; i++) {
3618 shuffled_player_set[i] =
FALSE;
3621 shuffled_players[i] = -1;
3625 for (i = 0; i < plrcount; i++) {
3628 "players.shuffled_player_%d", i);
3630 if (shuffle == -1) {
3631 log_sg(
"Missing player shuffle information (index %d) "
3632 "- reshuffle player list!", i);
3633 shuffle_loaded =
FALSE;
3635 }
else if (shuffled_player_set[shuffle]) {
3636 log_sg(
"Player shuffle %d used two times "
3637 "- reshuffle player list!", shuffle);
3638 shuffle_loaded =
FALSE;
3642 shuffled_player_set[shuffle] =
TRUE;
3645 shuffled_players[i] = shuffle;
3648 if (shuffle_loaded) {
3650 int shuffle_index = plrcount;
3652 for (i = 0; i <
slots; i++) {
3653 if (!shuffled_player_set[i]) {
3654 shuffled_players[shuffle_index++] = i;
3659 "Invalid player shuffle data!");
3667 log_debug(
"[load shuffle] id: %3d => slot: %3d | slot %3d: %s",
3668 plrid, shuffled_players[plrid], plrid,
3669 shuffled_player_set[plrid] ?
"is used" :
"-");
3678 if (!shuffle_loaded) {
3708 if (
is_ai(pplayer)) {
3709 log_normal(
_(
"%s has been added as %s level AI-controlled player "
3711 ai_level_translated_name(pplayer->ai_common.skill_level),
3714 log_normal(
_(
"%s has been added as human player."),
3737 log_sg(
_(
"%s had invalid nation; changing to %s."),
3753 log_sg(
"Illegal alliance structure detected: "
3754 "%s alliance to %s reduced to peace treaty.",
3768 pcity->server.illness
3770 &(pcity->illness_trade), NULL);
3796 BV_CLR_ALL(pplayer->server.really_gives_vision);
3806 "player%d.diplstate%d.gives_shared_vision", plr1, plr2)) {
3818 if (pplayer1 != pplayer2
3822 _(
"%s did not give shared vision to team member %s."),
3828 _(
"%s did not give shared vision to team member %s."),
3848 log_sg(
"%s doing illegal activity in savegame!",
3850 log_sg(
"Activity: %s, Target: %s, Tile: (%d, %d), Terrain: %s",
3894 char destroyed[
B_LAST+1];
3906 "players.destroyed_wonders");
3910 "players.identity_number_used");
3917 "players.shuffled_player_%d", i);
3946 const char *barb_str;
3959 "player%d.username", plrno));
3961 "player%d.unassigned_user", plrno),
3965 "player%d.orig_username", plrno));
3968 "player%d.ranked_username",
3971 "player%d.unassigned_ranked", plrno),
3974 "player%d.delegation_username",
3984 for (i = 0; i < nval; i++) {
3985 const char *sval = slist[i];
3986 enum plr_flag_id fid = plr_flag_id_by_name(sval,
fc_strcasecmp);
3988 sg_failure_ret(plr_flag_id_is_valid(fid),
"Invalid player flag \"%s\".", sval);
3997 if (plr->
nation != NULL) {
4005 sg_failure_ret(gov != NULL,
"Player%d: unsupported government \"%s\".",
4011 "player%d.target_government_name", plrno);
4019 "player%d.revolution_finishes", plrno);
4023 "player%d.got_first_city", plrno),
4035 fc_snprintf(buf,
sizeof(buf),
"player%d.diplstate%d", plrno, i);
4039 diplstate_type,
"%s.current", buf);
4042 diplstate_type,
"%s.closest", buf);
4045 "%s.first_contact_turn", buf);
4050 "%s.has_reason_to_cancel", buf);
4053 "%s.contact_turns_left", buf);
4067 fc_snprintf(buf,
sizeof(buf),
"player%d.ai%d", plrno,
4076 "player%d.adv.wonder_city",
4088 "player%d.ai.level", plrno);
4097 log_sg(
"Player%d: Invalid AI level \"%s\". "
4098 "Changed to \"%s\".", plrno,
level,
4104 "player%d.ai.barb_type", plrno);
4108 log_sg(
"Player%d: Invalid barbarian type \"%s\". "
4109 "Changed to \"None\".", plrno, barb_str);
4130 if (style == NULL) {
4132 log_sg(
"Player%d: unsupported city_style_name \"%s\". "
4139 "player%d.idle_turns", plrno),
4142 if (!strcmp(
"male", kind)) {
4148 "player%d.is_alive", plrno),
4151 "player%d.turns_alive", plrno),
4154 "player%d.last_war", plrno),
4157 "player%d.phase_done", plrno);
4159 "player%d.gold", plrno),
4162 "player%d.rates.tax", plrno),
4165 "player%d.rates.science", plrno),
4168 "player%d.rates.luxury", plrno),
4171 "player%d.infrapts",
4175 "player%d.research.bulbs_last_turn", plrno);
4179 for (i = 0; i < loading->
trait.
size; i++) {
4182 if (trait_is_valid(tr)) {
4191 "player%d.trait%d.mod", plrno, i),
4203 "player%d.achievement_count", plrno);
4206 for (i = 0; i < count; i++) {
4212 "player%d.achievement%d.name", plrno, i);
4216 "Unknown achievement \"%s\".",
name);
4219 "player%d.achievement%d.first",
4224 "Multiple players listed as first to get achievement \"%s\".",
4239 "score%d.happy", plrno);
4242 "score%d.content", plrno);
4245 "score%d.unhappy", plrno);
4248 "score%d.angry", plrno);
4259 "score%d.specialists%d", plrno, i);
4264 "score%d.wonders", plrno);
4267 "score%d.techs", plrno);
4270 "score%d.techout", plrno);
4273 "score%d.landarea", plrno);
4276 "score%d.settledarea", plrno);
4279 "score%d.population", plrno);
4282 "score%d.cities", plrno);
4285 "score%d.units", plrno);
4288 "score%d.pollution", plrno);
4291 "score%d.literacy", plrno);
4294 "score%d.bnp", plrno);
4297 "score%d.mfg", plrno);
4300 "score%d.spaceship", plrno);
4303 "score%d.units_built", plrno);
4306 "score%d.units_killed", plrno);
4309 "score%d.units_lost", plrno);
4312 "score%d.culture", plrno);
4315 "score%d.total", plrno);
4324 fc_snprintf(prefix,
sizeof(prefix),
"player%d.spaceship", plrno);
4328 "%s.state", prefix),
4334 "%s.structurals", prefix),
4337 "%s.components", prefix),
4340 "%s.modules", prefix),
4346 "%s.propulsion", prefix),
4349 "%s.habitation", prefix),
4352 "%s.life_support", prefix),
4355 "%s.solar_panels", prefix),
4362 "Undefined value '%c' within '%s.structure'.", st[i],
4365 if (!(st[i] ==
'0')) {
4371 "%s.launch_year", prefix),
4385 "Invalid length for 'player%d.lost_wonders' ("
4386 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
")",
4390 "Undefined value '%c' within "
4391 "'player%d.lost_wonders'.", plrno,
str[k]);
4393 if (
str[k] ==
'1') {
4417 const char *flag_names[PLRF_COUNT];
4424 for (i = 0; i < PLRF_COUNT; i++) {
4426 flag_names[set_count++] = plr_flag_id_name(i);
4431 "player%d.flags", plrno);
4434 "player%d.ai_type", plrno);
4436 "player%d.name", plrno);
4438 "player%d.username", plrno);
4440 "player%d.unassigned_user", plrno);
4441 if (plr->
rgb != NULL) {
4446 log_sg(
"Game has started, yet player %d has no color defined.", plrno);
4450 "player%d.ranked_username", plrno);
4452 "player%d.unassigned_ranked", plrno);
4454 "player%d.orig_username", plrno);
4458 "player%d.delegation_username", plrno);
4460 "player%d.nation", plrno);
4462 "player%d.team_no", plrno);
4466 "player%d.government_name", plrno);
4471 "player%d.target_government_name", plrno);
4475 "player%d.style_by_name", plrno);
4478 "player%d.idle_turns", plrno);
4481 "player%d.kind", plrno);
4484 "player%d.kind", plrno);
4487 "player%d.is_alive", plrno);
4489 "player%d.turns_alive", plrno);
4491 "player%d.last_war", plrno);
4493 "player%d.phase_done", plrno);
4502 fc_snprintf(buf,
sizeof(buf),
"player%d.diplstate%d", plrno, i);
4505 diplstate_type,
"%s.current", buf);
4507 diplstate_type,
"%s.closest", buf);
4509 "%s.first_contact_turn", buf);
4511 "%s.turns_left", buf);
4513 "%s.has_reason_to_cancel", buf);
4515 "%s.contact_turns_left", buf);
4519 "%s.gives_shared_vision", buf);
4526 "player%d.ai%d.love", plrno, i);
4531 "player%d.adv.wonder_city", plrno);
4538 for (k = 0; k < i; k++) {
4540 "player%d.multiplier%d.val", plrno, k);
4542 "player%d.multiplier%d.target", plrno, k);
4544 "player%d.multiplier%d.changed", plrno, k);
4548 "player%d.ai.level", plrno);
4550 "player%d.ai.barb_type", plrno);
4552 "player%d.gold", plrno);
4554 "player%d.rates.tax", plrno);
4556 "player%d.rates.science", plrno);
4558 "player%d.rates.luxury", plrno);
4560 "player%d.infrapts", plrno);
4562 "player%d.research.bulbs_last_turn", plrno);
4569 for (tr = trait_begin(), j = 0; tr != trait_end(); tr = trait_next(tr), j++) {
4571 "player%d.trait%d.val", plrno, j);
4573 "player%d.trait%d.mod", plrno, j);
4584 "player%d.achievement%d.name", plrno, j);
4585 if (pach->first == plr) {
4587 "player%d.achievement%d.first", plrno, j);
4590 "player%d.achievement%d.first", plrno, j);
4598 "player%d.achievement_count", plrno);
4602 "player%d.got_first_city", plrno);
4604 "player%d.revolution_finishes", plrno);
4608 "score%d.happy", plrno);
4610 "score%d.content", plrno);
4612 "score%d.unhappy", plrno);
4614 "score%d.angry", plrno);
4617 "score%d.specialists%d", plrno, sp);
4620 "score%d.wonders", plrno);
4622 "score%d.techs", plrno);
4624 "score%d.techout", plrno);
4626 "score%d.landarea", plrno);
4628 "score%d.settledarea", plrno);
4630 "score%d.population", plrno);
4632 "score%d.cities", plrno);
4634 "score%d.units", plrno);
4636 "score%d.pollution", plrno);
4638 "score%d.literacy", plrno);
4640 "score%d.bnp", plrno);
4642 "score%d.mfg", plrno);
4644 "score%d.spaceship", plrno);
4646 "score%d.units_built", plrno);
4648 "score%d.units_killed", plrno);
4650 "score%d.units_lost", plrno);
4652 "score%d.culture", plrno);
4654 "score%d.total", plrno);
4664 fc_snprintf(buf,
sizeof(buf),
"player%d.spaceship", plrno);
4667 "%s.structurals", buf);
4669 "%s.components", buf);
4676 "%s.life_support", buf);
4678 "%s.solar_panels", buf);
4687 "%s.launch_year", buf);
4704 "player%d.lost_wonders", plrno);
4708 "player%d.history", plrno);
4710 "player%d.hut_count", plrno);
4713 "player%d.border_vision", plrno);
4724 int wlist_max_length = 0;
4730 "player%d.ncities", plrno),
4733 if (!plr->
is_alive && ncities > 0) {
4734 log_sg(
"'player%d.ncities' = %d for dead player!", plrno, ncities);
4744 for (i = 0; i < ncities; i++) {
4746 "player%d.c%d.wl_length",
4749 wlist_max_length =
MAX(wlist_max_length, wl_length);
4753 for (i = 0; i < ncities; i++) {
4757 fc_snprintf(buf,
sizeof(buf),
"player%d.c%d", plrno, i);
4784 city_list_append(plr->
cities, pcity);
4787 tasks_handled =
FALSE;
4788 for (i = 0; !tasks_handled; i++) {
4790 struct city *pcity = NULL;
4795 if (city_id != -1) {
4799 if (pcity != NULL) {
4813 "Unknown workertask activity %s",
str);
4817 if (strcmp(
"-",
str)) {
4821 "Unknown workertask target %s",
str);
4825 if (ptask->
act == ACTIVITY_IRRIGATE) {
4826 ptask->
act = ACTIVITY_CULTIVATE;
4827 }
else if (ptask->
act == ACTIVITY_MINE) {
4828 ptask->
act = ACTIVITY_MINE;
4833 "player%d.task%d.want", plrno, i);
4835 worker_task_list_append(pcity->
task_reqs, ptask);
4837 tasks_handled =
TRUE;
4846 struct city *pcity,
const char *citystr,
4847 int wlist_max_length)
4850 const char *kind, *
name, *
str;
4851 int id, i, repair, sp_count = 0, workers = 0, value;
4854 const char *stylename;
4865 "%s has invalid center tile (%d, %d)",
4868 "%s duplicates city (%d, %d)", citystr,
nat_x,
nat_y);
4872 "%s.name", citystr));
4878 "%s.original", citystr);
4888 "Invalid city size: %d, set to %d", value,
size);
4901 for (i = 0; partner != 0; i++) {
4904 const char *good_str;
4908 trade_route_list_append(pcity->
routes, proute);
4913 "No traderoute direction found for %s", citystr);
4916 "Illegal route direction %s",
dir);
4919 "No good found for %s", citystr);
4922 "Illegal good %s", good_str);
4926 "%s.traderoute%d", citystr, i + 1);
4936 "%s.food_stock", citystr),
4939 "%s.shield_stock", citystr),
4954 "%s.anarchy", citystr),
4962 "%s.turn_founded", citystr),
4970 "%s.turn_last_built", citystr),
4979 "%s.currently_building: unknown \"%s\" \"%s\".",
4980 citystr, kind,
name);
4983 "%s.current_want", citystr);
4996 "%s.changed_from: unknown \"%s\" \"%s\".",
4997 citystr, kind,
name);
5001 "%s.before_change_shields", citystr);
5004 "%s.caravan_shields", citystr);
5007 "%s.disbanded_shields", citystr);
5010 "%s.last_turns_shield_surplus",
5014 "%s.style", citystr);
5015 if (stylename != NULL) {
5020 if (pcity->
style < 0) {
5035 "Invalid length of '%s.improvements' ("
5036 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
5040 "Undefined value '%c' within '%s.improvements'.",
5043 if (
str[i] ==
'1') {
5054 "No worked tiles map defined.");
5069 log_sg(
"[%s] '%s' (%d, %d) has worker outside current radius "
5090 if (NULL != pwork) {
5091 log_sg(
"[%s] city center of '%s' (%d,%d) [%d] is worked by '%s' "
5100 log_sg(
"[%s] city center of '%s' (%d,%d) [%d] is empty; repairing",
5112 log_sg(
"[%s] size mismatch for '%s' (%d,%d): size [%d] != "
5113 "(workers [%d] - free worked tiles [%d]) + specialists [%d]",
5126 for (i = 0; i < CITYO_LAST; i++) {
5136 "%s.rally_point_length", citystr);
5141 const char *rally_orders, *rally_dirs, *rally_activities;
5147 "%s.rally_point_persistent", citystr);
5150 "%s.rally_point_vigilant", citystr);
5154 "%s.rally_point_orders", citystr);
5157 "%s.rally_point_dirs", citystr);
5160 "%s.rally_point_activities", citystr);
5162 for (i = 0; i <
len; i++) {
5165 if (rally_orders[i] ==
'\0' || rally_dirs[i] ==
'\0'
5166 || rally_activities[i] ==
'\0') {
5167 log_sg(
"Invalid rally point.");
5178 "%s.rally_point_action_vec,%d",
5181 if (unconverted >= 0 && unconverted < loading->
action.size) {
5186 log_sg(
"Invalid action id in order for city rally point %d",
5195 "%s.rally_point_tgt_vec,%d",
5199 "%s.rally_point_sub_tgt_vec,%d",
5218 "%s.rally_point_tgt_vec", citystr);
5220 "%s.rally_point_sub_tgt_vec", citystr);
5227 "%s.cma_enabled", citystr);
5231 for (i = 0; i <
O_LAST; i++) {
5233 loading->
file, 0,
"%s.cma_minimal_surplus,%d", citystr, i);
5235 loading->
file, 0,
"%s.cma_factor,%d", citystr, i);
5239 loading->
file,
FALSE,
"%s.max_growth", citystr);
5241 loading->
file,
FALSE,
"%s.require_happy", citystr);
5243 loading->
file,
FALSE,
"%s.allow_disorder", citystr);
5245 loading->
file,
FALSE,
"%s.allow_specialists", citystr);
5247 loading->
file, 0,
"%s.happy_factor", citystr);
5252 for (i = 0; i <
O_LAST; i++) {
5254 "%s.cma_minimal_surplus,%d", citystr, i);
5256 "%s.cma_factor,%d", citystr, i);
5283 const char *citystr)
5293 "%s.citizen%d", citystr,
5296 log_sg(
"Citizens of an invalid nation for %s (player slot %d)!",
5303 "Invalid value for citizens of player %d in %s: %d.",
5316 log_sg(
"City size and number of citizens does not match in %s "
5331 int wlist_max_length = 0, rally_point_max_length = 0, routes_max = 0;
5340 "player%d.ncities", plrno);
5358 if (pcity->worklist.length > wlist_max_length) {
5359 wlist_max_length = pcity->worklist.length;
5362 if (pcity->rally_point.length > rally_point_max_length) {
5363 rally_point_max_length = pcity->rally_point.length;
5367 if (routes > routes_max) {
5368 routes_max = routes;
5384 char impr_buf[
B_LAST + 1];
5388 fc_snprintf(buf,
sizeof(buf),
"player%d.c%d", plrno, i);
5397 if (pcity->original != NULL) {
5399 "%s.original", buf);
5416 "%s.route_direction%d", buf, j);
5418 "%s.route_good%d", buf, j);
5423 for (; j < routes_max; j++) {
5426 "%s.route_direction%d", buf, j);
5428 "%s.route_good%d", buf, j);
5453 "%s.turn_last_built", buf);
5459 "%s.currently_building_kind", buf);
5461 "%s.currently_building_name", buf);
5463 if (pcity->production.kind == VUT_IMPROVEMENT) {
5467 "%s.current_want", buf);
5470 "%s.current_want", buf);
5474 "%s.changed_from_kind", buf);
5476 "%s.changed_from_name", buf);
5479 "%s.before_change_shields", buf);
5481 "%s.caravan_shields", buf);
5483 "%s.disbanded_shields", buf);
5485 "%s.last_turns_shield_surplus", buf);
5493 "player%d.c%d.city_radius_sq", plrno, i);
5507 "Invalid size of the improvement vector (%s.improvements: "
5508 SIZE_T_PRINTF
" < " SIZE_T_PRINTF
").", buf,
5509 strlen(impr_buf),
sizeof(impr_buf));
5515 for (j = 0; j < CITYO_LAST; j++) {
5517 "%s.option%d", buf, j);
5534 "%s.rally_point_length", buf);
5535 if (pcity->rally_point.length) {
5536 int len = pcity->rally_point.length;
5537 char orders[
len + 1], dirs[
len + 1], activities[
len + 1];
5540 int sub_targets[
len];
5543 "%s.rally_point_persistent", buf);
5545 "%s.rally_point_vigilant", buf);
5547 for (j = 0; j <
len; j++) {
5548 orders[j] =
order2char(pcity->rally_point.orders[j].order);
5550 activities[j] =
'?';
5554 switch (pcity->rally_point.orders[j].order) {
5557 dirs[j] =
dir2char(pcity->rally_point.orders[j].dir);
5560 sub_targets[j] = pcity->rally_point.orders[j].sub_target;
5565 actions[j] = pcity->rally_point.orders[j].action;
5566 targets[j] = pcity->rally_point.orders[j].target;
5567 sub_targets[j] = pcity->rally_point.orders[j].sub_target;
5574 orders[
len] = dirs[
len] = activities[
len] =
'\0';
5579 "%s.rally_point_activities", buf);
5582 "%s.rally_point_action_vec", buf);
5585 for (j =
len; j < rally_point_max_length; j++) {
5591 "%s.rally_point_tgt_vec", buf);
5594 for (j =
len; j < rally_point_max_length; j++) {
5596 "%s.rally_point_tgt_vec,%d", buf, j);
5600 "%s.rally_point_sub_tgt_vec", buf);
5603 for (j =
len; j < rally_point_max_length; j++) {
5626 for (j = 1; j < rally_point_max_length; j++) {
5634 for (j = 1; j < rally_point_max_length; j++) {
5636 "%s.rally_point_tgt_vec,%d", buf, j);
5642 for (j = 1; j < rally_point_max_length; j++) {
5649 "%s.cma_enabled", buf);
5650 if (pcity->cm_parameter) {
5652 pcity->cm_parameter->minimal_surplus,
O_LAST,
5653 "%s.cma_minimal_surplus", buf);
5655 pcity->cm_parameter->factor,
O_LAST,
5656 "%s.cma_factor", buf);
5658 "%s.max_growth", buf);
5660 "%s.require_happy", buf);
5662 "%s.allow_disorder", buf);
5664 pcity->cm_parameter->allow_specialists,
5665 "%s.allow_specialists", buf);
5667 "%s.happy_factor", buf);
5671 memset(zeros, 0,
sizeof(zeros));
5673 "%s.cma_minimal_surplus", buf);
5675 "%s.cma_factor", buf);
5697 "player%d.task%d.activity",
5699 if (ptask->tgt != NULL) {
5701 "player%d.task%d.target",
5705 "player%d.task%d.target",
5722 size_t orders_max_length;
5728 "player%d.nunits", plrno),
5730 if (!plr->
is_alive && nunits > 0) {
5731 log_sg(
"'player%d.nunits' = %d for dead player!", plrno, nunits);
5735 orders_max_length = 0;
5737 for (i = 0; i < nunits; i++) {
5739 "player%d.u%d.orders_length",
5742 orders_max_length =
MAX(orders_max_length, ol_length);
5745 for (i = 0; i < nunits; i++) {
5753 fc_snprintf(buf,
sizeof(buf),
"player%d.u%d", plrno, i);
5795 int orders_max_length,
5796 const char *unitstr)
5798 enum unit_activity activity;
5804 const char *facing_str;
5823 "%s.facing", unitstr);
5824 if (facing_str[0] !=
'x') {
5828 enum direction8 facing =
char2dir(facing_str[0]);
5830 if (direction8_is_valid(facing)) {
5833 log_error(
"Illegal unit orientation '%s'", facing_str);
5841 "%s.nationality", unitstr);
5849 "%s.homecity", unitstr),
FALSE,
5852 "%s.moves", unitstr),
FALSE,
5855 "%s.fuel", unitstr),
FALSE,
5858 "%s.activity", unitstr),
FALSE,
5865 "%s.born", unitstr);
5868 "%s.activity_tgt", unitstr);
5870 if (extra_id != -2) {
5871 if (extra_id >= 0 && extra_id < loading->extra.size) {
5874 }
else if (activity == ACTIVITY_IRRIGATE) {
5884 }
else if (activity == ACTIVITY_MINE) {
5902 "%s.activity_count", unitstr),
FALSE,
5907 "%s.changed_from", unitstr);
5910 "%s.changed_from_tgt", unitstr),
FALSE,
5913 if (extra_id >= 0 && extra_id < loading->extra.size) {
5921 "%s.changed_from_count", unitstr);
5928 if (activity == ACTIVITY_SENTRY) {
5948 "%s.done_moving", unitstr);
5951 "%s.battlegroup", unitstr);
5954 "%s.go", unitstr)) {
5958 "%s.goto_x", unitstr),
FALSE,
5961 "%s.goto_y", unitstr),
FALSE,
5979 "%s.server_side_agent",
5981 if (unconverted >= 0 && unconverted < loading->ssa.size) {
5985 log_sg(
"Invalid server side agent %d for unit %d",
5992 "%s.hp", unitstr),
FALSE,
6003 "%s.paradropped", unitstr);
6005 if (
str[0] !=
'\0') {
6023 "%s.action_decision", unitstr),
6026 if (unconverted >= 0 && unconverted < loading->act_dec.size) {
6031 log_sg(
"Invalid action decision want for unit %d",
punit->
id);
6041 "%s.action_decision_tile_x", unitstr)
6043 "%s.action_decision_tile_y", unitstr)) {
6062 "%s.orders_length", unitstr);
6065 const char *orders_unitstr, *dir_unitstr, *act_unitstr;
6072 "%s.orders_index", unitstr);
6075 "%s.orders_repeat", unitstr);
6078 "%s.orders_vigilant", unitstr);
6082 "%s.orders_list", unitstr);
6085 "%s.dir_list", unitstr);
6088 "%s.activity_list", unitstr);
6092 for (j = 0; j <
len; j++) {
6094 bool action_wants_extra =
FALSE;
6097 if (orders_unitstr[j] ==
'\0' || dir_unitstr[j] ==
'\0'
6098 || act_unitstr[j] ==
'\0') {
6099 log_sg(
"Invalid unit orders.");
6111 if (unconverted >= 0 && unconverted < loading->
action.size) {
6116 log_sg(
"Invalid action id in order for unit %d",
punit->
id);
6125 && !direction8_is_valid(
order->dir))
6129 &&
order->activity == ACTIVITY_LAST)) {
6141 "%s.sub_tgt_vec,%d",
6151 log_sg(
"Cannot find building %d for %s to %s",
6156 order->sub_target = order_sub_tgt;
6161 if (order_sub_tgt ==
A_NONE
6165 log_sg(
"Cannot find tech %d for %s to steal",
6169 order->sub_target = order_sub_tgt;
6173 case ASTK_EXTRA_NOT_THERE:
6175 action_wants_extra =
TRUE;
6180 "Specified sub target for action %d unsupported.",
6186 "Bad action action %d.",
6194 enum unit_activity act;
6196 if (order_sub_tgt < 0 || order_sub_tgt >= loading->
extra.
size) {
6198 log_sg(
"Cannot find extra %d for %s to build",
6204 order->sub_target = order_sub_tgt;
6208 if (action_wants_extra) {
6211 act =
order->activity;
6214 if (unit_activity_is_valid(act)
6224 if (order_sub_tgt != -1) {
6225 log_sg(
"Unexpected sub_target %d (expected %d) for order type %d",
6226 order_sub_tgt, -1,
order->order);
6232 for (; j < orders_max_length; j++) {
6234 "%s.action_vec,%d", unitstr, j);
6236 "%s.tgt_vec,%d", unitstr, j);
6238 "%s.sub_tgt_vec,%d", unitstr, j);
6256 for (j = 1; j < orders_max_length; j++) {
6258 "%s.action_vec,%d", unitstr, j);
6260 "%s.tgt_vec,%d", unitstr, j);
6262 "%s.sub_tgt_vec,%d", unitstr, j);
6285 "player%d.nunits", plrno),
6287 if (!plr->
is_alive && nunits > 0) {
6288 log_sg(
"'player%d.nunits' = %d for dead player!", plrno, nunits);
6292 for (i = 0; i < nunits; i++) {
6293 int id_unit, id_trans;
6303 "player%d.u%d.transported_by",
6305 if (id_trans == -1) {
6314#ifndef FREECIV_NDEBUG
6331 int longest_order = 0;
6338 "player%d.nunits", plrno);
6344 if (longest_order < punit->
orders.length) {
6352 char dirbuf[2] =
" ";
6356 fc_snprintf(buf,
sizeof(buf),
"player%d.u%d", plrno, i);
6367 "%s.nationality", buf);
6373 "%s.type_by_name", buf);
6377 "%s.activity_count", buf);
6382 "%s.activity_tgt", buf);
6386 "%s.changed_from", buf);
6388 "%s.changed_from_count", buf);
6393 "%s.changed_from_tgt", buf);
6397 "%s.done_moving", buf);
6403 "%s.battlegroup", buf);
6418 "%s.server_side_agent", buf);
6426 "%s.ord_city", buf);
6429 "%s.paradropped", buf);
6432 "%s.transported_by", buf);
6435 "%s.carrying", buf);
6441 "%s.action_decision", buf);
6449 "%s.action_decision_tile_x", buf);
6451 "%s.action_decision_tile_y", buf);
6455 "%s.action_decision_tile_x", buf);
6457 "%s.action_decision_tile_y", buf);
6465 char orders_buf[
len + 1], dir_buf[
len + 1];
6466 char act_buf[
len + 1];
6467 int action_buf[
len];
6469 int sub_tgt_vec[
len];
6475 "%s.orders_index", buf);
6477 "%s.orders_repeat", buf);
6479 "%s.orders_vigilant", buf);
6481 for (j = 0; j <
len; j++) {
6486 sub_tgt_vec[j] = -1;
6507 orders_buf[
len] = dir_buf[
len] = act_buf[
len] =
'\0';
6514 "%s.action_vec", buf);
6517 for (j = last_order; j < longest_order; j++) {
6525 for (j = last_order; j < longest_order; j++) {
6530 "%s.sub_tgt_vec", buf);
6533 for (j = last_order; j < longest_order; j++) {
6554 for (j = 1; j < longest_order; j++) {
6560 for (j = 1; j < longest_order; j++) {
6566 for (j = 1; j < longest_order; j++) {
6594 loading->
file, 0,
"player%d.attribute_v2_block_length", plrno);
6597 log_sg(
"player%d.attribute_v2_block_length=%d too small", plrno,
6600 }
else if (MAX_ATTRIBUTE_BLOCK < plr->attribute_block.length) {
6601 log_sg(
"player%d.attribute_v2_block_length=%d too big (max %d)",
6608#ifndef FREECIV_NDEBUG
6609 size_t actual_length;
6614 "player%d.attribute_v2_block_length_quoted",
6618 "player%d.attribute_v2_block_parts", plrno),
6624 for (part_nr = 0; part_nr <
parts; part_nr++) {
6625 const char *current =
6627 "player%d.attribute_v2_block_data.part%d",
6630 log_sg(
"attribute_v2_block_parts=%d actual=%d",
parts, part_nr);
6633 log_debug(
"attribute_v2_block_length_quoted=%d"
6634 " have=" SIZE_T_PRINTF
" part=" SIZE_T_PRINTF,
6635 quoted_length, strlen(quoted), strlen(current));
6636 fc_assert(strlen(quoted) + strlen(current) <= quoted_length);
6637 strcat(quoted, current);
6640 "attribute_v2_block_length_quoted=%d"
6641 " actual=" SIZE_T_PRINTF,
6642 quoted_length, strlen(quoted));
6644#ifndef FREECIV_NDEBUG
6671#define PART_SIZE (3*256)
6672#define PART_ADJUST (3)
6676 int current_part_nr;
6679 char *quoted_at = strchr(quoted,
':');
6680 size_t bytes_left = strlen(quoted);
6681 size_t bytes_at_colon = 1 + (quoted_at - quoted);
6682 size_t bytes_adjust = bytes_at_colon %
PART_ADJUST;
6685 "player%d.attribute_v2_block_length", plrno);
6687 "player%d.attribute_v2_block_length_quoted", plrno);
6692 if ((bytes_left - bytes_adjust) >
PART_SIZE) {
6700 "player%d.attribute_v2_block_parts", plrno);
6703 size_t size_of_current_part =
PART_SIZE + bytes_adjust;
6706 memcpy(
part, quoted, size_of_current_part);
6707 part[size_of_current_part] =
'\0';
6709 "player%d.attribute_v2_block_data.part%d",
6711 bytes_left -= size_of_current_part;
6712 quoted_at = "ed[size_of_current_part];
6713 current_part_nr = 1;
6716 current_part_nr = 0;
6719 for (; current_part_nr <
parts; current_part_nr++) {
6720 size_t size_of_current_part =
MIN(bytes_left,
PART_SIZE);
6722 memcpy(
part, quoted_at, size_of_current_part);
6723 part[size_of_current_part] =
'\0';
6725 "player%d.attribute_v2_block_data.part%d",
6728 bytes_left -= size_of_current_part;
6729 quoted_at = "ed_at[size_of_current_part];
6747 "player%d.dc_total", plrno);
6749 bool someone_alive =
FALSE;
6756 if (pteam_member->is_alive) {
6757 someone_alive =
TRUE;
6762 if (!someone_alive) {
6768 if (-1 == total_ncities
6771 "game.save_private_map")) {
6786 if (NULL != pcity) {
6800 "player%d.map_t%04d", plrno);
6807 loading->
file,
"player%d.map_e%02d_%04d", plrno, j);
6834 const char *ptr = buffer;
6835 const char *ptr2 = buffer2;
6838 "Savegame corrupt - map line %d not found.", y);
6845 scanin(&ptr,
",", token,
sizeof(token));
6847 "Savegame corrupt - map size not correct.");
6848 if (strcmp(token,
"-") == 0) {
6852 "Savegame corrupt - got tile owner=%s in (%d, %d).",
6857 scanin(&ptr2,
",", token2,
sizeof(token2));
6859 "Savegame corrupt - map size not correct.");
6860 if (strcmp(token2,
"-") == 0) {
6864 "Savegame corrupt - got extras owner=%s in (%d, %d).",
6873 for (i = 0; i < 4; i++) {
6879 loading->
file,
"player%d.map_u%02d_%04d", plrno, i);
6884 loading->
file,
"player%d.map_u%02d_%04d", plrno, i);
6889 for (i = 0; i < total_ncities; i++) {
6892 fc_snprintf(buf,
sizeof(buf),
"player%d.dc%d", plrno, i);
6901 log_sg(
"Skipping seen city %d for player %d.", i, plrno);
6902 if (pdcity != NULL) {
6916 if (NULL != pcity) {
6934 const char *citystr)
6940 const char *stylename;
6941 enum capital_type cap;
6952 "%s invalid tile (%d,%d)", citystr,
nat_x,
nat_y);
6959 "%s has invalid owner (%d); skipping.", citystr,
id);
6965 "%s has invalid id (%d); skipping.", citystr,
id);
6968 "%s.size", citystr),
6972 "Invalid city size: %d; set to %d.",
size, city_size);
6980 "Invalid length of '%s.improvements' ("
6981 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
6985 "Undefined value '%c' within '%s.improvements'.",
6988 if (
str[i] ==
'1') {
6998 "%s.name", citystr);
7000 if (vname != NULL) {
7005 "%s.occupied", citystr);
7007 "%s.walls", citystr);
7009 "%s.happy", citystr);
7011 "%s.unhappy", citystr);
7013 "%s.style", citystr);
7014 if (stylename != NULL) {
7019 if (pdcity->
style < 0) {
7024 "%s.city_image", citystr);
7027 "%s.capital", citystr),
7030 if (capital_type_is_valid(cap)) {
7033 pdcity->
capital = CAPITAL_NOT;
7058 saving->
file,
"player%d.map_t%04d", plrno);
7073 if (plrtile == NULL || plrtile->
owner == NULL) {
7079 strcat(line, token);
7097 if (plrtile == NULL || plrtile->
extras_owner == NULL) {
7103 strcat(line, token);
7118 for (l = 0; l < 4; l++) {
7130 saving->
file,
"player%d.map_e%02d_%04d", plrno, j);
7134 for (i = 0; i < 4; i++) {
7139 saving->
file,
"player%d.map_u%02d_%04d", plrno, i);
7146 char impr_buf[
B_LAST + 1];
7149 fc_snprintf(buf,
sizeof(buf),
"player%d.dc%d", plrno, i);
7165 "%s.occupied", buf);
7184 "Invalid size of the improvement vector (%s.improvements: "
7185 SIZE_T_PRINTF
" < " SIZE_T_PRINTF
" ).",
7186 buf, strlen(impr_buf),
sizeof(impr_buf));
7188 if (pdcity->
name != NULL) {
7213 int *vlist_research;
7215 vlist_research = NULL;
7226 for (i = 0; i < count; i++) {
7228 "research.r%d.number", i),
7232 "Invalid research number %d in 'research.r%d.number'",
7236 "research.r%d.goal", i);
7239 "research.r%d.techs", i),
7243 "research.r%d.futuretech", i),
7247 "research.r%d.bulbs", i),
7251 "research.r%d.bulbs_before", i),
7254 "research.r%d.saved", i);
7256 "research.r%d.now", i);
7259 "research.r%d.got_tech", i),
7266 "research.r%d.got_tech_multi",
7272 "Invalid length of 'research.r%d.done' ("
7273 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
7277 "Undefined value '%c' within 'research.r%d.done'.",
7280 if (
str[j] ==
'1') {
7296 "research.r%d.vbs", i);
7298 for (tn = 0; tn < count_res; tn++) {
7301 if (padvance != NULL) {
7303 = vlist_research[tn];
7323 int *vlist_research;
7325 vlist_research = NULL;
7332 "research.r%d.number", i);
7334 i, presearch->tech_goal);
7336 "research.r%d.techs", i);
7338 "research.r%d.futuretech", i);
7340 "research.r%d.bulbs_before", i);
7344 vlist_research[j] = presearch->inventions[j].bulbs_researched_saved;
7348 "research.r%d.vbs", i);
7349 if (vlist_research) {
7350 free(vlist_research);
7354 i, presearch->researching_saved);
7356 "research.r%d.bulbs", i);
7358 i, presearch->researching);
7360 "research.r%d.got_tech", i);
7362 "research.r%d.got_tech_multi", i);
7368 == TECH_KNOWN ?
'1' :
'0');
7426 "treaty%d.plr0", tidx)) != NULL ;
7438 if (p0 == NULL || p1 == NULL) {
7439 log_error(
"Treaty between unknown players %s and %s", plr0, plr1);
7444 treaty_list_prepend(
treaties, ptreaty);
7447 "treaty%d.clause%d.type",
7448 tidx, cidx)) != NULL ;
7453 if (!clause_type_is_valid(
type)) {
7454 log_error(
"Invalid clause type \"%s\"", ct);
7456 struct player *pgiver = NULL;
7466 log_error(
"Clause giver %s is not participant of the treaty"
7467 "between %s and %s", plrx, plr0, plr1);
7470 if (pgiver != NULL) {
7474 "treaty%d.clause%d.value",
7485 "treaty%d.accept0", tidx);
7487 "treaty%d.accept1", tidx);
7504 fc_snprintf(tpath,
sizeof(tpath),
"treaty%d", tidx++);
7514 fc_snprintf(cpath,
sizeof(cpath),
"%s.clause%d", tpath, cidx++);
7580 int mapdef_count, i;
7592 log_verbose(
"Saved map image definitions: %d.", mapdef_count);
7594 if (0 >= mapdef_count) {
7598 for (i = 0; i < mapdef_count; i++) {
7603 log_verbose(
"[Mapimg %4d] Missing definition.", i);
7608 log_error(
"Invalid map image definition %4d: %s.", i, p);
7659 log_verbose(
"Max players lower than current players, fixing");
7668 log_sg(
"Removing %s unferried %s in %s at (%d, %d)",
7705 log_error(
"[city id: %d] Bad worker task %d.",
7706 pcity->id, ptask->act);
7707 worker_task_list_remove(pcity->task_reqs, ptask);
7721 log_error(
"[city id: %d] Unused worked tile at (%d, %d).",
7732 if (presearch->researching !=
A_UNSET
7736 != TECH_PREREQS_KNOWN))) {
7737 log_sg(
_(
"%s had invalid researching technology."),
7739 presearch->researching =
A_UNSET;
7741 if (presearch->tech_goal !=
A_UNSET
7747 log_sg(
_(
"%s had invalid technology goal."),
7749 presearch->tech_goal =
A_UNSET;
7754 if (presearch->techs_researched !=
techs) {
7756 _(
"%s had finished researches count wrong."),
7758 presearch->techs_researched =
techs;
7764 int unique_count[
U_LAST];
7766 memset(unique_count, 0,
sizeof(unique_count));
7774 log_sg(
_(
"%s has multiple units of type %s though it should be possible "
7775 "to have only one."),
7796 if (0 == strlen(
server.game_identifier)
7800 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 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)
void map_init_topology(void)
#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_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)