From f08ca94751c45a2d53ae8f3d5d8f02bbedf1e635 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Mon, 30 Oct 2017 03:28:37 +1100 Subject: [PATCH] Lobby Data: minor cleanup, fixup * Wrap spaced_em_dash in a function since we can't guarantee font::unicode_em_dash will be initialized before this is, and Travis is crashing. * Remove an unnecessary std::string::find_first_of result check. If no character match is found, that returns std::string::npos, which substr takes to mean the entire string. --- src/game_initialization/lobby_data.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/game_initialization/lobby_data.cpp b/src/game_initialization/lobby_data.cpp index 2f7d69074211f..5043df1a46493 100644 --- a/src/game_initialization/lobby_data.cpp +++ b/src/game_initialization/lobby_data.cpp @@ -149,7 +149,11 @@ void user_info::update_relation() namespace { -const std::string spaced_em_dash = " " + font::unicode_em_dash + " "; +const std::string& spaced_em_dash() +{ + static const std::string res = " " + font::unicode_em_dash + " "; + return res; +} // Returns an abbreviated form of the provided string - ie, 'Ageless Era' should become 'AE' std::string make_short_name(const std::string& long_name) @@ -415,11 +419,10 @@ game_info::game_info(const config& game, const config& game_config, const std::v if(!turn.empty()) { started = true; - int index = turn.find_first_of('/'); - if(index > -1) { - const std::string current_turn_string = turn.substr(0, index); - current_turn = lexical_cast(current_turn_string); - } + + const std::string current_turn_string = turn.substr(0, turn.find_first_of('/')); + current_turn = lexical_cast(current_turn_string); + status = _("Turn") + " " + turn; } else { started = false;