59 #include <fc_config.h>
151 #define SAVE_MAP_CHAR(ptile, GET_XY_CHAR, secfile, secpath, ...) \
153 char _line[wld.map.xsize + 1]; \
154 int _nat_x, _nat_y; \
156 for (_nat_y = 0; _nat_y < wld.map.ysize; _nat_y++) { \
157 for (_nat_x = 0; _nat_x < wld.map.xsize; _nat_x++) { \
158 struct tile *ptile = \
159 native_pos_to_tile(&(wld.map), _nat_x, _nat_y); \
160 fc_assert_action(ptile != nullptr, continue); \
161 _line[_nat_x] = (GET_XY_CHAR); \
162 sg_failure_ret(QChar::isPrint(_line[_nat_x] & 0x7f), \
163 "Trying to write invalid map data at position " \
164 "(%d, %d) for path %s: '%c' (%d)", \
165 _nat_x, _nat_y, secpath, _line[_nat_x], \
168 _line[wld.map.xsize] = '\0'; \
169 secfile_insert_str(secfile, _line, secpath, ##__VA_ARGS__, _nat_y); \
200 #define LOAD_MAP_CHAR(ch, ptile, SET_XY_CHAR, secfile, secpath, ...) \
202 int _nat_x, _nat_y; \
203 bool _printed_warning = false; \
204 for (_nat_y = 0; _nat_y < wld.map.ysize; _nat_y++) { \
205 const char *_line = \
206 secfile_lookup_str(secfile, secpath, ##__VA_ARGS__, _nat_y); \
207 if (nullptr == _line) { \
209 fc_snprintf(buf, sizeof(buf), secpath, ##__VA_ARGS__, _nat_y); \
210 qDebug("Line not found='%s'", buf); \
211 _printed_warning = true; \
213 } else if (strlen(_line) != wld.map.xsize) { \
215 fc_snprintf(buf, sizeof(buf), secpath, ##__VA_ARGS__, _nat_y); \
216 qDebug("Line too short (expected %d got %lu)='%s'", wld.map.xsize, \
217 (unsigned long) qstrlen(_line), buf); \
218 _printed_warning = true; \
221 for (_nat_x = 0; _nat_x < wld.map.xsize; _nat_x++) { \
222 const char ch = _line[_nat_x]; \
223 struct tile *ptile = \
224 native_pos_to_tile(&(wld.map), _nat_x, _nat_y); \
228 if (_printed_warning) { \
230 log_sg(_("Saved game contains incomplete map data. This can" \
231 " happen with old saved games, or it may indicate an" \
232 " invalid saved game file. Proceed at your own risk.")); \
237 #define halfbyte_iterate_extras(e, num_extras_types) \
240 for (e = 0; 4 * e < (num_extras_types); e++) {
242 #define halfbyte_iterate_extras_end \
247 #define halfbyte_iterate_special(s, num_specials_types) \
250 for (s = 0; 4 * s < (num_specials_types); s++) {
252 #define halfbyte_iterate_special_end \
257 #define halfbyte_iterate_bases(b, num_bases_types) \
260 for (b = 0; 4 * b < (num_bases_types); b++) {
262 #define halfbyte_iterate_bases_end \
267 #define halfbyte_iterate_roads(r, num_roads_types) \
270 for (r = 0; 4 * r < (num_roads_types); r++) {
272 #define halfbyte_iterate_roads_end \
276 #define TOKEN_SIZE 10
282 static enum direction8
char2dir(
char dir);
285 static int unquote_block(
const char *
const quoted_,
void *dest,
288 const char *path, ...);
294 bool rivers_overlay);
300 const char *path,
int plrno);
323 bool rivers_overlay);
338 struct city *pcity,
const char *citystr);
342 const char *citystr);
346 struct unit *punit,
const char *unitstr);
356 const char *citystr);
380 bool was_send_city_suppressed, was_send_tile_suppressed;
435 qCritical(
"Failure loading savegame!");
439 load_rulesets(
nullptr,
nullptr,
false,
nullptr,
true,
false,
true);
549 static enum direction8
char2dir(
char dir)
554 return DIR8_SOUTHWEST;
558 return DIR8_SOUTHEAST;
564 return DIR8_NORTHWEST;
568 return DIR8_NORTHEAST;
572 return direction8_invalid();
583 case ACTIVITY_POLLUTION:
585 case ACTIVITY_OLD_ROAD:
589 case ACTIVITY_IRRIGATE:
591 case ACTIVITY_FORTIFIED:
593 case ACTIVITY_FORTRESS:
595 case ACTIVITY_SENTRY:
597 case ACTIVITY_OLD_RAILROAD:
599 case ACTIVITY_PILLAGE:
603 case ACTIVITY_EXPLORE:
605 case ACTIVITY_TRANSFORM:
607 case ACTIVITY_AIRBASE:
609 case ACTIVITY_FORTIFYING:
611 case ACTIVITY_FALLOUT:
615 case ACTIVITY_GEN_ROAD:
617 case ACTIVITY_CONVERT:
619 case ACTIVITY_UNKNOWN:
620 case ACTIVITY_PATROL_UNUSED:
621 case ACTIVITY_CULTIVATE:
639 for (a = 0; a < ACTIVITY_LAST; a++) {
642 if (activity == achar) {
643 return static_cast<unit_activity
>(a);
648 return ACTIVITY_LAST;
659 int i, length, parsed, tmp;
661 const char *quoted = quoted_;
663 parsed = sscanf(quoted,
"%d", &length);
666 if (length > dest_length) {
669 quoted = strchr(quoted,
':');
673 for (i = 0; i < length; i++) {
674 tmp = strtol(quoted, &endptr, 16);
678 (
static_cast<unsigned char *
>(dest))[i] = tmp;
689 const char *path, ...)
707 for (i = 0; i < pwl->
length; i++) {
715 if (pwl->
entries[i].
kind == universals_n_invalid()) {
716 log_sg(
"%s.wl_value%d: unknown \"%s\" \"%s\".", path_str, i, kind,
760 if (!pch || ch ==
'\0') {
761 log_sg(
"Unknown hex value: '%c' (%d)", ch, ch);
767 for (i = 0; i < 4; i++) {
770 if (pextra ==
nullptr) {
795 if (!pch || ch ==
'\0') {
796 log_sg(
"Unknown hex value: '%c' (%d)", ch, ch);
802 for (i = 0; i < 4; i++) {
823 if (bin & (1 << i)) {
847 enum extra_cause cause = EC_COUNT;
856 cause = EC_IRRIGATION;
862 cause = EC_POLLUTION;
875 if (cause != EC_COUNT) {
890 && (cause != EC_BASE || pterr->
base_time != 0)
891 && (cause != EC_ROAD || pterr->
road_time != 0)) {
899 nullptr, vtile,
nullptr,
nullptr,
900 nullptr,
nullptr,
nullptr,
933 if (!pch || ch ==
'\0') {
934 log_sg(
"Unknown hex value: '%c' (%d)", ch, ch);
940 for (i = 0; i < 4; i++) {
943 if (pbase ==
nullptr) {
946 if (bin & (1 << i)) {
964 if (!pch || ch ==
'\0') {
965 log_sg(
"Unknown hex value: '%c' (%d)", ch, ch);
971 for (i = 0; i < 4; i++) {
974 if (proad ==
nullptr) {
977 if (bin & (1 << i)) {
1008 if (pterrain->identifier == ch) {
1014 qFatal(
"Unknown terrain identifier '%c' in savegame.", ch);
1023 const char *path,
int plrno)
1025 char path_with_name[128];
1029 fc_snprintf(path_with_name,
sizeof(path_with_name),
"%s_name", path);
1049 "%s: unknown technology \"%s\".", path_with_name,
name);
1068 if (!strcmp(
"default",
game.
server.rulesetdir)) {
1073 if (version >= 30) {
1082 qDebug(
"Savegame specified ruleset '%s'. Really loading '%s'.",
ruleset,
1085 if (!
load_rulesets(
nullptr,
nullptr,
false,
nullptr,
true,
false,
true)) {
1088 _(
"Failed to load ruleset '%s' needed for savegame."),
1099 const char *terr_name;
1117 loading->
file,
true,
"savefile.last_updated_as_year");
1121 loading->
file, 0,
"savefile.improvement_size");
1125 "savefile.improvement_vector");
1132 loading->
file, 0,
"savefile.technology_size");
1136 "savefile.technology_vector");
1143 loading->
file, 0,
"savefile.activities_size");
1147 "savefile.activities_vector");
1157 loading->
file, &loading->
trait.
size,
"savefile.trait_vector");
1166 const char **modname;
1171 "savefile.extras_vector");
1175 "Number of extras defined by the ruleset (= %d) are "
1176 "lower than the number in the savefile (= %d).",
1179 nmod = 4 * ((loading->
extra.
size + 3) / 4);
1181 for (j = 0; j < loading->
extra.
size; j++) {
1185 for (; j < nmod; j++) {
1192 loading->
file, 0,
"savefile.multipliers_size");
1194 const char **modname;
1199 "savefile.multipliers_vector");
1208 qDebug(
"Multiplier \"%s\" in savegame but not in ruleset, "
1220 const char **modname;
1225 "savefile.specials_vector");
1253 for (; j < nmod; j++) {
1262 const char **modname;
1267 "savefile.bases_vector");
1271 nmod = 4 * ((loading->
base.
size + 3) / 4);
1273 for (j = 0; j < loading->
base.
size; j++) {
1279 "Unknown base type %s in savefile.", modname[j]);
1281 if (pextra !=
nullptr) {
1288 for (; j < nmod; j++) {
1297 const char **modname;
1302 "savefile.roads_vector");
1306 "Number of roads defined by the ruleset (= %d) are "
1307 "lower than the number in the savefile (= %d).",
1310 nmod = 4 * ((loading->
road.
size + 3) / 4);
1312 for (j = 0; j < loading->
road.
size; j++) {
1315 if (pextra !=
nullptr) {
1322 for (; j < nmod; j++) {
1329 loading->
file, 0,
"savefile.specialists_size");
1331 const char **modname;
1337 "savefile.specialists_vector");
1342 "Number of specialists defined by the ruleset (= %d) are "
1343 "lower than the number in the savefile (= %d).",
1355 for (; j < nmod; j++) {
1362 loading->
file, 0,
"savefile.diplstate_type_size");
1365 "Failed to load diplomatic state type order: %s",
1369 const char **modname;
1373 "savefile.diplstate_type_vector");
1377 for (j = 0; j < loading->
ds_t.
size; j++) {
1390 loading->
file,
nullptr,
"savefile.terrident%d.name", i))
1394 if (pterr !=
nullptr) {
1396 loading->
file,
nullptr,
"savefile.terrident%d.identifier", i);
1400 qCritical(
"Identifier for unknown terrain type %s.", terr_name);
1409 if (pterr != pterr2 && pterr->identifier_load !=
'\0') {
1410 sg_failure_ret((pterr->identifier_load != pterr2->identifier_load),
1411 "%s and %s share a saved identifier",
1436 loading->
file,
nullptr,
"ruledata.government%d.name", i));
1440 if (gov !=
nullptr) {
1442 loading->
file, 0,
"ruledata.government%d.changes", i);
1464 sg_failure_ret(20299 <= game_version,
"Saved game is too old, at least "
1465 "version 2.2.99 required.");
1469 "game.server_state");
1470 loading->
server_state = server_states_by_name(
string, strcmp);
1501 if (
level !=
nullptr) {
1504 game.
info.skill_level = ai_level_invalid();
1507 if (!ai_level_is_valid(
static_cast<ai_level
>(
game.
info.skill_level))) {
1510 "game.skill_level"));
1557 "game.global_advances");
1558 if (
string !=
nullptr) {
1560 "Invalid length of 'game.global_advances' (%lu ~= %lu).",
1561 (
unsigned long) qstrlen(
string),
1565 "Undefined value '%c' within 'game.global_advances'.",
1567 if (
string[i] ==
'1') {
1571 if (padvance !=
nullptr) {
1583 "game.last_turn_change_time")
1616 qWarning().noquote() << QString::fromUtf8(
1617 _(
"Cannot load old random generator state. Seeding a new one."));
1619 }
else if (
auto *state =
1622 std::stringstream ss;
1623 ss.imbue(std::locale::classic());
1627 qWarning().noquote() << QString::fromUtf8(
1628 _(
"Cannot load the random generator state. Seeding a new one."));
1670 bool lake_flood_default;
1685 loading->
file,
true,
"scenario.is_scenario");
1692 if (buf[0] !=
'\0') {
1697 if (buf[0] !=
'\0') {
1705 if (buf[0] !=
'\0') {
1712 loading->
file,
false,
"scenario.save_random");
1716 loading->
file,
false,
"scenario.startpos_nations");
1719 loading->
file,
false,
"scenario.prevent_new_cities");
1720 if (loading->
version < 20599) {
1723 lake_flood_default =
false;
1727 lake_flood_default =
true;
1730 loading->
file, lake_flood_default,
"scenario.lake_flooding");
1734 loading->
file,
false,
"scenario.allow_ai_type_fallback");
1740 "Invalid scenario definition (server state '%s' and "
1875 const char *spec_sprite;
1884 if (
nullptr != ptile->spec_sprite) {
1885 ptile->spec_sprite =
fc_strdup(spec_sprite);
1887 if (label !=
nullptr) {
1908 loading->
file,
"map.e%02d_%04d", j);
1927 loading->
file,
"map.b%02d_%04d", j);
1946 loading->
file,
"map.r%02d_%04d", j);
1955 bool rivers_overlay)
1980 loading->
file,
"map.spe%02d_%04d", j);
1994 loading->
file,
"map.res%04d");
1999 if (
nullptr == ptile->resource) {
2003 if (ptile->terrain ==
nullptr
2023 const char SEPARATOR =
'#';
2024 const char *nation_names;
2027 int i, startpos_count;
2035 if (0 == startpos_count) {
2040 for (i = 0; i < startpos_count; i++) {
2044 log_sg(
"Warning: Undefined coordinates for startpos %d", i);
2049 if (
nullptr == ptile) {
2050 qCritical(
"Start position native coordinates (%d, %d) do not exist "
2051 "in this map. Skipping...",
2057 "map.startpos%d.exclude", i);
2063 if (
nullptr != nation_names &&
'\0' != nation_names[0]) {
2064 const size_t size = qstrlen(nation_names) + 1;
2065 char buf[
size], *start, *end;
2067 memcpy(buf, nation_names,
size);
2068 for (start = buf - 1;
nullptr != start; start = end) {
2070 if ((end = strchr(start, SEPARATOR))) {
2082 qDebug(
"Missing nation \"%s\".", start);
2090 qDebug(
"Number of starts (%d) are lower than rules.max_players "
2091 "(%d), lowering rules.max_players.",
2108 struct player *owner =
nullptr;
2110 struct player *eowner =
nullptr;
2122 const char *buffer1 =
2124 const char *buffer2 =
2126 const char *buffer3 =
2128 const char *ptr1 = buffer1;
2129 const char *ptr2 = buffer2;
2130 const char *ptr3 = buffer3;
2145 scanin(
const_cast<char **
>(&ptr1), n, token1,
sizeof(token1));
2147 "Map size not correct (map.owner%d).", y);
2148 if (strcmp(token1,
"-") == 0) {
2152 "Got map owner %s in (%d, %d).", token1, x, y);
2155 scanin(
const_cast<char **
>(&ptr2), n, token2,
sizeof(token2));
2157 "Map size not correct (map.source%d).", y);
2158 if (strcmp(token2,
"-") == 0) {
2162 "Got map source %s in (%d, %d).", token2, x, y);
2168 scanin(
const_cast<char **
>(&ptr3), n, token3,
sizeof(token3));
2170 "Map size not correct (map.eowner%d).", y);
2171 if (strcmp(token3,
"-") == 0) {
2175 "Got base owner %s in (%d, %d).", token3, x, y);
2201 "City worked map not loaded!");
2206 const char *buffer =
2208 const char *ptr = buffer;
2211 "Savegame corrupt - map line %d not found.", y);
2217 scanin(
const_cast<char **
>(&ptr), n, token,
sizeof(token));
2219 "Savegame corrupt - map size not correct.");
2220 if (strcmp(token,
"-") == 0) {
2224 "Savegame corrupt - got tile worked by city "
2225 "id=%s in (%d, %d).",
2254 for (l = 0; l <
lines; l++) {
2255 for (j = 0; j < 8; j++) {
2256 for (i = 0; i < 4; i++) {
2264 loading->
file,
"map.k%02d_%04d", l * 8 + j);
2283 & (1u << (p % 32))) {
2311 bool shuffle_loaded =
true;
2325 "Invalid length for 'players.destroyed_wonders' "
2327 (
unsigned long) qstrlen(
string),
2331 "Undefined value '%c' within "
2332 "'players.destroyed_wonders'.",
2335 if (
string[k] ==
'1') {
2346 loading->
file,
server.identity_number,
"players.identity_number_used");
2356 struct rgbcolor *prgbcolor =
nullptr;
2375 log_sg(
"Game has started, yet player %d has no color defined.",
2379 qDebug(
"No color defined for player %d.", pslot_id);
2389 sg_failure_ret(pplayer !=
nullptr,
"Invalid AI type: '%s'!",
string);
2414 "player%d.multiplier%d.val",
2422 qDebug(
"Player %d had illegal value for multiplier \"%s\": "
2423 "was %d, clamped to %d",
2437 qDebug(
"Player %d had illegal value for multiplier_target "
2438 "\"%s\": was %d, clamped to %d",
2447 loading->
file,
false,
"player%d.border_vision",
2456 "The value of players.nplayers "
2457 "(%d) from the loaded game does not match the number of "
2458 "players present (%d).",
2471 "Invalid team definition for player %s (nb %d).",
2487 "players.shuffled_player_%d", 0)
2497 shuffled_player_set[plrid] =
false;
2500 shuffled_players[plrid] = -1;
2507 loading->
file, -1,
"players.shuffled_player_%d", i);
2509 if (shuffle == -1) {
2510 log_sg(
"Missing player shuffle information (index %d) "
2511 "- reshuffle player list!",
2513 shuffle_loaded =
false;
2515 }
else if (shuffled_player_set[shuffle]) {
2516 log_sg(
"Player shuffle %d used two times "
2517 "- reshuffle player list!",
2519 shuffle_loaded =
false;
2523 shuffled_player_set[shuffle] =
true;
2526 shuffled_players[i] = shuffle;
2529 if (shuffle_loaded) {
2534 if (!shuffled_player_set[i]) {
2535 shuffled_players[shuffle_index] = i;
2541 "Invalid player shuffle data!");
2544 #ifdef FREECIV_DEBUG
2549 log_debug(
"[load shuffle] id: %3d => slot: %3d | slot %3d: %s",
2550 plrid, shuffled_players[plrid], plrid,
2551 shuffled_player_set[plrid] ?
"is used" :
"-");
2561 if (!shuffle_loaded) {
2592 if (
is_ai(pplayer)) {
2593 qInfo(
_(
"%s has been added as %s level AI-controlled player "
2596 ai_level_translated_name(pplayer->ai_common.skill_level),
2599 qInfo(
_(
"%s has been added as human player."),
player_name(pplayer));
2624 pplayer,
pick_a_nation(
nullptr,
false,
true, NOT_A_BARBARIAN));
2626 log_sg(
_(
"%s had invalid nation; changing to %s."),
2644 log_sg(
"Illegal alliance structure detected: "
2645 "%s alliance to %s reduced to peace treaty.",
2663 pcity,
nullptr,
nullptr, &(pcity->illness_trade),
nullptr);
2697 BV_CLR_ALL(pplayer->server.really_gives_vision);
2709 loading->
file,
false,
2710 "player%d.diplstate%d.gives_shared_vision", plr1, plr2)) {
2730 log_sg(
"Unit doing illegal activity in savegame!");
2732 "Activity: %s, Target: %s", unit_activity_name(punit->activity),
2735 punit->activity = ACTIVITY_IDLE;
2767 const char *barb_str;
2779 "player%d.username", plrno));
2781 "player%d.unassigned_user", plrno),
2785 "player%d.orig_username", plrno));
2788 "player%d.ranked_username", plrno));
2790 "player%d.unassigned_ranked", plrno),
2793 "player%d.delegation_username", plrno);
2795 if (strlen(
string)) {
2803 for (i = 0; i < nval; i++) {
2804 const char *sval = slist[i];
2805 enum plr_flag_id fid = plr_flag_id_by_name(sval,
fc_strcasecmp);
2814 if (plr->
nation !=
nullptr) {
2822 sg_failure_ret(gov !=
nullptr,
"Player%d: unsupported government \"%s\".",
2828 "player%d.target_government_name", plrno);
2835 loading->
file, -1,
"player%d.revolution_finishes", plrno);
2838 &plr->
server.got_first_city,
2839 "player%d.got_first_city", plrno),
2853 fc_snprintf(buf,
sizeof(buf),
"player%d.diplstate%d", plrno, i);
2857 if (unconverted >= 0 && unconverted < loading->ds_t.size) {
2861 log_sg(
"No valid diplomatic state type between players %d and %d",
2869 if (unconverted >= 0 && unconverted < loading->ds_t.size) {
2873 log_sg(
"No valid diplomatic max_state between players %d and %d",
2880 loading->
file, 0,
"%s.first_contact_turn", buf);
2884 loading->
file, 0,
"%s.has_reason_to_cancel", buf);
2886 loading->
file, 0,
"%s.contact_turns_left", buf);
2902 fc_snprintf(buf,
sizeof(buf),
"player%d.ai%d", plrno,
2920 "player%d.ai.level", plrno);
2921 if (
level !=
nullptr) {
2937 "player%d.ai.skill_level", plrno));
2941 "player%d.ai.barb_type", plrno);
2946 log_sg(
"Player%d: Invalid barbarian type \"%s\". "
2947 "Changed to \"None\".",
2969 if (
string ==
nullptr) {
2971 "player%d.city_style_by_name", plrno);
2976 if (style ==
nullptr) {
2978 log_sg(
"Player%d: unsupported city_style_name \"%s\". "
2979 "Changed to \"%s\".",
2986 "player%d.idle_turns", plrno),
2989 "player%d.is_male", plrno);
2991 "player%d.is_alive", plrno),
2994 "player%d.turns_alive", plrno),
2997 "player%d.last_war", plrno),
3000 loading->
file,
false,
"player%d.phase_done", plrno);
3002 "player%d.gold", plrno),
3005 "player%d.rates.tax", plrno),
3008 "player%d.rates.science", plrno),
3011 "player%d.rates.luxury", plrno),
3014 loading->
file, 0,
"player%d.research.bulbs_last_turn", plrno);
3018 for (i = 0; i < loading->
trait.
size; i++) {
3021 if (trait_is_valid(tr)) {
3023 loading->
file, -1,
"player%d.trait%d.val", plrno, i);
3030 "player%d.trait%d.mod", plrno, i),
3042 "player%d.achievement_count", plrno);
3045 for (i = 0; i < count; i++) {
3051 "player%d.achievement%d.name", plrno, i);
3057 "player%d.achievement%d.first",
3063 "Multiple players listed as first to get achievement \"%s\".",
3103 loading->
file, 0,
"score%d.landarea", plrno);
3105 loading->
file, 0,
"score%d.settledarea", plrno);
3107 loading->
file, 0,
"score%d.population", plrno);
3113 loading->
file, 0,
"score%d.pollution", plrno);
3115 loading->
file, 0,
"score%d.literacy", plrno);
3121 loading->
file, 0,
"score%d.spaceship", plrno);
3123 loading->
file, 0,
"score%d.units_built", plrno);
3125 loading->
file, 0,
"score%d.units_killed", plrno);
3127 loading->
file, 0,
"score%d.units_lost", plrno);
3140 fc_snprintf(prefix,
sizeof(prefix),
"player%d.spaceship", plrno);
3149 "%s.structurals", prefix),
3152 "%s.components", prefix),
3155 "%s.modules", prefix),
3161 "%s.propulsion", prefix),
3164 "%s.habitation", prefix),
3167 "%s.life_support", prefix),
3170 "%s.solar_panels", prefix),
3175 st !=
nullptr,
"%s",
3179 "Undefined value '%c' within '%s.structure'.", st[i],
3189 "%s.launch_year", prefix),
3202 "Invalid length for 'player%d.lost_wonders' "
3204 plrno, (
unsigned long) qstrlen(
string),
3208 "Undefined value '%c' within "
3209 "'player%d.lost_wonders'.",
3212 if (
string[k] ==
'1') {
3223 "player%d.culture", plrno);
3225 "player%d.hut_count", plrno);
3244 if (!plr->
is_alive && ncities > 0) {
3245 log_sg(
"'player%d.ncities' = %d for dead player!", plrno, ncities);
3249 if (!plr->
server.got_first_city && ncities > 0) {
3251 plr->
server.got_first_city =
true;
3255 for (i = 0; i < ncities; i++) {
3259 fc_snprintf(buf,
sizeof(buf),
"player%d.c%d", plrno, i);
3267 sg_failure_ret(
false,
"Error loading city %d of player %d.", i, plrno);
3287 city_list_append(plr->
cities, pcity);
3290 tasks_handled =
false;
3291 for (i = 0; !tasks_handled; i++) {
3293 struct city *pcity =
nullptr;
3296 "player%d.task%d.city", plrno, i);
3298 if (city_id != -1) {
3302 if (pcity !=
nullptr) {
3308 "player%d.task%d.x", plrno, i);
3310 "player%d.task%d.y", plrno, i);
3319 "Unknown workertask activity %s", str);
3324 if (strcmp(
"-", str)) {
3330 ptask->
tgt =
nullptr;
3334 loading->
file, 1,
"player%d.task%d.want", plrno, i);
3336 worker_task_list_append(pcity->
task_reqs, ptask);
3338 tasks_handled =
true;
3347 struct city *pcity,
const char *citystr)
3350 const char *kind, *
name, *string;
3351 int id, i, repair, sp_count = 0, workers = 0, value;
3354 const char *stylename;
3362 "%s has invalid center tile (%d, %d)", citystr,
nat_x,
3365 "%s duplicates city (%d, %d)", citystr,
nat_x,
nat_y);
3369 "%s.name", citystr));
3376 "%s.original", citystr);
3378 if (
nullptr != past) {
3387 "Invalid city size: %d, set to %d", value,
size);
3401 "%s.traderoute%d", citystr, i);
3407 proute->
dir = RDIR_BIDIRECTIONAL;
3410 trade_route_list_append(pcity->
routes, proute);
3415 "%s.food_stock", citystr),
3418 "%s.shield_stock", citystr),
3426 "%s.was_happy", citystr);
3429 "%s.turn_plague", citystr);
3432 "%s.anarchy", citystr),
3441 loading->
file, -2,
"%s.turn_founded", citystr);
3452 "%s.did_sell", citystr);
3455 "%s.turn_last_built", citystr),
3464 "%s.currently_building: unknown \"%s\" \"%s\".", citystr,
3471 "%s.changed_from: unknown \"%s\" \"%s\".", citystr, kind,
3476 "%s.before_change_shields", citystr);
3478 loading->
file, 0,
"%s.caravan_shields", citystr);
3480 loading->
file, 0,
"%s.disbanded_shields", citystr);
3482 loading->
file, 0,
"%s.last_turns_shield_surplus", citystr);
3486 if (stylename !=
nullptr) {
3491 if (pcity->
style < 0) {
3495 pcity->
server.synced =
false;
3506 "Invalid length of '%s.improvements' (%lu ~= %lu).",
3507 citystr, (
unsigned long) qstrlen(
string),
3511 "Undefined value '%c' within '%s.improvements'.",
3514 if (
string[i] ==
'1')
3525 "No worked tiles map defined.");
3533 "%s.city_radius_sq", citystr);
3542 #ifdef FREECIV_DEBUG
3554 if (
nullptr != pwork) {
3555 log_sg(
"[%s] city center of '%s' (%d,%d) [%d] is worked by '%s' "
3556 "(%d,%d) [%d]; repairing ",
3565 log_sg(
"[%s] city center of '%s' (%d,%d) [%d] is empty; repairing ",
3578 log_sg(
"[%s] size mismatch for '%s' (%d,%d): size [%d] != "
3579 "(workers [%d] - 1 + specialists [%d]",
3592 for (i = 0; i < CITYO_LAST; i++) {
3610 const char *citystr)
3612 if (
game.
info.citizen_nationality) {
3624 log_sg(
"Citizens of an invalid nation for %s (player slot %d)!",
3631 "Invalid value for citizens of player %d in %s: %d.",
3645 log_sg(
"City size and number of citizens does not match in %s "
3646 "(%d != %d)! Repairing ...",
3668 if (!plr->
is_alive && nunits > 0) {
3669 log_sg(
"'player%d.nunits' = %d for dead player!", plrno, nunits);
3673 for (i = 0; i < nunits; i++) {
3681 fc_snprintf(buf,
sizeof(buf),
"player%d.u%d", plrno, i);
3685 sg_failure_ret(type !=
nullptr,
"%s: unknown unit type \"%s\".", buf,
3692 sg_failure_ret(
false,
"Error loading unit %d of player %d.", i, plrno);
3714 unit_list_append(plr->
units, punit);
3730 struct unit *punit,
const char *unitstr)
3733 enum unit_activity activity;
3744 const char *facing_str;
3764 if (facing_str[0] !=
'x') {
3768 enum direction8 facing =
char2dir(facing_str[0]);
3770 if (direction8_is_valid(facing)) {
3773 qCritical(
"Illegal unit orientation '%s'", facing_str);
3780 "%s.nationality", unitstr);
3788 "%s.homecity", unitstr),
3791 "%s.moves", unitstr),
3805 if (activity == ACTIVITY_PATROL_UNUSED) {
3813 activity = ACTIVITY_IDLE;
3819 if (extra_id != -2) {
3820 if (extra_id >= 0 && extra_id < loading->extra.size) {
3823 }
else if (activity == ACTIVITY_IRRIGATE) {
3826 if (tgt !=
nullptr) {
3831 }
else if (activity == ACTIVITY_MINE) {
3834 if (tgt !=
nullptr) {
3845 "%s.activity_base", unitstr);
3846 if (base_id >= 0 && base_id < loading->
base.size) {
3850 "%s.activity_road", unitstr);
3851 if (road_id >= 0 && road_id < loading->
road.size) {
3858 "%s.activity_target", unitstr);
3859 if (tgt_no >= 0 && tgt_no < loading->special.size) {
3874 if (activity == ACTIVITY_OLD_ROAD) {
3875 activity = ACTIVITY_GEN_ROAD;
3877 }
else if (activity == ACTIVITY_OLD_RAILROAD) {
3878 activity = ACTIVITY_GEN_ROAD;
3887 if (activity == ACTIVITY_BASE) {
3891 log_sg(
"Cannot find base %d for %s to build", base_id,
3895 }
else if (activity == ACTIVITY_GEN_ROAD) {
3899 log_sg(
"Cannot find road %d for %s to build", road_id,
3903 }
else if (activity == ACTIVITY_PILLAGE) {
3908 }
else if (pbase !=
nullptr) {
3910 }
else if (proad !=
nullptr) {
3919 }
else if (activity == ACTIVITY_IRRIGATE) {
3922 if (tgt !=
nullptr) {
3927 }
else if (activity == ACTIVITY_MINE) {
3930 if (tgt !=
nullptr) {
3935 }
else if (activity == ACTIVITY_POLLUTION) {
3938 if (tgt !=
nullptr) {
3943 }
else if (activity == ACTIVITY_FALLOUT) {
3946 if (tgt !=
nullptr) {
3957 "%s.activity_count", unitstr),
3962 loading->
file, ACTIVITY_IDLE,
"%s.changed_from", unitstr));
3965 "%s.changed_from_tgt", unitstr);
3967 if (extra_id != -2) {
3968 if (extra_id >= 0 && extra_id < loading->extra.size) {
3977 loading->
file,
S_LAST,
"%s.changed_from_target", unitstr));
3979 "%s.changed_from_base", unitstr);
3981 "%s.changed_from_road", unitstr);
3983 if (road_id == -1) {
3997 if (base_id >= 0 && base_id < loading->
base.size) {
4000 }
else if (road_id >= 0 && road_id < loading->
road.size) {
4003 }
else if (cfspe !=
S_LAST) {
4012 if (tgt !=
nullptr) {
4020 if (tgt !=
nullptr) {
4025 }
else if (punit->
changed_from == ACTIVITY_POLLUTION) {
4028 if (tgt !=
nullptr) {
4036 if (tgt !=
nullptr) {
4045 loading->
file, 0,
"%s.changed_from_count", unitstr);
4052 if (activity == ACTIVITY_SENTRY) {
4064 if (punit->
veteran >= levels) {
4070 loading->
file, (punit->
moves_left == 0),
"%s.done_moving", unitstr);
4100 if (ai_controlled) {
4118 loading->
file,
false,
"%s.paradropped", unitstr);
4138 loading->
file, ACT_DEC_NOTHING, action_decision,
4139 "%s.action_decision_want", unitstr));
4146 "%s.action_decision_tile_x", unitstr)
4148 "%s.action_decision_tile_y", unitstr)) {
4154 log_sg(
"Bad action_decision_tile for unit %d", punit->
id);
4167 "%s.orders_length", unitstr);
4169 const char *orders_unitstr, *dir_unitstr, *act_unitstr;
4170 const char *tgt_unitstr;
4171 const char *base_unitstr =
nullptr;
4172 const char *road_unitstr =
nullptr;
4179 loading->
file, 0,
"%s.orders_index", unitstr);
4181 loading->
file,
false,
"%s.orders_repeat", unitstr);
4183 loading->
file,
false,
"%s.orders_vigilant", unitstr);
4186 "%s.orders_list", unitstr);
4188 "%s.dir_list", unitstr);
4190 "%s.activity_list", unitstr);
4192 "%s.tgt_list", unitstr);
4194 if (tgt_unitstr ==
nullptr) {
4198 "%s.road_list", unitstr);
4202 for (j = 0; j <
len; j++) {
4205 if (orders_unitstr[j] ==
'\0' || dir_unitstr[j] ==
'\0'
4206 || act_unitstr[j] ==
'\0') {
4207 log_sg(
"Invalid unit orders.");
4220 && !direction8_is_valid(
order->dir))
4222 && !direction8_is_valid(
order->dir))
4224 &&
order->activity == ACTIVITY_LAST)) {
4241 if (tgt_unitstr[j] !=
'?') {
4242 extra_id =
char2num(tgt_unitstr[j]);
4244 if (extra_id < 0 || extra_id >= loading->
extra.
size) {
4245 log_sg(
"Cannot find extra %d for %s to build", extra_id,
4249 order->sub_target = extra_id;
4257 if (base_unitstr && base_unitstr[j] !=
'?'
4258 &&
order->activity == ACTIVITY_BASE) {
4259 base_id =
char2num(base_unitstr[j]);
4261 if (base_id < 0 || base_id >= loading->
base.
size) {
4262 log_sg(
"Cannot find base %d for %s to build", base_id,
4270 }
else if (road_unitstr && road_unitstr[j] !=
'?'
4271 &&
order->activity == ACTIVITY_GEN_ROAD) {
4272 road_id =
char2num(road_unitstr[j]);
4274 if (road_id < 0 || road_id >= loading->
road.
size) {
4275 log_sg(
"Cannot find road %d for %s to build", road_id,
4286 if (
order->activity == ACTIVITY_OLD_ROAD) {
4287 order->activity = ACTIVITY_GEN_ROAD;
4290 }
else if (
order->activity == ACTIVITY_OLD_RAILROAD) {
4291 order->activity = ACTIVITY_GEN_ROAD;
4334 if (!plr->
is_alive && nunits > 0) {
4335 log_sg(
"'player%d.nunits' = %d for dead player!", plrno, nunits);
4339 for (i = 0; i < nunits; i++) {
4340 int id_unit, id_trans;
4341 struct unit *punit, *ptrans;
4344 "player%d.u%d.id", plrno, i);
4349 loading->
file, -1,
"player%d.u%d.transported_by", plrno, i);
4350 if (id_trans == -1) {
4382 loading->
file, 0,
"player%d.attribute_v2_block_length", plrno);
4385 log_sg(
"player%d.attribute_v2_block_length=%d too small", plrno,
length);
4387 log_sg(
"player%d.attribute_v2_block_length=%d too big (max %d)", plrno,
4391 size_t actual_length;
4396 loading->
file, "ed_length,
4397 "player%d.attribute_v2_block_length_quoted", plrno),
4400 "player%d.attribute_v2_block_parts",
4404 quoted =
new char[quoted_length + 1];
4407 for (part_nr = 0; part_nr <
parts; part_nr++) {
4409 loading->
file,
"player%d.attribute_v2_block_data.part%d", plrno,
4412 log_sg(
"attribute_v2_block_parts=%d actual=%d",
parts, part_nr);
4415 log_debug(
"attribute_v2_block_length_quoted=%lu have=%lu part=%lu",
4416 (
unsigned long) quoted_length,
4417 (
unsigned long) qstrlen(quoted),
4418 (
unsigned long) qstrlen(current));
4419 fc_assert(strlen(quoted) + qstrlen(current) <= quoted_length);
4420 strcat(quoted, current);
4423 "attribute_v2_block_length_quoted=%lu actual=%lu",
4424 (
unsigned long) quoted_length,
4425 (
unsigned long) qstrlen(quoted));
4442 "player%d.dc_total", plrno);
4444 bool someone_alive =
false;
4449 if (
game.
server.revealmap & REVEAL_MAP_DEAD) {
4452 if (pteam_member->is_alive) {
4453 someone_alive =
true;
4459 if (!someone_alive) {
4467 "game.save_private_map")) {
4483 if (
nullptr != pcity) {
4497 loading->
file,
"player%d.map_t%04d", plrno);
4503 loading->
file,
"player%d.map_res%04d", plrno);
4514 loading->
file,
"player%d.map_e%02d_%04d", plrno, j);
4526 loading->
file,
"player%d.map_spe%02d_%04d", plrno, x);
4536 loading->
file,
"player%d.map_b%02d_%04d", plrno, j);
4548 loading->
file,
"player%d.map_r%02d_%04d", plrno, j);
4560 loading->
file,
"player%d.map_owner%04d", plrno, y);
4562 loading->
file,
"player%d.extras_owner%04d", plrno, y);
4563 const char *ptr = buffer;
4564 const char *ptr2 = buffer2;
4567 "Savegame corrupt - map line %d not found.", y);
4574 scanin(
const_cast<char **
>(&ptr), n, token,
sizeof(token));
4576 "Savegame corrupt - map size not correct.");
4577 if (strcmp(token,
"-") == 0) {
4581 "Savegame corrupt - got tile owner=%s in (%d, %d).",
4588 scanin(
const_cast<char **
>(&ptr2), n, token2,
sizeof(token2));
4590 "Savegame corrupt - map size not correct.");
4591 if (strcmp(token2,
"-") == 0) {
4596 "Savegame corrupt - got extras owner=%s in (%d, %d).", token,
4610 for (i = 0; i < 4; i++) {
4616 loading->
file,
"player%d.map_u%02d_%04d", plrno, i);
4621 loading->
file,
"player%d.map_u%02d_%04d", plrno, i);
4626 for (i = 0; i < total_ncities; i++) {
4629 fc_snprintf(buf,
sizeof(buf),
"player%d.dc%d", plrno, i);
4638 log_sg(
"Skipping seen city %d for player %d.", i, plrno);
4652 if (
nullptr != pcity) {
4671 const char *citystr)
4677 const char *stylename;
4685 "%s invalid tile (%d,%d)", citystr,
nat_x,
nat_y);
4692 "%s has invalid owner (%d); skipping.", citystr,
id);
4698 "%s has invalid id (%d); skipping.", citystr,
id);
4705 "Invalid city size: %d; set to %d.",
size, city_size);
4713 "Invalid length of '%s.improvements' (%lu ~= %lu).",
4714 citystr, (
unsigned long) qstrlen(
string),
4718 "Undefined value '%c' within '%s.improvements'.",
4721 if (
string[i] ==
'1')
4733 "%s.name", citystr));
4736 "%s.occupied", citystr);
4742 "%s.unhappy", citystr);
4745 if (stylename !=
nullptr) {
4750 if (pdcity->
style < 0) {
4755 "%s.city_image", citystr);
4757 pdcity->
capital = CAPITAL_NOT;
4789 for (i = 0; i < count; i++) {
4795 "Invalid research number %d in 'research.r%d.number'",
4802 "research.r%d.techs", i),
4805 "research.r%d.futuretech", i),
4809 "research.r%d.bulbs", i),
4813 "research.r%d.bulbs_before", i),
4820 "research.r%d.got_tech", i),
4826 "Invalid length of 'research.r%d.done' (%lu ~= %lu).", i,
4827 (
unsigned long) qstrlen(
string),
4831 "Undefined value '%c' within 'research.r%d.done'.",
4834 if (
string[j] ==
'1') {
4887 "treaty%d.plr0", tidx))
4900 if (p0 ==
nullptr || p1 ==
nullptr) {
4901 qCritical(
"Treaty between unknown players %s and %s", plr0, plr1);
4906 treaty_list_prepend(
treaties, ptreaty);
4909 loading->
file,
nullptr,
"treaty%d.clause%d.type",
4913 enum clause_type type = clause_type_by_name(ct,
fc_strcasecmp);
4916 if (!clause_type_is_valid(type)) {
4917 qCritical(
"Invalid clause type \"%s\"", ct);
4919 struct player *pgiver =
nullptr;
4929 qCritical(
"Clause giver %s is not participant of the treaty"
4930 "between %s and %s",
4934 if (pgiver !=
nullptr) {
4938 loading->
file, 0,
"treaty%d.clause%d.value", tidx, cidx);
4947 loading->
file,
false,
"treaty%d.accept0", tidx);
4949 loading->
file,
false,
"treaty%d.accept1", tidx);
4994 int mapdef_count, i;
5006 qDebug(
"Saved map image definitions: %d.", mapdef_count);
5008 if (0 >= mapdef_count) {
5012 for (i = 0; i < mapdef_count; i++) {
5017 qDebug(
"[Mapimg %4d] Missing definition.", i);
5022 qCritical(
"Invalid map image definition %4d: %s.", i, p);
5025 qDebug(
"Mapimg %4d loaded.", i);
5052 qDebug(
"Max players lower than current players, fixing");
5063 log_sg(
"Removing %s unferried %s in %s at (%d, %d)",
5091 bool saved_ai_control =
is_ai(pplayer);
5102 if (saved_ai_control) {
5109 #ifdef FREECIV_DEBUG
5115 qCritical(
"[city id: %d] Unused worked tile at (%d, %d).",
5126 if (presearch.researching !=
A_UNSET
5130 != TECH_PREREQS_KNOWN))) {
5131 log_sg(
_(
"%s had invalid researching technology."),
5133 presearch.researching =
A_UNSET;
5135 if (presearch.tech_goal !=
A_UNSET
5139 presearch.tech_goal)
5142 log_sg(
_(
"%s had invalid technology goal."),
5144 presearch.tech_goal =
A_UNSET;
5154 punit->orders.list)) {
5155 log_sg(
"Invalid unit orders for unit %d.", punit->id);
5163 if (0 == qstrlen(
server.game_identifier)
5167 sizeof(
server.game_identifier));
5173 int unique_count[
U_LAST];
5175 memset(unique_count, 0,
sizeof(unique_count));
5187 log_sg(
_(
"%s has multiple units of type %s though it should be "
5189 "to have only one."),
struct achievement * achievement_by_rule_name(const char *name)
Returns achievement matching rule name or nullptr if there is no achievement with such name.
void building_advisor(struct player *pplayer)
Prime pcity->server.adv.building_want[].
bool adv_data_phase_init(struct player *pplayer, bool is_new_phase)
Make and cache lots of calculations needed for other functions.
void adv_data_phase_done(struct player *pplayer)
Clean up our mess.
const char * ai_name(const struct ai_type *ai)
Return the name of the ai type.
#define CALL_FUNC_EACH_AI(_func,...)
#define CALL_PLR_AI_FUNC(_func, _player,...)
void ai_traits_init(struct player *pplayer)
Initialize ai traits for player.
Base_type_id base_number(const struct base_type *pbase)
Return the base index.
struct extra_type * base_extra_get(const struct base_type *pbase)
Return extra that base is.
struct base_type * base_by_number(const Base_type_id id)
Returns base_type entry for an ID value.
struct base_type * get_base_by_gui_type(enum base_gui_type type, const struct unit *punit, const struct tile *ptile)
Get best gui_type base for given parameters.
bool has_capability(const char *cap, const char *capstr)
Wrapper for fc_has_capability() for nullptr terminated strings.
void citizens_nation_set(struct city *pcity, const struct player_slot *pslot, citizens count)
Set the number of citizens with the given nationality.
citizens citizens_count(const struct city *pcity)
Return the number of citizens in a city.
void citizens_init(struct city *pcity)
Initialise citizens data.
void citizens_update(struct city *pcity, struct player *plr)
void city_map_radius_sq_set(struct city *pcity, int radius_sq)
Returns the current squared radius of the city.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
Calculate city's illness in tenth of percent:
void city_size_set(struct city *pcity, citizens size)
Set the city size.
void city_add_improvement(struct city *pcity, const struct impr_type *pimprove)
Adds an improvement (and its effects) to a city.
void destroy_city_virtual(struct city *pcity)
Removes the virtual skeleton of a city.
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
Create virtual skeleton for a city.
citizens city_size_get(const struct city *pcity)
Get the city size.
int city_style_by_rule_name(const char *s)
Returns the city style that has the given (untranslated) rule name.
#define cities_iterate_end
#define city_list_iterate(citylist, pcity)
#define cities_iterate(pcity)
#define city_tile_iterate(_radius_sq, _city_tile, _tile)
#define output_type_iterate(output)
#define city_list_iterate_end
#define city_tile_iterate_end
#define output_type_iterate_end
void auto_arrange_workers(struct city *pcity)
Call sync_cities() to send the affected cities to the clients.
void city_repair_size(struct city *pcity, int change)
Repair the city population without affecting city size.
bool city_refresh(struct city *pcity)
Updates unit upkeeps and city internal cached data.
static void road(QVariant data1, QVariant data2)
Action "Build Road" for choice dialog.
static void base(QVariant data1, QVariant data2)
Action "Build Base" for choice dialog.
void set_ai_level_directer(struct player *pplayer, enum ai_level level)
Set an AI level and related quantities, with no feedback.
static struct treaty_list * treaties
struct treaty_list * get_all_treaties()
Get treaty list.
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
Add clause to treaty.
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
Initialize treaty structure between two players.
#define MAX_NUM_PLAYER_SLOTS
enum output_type_id Output_type_id
#define IDENTITY_NUMBER_ZERO
struct unit * game_unit_by_number(int id)
Find unit out of all units in game: now uses fast idex method, instead of looking through all units o...
void initialize_globals()
Initialize wonder information.
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city 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)
Returns the government that has the given (untranslated) rule name.
void idex_register_unit(struct world *iworld, struct unit *punit)
Register a unit into idex, with current punit->id.
void idex_register_city(struct world *iworld, struct city *pcity)
Register a city into idex, with current pcity->id.
struct impr_type * improvement_by_rule_name(const char *name)
Does a linear search of improvement_types[].name.vernacular Returns nullptr when none match.
Impr_type_id improvement_index(const struct impr_type *pimprove)
Return the improvement index.
void adv_city_free(struct city *pcity)
Free advisors related city data.
void adv_city_alloc(struct city *pcity)
Allocate advisors related city data.
#define fc_assert_msg(condition, message,...)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
bool startpos_disallow(struct startpos *psp, struct nation_type *pnation)
Disallow the nation to start at the start position.
int map_startpos_count()
Is there start positions set for map.
struct startpos * map_startpos_new(struct tile *ptile)
Create a new start position at the given tile and return it.
void map_init_topology()
map_init_topology needs to be called after map.topology_id is changed.
struct tile * native_pos_to_tile(const struct civ_map *nmap, int nat_x, int nat_y)
Return the tile for the given native position.
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Return the tile for the given index position.
void main_map_allocate()
Allocate main map and related global structures.
bool startpos_allow(struct startpos *psp, struct nation_type *pnation)
Allow the nation to start at the start position.
#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()
Assigns continent and ocean numbers to all tiles, and set map.num_continents and map....
void player_map_init(struct player *pplayer)
Allocate space for map, and initialise the tiles.
void update_player_tile_last_seen(struct player *pplayer, struct tile *ptile)
Remember that tile was last seen this year.
void map_calculate_borders()
Update borders for all sources.
void map_claim_ownership(struct tile *ptile, struct player *powner, struct tile *psource, bool claim_bases)
Claim ownership of a single tile.
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
Return whether the player knows the tile.
bool send_tile_suppression(bool now)
Suppress send_tile_info() during game_load()
void map_know_and_see_all(struct player *pplayer)
Call this function to unfog all tiles.
bool update_player_tile_knowledge(struct player *pplayer, struct tile *ptile)
Give pplayer the correct knowledge about tile; return TRUE iff knowledge changed.
void tile_claim_bases(struct tile *ptile, struct player *powner)
Claim ownership of bases on single tile.
void map_set_known(struct tile *ptile, struct player *pplayer)
Set known status of the tile.
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
Returns whether the layer 'vlayer' of the tile 'ptile' is known and seen by the player 'pplayer'.
void change_playertile_site(struct player_tile *ptile, struct vision_site *new_site)
Changes site information for player tile.
void give_shared_vision(struct player *pfrom, struct player *pto)
Starts shared vision between two players.
struct player_tile * map_get_player_tile(const struct tile *ptile, const struct player *pplayer)
Players' information of tiles is tracked so that fogged area can be kept consistent even when the cli...
int mapimg_count()
Return the number of map image definitions.
bool mapimg_define(const char *maparg, bool check)
Define on map image.
bool mapimg_delete(int id)
Delete a map image definition.
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Return TRUE iff the unit can "exist" at this location.
const char * multiplier_rule_name(const struct multiplier *pmul)
Return the (untranslated) rule name of the multiplier.
struct multiplier * multiplier_by_rule_name(const char *name)
Returns multiplier matching rule name, or nullptr if there is no multiplier with such a name.
Multiplier_type_id multiplier_index(const struct multiplier *pmul)
Returns multiplier index.
#define multipliers_iterate(_mul_)
#define multipliers_iterate_end
const char * nation_rule_name(const struct nation_type *pnation)
Return the (untranslated) rule name of the nation (adjective form).
const char * nation_plural_for_player(const struct player *pplayer)
Return the (translated) plural noun of the given nation of a player.
struct nation_type * nation_by_rule_name(const char *name)
Returns the nation that has the given (untranslated) rule name (adjective).
struct nation_type * nation_of_player(const struct player *pplayer)
Return the nation of a player.
#define NO_NATION_SELECTED
void event_cache_load(struct section_file *file, const char *section)
Load the event cache from a savefile.
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
If the specified player owns the unit with the specified id, return pointer to the unit struct.
struct player_slot * player_slot_by_number(int player_id)
Return the possibly unused and uninitialized player slot.
bool player_slot_is_used(const struct player_slot *pslot)
Returns TRUE is this slot is "used" i.e.
struct player * player_by_name(const char *name)
Find player by given name.
struct player * player_by_number(const int player_id)
Return struct player pointer for the given player index.
int player_number(const struct player *pplayer)
Return the player index/number/id.
enum dipl_reason pplayer_can_make_treaty(const struct player *p1, const struct player *p2, enum diplstate_type treaty)
Returns true iff p1 can make given treaty with p2.
int player_count()
Return the number of players.
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players can attack each other.
int player_slot_index(const struct player_slot *pslot)
Returns the index of the player slot.
int player_slot_max_used_number()
Return the highest used player slot index.
int player_index(const struct player *pplayer)
Return the player index.
struct city * player_city_by_number(const struct player *pplayer, int city_id)
If the specified player owns the city with the specified id, return pointer to the city struct.
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
Set the player's nation to the given nation (may be nullptr).
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
#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 set_as_human(plr)
#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)
Try to set the player name to 'name'.
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
Creates a new, uninitialized, used player slot.
void assign_player_colors()
Permanently assign colors to any players that don't already have them.
void set_shuffled_players(int *shuffled_players)
Initialize the shuffled players list (as from a loaded savegame).
void player_delegation_set(struct player *pplayer, const char *username)
Define a delegation.
void fit_nationset_to_players()
Try to select a nation set that fits the current players' nations, or failing that,...
struct nation_type * pick_a_nation(const struct nation_list *choices, bool ignore_conflicts, bool needs_startpos, enum barbarian_type barb_type)
This function returns a random-ish nation that is suitable for 'barb_type' and is usable (not already...
void server_remove_player(struct player *pplayer)
This function does not close any connections attached to this player.
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
Initialize ANY newly-created player on the server.
int normal_player_count()
Return the number of non-barbarian players.
void shuffle_players()
Shuffle or reshuffle the player order, storing in static variables above.
std::mt19937 & fc_rand_state()
Returns a reference to the current random generator state; eg for save/restore.
void fc_rand_set_state(const std::mt19937 &state)
Replace current rand_state with user-supplied; eg for save/restore.
void fc_rand_seed(std::mt19937 &gen)
Seeds the given generator with a random value.
const char * secfile_error()
Returns the last error which occurred in a string.
bool secfile_lookup_int(const struct section_file *secfile, int *ival, const char *path,...)
Lookup a integer value in the secfile.
struct entry * secfile_entry_lookup(const struct section_file *secfile, const char *path,...)
Returns the entry at "fullpath" or nullptr if not matched.
const char * secfile_lookup_str(const struct section_file *secfile, const char *path,...)
Lookup a string value in the secfile.
const char ** secfile_lookup_str_vec(const struct section_file *secfile, size_t *dim, const char *path,...)
Lookup a string vector in the secfile.
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
Lookup a boolean value in the secfile.
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
Lookup a string value in the secfile.
struct entry * secfile_entry_by_path(const struct section_file *secfile, const char *path)
Returns the entry by the name or nullptr if not matched.
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
Lookup a integer value in the secfile.
struct section * secfile_section_lookup(const struct section_file *secfile, const char *path,...)
Find a section by path.
bool secfile_lookup_bool(const struct section_file *secfile, bool *bval, const char *path,...)
Lookup a boolean value in the secfile.
#define secfile_lookup_enum_default(secfile, defval, specenum_type, path, ...)
struct history_report * history_report_get()
Return current history report.
bool are_reqs_active(const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, const struct requirement_vector *reqs, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel)
Checks the requirement(s) to see if they are active on the given target.
struct universal universal_by_rule_name(const char *kind, const char *value)
Parse requirement type (kind) and value strings into a universal structure.
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Returns TRUE iff the given tech is ever reachable via research by the players sharing the research by...
enum tech_state research_invention_set(struct research *presearch, Tech_type_id tech, enum tech_state value)
Set research knowledge about tech to given state.
const char * research_name_translation(const struct research *presearch)
Returns the name of the research owner: a player name or a team name.
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Returns state of the tech for current research.
struct research * research_by_number(int number)
Returns the research for the given index.
bool research_is_valid(const struct research &presearch)
Checks whether the research object is valid in the current game.
void research_update(struct research *presearch)
Mark as TECH_PREREQS_KNOWN each tech which is available, not known and which has all requirements ful...
std::vector< research > research_array
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Free rgbcolor structure.
bool rgbcolor_load(struct section_file *file, struct rgbcolor **prgbcolor, const char *path,...)
Lookup an RGB color definition ([colorpath].red, [colorpath].green and [colorpath]....
Road_type_id road_number(const struct road_type *proad)
Return the road id.
struct road_type * road_by_compat_special(enum road_compat compat)
Return road type represented by given compatibility special, or nullptr if special does not represent...
struct road_type * road_by_number(Road_type_id id)
Return road type of given id.
struct extra_type * road_extra_get(const struct road_type *proad)
Return extra that road is.
bool load_rulesets(const char *restore, const char *alt, bool compat_mode, rs_conversion_logger logger, bool act, bool buffer_script, bool load_luadata)
Loads the rulesets.
#define sanity_check_city(x)
struct extra_type * resource_by_identifier(const char identifier)
Return the resource type matching the identifier, or nullptr when none matches.
int sg_order_to_action(int order, struct unit *act_unit, struct tile *tgt_tile)
Returns the action id corresponding to the specified order id.
const char * special_rule_name(enum tile_special_type type)
Return the untranslated name of the given special.
void set_unit_activity_road(struct unit *punit, Road_type_id road)
Assign a new road building task to unit.
struct extra_type * special_extra_get(int spe)
Get extra of the given special.
int char2num(char ch)
Converts single character into numerical value.
void sg_load_compat(struct loaddata *loading, enum sgf_version format_class)
Compatibility functions for loaded game.
enum ai_level ai_level_convert(int old_level)
Translate savegame secfile data from earlier development version format to current one.
void set_unit_activity_base(struct unit *punit, Base_type_id base)
Assign a new base building task to unit.
int ascii_hex2bin(char ch, int halfbyte)
This returns a binary integer value of the ascii hex char, offset by the given number of half-bytes.
enum tile_special_type special_by_rule_name(const char *name)
Return the special with the given name, or S_LAST.
void sg_load_post_load_compat(struct loaddata *loading, enum sgf_version format_class)
Compatibility functions for loaded game that needs game state.
#define sg_check_ret(...)
#define sg_warn(condition, message,...)
#define sg_failure_ret_val(condition, _val, message,...)
#define sg_failure_ret(condition, message,...)
#define ORDER_OLD_BUILD_WONDER
#define ORDER_OLD_BUILD_CITY
#define ORDER_OLD_DISBAND
#define ORDER_OLD_HOMECITY
#define sg_warn_ret_val(condition, _val, message,...)
#define ORDER_OLD_TRADE_ROUTE
static void sg_load_players_basic(struct loaddata *loading)
Load '[player]' (basic data).
static struct loaddata * loaddata_new(struct section_file *file)
Create new loaddata item for given section file.
static void sg_load_map_known(struct loaddata *loading)
Load tile known status.
#define halfbyte_iterate_roads_end
static struct extra_type * char2resource(char c)
Return the resource for the given identifier.
static void sg_load_map_owner(struct loaddata *loading)
Load tile owner information.
static void sg_extras_set(bv_extras *extras, char ch, struct extra_type **idx)
Helper function for loading extras from a savegame.
static void sg_bases_set(bv_extras *extras, char ch, struct base_type **idx)
Helper function for loading bases from a savegame.
#define halfbyte_iterate_extras_end
static void sg_load_map_tiles_roads(struct loaddata *loading)
Load roads to map.
#define halfbyte_iterate_extras(e, num_extras_types)
static void sg_load_map(struct loaddata *loading)
Load '[map'].
static enum unit_orders char2order(char order)
Returns an order for a character identifier.
static int unquote_block(const char *const quoted_, void *dest, int dest_length)
Unquote a string.
#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)
Load nationality data for one city.
static void sg_load_player_cities(struct loaddata *loading, struct player *plr)
Load city data.
static void sg_load_map_tiles(struct loaddata *loading)
Load tiles of the map.
static char activity2char(enum unit_activity activity)
Returns a character identifier for an activity.
static void sg_load_savefile(struct loaddata *loading)
Load '[savefile]'.
static enum unit_activity char2activity(char activity)
Returns an activity for a character identifier.
static bool sg_load_player_unit(struct loaddata *loading, struct player *plr, struct unit *punit, const char *unitstr)
Load one unit.
static void sg_load_settings(struct loaddata *loading)
Load '[settings]'.
static void sg_load_player_units(struct loaddata *loading, struct player *plr)
Load unit data.
#define halfbyte_iterate_special(s, num_specials_types)
void savegame2_load(struct section_file *file)
Really loading the savegame.
static void sg_load_researches(struct loaddata *loading)
Load '[research]'.
#define halfbyte_iterate_bases_end
static void sg_load_map_worked(struct loaddata *loading)
Load worked tiles information.
static void sg_load_random(struct loaddata *loading)
Load '[random]'.
#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)
Load the transport status of all units.
static void sg_load_history(struct loaddata *loading)
Load '[history]'.
static void sg_load_map_tiles_specials(struct loaddata *loading, bool rivers_overlay)
Load information about specials on map.
static void sg_load_script(struct loaddata *loading)
Load '[script]'.
static void sg_load_scenario(struct loaddata *loading)
Load '[scenario]'.
static void sg_load_ruleset(struct loaddata *loading)
Set up correct ruleset for the savegame.
static void sg_load_game(struct loaddata *loading)
Load '[game]'.
static void sg_load_player_main(struct loaddata *loading, struct player *plr)
Main player data loading function.
static void sg_load_treaties(struct loaddata *loading)
Load '[treaty_xxx]'.
static void sg_roads_set(bv_extras *extras, char ch, struct road_type **idx)
Helper function for loading roads from a savegame.
static Tech_type_id technology_load(struct section_file *file, const char *path, int plrno)
Load technology from path_name and if doesn't exist (because savegame is too old) load from path.
static void unit_ordering_apply()
For each city and tile, sort unit lists according to ord_city and ord_map values.
static enum direction8 char2dir(char dir)
Returns a direction for a character identifier.
static bool sg_load_player_city(struct loaddata *loading, struct player *plr, struct city *pcity, const char *citystr)
Load data for one city.
static void sg_load_map_tiles_resources(struct loaddata *loading)
Load information about resources on map.
static struct terrain * char2terrain(char ch)
Dereferences the terrain character.
static void sg_load_mapimg(struct loaddata *loading)
Load '[mapimg]'.
static void sg_load_player_attributes(struct loaddata *loading, struct player *plr)
Load player (client) attributes data.
static void sg_load_ruledata(struct loaddata *loading)
Load '[ruledata]'.
static void worklist_load(struct section_file *file, struct worklist *pwl, const char *path,...)
Load the worklist elements specified by path to the worklist pointed to by 'pwl'.
static void sg_load_player_vision(struct loaddata *loading, struct player *plr)
Load vision data.
static bool sg_load_player_vision_city(struct loaddata *loading, struct player *plr, struct vision_site *pdcity, const char *citystr)
Load data for one seen city.
static void sg_load_map_startpos(struct loaddata *loading)
Load starting positions for the players from a savegame file.
static void loaddata_destroy(struct loaddata *loading)
Free resources allocated for loaddata item.
static void sg_load_players(struct loaddata *loading)
Load '[player]'.
static void sg_load_map_tiles_extras(struct loaddata *loading)
Load extras to map.
static void sg_load_sanitycheck(struct loaddata *loading)
Sanity check for loaded game.
static void sg_load_event_cache(struct loaddata *loading)
Load '[event_cache]'.
static void sg_load_map_tiles_bases(struct loaddata *loading)
Load bases to map.
static void sg_special_set(struct tile *ptile, bv_extras *extras, char ch, const enum tile_special_type *idx, bool rivers_overlay)
Complicated helper function for loading specials from a savegame.
#define halfbyte_iterate_roads(r, num_roads_types)
void calc_civ_score(struct player *pplayer)
Calculates the civilization score for the player.
void script_server_state_load(struct section_file *file)
Load the scripting state from file.
void settings_game_load(struct section_file *file, const char *section)
Restore all settings from a savegame.
struct setting_list * level[OLEVELS_NUM]
bool str_to_int(const char *str, int *pint)
Convert 'str' to it's int reprentation if possible.
char scanin(char **buf, char *delimiters, char *dest, int size)
Scan in a word or set of words from start to but not including any of the given delimiters.
bool is_base64url(const char *s)
Check for valid base64url.
void randomize_base64url_string(char *s, size_t n)
generate a random string meeting criteria such as is_ascii_name(), is_base64url(),...
#define CLIP(lower, current, upper)
void spaceship_calc_derived(struct player_spaceship *ship)
Calculate and fill in the derived quantities about the spaceship.
void spaceship_init(struct player_spaceship *ship)
Initialize spaceship struct; could also be used to "cancel" a spaceship (eg, if/when capital-capture ...
#define NUM_SS_STRUCTURALS
struct specialist * specialist_by_rule_name(const char *name)
Return the specialist type with the given (untranslated!) rule name.
Specialist_type_id specialist_index(const struct specialist *sp)
Return the specialist index.
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
#define DEFAULT_SPECIALIST
void server_game_init(bool keep_ruleset_value)
Initialize game data for the server (corresponds to server_game_free).
const char * aifill(int amount)
Fill or remove players to meet the given aifill.
void server_game_free()
Free game data that we reinitialize as part of a server soft restart.
void identity_number_reserve(int id)
Mark identity number allocated.
struct server_arguments srvarg
void init_game_seed()
Initialize the game seed.
bool game_was_started()
Returns iff the game was started once upon a time.
void update_nations_with_startpos()
Update information about which nations have start positions on the map.
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
char name[MAX_LEN_CITYNAME]
int before_change_shields
struct city::@15::@17 server
citizens specialists[SP_MAX]
struct universal changed_from
struct unit_list * units_supported
struct civ_game::@28::@32 server
struct packet_scenario_description scenario_desc
struct packet_ruleset_control control
struct packet_game_info info
struct packet_scenario_info scenario
struct civ_map::@39::@41 server
char title[REPORT_TITLESIZE]
char body[REPORT_BODYSIZE]
struct loaddata::@96 trait
const char * secfile_options
struct loaddata::@98 multiplier
struct loaddata::@97 extra
struct loaddata::@103 ds_t
struct loaddata::@93 improvement
enum server_states server_state
struct loaddata::@94 technology
struct loaddata::@101 road
struct loaddata::@99 special
struct loaddata::@100 base
struct loaddata::@95 activities
struct loaddata::@102 specialist
struct section_file * file
enum ai_level skill_level
std::vector< ai_trait > traits
enum barbarian_type barbarian_type
int love[MAX_NUM_PLAYER_SLOTS]
enum diplstate_type max_state
bv_spaceship_structure structure
enum spaceship_state state
struct player * extras_owner
struct city_list * cities
QByteArray attribute_block
struct player_ai ai_common
struct government * target_government
char username[MAX_LEN_NAME]
struct player::@65::@67 server
struct government * government
char ranked_username[MAX_LEN_NAME]
struct player_economic economic
struct player_spaceship spaceship
struct player_score score
int multipliers[MAX_NUM_MULTIPLIERS]
struct nation_type * nation
struct nation_style * style
int multipliers_target[MAX_NUM_MULTIPLIERS]
int bulbs_researching_saved
Tech_type_id researching_saved
struct terrain * irrigation_result
struct terrain * mining_result
struct goods_type * goods
enum action_decision action_decision_want
struct extra_type * changed_from_target
struct unit::@76::@79 server
enum unit_activity changed_from
struct player * nationality
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)
Return citystyle of the city.
struct nation_style * style_by_rule_name(const char *name)
Returns style matching rule name or nullptr if there is no style with such name.
const char * style_rule_name(const struct nation_style *pstyle)
Return the (untranslated) rule name of the style.
struct nation_style * style_by_number(int id)
Return style of given id.
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
#define sz_strlcpy(dest, src)
void team_add_player(struct player *pplayer, struct team *pteam)
Set a player to a team.
const struct player_list * team_members(const struct team *pteam)
Returns the member list of the team.
struct team * team_new(struct team_slot *tslot)
Creates a new team for the slot.
struct team_slot * team_slot_by_number(int team_id)
Return the possibly unused and uninitialized team slot.
bool is_future_tech(Tech_type_id tech)
Is the given tech a future tech.
struct advance * advance_by_rule_name(const char *name)
Does a linear search of advances[].name.vernacular Returns nullptr when none match.
struct advance * valid_advance_by_number(const Tech_type_id id)
Returns pointer when the advance "exists" in this game, returns nullptr otherwise.
Tech_type_id advance_number(const struct advance *padvance)
Return the advance index.
const char * terrain_rule_name(const struct terrain *pterrain)
Return the (untranslated) rule name of the terrain.
struct terrain * terrain_by_rule_name(const char *name)
Return the terrain type matching the name, or T_UNKNOWN if none matches.
bool terrain_has_resource(const struct terrain *pterrain, const struct extra_type *presource)
Check for resource in terrain resources list.
#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)
Check if tile contains base providing effect for unit.
void tile_virtual_destroy(struct tile *vtile)
Frees all memory used by the virtual tile, including freeing virtual units in the tile's unit list an...
bool tile_set_label(struct tile *ptile, const char *label)
Sets label for tile.
void tile_set_resource(struct tile *ptile, struct extra_type *presource)
Set the given resource at the specified tile.
void tile_set_worked(struct tile *ptile, struct city *pcity)
Set the city/worker on the tile (may be nullptr).
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
struct tile * tile_virtual_new(const struct tile *ptile)
Returns a virtual tile.
#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)
Return goods type of given id.
void free_unit_orders(struct unit *punit)
Free and reset the unit's goto route (punit->pgr).
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
Load pcargo onto ptrans.
void set_unit_activity(struct unit *punit, enum unit_activity new_activity)
Assign a new untargeted task to a unit.
struct unit * unit_transport_get(const struct unit *pcargo)
Returns the transporter of the unit or nullptr if it is not transported.
bool can_unit_continue_current_activity(struct unit *punit)
Check if the unit's current activity is actually legal.
void set_unit_activity_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type *new_target)
assign a new targeted task to a unit.
void unit_virtual_destroy(struct unit *punit)
Free the memory used by virtual unit.
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Create a virtual unit skeleton.
void unit_tile_set(struct unit *punit, struct tile *ptile)
Set the tile location of the unit.
void unit_list_sort_ord_map(struct unit_list *punitlist)
Sorts the unit list by punit->server.ord_map values.
void unit_list_sort_ord_city(struct unit_list *punitlist)
Sorts the unit list by punit->server.ord_city values.
#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 char * unit_rule_name(const struct unit *punit)
Return the (untranslated) rule name of the unit.
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
Returns the upkeep of a unit of this type under the given government.
int utype_veteran_levels(const struct unit_type *punittype)
Return veteran levels of the given unit type.
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
struct unit_type * unit_type_by_rule_name(const char *name)
Returns the unit type that has the given (untranslated) rule name.
Unit_type_id utype_index(const struct unit_type *punittype)
Return the unit type index.
static bool utype_has_flag(const struct unit_type *punittype, int flag)
#define unit_type_iterate(_p)
#define unit_type_iterate_end
struct vision * vision_new(struct player *pplayer, struct tile *ptile)
Create a new vision source.
void vision_site_size_set(struct vision_site *psite, citizens size)
Set the city size.
bool vision_reveal_tiles(struct vision *vision, bool reveal_tiles)
Sets the can_reveal_tiles flag.
struct vision_site * vision_site_new(int identity, struct tile *location, struct player *owner)
Returns the basic structure.
void worklist_init(struct worklist *pwl)
Initialize a worklist to be empty.