diff options
author | Francesco Borzì <borzifrancesco@gmail.com> | 2021-08-26 18:02:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-26 18:02:08 +0200 |
commit | d8b8e123f66eb2d4ae2f3dd3f4cd5d9b5f97bf14 (patch) | |
tree | 7b39b05e07db2138182ee583dfe0a32569d206ef | |
parent | 5bb2e5f2f9971cbbe2f85063042d258015ecf2b3 (diff) |
refactor(Core/Common): code cleanup (part 12) (#7520)
-rw-r--r-- | src/common/Collision/Management/IMMAPManager.h | 2 | ||||
-rw-r--r-- | src/common/Collision/Management/MMapManager.cpp | 20 | ||||
-rw-r--r-- | src/common/Collision/Management/VMapManager2.cpp | 3 | ||||
-rw-r--r-- | src/common/Collision/Management/VMapManager2.h | 16 | ||||
-rw-r--r-- | src/common/Collision/Models/ModelInstance.cpp | 1 | ||||
-rw-r--r-- | src/common/Collision/Models/ModelInstance.h | 2 | ||||
-rw-r--r-- | src/common/Collision/Models/WorldModel.cpp | 13 | ||||
-rw-r--r-- | src/common/Cryptography/BigNumber.cpp | 1 | ||||
-rw-r--r-- | src/common/Cryptography/OpenSSLCrypto.cpp | 1 | ||||
-rw-r--r-- | src/common/Cryptography/TOTP.cpp | 1 | ||||
-rw-r--r-- | src/common/IPLocation/IPLocation.cpp | 1 | ||||
-rw-r--r-- | src/common/Logging/AppenderConsole.cpp | 1 | ||||
-rw-r--r-- | src/common/Logging/Log.cpp | 7 | ||||
-rw-r--r-- | src/common/Utilities/StartProcess.cpp | 8 | ||||
-rw-r--r-- | src/common/Utilities/Util.cpp | 6 |
15 files changed, 27 insertions, 56 deletions
diff --git a/src/common/Collision/Management/IMMAPManager.h b/src/common/Collision/Management/IMMAPManager.h index 197851206c..00f6420110 100644 --- a/src/common/Collision/Management/IMMAPManager.h +++ b/src/common/Collision/Management/IMMAPManager.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016+ AzerothCore <www.azerothcore.org> + * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/> * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> */ diff --git a/src/common/Collision/Management/MMapManager.cpp b/src/common/Collision/Management/MMapManager.cpp index 417447e2cd..9bbbad28a4 100644 --- a/src/common/Collision/Management/MMapManager.cpp +++ b/src/common/Collision/Management/MMapManager.cpp @@ -185,13 +185,9 @@ namespace MMAP LOG_DEBUG("maps", "MMAP:loadMap: Loaded mmtile %03i[%02i,%02i] into %03i[%02i,%02i]", mapId, x, y, mapId, header->x, header->y); return true; } - else - { - LOG_ERROR("maps", "MMAP:loadMap: Could not load %03u%02i%02i.mmtile into navmesh", mapId, x, y); - dtFree(data); - return false; - } + LOG_ERROR("maps", "MMAP:loadMap: Could not load %03u%02i%02i.mmtile into navmesh", mapId, x, y); + dtFree(data); return false; } @@ -228,15 +224,11 @@ namespace MMAP LOG_ERROR("maps", "MMAP:unloadMap: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y); ABORT(); } - else - { - mmap->loadedTileRefs.erase(packedGridPos); - --loadedTiles; - LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile %03i[%02i,%02i] from %03i", mapId, x, y, mapId); - return true; - } - return false; + mmap->loadedTileRefs.erase(packedGridPos); + --loadedTiles; + LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile %03i[%02i,%02i] from %03i", mapId, x, y, mapId); + return true; } bool MMapManager::unloadMap(uint32 mapId) diff --git a/src/common/Collision/Management/VMapManager2.cpp b/src/common/Collision/Management/VMapManager2.cpp index 11a1dbe665..3cea89bf25 100644 --- a/src/common/Collision/Management/VMapManager2.cpp +++ b/src/common/Collision/Management/VMapManager2.cpp @@ -21,7 +21,6 @@ #include "MapDefines.h" #include "MapTree.h" #include "ModelInstance.h" -#include "VMapDefinitions.h" #include "WorldModel.h" #include <G3D/Vector3.h> #include <iomanip> @@ -243,7 +242,7 @@ namespace VMAP { Vector3 pos = convertPositionToInternalRep(x, y, z); float height = instanceTree->second->getHeight(pos, maxSearchDist); - if (!(height < G3D::finf())) + if (height >= G3D::finf()) { return height = VMAP_INVALID_HEIGHT_VALUE; // No height } diff --git a/src/common/Collision/Management/VMapManager2.h b/src/common/Collision/Management/VMapManager2.h index 4fd65a7e20..0e3fc2f9a1 100644 --- a/src/common/Collision/Management/VMapManager2.h +++ b/src/common/Collision/Management/VMapManager2.h @@ -1,18 +1,5 @@ /* - * Copyright (C) 2016+ AzerothCore <www.azerothcore.org> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 */ #ifndef _VMAPMANAGER2_H @@ -56,7 +43,6 @@ namespace VMAP ManagedModel() { } void setModel(WorldModel* model) { iModel = model; } WorldModel* getModel() { return iModel; } - void incRefCount() { ++iRefCount; } int decRefCount() { return --iRefCount; } protected: WorldModel* iModel{nullptr}; diff --git a/src/common/Collision/Models/ModelInstance.cpp b/src/common/Collision/Models/ModelInstance.cpp index 01e2219cd6..fa46242f03 100644 --- a/src/common/Collision/Models/ModelInstance.cpp +++ b/src/common/Collision/Models/ModelInstance.cpp @@ -6,7 +6,6 @@ #include "ModelInstance.h" #include "MapTree.h" -#include "VMapDefinitions.h" #include "WorldModel.h" using G3D::Vector3; diff --git a/src/common/Collision/Models/ModelInstance.h b/src/common/Collision/Models/ModelInstance.h index 35583ec870..a06baa9f8a 100644 --- a/src/common/Collision/Models/ModelInstance.h +++ b/src/common/Collision/Models/ModelInstance.h @@ -65,4 +65,4 @@ namespace VMAP }; } // namespace VMAP -#endif // _MODELINSTANCE +#endif // _MODELINSTANCE_H_ diff --git a/src/common/Collision/Models/WorldModel.cpp b/src/common/Collision/Models/WorldModel.cpp index 7f974a00e4..4a78fc8df2 100644 --- a/src/common/Collision/Models/WorldModel.cpp +++ b/src/common/Collision/Models/WorldModel.cpp @@ -160,7 +160,7 @@ namespace VMAP // check if tile shall be used for liquid level // checking for 0x08 *might* be enough, but disabled tiles always are 0x?F: - if ((iFlags[tx + ty * iTilesX] & 0x0F) == 0x0F) + if (iFlags && (iFlags[tx + ty * iTilesX] & 0x0F) == 0x0F) { return false; } @@ -182,6 +182,11 @@ namespace VMAP 0 1 */ + if (!iHeight) + { + return false; + } + const uint32 rowOffset = iTilesX + 1; if (dx > dy) // case (a) { @@ -289,7 +294,7 @@ namespace VMAP bool result = true; uint32 chunkSize, count; - if (result && fwrite(&iBound, sizeof(G3D::AABox), 1, wf) != 1) { result = false; } + if (fwrite(&iBound, sizeof(G3D::AABox), 1, wf) != 1) { result = false; } if (result && fwrite(&iMogpFlags, sizeof(uint32), 1, wf) != 1) { result = false; } if (result && fwrite(&iGroupWMOID, sizeof(uint32), 1, wf) != 1) { result = false; } @@ -343,7 +348,7 @@ namespace VMAP delete iLiquid; iLiquid = nullptr; - if (result && fread(&iBound, sizeof(G3D::AABox), 1, rf) != 1) { result = false; } + if (fread(&iBound, sizeof(G3D::AABox), 1, rf) != 1) { result = false; } if (result && fread(&iMogpFlags, sizeof(uint32), 1, rf) != 1) { result = false; } if (result && fread(&iGroupWMOID, sizeof(uint32), 1, rf) != 1) { result = false; } @@ -621,7 +626,7 @@ namespace VMAP { //if (fread(&chunkSize, sizeof(uint32), 1, rf) != 1) result = false; - if (result && fread(&count, sizeof(uint32), 1, rf) != 1) { result = false; } + if (fread(&count, sizeof(uint32), 1, rf) != 1) { result = false; } if (result) { groupModels.resize(count); } //if (result && fread(&groupModels[0], sizeof(GroupModel), count, rf) != count) result = false; for (uint32 i = 0; i < count && result; ++i) diff --git a/src/common/Cryptography/BigNumber.cpp b/src/common/Cryptography/BigNumber.cpp index 53cfcd177a..d8079b861d 100644 --- a/src/common/Cryptography/BigNumber.cpp +++ b/src/common/Cryptography/BigNumber.cpp @@ -6,7 +6,6 @@ #include "Cryptography/BigNumber.h" #include "Errors.h" #include <algorithm> -#include <cstring> #include <memory> #include <openssl/bn.h> diff --git a/src/common/Cryptography/OpenSSLCrypto.cpp b/src/common/Cryptography/OpenSSLCrypto.cpp index 5303f98ff7..f732449f22 100644 --- a/src/common/Cryptography/OpenSSLCrypto.cpp +++ b/src/common/Cryptography/OpenSSLCrypto.cpp @@ -5,7 +5,6 @@ */ #include <OpenSSLCrypto.h> -#include <openssl/crypto.h> #if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1010000fL #include <vector> diff --git a/src/common/Cryptography/TOTP.cpp b/src/common/Cryptography/TOTP.cpp index 1f1628fe45..d1f66b99d5 100644 --- a/src/common/Cryptography/TOTP.cpp +++ b/src/common/Cryptography/TOTP.cpp @@ -4,7 +4,6 @@ */ #include "TOTP.h" -#include <cstring> #include <openssl/evp.h> #include <openssl/hmac.h> diff --git a/src/common/IPLocation/IPLocation.cpp b/src/common/IPLocation/IPLocation.cpp index 2ceada74ab..c1f70c8835 100644 --- a/src/common/IPLocation/IPLocation.cpp +++ b/src/common/IPLocation/IPLocation.cpp @@ -4,7 +4,6 @@ */ #include "IPLocation.h" -#include "Common.h" #include "Config.h" #include "Errors.h" #include "IpAddress.h" diff --git a/src/common/Logging/AppenderConsole.cpp b/src/common/Logging/AppenderConsole.cpp index f8dacf67c1..cab78c19f0 100644 --- a/src/common/Logging/AppenderConsole.cpp +++ b/src/common/Logging/AppenderConsole.cpp @@ -10,7 +10,6 @@ #include "StringFormat.h" #include "Tokenize.h" #include "Util.h" -#include <sstream> #if AC_PLATFORM == AC_PLATFORM_WINDOWS #include <Windows.h> diff --git a/src/common/Logging/Log.cpp b/src/common/Logging/Log.cpp index 665851e34b..db049c3600 100644 --- a/src/common/Logging/Log.cpp +++ b/src/common/Logging/Log.cpp @@ -6,7 +6,6 @@ #include "Log.h" #include "AppenderConsole.h" #include "AppenderFile.h" -#include "Common.h" #include "Config.h" #include "Errors.h" #include "LogMessage.h" @@ -158,16 +157,16 @@ void Log::CreateLoggerFromConfig(std::string const& appenderName) logger = std::make_unique<Logger>(name, level); //fprintf(stdout, "Log::CreateLoggerFromConfig: Created Logger %s, Level %u\n", name.c_str(), level); - for (std::string_view appenderName : Acore::Tokenize(tokens[1], ' ', false)) + for (std::string_view appendName : Acore::Tokenize(tokens[1], ' ', false)) { - if (Appender* appender = GetAppenderByName(appenderName)) + if (Appender* appender = GetAppenderByName(appendName)) { logger->addAppender(appender->getId(), appender); //fprintf(stdout, "Log::CreateLoggerFromConfig: Added Appender %s to Logger %s\n", appender->getName().c_str(), name.c_str()); } else { - fprintf(stderr, "Error while configuring Appender %s in Logger %s. Appender does not exist\n", std::string(appenderName).c_str(), name.c_str()); + fprintf(stderr, "Error while configuring Appender %s in Logger %s. Appender does not exist\n", std::string(appendName).c_str(), name.c_str()); } } } diff --git a/src/common/Utilities/StartProcess.cpp b/src/common/Utilities/StartProcess.cpp index 53c25bf382..e867aefe00 100644 --- a/src/common/Utilities/StartProcess.cpp +++ b/src/common/Utilities/StartProcess.cpp @@ -182,21 +182,21 @@ namespace Acore return CreateChildProcess([&](child& c) -> int { - int result; + int exitCode; my_child = std::reference_wrapper<child>(c); try { c.wait(); - result = c.exit_code(); + exitCode = c.exit_code(); } catch (...) { - result = EXIT_FAILURE; + exitCode = EXIT_FAILURE; } my_child.reset(); - return was_terminated ? EXIT_FAILURE : result; + return was_terminated ? EXIT_FAILURE : exitCode; }, executable, args, logger, input_file, is_secure); } diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index 5628323251..8ae33a8175 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -8,7 +8,6 @@ #include "Common.h" #include "Containers.h" #include "IpAddress.h" -#include "StringConvert.h" #include "StringFormat.h" #include <algorithm> #include <cctype> @@ -17,9 +16,6 @@ #include <iomanip> #include <sstream> #include <string> -#include <cctype> -#include <cstdarg> -#include <ctime> #include <utf8.h> Tokenizer::Tokenizer(const std::string& src, const char sep, uint32 vectorReserve) @@ -518,7 +514,7 @@ std::wstring GetMainPartOfName(std::wstring const& wname, uint32 declension) { std::wstring const& ending = **itr; std::size_t const endLen = ending.length(); - if (!(endLen <= thisLen)) + if (endLen > thisLen) { continue; } |