From 7f26c9ddaddb99fb47c6738c997e2fd2dbd876e4 Mon Sep 17 00:00:00 2001 From: Kargatum Date: Tue, 17 Nov 2020 16:59:58 +0700 Subject: [PATCH] refactor(Core/Common): restyle tools with astyle (#3706) --- .../BoundingIntervalHierarchyWrapper.h | 2 +- src/common/Collision/DynamicTree.cpp | 2 +- .../Collision/Management/IVMapManager.h | 6 +- .../Collision/Management/MMapManager.cpp | 4 +- src/common/Collision/Maps/MapTree.cpp | 2 +- src/common/Collision/Maps/TileAssembler.cpp | 2 +- src/common/Collision/RegularGrid.h | 2 +- src/common/Configuration/Config.h | 2 +- src/common/Cryptography/OpenSSLCrypto.cpp | 4 +- src/common/DataStores/DBCFileLoader.cpp | 18 +- src/common/Database/DatabaseWorkerPool.cpp | 3 +- src/common/Database/MySQLConnection.cpp | 70 ++--- src/common/Database/MySQLConnection.h | 2 +- src/common/Database/QueryHolder.cpp | 24 +- .../Debugging/WheatyExceptionReport.cpp | 282 +++++++++--------- src/common/Dynamic/LinkedList.h | 16 +- .../Dynamic/LinkedReference/RefManager.h | 2 +- .../Dynamic/LinkedReference/Reference.h | 16 +- src/common/Dynamic/ObjectRegistry.h | 2 +- src/common/Dynamic/TypeContainer.h | 6 +- src/common/Dynamic/TypeContainerFunctions.h | 6 +- .../Dynamic/TypeContainerFunctionsPtr.h | 12 +- src/common/Dynamic/TypeContainerVisitor.h | 6 +- src/common/Logging/Log.cpp | 2 +- src/common/Threading/LockedQueue.h | 2 +- src/common/Utilities/EventProcessor.cpp | 2 +- src/common/Utilities/Util.cpp | 12 +- src/common/Utilities/Util.h | 32 +- 28 files changed, 269 insertions(+), 272 deletions(-) diff --git a/src/common/Collision/BoundingIntervalHierarchyWrapper.h b/src/common/Collision/BoundingIntervalHierarchyWrapper.h index c3381ffdd..29c693928 100644 --- a/src/common/Collision/BoundingIntervalHierarchyWrapper.h +++ b/src/common/Collision/BoundingIntervalHierarchyWrapper.h @@ -13,7 +13,7 @@ #include "BoundingIntervalHierarchy.h" -template > +template> class BIHWrap { template diff --git a/src/common/Collision/DynamicTree.cpp b/src/common/Collision/DynamicTree.cpp index 74d373f07..84dac1171 100644 --- a/src/common/Collision/DynamicTree.cpp +++ b/src/common/Collision/DynamicTree.cpp @@ -50,7 +50,7 @@ static bool operator == (const GameObjectModel& mdl, const GameObjectModel& mdl2 } */ -typedef RegularGrid2D > ParentTree; +typedef RegularGrid2D> ParentTree; struct DynTreeImpl : public ParentTree/*, public Intersectable*/ { diff --git a/src/common/Collision/Management/IVMapManager.h b/src/common/Collision/Management/IVMapManager.h index 8393fd08c..42526de36 100644 --- a/src/common/Collision/Management/IVMapManager.h +++ b/src/common/Collision/Management/IVMapManager.h @@ -71,9 +71,9 @@ namespace VMAP */ void setEnableHeightCalc(bool pVal) { iEnableHeightCalc = pVal; } - bool isLineOfSightCalcEnabled() const { return(iEnableLineOfSightCalc); } - bool isHeightCalcEnabled() const { return(iEnableHeightCalc); } - bool isMapLoadingEnabled() const { return(iEnableLineOfSightCalc || iEnableHeightCalc ); } + bool isLineOfSightCalcEnabled() const { return (iEnableLineOfSightCalc); } + bool isHeightCalcEnabled() const { return (iEnableHeightCalc); } + bool isMapLoadingEnabled() const { return (iEnableLineOfSightCalc || iEnableHeightCalc ); } virtual std::string getDirFileName(unsigned int pMapId, int x, int y) const = 0; /** diff --git a/src/common/Collision/Management/MMapManager.cpp b/src/common/Collision/Management/MMapManager.cpp index 2d2b6d940..4f68e851a 100644 --- a/src/common/Collision/Management/MMapManager.cpp +++ b/src/common/Collision/Management/MMapManager.cpp @@ -96,7 +96,7 @@ namespace MMAP ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, MMapManagerLock); // make sure the mmap is loaded and ready to load tiles - if(!loadMapData(mapId)) + if (!loadMapData(mapId)) return false; // get this mmap data @@ -148,7 +148,7 @@ namespace MMAP ASSERT(data); size_t result = fread(data, fileHeader.size, 1, file); - if(!result) + if (!result) { sLog->outError("MMAP:loadMap: Bad header or data in mmap %03u%02i%02i.mmtile", mapId, x, y); fclose(file); diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp index 1dd007c81..1a81a5524 100644 --- a/src/common/Collision/Maps/MapTree.cpp +++ b/src/common/Collision/Maps/MapTree.cpp @@ -220,7 +220,7 @@ namespace VMAP { height = pPos.z - maxDist; } - return(height); + return (height); } //========================================================= diff --git a/src/common/Collision/Maps/TileAssembler.cpp b/src/common/Collision/Maps/TileAssembler.cpp index 5c2931c51..7e1fdbce0 100644 --- a/src/common/Collision/Maps/TileAssembler.cpp +++ b/src/common/Collision/Maps/TileAssembler.cpp @@ -37,7 +37,7 @@ namespace VMAP { Vector3 out = pIn * iScale; out = iRotation * out; - return(out); + return (out); } //================================================================= diff --git a/src/common/Collision/RegularGrid.h b/src/common/Collision/RegularGrid.h index 8997bd719..0477c694e 100644 --- a/src/common/Collision/RegularGrid.h +++ b/src/common/Collision/RegularGrid.h @@ -52,7 +52,7 @@ public: #define HGRID_MAP_SIZE (533.33333f * 64.f) // shouldn't be changed #define CELL_SIZE float(HGRID_MAP_SIZE/(float)CELL_NUMBER) - typedef G3D::Table > MemberTable; + typedef G3D::Table> MemberTable; MemberTable memberTable; Node* nodes[CELL_NUMBER][CELL_NUMBER]; diff --git a/src/common/Configuration/Config.h b/src/common/Configuration/Config.h index db631ba77..56cade006 100644 --- a/src/common/Configuration/Config.h +++ b/src/common/Configuration/Config.h @@ -49,7 +49,7 @@ public: private: bool dryRun = false; - + bool LoadData(std::string const& file); }; diff --git a/src/common/Cryptography/OpenSSLCrypto.cpp b/src/common/Cryptography/OpenSSLCrypto.cpp index ea4b5cc17..bbaa7aec9 100644 --- a/src/common/Cryptography/OpenSSLCrypto.cpp +++ b/src/common/Cryptography/OpenSSLCrypto.cpp @@ -27,7 +27,7 @@ static void threadIdCallback(CRYPTO_THREADID* id) void OpenSSLCrypto::threadsSetup() { cryptoLocks.resize(CRYPTO_num_locks()); - for(int i = 0 ; i < CRYPTO_num_locks(); ++i) + for (int i = 0 ; i < CRYPTO_num_locks(); ++i) { cryptoLocks[i] = new std::mutex(); } @@ -40,7 +40,7 @@ void OpenSSLCrypto::threadsCleanup() { CRYPTO_set_locking_callback(nullptr); CRYPTO_THREADID_set_callback(nullptr); - for(int i = 0 ; i < CRYPTO_num_locks(); ++i) + for (int i = 0 ; i < CRYPTO_num_locks(); ++i) { delete cryptoLocks[i]; } diff --git a/src/common/DataStores/DBCFileLoader.cpp b/src/common/DataStores/DBCFileLoader.cpp index 24deb407d..57502a6d4 100644 --- a/src/common/DataStores/DBCFileLoader.cpp +++ b/src/common/DataStores/DBCFileLoader.cpp @@ -275,17 +275,17 @@ char* DBCFileLoader::AutoProduceStrings(char const* format, char* dataTable) offset += sizeof(uint8); break; case FT_STRING: + { + // fill only not filled entries + char** slot = (char**)(&dataTable[offset]); + if (!*slot || !** slot) { - // fill only not filled entries - char** slot = (char**)(&dataTable[offset]); - if (!*slot || !** slot) - { - const char* st = getRecord(y).getString(x); - *slot = stringPool + (st - (char const*)stringTable); - } - offset += sizeof(char*); - break; + const char* st = getRecord(y).getString(x); + *slot = stringPool + (st - (char const*)stringTable); } + offset += sizeof(char*); + break; + } case FT_LOGIC: ASSERT(false && "Attempted to load DBC files that does not have field types that match what is in the core. Check DBCfmt.h or your DBC files."); break; diff --git a/src/common/Database/DatabaseWorkerPool.cpp b/src/common/Database/DatabaseWorkerPool.cpp index b68789573..d3a301c43 100644 --- a/src/common/Database/DatabaseWorkerPool.cpp +++ b/src/common/Database/DatabaseWorkerPool.cpp @@ -10,8 +10,7 @@ #define MIN_MYSQL_SERVER_VERSION 50600u #define MIN_MYSQL_CLIENT_VERSION 50600u -template -DatabaseWorkerPool::DatabaseWorkerPool() : +template DatabaseWorkerPool::DatabaseWorkerPool() : _mqueue(new ACE_Message_Queue(2 * 1024 * 1024, 2 * 1024 * 1024)), _queue(new ACE_Activation_Queue(_mqueue)) { diff --git a/src/common/Database/MySQLConnection.cpp b/src/common/Database/MySQLConnection.cpp index 75d5fa7de..b65fa0093 100644 --- a/src/common/Database/MySQLConnection.cpp +++ b/src/common/Database/MySQLConnection.cpp @@ -402,29 +402,29 @@ bool MySQLConnection::ExecuteTransaction(SQLTransaction& transaction) switch (itr->type) { case SQL_ELEMENT_PREPARED: + { + PreparedStatement* stmt = data.element.stmt; + ASSERT(stmt); + if (!Execute(stmt)) { - PreparedStatement* stmt = data.element.stmt; - ASSERT(stmt); - if (!Execute(stmt)) - { - sLog->outSQLDriver("[Warning] Transaction aborted. %u queries not executed.", (uint32)queries.size()); - RollbackTransaction(); - return false; - } + sLog->outSQLDriver("[Warning] Transaction aborted. %u queries not executed.", (uint32)queries.size()); + RollbackTransaction(); + return false; } - break; + } + break; case SQL_ELEMENT_RAW: + { + const char* sql = data.element.query; + ASSERT(sql); + if (!Execute(sql)) { - const char* sql = data.element.query; - ASSERT(sql); - if (!Execute(sql)) - { - sLog->outSQLDriver("[Warning] Transaction aborted. %u queries not executed.", (uint32)queries.size()); - RollbackTransaction(); - return false; - } + sLog->outSQLDriver("[Warning] Transaction aborted. %u queries not executed.", (uint32)queries.size()); + RollbackTransaction(); + return false; } - break; + } + break; } } @@ -515,27 +515,27 @@ bool MySQLConnection::_HandleMySQLErrno(uint32 errNo) #if !(MARIADB_VERSION_ID >= 100200) case CR_INVALID_CONN_HANDLE: #endif + { + m_reconnecting = true; + uint64 oldThreadId = mysql_thread_id(GetHandle()); + mysql_close(GetHandle()); + if (this->Open()) // Don't remove 'this' pointer unless you want to skip loading all prepared statements.... { - m_reconnecting = true; - uint64 oldThreadId = mysql_thread_id(GetHandle()); - mysql_close(GetHandle()); - if (this->Open()) // Don't remove 'this' pointer unless you want to skip loading all prepared statements.... - { - sLog->outSQLDriver("Connection to the MySQL server is active."); - if (oldThreadId != mysql_thread_id(GetHandle())) - sLog->outSQLDriver("Successfully reconnected to %s @%s:%s (%s).", - m_connectionInfo.database.c_str(), m_connectionInfo.host.c_str(), m_connectionInfo.port_or_socket.c_str(), - (m_connectionFlags & CONNECTION_ASYNC) ? "asynchronous" : "synchronous"); + sLog->outSQLDriver("Connection to the MySQL server is active."); + if (oldThreadId != mysql_thread_id(GetHandle())) + sLog->outSQLDriver("Successfully reconnected to %s @%s:%s (%s).", + m_connectionInfo.database.c_str(), m_connectionInfo.host.c_str(), m_connectionInfo.port_or_socket.c_str(), + (m_connectionFlags & CONNECTION_ASYNC) ? "asynchronous" : "synchronous"); - m_reconnecting = false; - return true; - } - - uint32 lErrno = mysql_errno(GetHandle()); // It's possible this attempted reconnect throws 2006 at us. To prevent crazy recursive calls, sleep here. - std::this_thread::sleep_for(3s); // Sleep 3 seconds - return _HandleMySQLErrno(lErrno); // Call self (recursive) + m_reconnecting = false; + return true; } + uint32 lErrno = mysql_errno(GetHandle()); // It's possible this attempted reconnect throws 2006 at us. To prevent crazy recursive calls, sleep here. + std::this_thread::sleep_for(3s); // Sleep 3 seconds + return _HandleMySQLErrno(lErrno); // Call self (recursive) + } + case ER_LOCK_DEADLOCK: return false; // Implemented in TransactionTask::Execute and DatabaseWorkerPool::DirectCommitTransaction // Query related errors - skip query diff --git a/src/common/Database/MySQLConnection.h b/src/common/Database/MySQLConnection.h index b78d28ebb..7f8d0ba43 100644 --- a/src/common/Database/MySQLConnection.h +++ b/src/common/Database/MySQLConnection.h @@ -51,7 +51,7 @@ struct MySQLConnectionInfo std::string port_or_socket; }; -typedef std::map > PreparedStatementMap; +typedef std::map> PreparedStatementMap; class MySQLConnection { diff --git a/src/common/Database/QueryHolder.cpp b/src/common/Database/QueryHolder.cpp index 7d0cbe277..aa17667e1 100644 --- a/src/common/Database/QueryHolder.cpp +++ b/src/common/Database/QueryHolder.cpp @@ -175,19 +175,19 @@ bool SQLQueryHolderTask::Execute() switch (data->type) { case SQL_ELEMENT_RAW: - { - char const* sql = data->element.query; - if (sql) - m_holder->SetResult(i, m_conn->Query(sql)); - break; - } + { + char const* sql = data->element.query; + if (sql) + m_holder->SetResult(i, m_conn->Query(sql)); + break; + } case SQL_ELEMENT_PREPARED: - { - PreparedStatement* stmt = data->element.stmt; - if (stmt) - m_holder->SetPreparedResult(i, m_conn->Query(stmt)); - break; - } + { + PreparedStatement* stmt = data->element.stmt; + if (stmt) + m_holder->SetPreparedResult(i, m_conn->Query(stmt)); + break; + } } } } diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/WheatyExceptionReport.cpp index e8c9644ab..40440c35a 100644 --- a/src/common/Debugging/WheatyExceptionReport.cpp +++ b/src/common/Debugging/WheatyExceptionReport.cpp @@ -271,147 +271,147 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) { // Windows NT product family. case VER_PLATFORM_WIN32_NT: - { + { #if WINVER < 0x0500 - BYTE suiteMask = osvi.wReserved[0]; - BYTE productType = osvi.wReserved[1]; + BYTE suiteMask = osvi.wReserved[0]; + BYTE productType = osvi.wReserved[1]; #else - WORD suiteMask = osvi.wSuiteMask; - BYTE productType = osvi.wProductType; + WORD suiteMask = osvi.wSuiteMask; + BYTE productType = osvi.wProductType; #endif // WINVER < 0x0500 - // Test for the specific product family. - if (osvi.dwMajorVersion == 10) + // Test for the specific product family. + if (osvi.dwMajorVersion == 10) + { + if (productType == VER_NT_WORKSTATION) + _tcsncat(szVersion, _T("Windows 10 "), cntMax); + else + _tcsncat(szVersion, _T("Windows Server 2016 "), cntMax); + } + else if (osvi.dwMajorVersion == 6) + { + if (productType == VER_NT_WORKSTATION) { - if (productType == VER_NT_WORKSTATION) - _tcsncat(szVersion, _T("Windows 10 "), cntMax); - else - _tcsncat(szVersion, _T("Windows Server 2016 "), cntMax); - } - else if (osvi.dwMajorVersion == 6) - { - if (productType == VER_NT_WORKSTATION) - { - if (osvi.dwMinorVersion == 3) - _tcsncat(szVersion, _T("Windows 8.1 "), cntMax); - else if (osvi.dwMinorVersion == 2) - _tcsncat(szVersion, _T("Windows 8 "), cntMax); - else if (osvi.dwMinorVersion == 1) - _tcsncat(szVersion, _T("Windows 7 "), cntMax); - else - _tcsncat(szVersion, _T("Windows Vista "), cntMax); - } - else if (osvi.dwMinorVersion == 3) - _tcsncat(szVersion, _T("Windows Server 2012 R2 "), cntMax); + if (osvi.dwMinorVersion == 3) + _tcsncat(szVersion, _T("Windows 8.1 "), cntMax); else if (osvi.dwMinorVersion == 2) - _tcsncat(szVersion, _T("Windows Server 2012 "), cntMax); + _tcsncat(szVersion, _T("Windows 8 "), cntMax); else if (osvi.dwMinorVersion == 1) - _tcsncat(szVersion, _T("Windows Server 2008 R2 "), cntMax); + _tcsncat(szVersion, _T("Windows 7 "), cntMax); else - _tcsncat(szVersion, _T("Windows Server 2008 "), cntMax); + _tcsncat(szVersion, _T("Windows Vista "), cntMax); } - else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) - _tcsncat(szVersion, _T("Microsoft Windows Server 2003 "), cntMax); - else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) - _tcsncat(szVersion, _T("Microsoft Windows XP "), cntMax); - else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) - _tcsncat(szVersion, _T("Microsoft Windows 2000 "), cntMax); - else if (osvi.dwMajorVersion <= 4) - _tcsncat(szVersion, _T("Microsoft Windows NT "), cntMax); + else if (osvi.dwMinorVersion == 3) + _tcsncat(szVersion, _T("Windows Server 2012 R2 "), cntMax); + else if (osvi.dwMinorVersion == 2) + _tcsncat(szVersion, _T("Windows Server 2012 "), cntMax); + else if (osvi.dwMinorVersion == 1) + _tcsncat(szVersion, _T("Windows Server 2008 R2 "), cntMax); + else + _tcsncat(szVersion, _T("Windows Server 2008 "), cntMax); + } + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) + _tcsncat(szVersion, _T("Microsoft Windows Server 2003 "), cntMax); + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) + _tcsncat(szVersion, _T("Microsoft Windows XP "), cntMax); + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) + _tcsncat(szVersion, _T("Microsoft Windows 2000 "), cntMax); + else if (osvi.dwMajorVersion <= 4) + _tcsncat(szVersion, _T("Microsoft Windows NT "), cntMax); - // Test for specific product on Windows NT 4.0 SP6 and later. - if (bVersionEx >= 0) + // Test for specific product on Windows NT 4.0 SP6 and later. + if (bVersionEx >= 0) + { + // Test for the workstation type. + if (productType == VER_NT_WORKSTATION) { - // Test for the workstation type. - if (productType == VER_NT_WORKSTATION) + if (osvi.dwMajorVersion == 4) + _tcsncat(szVersion, _T("Workstation 4.0 "), cntMax); + else if (suiteMask & VER_SUITE_PERSONAL) + _tcsncat(szVersion, _T("Home Edition "), cntMax); + else if (suiteMask & VER_SUITE_EMBEDDEDNT) + _tcsncat(szVersion, _T("Embedded "), cntMax); + else + _tcsncat(szVersion, _T("Professional "), cntMax); + } + // Test for the server type. + else if (productType == VER_NT_SERVER) + { + if (osvi.dwMajorVersion == 6 || osvi.dwMajorVersion == 10) { - if (osvi.dwMajorVersion == 4) - _tcsncat(szVersion, _T("Workstation 4.0 "), cntMax); - else if (suiteMask & VER_SUITE_PERSONAL) - _tcsncat(szVersion, _T("Home Edition "), cntMax); - else if (suiteMask & VER_SUITE_EMBEDDEDNT) - _tcsncat(szVersion, _T("Embedded "), cntMax); + if (suiteMask & VER_SUITE_SMALLBUSINESS_RESTRICTED) + _tcsncat(szVersion, _T("Essentials "), cntMax); + else if (suiteMask & VER_SUITE_DATACENTER) + _tcsncat(szVersion, _T("Datacenter "), cntMax); + else if (suiteMask & VER_SUITE_ENTERPRISE) + _tcsncat(szVersion, _T("Enterprise "), cntMax); else - _tcsncat(szVersion, _T("Professional "), cntMax); + _tcsncat(szVersion, _T("Standard "), cntMax); } - // Test for the server type. - else if (productType == VER_NT_SERVER) + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) { - if (osvi.dwMajorVersion == 6 || osvi.dwMajorVersion == 10) - { - if (suiteMask & VER_SUITE_SMALLBUSINESS_RESTRICTED) - _tcsncat(szVersion, _T("Essentials "), cntMax); - else if (suiteMask & VER_SUITE_DATACENTER) - _tcsncat(szVersion, _T("Datacenter "), cntMax); - else if (suiteMask & VER_SUITE_ENTERPRISE) - _tcsncat(szVersion, _T("Enterprise "), cntMax); - else - _tcsncat(szVersion, _T("Standard "), cntMax); - } - else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) - { - if (suiteMask & VER_SUITE_DATACENTER) - _tcsncat(szVersion, _T("Datacenter Edition "), cntMax); - else if (suiteMask & VER_SUITE_ENTERPRISE) - _tcsncat(szVersion, _T("Enterprise Edition "), cntMax); - else if (suiteMask == VER_SUITE_BLADE) - _tcsncat(szVersion, _T("Web Edition "), cntMax); - else - _tcsncat(szVersion, _T("Standard Edition "), cntMax); - } - else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) - { - if (suiteMask & VER_SUITE_DATACENTER) - _tcsncat(szVersion, _T("Datacenter Server "), cntMax); - else if (suiteMask & VER_SUITE_ENTERPRISE) - _tcsncat(szVersion, _T("Advanced Server "), cntMax); - else - _tcsncat(szVersion, _T("Server "), cntMax); - } - else // Windows NT 4.0 - { - if (suiteMask & VER_SUITE_ENTERPRISE) - _tcsncat(szVersion, _T("Server 4.0, Enterprise Edition "), cntMax); - else - _tcsncat(szVersion, _T("Server 4.0 "), cntMax); - } + if (suiteMask & VER_SUITE_DATACENTER) + _tcsncat(szVersion, _T("Datacenter Edition "), cntMax); + else if (suiteMask & VER_SUITE_ENTERPRISE) + _tcsncat(szVersion, _T("Enterprise Edition "), cntMax); + else if (suiteMask == VER_SUITE_BLADE) + _tcsncat(szVersion, _T("Web Edition "), cntMax); + else + _tcsncat(szVersion, _T("Standard Edition "), cntMax); + } + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) + { + if (suiteMask & VER_SUITE_DATACENTER) + _tcsncat(szVersion, _T("Datacenter Server "), cntMax); + else if (suiteMask & VER_SUITE_ENTERPRISE) + _tcsncat(szVersion, _T("Advanced Server "), cntMax); + else + _tcsncat(szVersion, _T("Server "), cntMax); + } + else // Windows NT 4.0 + { + if (suiteMask & VER_SUITE_ENTERPRISE) + _tcsncat(szVersion, _T("Server 4.0, Enterprise Edition "), cntMax); + else + _tcsncat(szVersion, _T("Server 4.0 "), cntMax); } } + } - // Display service pack (if any) and build number. - if (osvi.dwMajorVersion == 4 && _tcsicmp(szCSDVersion, _T("Service Pack 6")) == 0) - { - HKEY hKey; - LONG lRet; + // Display service pack (if any) and build number. + if (osvi.dwMajorVersion == 4 && _tcsicmp(szCSDVersion, _T("Service Pack 6")) == 0) + { + HKEY hKey; + LONG lRet; - // Test for SP6 versus SP6a. - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009"), 0, KEY_QUERY_VALUE, &hKey); - if (lRet == ERROR_SUCCESS) - { - _stprintf(wszTmp, _T("Service Pack 6a (Version %d.%d, Build %d)"), - osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); - _tcsncat(szVersion, wszTmp, cntMax); - } - else // Windows NT 4.0 prior to SP6a - { - _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), - szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); - _tcsncat(szVersion, wszTmp, cntMax); - } - ::RegCloseKey(hKey); - } - else // Windows NT 3.51 and earlier or Windows 2000 and later + // Test for SP6 versus SP6a. + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009"), 0, KEY_QUERY_VALUE, &hKey); + if (lRet == ERROR_SUCCESS) { - if (!_tcslen(szCSDVersion)) - _stprintf(wszTmp, _T("(Version %d.%d, Build %d)"), - osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); - else - _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), - szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + _stprintf(wszTmp, _T("Service Pack 6a (Version %d.%d, Build %d)"), + osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); _tcsncat(szVersion, wszTmp, cntMax); } - break; + else // Windows NT 4.0 prior to SP6a + { + _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), + szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + _tcsncat(szVersion, wszTmp, cntMax); + } + ::RegCloseKey(hKey); } + else // Windows NT 3.51 and earlier or Windows 2000 and later + { + if (!_tcslen(szCSDVersion)) + _stprintf(wszTmp, _T("(Version %d.%d, Build %d)"), + osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + else + _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), + szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + _tcsncat(szVersion, wszTmp, cntMax); + } + break; + } default: _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); @@ -845,8 +845,7 @@ void WheatyExceptionReport::WriteStackDetails( // The function invoked by SymEnumSymbols ////////////////////////////////////////////////////////////////////////////// -BOOL CALLBACK -WheatyExceptionReport::EnumerateSymbolsCallback( +BOOL CALLBACK WheatyExceptionReport::EnumerateSymbolsCallback( PSYMBOL_INFO pSymInfo, ULONG /*SymbolSize*/, PVOID UserContext) @@ -1295,27 +1294,27 @@ void WheatyExceptionReport::FormatOutputValue(char* pszCurrBuffer, switch (basicType) { case btChar: - { - // Special case handling for char[] type - if (countOverride != 0) - length = countOverride; - else - length = strlen((char*)pAddress); - if (length > bufferSize - 6) - pszCurrBuffer += sprintf(pszCurrBuffer, "\"%.*s...\"", (DWORD)(bufferSize - 6), (char*)pAddress); - else - pszCurrBuffer += sprintf(pszCurrBuffer, "\"%.*s\"", (DWORD)length, (char*)pAddress); - break; - } + { + // Special case handling for char[] type + if (countOverride != 0) + length = countOverride; + else + length = strlen((char*)pAddress); + if (length > bufferSize - 6) + pszCurrBuffer += sprintf(pszCurrBuffer, "\"%.*s...\"", (DWORD)(bufferSize - 6), (char*)pAddress); + else + pszCurrBuffer += sprintf(pszCurrBuffer, "\"%.*s\"", (DWORD)length, (char*)pAddress); + break; + } case btStdString: - { - std::string* value = static_cast(pAddress); - if (value->length() > bufferSize - 6) - pszCurrBuffer += sprintf(pszCurrBuffer, "\"%.*s...\"", (DWORD)(bufferSize - 6), value->c_str()); - else - pszCurrBuffer += sprintf(pszCurrBuffer, "\"%s\"", value->c_str()); - break; - } + { + std::string* value = static_cast(pAddress); + if (value->length() > bufferSize - 6) + pszCurrBuffer += sprintf(pszCurrBuffer, "\"%.*s...\"", (DWORD)(bufferSize - 6), value->c_str()); + else + pszCurrBuffer += sprintf(pszCurrBuffer, "\"%s\"", value->c_str()); + break; + } default: // Format appropriately (assuming it's a 1, 2, or 4 bytes (!!!) if (length == 1) @@ -1361,8 +1360,7 @@ void WheatyExceptionReport::FormatOutputValue(char* pszCurrBuffer, } } -BasicType -WheatyExceptionReport::GetBasicType(DWORD typeIndex, DWORD64 modBase) +BasicType WheatyExceptionReport::GetBasicType(DWORD typeIndex, DWORD64 modBase) { BasicType basicType; if (SymGetTypeInfo(m_hProcess, modBase, typeIndex, diff --git a/src/common/Dynamic/LinkedList.h b/src/common/Dynamic/LinkedList.h index 02e179c6f..b5324875f 100644 --- a/src/common/Dynamic/LinkedList.h +++ b/src/common/Dynamic/LinkedList.h @@ -24,9 +24,9 @@ public: LinkedListElement(): iNext(NULL), iPrev(NULL) { } ~LinkedListElement() { delink(); } - bool hasNext() const { return(iNext && iNext->iNext != NULL); } - bool hasPrev() const { return(iPrev && iPrev->iPrev != NULL); } - bool isInList() const { return(iNext != NULL && iPrev != NULL); } + bool hasNext() const { return (iNext && iNext->iNext != NULL); } + bool hasPrev() const { return (iPrev && iPrev->iPrev != NULL); } + bool isInList() const { return (iNext != NULL && iPrev != NULL); } LinkedListElement* next() { return hasNext() ? iNext : NULL; } LinkedListElement const* next() const { return hasNext() ? iNext : NULL; } @@ -83,13 +83,13 @@ public: iLast.iPrev = &iFirst; } - bool isEmpty() const { return(!iFirst.iNext->isInList()); } + bool isEmpty() const { return (!iFirst.iNext->isInList()); } - LinkedListElement* getFirst() { return(isEmpty() ? NULL : iFirst.iNext); } - LinkedListElement const* getFirst() const { return(isEmpty() ? NULL : iFirst.iNext); } + LinkedListElement* getFirst() { return (isEmpty() ? NULL : iFirst.iNext); } + LinkedListElement const* getFirst() const { return (isEmpty() ? NULL : iFirst.iNext); } - LinkedListElement* getLast() { return(isEmpty() ? NULL : iLast.iPrev); } - LinkedListElement const* getLast() const { return(isEmpty() ? NULL : iLast.iPrev); } + LinkedListElement* getLast() { return (isEmpty() ? NULL : iLast.iPrev); } + LinkedListElement const* getLast() const { return (isEmpty() ? NULL : iLast.iPrev); } void insertFirst(LinkedListElement* pElem) { diff --git a/src/common/Dynamic/LinkedReference/RefManager.h b/src/common/Dynamic/LinkedReference/RefManager.h index a112b9dbf..8f9ab3f10 100644 --- a/src/common/Dynamic/LinkedReference/RefManager.h +++ b/src/common/Dynamic/LinkedReference/RefManager.h @@ -14,7 +14,7 @@ template class RefManager : public LinkedListHead { public: - typedef LinkedListHead::Iterator< Reference > iterator; + typedef LinkedListHead::Iterator< Reference> iterator; RefManager() { } virtual ~RefManager() { clearReferences(); } diff --git a/src/common/Dynamic/LinkedReference/Reference.h b/src/common/Dynamic/LinkedReference/Reference.h index 644a4ff7a..99e221aaa 100644 --- a/src/common/Dynamic/LinkedReference/Reference.h +++ b/src/common/Dynamic/LinkedReference/Reference.h @@ -68,15 +68,15 @@ public: return iRefTo != NULL; } - Reference* next() { return((Reference*) LinkedListElement::next()); } - Reference const* next() const { return((Reference const*) LinkedListElement::next()); } - Reference* prev() { return((Reference*) LinkedListElement::prev()); } - Reference const* prev() const { return((Reference const*) LinkedListElement::prev()); } + Reference* next() { return ((Reference*) LinkedListElement::next()); } + Reference const* next() const { return ((Reference const*) LinkedListElement::next()); } + Reference* prev() { return ((Reference*) LinkedListElement::prev()); } + Reference const* prev() const { return ((Reference const*) LinkedListElement::prev()); } - Reference* nocheck_next() { return((Reference*) LinkedListElement::nocheck_next()); } - Reference const* nocheck_next() const { return((Reference const*) LinkedListElement::nocheck_next()); } - Reference* nocheck_prev() { return((Reference*) LinkedListElement::nocheck_prev()); } - Reference const* nocheck_prev() const { return((Reference const*) LinkedListElement::nocheck_prev()); } + Reference* nocheck_next() { return ((Reference*) LinkedListElement::nocheck_next()); } + Reference const* nocheck_next() const { return ((Reference const*) LinkedListElement::nocheck_next()); } + Reference* nocheck_prev() { return ((Reference*) LinkedListElement::nocheck_prev()); } + Reference const* nocheck_prev() const { return ((Reference const*) LinkedListElement::nocheck_prev()); } TO* operator ->() const { return iRefTo; } TO* getTarget() const { return iRefTo; } diff --git a/src/common/Dynamic/ObjectRegistry.h b/src/common/Dynamic/ObjectRegistry.h index 429d4ba0f..ba7451318 100644 --- a/src/common/Dynamic/ObjectRegistry.h +++ b/src/common/Dynamic/ObjectRegistry.h @@ -25,7 +25,7 @@ public: const T* GetRegistryItem(Key key) const { typename RegistryMapType::const_iterator iter = i_registeredObjects.find(key); - return( iter == i_registeredObjects.end() ? NULL : iter->second ); + return ( iter == i_registeredObjects.end() ? NULL : iter->second ); } static ObjectRegistry* instance() diff --git a/src/common/Dynamic/TypeContainer.h b/src/common/Dynamic/TypeContainer.h index 36652b9b5..f179a2a9a 100644 --- a/src/common/Dynamic/TypeContainer.h +++ b/src/common/Dynamic/TypeContainer.h @@ -32,7 +32,7 @@ template struct ContainerMapList template<> struct ContainerMapList /* nothing is in type null */ { }; -template struct ContainerMapList > +template struct ContainerMapList> { ContainerMapList _elements; ContainerMapList _TailElements; @@ -50,7 +50,7 @@ template struct ContainerArrayList // termination condition template<> struct ContainerArrayList { }; // recursion -template struct ContainerArrayList > +template struct ContainerArrayList> { ContainerArrayList _elements; ContainerArrayList _TailElements; @@ -67,7 +67,7 @@ template struct ContainerList /* TypeNull is underfined */ template<> struct ContainerList { }; -template struct ContainerList > +template struct ContainerList> { ContainerList _elements; ContainerMapList _TailElements; diff --git a/src/common/Dynamic/TypeContainerFunctions.h b/src/common/Dynamic/TypeContainerFunctions.h index 99ce0bb7b..59dd84014 100644 --- a/src/common/Dynamic/TypeContainerFunctions.h +++ b/src/common/Dynamic/TypeContainerFunctions.h @@ -36,12 +36,12 @@ namespace acore return 0; } - template size_t Count(const ContainerMapList >& elements, SPECIFIC_TYPE* fake) + template size_t Count(const ContainerMapList>& elements, SPECIFIC_TYPE* fake) { return Count(elements._elements, fake); } - template size_t Count(const ContainerMapList >& elements, SPECIFIC_TYPE* fake) + template size_t Count(const ContainerMapList>& elements, SPECIFIC_TYPE* fake) { return Count(elements._TailElements, fake); } @@ -66,7 +66,7 @@ namespace acore } // Recursion - template SPECIFIC_TYPE* Insert(ContainerMapList >& elements, SPECIFIC_TYPE* obj) + template SPECIFIC_TYPE* Insert(ContainerMapList>& elements, SPECIFIC_TYPE* obj) { SPECIFIC_TYPE* t = Insert(elements._elements, obj); return (t != NULL ? t : Insert(elements._TailElements, obj)); diff --git a/src/common/Dynamic/TypeContainerFunctionsPtr.h b/src/common/Dynamic/TypeContainerFunctionsPtr.h index fd7347156..a0722d507 100644 --- a/src/common/Dynamic/TypeContainerFunctionsPtr.h +++ b/src/common/Dynamic/TypeContainerFunctionsPtr.h @@ -49,7 +49,7 @@ namespace acore // non-const find functions template CountedPtr& Find(ContainerMapList& elements, OBJECT_HANDLE hdl, CountedPtr* /*fake*/) { - typename std::map >::iterator iter = elements._element.find(hdl); + typename std::map>::iterator iter = elements._element.find(hdl); return (iter == elements._element.end() ? NullPtr((SPECIFIC_TYPE*)NULL) : iter->second); }; @@ -63,7 +63,7 @@ namespace acore return NullPtr((SPECIFIC_TYPE*)NULL);// this is a missed } - template CountedPtr& Find(ContainerMapList >& elements, OBJECT_HANDLE hdl, CountedPtr* fake) + template CountedPtr& Find(ContainerMapList>& elements, OBJECT_HANDLE hdl, CountedPtr* fake) { CountedPtr& t = Find(elements._elements, hdl, fake); return (!t ? Find(elements._TailElements, hdl, fake) : t); @@ -86,7 +86,7 @@ namespace acore return NullPtr((SPECIFIC_TYPE*)NULL); } - template CountedPtr& Find(const ContainerMapList >& elements, OBJECT_HANDLE hdl, CountedPtr* fake) + template CountedPtr& Find(const ContainerMapList>& elements, OBJECT_HANDLE hdl, CountedPtr* fake) { CountedPtr& t = Find(elements._elements, hdl, fake); if (!t) @@ -114,7 +114,7 @@ namespace acore } // Recursion - template CountedPtr& Insert(ContainerMapList >& elements, CountedPtr& obj, OBJECT_HANDLE hdl) + template CountedPtr& Insert(ContainerMapList>& elements, CountedPtr& obj, OBJECT_HANDLE hdl) { CountedPtr& t = Insert(elements._elements, obj, hdl); return (!t ? Insert(elements._TailElements, obj, hdl) : t); @@ -123,7 +123,7 @@ namespace acore // non-const remove method template bool Remove(ContainerMapList& elements, CountedPtr& obj, OBJECT_HANDLE hdl) { - typename std::map >::iterator iter = elements._element.find(hdl); + typename std::map>::iterator iter = elements._element.find(hdl); if ( iter != elements._element.end() ) { elements._element.erase(iter); @@ -144,7 +144,7 @@ namespace acore return false; } - template bool Remove(ContainerMapList >& elements, CountedPtr& obj, OBJECT_HANDLE hdl) + template bool Remove(ContainerMapList>& elements, CountedPtr& obj, OBJECT_HANDLE hdl) { // The head element is bad bool t = Remove(elements._elements, obj, hdl); diff --git a/src/common/Dynamic/TypeContainerVisitor.h b/src/common/Dynamic/TypeContainerVisitor.h index 13629cdc8..0c4fc850d 100644 --- a/src/common/Dynamic/TypeContainerVisitor.h +++ b/src/common/Dynamic/TypeContainerVisitor.h @@ -34,7 +34,7 @@ template void VisitorHelper(VISITOR& v, ContainerList } // recursion for container list -template void VisitorHelper(VISITOR& v, ContainerList >& c) +template void VisitorHelper(VISITOR& v, ContainerList>& c) { VisitorHelper(v, c._elements); VisitorHelper(v, c._TailElements); @@ -49,7 +49,7 @@ template void VisitorHelper(VISITOR& v, ContainerMapList } // recursion container map list -template void VisitorHelper(VISITOR& v, ContainerMapList >& c) +template void VisitorHelper(VISITOR& v, ContainerMapList>& c) { VisitorHelper(v, c._elements); VisitorHelper(v, c._TailElements); @@ -64,7 +64,7 @@ template void VisitorHelper(VISITOR& v, ContainerArrayLi template void VisitorHelper(VISITOR& /*v*/, ContainerArrayList& /*c*/) { } // recursion -template void VisitorHelper(VISITOR& v, ContainerArrayList >& c) +template void VisitorHelper(VISITOR& v, ContainerArrayList>& c) { VisitorHelper(v, c._elements); VisitorHelper(v, c._TailElements); diff --git a/src/common/Logging/Log.cpp b/src/common/Logging/Log.cpp index af8198bab..2f1d0b41c 100644 --- a/src/common/Logging/Log.cpp +++ b/src/common/Logging/Log.cpp @@ -360,7 +360,7 @@ std::string Log::GetTimestampStr() void Log::outDB(LogTypes type, const char* str) { - if(!str || std::string(str).empty() || type >= MAX_LOG_TYPES) + if (!str || std::string(str).empty() || type >= MAX_LOG_TYPES) return; std::string new_str(str); diff --git a/src/common/Threading/LockedQueue.h b/src/common/Threading/LockedQueue.h index ea6731327..14f250f06 100644 --- a/src/common/Threading/LockedQueue.h +++ b/src/common/Threading/LockedQueue.h @@ -15,7 +15,7 @@ namespace ACE_Based { - template > + template > class LockedQueue { //! Lock access to the queue. diff --git a/src/common/Utilities/EventProcessor.cpp b/src/common/Utilities/EventProcessor.cpp index 415f0203c..2f21e9e93 100644 --- a/src/common/Utilities/EventProcessor.cpp +++ b/src/common/Utilities/EventProcessor.cpp @@ -82,7 +82,7 @@ void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime uint64 EventProcessor::CalculateTime(uint64 t_offset) const { - return(m_time + t_offset); + return (m_time + t_offset); } uint64 EventProcessor::CalculateQueueTime(uint64 delay) const diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index 9175071e7..726e5c4e1 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -360,7 +360,7 @@ size_t utf8length(std::string& utf8str) { return utf8::distance(utf8str.c_str(), utf8str.c_str() + utf8str.size()); } - catch(std::exception const&) + catch (std::exception const&) { utf8str.clear(); return 0; @@ -382,7 +382,7 @@ void utf8truncate(std::string& utf8str, size_t len) char* oend = utf8::utf16to8(wstr.c_str(), wstr.c_str() + wstr.size(), &utf8str[0]); utf8str.resize(oend - (&utf8str[0])); // remove unused tail } - catch(std::exception const&) + catch (std::exception const&) { utf8str.clear(); } @@ -397,7 +397,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize) wsize -= out.remaining(); // remaining unused space wstr[wsize] = L'\0'; } - catch(std::exception const&) + catch (std::exception const&) { // Replace the converted string with an error message if there is enough space // Otherwise just return an empty string @@ -429,7 +429,7 @@ bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr) { utf8::utf8to16(utf8str.c_str(), utf8str.c_str() + utf8str.size(), std::back_inserter(wstr)); } - catch(std::exception const&) + catch (std::exception const&) { wstr.clear(); return false; @@ -452,7 +452,7 @@ bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str) } utf8str = utf8str2; } - catch(std::exception const&) + catch (std::exception const&) { utf8str.clear(); return false; @@ -475,7 +475,7 @@ bool WStrToUtf8(std::wstring const& wstr, std::string& utf8str) } utf8str = utf8str2; } - catch(std::exception const&) + catch (std::exception const&) { utf8str.clear(); return false; diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h index 1c8417b89..852f0d57b 100644 --- a/src/common/Utilities/Util.h +++ b/src/common/Utilities/Util.h @@ -18,7 +18,7 @@ #include #include - // Searcher for map of structs +// Searcher for map of structs template struct Finder { T val_; @@ -440,7 +440,7 @@ public: part[0] == right.part[0] && part[1] == right.part[1] && part[2] == right.part[2] - ); + ); } inline bool operator!=(flag96 const& right) const @@ -541,20 +541,20 @@ bool CompareValues(ComparisionType type, T val1, T val2) { switch (type) { - case COMP_TYPE_EQ: - return val1 == val2; - case COMP_TYPE_HIGH: - return val1 > val2; - case COMP_TYPE_LOW: - return val1 < val2; - case COMP_TYPE_HIGH_EQ: - return val1 >= val2; - case COMP_TYPE_LOW_EQ: - return val1 <= val2; - default: - // incorrect parameter - ABORT(); - return false; + case COMP_TYPE_EQ: + return val1 == val2; + case COMP_TYPE_HIGH: + return val1 > val2; + case COMP_TYPE_LOW: + return val1 < val2; + case COMP_TYPE_HIGH_EQ: + return val1 >= val2; + case COMP_TYPE_LOW_EQ: + return val1 <= val2; + default: + // incorrect parameter + ABORT(); + return false; } }