diff --git a/FlippR-Driver/src/output/Display.cpp b/FlippR-Driver/src/output/Display.cpp index c834736..deb0484 100644 --- a/FlippR-Driver/src/output/Display.cpp +++ b/FlippR-Driver/src/output/Display.cpp @@ -31,10 +31,6 @@ template void Display::write_score(int score) { auto score_string = std::to_string(score); - if (score_string.length() > DigitCount) - { - CLOG(DEBUG, OUTPUT_LOGGER) << "Score too long for display"; - } auto score_c_string = this->fit_string(score_string).c_str(); @@ -44,15 +40,16 @@ void Display::write_score(int score) template std::string Display::fit_string(std::string& score_string) { - auto score_length = score_string.length(); - for (int i = 0; i < DigitCount; i++) - { - score_string = " " + score_string; - } - - score_length = score_string.length(); + auto score_length = score_string.length(); + if (score_length > DigitCount) + { + CLOG(DEBUG, OUTPUT_LOGGER) << "Score too long for display"; return score_string.substr(score_length-DigitCount, score_length); + } + + score_string.insert(0, DigitCount-score_length, ' '); + return score_string; } template