Implement a feature flags system.

* Scenarios contain a string map of feature flags. The flag names are the keys, and flag versions are the values, so a typical value might be "fixed" for bug fixes or for evolving features, "V1", "V2", etc.
* The game has a map of flags to lists of supported versions. The game can therefore signal that it supports a legacy behavior for a given feature flag. The last version in the list is considered to be this build version's default behavior.
* When launching a scenario, we check to make sure the game supports the scenario's required versions of its feature flags.
* When launching a replay, we make sure the game supports the feature flags that the version of the game that made the recording did.

Fix #555
Close #591
This commit is contained in:
2025-02-08 19:27:27 -06:00
committed by Celtic Minstrel
parent f0662902cb
commit f80f8a932a
11 changed files with 135 additions and 1 deletions

View File

@@ -590,4 +590,14 @@ std::vector<town_entrance_t> cScenario::find_town_entrances(int town_num) {
}
}
return matching_entrances;
}
bool cScenario::has_feature_flag(std::string flag) {
return this->feature_flags.find(flag) != this->feature_flags.end();
}
std::string cScenario::get_feature_flag(std::string flag) {
std::map<std::string, std::string>::const_iterator iter = this->feature_flags.find(flag);
if(iter == this->feature_flags.end()) return "";
return iter->second;
}

View File

@@ -65,6 +65,10 @@ public:
location where_start,out_sec_start,out_start;
size_t which_town_start;
spec_num_t init_spec;
std::map<std::string,std::string> feature_flags;
bool has_feature_flag(std::string flag);
std::string get_feature_flag(std::string flag);
std::array<spec_loc_t,10> town_mods;
std::array<rectangle,3> store_item_rects;
std::array<short,3> store_item_towns;