From 789c5cd3ac4c874ec924ee9a2088eba7723f7065 Mon Sep 17 00:00:00 2001 From: Iris Morelle Date: Mon, 26 Mar 2018 20:28:17 -0300 Subject: [PATCH] Use a fallback for when the player name is not known in debug notifications We just found out that it is possible for the player name to not be set when loading a singleplayer start-of-scenario save for the first time right after launching Wesnoth. It's best to have an actual $player value for that case instead of spurting 100% syntactically invalid statements like "The :lua command was used during 's turn" because of the empty variable. (cherry picked from commit 8b41d4d8fc4408084abff62a4e7d63eeb1c10bd1) --- src/synced_commands.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/synced_commands.cpp b/src/synced_commands.cpp index 9ca527392728..cbef6901bdb6 100644 --- a/src/synced_commands.cpp +++ b/src/synced_commands.cpp @@ -406,6 +406,10 @@ namespace std::string message; utils::string_map i18n_vars = {{ "player", current_team.current_player() }}; + if(i18n_vars["player"].empty()) { + i18n_vars["player"] = _("(unknown player)"); + } + if(message_is_command) { i18n_vars["command"] = text; message = VGETTEXT("The :$command debug command was used during $player’s turn", i18n_vars);