saving real data incl ip now

This commit is contained in:
Kai Philipp
2019-09-11 20:13:43 +02:00
parent 7cda99e881
commit ff4c2c5302
7 changed files with 14 additions and 13 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ ServerDBGeneric::SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/,
} }
void void
ServerDBGeneric::SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector<long> /*lastGames*/) ServerDBGeneric::SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector<long> /*lastGames*/, std::string /*playerIp*/)
{ {
} }
+1 -1
View File
@@ -57,7 +57,7 @@ public:
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName); virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place); virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> lastGames); virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> lastGames, std::string playerIp);
virtual void EndGame(unsigned requestId); 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); virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId);
+1 -1
View File
@@ -58,7 +58,7 @@ public:
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName) = 0; virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName) = 0;
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place) = 0; virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place) = 0;
virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> lastGames) = 0; virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> lastGames, std::string playerIp) = 0;
virtual void EndGame(unsigned requestId) = 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; virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId) = 0;
+1 -1
View File
@@ -55,7 +55,7 @@ public:
virtual void AsyncCreateGame(unsigned /*requestId*/, const std::string &/*gameName*/) {} virtual void AsyncCreateGame(unsigned /*requestId*/, const std::string &/*gameName*/) {}
virtual void SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/, unsigned /*place*/) {} virtual void SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/, unsigned /*place*/) {}
virtual void SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector<long> /*lastGames*/) {} virtual void SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector<long> /*lastGames*/, std::string /*playerIp*/) {}
virtual void EndGame(unsigned /*requestId*/) {} 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*/) {} virtual void AsyncReportAvatar(unsigned /*requestId*/, unsigned /*replyId*/, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id * /*byPlayerId*/) {}
+6 -4
View File
@@ -235,15 +235,17 @@ ServerDBThread::SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned
} }
void void
ServerDBThread::SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> lastGames) ServerDBThread::SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> lastGames, std::string playerIp)
{ {
LOG_ERROR("ServerDBThread::SetPlayerLastGames() entered."); 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<int>(oss, ";"));
std::string lastGamesFieldValue( oss.str() );
list<string> params; list<string> params;
ostringstream paramStream; ostringstream paramStream;
params.push_back(lastGamesFieldValue); params.push_back(lastGamesFieldValue);
params.push_back(lastIp); params.push_back(playerIp);
paramStream << playerId; paramStream << playerId;
params.push_back(paramStream.str()); params.push_back(paramStream.str());
boost::shared_ptr<AsyncDBQuery> asyncQuery( boost::shared_ptr<AsyncDBQuery> asyncQuery(
+1 -1
View File
@@ -67,7 +67,7 @@ public:
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName); virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place); virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> lastGames); virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> lastGames, std::string playerIp);
virtual void EndGame(unsigned requestId); 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); virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId);
+3 -4
View File
@@ -463,10 +463,9 @@ ServerGame::StoreLastGames(const PlayerDataList &playerDataList)
tmpPlayer->AddPlayerLastGame((long)time(NULL)); tmpPlayer->AddPlayerLastGame((long)time(NULL));
LOG_ERROR("TimeStamp stored: " << tmpPlayer->GetPlayerLastGames().back()); LOG_ERROR("TimeStamp stored: " << tmpPlayer->GetPlayerLastGames().back());
std::vector<long> lastGames = tmpPlayer->GetPlayerLastGames(); std::vector<long> lastGames = tmpPlayer->GetPlayerLastGames();
LOG_ERROR("Ready for storing vector for player " << tmpPlayer->GetUniqueId() << " - lastGameTs " << lastGames.back()); LOG_ERROR("Ready for storing vector for player " << tmpPlayer->GetDBId() << " - lastGameTs " << lastGames.back());
if(tmpPlayer->GetUniqueId() != DB_ID_INVALID){ if(tmpPlayer->GetDBId() != DB_ID_INVALID){
LOG_ERROR("ID != DB_ID_INVALID ... calling SetPlayerLastGames()..."); GetDatabase().SetPlayerLastGames(GetId(), tmpPlayer->GetDBId(), lastGames, GetSessionManager().GetSessionByUniquePlayerId(tmpPlayer->GetUniqueId())->GetClientAddr());
GetDatabase().SetPlayerLastGames(GetId(), tmpPlayer->GetDBId(), lastGames);
} }
++i; ++i;
} }