diff --git a/src/highscore.cpp b/src/highscore.cpp index 943edab559..e46a445c52 100644 --- a/src/highscore.cpp +++ b/src/highscore.cpp @@ -87,20 +87,19 @@ static bool HighScoreSorter(const Company * const &a, const Company * const &b) */ int8_t SaveHighScoreValueNetwork() { - const Company *cl[MAX_COMPANIES]; - size_t count = 0; + std::vector cl; int8_t local_company_place = -1; /* Sort all active companies with the highest score first */ - for (const Company *c : Company::Iterate()) cl[count++] = c; + for (const Company *c : Company::Iterate()) cl.push_back(c); - std::sort(std::begin(cl), std::begin(cl) + count, HighScoreSorter); + std::ranges::sort(cl, HighScoreSorter); /* Clear the high scores from the previous network game. */ auto &highscores = _highscore_table[SP_MULTIPLAYER]; std::fill(highscores.begin(), highscores.end(), HighScore{}); - for (size_t i = 0; i < count && i < highscores.size(); i++) { + for (size_t i = 0; i < cl.size() && i < highscores.size(); i++) { const Company *c = cl[i]; auto &highscore = highscores[i]; highscore.name = GetString(STR_HIGHSCORE_NAME, c->index, c->index); // get manager/company name string