Skip to content

Commit

Permalink
Lobby Data: minor cleanup, fixup
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Vultraz authored and GregoryLundberg committed Nov 30, 2017
1 parent 2d9ee0d commit f08ca94
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/game_initialization/lobby_data.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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<unsigned int>(current_turn_string);
}

const std::string current_turn_string = turn.substr(0, turn.find_first_of('/'));
current_turn = lexical_cast<unsigned int>(current_turn_string);

status = _("Turn") + " " + turn;
} else {
started = false;
Expand Down

0 comments on commit f08ca94

Please sign in to comment.