From 37f270324430008a6b1a213dc0fabcfa785576ef Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 26 Feb 2020 23:06:15 +0100 Subject: [PATCH] a bit of formatting and artifacts cleanup --- src/common/HighScoresManager.cxx | 14 +++++++++----- src/gui/GameInfoDialog.cxx | 9 ++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/common/HighScoresManager.cxx b/src/common/HighScoresManager.cxx index 33e98e1ef..e53433dbf 100644 --- a/src/common/HighScoresManager.cxx +++ b/src/common/HighScoresManager.cxx @@ -541,10 +541,14 @@ string HighScoresManager::fromPropString(const string& text) const } // some ugly formatting - char first = result[0]; - result = BSPF::toLowerCase(result); - result[0] = first; + if(result.length()) + { + char first = result[0]; + result = BSPF::toLowerCase(result); + result[0] = first; + } - return result; + // remove leading spaces (especially for empty values) + size_t start = result.find_first_not_of(" "); + return (start == std::string::npos) ? "" : result.substr(start); } - diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index d5507063c..98ad978d7 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -807,11 +807,14 @@ void GameInfoDialog::loadHighScoresProperties(const Properties& props) mySpecialAddress->setText(ss.str()); - for (uInt32 a = 0; a < instance().highScores().numAddrBytes(info.numDigits, info.trailingZeroes); ++a) + for (uInt32 a = 0; a < HSM::MAX_SCORE_ADDR; ++a) { ss.str(""); - ss << hex << right //<< setw(HSM::MAX_ADDR_CHARS) << setfill(' ') - << uppercase << info.scoreAddr[a]; + if(a < instance().highScores().numAddrBytes(info.numDigits, info.trailingZeroes)) + { + ss << hex << right //<< setw(HSM::MAX_ADDR_CHARS) << setfill(' ') + << uppercase << info.scoreAddr[a]; + } myScoreAddress[a]->setText(ss.str()); } updateHighScoresWidgets();