diff options
Diffstat (limited to 'src/common')
34 files changed, 259 insertions, 176 deletions
diff --git a/src/common/Collision/BoundingIntervalHierarchy.h b/src/common/Collision/BoundingIntervalHierarchy.h index dedcba64307..2f73967f09d 100644 --- a/src/common/Collision/BoundingIntervalHierarchy.h +++ b/src/common/Collision/BoundingIntervalHierarchy.h @@ -79,8 +79,8 @@ class TC_COMMON_API BIH } public: BIH() { init_empty(); } - template< class BoundsFunc, class PrimArray > - void build(const PrimArray &primitives, BoundsFunc &getBounds, uint32 leafSize = 3, bool printStats=false) + template <class BoundsFunc, class PrimArray> + void build(PrimArray const& primitives, BoundsFunc& getBounds, uint32 leafSize = 3, bool printStats = false) { if (primitives.size() == 0) { @@ -117,7 +117,7 @@ class TC_COMMON_API BIH uint32 primCount() const { return uint32(objects.size()); } template<typename RayCallback> - void intersectRay(const G3D::Ray &r, RayCallback& intersectCallback, float &maxDist, bool stopAtFirst=false) const + void intersectRay(const G3D::Ray &r, RayCallback& intersectCallback, float &maxDist, bool stopAtFirst = false) const { float intervalMin = -1.f; float intervalMax = -1.f; diff --git a/src/common/Collision/DynamicTree.cpp b/src/common/Collision/DynamicTree.cpp index b1f03aace13..5111ba7afa0 100644 --- a/src/common/Collision/DynamicTree.cpp +++ b/src/common/Collision/DynamicTree.cpp @@ -40,20 +40,20 @@ int CHECK_TREE_PERIOD = 200; } // namespace template<> struct HashTrait< GameObjectModel>{ - static size_t hashCode(const GameObjectModel& g) { return (size_t)(void*)&g; } + static size_t hashCode(GameObjectModel const& g) { return (size_t)(void*)&g; } }; template<> struct PositionTrait< GameObjectModel> { - static void getPosition(const GameObjectModel& g, G3D::Vector3& p) { p = g.getPosition(); } + static void getPosition(GameObjectModel const& g, G3D::Vector3& p) { p = g.getPosition(); } }; template<> struct BoundsTrait< GameObjectModel> { - static void getBounds(const GameObjectModel& g, G3D::AABox& out) { out = g.getBounds();} - static void getBounds2(const GameObjectModel* g, G3D::AABox& out) { out = g->getBounds();} + static void getBounds(GameObjectModel const& g, G3D::AABox& out) { out = g.getBounds();} + static void getBounds2(GameObjectModel const* g, G3D::AABox& out) { out = g->getBounds();} }; /* -static bool operator == (const GameObjectModel& mdl, const GameObjectModel& mdl2){ +static bool operator==(GameObjectModel const& mdl, GameObjectModel const& mdl2){ return &mdl == &mdl2; } */ @@ -71,13 +71,13 @@ struct DynTreeImpl : public ParentTree/*, public Intersectable*/ { } - void insert(const Model& mdl) + void insert(Model const& mdl) { base::insert(mdl); ++unbalanced_times; } - void remove(const Model& mdl) + void remove(Model const& mdl) { base::remove(mdl); ++unbalanced_times; @@ -114,17 +114,17 @@ DynamicMapTree::~DynamicMapTree() delete impl; } -void DynamicMapTree::insert(const GameObjectModel& mdl) +void DynamicMapTree::insert(GameObjectModel const& mdl) { impl->insert(mdl); } -void DynamicMapTree::remove(const GameObjectModel& mdl) +void DynamicMapTree::remove(GameObjectModel const& mdl) { impl->remove(mdl); } -bool DynamicMapTree::contains(const GameObjectModel& mdl) const +bool DynamicMapTree::contains(GameObjectModel const& mdl) const { return impl->contains(mdl); } diff --git a/src/common/Collision/DynamicTree.h b/src/common/Collision/DynamicTree.h index 5581702a504..6ddbb33c221 100644 --- a/src/common/Collision/DynamicTree.h +++ b/src/common/Collision/DynamicTree.h @@ -53,9 +53,9 @@ public: bool getAreaInfo(float x, float y, float& z, PhaseShift const& phaseShift, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const; void getAreaAndLiquidData(float x, float y, float z, PhaseShift const& phaseShift, uint8 reqLiquidType, VMAP::AreaAndLiquidData& data) const; - void insert(const GameObjectModel&); - void remove(const GameObjectModel&); - bool contains(const GameObjectModel&) const; + void insert(GameObjectModel const&); + void remove(GameObjectModel const&); + bool contains(GameObjectModel const&) const; void balance(); void update(uint32 diff); diff --git a/src/common/Collision/Management/IVMapManager.h b/src/common/Collision/Management/IVMapManager.h index 87c084f7f8c..3d760082e28 100644 --- a/src/common/Collision/Management/IVMapManager.h +++ b/src/common/Collision/Management/IVMapManager.h @@ -18,10 +18,10 @@ #ifndef _IVMAPMANAGER_H #define _IVMAPMANAGER_H -#include <string> #include "Define.h" #include "ModelIgnoreFlags.h" #include "Optional.h" +#include <string> //=========================================================== @@ -82,9 +82,9 @@ namespace VMAP virtual ~IVMapManager(void) { } - virtual int loadMap(const char* pBasePath, unsigned int pMapId, int x, int y) = 0; + virtual int loadMap(char const* pBasePath, unsigned int pMapId, int x, int y) = 0; - virtual LoadResult existsMap(const char* pBasePath, unsigned int pMapId, int x, int y) = 0; + virtual LoadResult existsMap(char const* pBasePath, unsigned int pMapId, int x, int y) = 0; virtual void unloadMap(unsigned int pMapId, int x, int y) = 0; virtual void unloadMap(unsigned int pMapId) = 0; diff --git a/src/common/Collision/Management/VMapManager2.cpp b/src/common/Collision/Management/VMapManager2.cpp index 428ae6ba146..88494d0a0c7 100644 --- a/src/common/Collision/Management/VMapManager2.cpp +++ b/src/common/Collision/Management/VMapManager2.cpp @@ -99,7 +99,7 @@ namespace VMAP return fname.str(); } - int VMapManager2::loadMap(const char* basePath, unsigned int mapId, int x, int y) + int VMapManager2::loadMap(char const* basePath, unsigned int mapId, int x, int y) { int result = VMAP_LOAD_RESULT_IGNORED; if (isMapLoadingEnabled()) @@ -387,7 +387,7 @@ namespace VMAP } } - LoadResult VMapManager2::existsMap(const char* basePath, unsigned int mapId, int x, int y) + LoadResult VMapManager2::existsMap(char const* basePath, unsigned int mapId, int x, int y) { return StaticMapTree::CanLoadMap(std::string(basePath), mapId, x, y, this); } diff --git a/src/common/Collision/Management/VMapManager2.h b/src/common/Collision/Management/VMapManager2.h index f16038264dc..76253faded4 100644 --- a/src/common/Collision/Management/VMapManager2.h +++ b/src/common/Collision/Management/VMapManager2.h @@ -101,7 +101,7 @@ namespace VMAP void InitializeThreadUnsafe(std::unordered_map<uint32, std::vector<uint32>> const& mapData); - int loadMap(const char* pBasePath, unsigned int mapId, int x, int y) override; + int loadMap(char const* pBasePath, unsigned int mapId, int x, int y) override; bool loadSingleMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY); void unloadMap(unsigned int mapId, int x, int y) override; @@ -131,7 +131,7 @@ namespace VMAP { return getMapFileName(mapId); } - virtual LoadResult existsMap(const char* basePath, unsigned int mapId, int x, int y) override; + virtual LoadResult existsMap(char const* basePath, unsigned int mapId, int x, int y) override; void getInstanceMapTree(InstanceTreeMap &instanceMapTree); diff --git a/src/common/Collision/Maps/MapDefines.h b/src/common/Collision/Maps/MapDefines.h index 4935e991259..50f7e93e4c3 100644 --- a/src/common/Collision/Maps/MapDefines.h +++ b/src/common/Collision/Maps/MapDefines.h @@ -1,3 +1,20 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * 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/>. + */ + #ifndef _MAPDEFINES_H #define _MAPDEFINES_H diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp index 313a95d855b..04f914fb4f1 100644 --- a/src/common/Collision/Maps/MapTree.cpp +++ b/src/common/Collision/Maps/MapTree.cpp @@ -35,26 +35,26 @@ namespace VMAP class MapRayCallback { public: - MapRayCallback(ModelInstance* val, ModelIgnoreFlags ignoreFlags): prims(val), hit(false), flags(ignoreFlags) { } - bool operator()(const G3D::Ray& ray, uint32 entry, float& distance, bool pStopAtFirstHit=true) + MapRayCallback(ModelInstance* val, ModelIgnoreFlags ignoreFlags) : prims(val), hit(false), flags(ignoreFlags) { } + bool operator()(const G3D::Ray& ray, uint32 entry, float& distance, bool pStopAtFirstHit = true) { bool result = prims[entry].intersectRay(ray, distance, pStopAtFirstHit, flags); if (result) hit = true; return result; } - bool didHit() { return hit; } - protected: - ModelInstance* prims; - bool hit; - ModelIgnoreFlags flags; + bool didHit() { return hit; } + protected: + ModelInstance* prims; + bool hit; + ModelIgnoreFlags flags; }; class AreaInfoCallback { public: - AreaInfoCallback(ModelInstance* val): prims(val) { } - void operator()(const Vector3& point, uint32 entry) + AreaInfoCallback(ModelInstance* val) : prims(val) { } + void operator()(Vector3 const& point, uint32 entry) { #ifdef VMAP_DEBUG TC_LOG_DEBUG("maps", "AreaInfoCallback: trying to intersect '%s'", prims[entry].name.c_str()); @@ -69,8 +69,8 @@ namespace VMAP class LocationInfoCallback { public: - LocationInfoCallback(ModelInstance* val, LocationInfo &info): prims(val), locInfo(info), result(false) { } - void operator()(const Vector3& point, uint32 entry) + LocationInfoCallback(ModelInstance* val, LocationInfo& info) : prims(val), locInfo(info), result(false) { } + void operator()(Vector3 const& point, uint32 entry) { #ifdef VMAP_DEBUG TC_LOG_DEBUG("maps", "LocationInfoCallback: trying to intersect '%s'", prims[entry].name.c_str()); @@ -80,7 +80,7 @@ namespace VMAP } ModelInstance* prims; - LocationInfo &locInfo; + LocationInfo& locInfo; bool result; }; @@ -96,7 +96,7 @@ namespace VMAP return tilefilename.str(); } - bool StaticMapTree::getAreaInfo(Vector3 &pos, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const + bool StaticMapTree::getAreaInfo(Vector3& pos, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const { AreaInfoCallback intersectionCallBack(iTreeValues); iTree.intersectPoint(pos, intersectionCallBack); @@ -112,17 +112,17 @@ namespace VMAP return false; } - bool StaticMapTree::GetLocationInfo(const Vector3 &pos, LocationInfo &info) const + bool StaticMapTree::GetLocationInfo(Vector3 const& pos, LocationInfo& info) const { LocationInfoCallback intersectionCallBack(iTreeValues, info); iTree.intersectPoint(pos, intersectionCallBack); return intersectionCallBack.result; } - StaticMapTree::StaticMapTree(uint32 mapID, const std::string &basePath) + StaticMapTree::StaticMapTree(uint32 mapID, std::string const& basePath) : iMapID(mapID), iTreeValues(nullptr), iNTreeValues(0), iBasePath(basePath) { - if (iBasePath.length() > 0 && iBasePath[iBasePath.length()-1] != '/' && iBasePath[iBasePath.length()-1] != '\\') + if (iBasePath.length() > 0 && iBasePath[iBasePath.length() - 1] != '/' && iBasePath[iBasePath.length() - 1] != '\\') { iBasePath.push_back('/'); } @@ -141,7 +141,7 @@ namespace VMAP Else, pMaxDist is not modified and returns false; */ - bool StaticMapTree::getIntersectionTime(const G3D::Ray& pRay, float &pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const + bool StaticMapTree::getIntersectionTime(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const { float distance = pMaxDist; MapRayCallback intersectionCallBack(iTreeValues, ignoreFlags); @@ -152,7 +152,7 @@ namespace VMAP } //========================================================= - bool StaticMapTree::isInLineOfSight(const Vector3& pos1, const Vector3& pos2, ModelIgnoreFlags ignoreFlag) const + bool StaticMapTree::isInLineOfSight(Vector3 const& pos1, Vector3 const& pos2, ModelIgnoreFlags ignoreFlag) const { float maxDist = (pos2 - pos1).magnitude(); // return false if distance is over max float, in case of cheater teleporting to the end of the universe @@ -165,7 +165,7 @@ namespace VMAP if (maxDist < 1e-10f) return true; // direction with length of 1 - G3D::Ray ray = G3D::Ray::fromOriginAndDirection(pos1, (pos2 - pos1)/maxDist); + G3D::Ray ray = G3D::Ray::fromOriginAndDirection(pos1, (pos2 - pos1) / maxDist); if (getIntersectionTime(ray, maxDist, true, ignoreFlag)) return false; @@ -177,9 +177,9 @@ namespace VMAP Return the hit pos or the original dest pos */ - bool StaticMapTree::getObjectHitPos(const Vector3& pPos1, const Vector3& pPos2, Vector3& pResultHitPos, float pModifyDist) const + bool StaticMapTree::getObjectHitPos(Vector3 const& pPos1, Vector3 const& pPos2, Vector3& pResultHitPos, float pModifyDist) const { - bool result=false; + bool result = false; float maxDist = (pPos2 - pPos1).magnitude(); // valid map coords should *never ever* produce float overflow, but this would produce NaNs too ASSERT(maxDist < std::numeric_limits<float>::max()); @@ -189,7 +189,7 @@ namespace VMAP pResultHitPos = pPos2; return false; } - Vector3 dir = (pPos2 - pPos1)/maxDist; // direction with length of 1 + Vector3 dir = (pPos2 - pPos1) / maxDist; // direction with length of 1 G3D::Ray ray(pPos1, dir); float dist = maxDist; if (getIntersectionTime(ray, dist, false, ModelIgnoreFlags::Nothing)) @@ -199,7 +199,7 @@ namespace VMAP { if ((pResultHitPos - pPos1).magnitude() > -pModifyDist) { - pResultHitPos = pResultHitPos + dir*pModifyDist; + pResultHitPos = pResultHitPos + dir * pModifyDist; } else { @@ -208,7 +208,7 @@ namespace VMAP } else { - pResultHitPos = pResultHitPos + dir*pModifyDist; + pResultHitPos = pResultHitPos + dir * pModifyDist; } result = true; } @@ -222,7 +222,7 @@ namespace VMAP //========================================================= - float StaticMapTree::getHeight(const Vector3& pPos, float maxSearchDist) const + float StaticMapTree::getHeight(Vector3 const& pPos, float maxSearchDist) const { float height = G3D::finf(); Vector3 dir = Vector3(0, 0, -1); @@ -258,10 +258,10 @@ namespace VMAP } //========================================================= - LoadResult StaticMapTree::CanLoadMap(const std::string &vmapPath, uint32 mapID, uint32 tileX, uint32 tileY, VMapManager2* vm) + LoadResult StaticMapTree::CanLoadMap(const std::string& vmapPath, uint32 mapID, uint32 tileX, uint32 tileY, VMapManager2* vm) { std::string basePath = vmapPath; - if (basePath.length() > 0 && basePath[basePath.length()-1] != '/' && basePath[basePath.length()-1] != '\\') + if (basePath.length() > 0 && basePath[basePath.length() - 1] != '/' && basePath[basePath.length() - 1] != '\\') basePath.push_back('/'); std::string fullname = basePath + VMapManager2::getMapFileName(mapID); @@ -377,7 +377,7 @@ namespace VMAP uint32 numSpawns = 0; if (result && fread(&numSpawns, sizeof(uint32), 1, fileResult.File) != 1) result = false; - for (uint32 i=0; i<numSpawns && result; ++i) + for (uint32 i = 0; i < numSpawns && result; ++i) { // read model spawns ModelSpawn spawn; @@ -446,14 +446,14 @@ namespace VMAP TileFileOpenResult fileResult = OpenMapTileFile(iBasePath, iMapID, tileX, tileY, vm); if (fileResult.File) { - bool result=true; + bool result = true; char chunk[8]; if (!readChunk(fileResult.File, chunk, VMAP_MAGIC, 8)) result = false; uint32 numSpawns; if (fread(&numSpawns, sizeof(uint32), 1, fileResult.File) != 1) result = false; - for (uint32 i=0; i<numSpawns && result; ++i) + for (uint32 i = 0; i < numSpawns && result; ++i) { // read model spawns ModelSpawn spawn; @@ -471,7 +471,7 @@ namespace VMAP { uint32 referencedNode = spawnIndex->second; if (!iLoadedSpawns.count(referencedNode)) - TC_LOG_ERROR("misc", "StaticMapTree::UnloadMapTile() : trying to unload non-referenced model '%s' (ID:%u)", spawn.name.c_str(), spawn.ID); + TC_LOG_ERROR("misc", "StaticMapTree::UnloadMapTile() : trying to unload non-referenced model '%s' (ID:%u)", spawn.name.c_str(), spawn.ID); else if (--iLoadedSpawns[referencedNode] == 0) { iTreeValues[referencedNode].setUnloaded(); @@ -488,7 +488,7 @@ namespace VMAP "Map: " + std::to_string(iMapID) + " TileX: " + std::to_string(tileX) + " TileY: " + std::to_string(tileY)); } - void StaticMapTree::getModelInstances(ModelInstance* &models, uint32 &count) + void StaticMapTree::getModelInstances(ModelInstance*& models, uint32& count) { models = iTreeValues; count = iNTreeValues; diff --git a/src/common/Collision/Maps/MapTree.h b/src/common/Collision/Maps/MapTree.h index a9eb70c6bab..d2012ea7a30 100644 --- a/src/common/Collision/Maps/MapTree.h +++ b/src/common/Collision/Maps/MapTree.h @@ -34,8 +34,8 @@ namespace VMAP { LocationInfo(): rootId(-1), hitInstance(nullptr), hitModel(nullptr), ground_Z(-G3D::finf()) { } int32 rootId; - const ModelInstance* hitInstance; - const GroupModel* hitModel; + ModelInstance const* hitInstance; + GroupModel const* hitModel; float ground_Z; }; diff --git a/src/common/Collision/Models/ModelInstance.cpp b/src/common/Collision/Models/ModelInstance.cpp index 3689824e50b..385702a25ad 100644 --- a/src/common/Collision/Models/ModelInstance.cpp +++ b/src/common/Collision/Models/ModelInstance.cpp @@ -24,13 +24,13 @@ using G3D::Ray; namespace VMAP { - ModelInstance::ModelInstance(const ModelSpawn &spawn, WorldModel* model): ModelSpawn(spawn), iModel(model) + ModelInstance::ModelInstance(ModelSpawn const& spawn, WorldModel* model) : ModelSpawn(spawn), iModel(model) { - iInvRot = G3D::Matrix3::fromEulerAnglesZYX(G3D::pif()*iRot.y/180.f, G3D::pif()*iRot.x/180.f, G3D::pif()*iRot.z/180.f).inverse(); - iInvScale = 1.f/iScale; + iInvRot = G3D::Matrix3::fromEulerAnglesZYX(G3D::pif() * iRot.y / 180.f, G3D::pif() * iRot.x / 180.f, G3D::pif() * iRot.z / 180.f).inverse(); + iInvScale = 1.f / iScale; } - bool ModelInstance::intersectRay(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const + bool ModelInstance::intersectRay(G3D::Ray const& pRay, float& pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const { if (!iModel) { @@ -63,7 +63,7 @@ namespace VMAP return hit; } - void ModelInstance::intersectPoint(const G3D::Vector3& p, AreaInfo &info) const + void ModelInstance::intersectPoint(const G3D::Vector3& p, AreaInfo& info) const { if (!iModel) { @@ -97,7 +97,7 @@ namespace VMAP } } - bool ModelInstance::GetLocationInfo(const G3D::Vector3& p, LocationInfo &info) const + bool ModelInstance::GetLocationInfo(const G3D::Vector3& p, LocationInfo& info) const { if (!iModel) { @@ -133,7 +133,7 @@ namespace VMAP return false; } - bool ModelInstance::GetLiquidLevel(const G3D::Vector3& p, LocationInfo &info, float &liqHeight) const + bool ModelInstance::GetLiquidLevel(const G3D::Vector3& p, LocationInfo& info, float& liqHeight) const { // child bounds are defined in object space: Vector3 pModel = iInvRot * (p - iPos) * iInvScale; @@ -149,7 +149,7 @@ namespace VMAP return false; } - bool ModelSpawn::readFromFile(FILE* rf, ModelSpawn &spawn) + bool ModelSpawn::readFromFile(FILE* rf, ModelSpawn& spawn) { uint32 check = 0, nameLen; check += fread(&spawn.flags, sizeof(uint32), 1, rf); @@ -195,9 +195,9 @@ namespace VMAP return true; } - bool ModelSpawn::writeToFile(FILE* wf, const ModelSpawn &spawn) + bool ModelSpawn::writeToFile(FILE* wf, ModelSpawn const& spawn) { - uint32 check=0; + uint32 check = 0; check += fwrite(&spawn.flags, sizeof(uint32), 1, wf); check += fwrite(&spawn.adtId, sizeof(uint16), 1, wf); check += fwrite(&spawn.ID, sizeof(uint32), 1, wf); diff --git a/src/common/Collision/Models/ModelInstance.h b/src/common/Collision/Models/ModelInstance.h index c5caf9599be..b342a14fdc6 100644 --- a/src/common/Collision/Models/ModelInstance.h +++ b/src/common/Collision/Models/ModelInstance.h @@ -51,25 +51,25 @@ namespace VMAP float iScale; G3D::AABox iBound; std::string name; - bool operator==(const ModelSpawn &other) const { return ID == other.ID; } + bool operator==(ModelSpawn const& other) const { return ID == other.ID; } //uint32 hashCode() const { return ID; } // temp? - const G3D::AABox& getBounds() const { return iBound; } + G3D::AABox const& getBounds() const { return iBound; } - static bool readFromFile(FILE* rf, ModelSpawn &spawn); - static bool writeToFile(FILE* rw, const ModelSpawn &spawn); + static bool readFromFile(FILE* rf, ModelSpawn& spawn); + static bool writeToFile(FILE* rw, ModelSpawn const& spawn); }; - class TC_COMMON_API ModelInstance: public ModelSpawn + class TC_COMMON_API ModelInstance : public ModelSpawn { public: - ModelInstance(): iInvScale(0.0f), iModel(nullptr) { } - ModelInstance(const ModelSpawn &spawn, WorldModel* model); + ModelInstance() : iInvScale(0.0f), iModel(nullptr) { } + ModelInstance(ModelSpawn const& spawn, WorldModel* model); void setUnloaded() { iModel = nullptr; } - bool intersectRay(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const; - void intersectPoint(const G3D::Vector3& p, AreaInfo &info) const; - bool GetLocationInfo(const G3D::Vector3& p, LocationInfo &info) const; - bool GetLiquidLevel(const G3D::Vector3& p, LocationInfo &info, float &liqHeight) const; + bool intersectRay(G3D::Ray const& pRay, float& pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const; + void intersectPoint(G3D::Vector3 const& p, AreaInfo& info) const; + bool GetLocationInfo(G3D::Vector3 const& p, LocationInfo& info) const; + bool GetLiquidLevel(G3D::Vector3 const& p, LocationInfo& info, float& liqHeight) const; WorldModel* getWorldModel() { return iModel; } protected: G3D::Matrix3 iInvRot; diff --git a/src/common/Collision/Models/WorldModel.cpp b/src/common/Collision/Models/WorldModel.cpp index a547a402b9d..9bbb6278950 100644 --- a/src/common/Collision/Models/WorldModel.cpp +++ b/src/common/Collision/Models/WorldModel.cpp @@ -31,7 +31,7 @@ template<> struct BoundsTrait<VMAP::GroupModel> namespace VMAP { - bool IntersectTriangle(const MeshTriangle &tri, std::vector<Vector3>::const_iterator points, const G3D::Ray &ray, float &distance) + bool IntersectTriangle(MeshTriangle const& tri, std::vector<Vector3>::const_iterator points, G3D::Ray const& ray, float& distance) { static const float EPS = 1e-5f; @@ -84,8 +84,8 @@ namespace VMAP class TriBoundFunc { public: - TriBoundFunc(std::vector<Vector3> &vert): vertices(vert.begin()) { } - void operator()(const MeshTriangle &tri, G3D::AABox &out) const + TriBoundFunc(std::vector<Vector3>& vert): vertices(vert.begin()) { } + void operator()(MeshTriangle const& tri, G3D::AABox& out) const { G3D::Vector3 lo = vertices[tri.idx0]; G3D::Vector3 hi = lo; @@ -101,7 +101,7 @@ namespace VMAP // ===================== WmoLiquid ================================== - WmoLiquid::WmoLiquid(uint32 width, uint32 height, const Vector3 &corner, uint32 type): + WmoLiquid::WmoLiquid(uint32 width, uint32 height, Vector3 const& corner, uint32 type) : iTilesX(width), iTilesY(height), iCorner(corner), iType(type) { if (width && height) @@ -116,7 +116,7 @@ namespace VMAP } } - WmoLiquid::WmoLiquid(const WmoLiquid &other): iHeight(nullptr), iFlags(nullptr) + WmoLiquid::WmoLiquid(WmoLiquid const& other) : iHeight(nullptr), iFlags(nullptr) { *this = other; // use assignment operator... } @@ -127,7 +127,7 @@ namespace VMAP delete[] iFlags; } - WmoLiquid& WmoLiquid::operator=(const WmoLiquid &other) + WmoLiquid& WmoLiquid::operator=(WmoLiquid const& other) { if (this == &other) return *this; @@ -154,7 +154,7 @@ namespace VMAP return *this; } - bool WmoLiquid::GetLiquidHeight(const Vector3 &pos, float &liqHeight) const + bool WmoLiquid::GetLiquidHeight(Vector3 const& pos, float& liqHeight) const { // simple case if (!iFlags) @@ -163,18 +163,18 @@ namespace VMAP return true; } - float tx_f = (pos.x - iCorner.x)/LIQUID_TILE_SIZE; + float tx_f = (pos.x - iCorner.x) / LIQUID_TILE_SIZE; uint32 tx = uint32(tx_f); if (tx_f < 0.0f || tx >= iTilesX) return false; - float ty_f = (pos.y - iCorner.y)/LIQUID_TILE_SIZE; + float ty_f = (pos.y - iCorner.y) / LIQUID_TILE_SIZE; uint32 ty = uint32(ty_f); if (ty_f < 0.0f || ty >= iTilesY) return false; // 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[tx + ty * iTilesX] & 0x0F) == 0x0F) return false; // (dx, dy) coordinates inside tile, in [0, 1]^2 @@ -194,7 +194,7 @@ namespace VMAP 0 1 */ - const uint32 rowOffset = iTilesX + 1; + uint32 const rowOffset = iTilesX + 1; if (dx > dy) // case (a) { float sx = iHeight[tx+1 + ty * rowOffset] - iHeight[tx + ty * rowOffset]; @@ -242,7 +242,7 @@ namespace VMAP return result; } - bool WmoLiquid::readFromFile(FILE* rf, WmoLiquid* &out) + bool WmoLiquid::readFromFile(FILE* rf, WmoLiquid*& out) { bool result = false; WmoLiquid* liquid = new WmoLiquid(); @@ -278,7 +278,7 @@ namespace VMAP return result; } - void WmoLiquid::getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const + void WmoLiquid::getPosInfo(uint32& tilesX, uint32& tilesY, G3D::Vector3& corner) const { tilesX = iTilesX; tilesY = iTilesY; @@ -287,7 +287,7 @@ namespace VMAP // ===================== GroupModel ================================== - GroupModel::GroupModel(const GroupModel &other): + GroupModel::GroupModel(GroupModel const& other) : iBound(other.iBound), iMogpFlags(other.iMogpFlags), iGroupWMOID(other.iGroupWMOID), vertices(other.vertices), triangles(other.triangles), meshTree(other.meshTree), iLiquid(nullptr) { @@ -295,7 +295,7 @@ namespace VMAP iLiquid = new WmoLiquid(*other.iLiquid); } - void GroupModel::setMeshData(std::vector<Vector3> &vert, std::vector<MeshTriangle> &tri) + void GroupModel::setMeshData(std::vector<Vector3>& vert, std::vector<MeshTriangle>& tri) { vertices.swap(vert); triangles.swap(tri); @@ -315,7 +315,7 @@ namespace VMAP // write vertices if (result && fwrite("VERT", 1, 4, wf) != 4) result = false; count = vertices.size(); - chunkSize = sizeof(uint32)+ sizeof(Vector3)*count; + chunkSize = sizeof(uint32) + sizeof(Vector3) * count; if (result && fwrite(&chunkSize, sizeof(uint32), 1, wf) != 1) result = false; if (result && fwrite(&count, sizeof(uint32), 1, wf) != 1) result = false; if (!count) // models without (collision) geometry end here, unsure if they are useful @@ -325,7 +325,7 @@ namespace VMAP // write triangle mesh if (result && fwrite("TRIM", 1, 4, wf) != 4) result = false; count = triangles.size(); - chunkSize = sizeof(uint32)+ sizeof(MeshTriangle)*count; + chunkSize = sizeof(uint32) + sizeof(MeshTriangle) * count; if (result && fwrite(&chunkSize, sizeof(uint32), 1, wf) != 1) result = false; if (result && fwrite(&count, sizeof(uint32), 1, wf) != 1) result = false; if (result && fwrite(&triangles[0], sizeof(MeshTriangle), count, wf) != count) result = false; @@ -394,12 +394,13 @@ namespace VMAP struct GModelRayCallback { - GModelRayCallback(const std::vector<MeshTriangle> &tris, const std::vector<Vector3> &vert): + GModelRayCallback(std::vector<MeshTriangle> const& tris, const std::vector<Vector3> &vert): vertices(vert.begin()), triangles(tris.begin()), hit(false) { } - bool operator()(const G3D::Ray& ray, uint32 entry, float& distance, bool /*pStopAtFirstHit*/) + bool operator()(G3D::Ray const& ray, uint32 entry, float& distance, bool /*pStopAtFirstHit*/) { bool result = IntersectTriangle(triangles[entry], vertices, ray, distance); - if (result) hit=true; + if (result) + hit = true; return hit; } std::vector<Vector3>::const_iterator vertices; @@ -407,7 +408,7 @@ namespace VMAP bool hit; }; - bool GroupModel::IntersectRay(const G3D::Ray &ray, float &distance, bool stopAtFirstHit) const + bool GroupModel::IntersectRay(G3D::Ray const& ray, float& distance, bool stopAtFirstHit) const { if (triangles.empty()) return false; @@ -417,7 +418,7 @@ namespace VMAP return callback.hit; } - bool GroupModel::IsInsideObject(const Vector3 &pos, const Vector3 &down, float &z_dist) const + bool GroupModel::IsInsideObject(Vector3 const& pos, Vector3 const& down, float& z_dist) const { if (triangles.empty() || !iBound.contains(pos)) return false; @@ -431,7 +432,7 @@ namespace VMAP return hit; } - bool GroupModel::GetLiquidLevel(const Vector3 &pos, float &liqHeight) const + bool GroupModel::GetLiquidLevel(Vector3 const& pos, float& liqHeight) const { if (iLiquid) return iLiquid->GetLiquidHeight(pos, liqHeight); @@ -454,7 +455,7 @@ namespace VMAP // ===================== WorldModel ================================== - void WorldModel::setGroupModels(std::vector<GroupModel> &models) + void WorldModel::setGroupModels(std::vector<GroupModel>& models) { groupModels.swap(models); groupTree.build(groupModels, BoundsTrait<GroupModel>::getBounds, 1); @@ -462,18 +463,19 @@ namespace VMAP struct WModelRayCallBack { - WModelRayCallBack(const std::vector<GroupModel> &mod): models(mod.begin()), hit(false) { } - bool operator()(const G3D::Ray& ray, uint32 entry, float& distance, bool pStopAtFirstHit) + WModelRayCallBack(std::vector<GroupModel> const& mod): models(mod.begin()), hit(false) { } + bool operator()(G3D::Ray const& ray, uint32 entry, float& distance, bool pStopAtFirstHit) { bool result = models[entry].IntersectRay(ray, distance, pStopAtFirstHit); - if (result) hit=true; + if (result) + hit = true; return hit; } std::vector<GroupModel>::const_iterator models; bool hit; }; - bool WorldModel::IntersectRay(const G3D::Ray &ray, float &distance, bool stopAtFirstHit, ModelIgnoreFlags ignoreFlags) const + bool WorldModel::IntersectRay(G3D::Ray const& ray, float& distance, bool stopAtFirstHit, ModelIgnoreFlags ignoreFlags) const { // If the caller asked us to ignore certain objects we should check flags if ((ignoreFlags & ModelIgnoreFlags::M2) != ModelIgnoreFlags::Nothing) @@ -495,14 +497,14 @@ namespace VMAP class WModelAreaCallback { public: - WModelAreaCallback(const std::vector<GroupModel> &vals, const Vector3 &down): + WModelAreaCallback(std::vector<GroupModel> const& vals, Vector3 const& down) : prims(vals.begin()), hit(vals.end()), minVol(G3D::finf()), zDist(G3D::finf()), zVec(down) { } std::vector<GroupModel>::const_iterator prims; std::vector<GroupModel>::const_iterator hit; float minVol; float zDist; Vector3 zVec; - void operator()(const Vector3& point, uint32 entry) + void operator()(Vector3 const& point, uint32 entry) { float group_Z; //float pVol = prims[entry].GetBound().volume(); @@ -519,7 +521,7 @@ namespace VMAP hit = prims + entry; } #ifdef VMAP_DEBUG - const GroupModel &gm = prims[entry]; + GroupModel const& gm = prims[entry]; printf("%10u %8X %7.3f, %7.3f, %7.3f | %7.3f, %7.3f, %7.3f | z=%f, p_z=%f\n", gm.GetWmoID(), gm.GetMogpFlags(), gm.GetBound().low().x, gm.GetBound().low().y, gm.GetBound().low().z, gm.GetBound().high().x, gm.GetBound().high().y, gm.GetBound().high().z, group_Z, point.z); @@ -530,7 +532,7 @@ namespace VMAP } }; - bool WorldModel::IntersectPoint(const G3D::Vector3 &p, const G3D::Vector3 &down, float &dist, AreaInfo &info) const + bool WorldModel::IntersectPoint(const G3D::Vector3& p, const G3D::Vector3& down, float& dist, AreaInfo& info) const { if (groupModels.empty()) return false; @@ -549,7 +551,7 @@ namespace VMAP return false; } - bool WorldModel::GetLocationInfo(const G3D::Vector3 &p, const G3D::Vector3 &down, float &dist, LocationInfo &info) const + bool WorldModel::GetLocationInfo(const G3D::Vector3& p, const G3D::Vector3& down, float& dist, LocationInfo& info) const { if (groupModels.empty()) return false; @@ -566,7 +568,7 @@ namespace VMAP return false; } - bool WorldModel::writeFile(const std::string &filename) + bool WorldModel::writeFile(const std::string& filename) { FILE* wf = fopen(filename.c_str(), "wb"); if (!wf) @@ -580,14 +582,14 @@ namespace VMAP if (result && fwrite(&RootWMOID, sizeof(uint32), 1, wf) != 1) result = false; // write group models - count=groupModels.size(); + count = groupModels.size(); if (count) { if (result && fwrite("GMOD", 1, 4, wf) != 4) result = false; //chunkSize = sizeof(uint32)+ sizeof(GroupModel)*count; //if (result && fwrite(&chunkSize, sizeof(uint32), 1, wf) != 1) result = false; if (result && fwrite(&count, sizeof(uint32), 1, wf) != 1) result = false; - for (uint32 i=0; i<groupModels.size() && result; ++i) + for (uint32 i = 0; i < groupModels.size() && result; ++i) result = groupModels[i].writeToFile(wf); // write group BIH @@ -599,7 +601,7 @@ namespace VMAP return result; } - bool WorldModel::readFile(const std::string &filename) + bool WorldModel::readFile(const std::string& filename) { FILE* rf = fopen(filename.c_str(), "rb"); if (!rf) @@ -623,7 +625,7 @@ namespace VMAP if (result && 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) + for (uint32 i = 0; i < count && result; ++i) result = groupModels[i].readFromFile(rf); // read group BIH diff --git a/src/common/Collision/Models/WorldModel.h b/src/common/Collision/Models/WorldModel.h index 4392f9b194f..093a4ea84ed 100644 --- a/src/common/Collision/Models/WorldModel.h +++ b/src/common/Collision/Models/WorldModel.h @@ -47,11 +47,11 @@ namespace VMAP class TC_COMMON_API WmoLiquid { public: - WmoLiquid(uint32 width, uint32 height, const G3D::Vector3 &corner, uint32 type); - WmoLiquid(const WmoLiquid &other); + WmoLiquid(uint32 width, uint32 height, G3D::Vector3 const& corner, uint32 type); + WmoLiquid(WmoLiquid const& other); ~WmoLiquid(); - WmoLiquid& operator=(const WmoLiquid &other); - bool GetLiquidHeight(const G3D::Vector3 &pos, float &liqHeight) const; + WmoLiquid& operator=(WmoLiquid const& other); + bool GetLiquidHeight(G3D::Vector3 const& pos, float& liqHeight) const; uint32 GetType() const { return iType; } float *GetHeightStorage() { return iHeight; } uint8 *GetFlagsStorage() { return iFlags; } @@ -74,8 +74,8 @@ namespace VMAP { public: GroupModel() : iBound(), iMogpFlags(0), iGroupWMOID(0), iLiquid(nullptr) { } - GroupModel(const GroupModel &other); - GroupModel(uint32 mogpFlags, uint32 groupWMOID, const G3D::AABox &bound): + GroupModel(GroupModel const& other); + GroupModel(uint32 mogpFlags, uint32 groupWMOID, G3D::AABox const& bound): iBound(bound), iMogpFlags(mogpFlags), iGroupWMOID(groupWMOID), iLiquid(nullptr) { } ~GroupModel() { delete iLiquid; } diff --git a/src/common/Collision/RegularGrid.h b/src/common/Collision/RegularGrid.h index 5de9d80c893..953ddd44a35 100644 --- a/src/common/Collision/RegularGrid.h +++ b/src/common/Collision/RegularGrid.h @@ -1,3 +1,20 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * 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/>. + */ + #ifndef _REGULAR_GRID_H #define _REGULAR_GRID_H @@ -86,15 +103,18 @@ public: struct Cell { int x, y; - bool operator == (const Cell& c2) const { return x == c2.x && y == c2.y;} + bool operator==(Cell const& c2) const + { + return x == c2.x && y == c2.y; + } static Cell ComputeCell(float fx, float fy) { - Cell c = { int(fx * (1.f/CELL_SIZE) + (CELL_NUMBER/2)), int(fy * (1.f/CELL_SIZE) + (CELL_NUMBER/2)) }; + Cell c = { int(fx * (1.f / CELL_SIZE) + (CELL_NUMBER / 2)), int(fy * (1.f / CELL_SIZE) + (CELL_NUMBER / 2)) }; return c; } - bool isValid() const { return x >= 0 && x < CELL_NUMBER && y >= 0 && y < CELL_NUMBER;} + bool isValid() const { return x >= 0 && x < CELL_NUMBER && y >= 0 && y < CELL_NUMBER; } }; Node& getGrid(int x, int y) diff --git a/src/common/Cryptography/OpenSSLCrypto.cpp b/src/common/Cryptography/OpenSSLCrypto.cpp index eca063804fe..ccb20431673 100644 --- a/src/common/Cryptography/OpenSSLCrypto.cpp +++ b/src/common/Cryptography/OpenSSLCrypto.cpp @@ -24,7 +24,7 @@ std::vector<std::mutex*> cryptoLocks; void ValgrindRandomSetup(); -static void lockingCallback(int mode, int type, const char* /*file*/, int /*line*/) +static void lockingCallback(int mode, int type, char const* /*file*/, int /*line*/) { if (mode & CRYPTO_LOCK) cryptoLocks[type]->lock(); diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/WheatyExceptionReport.cpp index 57d09fb01c6..c245c9978ec 100644 --- a/src/common/Debugging/WheatyExceptionReport.cpp +++ b/src/common/Debugging/WheatyExceptionReport.cpp @@ -930,7 +930,7 @@ DWORD64 modBase, DWORD dwTypeIndex, DWORD_PTR offset, bool & bHandled, -const char* Name, +char const* Name, char* /*suffix*/, bool newSymbol, bool logChildren) diff --git a/src/common/Debugging/WheatyExceptionReport.h b/src/common/Debugging/WheatyExceptionReport.h index 42d4d3e0a2a..a6f871bfb13 100644 --- a/src/common/Debugging/WheatyExceptionReport.h +++ b/src/common/Debugging/WheatyExceptionReport.h @@ -56,7 +56,7 @@ enum DataKind // Stolen from CVCONS DataIsConstant }; -const char* const rgBaseType[] = +char const* const rgBaseType[] = { "<user defined>", // btNoType = 0, "void", // btVoid = 1, @@ -100,7 +100,7 @@ struct SymbolPair _offset = offset; } - bool operator<(const SymbolPair& other) const + bool operator<(SymbolPair const& other) const { return _offset < other._offset || (_offset == other._offset && _type < other._type); @@ -176,7 +176,7 @@ class WheatyExceptionReport static bool FormatSymbolValue(PSYMBOL_INFO, STACKFRAME64 *); - static void DumpTypeIndex(DWORD64, DWORD, DWORD_PTR, bool &, const char*, char*, bool, bool); + static void DumpTypeIndex(DWORD64, DWORD, DWORD_PTR, bool &, char const*, char*, bool, bool); static void FormatOutputValue(char * pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress, size_t bufferSize, size_t countOverride = 0); diff --git a/src/common/Logging/Appender.cpp b/src/common/Logging/Appender.cpp index 5e26d2ff1ba..77c4352b469 100644 --- a/src/common/Logging/Appender.cpp +++ b/src/common/Logging/Appender.cpp @@ -70,7 +70,7 @@ void Appender::write(LogMessage* message) _write(message); } -const char* Appender::getLogLevelString(LogLevel level) +char const* Appender::getLogLevelString(LogLevel level) { switch (level) { diff --git a/src/common/Logging/Appender.h b/src/common/Logging/Appender.h index c3768058a1b..ed98fd56935 100644 --- a/src/common/Logging/Appender.h +++ b/src/common/Logging/Appender.h @@ -40,7 +40,7 @@ class TC_COMMON_API Appender void setLogLevel(LogLevel); void write(LogMessage* message); - static const char* getLogLevelString(LogLevel level); + static char const* getLogLevelString(LogLevel level); virtual void setRealmId(uint32 /*realmId*/) { } private: diff --git a/src/common/Logging/Log.cpp b/src/common/Logging/Log.cpp index 209a952dad2..c50b0e6c52e 100644 --- a/src/common/Logging/Log.cpp +++ b/src/common/Logging/Log.cpp @@ -61,7 +61,7 @@ void Log::CreateAppenderFromConfig(std::string const& appenderName) if (appenderName.empty()) return; - // Format=type, level, flags, optional1, optional2 + // Format = type, level, flags, optional1, optional2 // if type = File. optional1 = file and option2 = mode // if type = Console. optional1 = Color std::string options = sConfigMgr->GetStringDefault(appenderName.c_str(), ""); @@ -213,7 +213,7 @@ void Log::RegisterAppender(uint8 index, AppenderCreatorFn appenderCreateFn) appenderFactory[index] = appenderCreateFn; } -void Log::outMessage(std::string const& filter, LogLevel const level, std::string&& message) +void Log::outMessage(std::string const& filter, LogLevel level, std::string&& message) { write(std::make_unique<LogMessage>(level, filter, std::move(message))); } @@ -279,7 +279,7 @@ std::string Log::GetTimestampStr() } } -bool Log::SetLogLevel(std::string const& name, const char* newLevelc, bool isLogger /* = true */) +bool Log::SetLogLevel(std::string const& name, char const* newLevelc, bool isLogger /* = true */) { LogLevel newLevel = LogLevel(atoi(newLevelc)); if (newLevel < 0) diff --git a/src/common/Logging/Log.h b/src/common/Logging/Log.h index 6086ed93d41..27ce6da1cba 100644 --- a/src/common/Logging/Log.h +++ b/src/common/Logging/Log.h @@ -42,7 +42,7 @@ namespace Trinity typedef Appender*(*AppenderCreatorFn)(uint8 id, std::string const& name, LogLevel level, AppenderFlags flags, std::vector<char const*>&& extraArgs); -template<class AppenderImpl> +template <class AppenderImpl> Appender* CreateAppender(uint8 id, std::string const& name, LogLevel level, AppenderFlags flags, std::vector<char const*>&& extraArgs) { return new AppenderImpl(id, name, level, flags, std::forward<std::vector<char const*>>(extraArgs)); @@ -109,7 +109,7 @@ class TC_COMMON_API Log void ReadAppendersFromConfig(); void ReadLoggersFromConfig(); void RegisterAppender(uint8 index, AppenderCreatorFn appenderCreateFn); - void outMessage(std::string const& filter, LogLevel const level, std::string&& message); + void outMessage(std::string const& filter, LogLevel level, std::string&& message); void outCommand(std::string&& message, std::string&& param1); std::unordered_map<uint8, AppenderCreatorFn> appenderFactory; @@ -141,7 +141,7 @@ class TC_COMMON_API Log } #if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS -void check_args(const char*, ...) ATTR_PRINTF(1, 2); +void check_args(char const*, ...) ATTR_PRINTF(1, 2); void check_args(std::string const&, ...); // This will catch format errors on build time diff --git a/src/common/Logging/LogMessage.cpp b/src/common/Logging/LogMessage.cpp index 143203946e8..5f10087d1f0 100644 --- a/src/common/Logging/LogMessage.cpp +++ b/src/common/Logging/LogMessage.cpp @@ -36,7 +36,7 @@ std::string LogMessage::getTimeStr(time_t time) return Trinity::StringFormat("%04d-%02d-%02d_%02d:%02d:%02d", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec); } -std::string LogMessage::getTimeStr() +std::string LogMessage::getTimeStr() const { return getTimeStr(mtime); } diff --git a/src/common/Logging/LogMessage.h b/src/common/Logging/LogMessage.h index 25faf310796..d9709b43c4c 100644 --- a/src/common/Logging/LogMessage.h +++ b/src/common/Logging/LogMessage.h @@ -32,7 +32,7 @@ struct TC_COMMON_API LogMessage LogMessage& operator=(LogMessage const& /*other*/) = delete; static std::string getTimeStr(time_t time); - std::string getTimeStr(); + std::string getTimeStr() const; LogLevel const level; std::string const type; diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp index 285a836a44a..27e8996f112 100644 --- a/src/common/Metric/Metric.cpp +++ b/src/common/Metric/Metric.cpp @@ -249,7 +249,7 @@ std::string Metric::FormatInfluxDBValue(std::string const& value) return '"' + boost::replace_all_copy(value, "\"", "\\\"") + '"'; } -std::string Metric::FormatInfluxDBValue(const char* value) +std::string Metric::FormatInfluxDBValue(char const* value) { return FormatInfluxDBValue(std::string(value)); } diff --git a/src/common/Metric/Metric.h b/src/common/Metric/Metric.h index c09db7383de..d5085d27307 100644 --- a/src/common/Metric/Metric.h +++ b/src/common/Metric/Metric.h @@ -79,10 +79,10 @@ private: void ScheduleOverallStatusLog(); static std::string FormatInfluxDBValue(bool value); - template<class T> + template <class T> static std::string FormatInfluxDBValue(T value); static std::string FormatInfluxDBValue(std::string const& value); - static std::string FormatInfluxDBValue(const char* value); + static std::string FormatInfluxDBValue(char const* value); static std::string FormatInfluxDBValue(double value); static std::string FormatInfluxDBValue(float value); diff --git a/src/common/PrecompiledHeaders/commonPCH.h b/src/common/PrecompiledHeaders/commonPCH.h index fc9d8a0f6a7..614a2d18368 100644 --- a/src/common/PrecompiledHeaders/commonPCH.h +++ b/src/common/PrecompiledHeaders/commonPCH.h @@ -1,3 +1,20 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * 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/>. + */ + #include "BoundingIntervalHierarchy.h" #include "Common.h" #include "Config.h" diff --git a/src/common/Threading/ProcessPriority.cpp b/src/common/Threading/ProcessPriority.cpp index b72346dc4e7..3428a56258c 100644 --- a/src/common/Threading/ProcessPriority.cpp +++ b/src/common/Threading/ProcessPriority.cpp @@ -87,7 +87,9 @@ void SetProcessPriority(std::string const& logChannel, uint32 affinity, bool hig else TC_LOG_INFO(logChannel, "Process priority class set to %i", getpriority(PRIO_PROCESS, 0)); } + #else + // Suppresses unused argument warning for all other platforms (void)logChannel; (void)affinity; (void)highPriority; diff --git a/src/common/Utilities/Optional.h b/src/common/Utilities/Optional.h index e69d36c5a03..dc5cd970970 100644 --- a/src/common/Utilities/Optional.h +++ b/src/common/Utilities/Optional.h @@ -18,11 +18,8 @@ #ifndef TrinityCore_Optional_h__ #define TrinityCore_Optional_h__ +#include "OptionalFwd.h" #include <boost/optional.hpp> #include <boost/utility/in_place_factory.hpp> - //! Optional helper class to wrap optional values within. -template <typename T> -using Optional = boost::optional<T>; - #endif // TrinityCore_Optional_h__ diff --git a/src/common/Utilities/OptionalFwd.h b/src/common/Utilities/OptionalFwd.h new file mode 100644 index 00000000000..516ebeb772e --- /dev/null +++ b/src/common/Utilities/OptionalFwd.h @@ -0,0 +1,31 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * 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/>. + */ + +#ifndef OptionalFwd_h__ +#define OptionalFwd_h__ + +namespace boost +{ + template <class T> + class optional; +} + +//! Optional helper class to wrap optional values within. +template <class T> +using Optional = boost::optional<T>; + +#endif // OptionalFwd_h__ diff --git a/src/common/Utilities/StartProcess.cpp b/src/common/Utilities/StartProcess.cpp index e0c6f714e7e..160c6743a00 100644 --- a/src/common/Utilities/StartProcess.cpp +++ b/src/common/Utilities/StartProcess.cpp @@ -44,7 +44,7 @@ public: TCLogSink(T callback) : callback_(std::move(callback)) { } - std::streamsize write(const char* str, std::streamsize size) + std::streamsize write(char const* str, std::streamsize size) { callback_(std::string(str, size)); return size; diff --git a/src/common/Utilities/StartProcess.h b/src/common/Utilities/StartProcess.h index 6baf21e8957..71452315e77 100644 --- a/src/common/Utilities/StartProcess.h +++ b/src/common/Utilities/StartProcess.h @@ -62,7 +62,7 @@ TC_COMMON_API std::shared_ptr<AsyncProcessResult> bool secure = false); /// Searches for the given executable in the PATH variable -/// and returns a present optional when it was found. +/// and returns a non-empty string when it was found. TC_COMMON_API std::string SearchExecutableInPath(std::string const& filename); } // namespace Trinity diff --git a/src/common/Utilities/StringFormat.h b/src/common/Utilities/StringFormat.h index b7da2800c66..dd990c637e2 100644 --- a/src/common/Utilities/StringFormat.h +++ b/src/common/Utilities/StringFormat.h @@ -30,7 +30,7 @@ namespace Trinity } /// Returns true if the given char pointer is null. - inline bool IsFormatEmptyOrNull(const char* fmt) + inline bool IsFormatEmptyOrNull(char const* fmt) { return fmt == nullptr; } diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index 5a1ed443649..d5c1137cdd7 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -101,7 +101,7 @@ void stripLineInvisibleChars(std::string &str) } #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) -struct tm* localtime_r(const time_t* time, struct tm *result) +struct tm* localtime_r(time_t const* time, struct tm *result) { localtime_s(result, time); return result; @@ -131,7 +131,7 @@ std::string secsToTimeString(uint64 timeInSecs, bool shortText, bool hoursOnly) return ss.str(); } -int64 MoneyStringToMoney(const std::string& moneyString) +int64 MoneyStringToMoney(std::string const& moneyString) { int64 money = 0; @@ -162,7 +162,7 @@ int64 MoneyStringToMoney(const std::string& moneyString) return money; } -uint32 TimeStringToSecs(const std::string& timestring) +uint32 TimeStringToSecs(std::string const& timestring) { uint32 secs = 0; uint32 buffer = 0; diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h index 9592f36a7b7..308da01335d 100644 --- a/src/common/Utilities/Util.h +++ b/src/common/Utilities/Util.h @@ -57,12 +57,12 @@ private: TC_COMMON_API void stripLineInvisibleChars(std::string &src); -TC_COMMON_API int64 MoneyStringToMoney(const std::string& moneyString); +TC_COMMON_API int64 MoneyStringToMoney(std::string const& moneyString); -TC_COMMON_API struct tm* localtime_r(const time_t* time, struct tm *result); +TC_COMMON_API struct tm* localtime_r(time_t const* time, struct tm *result); TC_COMMON_API std::string secsToTimeString(uint64 timeInSecs, bool shortText = false, bool hoursOnly = false); -TC_COMMON_API uint32 TimeStringToSecs(const std::string& timestring); +TC_COMMON_API uint32 TimeStringToSecs(std::string const& timestring); TC_COMMON_API std::string TimeToTimestampStr(time_t t); // Percentage calculation @@ -401,7 +401,7 @@ public: part[3] = p4; } - inline bool operator <(const flag128 &right) const + inline bool operator<(flag128 const& right) const { for (uint8 i = 4; i > 0; --i) { @@ -413,7 +413,7 @@ public: return false; } - inline bool operator ==(const flag128 &right) const + inline bool operator==(flag128 const& right) const { return ( @@ -424,18 +424,17 @@ public: ); } - inline bool operator !=(const flag128 &right) const + inline bool operator!=(flag128 const& right) const { - return !this->operator ==(right); + return !(*this == right); } - inline flag128 operator &(const flag128 &right) const + inline flag128 operator&(flag128 const& right) const { - return flag128(part[0] & right.part[0], part[1] & right.part[1], - part[2] & right.part[2], part[3] & right.part[3]); + return flag128(part[0] & right.part[0], part[1] & right.part[1], part[2] & right.part[2], part[3] & right.part[3]); } - inline flag128 & operator &=(const flag128 &right) + inline flag128& operator&=(flag128 const& right) { part[0] &= right.part[0]; part[1] &= right.part[1]; @@ -444,13 +443,12 @@ public: return *this; } - inline flag128 operator |(const flag128 &right) const + inline flag128 operator|(flag128 const& right) const { - return flag128(part[0] | right.part[0], part[1] | right.part[1], - part[2] | right.part[2], part[3] | right.part[3]); + return flag128(part[0] | right.part[0], part[1] | right.part[1], part[2] | right.part[2], part[3] | right.part[3]); } - inline flag128 & operator |=(const flag128 &right) + inline flag128& operator |=(flag128 const& right) { part[0] |= right.part[0]; part[1] |= right.part[1]; @@ -459,18 +457,17 @@ public: return *this; } - inline flag128 operator ~() const + inline flag128 operator~() const { return flag128(~part[0], ~part[1], ~part[2], ~part[3]); } - inline flag128 operator ^(const flag128 &right) const + inline flag128 operator^(flag128 const& right) const { - return flag128(part[0] ^ right.part[0], part[1] ^ right.part[1], - part[2] ^ right.part[2], part[3] ^ right.part[3]); + return flag128(part[0] ^ right.part[0], part[1] ^ right.part[1], part[2] ^ right.part[2], part[3] ^ right.part[3]); } - inline flag128 & operator ^=(const flag128 &right) + inline flag128& operator^=(flag128 const& right) { part[0] ^= right.part[0]; part[1] ^= right.part[1]; @@ -486,15 +483,15 @@ public: inline bool operator !() const { - return !this->operator bool(); + return !(bool(*this)); } - inline uint32 & operator [](uint8 el) + inline uint32& operator[](uint8 el) { return part[el]; } - inline const uint32 & operator [](uint8 el) const + inline uint32 const& operator [](uint8 el) const { return part[el]; } |