From 4bc4a79a4bf995e8b4f47aa67f648e6f16d29546 Mon Sep 17 00:00:00 2001 From: WildEgo Date: Sat, 7 Jun 2025 13:51:00 +0100 Subject: [PATCH] remove: Unused code. --- .gitignore | 6 ++ .vscode/launch.json | 2 +- .vscode/settings.json | 21 +++- README.md | 2 +- TODO.md | 15 +++ common/version.h | 15 +++ src/db/src/Lock.cpp | 20 ---- src/db/src/Lock.h | 4 - src/db/src/Main.cpp | 2 - src/db/src/stdafx.h | 5 - src/game/src/MarkConvert.cpp | 17 --- src/game/src/char_change_empire.cpp | 3 + src/game/src/config.cpp | 2 - src/game/src/main.cpp | 13 --- src/game/src/questmanager.cpp | 23 ---- src/game/src/questmanager.h | 9 -- src/game/src/utils.h | 2 - src/libpoly/src/Poly.cc | 4 - src/libsql/include/CAsyncSQL.h | 6 -- src/libsql/include/CStatement.h | 41 ------- src/libsql/include/Tellwait.h | 4 - src/libsql/src/CAsyncSQL.cpp | 44 -------- src/libsql/src/CSemaphore.cpp | 69 ------------ src/libsql/src/CStatement.cpp | 159 ---------------------------- src/libsql/src/Tellwait.cpp | 5 - src/libthecore/include/typedef.h | 38 ------- src/libthecore/include/utils.h | 4 - src/libthecore/src/main.cpp | 5 - src/libthecore/src/signals.cpp | 81 +------------- src/libthecore/src/utils.cpp | 27 ----- src/quest/src/crc32.h | 2 - vcpkg.json | 14 +++ 32 files changed, 75 insertions(+), 589 deletions(-) create mode 100644 TODO.md create mode 100644 common/version.h delete mode 100644 src/libsql/include/CStatement.h delete mode 100644 src/libsql/src/CStatement.cpp create mode 100644 vcpkg.json diff --git a/.gitignore b/.gitignore index 7a40fb4..dbef2b7 100644 --- a/.gitignore +++ b/.gitignore @@ -406,6 +406,9 @@ FodyWeavers.xsd # CMake cmake-build-*/ +cmake/ +CMakeFiles/ +CMakeCache.txt # Mongo Explorer plugin .idea/**/mongoSettings.xml @@ -442,3 +445,6 @@ fabric.properties # Debug folder test/ + +# Vcpkg +vcpkg_installed/ \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index e8338f2..9467abf 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "request": "launch", "name": "Debug portfile(s)", "cmakeDebugType": "external", - "pipeName": "\\\\.\\pipe\\vcpkg_ext_portfile_dbg", + "pipeName": "/tmp/vcpkg_ext_portfile_dbg", "preLaunchTask": "Debug vcpkg commands" } ] diff --git a/.vscode/settings.json b/.vscode/settings.json index 23fcee5..6585b68 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,7 +12,24 @@ "xhash": "cpp", "xstring": "cpp", "xtree": "cpp", - "xutility": "cpp" + "xutility": "cpp", + "sstream": "cpp" }, - "editor.formatOnSave": false + "editor.formatOnSave": false, + "vcpkg.target.useManifest": false, + "cmake.configureArgs": [ + "-DVCPKG_MANIFEST_MODE=OFF", + "-DVCPKG_APPLOCAL_DEPS=ON", + "-DX_VCPKG_APPLOCAL_DEPS_INSTALL=ON", + "-DVCPKG_TARGET_TRIPLET=x64-linux" + ], + "vcpkg.general.enable": true, + "vcpkg.target.hostTriplet": "x64-linux", + "vcpkg.target.defaultTriplet": "x64-linux", + "vcpkg.target.useStaticLib": false, + "cmake.configureSettings": { + "CMAKE_TOOLCHAIN_FILE": "~/.vcpkg/scripts/buildsystems/vcpkg.cmake" + }, + "vcpkg.target.installDependencies": true, + "vcpkg.target.preferSystemLibs": false } diff --git a/README.md b/README.md index 6ff8810..81dcd0e 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Install `vcpkg` according to the [latest instructions](https://vcpkg.io/en/getti Build and install the required libraries: ```shell -vcpkg install cryptopp effolkronium-random libevent lzo fmt spdlog argon2 libpq +vcpkg install cryptopp effolkronium-random libevent lzo fmt spdlog argon2 libpq libpqxx ``` #### Building the binaries diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..b860e2d --- /dev/null +++ b/TODO.md @@ -0,0 +1,15 @@ +# The list +- [ ] Database initialization + - [ ] ClientManager + - [ ] ClientManagerBoot + - [ ] ClientManagerEventFlag + - [ ] ClientManagerGuild + - [ ] ClientManagerHorseName + - [ ] ClientManagerLogin + - [ ] ClientManagerPlayer + - [ ] DBManager + - [ ] GuildManager + - [ ] ItemAwardManager + - [ ] ItemIDRangeManager + - [ ] Marriage + - [ ] Monarch \ No newline at end of file diff --git a/common/version.h b/common/version.h new file mode 100644 index 0000000..f5cdcb5 --- /dev/null +++ b/common/version.h @@ -0,0 +1,15 @@ +#ifndef __INC_METIN_II_VERSION_H__ +#define __INC_METIN_II_VERSION_H__ + +#include + +#define __REVISION__ "c9bd9a7" +#define __COMMIT_DATE__ "2025-06-06 20:26:23 +0100" +#define __COMMIT_TAG__ "0.4.1" +#define __OS_NAME__ "Linux-5.15.167.4-microsoft-standard-WSL2" +#define __COMPILER__ "GNU 9.5.0" +#define __CPU_TARGET__ "x86_64" + +void WriteVersion(); + +#endif diff --git a/src/db/src/Lock.cpp b/src/db/src/Lock.cpp index 876836f..f251d97 100644 --- a/src/db/src/Lock.cpp +++ b/src/db/src/Lock.cpp @@ -12,39 +12,23 @@ CLock::~CLock() void CLock::Initialize() { m_bLocked = false; -#ifndef __WIN32__ pthread_mutex_init(&m_lock, NULL); -#else - ::InitializeCriticalSection(&m_lock); -#endif } void CLock::Destroy() { assert(!m_bLocked && "lock didn't released"); -#ifndef __WIN32__ pthread_mutex_destroy(&m_lock); -#else - ::DeleteCriticalSection(&m_lock); -#endif } int CLock::Trylock() { -#ifndef __WIN32__ return pthread_mutex_trylock(&m_lock); -#else - return ::TryEnterCriticalSection(&m_lock); -#endif } void CLock::Lock() { -#ifndef __WIN32__ pthread_mutex_lock(&m_lock); -#else - ::EnterCriticalSection(&m_lock); -#endif m_bLocked = true; } @@ -52,9 +36,5 @@ void CLock::Unlock() { assert(m_bLocked && "lock didn't issued"); m_bLocked = false; -#ifndef __WIN32__ pthread_mutex_unlock(&m_lock); -#else - ::LeaveCriticalSection(&m_lock); -#endif } diff --git a/src/db/src/Lock.h b/src/db/src/Lock.h index d0ae58a..0e1e7d1 100644 --- a/src/db/src/Lock.h +++ b/src/db/src/Lock.h @@ -2,11 +2,7 @@ #ifndef __INC_LOCK_H__ #define __INC_LOCK_H__ -#ifdef __WIN32__ -typedef CRITICAL_SECTION lock_t; -#else typedef pthread_mutex_t lock_t; -#endif class CLock { diff --git a/src/db/src/Main.cpp b/src/db/src/Main.cpp index 0251149..9c1bee1 100644 --- a/src/db/src/Main.cpp +++ b/src/db/src/Main.cpp @@ -269,9 +269,7 @@ int Start() SPDLOG_INFO("ClientManager initialization OK"); -#ifndef __WIN32__ signal(SIGUSR1, emergency_sig); -#endif signal(SIGSEGV, emergency_sig); return true; } diff --git a/src/db/src/stdafx.h b/src/db/src/stdafx.h index df0b38d..2095179 100644 --- a/src/db/src/stdafx.h +++ b/src/db/src/stdafx.h @@ -3,12 +3,7 @@ #include -#ifndef __WIN32__ #include -#else -#define isdigit iswdigit -#define isspace iswspace -#endif #include #include diff --git a/src/game/src/MarkConvert.cpp b/src/game/src/MarkConvert.cpp index 06473b8..613807f 100644 --- a/src/game/src/MarkConvert.cpp +++ b/src/game/src/MarkConvert.cpp @@ -1,10 +1,6 @@ #include "stdafx.h" #include "MarkManager.h" -#ifdef __WIN32__ -#include -#endif - #define OLD_MARK_INDEX_FILENAME "guild_mark.idx" #define OLD_MARK_DATA_FILENAME "guild_mark.tga" @@ -31,18 +27,10 @@ static Pixel * LoadOldGuildMarkImageFile() bool GuildMarkConvert(const std::vector & vecGuildID) { // 폴더 생성 -#ifndef __WIN32__ mkdir("mark", S_IRWXU); -#else - _mkdir("mark"); -#endif // 인덱스 파일이 있나? -#ifndef __WIN32__ if (0 != access(OLD_MARK_INDEX_FILENAME, F_OK)) -#else - if (0 != _access(OLD_MARK_INDEX_FILENAME, 0)) -#endif return true; // 인덱스 파일 열기 @@ -120,13 +108,8 @@ bool GuildMarkConvert(const std::vector & vecGuildID) fclose(fp); // 컨버트는 한번만 하면되므로 파일을 옮겨준다. -#ifndef __WIN32__ system("mv -f guild_mark.idx guild_mark.idx.removable"); system("mv -f guild_mark.tga guild_mark.tga.removable"); -#else - system("move /Y guild_mark.idx guild_mark.idx.removable"); - system("move /Y guild_mark.tga guild_mark.tga.removable"); -#endif SPDLOG_INFO("Guild Mark Converting Complete."); diff --git a/src/game/src/char_change_empire.cpp b/src/game/src/char_change_empire.cpp index 1d9bd3a..a050154 100644 --- a/src/game/src/char_change_empire.cpp +++ b/src/game/src/char_change_empire.cpp @@ -112,6 +112,9 @@ int CHARACTER::ChangeEmpire(BYTE empire) // 5. 제국 변경 이력을 추가한다. SetChangeEmpireCount(); + SetEmpire(empire); + UpdatePacket(); + return 999; } } diff --git a/src/game/src/config.cpp b/src/game/src/config.cpp index ca61c9a..f3a4e74 100644 --- a/src/game/src/config.cpp +++ b/src/game/src/config.cpp @@ -1,8 +1,6 @@ #include "stdafx.h" #include -#ifndef __WIN32__ #include -#endif #include "constants.h" #include "utils.h" diff --git a/src/game/src/main.cpp b/src/game/src/main.cpp index 03003a9..7c3423c 100644 --- a/src/game/src/main.cpp +++ b/src/game/src/main.cpp @@ -773,19 +773,6 @@ int idle() memset(&s_dwProfiler[0], 0, sizeof(s_dwProfiler)); } -#ifdef __WIN32__ - if (_kbhit()) { - int c = _getch(); - switch (c) { - case 0x1b: // Esc - return 0; // shutdown - break; - default: - break; - } - } -#endif - return 1; } diff --git a/src/game/src/questmanager.cpp b/src/game/src/questmanager.cpp index 187b6ce..5a7b752 100644 --- a/src/game/src/questmanager.cpp +++ b/src/game/src/questmanager.cpp @@ -1630,7 +1630,6 @@ namespace quest GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_PARTY, "LUA_ERROR: quest %s.%s %s", GetCurrentQuestName().c_str(), state_name, event_index_name.c_str() ); } -#ifndef __WIN32__ void CQuestManager::QuestError(const char* func, int line, const char* fmt, ...) { char szMsg[4096]; @@ -1651,28 +1650,6 @@ namespace quest } } } -#else - void CQuestManager::QuestError(const char* func, int line, const char* fmt, ...) - { - char szMsg[4096]; - va_list args; - - va_start(args, fmt); - vsnprintf(szMsg, sizeof(szMsg), fmt, args); - va_end(args); - - _SPDLOG_ERROR(func, line, "%s", szMsg); - if (test_server) - { - LPCHARACTER ch = GetCurrentCharacterPtr(); - if (ch) - { - ch->ChatPacket(CHAT_TYPE_PARTY, "error occurred on [%s:%d]", func,line); - ch->ChatPacket(CHAT_TYPE_PARTY, "%s", szMsg); - } - } - } -#endif void CQuestManager::AddServerTimer(const std::string& name, DWORD arg, LPEVENT event) { diff --git a/src/game/src/questmanager.h b/src/game/src/questmanager.h index 7f505f4..8b7d77b 100644 --- a/src/game/src/questmanager.h +++ b/src/game/src/questmanager.h @@ -5,11 +5,7 @@ #include "questnpc.h" -#ifndef __WIN32__ #define quest_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) -#else -#define quest_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) -#endif class ITEM; class CHARACTER; @@ -173,12 +169,7 @@ namespace quest void ClearError() { m_bError = false; } bool IsError() { return m_bError; } void WriteRunningStateToSyserr(); -#ifndef __WIN32__ void QuestError(const char* func, int line, const char* fmt, ...); -#else - //void QuestError(const char* fmt, ...); - void QuestError(const char* func, int line, const char* fmt, ...); -#endif void RegisterNPCVnum(DWORD dwVnum); diff --git a/src/game/src/utils.h b/src/game/src/utils.h index 938392a..09e8854 100644 --- a/src/game/src/utils.h +++ b/src/game/src/utils.h @@ -38,12 +38,10 @@ inline int DISTANCE_APPROX(int dx, int dy) ( min << 7 ) - ( min << 5 ) + ( min << 3 ) - ( min << 1 )) >> 8 ); } -#ifndef __WIN32__ inline WORD MAKEWORD(BYTE a, BYTE b) { return static_cast(a) | (static_cast(b) << 8); } -#endif extern void set_global_time(time_t t); extern time_t get_global_time(); diff --git a/src/libpoly/src/Poly.cc b/src/libpoly/src/Poly.cc index 023910d..65a2ec1 100644 --- a/src/libpoly/src/Poly.cc +++ b/src/libpoly/src/Poly.cc @@ -9,11 +9,7 @@ using namespace std; double _random() { -#ifndef __WIN32__ return random() / (2147483648.0); -#else - return rand() / (2147483648.0); -#endif } int CPoly::my_irandom(double start, double end) diff --git a/src/libsql/include/CAsyncSQL.h b/src/libsql/include/CAsyncSQL.h index 149918f..406079d 100644 --- a/src/libsql/include/CAsyncSQL.h +++ b/src/libsql/include/CAsyncSQL.h @@ -181,15 +181,9 @@ class CAsyncSQL volatile bool m_bEnd; -#ifndef __WIN32__ pthread_t m_hThread; pthread_mutex_t * m_mtxQuery; pthread_mutex_t * m_mtxResult; -#else - HANDLE m_hThread; - CRITICAL_SECTION* m_mtxQuery; - CRITICAL_SECTION* m_mtxResult; -#endif CSemaphore m_sem; diff --git a/src/libsql/include/CStatement.h b/src/libsql/include/CStatement.h deleted file mode 100644 index 4938400..0000000 --- a/src/libsql/include/CStatement.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __INC_METIN_II_LIBSQL_STATEMENT_H__ -#define __INC_METIN_II_LIBSQL_STATEMENT_H__ - -#include "CAsyncSQL.h" - -#include -#include - -class CStmt -{ - public: - CStmt(); - virtual ~CStmt(); - - bool Prepare(CAsyncSQL * sql, const char * c_pszQuery); - bool BindParam(enum_field_types type, void * p, int iMaxLen=0); - bool BindResult(enum_field_types type, void * p, int iMaxLen=0); - int Execute(); - bool Fetch(); - - void Error(const char * c_pszMsg); - - public: - int iRows; - - private: - void Destroy(); - - MYSQL_STMT * m_pkStmt; - - std::string m_stQuery; - - std::vector m_vec_param; - unsigned int m_uiParamCount; - uint64_t * m_puiParamLen; - - std::vector m_vec_result; - unsigned int m_uiResultCount; -}; - -#endif diff --git a/src/libsql/include/Tellwait.h b/src/libsql/include/Tellwait.h index ef2fb10..add8fad 100644 --- a/src/libsql/include/Tellwait.h +++ b/src/libsql/include/Tellwait.h @@ -1,8 +1,6 @@ #ifndef __INC_METIN_II_TELLWAIT_H__ #define __INC_METIN_II_TELLWAIT_H__ -#ifndef __WIN32__ - extern void TELL_WAIT(); extern void WAIT_CHILD(); @@ -12,5 +10,3 @@ extern void WAIT_PARENT(); extern void TELL_PARENT(pid_t pid); #endif - -#endif diff --git a/src/libsql/src/CAsyncSQL.cpp b/src/libsql/src/CAsyncSQL.cpp index 1977451..741d0d2 100644 --- a/src/libsql/src/CAsyncSQL.cpp +++ b/src/libsql/src/CAsyncSQL.cpp @@ -1,6 +1,4 @@ -#ifndef __WIN32__ #include -#endif #include #include @@ -8,22 +6,13 @@ #include "CAsyncSQL.h" // TODO: Consider providing platform-independent mutex class. -#ifndef __WIN32__ #define MUTEX_LOCK(mtx) pthread_mutex_lock(mtx) #define MUTEX_UNLOCK(mtx) pthread_mutex_unlock(mtx) -#else -#define MUTEX_LOCK(mtx) ::EnterCriticalSection(mtx) -#define MUTEX_UNLOCK(mtx) ::LeaveCriticalSection(mtx) -#endif CAsyncSQL::CAsyncSQL() : m_stHost(""), m_stUser(""), m_stPassword(""), m_stDB(""), m_stLocale(""), m_iMsgCount(0), m_bEnd(false), -#ifndef __WIN32__ m_hThread(0), -#else - m_hThread(INVALID_HANDLE_VALUE), -#endif m_mtxQuery(NULL), m_mtxResult(NULL), m_iQueryFinished(0), m_ulThreadID(0), m_bConnected(false), m_iCopiedQuery(0), m_iPort(0) @@ -51,32 +40,20 @@ void CAsyncSQL::Destroy() if (m_mtxQuery) { -#ifndef __WIN32__ pthread_mutex_destroy(m_mtxQuery); -#else - ::DeleteCriticalSection(m_mtxQuery); -#endif delete m_mtxQuery; m_mtxQuery = NULL; } if (m_mtxResult) { -#ifndef __WIN32__ pthread_mutex_destroy(m_mtxResult); -#else - ::DeleteCriticalSection(m_mtxResult); -#endif delete m_mtxResult; m_mtxQuery = NULL; } } -#ifndef __WIN32__ void * AsyncSQLThread(void * arg) -#else -unsigned int __stdcall AsyncSQLThread(void* arg) -#endif { CAsyncSQL * pSQL = ((CAsyncSQL *) arg); @@ -198,7 +175,6 @@ bool CAsyncSQL::Setup(const char * c_pszHost, const char * c_pszUser, const char return false; } */ -#ifndef __WIN32__ m_mtxQuery = new pthread_mutex_t; m_mtxResult = new pthread_mutex_t; @@ -215,19 +191,6 @@ bool CAsyncSQL::Setup(const char * c_pszHost, const char * c_pszUser, const char } pthread_create(&m_hThread, NULL, AsyncSQLThread, this); -#else - m_mtxQuery = new CRITICAL_SECTION; - m_mtxResult = new CRITICAL_SECTION; - - ::InitializeCriticalSection(m_mtxQuery); - ::InitializeCriticalSection(m_mtxResult); - - m_hThread = (HANDLE)::_beginthreadex(NULL, 0, AsyncSQLThread, this, 0, NULL); - if (m_hThread == INVALID_HANDLE_VALUE) { - perror("CAsyncSQL::Setup"); - return false; - } -#endif return true; } @@ -240,18 +203,11 @@ void CAsyncSQL::Quit() m_bEnd = true; m_sem.Release(); -#ifndef __WIN32__ if (m_hThread) { pthread_join(m_hThread, NULL); m_hThread = NULL; } -#else - if (m_hThread != INVALID_HANDLE_VALUE) { - ::WaitForSingleObject(m_hThread, INFINITE); - m_hThread = INVALID_HANDLE_VALUE; - } -#endif } SQLMsg * CAsyncSQL::DirectQuery(const char * c_pszQuery) diff --git a/src/libsql/src/CSemaphore.cpp b/src/libsql/src/CSemaphore.cpp index 8e29a52..94ec897 100644 --- a/src/libsql/src/CSemaphore.cpp +++ b/src/libsql/src/CSemaphore.cpp @@ -1,8 +1,6 @@ #include "stdafx.h" #include "CSemaphore.h" -#ifndef __WIN32__ - CSemaphore::CSemaphore() : m_hSem(NULL) { Initialize(); @@ -73,70 +71,3 @@ int CSemaphore::Release(int count) return true; } - -#else - -CSemaphore::CSemaphore() : m_hSem(NULL) -{ - Initialize(); -} - -CSemaphore::~CSemaphore() -{ - Destroy(); -} - -int CSemaphore::Initialize() -{ - Clear(); - - m_hSem = ::CreateSemaphore(NULL, 0, 32, NULL); - - if (m_hSem == NULL) { - return false; - } - - return true; -} - -void CSemaphore::Destroy() -{ - Clear(); -} - -void CSemaphore::Clear() -{ - if (m_hSem == NULL) { - return; - } - ::CloseHandle(m_hSem); - m_hSem = NULL; -} - -int CSemaphore::Wait() -{ - if (!m_hSem) - return true; - - DWORD dwWaitResult = ::WaitForSingleObject(m_hSem, INFINITE); - - switch (dwWaitResult) { - case WAIT_OBJECT_0: - return true; - default: - break; - } - return false; -} - -int CSemaphore::Release(int count) -{ - if (!m_hSem) - return false; - - ::ReleaseSemaphore(m_hSem, count, NULL); - - return true; -} - -#endif diff --git a/src/libsql/src/CStatement.cpp b/src/libsql/src/CStatement.cpp deleted file mode 100644 index 4f666ed..0000000 --- a/src/libsql/src/CStatement.cpp +++ /dev/null @@ -1,159 +0,0 @@ -#include "CStatement.h" - -#include -#include - -CStmt::CStmt() -{ - m_pkStmt = NULL; - m_uiParamCount = 0; - m_uiResultCount = 0; - iRows = 0; - m_puiParamLen = NULL; -} - -CStmt::~CStmt() -{ - Destroy(); -} - -void CStmt::Destroy() -{ - if (m_pkStmt) - { - mysql_stmt_close(m_pkStmt); - m_pkStmt = NULL; - } - - if (m_puiParamLen) - { - free(m_puiParamLen); - m_puiParamLen = NULL; - } -} - -void CStmt::Error(const char * c_pszMsg) -{ - SPDLOG_ERROR("SYSERR: {}: [{}] {}", c_pszMsg, mysql_stmt_errno(m_pkStmt), mysql_stmt_error(m_pkStmt)); -} - -bool CStmt::Prepare(CAsyncSQL * sql, const char * c_pszQuery) -{ - m_pkStmt = mysql_stmt_init(sql->GetSQLHandle()); - m_stQuery = c_pszQuery; - - if (mysql_stmt_prepare(m_pkStmt, m_stQuery.c_str(), m_stQuery.length())) - { - Error("mysql_stmt_prepare"); - return false; - } - - int iParamCount = 0; - - for (unsigned int i = 0; i < m_stQuery.length(); ++i) - if (c_pszQuery[i] == '?') - ++iParamCount; - - if (iParamCount) - { - m_vec_param.resize(iParamCount); - memset(&m_vec_param[0], 0, sizeof(MYSQL_BIND) * iParamCount); - - m_puiParamLen = (uint64_t *) calloc(iParamCount, sizeof(uint64_t)); - } - - m_vec_result.resize(48); - memset(&m_vec_result[0], 0, sizeof(MYSQL_BIND) * 48); - - if (mysql_stmt_bind_result(m_pkStmt, &m_vec_result[0])) - { - Error("mysql_stmt_bind_result"); - return 0; - } - - return true; -} - -bool CStmt::BindParam(enum_field_types type, void * p, int iMaxLen) -{ - if (m_uiParamCount >= m_vec_param.size()) - { - SPDLOG_ERROR("too many parameter in query: {}", m_stQuery); - return false; - } - - MYSQL_BIND * bind = &m_vec_param[m_uiParamCount]; - - bind->buffer_type = type; - bind->buffer = (void *) p; - bind->buffer_length = iMaxLen; - bind->length = m_puiParamLen + m_uiParamCount; - - if (++m_uiParamCount == m_vec_param.size()) - { - if (mysql_stmt_bind_param(m_pkStmt, &m_vec_param[0])) - { - Error("mysql_stmt_bind_param"); - return false; - } - } - - return true; -} - -bool CStmt::BindResult(enum_field_types type, void * p, int iMaxLen) -{ - if (m_uiResultCount >= m_vec_result.size()) - { - SPDLOG_ERROR("too many result in query: {}", m_stQuery); - return false; - } - - MYSQL_BIND * bind = &m_vec_result[m_uiResultCount++]; - - bind->buffer_type = type; - bind->buffer = (void *) p; - bind->buffer_length = iMaxLen; - return true; -} - -int CStmt::Execute() -{ - if (m_uiParamCount != m_vec_param.size()) - { - SPDLOG_ERROR("Parameter not enough {}, expected {} query: {}", m_uiParamCount, m_vec_param.size(), m_stQuery); - return 0; - } - - for (unsigned int i = 0; i < m_uiParamCount; ++i) - { - MYSQL_BIND * bind = &m_vec_param[i]; - - if (bind->buffer_type == MYSQL_TYPE_STRING) - { - *(m_puiParamLen + i) = strlen((const char *) bind->buffer); - SPDLOG_TRACE("param {} len {} buf {}", i, *m_puiParamLen, (const char *) bind->buffer); - } - } - - if (mysql_stmt_execute(m_pkStmt)) - { - Error("mysql_stmt_execute"); - return 0; - } - - if (mysql_stmt_store_result(m_pkStmt)) - { - Error("mysql_store_result"); - return 0; - } - - iRows = mysql_stmt_num_rows(m_pkStmt); - return true; -} - -bool CStmt::Fetch() -{ - return !mysql_stmt_fetch(m_pkStmt); -} - diff --git a/src/libsql/src/Tellwait.cpp b/src/libsql/src/Tellwait.cpp index a3b04df..a823c3f 100644 --- a/src/libsql/src/Tellwait.cpp +++ b/src/libsql/src/Tellwait.cpp @@ -1,5 +1,3 @@ -#ifndef __WIN32__ - #include #include #include @@ -82,6 +80,3 @@ void WAIT_CHILD(void) exit(1); } } - -#endif - diff --git a/src/libthecore/include/typedef.h b/src/libthecore/include/typedef.h index 4c981e2..daeb5c1 100644 --- a/src/libthecore/include/typedef.h +++ b/src/libthecore/include/typedef.h @@ -8,8 +8,6 @@ typedef uint8_t UBYTE; typedef int8_t sbyte; typedef uint16_t sh_int; -#ifndef __WIN32__ - typedef uint32_t DWORD; typedef uint32_t BOOL; typedef uint8_t BYTE; @@ -19,40 +17,4 @@ typedef uint32_t ULONG; typedef int32_t INT; typedef uint32_t UINT; -#else - -struct timezone -{ - int tz_minuteswest; /* minutes west of Greenwich */ - int tz_dsttime; /* type of dst correction */ -}; - -typedef SOCKET socket_t; - -#if !defined(_W64) -#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -#define _W64 __w64 -#else -#define _W64 -#endif -#endif - -#ifdef _WIN64 -typedef __int64 ssize_t; -#else -typedef _W64 int ssize_t; -#endif - -// Fixed-size integer types -#if defined(_MSC_VER) && (_MSC_VER >= 1300) -typedef __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#endif - -typedef unsigned int uint; - -#endif - #endif // __INC_LIBTHECORE_TYPEDEF_H__ diff --git a/src/libthecore/include/utils.h b/src/libthecore/include/utils.h index 6f8908f..af3ed9a 100644 --- a/src/libthecore/include/utils.h +++ b/src/libthecore/include/utils.h @@ -120,8 +120,4 @@ extern "C++" #endif #endif -#ifdef __WIN32__ -extern void gettimeofday(struct timeval* t, struct timezone* dummy); -#endif - #endif // __INC_UTILS_H__ diff --git a/src/libthecore/src/main.cpp b/src/libthecore/src/main.cpp index 68c7f2f..cd9cac2 100644 --- a/src/libthecore/src/main.cpp +++ b/src/libthecore/src/main.cpp @@ -15,12 +15,7 @@ unsigned int thecore_profiler[NUM_PF]; int thecore_init(int fps, HEARTFUNC heartbeat_func) { -#if defined(__WIN32__) || defined(__linux__) srand(time(0)); -#else - srandom(time(0) + getpid() + getuid()); - srandomdev(); -#endif signal_setup(); thecore_heart = heart_new(1000000 / fps, heartbeat_func); diff --git a/src/libthecore/src/signals.cpp b/src/libthecore/src/signals.cpp index 21866d8..dfac9c3 100644 --- a/src/libthecore/src/signals.cpp +++ b/src/libthecore/src/signals.cpp @@ -7,85 +7,6 @@ #define __LIBTHECORE__ #include "stdafx.h" -#if defined(__WIN32__) || defined(__linux__) void signal_setup() {} void signal_timer_disable() {} -void signal_timer_enable(int timeout_seconds) {} -#elif __FreeBSD__ -#define RETSIGTYPE void - -RETSIGTYPE reap(int sig) -{ - while (waitpid(-1, NULL, WNOHANG) > 0); - signal(SIGCHLD, reap); -} - - -RETSIGTYPE checkpointing(int sig) -{ - if (!tics) - { - sys_err("CHECKPOINT shutdown: tics did not updated."); - abort(); - } - else - tics = 0; -} - - -RETSIGTYPE hupsig(int sig) -{ - shutdowned = true; - sys_err("SIGHUP, SIGINT, SIGTERM signal has been received. shutting down."); -} - -RETSIGTYPE usrsig(int sig) -{ - core_dump(); -} - -void signal_timer_disable(void) -{ - struct itimerval itime; - struct timeval interval; - - interval.tv_sec = 0; - interval.tv_usec = 0; - - itime.it_interval = interval; - itime.it_value = interval; - - setitimer(ITIMER_VIRTUAL, &itime, NULL); -} - -void signal_timer_enable(int sec) -{ - struct itimerval itime; - struct timeval interval; - - interval.tv_sec = sec; - interval.tv_usec = 0; - - itime.it_interval = interval; - itime.it_value = interval; - - setitimer(ITIMER_VIRTUAL, &itime, NULL); -} - -void signal_setup(void) -{ - signal_timer_enable(30); - - signal(SIGVTALRM, checkpointing); - - /* just to be on the safe side: */ - signal(SIGHUP, hupsig); - signal(SIGCHLD, reap); - signal(SIGINT, hupsig); - signal(SIGTERM, hupsig); - signal(SIGPIPE, SIG_IGN); - signal(SIGALRM, SIG_IGN); - signal(SIGUSR1, usrsig); -} - -#endif +void signal_timer_enable(int timeout_seconds) {} \ No newline at end of file diff --git a/src/libthecore/src/utils.cpp b/src/libthecore/src/utils.cpp index af94c67..7973f02 100644 --- a/src/libthecore/src/utils.cpp +++ b/src/libthecore/src/utils.cpp @@ -210,7 +210,6 @@ struct tm * tm_calc(const struct tm * curr_tm, int days) return (&new_tm); } -#ifndef __WIN32__ void thecore_sleep(struct timeval* timeout) { if (select(0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, timeout) < 0) @@ -251,32 +250,6 @@ uint64_t rdtsc() } */ -#else - -void thecore_sleep(struct timeval* timeout) -{ - Sleep(timeout->tv_sec * 1000 + timeout->tv_usec / 1000); -} - -void thecore_msleep(DWORD dwMillisecond) -{ - Sleep(dwMillisecond); -} - -void gettimeofday(struct timeval* t, struct timezone* dummy) -{ - DWORD millisec = GetTickCount(); - - t->tv_sec = (millisec / 1000); - t->tv_usec = (millisec % 1000) * 1000; -} - -void core_dump_unix(const char *who, WORD line) -{ -} - -#endif - float get_float_time() { struct timeval tv; diff --git a/src/quest/src/crc32.h b/src/quest/src/crc32.h index c4aebeb..6eb45ed 100644 --- a/src/quest/src/crc32.h +++ b/src/quest/src/crc32.h @@ -1,9 +1,7 @@ #ifndef __INC_CRC32_H__ #define __INC_CRC32_H__ -#ifndef __WIN32__ #include -#endif typedef unsigned int crc_t; diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..2a99add --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,14 @@ +{ + "dependencies": [ + "cryptopp", + "effolkronium-random", + "libevent", + "lzo", + "fmt", + "spdlog", + "argon2", + "libpq", + "libpqxx" + ], + "builtin-baseline": "a9eee3b18df395dbb8be71a31bd78ea441056e42" +}