Update the number of ranked races before using it in the rank computations

This commit is contained in:
Alayan-stk-2 2018-10-19 01:46:24 +02:00 committed by GitHub
parent 1d5e4de91d
commit ab0a0da716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1139,6 +1139,14 @@ void ServerLobby::computeNewRankings()
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);
}