From 06f9fb7fffd862f5d9aa3830d27815bd15f5a141 Mon Sep 17 00:00:00 2001 From: Kai Philipp Date: Fri, 13 Sep 2019 14:38:05 +0200 Subject: [PATCH] lastGames restored after login --- src/db/dbdefs.h | 2 +- src/dbofficial/serverdbthread.cpp | 2 +- src/net/common/serverlobbythread.cpp | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/db/dbdefs.h b/src/db/dbdefs.h index 59329dce..c664ce7b 100644 --- a/src/db/dbdefs.h +++ b/src/db/dbdefs.h @@ -46,7 +46,7 @@ struct DBPlayerData { std::string secret; std::string country; std::string last_login; - std::vector lastGames; + std::string lastGames; std::string lastIp; }; diff --git a/src/dbofficial/serverdbthread.cpp b/src/dbofficial/serverdbthread.cpp index 3bb08885..179c0c1d 100644 --- a/src/dbofficial/serverdbthread.cpp +++ b/src/dbofficial/serverdbthread.cpp @@ -463,7 +463,7 @@ ServerDBThread::EstablishDBConnection() */ prepareNick << "PREPARE " QUERY_NICK_PREPARE " FROM " << mysqlpp::quote - << "SELECT " DB_TABLE_PLAYER_COL_ID ", AES_DECRYPT(" DB_TABLE_PLAYER_COL_PASSWORD ", ?), " DB_TABLE_PLAYER_COL_VALID ", TRIM(" DB_TABLE_PLAYER_COL_COUNTRY "), " DB_TABLE_PLAYER_COL_LASTLOGIN ", " DB_TABLE_PLAYER_COL_ACTIVE " FROM " DB_TABLE_PLAYER " WHERE " DB_TABLE_PLAYER_COL_USERNAME " = ?"; + << "SELECT " DB_TABLE_PLAYER_COL_ID ", AES_DECRYPT(" DB_TABLE_PLAYER_COL_PASSWORD ", ?), " DB_TABLE_PLAYER_COL_VALID ", TRIM(" DB_TABLE_PLAYER_COL_COUNTRY "), " DB_TABLE_PLAYER_COL_LASTLOGIN ", " DB_TABLE_PLAYER_COL_LASTGAMES ", " DB_TABLE_PLAYER_COL_LASTIP " FROM " DB_TABLE_PLAYER " WHERE " DB_TABLE_PLAYER_COL_USERNAME " = ?"; mysqlpp::Query prepareAvatarBlacklist = m_connData->conn.query(); prepareAvatarBlacklist diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index 14f4689c..e0c15673 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -1811,6 +1811,16 @@ ServerLobbyThread::UserValid(unsigned playerId, const DBPlayerData &dbPlayerData if (tmpSession && tmpSession->GetPlayerData()) { tmpSession->GetPlayerData()->SetDBId(dbPlayerData.id); tmpSession->GetPlayerData()->SetCountry(dbPlayerData.country); +LOG_ERROR("lastGames from db = " << dbPlayerData.lastGames); + std::vector lastGames; + std::stringstream ss(dbPlayerData.lastGames); + for (int i; ss >> i;) { + lastGames.push_back(i); + if (ss.peek() == ',') + ss.ignore(); + } + tmpSession->GetPlayerData()->SetPlayerLastGames(lastGames); +LOG_ERROR("lastGames first from vector after db = " << tmpSession->GetPlayerData()->GetPlayerLastGames()); this->AuthChallenge(tmpSession, dbPlayerData.secret); } }