Reevaluate [show_if] conditions and delayed variable expansions before displaying objectives at start.

Fixes #3544.
This commit is contained in:
josteph 2018-09-12 22:11:29 +00:00
parent 3809b64cf4
commit d99f5b8a76
3 changed files with 11 additions and 4 deletions

View file

@ -138,10 +138,7 @@ void menu_handler::objectives()
return;
}
config cfg;
cfg["side"] = gui_->viewing_side();
gamestate().lua_kernel_->run_wml_action("show_objectives", vconfig(cfg),
game_events::queued_event("_from_interface", "", map_location(), map_location(), config()));
pc_.refresh_objectives();
pc_.show_objectives();
}

View file

@ -388,6 +388,13 @@ void play_controller::fire_prestart()
gamestate().gamedata_.get_variable("turn_number") = static_cast<int>(turn());
}
void play_controller::refresh_objectives()
{
const config cfg("side", gui_->viewing_side());
gamestate().lua_kernel_->run_wml_action("show_objectives", vconfig(cfg),
game_events::queued_event("_from_interface", "", map_location(), map_location(), config()));
}
void play_controller::fire_start()
{
gamestate().gamedata_.set_phase(game_data::START);
@ -396,6 +403,7 @@ void play_controller::fire_start()
// start event may modify start turn with WML, reflect any changes.
gamestate().gamedata_.get_variable("turn_number") = static_cast<int>(turn());
refresh_objectives();
check_objectives();
// prestart and start events may modify the initial gold amount, reflect any changes.

View file

@ -361,6 +361,8 @@ public:
return false;
}
/// Reevaluate [show_if] conditions and build a new objectives string.
void refresh_objectives();
void show_objectives() const;
struct scoped_savegame_snapshot