bugfix vector erase

This commit is contained in:
Kai Philipp
2019-09-14 18:07:54 +02:00
parent 213d110bc6
commit df81e925dc
2 changed files with 22 additions and 12 deletions
+20 -10
View File
@@ -1813,16 +1813,26 @@ ServerLobbyThread::UserValid(unsigned playerId, const DBPlayerData &dbPlayerData
tmpSession->GetPlayerData()->SetDBId(dbPlayerData.id);
tmpSession->GetPlayerData()->SetCountry(dbPlayerData.country);
LOG_ERROR("last_games from db = " << dbPlayerData.last_games);
//std::vector<long> last_games;
std::stringstream ss(dbPlayerData.last_games);
for (string i; ss >> i;) {
if(i.length() > 0){
LOG_ERROR("adding lastGame " << i);
tmpSession->GetPlayerData()->AddPlayerLastGame(stol(i));
}
if (ss.peek() == ',')
ss.ignore();
}
vector<string> last_games;
boost::split(last_games, dbPlayerData.last_games, boost::is_any_of(","));
for (int i = 0; i < result.size(); i++){
if(result[i].length() > 0)
tmpSession->GetPlayerData()->AddPlayerLastGame(stol(result[i]));
}
// std::stringstream ss(dbPlayerData.last_games);
// for (string i; ss >> i;) {
// if(i.length() > 0){
// LOG_ERROR("adding lastGame " << i);
// tmpSession->GetPlayerData()->AddPlayerLastGame(stol(i));
// }
// if (ss.peek() == ',')
// ss.ignore();
// }
//tmpSession->GetPlayerData()->SetPlayerLastGames(last_games);
LOG_ERROR("last_games last from vector after db = " << tmpSession->GetPlayerData()->GetPlayerLastGames().back());
this->AuthChallenge(tmpSession, dbPlayerData.secret);
+2 -2
View File
@@ -290,8 +290,8 @@ LOG_ERROR("checking IsPlayerAllowedToJoinCreateLimitRank() ");
LOG_ERROR("counting timeStamp in time " << *timeStamp);
count++;
}else{
//LOG_ERROR("erasing overdued timestamp " << *timeStamp);
//m_last_games.erase(m_last_games.begin() + i); // erase overdued entries
LOG_ERROR("erasing overdued timestamp " << *timeStamp);
m_last_games.erase(m_last_games.begin() + i); // erase overdued entries
}
i++;
}