Skip to content

Commit

Permalink
Reevaluate [show_if] conditions and delayed variable expansions befor…
Browse files Browse the repository at this point in the history
…e displaying objectives at start.

Fixes #3544.
  • Loading branch information
jostephd committed Sep 14, 2018
1 parent 3809b64 commit d99f5b8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/menu_events.cpp
Expand Up @@ -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();
}

Expand Down
8 changes: 8 additions & 0 deletions src/play_controller.cpp
Expand Up @@ -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);
Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/play_controller.hpp
Expand Up @@ -361,6 +361,8 @@ class play_controller : public controller_base, public events::observer, public
return false;
}

/// Reevaluate [show_if] conditions and build a new objectives string.
void refresh_objectives();
void show_objectives() const;

struct scoped_savegame_snapshot
Expand Down

0 comments on commit d99f5b8

Please sign in to comment.