optimizations for number of game-joins per player, removed @XXX from comments

This commit is contained in:
Kai Philipp
2016-07-17 16:55:06 +02:00
parent 8f5813416d
commit 24acd01e90
5 changed files with 19 additions and 42 deletions
+9 -14
View File
@@ -457,7 +457,6 @@ ServerGame::InternalEndGame()
{
StoreAndResetRanking();
m_game.reset();
// @XXX: reset NumJoinsPerPlayerMap (if a game restarts, the number of joins will be set to 0 for each player)
ResetNumJoinsPerPlayer();
}
@@ -1169,10 +1168,12 @@ ServerGame::GetNextGameNum()
void
ServerGame::AddPlayerToNumJoinsPerPlayer(const std::string &playerName)
{
if(m_numjoinsp.find(playerName) != m_numjoinsp.end()) {
m_numjoinsp[playerName] = m_numjoinsp[playerName] + 1;
} else {
m_numjoinsp[playerName] = 1;
NumJoinsPerPlayerMap::iterator pos = m_numJoinsPerPlayer.find(playerName);
if (pos != m_numJoinsPerPlayer.end())
{
pos->second++;
} else{
m_numJoinsPerPlayer[playerName] = 1;
}
}
@@ -1180,8 +1181,8 @@ int
ServerGame::GetNumJoinsPerPlayer(const std::string &playerName)
{
int num = 0;
if(m_numjoinsp.find(playerName) != m_numjoinsp.end()) {
num = m_numjoinsp[playerName];
if(m_numJoinsPerPlayer.find(playerName) != m_numJoinsPerPlayer.end()) {
num = m_numJoinsPerPlayer[playerName];
}
return num;
}
@@ -1189,11 +1190,5 @@ ServerGame::GetNumJoinsPerPlayer(const std::string &playerName)
void
ServerGame::ResetNumJoinsPerPlayer()
{
NumJoinsPerPlayerMap::const_iterator numj_i = m_numjoinsp.begin();
NumJoinsPerPlayerMap::const_iterator numj_end = m_numjoinsp.end();
while (numj_i != numj_end) {
m_numjoinsp[numj_i->first] = 0;
++numj_i;
}
m_numJoinsPerPlayer.clear();
}