From ab0a0da716815d4885dae325beb2b4ae9a84aac4 Mon Sep 17 00:00:00 2001 From: Alayan-stk-2 Date: Fri, 19 Oct 2018 01:46:24 +0200 Subject: [PATCH] Update the number of ranked races before using it in the rank computations --- src/network/protocols/server_lobby.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/network/protocols/server_lobby.cpp b/src/network/protocols/server_lobby.cpp index 6c0c5601a..0e06bf392 100644 --- a/src/network/protocols/server_lobby.cpp +++ b/src/network/protocols/server_lobby.cpp @@ -1138,7 +1138,15 @@ void ServerLobby::computeNewRankings() new_scores.push_back(m_scores.at(id)); new_scores[i] += distributeBasePoints(id); } + + // First, update the number of ranked races + for (unsigned i = 0; i < players.size(); i++) + { + const uint32_t id = race_manager->getKartInfo(i).getOnlineId(); + m_num_ranked_races.at(id)++; + } + // Now compute points exchanges for (unsigned i = 0; i < players.size(); i++) { scores_change.push_back(0.0); @@ -1227,7 +1235,6 @@ void ServerLobby::computeNewRankings() m_scores.at(id) = new_scores[i]; if (m_scores.at(id) > m_max_scores.at(id)) m_max_scores.at(id) = m_scores.at(id); - m_num_ranked_races.at(id)++; } } // computeNewRankings @@ -1303,7 +1310,7 @@ double ServerLobby::scalingValueForTime(double time) double ServerLobby::distributeBasePoints(uint32_t online_id) { unsigned num_races = m_num_ranked_races.at(online_id); - if (num_races < 45) + if (num_races <= 45) { return BASE_RANKING_POINTS / 2000.0 * std::max((45u - num_races), 4u); }