36 "Irrigation",
"Mine",
"Pollution",
"Hut",
"Farmland",
123#define compat_current (compat_num - 1)
146 log_error(
"Savegame version newer than this build found (%d > %d). "
147 "Trying to load the game nevertheless ...", loading->
version,
153 "Unknown savefile format version (%d).", loading->
version);
159 log_normal(
_(
"Run compatibility function for version: <%d "
188 log_normal(
_(
"Run post load compatibility function for version: <%d "
211 return hex_chars[((value) >> ((halfbyte_wanted) * 4)) & 0xf];
235 "Unknown hex value: '%c' %d", ch, ch);
236 return (pch -
hex_chars) << (halfbyte * 4);
240 "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+";
252 "Unknown ascii value for num: '%c' %d", ch, ch);
290 if (spe < extra_type_list_size(elist)) {
291 return extra_type_list_get(elist, spe);
303 if (presource->data.resource->id_old_save == identifier) {
324 log_debug(
"Upgrading data from savegame to version 2.4.0");
342 "player%d.ncities", plrno);
344 for (i = 0; i < ncities; i++) {
346 "player%d.c%d.size", plrno, i);
349 "player%d.c%d.citizen%d", plrno, i, plrno);
372 if (strncmp(
name,
"kvb", 3) == 0) {
391 const int maxslots = 128, maxmapsize = 512;
392 const int lines = maxslots/32;
393 int xsize = 0, y, l, j, x;
394 unsigned int known_row_old[
lines * maxmapsize],
395 known_row[
lines * maxmapsize];
397 for (y = 0; y < maxmapsize; y++) {
400 memset(known_row_old, 0,
sizeof(known_row_old));
401 for (l = 0; l <
lines; l++) {
402 for (j = 0; j < 8; j++) {
405 "map.k%02d_%04d", l * 8 + j, y);
412 "Inconsistent xsize in map.k%02d_%04d",
414 for (x = 0; x < xsize; x++) {
425 memset(known_row, 0,
sizeof(known_row));
427 for (p = 0; p < maxslots; p++) {
429 for (x = 0; x < xsize; x++) {
433 if (known_row_old[l * xsize + x] & (1u << (p - l * 8))) {
434 known_row[l * xsize + x] |= (1u << (p - l * 32));
440 for (l = 0; l <
lines; l++) {
441 for (j = 0; j < 8; j++) {
445 for (x = 0; x < xsize; x++) {
450 "map.k%02d_%04d", l * 8 + j, y);
462 int i, new_opt = set_count;
465 "settings.gamestart_valid");
466 for (i = 0; i < set_count; i++) {
479 const char *
const nosave =
"GAMEOVER|QUITIDLE|INTERRUPT";
480 const char *
const save =
"TURN|GAMEOVER|QUITIDLE|INTERRUPT";
484 "settings.set%d.value", i)) {
488 "settings.set%d.value", new_opt);
491 "settings.set%d.value", i);
494 "settings.set%d.value", new_opt);
499 if (gamestart_valid) {
501 "settings.set%d.gamestart", i)) {
505 "settings.set%d.gamestart", new_opt);
508 "settings.set%d.gamestart", i);
511 "settings.set%d.gamestart", new_opt);
520 log_sg(
"Unexpected \"autosaves\" setting found in pre-2.4 "
521 "savefile. It may have been overridden.");
551 const char *modname[] = {
"Road",
"Railroad" };
552 const char *old_activities_names[] = {
579 log_debug(
"Upgrading data from savegame to version 2.5.0");
585 "savefile.roads_vector");
589 "savefile.activities_vector");
599 "settings.gamestart_valid");
600 for (i = 0; i < set_count; i++) {
614 "settings.set%d.value", i)) {
620 "settings.set%d.value", i);
623 "settings.set%d.value", i);
628 if (gamestart_valid) {
631 "settings.set%d.gamestart", i)) {
637 "settings.set%d.gamestart", i);
640 "settings.set%d.gamestart", i);
685 log_debug(
"Upgrading data from savegame to version 2.6.0");
704 char value_buffer[1024] =
"";
705 char gamestart_buffer[1024] =
"";
713 "settings.gamestart_valid");
716 for (i = 0; i < set_count; i++) {
729 "settings.set%d.value", i)) {
731 if (value_buffer[0] !=
'\0') {
740 "settings.set%d.gamestart", i)) {
742 if (gamestart_buffer[0] !=
'\0') {
759 "settings.set%d.value", i)) {
761 if (value_buffer[0] !=
'\0') {
770 "settings.set%d.gamestart", i)) {
772 if (gamestart_buffer[0] !=
'\0') {
784 "settings.set%d.value", i)) {
789 "settings.set%d.value", i);
797 "settings.set%d.gamestart", i)) {
802 "settings.set%d.gamestart", i);
813 "settings.set%d.value", i)) {
817 "settings.set%d.value", i);
820 "settings.set%d.value", i);
826 "settings.set%d.gamestart", i)) {
830 "settings.set%d.gamestart", i);
833 "settings.set%d.gamestart", i);
840 &team_pooled_research,
841 "settings.set%d.value", i),
846 "settings.set%d.value", i)) {
852 "settings.set%d.gamestart", i)) {
861 "settings.set%d.value", i)) {
871 new_set_count = set_count + 2;
895 if (gamestart_valid) {
918 enum barbarian_type new_barb_type;
930 "player%d.capital", plrno)) {
932 "player%d.got_first_city", plrno);
938 "player%d.unassigned_user", plrno);
942 "player%d.unassigned_ranked", plrno);
946 "player%d.ai.is_barbarian", plrno);
949 "player%d.ai.barb_type", plrno);
961 for (i = 0; i < tsize; i++) {
971 "player%d.trait.mod%d", plrno, i),
977 "player%d.units_built", plrno);
983 "player%d.units_killed", plrno);
989 "player%d.units_lost", plrno);
999 for (i = 0; i < units_num; i++) {
1003 "player%d.u%d.orders_last_move_safe",
1009 "player%d.u%d.orders_length",
1012 char orders_str[
len + 1];
1017 "player%d.u%d.orders_list",
1019 if ((p = strrchr(orders_str,
'm'))
1020 || (p = strrchr(orders_str,
'M'))) {
1023 "player%d.u%d.orders_list", plrno, i);
1033 "savefile.specialists_size");
1035 const char **modname;
1045 "savefile.specialists_vector");
1062 for (i = 0; i < ncities; i++) {
1102 for (i = 0; i <
ARRAY_SIZE(researches); i++) {
1118 if (team_pooled_research) {
1120 "player%d.team_no", plrno);
1126 "Research out of bounds (%d)!", i);
1129 if (researches[i] == -1) {
1132 researches[i] = count;
1142 "player%d.research.%s",
1150 "player%d.research.%s",
1158 "player%d.research.%s",
1166 "Research related entry marked as float.");
1182 "savefile.diplstate_type_size");
1184 const char **modname;
1189 modname =
fc_calloc(DS_LAST,
sizeof(*modname));
1191 for (j = 0; j < DS_LAST; j++) {
1192 modname[i++] = diplstate_type_name(j);
1197 "savefile.diplstate_type_vector");
1220 fc_snprintf(buf,
sizeof(buf),
"player%d.diplstate%d", plrno, i);
1232 if (closest == DS_NO_CONTACT
1233 && (current == DS_PEACE
1234 || current == DS_ALLIANCE)) {
1236 "player%d.name", plrno);
1238 "player%d.name", i);
1242 log_sg(
_(
"The save game is wrong about what the closest"
1243 " relationship %s (player %d) and %s (player %d) have had is."
1245 name1, plrno, name2, i);
1257 int old_def,
bool keep_default)
1263 if (value != old_def || !keep_default) {
1290 log_debug(
"Upgrading data from savegame to version 3.0.0");
1311 const char *flag_names[1];
1319 flag_names[0] = plr_flag_id_name(PLRF_AI);
1322 "player%d.flags", plrno);
1330 for (i = 0; i < num; i++) {
1333 fc_snprintf(buf,
sizeof(buf),
"player%d.u%d.born", plrno, i);
1339 "player%d.ncities", plrno);
1341 for (i = 0; i < num; i++) {
1344 fc_snprintf(buf,
sizeof(buf),
"player%d.c%d.turn_founded", plrno, i);
1353 "settings.set_count");
1357 "game.meta_usermessage")) {
1358 const char *metamessage;
1361 "game.meta_message");
1365 "settings.set%d.name", num_settings);
1367 "settings.set%d.value", num_settings);
1369 "settings.set%d.gamestart", num_settings);
1377 for (i = 0; i < event_count; i++) {
1384 "event_cache.events%d.event", i);
1403 "savefile.server_side_agent_size");
1405 if (ssa_size != 0) {
1412 "savefile.server_side_agent_size");
1413 if (SSA_COUNT > 0) {
1414 const char **modname;
1419 modname =
fc_calloc(SSA_COUNT,
sizeof(*modname));
1421 for (j = 0; j < SSA_COUNT; j++) {
1422 modname[i++] = server_side_agent_name(j);
1427 "savefile.server_side_agent_list");
1451 "player%d.u%d.server_side_agent",
1466 "player%d.u%d.server_side_agent",
1470 "player%d.u%d.server_side_agent",
1489 log_debug(
"Upgrading data from savegame to version 3.1.0");
1508 const char *action_unitstr;
1512 "player%d.u%d.orders_length",
1516 "player%d.u%d.action_list",
1520 if (order_len > strlen(action_unitstr)) {
1521 order_len = strlen(action_unitstr);
1524 for (order_num = 0; order_num < order_len; order_num++) {
1525 int unconverted_action_id;
1527 if (action_unitstr[order_num] ==
'?') {
1528 unconverted_action_id = -1;
1530 unconverted_action_id =
char2num(action_unitstr[order_num]);
1533 if (order_num == 0) {
1536 "player%d.u%d.action_vec",
1540 "player%d.u%d.action_vec,%d",
1541 plrno,
unit, order_num);
1552 "savefile.action_size");
1554 if (action_count > 0) {
1555 const char **modname;
1556 const char **savemod;
1558 const char *dur_name =
"Disband Unit Recover";
1561 "savefile.action_vector");
1563 savemod =
fc_calloc(action_count,
sizeof(*savemod));
1565 for (j = 0; j < action_count; j++) {
1567 savemod[j] = dur_name;
1569 savemod[j] = modname[j];
1574 "savefile.action_vector");
1586 bool gamestart_valid
1588 "settings.gamestart_valid");
1591 if (gamestart_valid) {
1592 for (i = 0; i < set_count; i++) {
1601 "settings.set%d.gamesetdef", i);
1625 switch (
order->activity) {
1626 case ACTIVITY_FALLOUT:
1627 case ACTIVITY_POLLUTION:
1629 case ACTIVITY_IRRIGATE:
1630 case ACTIVITY_PLANT:
1631 case ACTIVITY_CULTIVATE:
1632 case ACTIVITY_TRANSFORM:
1633 case ACTIVITY_CONVERT:
1634 case ACTIVITY_FORTIFYING:
1636 case ACTIVITY_GEN_ROAD:
1637 case ACTIVITY_PILLAGE:
1649 case ACTIVITY_SENTRY:
1652 case ACTIVITY_EXPLORE:
1655 case ACTIVITY_FORTIFIED:
1656 case ACTIVITY_OLD_ROAD:
1657 case ACTIVITY_OLD_RAILROAD:
1658 case ACTIVITY_FORTRESS:
1659 case ACTIVITY_AIRBASE:
1660 case ACTIVITY_PATROL_UNUSED:
1662 case ACTIVITY_UNKNOWN:
1663 log_error(
"Activity %d is not supposed to appear in unit orders",
1678 case DIR8_NORTHEAST:
1679 return DIR8_SOUTHWEST;
1682 case DIR8_SOUTHEAST:
1683 return DIR8_NORTHWEST;
1686 case DIR8_SOUTHWEST:
1687 return DIR8_NORTHEAST;
1690 case DIR8_NORTHWEST:
1691 return DIR8_SOUTHEAST;
1703 struct tile *current_tile;
1704 struct tile *tgt_tile;
1714 for (i = act_unit->
orders.
index; i > 0 && current_tile != NULL; i--) {
1720 && direction8_is_valid(prev_order->
dir)) {
1727 for (i = 0; i < act_unit->
orders.
length && current_tile != NULL; i++) {
1740 if (!direction8_is_valid(
order->dir)) {
1742 tgt_tile = current_tile;
1749 if (tgt_tile != NULL) {
1762 current_tile = tgt_tile;
1765 current_tile = NULL;
1768 current_tile = tgt_tile;
1772 if (current_tile == NULL) {
1828 == ACTION_SPY_TARGETED_SABOTAGE_CITY)
1830 == ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC))) {
1835 == ACTION_SPY_TARGETED_SABOTAGE_CITY)
1838 = ACTION_SPY_SABOTAGE_CITY_PRODUCTION;
1842 == ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC)
1845 = ACTION_SPY_SABOTAGE_CITY_PRODUCTION_ESC;
1885 switch (old_level) {
1887 return AI_LEVEL_AWAY;
1889 return AI_LEVEL_NOVICE;
1891 return AI_LEVEL_EASY;
1893 return AI_LEVEL_NORMAL;
1895 return AI_LEVEL_HARD;
1897 return AI_LEVEL_CHEATING;
1900 return AI_LEVEL_EXPERIMENTAL;
1902 return AI_LEVEL_HARD;
1906 return ai_level_invalid();
1916 return NOT_A_BARBARIAN;
1918 return LAND_BARBARIAN;
1920 return SEA_BARBARIAN;
1923 return barbarian_type_invalid();
int action_number(const struct action *action)
enum unit_activity actres_get_activity(enum action_result result)
static struct action * action_by_number(action_id act_id)
#define action_iterate_end
#define action_iterate(_act_)
struct @124::my_agent entries[MAX_AGENTS]
const char * default_ai_type_name(void)
struct extra_type * base_extra_get(const struct base_type *pbase)
struct base_type * base_by_number(const Base_type_id id)
bool has_capability(const char *cap, const char *capstr)
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
#define GAME_DEFAULT_REVOLENTYPE
#define GAME_DEFAULT_SCORETURN
#define GAME_DEFAULT_SAVETURNS
#define GAME_DEFAULT_TEAM_POOLED_RESEARCH
#define fc_assert(condition)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
#define log_normal(message,...)
#define log_error(message,...)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
#define fc_calloc(n, esz)
int player_slot_count(void)
int player_slot_index(const struct player_slot *pslot)
#define player_slots_iterate(_pslot)
#define players_iterate_alive_end
#define player_slots_iterate_end
#define players_iterate_alive(_pplayer)
const char * secfile_error(void)
bool secfile_lookup_int(const struct section_file *secfile, int *ival, const char *path,...)
bool secfile_entry_delete(struct section_file *secfile, const char *path,...)
bool entry_set_name(struct entry *pentry, const char *name)
bool secfile_lookup_enum_data(const struct section_file *secfile, int *pvalue, bool bitwise, secfile_enum_name_data_fn_t name_fn, secfile_data_t data, const char *path,...)
const struct entry_list * section_entries(const struct section *psection)
const char ** secfile_lookup_str_vec(const struct section_file *secfile, size_t *dim, const char *path,...)
const char * entry_name(const struct entry *pentry)
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 section * secfile_section_by_name(const struct section_file *secfile, const char *name)
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_replace_str_vec(secfile, strings, dim, path,...)
#define secfile_insert_int(secfile, value, path,...)
#define secfile_insert_str_vec(secfile, strings, dim, path,...)
#define secfile_replace_int(secfile, value, path,...)
#define entry_list_iterate_end
#define secfile_insert_str(secfile, string, path,...)
#define secfile_insert_bool(secfile, value, path,...)
#define secfile_replace_str(secfile, string, path,...)
#define entry_list_iterate(entlist, pentry)
#define secfile_replace_bool(secfile, value, path,...)
const void * secfile_data_t
struct extra_type * road_extra_get(const struct road_type *proad)
struct road_type * road_by_number(Road_type_id id)
static void compat_post_load_030100(struct loaddata *loading, enum sgf_version format_class)
struct extra_type * resource_by_identifier(const char identifier)
int current_compat_ver(void)
static void compat_load_030000(struct loaddata *loading, enum sgf_version format_class)
static const char num_chars[]
static const char * killcitizen_enum_str(secfile_data_t data, int bit)
enum barbarian_type barb_type_convert(int old_type)
static char * special_names[]
static struct compatibility compat[]
void set_unit_activity_road(struct unit *punit, Road_type_id road)
static void compat_load_020400(struct loaddata *loading, enum sgf_version format_class)
static void upgrade_unit_order_targets(struct unit *act_unit)
char bin2ascii_hex(int value, int halfbyte_wanted)
static const int compat_num
static void compat_load_020600(struct loaddata *loading, enum sgf_version format_class)
static enum direction8 dir_opposite(enum direction8 dir)
void(* load_version_func_t)(struct loaddata *loading, enum sgf_version format_class)
static void upgrade_server_side_agent(struct loaddata *loading)
void sg_load_compat(struct loaddata *loading, enum sgf_version format_class)
static void unit_order_activity_to_action(struct unit *act_unit)
static char * revolentype_str(enum revolen_type type)
static int increase_secfile_turn_int(struct loaddata *loading, const char *key, int old_def, bool keep_default)
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)
static void compat_load_020500(struct loaddata *loading, enum sgf_version format_class)
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)
static void compat_load_030100(struct loaddata *loading, enum sgf_version format_class)
static void insert_server_side_agent(struct loaddata *loading, enum sgf_version format_class)
#define sg_check_ret(...)
#define sg_warn(condition, message,...)
#define sg_failure_ret_val(condition, _val, message,...)
#define sg_failure_ret(condition, message,...)
struct specialist * specialist_by_number(const Specialist_type_id id)
const char * specialist_rule_name(const struct specialist *sp)
Specialist_type_id specialist_count(void)
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
enum action_result result
struct civ_map::@41::@43 server
const load_version_func_t post_load
const load_version_func_t load
struct loaddata::@110 action
struct section_file * file
struct name_translation name
enum unit_activity activity
enum unit_activity activity
struct extra_type * activity_target
enum server_side_agent ssa_controller
int fc_snprintf(char *str, size_t n, const char *format,...)
int fc_strcasecmp(const char *str0, const char *str1)
#define sz_strlcpy(dest, src)
#define sz_strlcat(dest, src)
int team_slot_count(void)
char terrain_identifier(const struct terrain *pterrain)
const char * terrain_rule_name(const struct terrain *pterrain)
#define terrain_type_iterate(_p)
#define terrain_type_iterate_end
void free_unit_orders(struct unit *punit)
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
void set_unit_activity_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type *new_target)
bool unit_has_orders(const struct unit *punit)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
bool utype_is_moved_to_tgt_by_action(const struct action *paction, const struct unit_type *utype)
const char * unit_rule_name(const struct unit *punit)
bool utype_is_unmoved_by_action(const struct action *paction, const struct unit_type *utype)