Avoid player score being reset if connection to stk addons is broken

This commit is contained in:
Benau 2020-01-30 16:55:40 +08:00
parent 652bf5480a
commit 17bf24c6d1

View File

@ -4211,12 +4211,28 @@ void ServerLobby::getRankingForPlayer(std::shared_ptr<NetworkPlayerProfile> p)
} }
else else
{ {
Log::error("ServerLobby", "No ranking info found."); Log::error("ServerLobby", "No ranking info found for player %s.",
StringUtils::wideToUtf8(p->getName()).c_str());
// Kick the player to avoid his score being reset in case
// connection to stk addons is broken
auto peer = p->getPeer();
if (peer)
{
peer->kick();
return;
}
} }
} }
else else
{ {
Log::error("ServerLobby", "No ranking info found."); Log::error("ServerLobby", "No ranking info found for player %s.",
StringUtils::wideToUtf8(p->getName()).c_str());
auto peer = p->getPeer();
if (peer)
{
peer->kick();
return;
}
} }
m_ranked_players[id] = p; m_ranked_players[id] = p;
m_scores[id] = score; m_scores[id] = score;