From c78eed576ffec04c8831ff07f7994e64cf0ce8fb Mon Sep 17 00:00:00 2001 From: woogerboy21 Date: Wed, 7 Dec 2016 07:52:39 -0500 Subject: [PATCH] Fix store replays (#2301) * Fix Store Replays Functionality For whatever reason we have a variable in the servers ini to enable/disable the storing of replays but there is no code that uses that variable. At one time there was but in light of it being removed some were along the line this add's the ability back in for server owners to disable the storing of game replay data. * Added code * Moved store replay check Moved the check for storing replay information into existing routine. * Updated Per Request Combined lines per request --- common/server.h | 1 + common/server_game.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/common/server.h b/common/server.h index bdf172c9..a345e00a 100644 --- a/common/server.h +++ b/common/server.h @@ -65,6 +65,7 @@ public: virtual bool getRegOnlyServerEnabled() const { return false; } virtual bool getMaxUserLimitEnabled() const { return false; } virtual bool getEnableLogQuery() const { return false; } + virtual bool getStoreReplaysEnabled() const { return true; } virtual int getIdleClientTimeout() const { return 0; } virtual int getClientKeepAlive() const { return 0; } virtual int getMaxGameInactivityTime() const { return 9999999; } diff --git a/common/server_game.cpp b/common/server_game.cpp index 1a3e748f..673bb300 100644 --- a/common/server_game.cpp +++ b/common/server_game.cpp @@ -96,7 +96,6 @@ Server_Game::~Server_Game() gameClosed = true; sendGameEventContainer(prepareGameEvent(Event_GameClosed(), -1)); - QMapIterator playerIterator(players); while (playerIterator.hasNext()) playerIterator.next().value()->prepareDestroy(); @@ -108,7 +107,6 @@ Server_Game::~Server_Game() gameMutex.unlock(); room->gamesLock.unlock(); - currentReplay->set_duration_seconds(secondsElapsed - startTimeOfThisGame); replayList.append(currentReplay); storeGameInformation(); @@ -155,13 +153,15 @@ void Server_Game::storeGameInformation() server->clientsLock.lockForRead(); while (allUsersIterator.hasNext()) { Server_AbstractUserInterface *userHandler = server->findUser(allUsersIterator.next()); - if (userHandler) - userHandler->sendProtocolItem(*sessionEvent); + if (userHandler && server->getStoreReplaysEnabled()) + userHandler->sendProtocolItem(*sessionEvent); } server->clientsLock.unlock(); delete sessionEvent; - server->getDatabaseInterface()->storeGameInformation(room->getName(), gameTypes, gameInfo, allPlayersEver, allSpectatorsEver, replayList); + if (server->getStoreReplaysEnabled()) + server->getDatabaseInterface()->storeGameInformation(room->getName(), gameTypes, gameInfo, allPlayersEver, allSpectatorsEver, replayList); + } void Server_Game::pingClockTimeout()