Set place for all players (not only first place) in ranked games. Simple version (all players who leave/lose at the same time get the same place).

This commit is contained in:
lotodore
2010-08-28 14:34:02 +00:00
parent b6723e5ebf
commit 698432279f
3 changed files with 44 additions and 3 deletions
+39 -1
View File
@@ -295,6 +295,44 @@ ServerGame::InitRankingMap(const PlayerDataList &playerDataList)
}
}
void
ServerGame::UpdateRankingMap()
{
list<boost::shared_ptr<PlayerInterface> > activePlayers = *m_game->getActivePlayerList();
size_t currentRank = activePlayers.size();
list<boost::shared_ptr<PlayerInterface> > tmpRemovedPlayers;
PlayerListIterator active_i = activePlayers.begin();
PlayerListIterator active_end = activePlayers.end();
PlayerListIterator next_i = active_i;
while(active_i != active_end)
{
++next_i;
if ((*active_i)->getMyCash() < 1)
{
tmpRemovedPlayers.push_back(*active_i);
activePlayers.erase(active_i);
}
active_i = next_i;
}
if (!tmpRemovedPlayers.empty())
{
currentRank = currentRank - tmpRemovedPlayers.size() + 1;
PlayerListConstIterator removed_i = tmpRemovedPlayers.begin();
PlayerListConstIterator removed_end = tmpRemovedPlayers.end();
while (removed_i != removed_end)
{
SetPlayerPlace((*removed_i)->getMyUniqueID(), currentRank);
++removed_i;
}
}
// Last player is winner.
if (activePlayers.size() == 1)
{
SetPlayerPlace((*(activePlayers.begin()))->getMyUniqueID(), 1);
}
}
void
ServerGame::SetPlayerPlace(unsigned playerId, int place)
{
@@ -736,7 +774,7 @@ void
ServerGame::RemoveDisconnectedPlayers()
{
// This should only be called between hands.
if (m_game.get())
if (m_game)
{
PlayerListIterator i = m_game->getSeatsList()->begin();
PlayerListIterator end = m_game->getSeatsList()->end();