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:
@@ -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;
|
||||
}
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user