156#define SAVE_MAP_CHAR(ptile, GET_XY_CHAR, secfile, secpath, ...) \
158 char _line[wld.map.xsize + 1]; \
159 int _nat_x, _nat_y; \
161 for (_nat_y = 0; _nat_y < wld.map.ysize; _nat_y++) { \
162 for (_nat_x = 0; _nat_x < wld.map.xsize; _nat_x++) { \
163 struct tile *ptile = native_pos_to_tile(&(wld.map), _nat_x, _nat_y); \
164 fc_assert_action(ptile != NULL, continue); \
165 _line[_nat_x] = (GET_XY_CHAR); \
166 sg_failure_ret(fc_isprint(_line[_nat_x] & 0x7f), \
167 "Trying to write invalid map data at position " \
168 "(%d, %d) for path %s: '%c' (%d)", _nat_x, _nat_y, \
169 secpath, _line[_nat_x], _line[_nat_x]); \
171 _line[wld.map.xsize] = '\0'; \
172 secfile_insert_str(secfile, _line, secpath, ## __VA_ARGS__, _nat_y); \
203#define LOAD_MAP_CHAR(ch, ptile, SET_XY_CHAR, secfile, secpath, ...) \
205 int _nat_x, _nat_y; \
206 bool _printed_warning = FALSE; \
207 for (_nat_y = 0; _nat_y < wld.map.ysize; _nat_y++) { \
208 const char *_line = secfile_lookup_str(secfile, secpath, \
209 ## __VA_ARGS__, _nat_y); \
210 if (NULL == _line) { \
212 fc_snprintf(buf, sizeof(buf), secpath, ## __VA_ARGS__, _nat_y); \
213 log_verbose("Line not found='%s'", buf); \
214 _printed_warning = TRUE; \
216 } else if (strlen(_line) != wld.map.xsize) { \
218 fc_snprintf(buf, sizeof(buf), secpath, ## __VA_ARGS__, _nat_y); \
219 log_verbose("Line too short (expected %d got " SIZE_T_PRINTF \
220 ")='%s'", wld.map.xsize, strlen(_line), buf); \
221 _printed_warning = TRUE; \
224 for (_nat_x = 0; _nat_x < wld.map.xsize; _nat_x++) { \
225 const char ch = _line[_nat_x]; \
226 struct tile *ptile = native_pos_to_tile(&(wld.map), _nat_x, _nat_y); \
230 if (_printed_warning) { \
232 log_sg(_("Saved game contains incomplete map data. This can" \
233 " happen with old saved games, or it may indicate an" \
234 " invalid saved game file. Proceed at your own risk.")); \
239#define halfbyte_iterate_extras(e, num_extras_types) \
242 for (e = 0; 4 * e < (num_extras_types); e++) {
244#define halfbyte_iterate_extras_end \
249#define halfbyte_iterate_special(s, num_specials_types) \
251 enum tile_special_type s; \
252 for (s = 0; 4 * s < (num_specials_types); s++) {
254#define halfbyte_iterate_special_end \
259#define halfbyte_iterate_bases(b, num_bases_types) \
262 for (b = 0; 4 * b < (num_bases_types); b++) {
264#define halfbyte_iterate_bases_end \
269#define halfbyte_iterate_roads(r, num_roads_types) \
272 for (r = 0; 4 * r < (num_roads_types); r++) {
274#define halfbyte_iterate_roads_end \
280#define ORDER_OLD_BUILD_CITY (-1)
281#define ORDER_OLD_DISBAND (-2)
282#define ORDER_OLD_BUILD_WONDER (-3)
283#define ORDER_OLD_TRADE_ROUTE (-4)
284#define ORDER_OLD_HOMECITY (-5)
290static enum direction8
char2dir(
char dir);
293static int unquote_block(
const char *
const quoted_,
void *dest,
296 struct worklist *pwl,
const char *path, ...);
301 bool rivers_overlay);
307 const char *path,
int plrno);
330 bool rivers_overlay);
345 struct city *pcity,
const char *citystr,
346 int wlist_max_length);
350 const char *citystr);
355 const char *unitstr);
365 const char *citystr);
390 bool was_send_city_suppressed, was_send_tile_suppressed;
458 struct loaddata *loading = calloc(1,
sizeof(*loading));
599 return DIR8_SOUTHWEST;
603 return DIR8_SOUTHEAST;
609 return DIR8_NORTHWEST;
613 return DIR8_NORTHEAST;
617 return direction8_invalid();
628 case ACTIVITY_POLLUTION:
630 case ACTIVITY_OLD_ROAD:
634 case ACTIVITY_IRRIGATE:
636 case ACTIVITY_FORTIFIED:
638 case ACTIVITY_FORTRESS:
640 case ACTIVITY_SENTRY:
642 case ACTIVITY_OLD_RAILROAD:
644 case ACTIVITY_PILLAGE:
648 case ACTIVITY_EXPLORE:
650 case ACTIVITY_TRANSFORM:
652 case ACTIVITY_AIRBASE:
654 case ACTIVITY_FORTIFYING:
656 case ACTIVITY_FALLOUT:
660 case ACTIVITY_GEN_ROAD:
662 case ACTIVITY_CONVERT:
664 case ACTIVITY_UNKNOWN:
665 case ACTIVITY_PATROL_UNUSED:
666 case ACTIVITY_CULTIVATE:
682 enum unit_activity a;
684 for (a = 0; a < ACTIVITY_LAST; a++) {
687 if (activity == achar) {
693 return ACTIVITY_LAST;
704 int i, length, parsed, tmp;
706 const char *quoted = quoted_;
708 parsed = sscanf(quoted,
"%d", &length);
711 log_error(
_(
"Syntax error in attribute block."));
715 if (length > dest_length) {
719 quoted = strchr(quoted,
':');
721 if (quoted == NULL) {
722 log_error(
_(
"Syntax error in attribute block."));
728 for (i = 0; i < length; i++) {
729 tmp = strtol(quoted, &endptr, 16);
731 if ((endptr - quoted) != 2
733 || (tmp & 0xff) != tmp) {
734 log_error(
_(
"Syntax error in attribute block."));
738 ((
unsigned char *) dest)[i] = tmp;
750 struct worklist *pwl,
const char *path, ...)
766 "%s.wl_length", path_str);
768 for (i = 0; i < pwl->
length; i++) {
776 if (pwl->
entries[i].
kind == universals_n_invalid()) {
777 log_sg(
"%s.wl_value%d: unknown \"%s\" \"%s\".", path_str, i, kind,
785 for (; i < wlist_max_length; i++) {
821 if (!pch || ch ==
'\0') {
822 log_sg(
"Unknown hex value: '%c' (%d)", ch, ch);
828 for (i = 0; i < 4; i++) {
831 if (pextra == NULL) {
855 if (!pch || ch ==
'\0') {
856 log_sg(
"Unknown hex value: '%c' (%d)", ch, ch);
862 for (i = 0; i < 4; i++) {
883 if (bin & (1 << i)) {
907 enum extra_cause cause = EC_COUNT;
915 cause = EC_IRRIGATION;
921 cause = EC_POLLUTION;
934 if (cause != EC_COUNT) {
950 && (cause != EC_BASE || pterr->
base_time != 0)
951 && (cause != EC_ROAD || pterr->
road_time != 0)) {
990 if (!pch || ch ==
'\0') {
991 log_sg(
"Unknown hex value: '%c' (%d)", ch, ch);
997 for (i = 0; i < 4; i++) {
1000 if (pbase == NULL) {
1003 if (bin & (1 << i)) {
1019 const char *pch = strchr(
hex_chars, ch);
1021 if (!pch || ch ==
'\0') {
1022 log_sg(
"Unknown hex value: '%c' (%d)", ch, ch);
1028 for (i = 0; i < 4; i++) {
1031 if (proad == NULL) {
1034 if (bin & (1 << i)) {
1065 if (pterrain->identifier == ch) {
1070 log_fatal(
"Unknown terrain identifier '%c' in savegame.", ch);
1081 const char *path,
int plrno)
1083 char path_with_name[128];
1087 fc_snprintf(path_with_name,
sizeof(path_with_name),
1108 "%s: unknown technology \"%s\".", path_with_name,
name);
1124 "savefile.rulesetdir");
1132 if (version >= 30) {
1141 log_verbose(
"Savegame specified ruleset '%s'. Really loading '%s'.",
1157 const char *terr_name;
1174 "savefile.last_updated_as_year");
1179 "savefile.improvement_size");
1183 "savefile.improvement_vector");
1185 "Failed to load improvement order: %s",
1192 "savefile.technology_size");
1196 "savefile.technology_vector");
1198 "Failed to load technology order: %s",
1205 "savefile.activities_size");
1209 "savefile.activities_vector");
1211 "Failed to load activity order: %s",
1218 "savefile.trait_size");
1222 "savefile.trait_vector");
1224 "Failed to load trait order: %s",
1231 "savefile.extras_size");
1233 const char **modname;
1238 "savefile.extras_vector");
1240 "Failed to load extras order: %s",
1243 "Number of extras defined by the ruleset (= %d) are "
1244 "lower than the number in the savefile (= %d).",
1247 nmod = 4 * ((loading->
extra.
size + 3) / 4);
1249 for (j = 0; j < loading->
extra.
size; j++) {
1253 for (; j < nmod; j++) {
1261 "savefile.multipliers_size");
1263 const char **modname;
1267 "savefile.multipliers_vector");
1269 "Failed to load multipliers order: %s",
1278 log_verbose(
"Multiplier \"%s\" in savegame but not in ruleset, "
1279 "discarding", modname[j]);
1288 "savefile.specials_size");
1290 const char **modname;
1295 "savefile.specials_vector");
1297 "Failed to load specials order: %s",
1325 for (; j < nmod; j++) {
1333 "savefile.bases_size");
1335 const char **modname;
1340 "savefile.bases_vector");
1342 "Failed to load bases order: %s",
1345 nmod = 4 * ((loading->
base.
size + 3) / 4);
1347 for (j = 0; j < loading->
base.
size; j++) {
1352 "Unknown base type %s in savefile.",
1355 if (pextra != NULL) {
1362 for (; j < nmod; j++) {
1370 "savefile.roads_size");
1372 const char **modname;
1377 "savefile.roads_vector");
1379 "Failed to load roads order: %s",
1382 "Number of roads defined by the ruleset (= %d) are "
1383 "lower than the number in the savefile (= %d).",
1386 nmod = 4 * ((loading->
road.
size + 3) / 4);
1388 for (j = 0; j < loading->
road.
size; j++) {
1391 if (pextra != NULL) {
1398 for (; j < nmod; j++) {
1406 "savefile.specialists_size");
1408 const char **modname;
1413 "savefile.specialists_vector");
1415 "Failed to load specialists order: %s",
1418 "Number of specialists defined by the ruleset (= %d) are "
1419 "lower than the number in the savefile (= %d).",
1431 for (; j < nmod; j++) {
1439 "savefile.diplstate_type_size");
1442 "Failed to load diplomatic state type order: %s",
1446 const char **modname;
1450 "savefile.diplstate_type_vector");
1455 for (j = 0; j < loading->
ds_t.
size; j++) {
1456 loading->
ds_t.
order[j] = diplstate_type_by_name(modname[j],
1468 for (j = 0; j < i; j++) {
1474 pterr->identifier_load =
'\0';
1479 "savefile.terrident%d.name", i)) != NULL) {
1482 if (pterr != NULL) {
1484 "savefile.terrident%d.identifier", i);
1488 log_error(
"Identifier for unknown terrain type %s.", terr_name);
1495 if (pterr != pterr2 && pterr->identifier_load !=
'\0') {
1496 sg_failure_ret((pterr->identifier_load != pterr2->identifier_load),
1497 "%s and %s share a saved identifier",
1521 "ruledata.government%d.name", i));
1527 "ruledata.government%d.changes", i);
1549 sg_failure_ret(20299 <= game_version,
"Saved game is too old, at least "
1550 "version 2.2.99 required.");
1558 "game.server_state");
1567 "game.meta_patches");
1576 "game.meta_server"));
1595 if (
level != NULL) {
1610 "game.skill_level"));
1617 "game.phase_mode_stored");
1631 "game.timeoutintinc");
1637 "game.timeoutincmult");
1640 "game.timeoutcounter");
1669 "game.global_advances");
1672 "Invalid length of 'game.global_advances' ("
1673 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
1677 "Undefined value '%c' within 'game.global_advances'.",
1679 if (
str[i] ==
'1') {
1683 if (padvance != NULL) {
1734 for (i = 0; i < 8; i++) {
1737 sscanf(
str,
"%8x %8x %8x %8x %8x %8x %8x", &loading->
rstate.
v[7*i],
1781 bool lake_flood_default;
1802 if (buf[0] !=
'\0') {
1807 "scenario.authors");
1808 if (buf[0] !=
'\0') {
1815 "scenario.description");
1816 if (buf[0] !=
'\0') {
1828 "scenario.startpos_nations");
1832 "scenario.prevent_new_cities");
1833 if (loading->
version < 20599) {
1836 lake_flood_default =
FALSE;
1840 lake_flood_default =
TRUE;
1844 "scenario.lake_flooding");
1847 "scenario.handmade");
1850 "scenario.allow_ai_type_fallback");
1856 "Invalid scenario definition (server state '%s' and "
1997 const char *spec_sprite;
2006 if (NULL != ptile->spec_sprite) {
2007 ptile->spec_sprite =
fc_strdup(spec_sprite);
2009 if (label != NULL) {
2026 loading->
file,
"map.e%02d_%04d", j);
2042 loading->
file,
"map.b%02d_%04d", j);
2058 loading->
file,
"map.r%02d_%04d", j);
2066 bool rivers_overlay)
2089 loading->
file,
"map.spe%02d_%04d", j);
2102 loading->
file,
"map.res%04d");
2106 if (NULL == ptile->resource) {
2128 const char SEPARATOR =
'#';
2129 const char *nation_names;
2132 int i, startpos_count;
2140 if (0 == startpos_count) {
2145 for (i = 0; i < startpos_count; i++) {
2148 "map.startpos%d.y", i)) {
2149 log_sg(
"Warning: Undefined coordinates for startpos %d", i);
2154 if (NULL == ptile) {
2155 log_error(
"Start position native coordinates (%d, %d) do not exist "
2161 "map.startpos%d.exclude", i);
2166 "map.startpos%d.nations", i);
2167 if (NULL != nation_names &&
'\0' != nation_names[0]) {
2168 const size_t size = strlen(nation_names) + 1;
2169 char buf[
size], *start, *end;
2171 memcpy(buf, nation_names,
size);
2172 for (start = buf - 1; NULL != start; start = end) {
2174 if ((end = strchr(start, SEPARATOR))) {
2195 log_verbose(
"Number of starts (%d) are lower than rules.max_players "
2196 "(%d), lowering rules.max_players.",
2215 struct player *eowner = NULL;
2228 "map.owner%04d", y);
2230 "map.source%04d", y);
2232 "map.eowner%04d", y);
2233 const char *ptr1 = buffer1;
2234 const char *ptr2 = buffer2;
2235 const char *ptr3 = buffer3;
2250 scanin(&ptr1,
",", token1,
sizeof(token1));
2252 "Map size not correct (map.owner%d).", y);
2253 if (strcmp(token1,
"-") == 0) {
2257 "Got map owner %s in (%d, %d).", token1, x, y);
2261 scanin(&ptr2,
",", token2,
sizeof(token2));
2263 "Map size not correct (map.source%d).", y);
2264 if (strcmp(token2,
"-") == 0) {
2268 "Got map source %s in (%d, %d).", token2, x, y);
2273 scanin(&ptr3,
",", token3,
sizeof(token3));
2275 "Map size not correct (map.eowner%d).", y);
2276 if (strcmp(token3,
"-") == 0) {
2280 "Got base owner %s in (%d, %d).", token3, x, y);
2305 "City worked map not loaded!");
2313 const char *ptr = buffer;
2316 "Savegame corrupt - map line %d not found.", y);
2322 scanin(&ptr,
",", token,
sizeof(token));
2324 "Savegame corrupt - map size not correct.");
2325 if (strcmp(token,
"-") == 0) {
2329 "Savegame corrupt - got tile worked by city "
2330 "id=%s in (%d, %d).", token, x, y);
2353 "game.save_known")) {
2358 for (l = 0; l <
lines; l++) {
2359 for (j = 0; j < 8; j++) {
2360 for (i = 0; i < 4; i++) {
2367 loading->
file,
"map.k%02d_%04d", l * 8 + j);
2410 bool shuffle_loaded =
TRUE;
2423 "players.destroyed_wonders");
2426 "Invalid length for 'players.destroyed_wonders' ("
2427 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
")",
2431 "Undefined value '%c' within "
2432 "'players.destroyed_wonders'.",
str[k]);
2434 if (
str[k] ==
'1') {
2447 "players.identity_number_used");
2476 log_sg(
"Game has started, yet player %d has no color defined.",
2480 log_verbose(
"No color defined for player %d.", pslot_id);
2515 "player%d.multiplier%d.val",
2521 log_verbose(
"Player %d had illegal value for multiplier \"%s\": "
2522 "was %d, clamped to %d", pslot_id,
2530 "player%d.multiplier%d.target",
2536 log_verbose(
"Player %d had illegal value for multiplier_target "
2537 "\"%s\": was %d, clamped to %d", pslot_id,
2550 "player%d.border_vision",
2557 "(%d) from the loaded game does not match the number of "
2569 "Invalid team definition for player %s (nb %d).",
2585 "players.shuffled_player_%d", 0) >= 0) {
2588 int shuffled_players[
slots];
2589 bool shuffled_player_set[
slots];
2591 for (i = 0; i <
slots; i++) {
2593 shuffled_player_set[i] =
FALSE;
2596 shuffled_players[i] = -1;
2600 for (i = 0; i < plrcount; i++) {
2603 "players.shuffled_player_%d", i);
2605 if (shuffle == -1) {
2606 log_sg(
"Missing player shuffle information (index %d) "
2607 "- reshuffle player list!", i);
2608 shuffle_loaded =
FALSE;
2610 }
else if (shuffled_player_set[shuffle]) {
2611 log_sg(
"Player shuffle %d used two times "
2612 "- reshuffle player list!", shuffle);
2613 shuffle_loaded =
FALSE;
2617 shuffled_player_set[shuffle] =
TRUE;
2620 shuffled_players[i] = shuffle;
2623 if (shuffle_loaded) {
2625 int shuffle_index = plrcount;
2627 for (i = 0; i <
slots; i++) {
2628 if (!shuffled_player_set[i]) {
2629 shuffled_players[shuffle_index++] = i;
2634 "Invalid player shuffle data!");
2642 log_debug(
"[load shuffle] id: %3d => slot: %3d | slot %3d: %s",
2643 plrid, shuffled_players[plrid], plrid,
2644 shuffled_player_set[plrid] ?
"is used" :
"-");
2653 if (!shuffle_loaded) {
2683 if (
is_ai(pplayer)) {
2684 log_normal(
_(
"%s has been added as %s level AI-controlled player "
2686 ai_level_translated_name(pplayer->ai_common.skill_level),
2689 log_normal(
_(
"%s has been added as human player."),
2713 log_sg(
_(
"%s had invalid nation; changing to %s."),
2729 log_sg(
"Illegal alliance structure detected: "
2730 "%s alliance to %s reduced to peace treaty.",
2744 pcity->server.illness
2746 &(pcity->illness_trade), NULL);
2772 BV_CLR_ALL(pplayer->server.really_gives_vision);
2783 "player%d.diplstate%d.gives_shared_vision", plr1, plr2)) {
2795 if (pplayer1 != pplayer2
2799 _(
"%s did not give shared vision to team member %s."),
2805 _(
"%s did not give shared vision to team member %s."),
2825 log_sg(
"%s doing illegal activity in savegame!",
2827 log_sg(
"Activity: %s, Target: %s, Tile: (%d, %d), Terrain: %s",
2862 const char *barb_str;
2874 "player%d.username", plrno));
2876 "player%d.unassigned_user", plrno),
2880 "player%d.orig_username",
2884 "player%d.ranked_username",
2887 "player%d.unassigned_ranked", plrno),
2890 "player%d.delegation_username",
2900 for (i = 0; i < nval; i++) {
2901 const char *sval = slist[i];
2902 enum plr_flag_id fid = plr_flag_id_by_name(sval,
fc_strcasecmp);
2904 sg_failure_ret(plr_flag_id_is_valid(fid),
"Invalid player flag \"%s\".", sval);
2913 if (plr->
nation != NULL) {
2921 sg_failure_ret(gov != NULL,
"Player%d: unsupported government \"%s\".",
2927 "player%d.target_government_name", plrno);
2935 "player%d.revolution_finishes", plrno);
2939 "player%d.got_first_city", plrno),
2952 fc_snprintf(buf,
sizeof(buf),
"player%d.diplstate%d", plrno, i);
2956 if (unconverted >= 0 && unconverted < loading->ds_t.size) {
2960 log_sg(
"No valid diplomatic state type between players %d and %d",
2968 if (unconverted >= 0 && unconverted < loading->ds_t.size) {
2972 log_sg(
"No valid diplomatic max_state between players %d and %d",
2980 "%s.first_contact_turn", buf);
2985 "%s.has_reason_to_cancel", buf);
2988 "%s.contact_turns_left", buf);
3002 fc_snprintf(buf,
sizeof(buf),
"player%d.ai%d", plrno,
3019 "player%d.ai.level", plrno);
3020 if (
level != NULL) {
3035 "player%d.ai.skill_level",
3040 "player%d.ai.barb_type", plrno);
3044 log_sg(
"Player%d: Invalid barbarian type \"%s\". "
3045 "Changed to \"None\".", plrno, barb_str);
3072 if (style == NULL) {
3074 log_sg(
"Player%d: unsupported city_style_name \"%s\". "
3081 "player%d.idle_turns", plrno),
3084 "player%d.is_male", plrno);
3086 "player%d.is_alive", plrno),
3089 "player%d.turns_alive", plrno),
3092 "player%d.last_war", plrno),
3095 "player%d.phase_done", plrno);
3097 "player%d.gold", plrno),
3100 "player%d.rates.tax", plrno),
3103 "player%d.rates.science", plrno),
3106 "player%d.rates.luxury", plrno),
3110 "player%d.research.bulbs_last_turn", plrno);
3114 for (i = 0; i < loading->
trait.
size; i++) {
3117 if (trait_is_valid(tr)) {
3126 "player%d.trait%d.mod", plrno, i),
3138 "player%d.achievement_count", plrno);
3141 for (i = 0; i < count; i++) {
3147 "player%d.achievement%d.name", plrno, i);
3151 "Unknown achievement \"%s\".",
name);
3154 "player%d.achievement%d.first",
3159 "Multiple players listed as first to get achievement \"%s\".",
3174 "score%d.happy", plrno);
3177 "score%d.content", plrno);
3180 "score%d.unhappy", plrno);
3183 "score%d.angry", plrno);
3194 "score%d.specialists%d", plrno, i);
3199 "score%d.wonders", plrno);
3202 "score%d.techs", plrno);
3205 "score%d.techout", plrno);
3208 "score%d.landarea", plrno);
3211 "score%d.settledarea", plrno);
3214 "score%d.population", plrno);
3217 "score%d.cities", plrno);
3220 "score%d.units", plrno);
3223 "score%d.pollution", plrno);
3226 "score%d.literacy", plrno);
3229 "score%d.bnp", plrno);
3232 "score%d.mfg", plrno);
3235 "score%d.spaceship", plrno);
3238 "score%d.units_built", plrno);
3241 "score%d.units_killed", plrno);
3244 "score%d.units_lost", plrno);
3247 "score%d.culture", plrno);
3250 "score%d.total", plrno);
3259 fc_snprintf(prefix,
sizeof(prefix),
"player%d.spaceship", plrno);
3263 "%s.state", prefix),
3269 "%s.structurals", prefix),
3272 "%s.components", prefix),
3275 "%s.modules", prefix),
3281 "%s.propulsion", prefix),
3284 "%s.habitation", prefix),
3287 "%s.life_support", prefix),
3290 "%s.solar_panels", prefix),
3297 "Undefined value '%c' within '%s.structure'.", st[i],
3300 if (!(st[i] ==
'0')) {
3306 "%s.launch_year", prefix),
3320 "Invalid length for 'player%d.lost_wonders' ("
3321 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
")",
3325 "Undefined value '%c' within "
3326 "'player%d.lost_wonders'.", plrno,
str[k]);
3328 if (
str[k] ==
'1') {
3353 int wlist_max_length = 0;
3359 "player%d.ncities", plrno),
3362 if (!plr->
is_alive && ncities > 0) {
3363 log_sg(
"'player%d.ncities' = %d for dead player!", plrno, ncities);
3373 for (i = 0; i < ncities; i++) {
3375 "player%d.c%d.wl_length",
3378 wlist_max_length =
MAX(wlist_max_length, wl_length);
3382 for (i = 0; i < ncities; i++) {
3386 fc_snprintf(buf,
sizeof(buf),
"player%d.c%d", plrno, i);
3413 city_list_append(plr->
cities, pcity);
3416 tasks_handled =
FALSE;
3417 for (i = 0; !tasks_handled; i++) {
3419 struct city *pcity = NULL;
3424 if (city_id != -1) {
3428 if (pcity != NULL) {
3442 "Unknown workertask activity %s",
str);
3446 if (strcmp(
"-",
str)) {
3450 "Unknown workertask target %s",
str);
3456 "player%d.task%d.want", plrno, i);
3458 worker_task_list_append(pcity->
task_reqs, ptask);
3460 tasks_handled =
TRUE;
3469 struct city *pcity,
const char *citystr,
3470 int wlist_max_length)
3473 const char *kind, *
name, *
str;
3474 int id, i, repair, sp_count = 0, workers = 0, value;
3477 const char *stylename;
3486 "%s has invalid center tile (%d, %d)",
3489 "%s duplicates city (%d, %d)", citystr,
nat_x,
nat_y);
3493 "%s.name", citystr));
3499 "%s.original", citystr);
3509 "Invalid city size: %d, set to %d", value,
size);
3523 "%s.traderoute%d", citystr, i);
3529 proute->
dir = RDIR_BIDIRECTIONAL;
3532 trade_route_list_append(pcity->
routes, proute);
3537 "%s.food_stock", citystr),
3540 "%s.shield_stock", citystr),
3555 "%s.anarchy", citystr),
3578 "%s.turn_last_built", citystr),
3587 "%s.currently_building: unknown \"%s\" \"%s\".",
3588 citystr, kind,
name);
3596 "%s.changed_from: unknown \"%s\" \"%s\".",
3597 citystr, kind,
name);
3601 "%s.before_change_shields", citystr);
3604 "%s.caravan_shields", citystr);
3607 "%s.disbanded_shields", citystr);
3610 "%s.last_turns_shield_surplus",
3614 "%s.style", citystr);
3615 if (stylename != NULL) {
3620 if (pcity->
style < 0) {
3635 "Invalid length of '%s.improvements' ("
3636 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
3640 "Undefined value '%c' within '%s.improvements'.",
3643 if (
str[i] ==
'1') {
3654 "No worked tiles map defined.");
3669 log_sg(
"[%s] '%s' (%d, %d) has worker outside current radius "
3690 if (NULL != pwork) {
3691 log_sg(
"[%s] city center of '%s' (%d,%d) [%d] is worked by '%s' "
3700 log_sg(
"[%s] city center of '%s' (%d,%d) [%d] is empty; repairing",
3712 log_sg(
"[%s] size mismatch for '%s' (%d,%d): size [%d] != "
3713 "(workers [%d] - free worked tiles [%d]) + specialists [%d]",
3726 for (i = 0; i < CITYO_LAST; i++) {
3744 const char *citystr)
3754 "%s.citizen%d", citystr,
3757 log_sg(
"Citizens of an invalid nation for %s (player slot %d)!",
3764 "Invalid value for citizens of player %d in %s: %d.",
3777 log_sg(
"City size and number of citizens does not match in %s "
3798 "player%d.nunits", plrno),
3800 if (!plr->
is_alive && nunits > 0) {
3801 log_sg(
"'player%d.nunits' = %d for dead player!", plrno, nunits);
3805 for (i = 0; i < nunits; i++) {
3813 fc_snprintf(buf,
sizeof(buf),
"player%d.u%d", plrno, i);
3868 struct tile *tgt_tile)
3878 return ACTION_JOIN_CITY;
3881 return ACTION_FOUND_CITY;
3885 return ACTION_HELP_WONDER;
3888 return ACTION_TRADE_ROUTE;
3896 return ACTION_DISBAND_UNIT_RECOVER;
3898 return ACTION_HOME_CITY;
3910 const char *unitstr)
3912 enum unit_activity activity;
3923 const char *facing_str;
3942 "%s.facing", unitstr);
3943 if (facing_str[0] !=
'x') {
3947 enum direction8 facing =
char2dir(facing_str[0]);
3949 if (direction8_is_valid(facing)) {
3952 log_error(
"Illegal unit orientation '%s'", facing_str);
3960 "%s.nationality", unitstr);
3968 "%s.homecity", unitstr),
FALSE,
3971 "%s.moves", unitstr),
FALSE,
3974 "%s.fuel", unitstr),
FALSE,
3977 "%s.activity", unitstr),
FALSE,
3984 "%s.born", unitstr);
3987 "%s.activity_tgt", unitstr);
3989 if (extra_id != -2) {
3990 if (extra_id >= 0 && extra_id < loading->extra.size) {
3993 }
else if (activity == ACTIVITY_IRRIGATE) {
4003 }
else if (activity == ACTIVITY_MINE) {
4019 "%s.activity_base", unitstr);
4020 if (base_id >= 0 && base_id < loading->
base.size) {
4024 "%s.activity_road", unitstr);
4025 if (road_id >= 0 && road_id < loading->
road.size) {
4032 "%s.activity_target", unitstr);
4033 if (tgt_no >= 0 && tgt_no < loading->special.size) {
4048 if (activity == ACTIVITY_OLD_ROAD) {
4049 activity = ACTIVITY_GEN_ROAD;
4051 }
else if (activity == ACTIVITY_OLD_RAILROAD) {
4052 activity = ACTIVITY_GEN_ROAD;
4061 if (activity == ACTIVITY_BASE) {
4065 log_sg(
"Cannot find base %d for %s to build",
4069 }
else if (activity == ACTIVITY_GEN_ROAD) {
4073 log_sg(
"Cannot find road %d for %s to build",
4077 }
else if (activity == ACTIVITY_PILLAGE) {
4082 }
else if (pbase != NULL) {
4084 }
else if (proad != NULL) {
4093 }
else if (activity == ACTIVITY_IRRIGATE) {
4103 }
else if (activity == ACTIVITY_MINE) {
4113 }
else if (activity == ACTIVITY_POLLUTION) {
4123 }
else if (activity == ACTIVITY_FALLOUT) {
4139 "%s.activity_count", unitstr),
FALSE,
4144 "%s.changed_from", unitstr);
4147 "%s.changed_from_tgt", unitstr);
4149 if (extra_id != -2) {
4150 if (extra_id >= 0 && extra_id < loading->extra.size) {
4160 "%s.changed_from_target", unitstr);
4163 "%s.changed_from_base", unitstr);
4166 "%s.changed_from_road", unitstr);
4168 if (road_id == -1) {
4182 if (base_id >= 0 && base_id < loading->
base.size) {
4184 }
else if (road_id >= 0 && road_id < loading->
road.size) {
4186 }
else if (cfspe !=
S_LAST) {
4237 "%s.changed_from_count", unitstr);
4244 if (activity == ACTIVITY_SENTRY) {
4263 "%s.done_moving", unitstr);
4266 "%s.battlegroup", unitstr);
4269 "%s.go", unitstr)) {
4273 "%s.goto_x", unitstr),
FALSE,
4276 "%s.goto_y", unitstr),
FALSE,
4285 log_sg(
"Unit %d on goto without goto_tile. Aborting goto.",
4301 "%s.ai", unitstr),
FALSE,
4303 if (ai_controlled) {
4311 "%s.hp", unitstr),
FALSE,
4322 "%s.paradropped", unitstr);
4339 ACT_DEC_NOTHING, action_decision,
4340 "%s.action_decision_want", unitstr);
4347 "%s.action_decision_tile_x", unitstr)
4349 "%s.action_decision_tile_y", unitstr)) {
4366 "%s.orders_length", unitstr);
4369 const char *orders_unitstr, *dir_unitstr, *act_unitstr;
4370 const char *tgt_unitstr;
4371 const char *base_unitstr = NULL;
4372 const char *road_unitstr = NULL;
4381 "%s.orders_index", unitstr);
4384 "%s.orders_repeat", unitstr);
4387 "%s.orders_vigilant", unitstr);
4391 "%s.orders_list", unitstr);
4394 "%s.dir_list", unitstr);
4397 "%s.activity_list", unitstr);
4401 if (tgt_unitstr == NULL) {
4410 for (j = 0; j <
len; j++) {
4413 if (orders_unitstr[j] ==
'\0' || dir_unitstr[j] ==
'\0'
4414 || act_unitstr[j] ==
'\0') {
4415 log_sg(
"Invalid unit orders.");
4429 && !direction8_is_valid(
order->dir))
4431 &&
order->activity == ACTIVITY_LAST)) {
4450 if (tgt_unitstr[j] !=
'?') {
4451 extra_id =
char2num(tgt_unitstr[j]);
4453 if (extra_id < 0 || extra_id >= loading->
extra.
size) {
4454 log_sg(
"Cannot find extra %d for %s to build",
4458 order->sub_target = extra_id;
4466 if (base_unitstr && base_unitstr[j] !=
'?'
4467 &&
order->activity == ACTIVITY_BASE) {
4468 base_id =
char2num(base_unitstr[j]);
4470 if (base_id < 0 || base_id >= loading->
base.
size) {
4471 log_sg(
"Cannot find base %d for %s to build",
4479 }
else if (road_unitstr && road_unitstr[j] !=
'?'
4480 &&
order->activity == ACTIVITY_GEN_ROAD) {
4481 road_id =
char2num(road_unitstr[j]);
4483 if (road_id < 0 || road_id >= loading->
road.
size) {
4484 log_sg(
"Cannot find road %d for %s to build",
4495 if (
order->activity == ACTIVITY_OLD_ROAD) {
4496 order->activity = ACTIVITY_GEN_ROAD;
4499 }
else if (
order->activity == ACTIVITY_OLD_RAILROAD) {
4500 order->activity = ACTIVITY_GEN_ROAD;
4544 "player%d.nunits", plrno),
4546 if (!plr->
is_alive && nunits > 0) {
4547 log_sg(
"'player%d.nunits' = %d for dead player!", plrno, nunits);
4551 for (i = 0; i < nunits; i++) {
4552 int id_unit, id_trans;
4562 "player%d.u%d.transported_by",
4564 if (id_trans == -1) {
4573#ifndef FREECIV_NDEBUG
4602 loading->
file, 0,
"player%d.attribute_v2_block_length", plrno);
4605 log_sg(
"player%d.attribute_v2_block_length=%d too small", plrno,
4608 }
else if (MAX_ATTRIBUTE_BLOCK < plr->attribute_block.length) {
4609 log_sg(
"player%d.attribute_v2_block_length=%d too big (max %d)",
4616#ifndef FREECIV_NDEBUG
4617 size_t actual_length;
4622 "player%d.attribute_v2_block_length_quoted",
4626 "player%d.attribute_v2_block_parts", plrno),
4632 for (part_nr = 0; part_nr <
parts; part_nr++) {
4633 const char *current =
4635 "player%d.attribute_v2_block_data.part%d",
4638 log_sg(
"attribute_v2_block_parts=%d actual=%d",
parts, part_nr);
4641 log_debug(
"attribute_v2_block_length_quoted=%d"
4642 " have=" SIZE_T_PRINTF
" part=" SIZE_T_PRINTF,
4643 quoted_length, strlen(quoted), strlen(current));
4644 fc_assert(strlen(quoted) + strlen(current) <= quoted_length);
4645 strcat(quoted, current);
4648 "attribute_v2_block_length_quoted=%d"
4649 " actual=" SIZE_T_PRINTF,
4650 quoted_length, strlen(quoted));
4652#ifndef FREECIV_NDEBUG
4672 "player%d.dc_total", plrno);
4674 bool someone_alive =
FALSE;
4681 if (pteam_member->is_alive) {
4682 someone_alive =
TRUE;
4687 if (!someone_alive) {
4694 || -1 == total_ncities
4697 "game.save_private_map")) {
4712 if (NULL != pcity) {
4726 "player%d.map_t%04d", plrno);
4732 "player%d.map_res%04d", plrno);
4742 loading->
file,
"player%d.map_e%02d_%04d", plrno, j);
4750 loading->
file,
"player%d.map_spe%02d_%04d", plrno, j);
4758 loading->
file,
"player%d.map_b%02d_%04d", plrno, j);
4768 loading->
file,
"player%d.map_r%02d_%04d", plrno, j);
4784 const char *ptr = buffer;
4785 const char *ptr2 = buffer2;
4788 "Savegame corrupt - map line %d not found.", y);
4795 scanin(&ptr,
",", token,
sizeof(token));
4797 "Savegame corrupt - map size not correct.");
4798 if (strcmp(token,
"-") == 0) {
4802 "Savegame corrupt - got tile owner=%s in (%d, %d).",
4808 scanin(&ptr2,
",", token2,
sizeof(token2));
4810 "Savegame corrupt - map size not correct.");
4811 if (strcmp(token2,
"-") == 0) {
4815 "Savegame corrupt - got extras owner=%s in (%d, %d).",
4828 for (i = 0; i < 4; i++) {
4834 loading->
file,
"player%d.map_u%02d_%04d", plrno, i);
4839 loading->
file,
"player%d.map_u%02d_%04d", plrno, i);
4844 for (i = 0; i < total_ncities; i++) {
4847 fc_snprintf(buf,
sizeof(buf),
"player%d.dc%d", plrno, i);
4856 log_sg(
"Skipping seen city %d for player %d.", i, plrno);
4857 if (pdcity != NULL) {
4871 if (NULL != pcity) {
4889 const char *citystr)
4895 const char *stylename;
4906 "%s invalid tile (%d,%d)", citystr,
nat_x,
nat_y);
4913 "%s has invalid owner (%d); skipping.", citystr,
id);
4919 "%s has invalid id (%d); skipping.", citystr,
id);
4922 "%s.size", citystr),
4926 "Invalid city size: %d; set to %d.",
size, city_size);
4934 "Invalid length of '%s.improvements' ("
4935 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
4939 "Undefined value '%c' within '%s.improvements'.",
4942 if (
str[i] ==
'1') {
4953 "%s.name", citystr);
4955 if (vname != NULL) {
4960 "%s.occupied", citystr);
4962 "%s.walls", citystr);
4964 "%s.happy", citystr);
4966 "%s.unhappy", citystr);
4968 "%s.style", citystr);
4969 if (stylename != NULL) {
4974 if (pdcity->
style < 0) {
4979 "%s.city_image", citystr);
4981 pdcity->
capital = CAPITAL_NOT;
5011 for (i = 0; i < count; i++) {
5013 "research.r%d.number", i),
5017 "Invalid research number %d in 'research.r%d.number'",
5021 "research.r%d.goal", i);
5024 "research.r%d.techs", i),
5028 "research.r%d.futuretech", i),
5032 "research.r%d.bulbs", i),
5036 "research.r%d.bulbs_before", i),
5039 "research.r%d.saved", i);
5041 "research.r%d.now", i);
5044 "research.r%d.got_tech", i),
5050 "Invalid length of 'research.r%d.done' ("
5051 SIZE_T_PRINTF
" ~= " SIZE_T_PRINTF
").",
5055 "Undefined value '%c' within 'research.r%d.done'.",
5058 if (
str[j] ==
'1') {
5109 "treaty%d.plr0", tidx)) != NULL ;
5121 if (p0 == NULL || p1 == NULL) {
5122 log_error(
"Treaty between unknown players %s and %s", plr0, plr1);
5127 treaty_list_prepend(
treaties, ptreaty);
5130 "treaty%d.clause%d.type",
5131 tidx, cidx)) != NULL ;
5136 if (!clause_type_is_valid(
type)) {
5137 log_error(
"Invalid clause type \"%s\"", ct);
5139 struct player *pgiver = NULL;
5149 log_error(
"Clause giver %s is not participant of the treaty"
5150 "between %s and %s", plrx, plr0, plr1);
5153 if (pgiver != NULL) {
5157 "treaty%d.clause%d.value",
5168 "treaty%d.accept0", tidx);
5170 "treaty%d.accept1", tidx);
5217 int mapdef_count, i;
5229 log_verbose(
"Saved map image definitions: %d.", mapdef_count);
5231 if (0 >= mapdef_count) {
5235 for (i = 0; i < mapdef_count; i++) {
5240 log_verbose(
"[Mapimg %4d] Missing definition.", i);
5245 log_error(
"Invalid map image definition %4d: %s.", i, p);
5275 log_verbose(
"Max players lower than current players, fixing");
5284 log_sg(
"Removing %s unferried %s in %s at (%d, %d)",
5321 log_error(
"[city id: %d] Bad worker task %d.",
5322 pcity->id, ptask->act);
5323 worker_task_list_remove(pcity->task_reqs, ptask);
5337 log_error(
"[city id: %d] Unused worked tile at (%d, %d).",
5348 if (presearch->researching !=
A_UNSET
5352 != TECH_PREREQS_KNOWN))) {
5353 log_sg(
_(
"%s had invalid researching technology."),
5355 presearch->researching =
A_UNSET;
5357 if (presearch->tech_goal !=
A_UNSET
5363 log_sg(
_(
"%s had invalid technology goal."),
5365 presearch->tech_goal =
A_UNSET;
5370 if (presearch->techs_researched !=
techs) {
5372 _(
"%s had finished researches count wrong."),
5374 presearch->techs_researched =
techs;
5394 if (0 == strlen(
server.game_identifier)
5398 sizeof(
server.game_identifier));
5403 int unique_count[
U_LAST];
5405 memset(unique_count, 0,
sizeof(unique_count));
5413 log_sg(
_(
"%s has multiple units of type %s though it should be possible "
5414 "to have only one."),
struct achievement * achievement_by_rule_name(const char *name)
void building_advisor(struct player *pplayer)
bool adv_data_phase_init(struct player *pplayer, bool is_new_phase)
void adv_data_phase_done(struct player *pplayer)
const char * ai_name(const struct ai_type *ai)
#define CALL_FUNC_EACH_AI(_func,...)
#define CALL_PLR_AI_FUNC(_func, _player,...)
void ai_traits_init(struct player *pplayer)
Base_type_id base_number(const struct base_type *pbase)
struct extra_type * base_extra_get(const struct base_type *pbase)
struct base_type * get_base_by_gui_type(enum base_gui_type type, const struct unit *punit, const struct tile *ptile)
struct base_type * base_by_number(const Base_type_id id)
void dbv_clr_all(struct dbv *pdbv)
bool has_capability(const char *cap, const char *capstr)
void citizens_nation_set(struct city *pcity, const struct player_slot *pslot, citizens count)
citizens citizens_count(const struct city *pcity)
void citizens_init(struct city *pcity)
void citizens_update(struct city *pcity, struct player *plr)
void city_map_radius_sq_set(struct city *pcity, int radius_sq)
void city_name_set(struct city *pcity, const char *new_name)
const char * city_name_get(const struct city *pcity)
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
void city_size_set(struct city *pcity, citizens size)
void city_add_improvement(struct city *pcity, const struct impr_type *pimprove)
void destroy_city_virtual(struct city *pcity)
int city_style_by_rule_name(const char *s)
#define cities_iterate_end
#define city_list_iterate(citylist, pcity)
#define city_tile(_pcity_)
#define cities_iterate(pcity)
#define CITY_MAP_MAX_RADIUS_SQ
static citizens city_size_get(const struct city *pcity)
#define output_type_iterate(output)
#define city_owner(_pcity_)
#define FREE_WORKED_TILES
#define city_list_iterate_end
#define city_tile_iterate(_nmap, _radius_sq, _city_tile, _tile)
#define city_tile_iterate_end
#define output_type_iterate_end
void auto_arrange_workers(struct city *pcity)
void city_repair_size(struct city *pcity, int change)
bool city_refresh(struct city *pcity)
static void road(QVariant data1, QVariant data2)
static void base(QVariant data1, QVariant data2)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
void set_ai_level_directer(struct player *pplayer, enum ai_level level)
static struct treaty_list * treaties
struct treaty_list * get_all_treaties(void)
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val, struct player *client_player)
#define IDENTITY_NUMBER_ZERO
struct unit * game_unit_by_number(int id)
void initialize_globals(void)
struct city * game_city_by_number(int id)
#define GAME_DEFAULT_TIMEOUTINTINC
#define GAME_DEFAULT_SCORETURN
#define GAME_DEFAULT_TIMEOUTINT
#define GAME_DEFAULT_TIMEOUTINCMULT
#define GAME_DEFAULT_TIMEOUTINC
#define GAME_DEFAULT_RULESETDIR
#define GAME_DEFAULT_TIMEOUTCOUNTER
#define GAME_DEFAULT_PHASE_MODE
#define GAME_HARDCODED_DEFAULT_SKILL_LEVEL
struct government * government_by_rule_name(const char *name)
void idex_register_unit(struct world *iworld, struct unit *punit)
void idex_register_city(struct world *iworld, struct city *pcity)
Impr_type_id improvement_index(const struct impr_type *pimprove)
struct impr_type * improvement_by_rule_name(const char *name)
void adv_city_free(struct city *pcity)
void adv_city_alloc(struct city *pcity)
#define fc_assert_msg(condition, message,...)
#define log_verbose(message,...)
#define fc_assert(condition)
#define log_fatal(message,...)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
#define log_normal(message,...)
#define log_error(message,...)
bool startpos_disallow(struct startpos *psp, struct nation_type *pnation)
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
struct startpos * map_startpos_new(struct tile *ptile)
void map_init_topology(struct civ_map *nmap)
void main_map_allocate(void)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
int map_startpos_count(void)
struct tile * native_pos_to_tile(const struct civ_map *nmap, int nat_x, int nat_y)
bool startpos_allow(struct startpos *psp, struct nation_type *pnation)
#define whole_map_iterate(_map, _tile)
#define index_to_native_pos(pnat_x, pnat_y, mindex)
#define whole_map_iterate_end
void assign_continent_numbers(void)
void player_map_init(struct player *pplayer)
void update_player_tile_last_seen(struct player *pplayer, struct tile *ptile)
void map_claim_ownership(struct tile *ptile, struct player *powner, struct tile *psource, bool claim_bases)
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
bool send_tile_suppression(bool now)
bool really_gives_vision(struct player *me, struct player *them)
void map_know_and_see_all(struct player *pplayer)
bool update_player_tile_knowledge(struct player *pplayer, struct tile *ptile)
void tile_claim_bases(struct tile *ptile, struct player *powner)
void map_set_known(struct tile *ptile, struct player *pplayer)
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
void change_playertile_site(struct player_tile *ptile, struct vision_site *new_site)
void map_calculate_borders(void)
void give_shared_vision(struct player *pfrom, struct player *pto)
struct player_tile * map_get_player_tile(const struct tile *ptile, const struct player *pplayer)
bool mapimg_define(const char *maparg, bool check)
bool mapimg_delete(int id)
#define fc_calloc(n, esz)
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
const char * multiplier_rule_name(const struct multiplier *pmul)
struct multiplier * multiplier_by_rule_name(const char *name)
Multiplier_type_id multiplier_index(const struct multiplier *pmul)
#define multipliers_iterate(_mul_)
#define multipliers_iterate_end
const char * nation_rule_name(const struct nation_type *pnation)
struct nation_type * nation_of_player(const struct player *pplayer)
struct nation_type * nation_by_rule_name(const char *name)
const char * nation_plural_for_player(const struct player *pplayer)
#define NO_NATION_SELECTED
void event_cache_load(struct section_file *file, const char *section)
bool player_slot_is_used(const struct player_slot *pslot)
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
struct player * player_by_number(const int player_id)
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
int player_slot_count(void)
struct player_slot * player_slot_by_number(int player_id)
int player_number(const struct player *pplayer)
enum dipl_reason pplayer_can_make_treaty(const struct player *p1, const struct player *p2, enum diplstate_type treaty)
const char * player_name(const struct player *pplayer)
int player_slot_max_used_number(void)
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
int player_slot_index(const struct player_slot *pslot)
struct player * player_by_name(const char *name)
struct city * player_city_by_number(const struct player *pplayer, int city_id)
int player_index(const struct player *pplayer)
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
struct player_slot * slots
#define players_iterate_end
@ DIPL_ALLIANCE_PROBLEM_THEM
@ DIPL_ALLIANCE_PROBLEM_US
#define players_iterate(_pplayer)
#define MAX_ATTRIBUTE_BLOCK
#define player_list_iterate(playerlist, pplayer)
static bool is_barbarian(const struct player *pplayer)
#define player_slots_iterate(_pslot)
#define player_list_iterate_end
#define players_iterate_alive_end
#define player_slots_iterate_end
#define players_iterate_alive(_pplayer)
void server_player_set_name(struct player *pplayer, const char *name)
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
int normal_player_count(void)
void player_limit_to_max_rates(struct player *pplayer)
struct nation_type * pick_a_nation(const struct nation_list *choices, bool ignore_conflicts, bool needs_startpos, enum barbarian_type barb_type)
void set_shuffled_players(int *shuffled_players)
void player_delegation_set(struct player *pplayer, const char *username)
void shuffle_players(void)
void server_remove_player(struct player *pplayer)
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
void assign_player_colors(void)
void fit_nationset_to_players(void)
RANDOM_STATE fc_rand_state(void)
void fc_rand_set_state(RANDOM_STATE state)
const char * secfile_error(void)
bool secfile_lookup_int(const struct section_file *secfile, int *ival, const char *path,...)
const char ** secfile_lookup_str_vec(const struct section_file *secfile, size_t *dim, const char *path,...)
struct entry * secfile_entry_lookup(const struct section_file *secfile, const char *path,...)
const char * secfile_lookup_str(const struct section_file *secfile, const char *path,...)
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
struct entry * secfile_entry_by_path(const struct section_file *secfile, const char *path)
struct section * secfile_section_lookup(const struct section_file *secfile, const char *path,...)
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
bool secfile_lookup_bool(const struct section_file *secfile, bool *bval, const char *path,...)
#define secfile_lookup_enum_default(secfile, defval, specenum_type, path,...)
#define secfile_entry_ignore(_sfile_, _fmt_,...)
struct history_report * history_report_get(void)
bool are_reqs_active(const struct req_context *context, const struct player *other_player, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
struct universal universal_by_rule_name(const char *kind, const char *value)
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
const char * research_name_translation(const struct research *presearch)
enum tech_state research_invention_set(struct research *presearch, Tech_type_id tech, enum tech_state value)
struct research * research_by_number(int number)
int recalculate_techs_researched(const struct research *presearch)
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
void research_update(struct research *presearch)
#define researches_iterate(_presearch)
#define researches_iterate_end
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
bool rgbcolor_load(struct section_file *file, struct rgbcolor **prgbcolor, char *path,...)
struct extra_type * road_extra_get(const struct road_type *proad)
Road_type_id road_number(const struct road_type *proad)
struct road_type * road_by_number(Road_type_id id)
struct road_type * road_by_compat_special(enum road_compat compat)
bool load_rulesets(const char *restore, const char *alt, bool compat_mode, rs_conversion_logger logger, bool act, bool buffer_script, bool load_luadata)
#define sanity_check_city(x)
struct extra_type * resource_by_identifier(const char identifier)
void set_unit_activity_road(struct unit *punit, Road_type_id road)
void sg_load_compat(struct loaddata *loading, enum sgf_version format_class)
enum ai_level ai_level_convert(int old_level)
void set_unit_activity_base(struct unit *punit, Base_type_id base)
int ascii_hex2bin(char ch, int halfbyte)
struct extra_type * special_extra_get(int spe)
enum tile_special_type special_by_rule_name(const char *name)
void sg_load_post_load_compat(struct loaddata *loading, enum sgf_version format_class)
const char * special_rule_name(enum tile_special_type type)
#define sg_check_ret(...)
#define sg_warn(condition, message,...)
#define sg_failure_ret_val(condition, _val, message,...)
#define sg_failure_ret(condition, message,...)
#define sg_regr(fixversion, message,...)
#define sg_warn_ret_val(condition, _val, message,...)
static void unit_ordering_apply(void)
static void sg_load_players_basic(struct loaddata *loading)
static struct loaddata * loaddata_new(struct section_file *file)
static void sg_load_map_known(struct loaddata *loading)
#define halfbyte_iterate_roads_end
static struct extra_type * char2resource(char c)
static void sg_load_map_owner(struct loaddata *loading)
static void sg_extras_set(bv_extras *extras, char ch, struct extra_type **idx)
static void sg_bases_set(bv_extras *extras, char ch, struct base_type **idx)
#define halfbyte_iterate_extras_end
static void sg_load_map_tiles_roads(struct loaddata *loading)
#define halfbyte_iterate_extras(e, num_extras_types)
static void sg_load_map(struct loaddata *loading)
static enum unit_orders char2order(char order)
static int unquote_block(const char *const quoted_, void *dest, int dest_length)
#define LOAD_MAP_CHAR(ch, ptile, SET_XY_CHAR, secfile, secpath,...)
static void sg_load_player_city_citizens(struct loaddata *loading, struct player *plr, struct city *pcity, const char *citystr)
static void sg_load_player_cities(struct loaddata *loading, struct player *plr)
static void sg_load_map_tiles(struct loaddata *loading)
static char activity2char(enum unit_activity activity)
static void sg_load_savefile(struct loaddata *loading)
static enum unit_activity char2activity(char activity)
static bool sg_load_player_unit(struct loaddata *loading, struct player *plr, struct unit *punit, const char *unitstr)
static bool sg_load_player_city(struct loaddata *loading, struct player *plr, struct city *pcity, const char *citystr, int wlist_max_length)
static void sg_load_settings(struct loaddata *loading)
static void sg_load_player_units(struct loaddata *loading, struct player *plr)
#define halfbyte_iterate_special(s, num_specials_types)
void savegame2_load(struct section_file *file)
static void sg_load_researches(struct loaddata *loading)
#define halfbyte_iterate_bases_end
static void sg_load_map_worked(struct loaddata *loading)
static void sg_load_random(struct loaddata *loading)
#define halfbyte_iterate_special_end
#define halfbyte_iterate_bases(b, num_bases_types)
static void sg_load_player_units_transport(struct loaddata *loading, struct player *plr)
static void sg_load_history(struct loaddata *loading)
#define ORDER_OLD_BUILD_WONDER
static void sg_load_map_tiles_specials(struct loaddata *loading, bool rivers_overlay)
static void sg_load_script(struct loaddata *loading)
static void sg_load_scenario(struct loaddata *loading)
static void sg_load_ruleset(struct loaddata *loading)
static void sg_load_game(struct loaddata *loading)
static void sg_load_player_main(struct loaddata *loading, struct player *plr)
static void sg_load_treaties(struct loaddata *loading)
static void sg_roads_set(bv_extras *extras, char ch, struct road_type **idx)
static Tech_type_id technology_load(struct section_file *file, const char *path, int plrno)
static enum direction8 char2dir(char dir)
static void sg_load_map_tiles_resources(struct loaddata *loading)
#define ORDER_OLD_BUILD_CITY
static struct terrain * char2terrain(char ch)
#define ORDER_OLD_DISBAND
static void sg_load_mapimg(struct loaddata *loading)
#define ORDER_OLD_HOMECITY
static void sg_load_player_attributes(struct loaddata *loading, struct player *plr)
static void sg_load_ruledata(struct loaddata *loading)
static void sg_load_player_vision(struct loaddata *loading, struct player *plr)
static void worklist_load(struct section_file *file, int wlist_max_length, struct worklist *pwl, const char *path,...)
static bool sg_load_player_vision_city(struct loaddata *loading, struct player *plr, struct vision_site *pdcity, const char *citystr)
static void sg_load_map_startpos(struct loaddata *loading)
static void loaddata_destroy(struct loaddata *loading)
static void sg_load_players(struct loaddata *loading)
#define ORDER_OLD_TRADE_ROUTE
static void sg_load_map_tiles_extras(struct loaddata *loading)
static void sg_load_sanitycheck(struct loaddata *loading)
static void sg_load_event_cache(struct loaddata *loading)
static void sg_load_map_tiles_bases(struct loaddata *loading)
static void sg_special_set(struct tile *ptile, bv_extras *extras, char ch, const enum tile_special_type *idx, bool rivers_overlay)
static int sg_order_to_action(int order, struct unit *act_unit, struct tile *tgt_tile)
#define halfbyte_iterate_roads(r, num_roads_types)
void calc_civ_score(struct player *pplayer)
void script_server_state_load(struct section_file *file)
void settings_game_load(struct section_file *file, const char *section)
struct setting_list * level[OLEVELS_NUM]
bool str_to_int(const char *str, int *pint)
bool is_base64url(const char *s)
char scanin(const char **buf, char *delimiters, char *dest, int size)
void randomize_base64url_string(char *s, size_t n)
#define CLIP(lower, current, upper)
void spaceship_calc_derived(struct player_spaceship *ship)
void spaceship_init(struct player_spaceship *ship)
#define NUM_SS_STRUCTURALS
struct specialist * specialist_by_rule_name(const char *name)
Specialist_type_id specialist_index(const struct specialist *sp)
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
#define DEFAULT_SPECIALIST
void server_game_init(bool keep_ruleset_value)
const char * aifill(int amount)
bool game_was_started(void)
void identity_number_reserve(int id)
struct server_arguments srvarg
void init_game_seed(void)
void update_nations_with_startpos(void)
void server_game_free(void)
struct worker_task_list * task_reqs
struct built_status built[B_LAST]
int last_turns_shield_surplus
bv_city_options city_options
struct trade_route_list * routes
struct universal production
int before_change_shields
citizens specialists[SP_MAX]
struct city::@17::@19 server
struct universal changed_from
struct unit_list * units_supported
struct civ_game::@30::@34 server
struct packet_scenario_description scenario_desc
struct packet_ruleset_control control
struct packet_game_info info
char rulesetdir[MAX_LEN_NAME]
struct packet_scenario_info scenario
struct civ_map::@41::@43 server
enum map_generator generator
char title[REPORT_TITLESIZE]
char body[REPORT_BODYSIZE]
const char * secfile_options
struct loaddata::@107 road
struct loaddata::@106 base
struct loaddata::@104 multiplier
struct loaddata::@109 ds_t
struct loaddata::@105 special
enum server_states server_state
struct loaddata::@100 technology
struct loaddata::@108 specialist
struct loaddata::@101 activities
struct loaddata::@102 trait
struct loaddata::@99 improvement
struct loaddata::@103 extra
struct section_file * file
int great_wonder_owners[B_LAST]
bool global_advances[A_LAST]
enum ai_level skill_level
enum phase_mode_type phase_mode
char description[MAX_LEN_CONTENT]
bool allow_ai_type_fallback
char authors[MAX_LEN_PACKET/3]
enum ai_level skill_level
enum barbarian_type barbarian_type
int love[MAX_NUM_PLAYER_SLOTS]
enum diplstate_type max_state
char has_reason_to_cancel
bv_spaceship_structure structure
enum spaceship_state state
struct player * extras_owner
struct city_list * cities
struct player_ai ai_common
struct government * target_government
char username[MAX_LEN_NAME]
struct government * government
char ranked_username[MAX_LEN_NAME]
struct player_economic economic
struct player_spaceship spaceship
struct attribute_block_s attribute_block
struct player_score score
struct multiplier_value multipliers[MAX_NUM_MULTIPLIERS]
struct nation_type * nation
struct nation_style * style
struct player::@69::@71 server
char orig_username[MAX_LEN_NAME]
int bulbs_researching_saved
Tech_type_id researching_saved
char metaserver_addr[256]
struct goods_type * goods
enum action_decision action_decision_want
enum unit_activity activity
struct extra_type * changed_from_target
struct extra_type * activity_target
enum unit_activity changed_from
struct player * nationality
struct unit::@80::@83 server
struct tile * action_decision_tile
enum server_side_agent ssa_controller
enum capital_type capital
struct universal entries[MAX_LEN_WORKLIST]
int city_style(struct city *pcity)
struct nation_style * style_by_rule_name(const char *name)
struct nation_style * style_by_number(int id)
const char * style_rule_name(const struct nation_style *pstyle)
int fc_snprintf(char *str, size_t n, const char *format,...)
int fc_strcasecmp(const char *str0, const char *str1)
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
#define sz_strlcpy(dest, src)
#define RETURN_VALUE_AFTER_EXIT(_val_)
struct team_slot * team_slot_by_number(int team_id)
bool team_add_player(struct player *pplayer, struct team *pteam)
struct team * team_new(struct team_slot *tslot)
const struct player_list * team_members(const struct team *pteam)
bool is_future_tech(Tech_type_id tech)
struct advance * valid_advance_by_number(const Tech_type_id id)
struct advance * advance_by_rule_name(const char *name)
Tech_type_id advance_number(const struct advance *padvance)
struct terrain * terrain_by_rule_name(const char *name)
const char * terrain_rule_name(const struct terrain *pterrain)
bool terrain_has_resource(const struct terrain *pterrain, const struct extra_type *presource)
#define terrain_type_iterate(_p)
#define TERRAIN_UNKNOWN_IDENTIFIER
#define terrain_type_iterate_end
#define RESOURCE_NONE_IDENTIFIER
#define RESOURCE_NULL_IDENTIFIER
bool tile_has_claimable_base(const struct tile *ptile, const struct unit_type *punittype)
void tile_virtual_destroy(struct tile *vtile)
struct tile * tile_virtual_new(const struct tile *ptile)
bool tile_set_label(struct tile *ptile, const char *label)
void tile_set_resource(struct tile *ptile, struct extra_type *presource)
struct city * tile_city(const struct tile *ptile)
void tile_set_worked(struct tile *ptile, struct city *pcity)
#define tile_worked(_tile)
#define tile_terrain(_tile)
#define tile_has_extra(ptile, pextra)
#define tile_owner(_tile)
struct goods_type * goods_by_number(Goods_type_id id)
void free_unit_orders(struct unit *punit)
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
void set_unit_activity(struct unit *punit, enum unit_activity new_activity)
struct unit * unit_transport_get(const struct unit *pcargo)
bool can_unit_continue_current_activity(const struct civ_map *nmap, struct unit *punit)
void set_unit_activity_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type *new_target)
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
bool unit_order_list_is_sane(const struct civ_map *nmap, int length, const struct unit_order *orders)
void unit_virtual_destroy(struct unit *punit)
void unit_tile_set(struct unit *punit, struct tile *ptile)
void unit_list_sort_ord_map(struct unit_list *punitlist)
void unit_list_sort_ord_city(struct unit_list *punitlist)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_safe(unitlist, _unit)
#define unit_list_iterate_end
#define unit_list_iterate_safe_end
const struct unit_type * unit_type_get(const struct unit *punit)
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
struct unit_type * unit_type_by_rule_name(const char *name)
const char * unit_rule_name(const struct unit *punit)
int utype_veteran_levels(const struct unit_type *punittype)
Unit_type_id utype_index(const struct unit_type *punittype)
const char * utype_name_translation(const struct unit_type *punittype)
static bool utype_has_flag(const struct unit_type *punittype, int flag)
#define unit_type_iterate(_p)
#define unit_type_iterate_end
void vision_site_size_set(struct vision_site *psite, citizens size)
struct vision * vision_new(struct player *pplayer, struct tile *ptile)
bool vision_reveal_tiles(struct vision *vision, bool reveal_tiles)
struct vision_site * vision_site_new(int identity, struct tile *location, struct player *owner)
void vision_site_destroy(struct vision_site *psite)
bool worker_task_is_sane(struct worker_task *ptask)
#define worker_task_list_iterate(tasklist, ptask)
#define worker_task_list_iterate_end
void worklist_init(struct worklist *pwl)