diff --git a/src/net/common/servergame.cpp b/src/net/common/servergame.cpp index 3c219db9..dfa3dc73 100644 --- a/src/net/common/servergame.cpp +++ b/src/net/common/servergame.cpp @@ -344,6 +344,12 @@ ServerGame::InternalStartGame() GuiInterface &gui = GetGui(); m_game.reset(new Game(&gui, factory, playerData, GetGameData(), GetStartData(), GetNextGameNum(), NULL)); + // @TODO: here to save lastGames with mysql per player + //if (GetGameData().gameType == GAME_TYPE_RANKING) + if(true) + StoreLastGames(); + + GetDatabase().AsyncCreateGame(GetId(), GetName()); InitRankingMap(playerData); } @@ -442,6 +448,25 @@ ServerGame::StoreAndResetRanking() m_rankingMap.clear(); } +void +ServerGame::StoreLastGames() +{ + // Store players lastgames in database. + RankingMap::const_iterator i = m_rankingMap.begin(); + RankingMap::const_iterator end = m_rankingMap.end(); + while (i != end) { + std::vector lastGames = GetSessionManager().GetSessionByUniquePlayerId((*i).second.dbid).GetPlayerLastGames(); + + if(lastGames) + //GetLobbyThread().GetDatabase().SetGamePlayerPlace(GetId(), (*i).second.dbid, lastGames); + LOG_VERBOSE("first timeStamp" << lastGames.front().first << "."); + + ++i; + } + GetDatabase().EndGame(GetId()); + m_rankingMap.clear(); +} + void ServerGame::RemoveAutoLeavePlayers() {