Game Events: don't write disabled events to config

This should help mitigate an odd issue some people have reported with 1.13.11. After reloading a
save *after* executing a first_time_only=yes event, they can execute the event again. Looking at
savefiles for one of the reports, the event was included in the savefile even though it had already
executed. Most likely, when the player reloaded, the event was re-added to the gamestate and they
could execute it again.

The questions is then why the event had never been removed in handler cleanup. I'll have to look
into that further, but this at least ensures we don't get dead events written to config (that
includes saved games).
This commit is contained in:
Charles Dang 2018-03-06 17:24:59 +11:00
parent 390df50ebc
commit a46ddf9bcd

View file

@ -108,11 +108,9 @@ void manager::add_events(const config::const_child_itors& cfgs, const std::strin
void manager::write_events(config& cfg) const
{
for(const handler_ptr& eh : event_handlers_->get_active()) {
if(!eh || eh->is_menu_item()) {
continue;
if(eh && !eh->is_menu_item() && !eh->disabled()) {
cfg.add_child("event", eh->get_config());;
}
cfg.add_child("event", eh->get_config());
}
cfg["unit_wml_ids"] = utils::join(unit_wml_ids_);