diff --git a/src/db/src/ClientManagerPlayer.cpp b/src/db/src/ClientManagerPlayer.cpp index 944da6e..16b7558 100644 --- a/src/db/src/ClientManagerPlayer.cpp +++ b/src/db/src/ClientManagerPlayer.cpp @@ -6,11 +6,8 @@ #include "Main.h" #include "QID.h" #include "ItemAwardManager.h" -#include "HB.h" #include "Cache.h" -extern bool g_bHotBackup; - extern std::string g_stLocale; extern int g_test_server; @@ -195,9 +192,6 @@ void CClientManager::PutPlayerCache(TPlayerTable * pNew) m_map_playerCache.insert(TPlayerTableCacheMap::value_type(pNew->id, c)); } - if (g_bHotBackup) - PlayerHB::instance().Put(pNew->id); - c->Put(pNew); } diff --git a/src/db/src/DBManager.h b/src/db/src/DBManager.h index f8b1d39..f9268f9 100644 --- a/src/db/src/DBManager.h +++ b/src/db/src/DBManager.h @@ -23,7 +23,6 @@ enum eSQL_SLOT SQL_PLAYER, SQL_ACCOUNT, SQL_COMMON, - SQL_HOTBACKUP, SQL_MAX_NUM, }; diff --git a/src/db/src/HB.cpp b/src/db/src/HB.cpp deleted file mode 100644 index 8e899fe..0000000 --- a/src/db/src/HB.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "stdafx.h" -#include "HB.h" -#include "Main.h" -#include "DBManager.h" - -#include - -PlayerHB::PlayerHB() -{ - m_iExpireTime = 3600; // 1 hour hotbackup default. -} - -PlayerHB::~PlayerHB() -{ -} - -bool PlayerHB::Initialize() -{ - char szQuery[128]; - snprintf(szQuery, sizeof(szQuery), "SHOW CREATE TABLE player%s", GetTablePostfix()); - - std::unique_ptr pMsg(CDBManager::instance().DirectQuery(szQuery)); - - if (pMsg->Get()->uiNumRows == 0) - return false; - - MYSQL_ROW row = mysql_fetch_row(pMsg->Get()->pSQLResult); - m_stCreateTableQuery = row[1]; - return true; -} - -// -// @version 05/07/05 Bang2ni - id ¿¡ ÇØ´çÇÏ´Â data °¡ ¾øÀ» ¶§ Äõ¸®ÇÏ°í data ¸¦ insert ÇÏ´ÂÄÚµå Ãß°¡. -// -void PlayerHB::Put(DWORD id) -{ - itertype(m_map_data) it = m_map_data.find(id); - - if (it == m_map_data.end()) - { - Query(id); - m_map_data.insert(std::pair< DWORD, time_t >(id, get_dword_time())); - return; - } - - if (time(0) - it->second > m_iExpireTime) - Query(id); -} - -// -// @version 05/07/05 Bang2ni - Query string ¹öÆÛ°¡ À۾Ƽ­ ´Ã·ÁÁÜ. -// -bool PlayerHB::Query(DWORD id) -{ - time_t ct = time(0); - struct tm curr_tm = *localtime(&ct); - char szTableName[64]; - snprintf(szTableName, sizeof(szTableName), "hb_%02d%02d%02d%02d_player%s", - curr_tm.tm_year - 100, curr_tm.tm_mon + 1, curr_tm.tm_mday, curr_tm.tm_hour, GetTablePostfix()); - - char szQuery[4096]; - - if (m_stTableName.compare(szTableName)) - { - char szFind[32]; - snprintf(szFind, sizeof(szFind), "CREATE TABLE `player%s`", GetTablePostfix()); - int pos = m_stCreateTableQuery.find(szFind); - - if (pos < 0) - { - SPDLOG_ERROR("cannot find {} ", szFind); - // SPDLOG_ERROR("cannot find {} in {}", szFind, m_stCreateTableQuery.c_str()); - return false; - } - - snprintf(szQuery, sizeof(szQuery), "CREATE TABLE IF NOT EXISTS %s%s", szTableName, m_stCreateTableQuery.c_str() + strlen(szFind)); - // SPDLOG_DEBUG("{}", szQuery); - std::unique_ptr pMsg(CDBManager::instance().DirectQuery(szQuery, SQL_HOTBACKUP)); - m_stTableName = szTableName; - } - - snprintf(szQuery, sizeof(szQuery), "REPLACE INTO %s SELECT * FROM %splayer%s WHERE id=%u", m_stTableName.c_str(), GetPlayerDBName(), GetTablePostfix(), id); - CDBManager::instance().AsyncQuery(szQuery, SQL_HOTBACKUP); - return true; -} - diff --git a/src/db/src/HB.h b/src/db/src/HB.h deleted file mode 100644 index 8c5da77..0000000 --- a/src/db/src/HB.h +++ /dev/null @@ -1,24 +0,0 @@ -// vim:ts=8 sw=4 -#ifndef __INC_METIN_II_PLAYERHB_H__ -#define __INC_METIN_II_PLAYERHB_H__ - -class PlayerHB : public singleton -{ - public: - PlayerHB(); - virtual ~PlayerHB(); - - bool Initialize(); - - void Put(DWORD id); - - private: - bool Query(DWORD id); - - std::map m_map_data; - std::string m_stCreateTableQuery; - std::string m_stTableName; - int m_iExpireTime; -}; - -#endif diff --git a/src/db/src/Main.cpp b/src/db/src/Main.cpp index ac392cb..271c4ef 100644 --- a/src/db/src/Main.cpp +++ b/src/db/src/Main.cpp @@ -5,7 +5,6 @@ #include "ClientManager.h" #include "GuildManager.h" #include "ItemAwardManager.h" -#include "HB.h" #include "PrivManager.h" #include "MoneyLog.h" #include "Marriage.h" @@ -28,7 +27,6 @@ std::string g_stLocale = "euckr"; std::string g_stPlayerDBName = ""; -bool g_bHotBackup = false; BOOL g_test_server = false; //´ÜÀ§ ÃÊ @@ -70,7 +68,6 @@ int main() CConfig Config; CDBManager DBManager; CClientManager ClientManager; - PlayerHB player_hb; CGuildManager GuildManager; CPrivManager PrivManager; CMoneyLog MoneyLog; @@ -170,27 +167,8 @@ int Start() { g_stLocale = szBuf; SPDLOG_INFO("LOCALE set to {}", g_stLocale.c_str()); - - // CHINA_DISABLE_HOTBACKUP - if ("gb2312" == g_stLocale) - { - SPDLOG_INFO("CIBN_LOCALE: DISABLE_HOTBACKUP"); - g_bHotBackup = false; - } - // END_OF_CHINA_DISABLE_HOTBACKUP } - int iDisableHotBackup; - if (CConfig::instance().GetValue("DISABLE_HOTBACKUP", &iDisableHotBackup)) - { - if (iDisableHotBackup) - { - SPDLOG_INFO("CONFIG: DISABLE_HOTBACKUP"); - g_bHotBackup = false; - } - } - - if (!CConfig::instance().GetValue("TABLE_POSTFIX", szBuf, 256)) { SPDLOG_WARN("TABLE_POSTFIX not configured use default"); @@ -324,35 +302,6 @@ int Start() return false; } - if (CConfig::instance().GetValue("SQL_HOTBACKUP", line, 256)) - { - sscanf(line, " %s %s %s %s %d ", szAddr, szDB, szUser, szPassword, &iPort); - SPDLOG_DEBUG("connecting to MySQL server (hotbackup)"); - - int iRetry = 5; - - do - { - if (CDBManager::instance().Connect(SQL_HOTBACKUP, szAddr, iPort, szDB, szUser, szPassword)) - { - SPDLOG_DEBUG(" OK"); - break; - } - - SPDLOG_DEBUG(" failed, retrying in 5 seconds"); - SPDLOG_ERROR(" failed, retrying in 5 seconds"); - sleep(5); - } - while (iRetry--); - - SPDLOG_INFO("Success HOTBACKUP"); - } - else - { - SPDLOG_ERROR("SQL_HOTBACKUP not configured"); - return false; - } - if (!CClientManager::instance().Initialize()) { SPDLOG_ERROR("ClientManager initialization failed"); @@ -361,12 +310,6 @@ int Start() SPDLOG_INFO("ClientManager initialization OK"); - if (!PlayerHB::instance().Initialize()) - { - SPDLOG_ERROR("cannot initialize player hotbackup"); - return false; - } - #ifndef __WIN32__ signal(SIGUSR1, emergency_sig); #endif