From ff4c2c5302a3d4caa2f68fad87afeccec3d16d6a Mon Sep 17 00:00:00 2001 From: Kai Philipp Date: Wed, 11 Sep 2019 20:13:43 +0200 Subject: [PATCH] saving real data incl ip now --- src/db/common/serverdbgeneric.cpp | 2 +- src/db/serverdbgeneric.h | 2 +- src/db/serverdbinterface.h | 2 +- src/db/serverdbnoaction.h | 2 +- src/dbofficial/serverdbthread.cpp | 10 ++++++---- src/dbofficial/serverdbthread.h | 2 +- src/net/common/servergame.cpp | 7 +++---- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/db/common/serverdbgeneric.cpp b/src/db/common/serverdbgeneric.cpp index 7352456f..5eab83a7 100644 --- a/src/db/common/serverdbgeneric.cpp +++ b/src/db/common/serverdbgeneric.cpp @@ -94,7 +94,7 @@ ServerDBGeneric::SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/, } void -ServerDBGeneric::SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector /*lastGames*/) +ServerDBGeneric::SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector /*lastGames*/, std::string /*playerIp*/) { } diff --git a/src/db/serverdbgeneric.h b/src/db/serverdbgeneric.h index 218e34d5..c79a0290 100644 --- a/src/db/serverdbgeneric.h +++ b/src/db/serverdbgeneric.h @@ -57,7 +57,7 @@ public: virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName); virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place); - virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector lastGames); + virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector lastGames, std::string playerIp); virtual void EndGame(unsigned requestId); virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId); diff --git a/src/db/serverdbinterface.h b/src/db/serverdbinterface.h index 5edf49b7..3d5d5288 100644 --- a/src/db/serverdbinterface.h +++ b/src/db/serverdbinterface.h @@ -58,7 +58,7 @@ public: virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName) = 0; virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place) = 0; - virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector lastGames) = 0; + virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector lastGames, std::string playerIp) = 0; virtual void EndGame(unsigned requestId) = 0; virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId) = 0; diff --git a/src/db/serverdbnoaction.h b/src/db/serverdbnoaction.h index 3ff8c526..7bcf0366 100644 --- a/src/db/serverdbnoaction.h +++ b/src/db/serverdbnoaction.h @@ -55,7 +55,7 @@ public: virtual void AsyncCreateGame(unsigned /*requestId*/, const std::string &/*gameName*/) {} virtual void SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/, unsigned /*place*/) {} - virtual void SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector /*lastGames*/) {} + virtual void SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector /*lastGames*/, std::string /*playerIp*/) {} virtual void EndGame(unsigned /*requestId*/) {} virtual void AsyncReportAvatar(unsigned /*requestId*/, unsigned /*replyId*/, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id * /*byPlayerId*/) {} diff --git a/src/dbofficial/serverdbthread.cpp b/src/dbofficial/serverdbthread.cpp index e993da9e..d5be1fe3 100644 --- a/src/dbofficial/serverdbthread.cpp +++ b/src/dbofficial/serverdbthread.cpp @@ -235,15 +235,17 @@ ServerDBThread::SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned } void -ServerDBThread::SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector lastGames) +ServerDBThread::SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector lastGames, std::string playerIp) { LOG_ERROR("ServerDBThread::SetPlayerLastGames() entered."); - string lastGamesFieldValue = "1,2,3"; - string lastIp = "127.0.0.1"; + + std::ostringstream oss; + std::copy(lastGames.begin(), lastGames.end(), std::ostream_iterator(oss, ";")); + std::string lastGamesFieldValue( oss.str() ); list params; ostringstream paramStream; params.push_back(lastGamesFieldValue); - params.push_back(lastIp); + params.push_back(playerIp); paramStream << playerId; params.push_back(paramStream.str()); boost::shared_ptr asyncQuery( diff --git a/src/dbofficial/serverdbthread.h b/src/dbofficial/serverdbthread.h index bbe7b5fd..159abc22 100644 --- a/src/dbofficial/serverdbthread.h +++ b/src/dbofficial/serverdbthread.h @@ -67,7 +67,7 @@ public: virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName); virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place); - virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector lastGames); + virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector lastGames, std::string playerIp); virtual void EndGame(unsigned requestId); virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId); diff --git a/src/net/common/servergame.cpp b/src/net/common/servergame.cpp index ccdc0fd6..e9f193a2 100644 --- a/src/net/common/servergame.cpp +++ b/src/net/common/servergame.cpp @@ -463,10 +463,9 @@ ServerGame::StoreLastGames(const PlayerDataList &playerDataList) tmpPlayer->AddPlayerLastGame((long)time(NULL)); LOG_ERROR("TimeStamp stored: " << tmpPlayer->GetPlayerLastGames().back()); std::vector lastGames = tmpPlayer->GetPlayerLastGames(); - LOG_ERROR("Ready for storing vector for player " << tmpPlayer->GetUniqueId() << " - lastGameTs " << lastGames.back()); - if(tmpPlayer->GetUniqueId() != DB_ID_INVALID){ - LOG_ERROR("ID != DB_ID_INVALID ... calling SetPlayerLastGames()..."); - GetDatabase().SetPlayerLastGames(GetId(), tmpPlayer->GetDBId(), lastGames); + LOG_ERROR("Ready for storing vector for player " << tmpPlayer->GetDBId() << " - lastGameTs " << lastGames.back()); + if(tmpPlayer->GetDBId() != DB_ID_INVALID){ + GetDatabase().SetPlayerLastGames(GetId(), tmpPlayer->GetDBId(), lastGames, GetSessionManager().GetSessionByUniquePlayerId(tmpPlayer->GetUniqueId())->GetClientAddr()); } ++i; }