Add debug for "[event] is missing name or id"

The problem with this warning was that it didn't include any clue about what
had triggered it - just that there's a broken event somewhere, and it could be
in a scenario, macro, unit_type or even from another add-on if you're using a
non-default era.

When run with `--log-debug=wml`, this makes Wesnoth print out whatever the
contents of the affected [event] tag are.

(cherry picked from commit d6b56969a0)
This commit is contained in:
Steve Cotton 2022-04-09 16:56:07 +02:00
parent 0f6a94f2a7
commit bfd0ef9af7

View file

@ -34,6 +34,7 @@ static lg::log_domain log_event_handler("event_handler");
static lg::log_domain log_wml("wml"); static lg::log_domain log_wml("wml");
#define ERR_WML LOG_STREAM(err, log_wml) #define ERR_WML LOG_STREAM(err, log_wml)
#define DBG_WML LOG_STREAM(debug, log_wml)
namespace game_events namespace game_events
{ {
@ -115,7 +116,8 @@ void event_handlers::add_event_handler(const config& cfg, bool is_menu_item)
if(name.empty() && id.empty()) { if(name.empty() && id.empty()) {
lg::log_to_chat() << "[event] is missing name or id field\n"; lg::log_to_chat() << "[event] is missing name or id field\n";
ERR_WML << "[event] is missing name or id field"; ERR_WML << "[event] is missing name or id field\n";
DBG_WML << "Content of that event:\n" << cfg.debug() << "\n";
return; return;
} }