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");
2693 "map.have_resources");
2738 const char *spec_sprite;
2747 if (NULL != ptile->spec_sprite) {
2748 ptile->spec_sprite =
fc_strdup(spec_sprite);
2750 if (label != NULL) {
2773 if (ptile->spec_sprite) {
2777 if (ptile->label != NULL) {
2795 loading->
file,
"map.e%02d_%04d", j);
2828 for (l = 0; l < 4; l++) {
2836 saving->
file,
"map.e%02d_%04d", j);
2849 const char SEPARATOR =
'#';
2850 const char *nation_names;
2853 int i, startpos_count;
2861 if (0 == startpos_count) {
2866 for (i = 0; i < startpos_count; i++) {
2869 "map.startpos%d.y", i)) {
2870 log_sg(
"Warning: Undefined coordinates for startpos %d", i);
2875 if (NULL == ptile) {
2876 log_error(
"Start position native coordinates (%d, %d) do not exist "
2882 "map.startpos%d.exclude", i);
2887 "map.startpos%d.nations", i);
2888 if (NULL != nation_names &&
'\0' != nation_names[0]) {
2889 const size_t size = strlen(nation_names) + 1;
2890 char buf[
size], *start, *end;
2892 memcpy(buf, nation_names,
size);
2893 for (start = buf - 1; NULL != start; start = end) {
2895 if ((end = strchr(start, SEPARATOR))) {
2916 log_verbose(
"Number of starts (%d) are lower than rules.max_players "
2917 "(%d), lowering rules.max_players.",
2934 const char SEPARATOR =
'#';
2945 "map.startpos_count");
2957 "map.startpos%d.exclude", i);
2964 nation_names[0] =
'\0';
2966 if (
'\0' == nation_names[0]) {
2968 sizeof(nation_names));
2975 "map.startpos%d.nations", i);
3003 "map.owner%04d", y);
3005 "map.source%04d", y);
3007 "map.eowner%04d", y);
3010 "map.placing%04d", y);
3013 "map.infra_turns%04d", y);
3014 const char *ptr1 = buffer1;
3015 const char *ptr2 = buffer2;
3016 const char *ptr3 = buffer3;
3017 const char *ptr_placing = buffer_placing;
3018 const char *ptr_turns = buffer_turns;
3031 struct player *eowner = NULL;
3036 scanin(&ptr1,
",", token1,
sizeof(token1));
3038 "Map size not correct (map.owner%d).", y);
3039 if (strcmp(token1,
"-") == 0) {
3043 "Got map owner %s in (%d, %d).", token1, x, y);
3047 scanin(&ptr2,
",", token2,
sizeof(token2));
3049 "Map size not correct (map.source%d).", y);
3050 if (strcmp(token2,
"-") == 0) {
3054 "Got map source %s in (%d, %d).", token2, x, y);
3058 scanin(&ptr3,
",", token3,
sizeof(token3));
3060 "Map size not correct (map.eowner%d).", y);
3061 if (strcmp(token3,
"-") == 0) {
3065 "Got base owner %s in (%d, %d).", token3, x, y);
3069 if (ptr_placing != NULL) {
3070 scanin(&ptr_placing,
",", token_placing,
sizeof(token_placing));
3072 "Map size not correct (map.placing%d).", y);
3073 if (strcmp(token_placing,
"-") == 0) {
3077 "Got placing extra %s in (%d, %d).", token_placing, x, y);
3084 if (ptr_turns != NULL) {
3085 scanin(&ptr_turns,
",", token_turns,
sizeof(token_turns));
3087 "Map size not correct (map.infra_turns%d).", y);
3089 "Got infra_turns %s in (%d, %d).", token_turns, x, y);
3134 strcat(line, token);
3155 strcat(line, token);
3177 strcat(line, token);
3199 strcat(line, token);
3221 strcat(line, token);
3241 "City worked map not loaded!");
3249 const char *ptr = buffer;
3252 "Savegame corrupt - map line %d not found.", y);
3258 scanin(&ptr,
",", token,
sizeof(token));
3260 "Savegame corrupt - map size not correct.");
3261 if (strcmp(token,
"-") == 0) {
3265 "Savegame corrupt - got tile worked by city "
3266 "id=%s in (%d, %d).", token, x, y);
3299 if (pcity == NULL) {
3304 strcat(line, token);
3328 "game.save_known")) {
3333 for (l = 0; l <
lines; l++) {
3334 for (j = 0; j < 8; j++) {
3335 for (i = 0; i < 4; i++) {
3342 loading->
file,
"map.k%02d_%04d", l * 8 + j);
3399 |= (1u << (p % 32));
3404 for (l = 0; l <
lines; l++) {
3405 for (j = 0; j < 8; j++) {
3406 for (i = 0; i < 4; i++) {
3413 saving->
file,
"map.k%02d_%04d", l * 8 + j);
3440 bool shuffle_loaded =
TRUE;
3453 "players.destroyed_wonders");
3456 "Invalid length for 'players.destroyed_wonders' ("
3457 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
")",
3461 "Undefined value '%c' within "
3462 "'players.destroyed_wonders'.",
str[k]);
3464 if (
str[k] ==
'1') {
3476 "players.identity_number_used");
3503 log_sg(
"Game has started, yet player %d has no color defined.",
3507 log_verbose(
"No color defined for player %d.", pslot_id);
3542 "player%d.multiplier%d.val",
3548 log_verbose(
"Player %d had illegal value for multiplier \"%s\": "
3549 "was %d, clamped to %d", pslot_id,
3557 "player%d.multiplier%d.target",
3563 log_verbose(
"Player %d had illegal value for multiplier_target "
3564 " \"%s\": was %d, clamped to %d", pslot_id,
3571 "player%d.multiplier%d.changed",
3579 "player%d.border_vision",
3586 "(%d) from the loaded game does not match the number of "
3598 "Invalid team definition for player %s (nb %d).",
3614 "players.shuffled_player_%d", 0) >= 0) {
3617 int shuffled_players[
slots];
3618 bool shuffled_player_set[
slots];
3620 for (i = 0; i <
slots; i++) {
3622 shuffled_player_set[i] =
FALSE;
3625 shuffled_players[i] = -1;
3629 for (i = 0; i < plrcount; i++) {
3632 "players.shuffled_player_%d", i);
3634 if (shuffle == -1) {
3635 log_sg(
"Missing player shuffle information (index %d) "
3636 "- reshuffle player list!", i);
3637 shuffle_loaded =
FALSE;
3639 }
else if (shuffled_player_set[shuffle]) {
3640 log_sg(
"Player shuffle %d used two times "
3641 "- reshuffle player list!", shuffle);
3642 shuffle_loaded =
FALSE;
3646 shuffled_player_set[shuffle] =
TRUE;
3649 shuffled_players[i] = shuffle;
3652 if (shuffle_loaded) {
3654 int shuffle_index = plrcount;
3656 for (i = 0; i <
slots; i++) {
3657 if (!shuffled_player_set[i]) {
3658 shuffled_players[shuffle_index++] = i;
3663 "Invalid player shuffle data!");
3671 log_debug(
"[load shuffle] id: %3d => slot: %3d | slot %3d: %s",
3672 plrid, shuffled_players[plrid], plrid,
3673 shuffled_player_set[plrid] ?
"is used" :
"-");
3682 if (!shuffle_loaded) {
3712 if (
is_ai(pplayer)) {
3713 log_normal(
_(
"%s has been added as %s level AI-controlled player "
3715 ai_level_translated_name(pplayer->ai_common.skill_level),
3718 log_normal(
_(
"%s has been added as human player."),
3741 log_sg(
_(
"%s had invalid nation; changing to %s."),
3757 log_sg(
"Illegal alliance structure detected: "
3758 "%s alliance to %s reduced to peace treaty.",
3772 pcity->server.illness
3774 &(pcity->illness_trade), NULL);
3800 BV_CLR_ALL(pplayer->server.really_gives_vision);
3810 "player%d.diplstate%d.gives_shared_vision", plr1, plr2)) {
3822 if (pplayer1 != pplayer2
3826 _(
"%s did not give shared vision to team member %s."),
3832 _(
"%s did not give shared vision to team member %s."),
3852 log_sg(
"%s doing illegal activity in savegame!",
3854 log_sg(
"Activity: %s, Target: %s, Tile: (%d, %d), Terrain: %s",
3898 char destroyed[
B_LAST+1];
3910 "players.destroyed_wonders");
3914 "players.identity_number_used");
3921 "players.shuffled_player_%d", i);
3950 const char *barb_str;
3963 "player%d.username", plrno));
3965 "player%d.unassigned_user", plrno),
3969 "player%d.orig_username", plrno));
3972 "player%d.ranked_username",
3975 "player%d.unassigned_ranked", plrno),
3978 "player%d.delegation_username",
3988 for (i = 0; i < nval; i++) {
3989 const char *sval = slist[i];
3990 enum plr_flag_id fid = plr_flag_id_by_name(sval,
fc_strcasecmp);
3992 sg_failure_ret(plr_flag_id_is_valid(fid),
"Invalid player flag \"%s\".", sval);
4001 if (plr->
nation != NULL) {
4009 sg_failure_ret(gov != NULL,
"Player%d: unsupported government \"%s\".",
4015 "player%d.target_government_name", plrno);
4023 "player%d.revolution_finishes", plrno);
4027 "player%d.got_first_city", plrno),
4039 fc_snprintf(buf,
sizeof(buf),
"player%d.diplstate%d", plrno, i);
4043 diplstate_type,
"%s.current", buf);
4046 diplstate_type,
"%s.closest", buf);
4049 "%s.first_contact_turn", buf);
4054 "%s.has_reason_to_cancel", buf);
4057 "%s.contact_turns_left", buf);
4071 fc_snprintf(buf,
sizeof(buf),
"player%d.ai%d", plrno,
4080 "player%d.adv.wonder_city",
4092 "player%d.ai.level", plrno);
4101 log_sg(
"Player%d: Invalid AI level \"%s\". "
4102 "Changed to \"%s\".", plrno,
level,
4108 "player%d.ai.barb_type", plrno);
4112 log_sg(
"Player%d: Invalid barbarian type \"%s\". "
4113 "Changed to \"None\".", plrno, barb_str);
4134 if (style == NULL) {
4136 log_sg(
"Player%d: unsupported city_style_name \"%s\". "
4143 "player%d.idle_turns", plrno),
4146 if (!strcmp(
"male", kind)) {
4152 "player%d.is_alive", plrno),
4155 "player%d.turns_alive", plrno),
4158 "player%d.last_war", plrno),
4161 "player%d.phase_done", plrno);
4163 "player%d.gold", plrno),
4166 "player%d.rates.tax", plrno),
4169 "player%d.rates.science", plrno),
4172 "player%d.rates.luxury", plrno),
4175 "player%d.infrapts",
4179 "player%d.research.bulbs_last_turn", plrno);
4183 for (i = 0; i < loading->
trait.
size; i++) {
4186 if (trait_is_valid(tr)) {
4195 "player%d.trait%d.mod", plrno, i),
4207 "player%d.achievement_count", plrno);
4210 for (i = 0; i < count; i++) {
4216 "player%d.achievement%d.name", plrno, i);
4220 "Unknown achievement \"%s\".",
name);
4223 "player%d.achievement%d.first",
4228 "Multiple players listed as first to get achievement \"%s\".",
4243 "score%d.happy", plrno);
4246 "score%d.content", plrno);
4249 "score%d.unhappy", plrno);
4252 "score%d.angry", plrno);
4263 "score%d.specialists%d", plrno, i);
4268 "score%d.wonders", plrno);
4271 "score%d.techs", plrno);
4274 "score%d.techout", plrno);
4277 "score%d.landarea", plrno);
4280 "score%d.settledarea", plrno);
4283 "score%d.population", plrno);
4286 "score%d.cities", plrno);
4289 "score%d.units", plrno);
4292 "score%d.pollution", plrno);
4295 "score%d.literacy", plrno);
4298 "score%d.bnp", plrno);
4301 "score%d.mfg", plrno);
4304 "score%d.spaceship", plrno);
4307 "score%d.units_built", plrno);
4310 "score%d.units_killed", plrno);
4313 "score%d.units_lost", plrno);
4316 "score%d.culture", plrno);
4319 "score%d.total", plrno);
4328 fc_snprintf(prefix,
sizeof(prefix),
"player%d.spaceship", plrno);
4332 "%s.state", prefix),
4338 "%s.structurals", prefix),
4341 "%s.components", prefix),
4344 "%s.modules", prefix),
4350 "%s.propulsion", prefix),
4353 "%s.habitation", prefix),
4356 "%s.life_support", prefix),
4359 "%s.solar_panels", prefix),
4366 "Undefined value '%c' within '%s.structure'.", st[i],
4369 if (!(st[i] ==
'0')) {
4375 "%s.launch_year", prefix),
4389 "Invalid length for 'player%d.lost_wonders' ("
4390 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
")",
4394 "Undefined value '%c' within "
4395 "'player%d.lost_wonders'.", plrno,
str[k]);
4397 if (
str[k] ==
'1') {
4421 const char *flag_names[PLRF_COUNT];
4428 for (i = 0; i < PLRF_COUNT; i++) {
4430 flag_names[set_count++] = plr_flag_id_name(i);
4435 "player%d.flags", plrno);
4438 "player%d.ai_type", plrno);
4440 "player%d.name", plrno);
4442 "player%d.username", plrno);
4444 "player%d.unassigned_user", plrno);
4445 if (plr->
rgb != NULL) {
4450 log_sg(
"Game has started, yet player %d has no color defined.", plrno);
4454 "player%d.ranked_username", plrno);
4456 "player%d.unassigned_ranked", plrno);
4458 "player%d.orig_username", plrno);
4462 "player%d.delegation_username", plrno);
4464 "player%d.nation", plrno);
4466 "player%d.team_no", plrno);
4470 "player%d.government_name", plrno);
4475 "player%d.target_government_name", plrno);
4479 "player%d.style_by_name", plrno);
4482 "player%d.idle_turns", plrno);
4485 "player%d.kind", plrno);
4488 "player%d.kind", plrno);
4491 "player%d.is_alive", plrno);
4493 "player%d.turns_alive", plrno);
4495 "player%d.last_war", plrno);
4497 "player%d.phase_done", plrno);
4506 fc_snprintf(buf,
sizeof(buf),
"player%d.diplstate%d", plrno, i);
4509 diplstate_type,
"%s.current", buf);
4511 diplstate_type,
"%s.closest", buf);
4513 "%s.first_contact_turn", buf);
4515 "%s.turns_left", buf);
4517 "%s.has_reason_to_cancel", buf);
4519 "%s.contact_turns_left", buf);
4523 "%s.gives_shared_vision", buf);
4530 "player%d.ai%d.love", plrno, i);
4535 "player%d.adv.wonder_city", plrno);
4542 for (k = 0; k < i; k++) {
4544 "player%d.multiplier%d.val", plrno, k);
4546 "player%d.multiplier%d.target", plrno, k);
4548 "player%d.multiplier%d.changed", plrno, k);
4552 "player%d.ai.level", plrno);
4554 "player%d.ai.barb_type", plrno);
4556 "player%d.gold", plrno);
4558 "player%d.rates.tax", plrno);
4560 "player%d.rates.science", plrno);
4562 "player%d.rates.luxury", plrno);
4564 "player%d.infrapts", plrno);
4566 "player%d.research.bulbs_last_turn", plrno);
4573 for (tr = trait_begin(), j = 0; tr != trait_end(); tr = trait_next(tr), j++) {
4575 "player%d.trait%d.val", plrno, j);
4577 "player%d.trait%d.mod", plrno, j);
4588 "player%d.achievement%d.name", plrno, j);
4589 if (pach->first == plr) {
4591 "player%d.achievement%d.first", plrno, j);
4594 "player%d.achievement%d.first", plrno, j);
4602 "player%d.achievement_count", plrno);
4606 "player%d.got_first_city", plrno);
4608 "player%d.revolution_finishes", plrno);
4612 "score%d.happy", plrno);
4614 "score%d.content", plrno);
4616 "score%d.unhappy", plrno);
4618 "score%d.angry", plrno);
4621 "score%d.specialists%d", plrno, sp);
4624 "score%d.wonders", plrno);
4626 "score%d.techs", plrno);
4628 "score%d.techout", plrno);
4630 "score%d.landarea", plrno);
4632 "score%d.settledarea", plrno);
4634 "score%d.population", plrno);
4636 "score%d.cities", plrno);
4638 "score%d.units", plrno);
4640 "score%d.pollution", plrno);
4642 "score%d.literacy", plrno);
4644 "score%d.bnp", plrno);
4646 "score%d.mfg", plrno);
4648 "score%d.spaceship", plrno);
4650 "score%d.units_built", plrno);
4652 "score%d.units_killed", plrno);
4654 "score%d.units_lost", plrno);
4656 "score%d.culture", plrno);
4658 "score%d.total", plrno);
4668 fc_snprintf(buf,
sizeof(buf),
"player%d.spaceship", plrno);
4671 "%s.structurals", buf);
4673 "%s.components", buf);
4680 "%s.life_support", buf);
4682 "%s.solar_panels", buf);
4691 "%s.launch_year", buf);
4708 "player%d.lost_wonders", plrno);
4712 "player%d.history", plrno);
4714 "player%d.hut_count", plrno);
4717 "player%d.border_vision", plrno);
4728 int wlist_max_length = 0;
4734 "player%d.ncities", plrno),
4737 if (!plr->
is_alive && ncities > 0) {
4738 log_sg(
"'player%d.ncities' = %d for dead player!", plrno, ncities);
4748 for (i = 0; i < ncities; i++) {
4750 "player%d.c%d.wl_length",
4753 wlist_max_length =
MAX(wlist_max_length, wl_length);
4757 for (i = 0; i < ncities; i++) {
4761 fc_snprintf(buf,
sizeof(buf),
"player%d.c%d", plrno, i);
4788 city_list_append(plr->
cities, pcity);
4791 tasks_handled =
FALSE;
4792 for (i = 0; !tasks_handled; i++) {
4794 struct city *pcity = NULL;
4799 if (city_id != -1) {
4803 if (pcity != NULL) {
4817 "Unknown workertask activity %s",
str);
4821 if (strcmp(
"-",
str)) {
4825 "Unknown workertask target %s",
str);
4829 if (ptask->
act == ACTIVITY_IRRIGATE) {
4830 ptask->
act = ACTIVITY_CULTIVATE;
4831 }
else if (ptask->
act == ACTIVITY_MINE) {
4832 ptask->
act = ACTIVITY_MINE;
4837 "player%d.task%d.want", plrno, i);
4839 worker_task_list_append(pcity->
task_reqs, ptask);
4841 tasks_handled =
TRUE;
4850 struct city *pcity,
const char *citystr,
4851 int wlist_max_length)
4854 const char *kind, *
name, *
str;
4855 int id, i, repair, sp_count = 0, workers = 0, value;
4858 const char *stylename;
4869 "%s has invalid center tile (%d, %d)",
4872 "%s duplicates city (%d, %d)", citystr,
nat_x,
nat_y);
4876 "%s.name", citystr));
4882 "%s.original", citystr);
4892 "Invalid city size: %d, set to %d", value,
size);
4905 for (i = 0; partner != 0; i++) {
4908 const char *good_str;
4912 trade_route_list_append(pcity->
routes, proute);
4917 "No traderoute direction found for %s", citystr);
4920 "Illegal route direction %s",
dir);
4923 "No good found for %s", citystr);
4926 "Illegal good %s", good_str);
4930 "%s.traderoute%d", citystr, i + 1);
4940 "%s.food_stock", citystr),
4943 "%s.shield_stock", citystr),
4958 "%s.anarchy", citystr),
4966 "%s.turn_founded", citystr),
4974 "%s.turn_last_built", citystr),
4983 "%s.currently_building: unknown \"%s\" \"%s\".",
4984 citystr, kind,
name);
4987 "%s.current_want", citystr);
5000 "%s.changed_from: unknown \"%s\" \"%s\".",
5001 citystr, kind,
name);
5005 "%s.before_change_shields", citystr);
5008 "%s.caravan_shields", citystr);
5011 "%s.disbanded_shields", citystr);
5014 "%s.last_turns_shield_surplus",
5018 "%s.style", citystr);
5019 if (stylename != NULL) {
5024 if (pcity->
style < 0) {
5039 "Invalid length of '%s.improvements' ("
5040 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
5044 "Undefined value '%c' within '%s.improvements'.",
5047 if (
str[i] ==
'1') {
5058 "No worked tiles map defined.");
5073 log_sg(
"[%s] '%s' (%d, %d) has worker outside current radius "
5094 if (NULL != pwork) {
5095 log_sg(
"[%s] city center of '%s' (%d,%d) [%d] is worked by '%s' "
5104 log_sg(
"[%s] city center of '%s' (%d,%d) [%d] is empty; repairing",
5116 log_sg(
"[%s] size mismatch for '%s' (%d,%d): size [%d] != "
5117 "(workers [%d] - free worked tiles [%d]) + specialists [%d]",
5130 for (i = 0; i < CITYO_LAST; i++) {
5140 "%s.rally_point_length", citystr);
5145 const char *rally_orders, *rally_dirs, *rally_activities;
5151 "%s.rally_point_persistent", citystr);
5154 "%s.rally_point_vigilant", citystr);
5158 "%s.rally_point_orders", citystr);
5161 "%s.rally_point_dirs", citystr);
5164 "%s.rally_point_activities", citystr);
5166 for (i = 0; i <
len; i++) {
5169 if (rally_orders[i] ==
'\0' || rally_dirs[i] ==
'\0'
5170 || rally_activities[i] ==
'\0') {
5171 log_sg(
"Invalid rally point.");
5182 "%s.rally_point_action_vec,%d",
5185 if (unconverted >= 0 && unconverted < loading->
action.size) {
5190 log_sg(
"Invalid action id in order for city rally point %d",
5199 "%s.rally_point_tgt_vec,%d",
5203 "%s.rally_point_sub_tgt_vec,%d",
5222 "%s.rally_point_tgt_vec", citystr);
5224 "%s.rally_point_sub_tgt_vec", citystr);
5231 "%s.cma_enabled", citystr);
5235 for (i = 0; i <
O_LAST; i++) {
5237 loading->
file, 0,
"%s.cma_minimal_surplus,%d", citystr, i);
5239 loading->
file, 0,
"%s.cma_factor,%d", citystr, i);
5243 loading->
file,
FALSE,
"%s.max_growth", citystr);
5245 loading->
file,
FALSE,
"%s.require_happy", citystr);
5247 loading->
file,
FALSE,
"%s.allow_disorder", citystr);
5249 loading->
file,
FALSE,
"%s.allow_specialists", citystr);
5251 loading->
file, 0,
"%s.happy_factor", citystr);
5256 for (i = 0; i <
O_LAST; i++) {
5258 "%s.cma_minimal_surplus,%d", citystr, i);
5260 "%s.cma_factor,%d", citystr, i);
5287 const char *citystr)
5297 "%s.citizen%d", citystr,
5300 log_sg(
"Citizens of an invalid nation for %s (player slot %d)!",
5307 "Invalid value for citizens of player %d in %s: %d.",
5320 log_sg(
"City size and number of citizens does not match in %s "
5335 int wlist_max_length = 0, rally_point_max_length = 0, routes_max = 0;
5344 "player%d.ncities", plrno);
5362 if (pcity->worklist.length > wlist_max_length) {
5363 wlist_max_length = pcity->worklist.length;
5366 if (pcity->rally_point.length > rally_point_max_length) {
5367 rally_point_max_length = pcity->rally_point.length;
5371 if (routes > routes_max) {
5372 routes_max = routes;
5388 char impr_buf[
B_LAST + 1];
5392 fc_snprintf(buf,
sizeof(buf),
"player%d.c%d", plrno, i);
5401 if (pcity->original != NULL) {
5403 "%s.original", buf);
5420 "%s.route_direction%d", buf, j);
5422 "%s.route_good%d", buf, j);
5427 for (; j < routes_max; j++) {
5430 "%s.route_direction%d", buf, j);
5432 "%s.route_good%d", buf, j);
5457 "%s.turn_last_built", buf);
5463 "%s.currently_building_kind", buf);
5465 "%s.currently_building_name", buf);
5467 if (pcity->production.kind == VUT_IMPROVEMENT) {
5471 "%s.current_want", buf);
5474 "%s.current_want", buf);
5478 "%s.changed_from_kind", buf);
5480 "%s.changed_from_name", buf);
5483 "%s.before_change_shields", buf);
5485 "%s.caravan_shields", buf);
5487 "%s.disbanded_shields", buf);
5489 "%s.last_turns_shield_surplus", buf);
5497 "player%d.c%d.city_radius_sq", plrno, i);
5511 "Invalid size of the improvement vector (%s.improvements: "
5512 SIZE_T_PRINTF
" < " SIZE_T_PRINTF
").", buf,
5513 strlen(impr_buf),
sizeof(impr_buf));
5519 for (j = 0; j < CITYO_LAST; j++) {
5521 "%s.option%d", buf, j);
5538 "%s.rally_point_length", buf);
5539 if (pcity->rally_point.length) {
5540 int len = pcity->rally_point.length;
5541 char orders[
len + 1], dirs[
len + 1], activities[
len + 1];
5544 int sub_targets[
len];
5547 "%s.rally_point_persistent", buf);
5549 "%s.rally_point_vigilant", buf);
5551 for (j = 0; j <
len; j++) {
5552 orders[j] =
order2char(pcity->rally_point.orders[j].order);
5554 activities[j] =
'?';
5558 switch (pcity->rally_point.orders[j].order) {
5561 dirs[j] =
dir2char(pcity->rally_point.orders[j].dir);
5564 sub_targets[j] = pcity->rally_point.orders[j].sub_target;
5569 actions[j] = pcity->rally_point.orders[j].action;
5570 targets[j] = pcity->rally_point.orders[j].target;
5571 sub_targets[j] = pcity->rally_point.orders[j].sub_target;
5578 orders[
len] = dirs[
len] = activities[
len] =
'\0';
5583 "%s.rally_point_activities", buf);
5586 "%s.rally_point_action_vec", buf);
5589 for (j =
len; j < rally_point_max_length; j++) {
5595 "%s.rally_point_tgt_vec", buf);
5598 for (j =
len; j < rally_point_max_length; j++) {
5600 "%s.rally_point_tgt_vec,%d", buf, j);
5604 "%s.rally_point_sub_tgt_vec", buf);
5607 for (j =
len; j < rally_point_max_length; j++) {
5630 for (j = 1; j < rally_point_max_length; j++) {
5638 for (j = 1; j < rally_point_max_length; j++) {
5640 "%s.rally_point_tgt_vec,%d", buf, j);
5646 for (j = 1; j < rally_point_max_length; j++) {
5653 "%s.cma_enabled", buf);
5654 if (pcity->cm_parameter) {
5656 pcity->cm_parameter->minimal_surplus,
O_LAST,
5657 "%s.cma_minimal_surplus", buf);
5659 pcity->cm_parameter->factor,
O_LAST,
5660 "%s.cma_factor", buf);
5662 "%s.max_growth", buf);
5664 "%s.require_happy", buf);
5666 "%s.allow_disorder", buf);
5668 pcity->cm_parameter->allow_specialists,
5669 "%s.allow_specialists", buf);
5671 "%s.happy_factor", buf);
5675 memset(zeros, 0,
sizeof(zeros));
5677 "%s.cma_minimal_surplus", buf);
5679 "%s.cma_factor", buf);
5701 "player%d.task%d.activity",
5703 if (ptask->tgt != NULL) {
5705 "player%d.task%d.target",
5709 "player%d.task%d.target",
5726 size_t orders_max_length;
5732 "player%d.nunits", plrno),
5734 if (!plr->
is_alive && nunits > 0) {
5735 log_sg(
"'player%d.nunits' = %d for dead player!", plrno, nunits);
5739 orders_max_length = 0;
5741 for (i = 0; i < nunits; i++) {
5743 "player%d.u%d.orders_length",
5746 orders_max_length =
MAX(orders_max_length, ol_length);
5749 for (i = 0; i < nunits; i++) {
5757 fc_snprintf(buf,
sizeof(buf),
"player%d.u%d", plrno, i);
5799 int orders_max_length,
5800 const char *unitstr)
5802 enum unit_activity activity;
5808 const char *facing_str;
5827 "%s.facing", unitstr);
5828 if (facing_str[0] !=
'x') {
5832 enum direction8 facing =
char2dir(facing_str[0]);
5834 if (direction8_is_valid(facing)) {
5837 log_error(
"Illegal unit orientation '%s'", facing_str);
5845 "%s.nationality", unitstr);
5853 "%s.homecity", unitstr),
FALSE,
5856 "%s.moves", unitstr),
FALSE,
5859 "%s.fuel", unitstr),
FALSE,
5862 "%s.activity", unitstr),
FALSE,
5869 "%s.born", unitstr);
5872 "%s.activity_tgt", unitstr);
5874 if (extra_id != -2) {
5875 if (extra_id >= 0 && extra_id < loading->extra.size) {
5878 }
else if (activity == ACTIVITY_IRRIGATE) {
5888 }
else if (activity == ACTIVITY_MINE) {
5906 "%s.activity_count", unitstr),
FALSE,
5911 "%s.changed_from", unitstr);
5914 "%s.changed_from_tgt", unitstr),
FALSE,
5917 if (extra_id >= 0 && extra_id < loading->extra.size) {
5925 "%s.changed_from_count", unitstr);
5932 if (activity == ACTIVITY_SENTRY) {
5952 "%s.done_moving", unitstr);
5955 "%s.battlegroup", unitstr);
5958 "%s.go", unitstr)) {
5962 "%s.goto_x", unitstr),
FALSE,
5965 "%s.goto_y", unitstr),
FALSE,
5983 "%s.server_side_agent",
5985 if (unconverted >= 0 && unconverted < loading->ssa.size) {
5989 log_sg(
"Invalid server side agent %d for unit %d",
5996 "%s.hp", unitstr),
FALSE,
6007 "%s.paradropped", unitstr);
6009 if (
str[0] !=
'\0') {
6027 "%s.action_decision", unitstr),
6030 if (unconverted >= 0 && unconverted < loading->act_dec.size) {
6035 log_sg(
"Invalid action decision want for unit %d",
punit->
id);
6045 "%s.action_decision_tile_x", unitstr)
6047 "%s.action_decision_tile_y", unitstr)) {
6066 "%s.orders_length", unitstr);
6069 const char *orders_unitstr, *dir_unitstr, *act_unitstr;
6076 "%s.orders_index", unitstr);
6079 "%s.orders_repeat", unitstr);
6082 "%s.orders_vigilant", unitstr);
6086 "%s.orders_list", unitstr);
6089 "%s.dir_list", unitstr);
6092 "%s.activity_list", unitstr);
6096 for (j = 0; j <
len; j++) {
6098 bool action_wants_extra =
FALSE;
6101 if (orders_unitstr[j] ==
'\0' || dir_unitstr[j] ==
'\0'
6102 || act_unitstr[j] ==
'\0') {
6103 log_sg(
"Invalid unit orders.");
6115 if (unconverted >= 0 && unconverted < loading->
action.size) {
6120 log_sg(
"Invalid action id in order for unit %d",
punit->
id);
6129 && !direction8_is_valid(
order->dir))
6133 &&
order->activity == ACTIVITY_LAST)) {
6145 "%s.sub_tgt_vec,%d",
6155 log_sg(
"Cannot find building %d for %s to %s",
6160 order->sub_target = order_sub_tgt;
6165 if (order_sub_tgt ==
A_NONE
6169 log_sg(
"Cannot find tech %d for %s to steal",
6173 order->sub_target = order_sub_tgt;
6177 case ASTK_EXTRA_NOT_THERE:
6179 action_wants_extra =
TRUE;
6184 "Specified sub target for action %d unsupported.",
6190 "Bad action action %d.",
6198 enum unit_activity act;
6200 if (order_sub_tgt < 0 || order_sub_tgt >= loading->
extra.
size) {
6202 log_sg(
"Cannot find extra %d for %s to build",
6208 order->sub_target = order_sub_tgt;
6212 if (action_wants_extra) {
6215 act =
order->activity;
6218 if (unit_activity_is_valid(act)
6228 if (order_sub_tgt != -1) {
6229 log_sg(
"Unexpected sub_target %d (expected %d) for order type %d",
6230 order_sub_tgt, -1,
order->order);
6236 for (; j < orders_max_length; j++) {
6238 "%s.action_vec,%d", unitstr, j);
6240 "%s.tgt_vec,%d", unitstr, j);
6242 "%s.sub_tgt_vec,%d", unitstr, j);
6260 for (j = 1; j < orders_max_length; j++) {
6262 "%s.action_vec,%d", unitstr, j);
6264 "%s.tgt_vec,%d", unitstr, j);
6266 "%s.sub_tgt_vec,%d", unitstr, j);
6289 "player%d.nunits", plrno),
6291 if (!plr->
is_alive && nunits > 0) {
6292 log_sg(
"'player%d.nunits' = %d for dead player!", plrno, nunits);
6296 for (i = 0; i < nunits; i++) {
6297 int id_unit, id_trans;
6307 "player%d.u%d.transported_by",
6309 if (id_trans == -1) {
6318#ifndef FREECIV_NDEBUG
6335 int longest_order = 0;
6342 "player%d.nunits", plrno);
6348 if (longest_order < punit->
orders.length) {
6356 char dirbuf[2] =
" ";
6360 fc_snprintf(buf,
sizeof(buf),
"player%d.u%d", plrno, i);
6371 "%s.nationality", buf);
6377 "%s.type_by_name", buf);
6381 "%s.activity_count", buf);
6386 "%s.activity_tgt", buf);
6390 "%s.changed_from", buf);
6392 "%s.changed_from_count", buf);
6397 "%s.changed_from_tgt", buf);
6401 "%s.done_moving", buf);
6407 "%s.battlegroup", buf);
6422 "%s.server_side_agent", buf);
6430 "%s.ord_city", buf);
6433 "%s.paradropped", buf);
6436 "%s.transported_by", buf);
6439 "%s.carrying", buf);
6445 "%s.action_decision", buf);
6453 "%s.action_decision_tile_x", buf);
6455 "%s.action_decision_tile_y", buf);
6459 "%s.action_decision_tile_x", buf);
6461 "%s.action_decision_tile_y", buf);
6469 char orders_buf[
len + 1], dir_buf[
len + 1];
6470 char act_buf[
len + 1];
6471 int action_buf[
len];
6473 int sub_tgt_vec[
len];
6479 "%s.orders_index", buf);
6481 "%s.orders_repeat", buf);
6483 "%s.orders_vigilant", buf);
6485 for (j = 0; j <
len; j++) {
6490 sub_tgt_vec[j] = -1;
6511 orders_buf[
len] = dir_buf[
len] = act_buf[
len] =
'\0';
6518 "%s.action_vec", buf);
6521 for (j = last_order; j < longest_order; j++) {
6529 for (j = last_order; j < longest_order; j++) {
6534 "%s.sub_tgt_vec", buf);
6537 for (j = last_order; j < longest_order; j++) {
6558 for (j = 1; j < longest_order; j++) {
6564 for (j = 1; j < longest_order; j++) {
6570 for (j = 1; j < longest_order; j++) {
6598 loading->
file, 0,
"player%d.attribute_v2_block_length", plrno);
6601 log_sg(
"player%d.attribute_v2_block_length=%d too small", plrno,
6604 }
else if (MAX_ATTRIBUTE_BLOCK < plr->attribute_block.length) {
6605 log_sg(
"player%d.attribute_v2_block_length=%d too big (max %d)",
6612#ifndef FREECIV_NDEBUG
6613 size_t actual_length;
6618 "player%d.attribute_v2_block_length_quoted",
6622 "player%d.attribute_v2_block_parts", plrno),
6628 for (part_nr = 0; part_nr <
parts; part_nr++) {
6629 const char *current =
6631 "player%d.attribute_v2_block_data.part%d",
6634 log_sg(
"attribute_v2_block_parts=%d actual=%d",
parts, part_nr);
6637 log_debug(
"attribute_v2_block_length_quoted=%d"
6638 " have=" SIZE_T_PRINTF
" part=" SIZE_T_PRINTF,
6639 quoted_length, strlen(quoted), strlen(current));
6640 fc_assert(strlen(quoted) + strlen(current) <= quoted_length);
6641 strcat(quoted, current);
6644 "attribute_v2_block_length_quoted=%d"
6645 " actual=" SIZE_T_PRINTF,
6646 quoted_length, strlen(quoted));
6648#ifndef FREECIV_NDEBUG
6675#define PART_SIZE (3*256)
6676#define PART_ADJUST (3)
6680 int current_part_nr;
6683 char *quoted_at = strchr(quoted,
':');
6684 size_t bytes_left = strlen(quoted);
6685 size_t bytes_at_colon = 1 + (quoted_at - quoted);
6686 size_t bytes_adjust = bytes_at_colon %
PART_ADJUST;
6689 "player%d.attribute_v2_block_length", plrno);
6691 "player%d.attribute_v2_block_length_quoted", plrno);
6696 if ((bytes_left - bytes_adjust) >
PART_SIZE) {
6704 "player%d.attribute_v2_block_parts", plrno);
6707 size_t size_of_current_part =
PART_SIZE + bytes_adjust;
6710 memcpy(
part, quoted, size_of_current_part);
6711 part[size_of_current_part] =
'\0';
6713 "player%d.attribute_v2_block_data.part%d",
6715 bytes_left -= size_of_current_part;
6716 quoted_at = "ed[size_of_current_part];
6717 current_part_nr = 1;
6720 current_part_nr = 0;
6723 for (; current_part_nr <
parts; current_part_nr++) {
6724 size_t size_of_current_part =
MIN(bytes_left,
PART_SIZE);
6726 memcpy(
part, quoted_at, size_of_current_part);
6727 part[size_of_current_part] =
'\0';
6729 "player%d.attribute_v2_block_data.part%d",
6732 bytes_left -= size_of_current_part;
6733 quoted_at = "ed_at[size_of_current_part];
6751 "player%d.dc_total", plrno);
6753 bool someone_alive =
FALSE;
6760 if (pteam_member->is_alive) {
6761 someone_alive =
TRUE;
6766 if (!someone_alive) {
6772 if (-1 == total_ncities
6775 "game.save_private_map")) {
6790 if (NULL != pcity) {
6804 "player%d.map_t%04d", plrno);
6811 loading->
file,
"player%d.map_e%02d_%04d", plrno, j);
6838 const char *ptr = buffer;
6839 const char *ptr2 = buffer2;
6842 "Savegame corrupt - map line %d not found.", y);
6849 scanin(&ptr,
",", token,
sizeof(token));
6851 "Savegame corrupt - map size not correct.");
6852 if (strcmp(token,
"-") == 0) {
6856 "Savegame corrupt - got tile owner=%s in (%d, %d).",
6861 scanin(&ptr2,
",", token2,
sizeof(token2));
6863 "Savegame corrupt - map size not correct.");
6864 if (strcmp(token2,
"-") == 0) {
6868 "Savegame corrupt - got extras owner=%s in (%d, %d).",
6877 for (i = 0; i < 4; i++) {
6883 loading->
file,
"player%d.map_u%02d_%04d", plrno, i);
6888 loading->
file,
"player%d.map_u%02d_%04d", plrno, i);
6893 for (i = 0; i < total_ncities; i++) {
6896 fc_snprintf(buf,
sizeof(buf),
"player%d.dc%d", plrno, i);
6905 log_sg(
"Skipping seen city %d for player %d.", i, plrno);
6906 if (pdcity != NULL) {
6920 if (NULL != pcity) {
6938 const char *citystr)
6944 const char *stylename;
6945 enum capital_type cap;
6956 "%s invalid tile (%d,%d)", citystr,
nat_x,
nat_y);
6963 "%s has invalid owner (%d); skipping.", citystr,
id);
6969 "%s has invalid id (%d); skipping.", citystr,
id);
6972 "%s.size", citystr),
6976 "Invalid city size: %d; set to %d.",
size, city_size);
6984 "Invalid length of '%s.improvements' ("
6985 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
6989 "Undefined value '%c' within '%s.improvements'.",
6992 if (
str[i] ==
'1') {
7002 "%s.name", citystr);
7004 if (vname != NULL) {
7009 "%s.occupied", citystr);
7011 "%s.walls", citystr);
7013 "%s.happy", citystr);
7015 "%s.unhappy", citystr);
7017 "%s.style", citystr);
7018 if (stylename != NULL) {
7023 if (pdcity->
style < 0) {
7028 "%s.city_image", citystr);
7031 "%s.capital", citystr),
7034 if (capital_type_is_valid(cap)) {
7037 pdcity->
capital = CAPITAL_NOT;
7062 saving->
file,
"player%d.map_t%04d", plrno);
7077 if (plrtile == NULL || plrtile->
owner == NULL) {
7083 strcat(line, token);
7101 if (plrtile == NULL || plrtile->
extras_owner == NULL) {
7107 strcat(line, token);
7122 for (l = 0; l < 4; l++) {
7134 saving->
file,
"player%d.map_e%02d_%04d", plrno, j);
7138 for (i = 0; i < 4; i++) {
7143 saving->
file,
"player%d.map_u%02d_%04d", plrno, i);
7150 char impr_buf[
B_LAST + 1];
7153 fc_snprintf(buf,
sizeof(buf),
"player%d.dc%d", plrno, i);
7169 "%s.occupied", buf);
7188 "Invalid size of the improvement vector (%s.improvements: "
7189 SIZE_T_PRINTF
" < " SIZE_T_PRINTF
" ).",
7190 buf, strlen(impr_buf),
sizeof(impr_buf));
7192 if (pdcity->
name != NULL) {
7217 int *vlist_research;
7219 vlist_research = NULL;
7230 for (i = 0; i < count; i++) {
7232 "research.r%d.number", i),
7236 "Invalid research number %d in 'research.r%d.number'",
7240 "research.r%d.goal", i);
7243 "research.r%d.techs", i),
7247 "research.r%d.futuretech", i),
7251 "research.r%d.bulbs", i),
7255 "research.r%d.bulbs_before", i),
7258 "research.r%d.saved", i);
7260 "research.r%d.now", i);
7263 "research.r%d.got_tech", i),
7270 "research.r%d.got_tech_multi",
7276 "Invalid length of 'research.r%d.done' ("
7277 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
7281 "Undefined value '%c' within 'research.r%d.done'.",
7284 if (
str[j] ==
'1') {
7300 "research.r%d.vbs", i);
7302 for (tn = 0; tn < count_res; tn++) {
7305 if (padvance != NULL) {
7307 = vlist_research[tn];
7327 int *vlist_research;
7329 vlist_research = NULL;
7336 "research.r%d.number", i);
7338 i, presearch->tech_goal);
7340 "research.r%d.techs", i);
7342 "research.r%d.futuretech", i);
7344 "research.r%d.bulbs_before", i);
7348 vlist_research[j] = presearch->inventions[j].bulbs_researched_saved;
7352 "research.r%d.vbs", i);
7353 if (vlist_research) {
7354 free(vlist_research);
7358 i, presearch->researching_saved);
7360 "research.r%d.bulbs", i);
7362 i, presearch->researching);
7364 "research.r%d.got_tech", i);
7366 "research.r%d.got_tech_multi", i);
7372 == TECH_KNOWN ?
'1' :
'0');
7430 "treaty%d.plr0", tidx)) != NULL ;
7442 if (p0 == NULL || p1 == NULL) {
7443 log_error(
"Treaty between unknown players %s and %s", plr0, plr1);
7448 treaty_list_prepend(
treaties, ptreaty);
7451 "treaty%d.clause%d.type",
7452 tidx, cidx)) != NULL ;
7457 if (!clause_type_is_valid(
type)) {
7458 log_error(
"Invalid clause type \"%s\"", ct);
7460 struct player *pgiver = NULL;
7470 log_error(
"Clause giver %s is not participant of the treaty"
7471 "between %s and %s", plrx, plr0, plr1);
7474 if (pgiver != NULL) {
7478 "treaty%d.clause%d.value",
7489 "treaty%d.accept0", tidx);
7491 "treaty%d.accept1", tidx);
7508 fc_snprintf(tpath,
sizeof(tpath),
"treaty%d", tidx++);
7518 fc_snprintf(cpath,
sizeof(cpath),
"%s.clause%d", tpath, cidx++);
7584 int mapdef_count, i;
7596 log_verbose(
"Saved map image definitions: %d.", mapdef_count);
7598 if (0 >= mapdef_count) {
7602 for (i = 0; i < mapdef_count; i++) {
7607 log_verbose(
"[Mapimg %4d] Missing definition.", i);
7612 log_error(
"Invalid map image definition %4d: %s.", i, p);
7663 log_verbose(
"Max players lower than current players, fixing");
7672 log_sg(
"Removing %s unferried %s in %s at (%d, %d)",
7709 log_error(
"[city id: %d] Bad worker task %d.",
7710 pcity->id, ptask->act);
7711 worker_task_list_remove(pcity->task_reqs, ptask);
7725 log_error(
"[city id: %d] Unused worked tile at (%d, %d).",
7736 if (presearch->researching !=
A_UNSET
7740 != TECH_PREREQS_KNOWN))) {
7741 log_sg(
_(
"%s had invalid researching technology."),
7743 presearch->researching =
A_UNSET;
7745 if (presearch->tech_goal !=
A_UNSET
7751 log_sg(
_(
"%s had invalid technology goal."),
7753 presearch->tech_goal =
A_UNSET;
7758 if (presearch->techs_researched !=
techs) {
7760 _(
"%s had finished researches count wrong."),
7762 presearch->techs_researched =
techs;
7768 int unique_count[
U_LAST];
7770 memset(unique_count, 0,
sizeof(unique_count));
7778 log_sg(
_(
"%s has multiple units of type %s though it should be possible "
7779 "to have only one."),
7800 if (0 == strlen(
server.game_identifier)
7804 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)