Fix non-serializable events being serialized as an empty [event] tag

This commit is contained in:
Celtic Minstrel 2022-06-22 09:31:55 -04:00 committed by Celtic Minstrel
parent 865eface07
commit 72249b1bb3
2 changed files with 8 additions and 1 deletions

View File

@ -184,7 +184,11 @@ void manager::write_events(config& cfg, bool include_nonserializable) const
assert(!eh->disabled());
}
eh->write_config(cfg.add_child("event"), include_nonserializable);
config event_cfg;
eh->write_config(event_cfg, include_nonserializable);
if(!event_cfg.empty()) {
cfg.add_child("event", std::move(event_cfg));
}
}
cfg["unit_wml_ids"] = utils::join(unit_wml_ids_);

View File

@ -73,6 +73,9 @@ public:
void add_events(const config::const_child_itors& cfgs, game_lua_kernel& lk, const std::string& type = std::string());
// Normally non-serializable events are skipped when serializing (with a warning).
// If include_nonserializable is true, the game attempts to serialize them anyway.
// This will produce output that kind of looks like the event but would not deserialize to the same event.
void write_events(config& cfg, bool include_nonserializable=false) const;
using event_func_t = std::function<void(game_events::manager&, handler_ptr&)>;