Skip to content

Commit

Permalink
Add ability to bypass strict no-disabled-events assertion when writin…
Browse files Browse the repository at this point in the history
…g events

This is since the Gamestate Inspector can be invoked mid-event (using [inspect])
and it makes use of write_events().

(cherry-picked from commit afaa758)
  • Loading branch information
Vultraz committed Oct 7, 2018
1 parent d422f21 commit 2220078
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/game_events/manager.cpp
Expand Up @@ -132,11 +132,14 @@ void manager::add_events(const config::const_child_itors& cfgs, const std::strin
}
}

void manager::write_events(config& cfg) const
void manager::write_events(config& cfg, bool strict) const
{
for(const handler_ptr& eh : event_handlers_->get_active()) {
if(eh && !eh->is_menu_item()) {
assert(!eh->disabled());
if(strict) {
assert(!eh->disabled());
}

cfg.add_child("event", eh->get_config());;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/game_events/manager.hpp
Expand Up @@ -68,7 +68,7 @@ class manager

void add_events(const config::const_child_itors& cfgs, const std::string& type = std::string());

void write_events(config& cfg) const;
void write_events(config& cfg, bool strict = true) const;

using event_func_t = std::function<void(game_events::manager&, handler_ptr&)>;
void execute_on_events(const std::string& event_id, event_func_t func);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/gamestate_inspector.cpp
Expand Up @@ -509,7 +509,7 @@ const display_context& single_mode_controller::dc() const {
event_mode_controller::event_mode_controller(gamestate_inspector::controller& c)
: single_mode_controller(c)
{
single_mode_controller::events().write_events(events);
single_mode_controller::events().write_events(events, false);
}

void variable_mode_controller::show_list(tree_view_node& node)
Expand Down

0 comments on commit 2220078

Please sign in to comment.