Skip to content

Commit

Permalink
Fixup c8b0833 (crash when creating scenario in Editor)
Browse files Browse the repository at this point in the history
There's no AI manager in the editor (a game state is required), nor a need for one, so I simply
disabled the AI initialization if we're not in the editor.
  • Loading branch information
Vultraz committed Jan 24, 2018
1 parent e9e22f3 commit 3dc8617
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/team.cpp
Expand Up @@ -203,10 +203,14 @@ void team::team_info::read(const config& cfg)
if(!user_team_name.translatable())
user_team_name = t_string::from_serialized(user_team_name);

if(cfg.has_attribute("ai_config")) {
ai::manager::get_singleton().add_ai_for_side_from_file(side, cfg["ai_config"], true);
} else {
ai::manager::get_singleton().add_ai_for_side_from_config(side, cfg, true);
display* disp = display::get_singleton();

if(disp && !disp->in_editor()) {
if(cfg.has_attribute("ai_config")) {
ai::manager::get_singleton().add_ai_for_side_from_file(side, cfg["ai_config"], true);
} else {
ai::manager::get_singleton().add_ai_for_side_from_config(side, cfg, true);
}
}

std::vector<std::string> recruits = utils::split(cfg["recruit"]);
Expand Down

0 comments on commit 3dc8617

Please sign in to comment.