From 0c9396ca327d38dca772713d05892d5b58d5dcb9 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 18 Feb 2023 17:40:05 +0200 Subject: [PATCH 4/5] Clean out 3.1-to-3.2 rscompat code See osdn #47397 Signed-off-by: Marko Lindqvist --- server/rscompat.c | 367 ---------------------------------------------- server/rscompat.h | 28 +--- server/ruleset.c | 253 ++++---------------------------- server/ruleset.h | 2 + server/settings.c | 36 ----- 5 files changed, 35 insertions(+), 651 deletions(-) diff --git a/server/rscompat.c b/server/rscompat.c index 06896b6cd7..d7babadd4e 100644 --- a/server/rscompat.c +++ b/server/rscompat.c @@ -337,15 +337,6 @@ bool rscompat_names(struct rscompat_info *info) **************************************************************************/ static bool effect_list_compat_cb(struct effect *peffect, void *data) { - struct rscompat_info *info = (struct rscompat_info *)data; - - if (info->version < RSFORMAT_3_2) { - if (peffect->type == EFT_GROWTH_FOOD) { - /* Equivalent Shrink_Food effect for each old Growth_Food */ - effect_copy(peffect, EFT_SHRINK_FOOD); - } - } - /* Go to the next effect. */ return TRUE; } @@ -365,65 +356,6 @@ void rscompat_postprocess(struct rscompat_info *info) * the new effects from being upgraded by accident. */ iterate_effect_cache(effect_list_compat_cb, info); - if (info->version < RSFORMAT_3_2) { - struct effect *peffect; - - /* Nuke blast radius has moved to the ruleset. */ - action_iterate(act_id) { - const struct action *paction = action_by_number(act_id); - - if (!(action_has_result(paction, ACTRES_NUKE) - || action_has_result(paction, ACTRES_NUKE_UNITS) - || action_has_result(paction, ACTRES_SPY_NUKE))) { - /* Not relevant. */ - continue; - } - - peffect = effect_new(EFT_NUKE_BLAST_RADIUS_1_SQ, 2, NULL); - effect_req_append(peffect, req_from_str("Action", "Local", - FALSE, TRUE, FALSE, - action_rule_name(paction))); - } action_iterate_end; - - action_enablers_iterate(ae) { - if (ae->action == ACTION_CLEAN_POLLUTION) { - /* TODO: Stop making the copy to preserve enabler for - * the original action. */ - struct action_enabler *copy = action_enabler_copy(ae); - - copy->action = ACTION_CLEAN; - requirement_vector_append(©->target_reqs, - req_from_str("ExtraFlag", "Local", - FALSE, TRUE, TRUE, - "CleanAsPollution")); - - action_enabler_add(copy); - } - if (ae->action == ACTION_CLEAN_FALLOUT) { - /* TODO: Stop making the copy to preserve enabler for - * the original action. */ - struct action_enabler *copy = action_enabler_copy(ae); - - copy->action = ACTION_CLEAN; - requirement_vector_append(©->target_reqs, - req_from_str("ExtraFlag", "Local", - FALSE, TRUE, TRUE, - "CleanAsFallout")); - - action_enabler_add(copy); - } - } action_enablers_iterate_end; - - /* That Attack and Bombard can't destroy a city - * has moved to the ruleset. */ - peffect = effect_new(EFT_UNIT_NO_LOSE_POP, - effect_value_will_make_positive( - EFT_UNIT_NO_LOSE_POP), - NULL); - effect_req_append(peffect, req_from_str("MinSize", "City", FALSE, FALSE, - FALSE, "2")); - } - /* Make sure that all action enablers added or modified by the * compatibility post processing fulfills all hard action requirements. */ rscompat_enablers_add_obligatory_hard_reqs(); @@ -436,302 +368,3 @@ void rscompat_postprocess(struct rscompat_info *info) * using it risks an unexpected change on the next load and save. */ autoadjust_ruleset_data(); } - -/**********************************************************************//** - Update improvement genus for coinage improvements. -**************************************************************************/ -enum impr_genus_id rscompat_genus_3_2(struct rscompat_info *compat, - const bv_impr_flags flags, - enum impr_genus_id old_genus) -{ - if (compat->compat_mode && compat->version < RSFORMAT_3_2) { - if (BV_ISSET(flags, IF_GOLD) && IG_SPECIAL == old_genus) { - return IG_CONVERT; - } - } - - return old_genus; -} - -/**********************************************************************//** - Update requirement range for certain requirement types. -**************************************************************************/ -const char *rscompat_req_range_3_2(struct rscompat_info *compat, - const char *type, - const char *old_range) -{ - if (compat->compat_mode && compat->version < RSFORMAT_3_2) { - /* Requirement types that refer to the target tile and now use the - * "Tile" range instead of the "Local" range */ - if (!fc_strcasecmp(req_range_name(REQ_RANGE_LOCAL), old_range) - && (!fc_strcasecmp(universals_n_name(VUT_TERRAIN), type) - || !fc_strcasecmp(universals_n_name(VUT_TERRAINCLASS), type) - || !fc_strcasecmp(universals_n_name(VUT_TERRAINALTER), type) - || !fc_strcasecmp(universals_n_name(VUT_CITYTILE), type) - || !fc_strcasecmp(universals_n_name(VUT_TERRFLAG), type) - || !fc_strcasecmp(universals_n_name(VUT_ROADFLAG), type) - || !fc_strcasecmp(universals_n_name(VUT_EXTRA), type) - || !fc_strcasecmp(universals_n_name(VUT_MAXTILEUNITS), type) - || !fc_strcasecmp(universals_n_name(VUT_EXTRAFLAG), type))) { - return req_range_name(REQ_RANGE_TILE); - } - } - - return old_range; -} - -/**********************************************************************//** - Update individual requirements. -**************************************************************************/ -void rscompat_req_adjust_3_2(const struct rscompat_info *compat, - const char **ptype, const char **pname, - bool *ppresent, const char *sec_name) -{ - char buf[1024]; - - if (compat->compat_mode && compat->version < RSFORMAT_3_2) { - /* Recreate old "alltemperate" and "singlepole" ServerSetting - * requirements with MinLatitude and MaxLatitude. */ - if (!fc_strcasecmp(universals_n_name(VUT_SERVERSETTING), *ptype)) { - if (!fc_strcasecmp("alltemperate", *pname)) { - /* alltemperate implies no latitudes != 500 - * !alltemperate implies latitudes 0 to 1000 - * ~> alltemperate enabled iff no latitude >= 750 - * (other numbers in [501,1000] would work as well) - * (no latitude <= some number in [0, 499] would work as well) */ - *ptype = universals_n_name(VUT_MINLATITUDE); - *pname = "750"; - *ppresent = !(*ppresent); - - if (compat->log_cb != NULL) { - /* Inform the user that there are different solutions */ - fc_snprintf(buf, sizeof(buf), - "Replaced 'alltemperate' server setting requirement " - "in %s with a MinLatitude requirement. Other " - "equivalent requirements are possible; make sure it " - "makes sense.", sec_name); - compat->log_cb(buf); - } - } else if (!fc_strcasecmp("singlepole", *pname)) { - /* Assume we're updating a sane ruleset, i.e. singlepole reqs only - * possible/relevant when alltemperate is already disabled. - * singlepole implies no latitudes < 0 - * !singlepole implies latitudes -1000 to -1 (given !alltemperate) - * ~> singlepole enabled iff no latitude <= -500 - * (other numbers in [-1000,-1] would work as well) */ - *ptype = universals_n_name(VUT_MAXLATITUDE); - *pname = "-500"; - *ppresent = !(*ppresent); - - if (compat->log_cb != NULL) { - /* Inform the user that there are different solutions */ - fc_snprintf(buf, sizeof(buf), - "Replaced 'singlepole' server setting requirement " - "in %s with a MaxLatitude requirement. Other " - "equivalent requirements are possible; make sure it " - "makes sense.", sec_name); - compat->log_cb(buf); - } - } - } - } -} - -/**********************************************************************//** - Add user extra flags needed in ruleset update from 3.1 to 3.2 - - @return Number of flags added -**************************************************************************/ -int add_user_extra_flags_3_2(int start) -{ - int i = 0; - - /* TODO: Do we need "CleanAsPollution", or can we treat - * it as the default while "CleanAsFallout" is special case? */ - set_user_extra_flag_name(EF_USER_FLAG_1 + start + i++, - "CleanAsPollution", NULL); - set_user_extra_flag_name(EF_USER_FLAG_1 + start + i++, - "CleanAsFallout", NULL); - - return i; -} - -/**********************************************************************//** - Adjust values of an extra loaded from a 3.1 ruleset. -**************************************************************************/ -void rscompat_extra_adjust_3_2(struct extra_type *pextra) -{ - /* Huts were not allowed on polar regions - * (defined as "Frozen" - but that was just workaround we don't want to reproduce) */ - if (is_extra_caused_by(pextra, EC_HUT)) { - requirement_vector_append(&pextra->reqs, - req_from_str("MaxLatitude", "Tile", - FALSE, TRUE, FALSE, - "980")); - requirement_vector_append(&pextra->reqs, - req_from_str("MinLatitude", "Tile", - FALSE, TRUE, FALSE, - "-980")); - } - - /* Don't give these flags to extras that have been using - * removal time not tied to terrain, so it won't get - * overridden by "ActivityTime" effects we also add. */ - if (is_extra_removed_by(pextra, ERM_CLEANPOLLUTION) - && pextra->removal_time == 0) { - BV_SET(pextra->flags, - extra_flag_id_by_name("CleanAsPollution", fc_strcasecmp)); - } - - if (is_extra_removed_by(pextra, ERM_CLEANFALLOUT) - && pextra->removal_time == 0) { - BV_SET(pextra->flags, - extra_flag_id_by_name("CleanAsFallout", fc_strcasecmp)); - } -} - -/**********************************************************************//** - Determine whether the given setting should be skipped and - rscompat_settings_do_special_handling should be called. -**************************************************************************/ -bool rscompat_setting_needs_special_handling(const char *name) -{ - /* Replaced by 'northlatitude' and 'southlatitude' */ - if (!fc_strcasecmp("alltemperate", name) - || !fc_strcasecmp("singlepole", name)) { - return TRUE; - } - - return FALSE; -} - -/**********************************************************************//** - Special handling for complex server setting changes. -**************************************************************************/ -void rscompat_settings_do_special_handling(struct section_file *file, - const char *section, void (*setdef)(struct setting *pset)) -{ - /* Replace 'alltemperate' and 'singlepole' with appropriate - * 'northlatitude' and 'southlatitude' settings */ - { - bool has_either = FALSE, locks_either = FALSE; - bool alltemperate = FALSE, singlepole = FALSE; - const char *name; - int j; - - for (j = 0; (name = secfile_lookup_str_default(file, NULL, - "%s.set%d.name", - section, j)); j++) { - bool *pval; - - if (!fc_strcasecmp("alltemperate", name)) { - pval = &alltemperate; - } else if (!fc_strcasecmp("singlepole", name)) { - pval = &singlepole; - } else { - /* neither of the settings we care for */ - continue; - } - - has_either = TRUE; - - if (!secfile_lookup_bool(file, pval, "%s.set%d.value", section, j)) { - log_error("Can't read value for setting '%s': %s", name, - secfile_error()); - } - - if (secfile_lookup_bool_default(file, FALSE, - "%s.set%d.lock", section, j)) { - locks_either = TRUE; - } - } - - if (has_either) { - int north_latitude = alltemperate ? 500 : 1000; - int south_latitude = alltemperate ? 500 : (singlepole ? 0 : -1000); - struct setting *pset; - char reject_msg[256], buf[256]; - -#define SET_INT_SETTING(name, value, lock) \ - pset = setting_by_name(name); \ - fc_assert(pset != NULL && setting_type(pset) == SST_INT); \ - \ - if (setting_int_set(pset, value, NULL, reject_msg, \ - sizeof(reject_msg))) { \ - log_normal(_("Ruleset: '%s' has been set to %s."), \ - setting_name(pset), \ - setting_value_name(pset, TRUE, buf, sizeof(buf))); \ - } else { \ - log_error("%s", reject_msg); \ - } \ - \ - setdef(pset); \ - \ - if (lock) { \ - setting_ruleset_lock_set(pset); \ - log_normal(_("Ruleset: '%s' has been locked by the ruleset."), \ - setting_name(pset)); \ - } - - SET_INT_SETTING("northlatitude", north_latitude, locks_either); - SET_INT_SETTING("southlatitude", south_latitude, locks_either); - -#undef SET_INT_SETTING - } - } -} - -/**********************************************************************//** - Migrate pollution and fallout time to extra specific removal times. -**************************************************************************/ -bool rscompat_terrain_extra_rmtime_3_2(struct section_file *file, - const char *tsection, - struct terrain *pterrain) -{ - int pol_time = 3; /* Old default */ - int fal_time = 3; /* Old default */ - const char *filename = secfile_name(file); - bool ok = TRUE; - - lookup_time(file, &pol_time, - tsection, "clean_pollution_time", filename, NULL, &ok); - lookup_time(file, &fal_time, - tsection, "clean_fallout_time", filename, NULL, &ok); - - if (pol_time == fal_time) { - extra_type_iterate(pextra) { - pterrain->extra_removal_times[extra_index(pextra)] = pol_time; - } extra_type_iterate_end; - } else { - struct effect *peffect; - - extra_type_iterate(pextra) { - pterrain->extra_removal_times[extra_index(pextra)] = pol_time; - } extra_type_iterate_end; - - peffect = effect_new(EFT_ACTIVITY_TIME, fal_time, NULL); - effect_req_append(peffect, req_from_str("ExtraFlag", "Local", - FALSE, TRUE, TRUE, - "CleanAsFallout")); - effect_req_append(peffect, req_from_str("Terrain", "Tile", - FALSE, TRUE, TRUE, - terrain_rule_name(pterrain))); - } - - return ok; -} - -/**********************************************************************//** - Adjust freeciv-3.1 ruleset action ui_name to freeciv-3.2 -**************************************************************************/ -const char *rscompat_action_ui_name_S3_2(struct rscompat_info *compat, - int act_id) -{ - if (compat->compat_mode && compat->version < RSFORMAT_3_2) { - if (act_id == ACTION_TRANSPORT_DEBOARD) { - return "ui_name_transport_alight"; - } - } - - return NULL; -} diff --git a/server/rscompat.h b/server/rscompat.h index 456985a462..63651da646 100644 --- a/server/rscompat.h +++ b/server/rscompat.h @@ -56,33 +56,7 @@ struct requirement_vector *lookup_req_list(struct section_file *file, const char *sub, const char *rfor); -/* Functions specific to 3.1 -> 3.2 transition */ -enum impr_genus_id rscompat_genus_3_2(struct rscompat_info *compat, - const bv_impr_flags flags, - enum impr_genus_id old_genus); -const char *rscompat_req_range_3_2(struct rscompat_info *compat, - const char *type, - const char *old_range); -void rscompat_req_adjust_3_2(const struct rscompat_info *compat, - const char **ptype, const char **pname, - bool *ppresent, const char *sec_name); -int add_user_extra_flags_3_2(int start); -void rscompat_extra_adjust_3_2(struct extra_type *pextra); -bool rscompat_setting_needs_special_handling(const char *name); -void rscompat_settings_do_special_handling(struct section_file *file, - const char *section, void (*setdef)(struct setting *pset)); -bool rscompat_terrain_extra_rmtime_3_2(struct section_file *file, - const char *tsection, - struct terrain *pterrain); -const char *rscompat_action_ui_name_S3_2(struct rscompat_info *compat, - int act_id); - -/* In ruleset.c, but should not be in public interface - make static again once - * rscompat.c no longer needs. */ -bool lookup_time(const struct section_file *secfile, int *turns, - const char *sec_name, const char *property_name, - const char *filename, const char *item_name, - bool *ok); +/* Functions specific to 3.2 -> 3.3 transition */ #ifdef __cplusplus } diff --git a/server/ruleset.c b/server/ruleset.c index 74dff2763a..69698bd655 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -733,10 +733,6 @@ struct requirement_vector *lookup_req_list(struct section_file *file, return NULL; } - if (compat->compat_mode) { - range = rscompat_req_range_3_2(compat, type, range); - } - survives = FALSE; if ((pentry = secfile_entry_lookup(file, "%s.%s%d.survives", sec, sub, j)) @@ -763,10 +759,6 @@ struct requirement_vector *lookup_req_list(struct section_file *file, "'%s.%s%d'.", filename, sec, sub, j); } - if (compat->compat_mode) { - rscompat_req_adjust_3_2(compat, &type, &name, &present, sec); - } - req = req_from_str(type, range, survives, present, quiet, name); if (req.source.kind == universals_n_invalid()) { ruleset_error(NULL, LOG_ERROR, @@ -878,39 +870,6 @@ static bool lookup_tech(struct section_file *file, return TRUE; } -/**********************************************************************//** - Lookup a string prefix.entry in the file and return the corresponding - improvement pointer. Return B_NEVER for match "None" or - can't match. - If description is not NULL, it is used in the warning message - instead of prefix (eg pass unit->name instead of prefix="units2.u27") -**************************************************************************/ -static bool lookup_building(struct section_file *file, - const char *prefix, const char *entry, - struct impr_type **result, - const char *filename, - const char *description) -{ - const char *sval; - bool ok = TRUE; - - sval = secfile_lookup_str_default(file, NULL, "%s.%s", prefix, entry); - if (!sval || strcmp(sval, "None") == 0) { - *result = B_NEVER; - } else { - *result = improvement_by_rule_name(sval); - - if (B_NEVER == *result) { - ruleset_error(NULL, LOG_ERROR, - "\"%s\" %s %s: couldn't match \"%s\".", - filename, (description ? description : prefix), entry, sval); - ok = FALSE; - } - } - - return ok; -} - /**********************************************************************//** Lookup a prefix.entry string vector in the file and fill in the array, which should hold MAX_NUM_UNIT_LIST items. The output array is @@ -1261,10 +1220,10 @@ static bool lookup_terrain(struct section_file *file, Returns FALSE if not found in secfile, but TRUE even if validation failed. Sets *ok to FALSE if validation failed, leaves it alone otherwise. **************************************************************************/ -bool lookup_time(const struct section_file *secfile, int *turns, - const char *sec_name, const char *property_name, - const char *filename, const char *item_name, - bool *ok) +static bool lookup_time(const struct section_file *secfile, int *turns, + const char *sec_name, const char *property_name, + const char *filename, const char *item_name, + bool *ok) { /* Assumes that PACKET_UNIT_INFO.activity_count in packets.def is UINT16 */ const int max_turns = 65535 / ACTIVITY_FACTOR; @@ -2197,92 +2156,18 @@ static bool load_ruleset_units(struct section_file *file, const int i = utype_index(u); const struct section *psection = section_list_get(sec, i); const char *sec_name = section_name(psection); + struct requirement_vector *reqs; - if (compat->compat_mode && compat->version < RSFORMAT_3_2) { - struct advance *adv_req; - struct impr_type *impr_req = NULL; - - if (!lookup_tech(file, &adv_req, sec_name, - "tech_req", filename, - rule_name_get(&u->name))) { - ok = FALSE; - break; - } - if (adv_req == A_NEVER) { - ruleset_error(NULL, LOG_ERROR, "%s lacks valid tech_req.", - rule_name_get(&u->name)); - ok = FALSE; - break; - } else if (adv_req != advance_by_number(A_NONE)) { - requirement_vector_append(&u->build_reqs, - req_from_values(VUT_ADVANCE, REQ_RANGE_PLAYER, - FALSE, TRUE, FALSE, - advance_number(adv_req))); - } - - /* Read the government build requirement from the old ruleset format - * and put it in unit_type's build_reqs requirement vector. - * The build_reqs requirement vector isn't ready to be exposed in the - * ruleset yet. - * Barbarians can build certain units as long as anyone in the world - * has the required tech. Regular players must have the required tech - * them self to build the same unit. One way to solve this is to make - * unit building an action enabler controlled action with a city (not - * unit) actor. - * Putting a requirement vector on unit types in the ruleset will - * force ruleset authors to change all their unit type build - * requirements to a requirement vector. Forcing them to convert their - * unit type requirements again in the next version (should building be - * switched to an action enabler with a city actor) is not good. */ - if (NULL != section_entry_by_name(psection, "gov_req")) { - char tmp[200] = "\0"; - struct government *need_government; - - fc_strlcat(tmp, section_name(psection), sizeof(tmp)); - fc_strlcat(tmp, ".gov_req", sizeof(tmp)); - need_government = lookup_government(file, tmp, filename, NULL); - if (need_government == NULL) { - ok = FALSE; - break; - } - requirement_vector_append(&u->build_reqs, req_from_values( - VUT_GOVERNMENT, REQ_RANGE_PLAYER, - FALSE, TRUE, FALSE, - government_number(need_government))); - } - - /* Read the building build requirement from the old ruleset format - * and put it in unit_type's build_reqs requirement vector. - * The build_reqs requirement vector isn't ready to be exposed in the - * ruleset yet. - * See the comment for gov_req above for why. */ - if (!lookup_building(file, sec_name, "impr_req", - &impr_req, filename, - rule_name_get(&u->name))) { - ok = FALSE; - break; - } - if (impr_req) { - requirement_vector_append(&u->build_reqs, req_from_values( - VUT_IMPROVEMENT, REQ_RANGE_CITY, - FALSE, TRUE, FALSE, - improvement_number(impr_req))); - } - } else { - /* Freeciv-3.2 format */ - struct requirement_vector *reqs; - - reqs = lookup_req_list(file, compat, sec_name, "reqs", - utype_rule_name(u)); - - if (reqs == NULL) { - ok = FALSE; - break; - } + reqs = lookup_req_list(file, compat, sec_name, "reqs", + utype_rule_name(u)); - requirement_vector_copy(&u->build_reqs, reqs); + if (reqs == NULL) { + ok = FALSE; + break; } + requirement_vector_copy(&u->build_reqs, reqs); + if (!load_ruleset_veteran(file, sec_name, &u->veteran, msg, sizeof(msg))) { ruleset_error(NULL, LOG_ERROR, @@ -2803,10 +2688,6 @@ static bool load_ruleset_buildings(struct section_file *file, break; } - if (compat->compat_mode) { - b->genus = rscompat_genus_3_2(compat, b->flags, b->genus); - } - requirement_vector_copy(&b->reqs, reqs); { @@ -2939,17 +2820,13 @@ static bool load_terrain_names(struct section_file *file, set_user_extra_flag_name(EF_USER_FLAG_1 + i, flag, helptxt); } - if (compat->compat_mode && compat->version < RSFORMAT_3_2) { - i += add_user_extra_flags_3_2(i); - } - if (ok) { /* Blank the remaining extra user flag slots. */ for (; i < MAX_NUM_USER_EXTRA_FLAGS; i++) { set_user_extra_flag_name(EF_USER_FLAG_1 + i, NULL, NULL); } - /* terrain names */ + /* Terrain names */ sec = secfile_sections_by_name_prefix(file, TERRAIN_SECTION_PREFIX); if (NULL == sec || 0 == (nval = section_list_size(sec))) { @@ -3539,13 +3416,6 @@ static bool load_ruleset_terrain(struct section_file *file, pterrain->extra_removal_times[extra_index(pextra)] = 0; } extra_type_iterate_end; - if (compat->compat_mode && compat->version < RSFORMAT_3_2) { - if (!rscompat_terrain_extra_rmtime_3_2(file, tsection, pterrain)) { - ok = FALSE; - break; - } - } - for (j = 0; (ename = secfile_lookup_str_default(file, NULL, "%s.extra_settings%d.extra", tsection, j)); j++) { @@ -3986,10 +3856,6 @@ static bool load_ruleset_terrain(struct section_file *file, pextra->visibility_req = advance_number(vis_req); pextra->helptext = lookup_strvec(file, section, "helptext"); - - if (compat->compat_mode && compat->version < RSFORMAT_3_2) { - rscompat_extra_adjust_3_2(pextra); - } } extra_type_iterate_end; } @@ -6072,8 +5938,6 @@ static bool load_ruleset_cities(struct section_file *file, } if (ok) { - bool def_ubuild_nat = RS_DEFAULT_UBUILD_NAT; - /* civ1 & 2 didn't reveal tiles */ game.server.vision_reveal_tiles = secfile_lookup_bool_default(file, GAME_DEFAULT_VISION_REVEAL_TILES, @@ -6086,13 +5950,8 @@ static bool load_ruleset_cities(struct section_file *file, game.info.citizen_nationality = secfile_lookup_bool_default(file, RS_DEFAULT_NATIONALITY, "citizen.nationality"); - - if (compat->compat_mode && compat->version < RSFORMAT_3_2) { - /* Same as old hardcoded behavior */ - def_ubuild_nat = TRUE; - } game.info.unit_builders_nationality = - secfile_lookup_bool_default(file, def_ubuild_nat, + secfile_lookup_bool_default(file, FALSE, "citizen.ubuilder_nationality"); game.info.citizen_convert_speed = secfile_lookup_int_default(file, RS_DEFAULT_CONVERT_SPEED, @@ -6388,17 +6247,11 @@ static int secfile_lookup_int_default_min_max(struct section_file *file, Load ui_name of one action **************************************************************************/ static bool load_action_ui_name(struct section_file *file, int act, - const char *entry_name, - const char *compat_name) + const char *entry_name) { const char *text; const char *def = action_ui_name_default(act); - if (compat_name != NULL) { - def = secfile_lookup_str_default(file, def, - "actions.%s", compat_name); - } - text = secfile_lookup_str_default(file, def, "actions.%s", entry_name); sz_strlcpy(action_by_number(act)->ui_name, text); @@ -6890,22 +6743,12 @@ static bool load_ruleset_game(struct section_file *file, bool act, RS_MAX_BASE_TECH_COST, "research.base_tech_cost"); - if (compat->compat_mode && compat->version < RSFORMAT_3_2) { - /* base_tech_cost used to be used for this too. */ - game.info.min_tech_cost - = secfile_lookup_int_default_min_max(file, - game.info.base_tech_cost, - RS_MIN_MIN_TECH_COST, - RS_MAX_MIN_TECH_COST, - "research.min_tech_cost"); - } else { - game.info.min_tech_cost - = secfile_lookup_int_default_min_max(file, - RS_DEFAULT_MIN_TECH_COST, - RS_MIN_MIN_TECH_COST, - RS_MAX_MIN_TECH_COST, - "research.min_tech_cost"); - } + game.info.min_tech_cost + = secfile_lookup_int_default_min_max(file, + RS_DEFAULT_MIN_TECH_COST, + RS_MIN_MIN_TECH_COST, + RS_MAX_MIN_TECH_COST, + "research.min_tech_cost"); food_ini = secfile_lookup_int_vec(file, &gni_tmp, "civstyle.granary_food_ini"); @@ -7504,18 +7347,12 @@ static bool load_ruleset_game(struct section_file *file, bool act, if (ok) { const char *str; - bool reveal_default = FALSE; game.info.min_trade_route_val = secfile_lookup_int_default(file, 0, "trade.min_trade_route_val"); - if (compat->compat_mode && compat->version < RSFORMAT_3_2) { - /* Old hardcoded behavior was to reveal the trade partner. */ - reveal_default = TRUE; - } - game.info.reveal_trade_partner - = secfile_lookup_bool_default(file, reveal_default, + = secfile_lookup_bool_default(file, FALSE, "trade.reveal_trade_partner"); str = secfile_lookup_str_default(file, @@ -7790,8 +7627,7 @@ static bool load_ruleset_actions(struct section_file *file, ok = FALSE; } else { load_action_ui_name(file, act_id, - action_ui_name_ruleset_var_name(act_id), - rscompat_action_ui_name_S3_2(compat, act_id)); + action_ui_name_ruleset_var_name(act_id)); } if (!ok) { @@ -9407,22 +9243,8 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, server.playable_nations = 0; gamefile = openload_ruleset_file("game", rsdir); - - if (gamefile != NULL) { - /* Needed here to fill compat_info. RSFORMAT_3_2 specific arrangement. */ - ok = load_game_names(gamefile, &compat_info); - } else { - ok = FALSE; - } - techfile = openload_ruleset_file("techs", rsdir); - - if (compat_info.version >= RSFORMAT_3_2) { - actionfile = openload_ruleset_file("actions", rsdir); - } else { - actionfile = NULL; - } - + actionfile = openload_ruleset_file("actions", rsdir); buildfile = openload_ruleset_file("buildings", rsdir); govfile = openload_ruleset_file("governments", rsdir); unitfile = openload_ruleset_file("units", rsdir); @@ -9447,15 +9269,16 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, || cityfile == NULL || nationfile == NULL || effectfile == NULL - || (actionfile == NULL && (!compat_info.compat_mode || compat_info.version >= RSFORMAT_3_2)) + || actionfile == NULL || gamefile == NULL) { ok = FALSE; } if (ok) { /* Note: Keep load_game_names() first so that compat_info.version is - * correctly initialized. (Currently handled above already) */ - ok = (actionfile == NULL || load_action_names(actionfile, &compat_info)) + * correctly initialized. */ + ok = load_game_names(gamefile, &compat_info) + && load_action_names(actionfile, &compat_info) && load_tech_names(techfile, &compat_info) && load_building_names(buildfile, &compat_info) && load_government_names(govfile, &compat_info) @@ -9465,21 +9288,6 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, && load_nation_names(nationfile, &compat_info); } - if (ok) { - /* Can only happen here because 3.1 rulesets may not have a - * actions.ruleset. Remember to move it with the others in 3.3. */ - if (compat_info.version < RSFORMAT_3_2) { - ok = load_ruleset_actions(gamefile, gamefile, &compat_info); - } else { - if (secfile_section_prefix_present(actionfile, ACTION_ENABLER_SECTION_PREFIX)) { - ok = load_ruleset_actions(actionfile, gamefile, &compat_info); - } else { - /* Actions not moved to actions.ruleset, or there's none */ - ok = load_ruleset_actions(gamefile, gamefile, &compat_info); - } - } - } - if (ok) { ok = rscompat_names(&compat_info); } @@ -9512,6 +9320,9 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, if (ok) { ok = load_ruleset_effects(effectfile, &compat_info); } + if (ok) { + ok = load_ruleset_actions(actionfile, gamefile, &compat_info); + } if (ok) { ok = load_ruleset_game(gamefile, act, &compat_info); } @@ -9536,7 +9347,7 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, /* Only load settings for a sane ruleset */ ok = settings_ruleset(gamefile, "settings", act, compat_info.compat_mode - && compat_info.version < RSFORMAT_3_2); + && compat_info.version < RSFORMAT_CURRENT); if (ok) { secfile_check_unused(gamefile); diff --git a/server/ruleset.h b/server/ruleset.h index a98b3fad46..fc8504f2e6 100644 --- a/server/ruleset.h +++ b/server/ruleset.h @@ -34,6 +34,8 @@ extern "C" { */ #define RSFORMAT_3_2 30 +#define RSFORMAT_3_3 40 +#define RSFORMAT_CURRENT RSFORMAT_3_3 struct conn_list; diff --git a/server/settings.c b/server/settings.c index 37799f9edf..d3aa0826b3 100644 --- a/server/settings.c +++ b/server/settings.c @@ -4386,18 +4386,10 @@ bool settings_ruleset(struct section_file *file, const char *section, log_verbose("no [%s] section for game settings in %s", section, secfile_name(file)); } else { - bool rscompat_special_handling = FALSE; - for (j = 0; (name = secfile_lookup_str_default(file, NULL, "%s.set%d.name", section, j)); j++) { char path[256]; - if (compat && rscompat_setting_needs_special_handling(name)) { - /* Skip this setting for now; handle it later */ - rscompat_special_handling = TRUE; - continue; - } - fc_snprintf(path, sizeof(path), "%s.set%d", section, j); if (compat) { @@ -4409,11 +4401,6 @@ bool settings_ruleset(struct section_file *file, const char *section, secfile_name(file), name); } } - - if (compat && rscompat_special_handling) { - rscompat_settings_do_special_handling(file, section, - setting_ruleset_setdef); - } } /* Execute all setting actions to consider actions due to the @@ -4576,29 +4563,6 @@ static bool setting_ruleset_one(struct section_file *file, log_error("Can't read value for setting '%s': %s", name, secfile_error()); } else if (val != *pset->bitwise.pvalue) { - /* RSFORMAT_3_1 */ - if (compat && !fc_strcasecmp("topology", name)) { - struct setting *wrap = setting_by_name("wrap"); - - if (val & TF_OLD_WRAPX) { - if (val & TF_OLD_WRAPY) { - setting_bitwise_set(wrap, "WrapX|WrapY", NULL, NULL, 0); - } else { - setting_bitwise_set(wrap, "WrapX", NULL, NULL, 0); - } - } else if (val & TF_OLD_WRAPY) { - setting_bitwise_set(wrap, "WrapY", NULL, NULL, 0); - } else { - setting_bitwise_set(wrap, "", NULL, NULL, 0); - } - - val &= ~(TF_OLD_WRAPX | TF_OLD_WRAPY); - - log_normal(_("Ruleset: '%s' has been set to %s."), - setting_name(wrap), - setting_value_name(wrap, TRUE, buf, sizeof(buf))); - } - if (NULL == pset->bitwise.validate || pset->bitwise.validate((unsigned) val, NULL, reject_msg, sizeof(reject_msg))) { -- 2.39.1