limit rank games per time unit implemented
This commit is contained in:
@@ -293,11 +293,13 @@ ServerGame::TimerVoteKick(const boost::system::error_code &ec)
|
||||
PlayerDataList
|
||||
ServerGame::InternalStartGame()
|
||||
{
|
||||
LOG_ERROR("InternalStartGame() entered.");
|
||||
// Initialize the game.
|
||||
PlayerDataList playerData(GetFullPlayerDataList());
|
||||
|
||||
if (playerData.size() >= 2) {
|
||||
// Set DB Backend.
|
||||
// @TODO: check for wec or bbc game with bbcbot as creator
|
||||
if (GetGameData().gameType == GAME_TYPE_RANKING)
|
||||
m_database = GetLobbyThread().GetDatabase();
|
||||
else
|
||||
@@ -346,6 +348,12 @@ ServerGame::InternalStartGame()
|
||||
|
||||
GetDatabase().AsyncCreateGame(GetId(), GetName());
|
||||
InitRankingMap(playerData);
|
||||
|
||||
// @TODO: here to save last_games with mysql per player
|
||||
|
||||
if (GetGameData().gameType == GAME_TYPE_RANKING)
|
||||
StoreLastGames(playerData);
|
||||
|
||||
}
|
||||
return playerData;
|
||||
}
|
||||
@@ -442,6 +450,26 @@ ServerGame::StoreAndResetRanking()
|
||||
m_rankingMap.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::StoreLastGames(const PlayerDataList &playerDataList)
|
||||
{
|
||||
// Store players lastgames in database.
|
||||
PlayerDataList::const_iterator i = playerDataList.begin();
|
||||
PlayerDataList::const_iterator end = playerDataList.end();
|
||||
while (i != end) {
|
||||
boost::shared_ptr<PlayerData> tmpPlayer(*i);
|
||||
// tmpPlayer->GetUniqueId()
|
||||
tmpPlayer->AddPlayerLastGame((long)time(NULL));
|
||||
LOG_ERROR("TimeStamp stored: " << tmpPlayer->GetPlayerLastGames().back());
|
||||
std::vector<long> last_games = tmpPlayer->GetPlayerLastGames();
|
||||
LOG_ERROR("Ready for storing vector for player " << tmpPlayer->GetDBId() << " - lastGameTs " << last_games.back());
|
||||
if(tmpPlayer->GetDBId() != DB_ID_INVALID){
|
||||
GetDatabase().SetPlayerLastGames(GetId(), tmpPlayer->GetDBId(), last_games, GetSessionManager().GetSessionByUniquePlayerId(tmpPlayer->GetUniqueId())->GetClientAddr());
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::RemoveAutoLeavePlayers()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user