AI: move default algorithm definition from C++ to WML
Among other things this now allows defining cores that have a different default AI.
This commit is contained in:
parent
f901a0fd81
commit
073f70b0a6
3 changed files with 8 additions and 1 deletions
|
@ -38,6 +38,7 @@
|
|||
{campaigns/}
|
||||
|
||||
[ais]
|
||||
default_ai_algorithm=ai_default_rca
|
||||
[default_config]
|
||||
{ai/utils/default_config.cfg}
|
||||
[/default_config]
|
||||
|
|
|
@ -49,6 +49,10 @@ void configuration::init(const config &game_config)
|
|||
ERR_AI_CONFIGURATION << "Missing AI [default_config]. Therefore, default_config_ set to empty." << std::endl;
|
||||
default_config_.clear();
|
||||
}
|
||||
default_ai_algorithm_ = ais["default_ai_algorithm"].str();
|
||||
if (default_ai_algorithm_.empty()) {
|
||||
ERR_AI_CONFIGURATION << "Missing default_ai_algorithm. This will result in no AI being loaded by default." << std::endl;
|
||||
}
|
||||
|
||||
|
||||
for (const config &ai_configuration : ais.child_range("ai")) {
|
||||
|
@ -166,6 +170,7 @@ configuration::description_map configuration::ai_configurations_ = configuration
|
|||
configuration::description_map configuration::era_ai_configurations_ = configuration::description_map();
|
||||
configuration::description_map configuration::mod_ai_configurations_ = configuration::description_map();
|
||||
config configuration::default_config_ = config();
|
||||
std::string configuration::default_ai_algorithm_;
|
||||
|
||||
bool configuration::get_side_config_from_file(const std::string& file, config& cfg ){
|
||||
try {
|
||||
|
@ -359,7 +364,7 @@ void configuration::expand_simplified_aspects(side_number side, config &cfg) {
|
|||
}
|
||||
}
|
||||
if (algorithm.empty() && !parsed_config.has_child("stage")) {
|
||||
base_config = get_ai_config_for("ai_default_rca");
|
||||
base_config = get_ai_config_for(default_ai_algorithm_);
|
||||
}
|
||||
for (const config::any_child &child : parsed_config.all_children_range()) {
|
||||
base_config.add_child(child.key, child.cfg);
|
||||
|
|
|
@ -120,6 +120,7 @@ private:
|
|||
static description_map era_ai_configurations_;
|
||||
static description_map mod_ai_configurations_;
|
||||
static config default_config_;
|
||||
static std::string default_ai_algorithm_;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue