Core/Misc: Port all the refactors sneaked in master to 3.3.5 include cleanup port

This commit is contained in:
Shauren
2020-09-04 13:38:24 +02:00
parent b20acfe701
commit b231903932
631 changed files with 2966 additions and 3263 deletions
@@ -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;
+10 -10
View File
@@ -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);
}
+3 -3
View File
@@ -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);
@@ -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;
@@ -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);
}
@@ -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);
+17
View File
@@ -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
+32 -32
View File
@@ -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;
+2 -2
View File
@@ -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;
};
+10 -10
View File
@@ -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);
+11 -11
View File
@@ -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;
+40 -38
View File
@@ -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
+6 -6
View File
@@ -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; }
+23 -3
View File
@@ -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)
+1 -1
View File
@@ -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();
@@ -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)
+3 -3
View File
@@ -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);
+1 -1
View File
@@ -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)
{
+1 -1
View File
@@ -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:
+3 -3
View File
@@ -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)
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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));
}
+2 -2
View File
@@ -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);
+17
View File
@@ -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"
+2
View File
@@ -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;
+1 -4
View File
@@ -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__
+31
View File
@@ -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__
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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;
}
+3 -3
View File
@@ -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;
+20 -23
View File
@@ -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];
}
+1 -1
View File
@@ -118,7 +118,7 @@ int main(int argc, char** argv)
{
TC_LOG_INFO("server.bnetserver", "%s", text);
},
[]()
[]()
{
TC_LOG_INFO("server.bnetserver", "Using configuration file %s.", sConfigMgr->GetFilename().c_str());
TC_LOG_INFO("server.bnetserver", "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
@@ -23,7 +23,7 @@
#include <cstring>
/*! Basic, ad-hoc queries. */
BasicStatementTask::BasicStatementTask(const char* sql, bool async) :
BasicStatementTask::BasicStatementTask(char const* sql, bool async) :
m_result(nullptr)
{
m_sql = strdup(sql);
@@ -26,14 +26,14 @@
class TC_DATABASE_API BasicStatementTask : public SQLOperation
{
public:
BasicStatementTask(const char* sql, bool async = false);
BasicStatementTask(char const* sql, bool async = false);
~BasicStatementTask();
bool Execute() override;
QueryResultFuture GetFuture() const { return m_result->get_future(); }
private:
const char* m_sql; //- Raw query to be executed
char const* m_sql; //- Raw query to be executed
bool m_has_result;
QueryResultPromise* m_result;
};
+2 -2
View File
@@ -21,9 +21,9 @@
#include "Define.h"
#include "DatabaseWorkerPool.h"
#include "Implementation/WorldDatabase.h"
#include "Implementation/CharacterDatabase.h"
#include "Implementation/LoginDatabase.h"
#include "Implementation/CharacterDatabase.h"
#include "Implementation/WorldDatabase.h"
#include "Implementation/HotfixDatabase.h"
#include "Field.h"
@@ -184,6 +184,6 @@ DatabaseLoader& DatabaseLoader::AddDatabase<LoginDatabaseConnection>(DatabaseWor
template TC_DATABASE_API
DatabaseLoader& DatabaseLoader::AddDatabase<CharacterDatabaseConnection>(DatabaseWorkerPool<CharacterDatabaseConnection>&, std::string const&);
template TC_DATABASE_API
DatabaseLoader& DatabaseLoader::AddDatabase<HotfixDatabaseConnection>(DatabaseWorkerPool<HotfixDatabaseConnection>&, std::string const&);
template TC_DATABASE_API
DatabaseLoader& DatabaseLoader::AddDatabase<WorldDatabaseConnection>(DatabaseWorkerPool<WorldDatabaseConnection>&, std::string const&);
template TC_DATABASE_API
DatabaseLoader& DatabaseLoader::AddDatabase<HotfixDatabaseConnection>(DatabaseWorkerPool<HotfixDatabaseConnection>&, std::string const&);
@@ -25,7 +25,7 @@
#include <stack>
#include <string>
template<class T>
template <class T>
class DatabaseWorkerPool;
// A helper class to initiate all database worker pools,
@@ -167,7 +167,7 @@ bool DatabaseWorkerPool<T>::PrepareStatements()
}
template <class T>
QueryResult DatabaseWorkerPool<T>::Query(const char* sql, T* connection /*= nullptr*/)
QueryResult DatabaseWorkerPool<T>::Query(char const* sql, T* connection /*= nullptr*/)
{
if (!connection)
connection = GetFreeConnection();
@@ -203,7 +203,7 @@ PreparedQueryResult DatabaseWorkerPool<T>::Query(PreparedStatement<T>* stmt)
}
template <class T>
QueryCallback DatabaseWorkerPool<T>::AsyncQuery(const char* sql)
QueryCallback DatabaseWorkerPool<T>::AsyncQuery(char const* sql)
{
BasicStatementTask* task = new BasicStatementTask(sql, true);
// Store future result before enqueueing - task might get already processed and deleted before returning from this method
@@ -395,7 +395,7 @@ uint32 DatabaseWorkerPool<T>::OpenConnections(InternalIndex type, uint8 numConne
}
template <class T>
unsigned long DatabaseWorkerPool<T>::EscapeString(char *to, const char *from, unsigned long length)
unsigned long DatabaseWorkerPool<T>::EscapeString(char* to, char const* from, unsigned long length)
{
if (!to || !from || !length)
return 0;
@@ -434,7 +434,7 @@ char const* DatabaseWorkerPool<T>::GetDatabaseName() const
}
template <class T>
void DatabaseWorkerPool<T>::Execute(const char* sql)
void DatabaseWorkerPool<T>::Execute(char const* sql)
{
if (Trinity::IsFormatEmptyOrNull(sql))
return;
@@ -451,7 +451,7 @@ void DatabaseWorkerPool<T>::Execute(PreparedStatement<T>* stmt)
}
template <class T>
void DatabaseWorkerPool<T>::DirectExecute(const char* sql)
void DatabaseWorkerPool<T>::DirectExecute(char const* sql)
{
if (Trinity::IsFormatEmptyOrNull(sql))
return;
@@ -473,7 +473,7 @@ void DatabaseWorkerPool<T>::DirectExecute(PreparedStatement<T>* stmt)
}
template <class T>
void DatabaseWorkerPool<T>::ExecuteOrAppend(SQLTransaction<T>& trans, const char* sql)
void DatabaseWorkerPool<T>::ExecuteOrAppend(SQLTransaction<T>& trans, char const* sql)
{
if (!trans)
Execute(sql);
@@ -68,7 +68,7 @@ class DatabaseWorkerPool
//! Enqueues a one-way SQL operation in string format that will be executed asynchronously.
//! This method should only be used for queries that are only executed once, e.g during startup.
void Execute(const char* sql);
void Execute(char const* sql);
//! Enqueues a one-way SQL operation in string format -with variable args- that will be executed asynchronously.
//! This method should only be used for queries that are only executed once, e.g during startup.
@@ -91,7 +91,7 @@ class DatabaseWorkerPool
//! Directly executes a one-way SQL operation in string format, that will block the calling thread until finished.
//! This method should only be used for queries that are only executed once, e.g during startup.
void DirectExecute(const char* sql);
void DirectExecute(char const* sql);
//! Directly executes a one-way SQL operation in string format -with variable args-, that will block the calling thread until finished.
//! This method should only be used for queries that are only executed once, e.g during startup.
@@ -114,7 +114,7 @@ class DatabaseWorkerPool
//! Directly executes an SQL query in string format that will block the calling thread until finished.
//! Returns reference counted auto pointer, no need for manual memory management in upper level code.
QueryResult Query(const char* sql, T* connection = nullptr);
QueryResult Query(char const* sql, T* connection = nullptr);
//! Directly executes an SQL query in string format -with variable args- that will block the calling thread until finished.
//! Returns reference counted auto pointer, no need for manual memory management in upper level code.
@@ -149,7 +149,7 @@ class DatabaseWorkerPool
//! Enqueues a query in string format that will set the value of the QueryResultFuture return object as soon as the query is executed.
//! The return value is then processed in ProcessQueryCallback methods.
QueryCallback AsyncQuery(const char* sql);
QueryCallback AsyncQuery(char const* sql);
//! Enqueues a query in prepared format that will set the value of the PreparedQueryResultFuture return object as soon as the query is executed.
//! The return value is then processed in ProcessQueryCallback methods.
@@ -183,7 +183,7 @@ class DatabaseWorkerPool
//! Method used to execute ad-hoc statements in a diverse context.
//! Will be wrapped in a transaction if valid object is present, otherwise executed standalone.
void ExecuteOrAppend(SQLTransaction<T>& trans, const char* sql);
void ExecuteOrAppend(SQLTransaction<T>& trans, char const* sql);
//! Method used to execute prepared statements in a diverse context.
//! Will be wrapped in a transaction if valid object is present, otherwise executed standalone.
@@ -209,7 +209,7 @@ class DatabaseWorkerPool
private:
uint32 OpenConnections(InternalIndex type, uint8 numConnections);
unsigned long EscapeString(char *to, const char *from, unsigned long length);
unsigned long EscapeString(char* to, char const* from, unsigned long length);
void Enqueue(SQLOperation* op);
@@ -165,7 +165,7 @@ bool MySQLConnection::PrepareStatements()
return !m_prepareError;
}
bool MySQLConnection::Execute(const char* sql)
bool MySQLConnection::Execute(char const* sql)
{
if (!m_Mysql)
return false;
@@ -294,7 +294,7 @@ bool MySQLConnection::_Query(PreparedStatementBase* stmt, MySQLResult** pResult,
return true;
}
ResultSet* MySQLConnection::Query(const char* sql)
ResultSet* MySQLConnection::Query(char const* sql)
{
if (!sql)
return nullptr;
@@ -394,7 +394,7 @@ int MySQLConnection::ExecuteTransaction(std::shared_ptr<TransactionBase> transac
break;
case SQL_ELEMENT_RAW:
{
const char* sql = data.element.query;
char const* sql = data.element.query;
ASSERT(sql);
if (!Execute(sql))
{
@@ -66,11 +66,11 @@ class TC_DATABASE_API MySQLConnection
bool PrepareStatements();
bool Execute(const char* sql);
bool Execute(char const* sql);
bool Execute(PreparedStatementBase* stmt);
ResultSet* Query(const char* sql);
ResultSet* Query(char const* sql);
PreparedResultSet* Query(PreparedStatementBase* stmt);
bool _Query(const char* sql, MySQLResult** pResult, MySQLField** pFields, uint64* pRowCount, uint32* pFieldCount);
bool _Query(char const* sql, MySQLResult** pResult, MySQLField** pFields, uint64* pRowCount, uint32* pFieldCount);
bool _Query(PreparedStatementBase* stmt, MySQLResult** pResult, uint64* pRowCount, uint32* pFieldCount);
void BeginTransaction();
@@ -83,6 +83,7 @@ class TC_DATABASE_API PreparedStatementBase
explicit PreparedStatementBase(uint32 index, uint8 capacity);
virtual ~PreparedStatementBase();
void setNull(const uint8 index);
void setBool(const uint8 index, const bool value);
void setUInt8(const uint8 index, const uint8 value);
void setUInt16(const uint8 index, const uint16 value);
@@ -102,7 +103,6 @@ class TC_DATABASE_API PreparedStatementBase
std::vector<uint8> vec(value.begin(), value.end());
setBinary(index, vec);
}
void setNull(const uint8 index);
uint32 GetIndex() const { return m_index; }
+1 -1
View File
@@ -85,7 +85,7 @@ bool SQLQueryHolderTask::Execute()
return false;
/// execute all queries in the holder and pass the results
for (size_t i = 0; i < m_holder->m_queries.size(); i++)
for (size_t i = 0; i < m_holder->m_queries.size(); ++i)
if (PreparedStatementBase* stmt = m_holder->m_queries[i].first)
m_holder->SetPreparedResult(i, m_conn->Query(stmt));
+1 -1
View File
@@ -25,7 +25,7 @@
union SQLElementUnion
{
PreparedStatementBase* stmt;
const char* query;
char const* query;
};
//- Type specifier of our element data
+2 -2
View File
@@ -23,7 +23,7 @@
std::mutex TransactionTask::_deadlockLock;
//- Append a raw ad-hoc query to the transaction
void TransactionBase::Append(const char* sql)
void TransactionBase::Append(char const* sql)
{
SQLElementData data;
data.type = SQL_ELEMENT_RAW;
@@ -46,7 +46,7 @@ void TransactionBase::Cleanup()
if (_cleanedUp)
return;
for (SQLElementData const &data : m_queries)
for (SQLElementData const& data : m_queries)
{
switch (data.type)
{
+1 -1
View File
@@ -39,7 +39,7 @@ class TC_DATABASE_API TransactionBase
TransactionBase() : _cleanedUp(false) { }
virtual ~TransactionBase() { Cleanup(); }
void Append(const char* sql);
void Append(char const* sql);
template<typename Format, typename... Args>
void PAppend(Format&& sql, Args&&... args)
{
@@ -1,15 +1,29 @@
/*
* 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 "Define.h"
#include "Errors.h"
#include "Field.h"
#include "Log.h"
#include "MySQLConnection.h"
#include "MySQLWorkaround.h"
#include "PreparedStatement.h"
#include "QueryResult.h"
#include "SQLOperation.h"
#include "Transaction.h"
#ifdef _WIN32 // hack for broken mysql.h not including the correct winsock header for SOCKET definition, fixed in 5.7
#include <winsock2.h>
#endif
#include <mysql.h>
#include <string>
#include <vector>
@@ -34,7 +34,6 @@ struct UpdateFetcher::DirectoryEntry
DirectoryEntry(Path const& path_, State state_) : path(path_), state(state_) { }
Path const path;
State const state;
};
+1 -1
View File
@@ -248,7 +248,7 @@ TurretAI::TurretAI(Creature* c) : CreatureAI(c)
me->m_SightDistance = me->m_CombatDistance;
}
bool TurretAI::CanAIAttack(const Unit* /*who*/) const
bool TurretAI::CanAIAttack(Unit const* /*who*/) const
{
/// @todo use one function to replace it
if (!me->IsWithinCombatRange(me->GetVictim(), me->m_CombatDistance)
+3 -3
View File
@@ -46,7 +46,7 @@ class TC_GAME_API GameObjectAI
virtual void SetGUID(uint64 /*guid*/, int32 /*id = 0 */) { }
virtual uint64 GetGUID(int32 /*id = 0 */) const { return 0; }
static int32 Permissible(GameObject const* /*go*/);
static int32 Permissible(GameObject const* go);
// Called when a player opens a gossip dialog with the gameobject.
virtual bool GossipHello(Player* /*player*/) { return false; }
@@ -82,7 +82,7 @@ class TC_GAME_API GameObjectAI
virtual void OnLootStateChanged(uint32 /*state*/, Unit* /*unit*/) { }
virtual void OnStateChanged(uint32 /*state*/) { }
virtual void EventInform(uint32 /*eventId*/) { }
virtual void SpellHit(Unit* /*unit*/, const SpellInfo* /*spellInfo*/) { }
virtual void SpellHit(Unit* /*unit*/, SpellInfo const* /*spellInfo*/) { }
};
class TC_GAME_API NullGameObjectAI : public GameObjectAI
@@ -92,6 +92,6 @@ class TC_GAME_API NullGameObjectAI : public GameObjectAI
void UpdateAI(uint32 /*diff*/) override { }
static int32 Permissible(GameObject const* /*go*/);
static int32 Permissible(GameObject const* go);
};
#endif
+9 -9
View File
@@ -28,7 +28,7 @@
#define ENSURE_AI(a,b) (EnsureAI<a>(b))
template<class T, class U>
inline T* EnsureAI(U* ai)
T* EnsureAI(U* ai)
{
T* cast_ai = dynamic_cast<T*>(ai);
ASSERT(cast_ai);
@@ -74,7 +74,7 @@ struct TC_GAME_API DefaultTargetSelector
// Target selector for spell casts checking range, auras and attributes
/// @todo Add more checks from Spell::CheckCast
struct TC_GAME_API SpellTargetSelector : public std::unary_function<Unit*, bool>
struct TC_GAME_API SpellTargetSelector
{
public:
SpellTargetSelector(Unit* caster, uint32 spellId);
@@ -88,7 +88,7 @@ struct TC_GAME_API SpellTargetSelector : public std::unary_function<Unit*, bool>
// Very simple target selector, will just skip main target
// NOTE: When passing to UnitAI::SelectTarget remember to use 0 as position for random selection
// because tank will not be in the temporary list
struct TC_GAME_API NonTankTargetSelector : public std::unary_function<Unit*, bool>
struct TC_GAME_API NonTankTargetSelector
{
public:
NonTankTargetSelector(Unit* source, bool playerOnly = true) : _source(source), _playerOnly(playerOnly) { }
@@ -119,11 +119,11 @@ public:
FarthestTargetSelector(Unit const* unit, float dist, bool playerOnly, bool inLos) : _me(unit), _dist(dist), _playerOnly(playerOnly), _inLos(inLos) {}
bool operator()(Unit const* target) const;
private:
const Unit* _me;
float _dist;
bool _playerOnly;
bool _inLos;
private:
Unit const* _me;
float _dist;
bool _playerOnly;
bool _inLos;
};
class TC_GAME_API UnitAI
@@ -315,7 +315,7 @@ class TC_GAME_API UnitAI
virtual bool GossipSelect(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/) { return false; }
// Called when a player selects a gossip with a code in the creature's gossip menu.
virtual bool GossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, const char* /*code*/) { return false; }
virtual bool GossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, char const* /*code*/) { return false; }
// Called when a player accepts a quest from the creature.
virtual void QuestAccept(Player* /*player*/, Quest const* /*quest*/) { }
+1 -1
View File
@@ -393,7 +393,7 @@ bool CreatureAI::CheckInRoom()
}
}
Creature* CreatureAI::DoSummon(uint32 entry, const Position& pos, uint32 despawnTime, TempSummonType summonType)
Creature* CreatureAI::DoSummon(uint32 entry, Position const& pos, uint32 despawnTime, TempSummonType summonType)
{
return me->SummonCreature(entry, pos, summonType, despawnTime);
}
+3
View File
@@ -21,6 +21,9 @@
#include "ObjectRegistry.h"
#include "FactoryHolder.h"
class Creature;
class CreatureAI;
typedef FactoryHolder<CreatureAI, Creature> CreatureAICreator;
struct SelectableAI : public CreatureAICreator, public Permissible<Creature>
+2 -2
View File
@@ -93,8 +93,8 @@ AISpellInfoType* GetAISpellInfo(uint32 spellId, Difficulty difficulty);
TC_GAME_API bool InstanceHasScript(WorldObject const* obj, char const* scriptName);
template<class AI, class T>
inline AI* GetInstanceAI(T* obj, char const* scriptName)
template <class AI, class T>
AI* GetInstanceAI(T* obj, char const* scriptName)
{
if (InstanceHasScript(obj, scriptName))
return new AI(obj);
+11 -10
View File
@@ -15,19 +15,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PassiveAI.h"
#include "ReactorAI.h"
#include "CombatAI.h"
#include "GuardAI.h"
#include "PetAI.h"
#include "TotemAI.h"
#include "RandomMovementGenerator.h"
#include "MovementGenerator.h"
#include "CreatureAIRegistry.h"
#include "WaypointMovementGenerator.h"
#include "CreatureAIFactory.h"
#include "GameObjectAIFactory.h"
#include "CombatAI.h"
#include "GuardAI.h"
#include "PassiveAI.h"
#include "PetAI.h"
#include "ReactorAI.h"
#include "SmartAI.h"
#include "TotemAI.h"
#include "MovementGenerator.h"
#include "RandomMovementGenerator.h"
#include "WaypointMovementGenerator.h"
namespace AIRegistry
{
+1
View File
@@ -30,6 +30,7 @@ class TC_GAME_API PlayerAI : public UnitAI
void OnCharmed(bool /*apply*/) override { } // charm AI application for players is handled by Unit::SetCharmedBy / Unit::RemoveCharmedBy
Creature* GetCharmer() const;
// helper functions to determine player info
uint16 GetSpec(Player const* who = nullptr) const;
static bool IsPlayerHealer(Player const* who);
@@ -548,7 +548,7 @@ bool BossAI::CanAIAttack(Unit const* target) const
return CheckBoundary(target);
}
void BossAI::_DespawnAtEvade(Seconds delayToRespawn, Creature* who)
void BossAI::_DespawnAtEvade(Seconds delayToRespawn /*= 30s*/, Creature* who /*= nullptr*/)
{
if (delayToRespawn < Seconds(2))
{
@@ -566,7 +566,7 @@ void BossAI::_DespawnAtEvade(Seconds delayToRespawn, Creature* who)
return;
}
who->DespawnOrUnsummon(0, Seconds(delayToRespawn));
who->DespawnOrUnsummon(0, delayToRespawn);
if (instance && who == me)
instance->SetBossState(_bossId, FAIL);
@@ -19,7 +19,7 @@
#define SCRIPTEDCREATURE_H_
#include "CreatureAI.h"
#include "Creature.h" // convenience include for scripts, all uses of ScriptedCreature also need Creature (except ScriptedCreature itself doesn't need Creature)
#include "Creature.h" // convenience include for scripts, all uses of ScriptedCreature also need Creature (except ScriptedCreature itself doesn't need Creature)
#include "DBCEnums.h"
#include "TaskScheduler.h"
@@ -90,7 +90,7 @@ public:
void DespawnAll();
template <typename T>
void DespawnIf(T const &predicate)
void DespawnIf(T const& predicate)
{
storage_.remove_if(predicate);
}
@@ -364,7 +364,7 @@ class TC_GAME_API BossAI : public ScriptedAI
void _EnterCombat();
void _JustDied();
void _JustReachedHome();
void _DespawnAtEvade(Seconds delayToRespawn, Creature* who = nullptr);
void _DespawnAtEvade(Seconds delayToRespawn, Creature* who = nullptr);
void _DespawnAtEvade(uint32 delayToRespawn = 30, Creature* who = nullptr) { _DespawnAtEvade(Seconds(delayToRespawn), who); }
void TeleportCheaters();
@@ -109,11 +109,9 @@ void EscortAI::JustDied(Unit* /*killer*/)
if (Group* group = player->GetGroup())
{
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
{
if (Player* member = groupRef->GetSource())
if (member->IsInMap(player))
member->FailQuest(_escortQuest->GetQuestId());
}
}
else
player->FailQuest(_escortQuest->GetQuestId());
@@ -170,11 +168,9 @@ bool EscortAI::IsPlayerOrGroupInRange()
if (Group* group = player->GetGroup())
{
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
{
if (Player* member = groupRef->GetSource())
if (me->IsWithinDistInMap(member, GetMaxPlayerDistance()))
return true;
}
}
else if (me->IsWithinDistInMap(player, GetMaxPlayerDistance()))
return true;
@@ -270,7 +270,7 @@ void FollowerAI::MovementInform(uint32 motionType, uint32 pointId)
}
}
void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, const Quest* quest)
void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, Quest const* quest)
{
if (me->GetVictim())
{
@@ -55,7 +55,7 @@ class TC_GAME_API FollowerAI : public ScriptedAI
void UpdateAI(uint32) override; //the "internal" update, calls UpdateFollowerAI()
virtual void UpdateFollowerAI(uint32); //used when it's needed to add code in update (abilities, scripted events, etc)
void StartFollow(Player* player, uint32 factionForFollower = 0, const Quest* quest = nullptr);
void StartFollow(Player* player, uint32 factionForFollower = 0, Quest const* quest = nullptr);
void SetFollowPaused(bool bPaused); //if special event require follow mode to hold/resume during the follow
void SetFollowComplete(bool bWithEndEvent = false);
@@ -75,7 +75,7 @@ class TC_GAME_API FollowerAI : public ScriptedAI
uint32 m_uiUpdateFollowTimer;
uint32 m_uiFollowState;
const Quest* m_pQuestForFollow; //normally we have a quest
Quest const* m_pQuestForFollow; //normally we have a quest
};
#endif
+6 -6
View File
@@ -494,7 +494,7 @@ void SmartAI::MoveInLineOfSight(Unit* who)
CreatureAI::MoveInLineOfSight(who);
}
bool SmartAI::CanAIAttack(const Unit* /*who*/) const
bool SmartAI::CanAIAttack(Unit const* /*who*/) const
{
return !(me->HasReactState(REACT_PASSIVE));
}
@@ -635,12 +635,12 @@ void SmartAI::AttackStart(Unit* who)
}
}
void SmartAI::SpellHit(Unit* unit, const SpellInfo* spellInfo)
void SmartAI::SpellHit(Unit* unit, SpellInfo const* spellInfo)
{
GetScript()->ProcessEventsFor(SMART_EVENT_SPELLHIT, unit, 0, 0, false, spellInfo);
}
void SmartAI::SpellHitTarget(Unit* target, const SpellInfo* spellInfo)
void SmartAI::SpellHitTarget(Unit* target, SpellInfo const* spellInfo)
{
GetScript()->ProcessEventsFor(SMART_EVENT_SPELLHIT_TARGET, target, 0, 0, false, spellInfo);
}
@@ -788,7 +788,7 @@ bool SmartAI::GossipSelect(Player* player, uint32 menuId, uint32 gossipListId)
return _gossipReturn;
}
bool SmartAI::GossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, const char* /*code*/)
bool SmartAI::GossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, char const* /*code*/)
{
return false;
}
@@ -967,7 +967,7 @@ bool SmartGameObjectAI::GossipSelect(Player* player, uint32 sender, uint32 actio
}
// Called when a player selects a gossip with a code in the gameobject's gossip menu.
bool SmartGameObjectAI::GossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, const char* /*code*/)
bool SmartGameObjectAI::GossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, char const* /*code*/)
{
return false;
}
@@ -1017,7 +1017,7 @@ void SmartGameObjectAI::EventInform(uint32 eventId)
GetScript()->ProcessEventsFor(SMART_EVENT_GO_EVENT_INFORM, nullptr, eventId);
}
void SmartGameObjectAI::SpellHit(Unit* unit, const SpellInfo* spellInfo)
void SmartGameObjectAI::SpellHit(Unit* unit, SpellInfo const* spellInfo)
{
GetScript()->ProcessEventsFor(SMART_EVENT_SPELLHIT, unit, 0, 0, false, spellInfo);
}
+6 -6
View File
@@ -102,10 +102,10 @@ class TC_GAME_API SmartAI : public CreatureAI
void MoveInLineOfSight(Unit* who) override;
// Called when hit by a spell
void SpellHit(Unit* unit, const SpellInfo* spellInfo) override;
void SpellHit(Unit* unit, SpellInfo const* spellInfo) override;
// Called when spell hits a target
void SpellHitTarget(Unit* target, const SpellInfo* spellInfo) override;
void SpellHitTarget(Unit* target, SpellInfo const* spellInfo) override;
// Called at any Damage from any attacker (before damage apply)
void DamageTaken(Unit* doneBy, uint32& damage) override;
@@ -144,7 +144,7 @@ class TC_GAME_API SmartAI : public CreatureAI
void OnCharmed(bool apply) override;
// Called when victim is in line of sight
bool CanAIAttack(const Unit* who) const override;
bool CanAIAttack(Unit const* who) const override;
// Used in scripts to share variables
void DoAction(int32 param = 0) override;
@@ -176,7 +176,7 @@ class TC_GAME_API SmartAI : public CreatureAI
bool GossipHello(Player* player) override;
bool GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override;
bool GossipSelectCode(Player* player, uint32 menuId, uint32 gossipListId, const char* code) override;
bool GossipSelectCode(Player* player, uint32 menuId, uint32 gossipListId, char const* code) override;
void QuestAccept(Player* player, Quest const* quest) override;
void QuestReward(Player* player, Quest const* quest, uint32 opt) override;
void OnGameEvent(bool start, uint16 eventId) override;
@@ -263,7 +263,7 @@ class TC_GAME_API SmartGameObjectAI : public GameObjectAI
bool GossipHello(Player* player) override;
bool OnReportUse(Player* player) override;
bool GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override;
bool GossipSelectCode(Player* player, uint32 menuId, uint32 gossipListId, const char* code) override;
bool GossipSelectCode(Player* player, uint32 menuId, uint32 gossipListId, char const* code) override;
void QuestAccept(Player* player, Quest const* quest) override;
void QuestReward(Player* player, Quest const* quest, uint32 opt) override;
void Destroyed(Player* player, uint32 eventId) override;
@@ -272,7 +272,7 @@ class TC_GAME_API SmartGameObjectAI : public GameObjectAI
void OnGameEvent(bool start, uint16 eventId) override;
void OnLootStateChanged(uint32 state, Unit* unit) override;
void EventInform(uint32 eventId) override;
void SpellHit(Unit* unit, const SpellInfo* spellInfo) override;
void SpellHit(Unit* unit, SpellInfo const* spellInfo) override;
void SetGossipReturn(bool val) { _gossipReturn = val; }
@@ -172,6 +172,7 @@ void SmartScript::ResetBaseObject()
go = nullptr;
}
}
if (!goOrigGUID.IsEmpty())
{
if (GameObject* o = ObjectAccessor::GetGameObject(*lookupRoot, goOrigGUID))
@@ -185,7 +186,7 @@ void SmartScript::ResetBaseObject()
meOrigGUID.Clear();
}
void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob, std::string const& varString)
void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint32 var1, bool bvar, SpellInfo const* spell, GameObject* gob, std::string const& varString)
{
for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
{
@@ -199,7 +200,7 @@ void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint3
}
}
void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob, std::string const& varString)
void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, uint32 var1, bool bvar, SpellInfo const* spell, GameObject* gob, std::string const& varString)
{
// calc random
if (e.GetEventType() != SMART_EVENT_LINK && e.event.event_chance < 100 && e.event.event_chance)
@@ -2351,7 +2352,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
}
void SmartScript::ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob, std::string const& varString)
void SmartScript::ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit, uint32 var0, uint32 var1, bool bvar, SpellInfo const* spell, GameObject* gob, std::string const& varString)
{
// We may want to execute action rarely and because of this if condition is not fulfilled the action will be rechecked in a long time
if (sConditionMgr->IsObjectMeetingSmartEventConditions(e.entryOrGuid, e.event_id, e.source_type, unit, GetBaseObject()))
@@ -2829,7 +2830,7 @@ void SmartScript::GetWorldObjectsInDist(ObjectVector& targets, float dist) const
Cell::VisitAllObjects(obj, searcher, dist);
}
void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob, std::string const& varString)
void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, uint32 var1, bool bvar, SpellInfo const* spell, GameObject* gob, std::string const& varString)
{
if (!e.active && e.GetEventType() != SMART_EVENT_LINK)
return;
@@ -40,14 +40,14 @@ class TC_GAME_API SmartScript
void GetScript();
void FillScript(SmartAIEventList e, WorldObject* obj, AreaTriggerEntry const* at, SceneTemplate const* scene);
void ProcessEventsFor(SMART_EVENT e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = "");
void ProcessEvent(SmartScriptHolder& e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = "");
void ProcessEventsFor(SMART_EVENT e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, SpellInfo const* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = "");
void ProcessEvent(SmartScriptHolder& e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, SpellInfo const* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = "");
bool CheckTimer(SmartScriptHolder const& e) const;
static void RecalcTimer(SmartScriptHolder& e, uint32 min, uint32 max);
void UpdateTimer(SmartScriptHolder& e, uint32 const diff);
static void InitTimer(SmartScriptHolder& e);
void ProcessAction(SmartScriptHolder& e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = "");
void ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = "");
void ProcessAction(SmartScriptHolder& e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, SpellInfo const* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = "");
void ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, SpellInfo const* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = "");
void GetTargets(ObjectVector& targets, SmartScriptHolder const& e, Unit* invoker = nullptr) const;
void GetWorldObjectsInDist(ObjectVector& objects, float dist) const;
void InstallTemplate(SmartScriptHolder const& e);
@@ -55,7 +55,6 @@ class TC_GAME_API SmartScript
void AddEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, uint32 event_param5, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 phaseMask = 0);
void SetPathId(uint32 id) { mPathId = id; }
uint32 GetPathId() const { return mPathId; }
WorldObject* GetBaseObject() const;
WorldObject* GetBaseObjectOrUnit(Unit* unit);
static bool IsUnit(WorldObject* obj);
@@ -16,8 +16,8 @@
*/
#include "SmartScriptMgr.h"
#include "DB2Stores.h"
#include "CreatureTextMgr.h"
#include "DB2Stores.h"
#include "DatabaseEnv.h"
#include "GameEventMgr.h"
#include "InstanceScript.h"
@@ -1630,31 +1630,22 @@ class TC_GAME_API SmartAIMgr
bool IsEventValid(SmartScriptHolder& e);
bool IsTargetValid(SmartScriptHolder const& e);
bool IsMinMaxValid(SmartScriptHolder const& e, uint32 min, uint32 max);
/*inline bool IsPercentValid(SmartScriptHolder e, int32 pct)
{
if (pct < -100 || pct > 100)
{
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry %d SourceType %u Event %u Action %u has invalid Percent set (%d), skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), pct);
return false;
}
return true;
}*/
bool NotNULL(SmartScriptHolder const& e, uint32 data);
bool IsCreatureValid(SmartScriptHolder const& e, uint32 entry);
bool IsQuestValid(SmartScriptHolder const& e, uint32 entry);
bool IsGameObjectValid(SmartScriptHolder const& e, uint32 entry);
bool IsSpellValid(SmartScriptHolder const& e, uint32 entry);
bool IsItemValid(SmartScriptHolder const& e, uint32 entry);
bool IsTextEmoteValid(SmartScriptHolder const& e, uint32 entry);
bool IsEmoteValid(SmartScriptHolder const& e, uint32 entry);
bool IsAreaTriggerValid(SmartScriptHolder const& e, uint32 entry);
bool IsSoundValid(SmartScriptHolder const& e, uint32 entry);
bool IsAnimKitValid(SmartScriptHolder const& e, uint32 entry);
bool IsSpellVisualKitValid(SmartScriptHolder const& e, uint32 entry);
bool IsTextValid(SmartScriptHolder const& e, uint32 id);
static bool NotNULL(SmartScriptHolder const& e, uint32 data);
static bool IsCreatureValid(SmartScriptHolder const& e, uint32 entry);
static bool IsQuestValid(SmartScriptHolder const& e, uint32 entry);
static bool IsGameObjectValid(SmartScriptHolder const& e, uint32 entry);
static bool IsSpellValid(SmartScriptHolder const& e, uint32 entry);
static bool IsItemValid(SmartScriptHolder const& e, uint32 entry);
static bool IsTextEmoteValid(SmartScriptHolder const& e, uint32 entry);
static bool IsEmoteValid(SmartScriptHolder const& e, uint32 entry);
static bool IsAreaTriggerValid(SmartScriptHolder const& e, uint32 entry);
static bool IsSoundValid(SmartScriptHolder const& e, uint32 entry);
static bool IsAnimKitValid(SmartScriptHolder const& e, uint32 entry);
static bool IsSpellVisualKitValid(SmartScriptHolder const& e, uint32 entry);
static bool IsTextValid(SmartScriptHolder const& e, uint32 id);
// Helpers
void LoadHelperStores();
@@ -214,8 +214,8 @@ public:
static AuctionBotConfig* instance();
bool Initialize();
const std::string& GetAHBotIncludes() const { return _AHBotIncludes; }
const std::string& GetAHBotExcludes() const { return _AHBotExcludes; }
std::string const& GetAHBotIncludes() const { return _AHBotIncludes; }
std::string const& GetAHBotExcludes() const { return _AHBotExcludes; }
uint32 GetConfig(AuctionBotConfigUInt32Values index) const { return _configUint32Values[index]; }
bool GetConfig(AuctionBotConfigBoolValues index) const { return _configBoolValues[index]; }
@@ -317,7 +317,7 @@ void AuctionBotBuyer::BuyAndBidItems(BuyerConfiguration& config)
bidPrice = auction->MinBid;
}
const BuyerItemInfo* ahInfo = nullptr;
BuyerItemInfo const* ahInfo = nullptr;
BuyerItemInfoMap::const_iterator sameItemItr = config.SameItemInfo.find(auction->Bucket->Key.ItemId);
if (sameItemItr != config.SameItemInfo.end())
ahInfo = &sameItemItr->second;
@@ -109,7 +109,6 @@ bool AuctionBotSeller::Initialize()
for (uint32 itemId = 0; itemId < sItemStore.GetNumRows(); ++itemId)
{
ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(itemId);
if (!prototype)
continue;
+2 -2
View File
@@ -588,7 +588,7 @@ BfGraveyard* Battlefield::GetGraveyardById(uint32 id) const
return nullptr;
}
WorldSafeLocsEntry const* Battlefield::GetClosestGraveYard(Player* player)
WorldSafeLocsEntry const* Battlefield::GetClosestGraveyard(Player* player)
{
BfGraveyard* closestGY = nullptr;
float maxdist = -1;
@@ -762,7 +762,7 @@ void BfGraveyard::RelocateDeadPlayers()
player->TeleportTo(closestGrave->Loc);
else
{
closestGrave = m_Bf->GetClosestGraveYard(player);
closestGrave = m_Bf->GetClosestGraveyard(player);
if (closestGrave)
player->TeleportTo(closestGrave->Loc);
}
+1 -1
View File
@@ -300,7 +300,7 @@ class TC_GAME_API Battlefield : public ZoneScript
// Graveyard methods
// Find which graveyard the player must be teleported to to be resurrected by spiritguide
WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player);
virtual void AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid);
void RemovePlayerFromResurrectQueue(ObjectGuid player_guid);
@@ -45,7 +45,7 @@ struct BfWGCoordGY
};
// 7 in sql, 7 in header
BfWGCoordGY const WGGraveYard[BATTLEFIELD_WG_GRAVEYARD_MAX] =
BfWGCoordGY const WGGraveyard[BATTLEFIELD_WG_GRAVEYARD_MAX] =
{
{ { 5104.750f, 2300.940f, 368.579f, 0.733038f }, 1329, BATTLEFIELD_WG_GOSSIPTEXT_GY_NE, TEAM_NEUTRAL },
{ { 5099.120f, 3466.036f, 368.484f, 5.317802f }, 1330, BATTLEFIELD_WG_GOSSIPTEXT_GY_NW, TEAM_NEUTRAL },
@@ -436,7 +436,7 @@ bool BattlefieldWG::SetupBattlefield()
m_saveTimer = 60000;
// Init GraveYards
// Init Graveyards
SetGraveyardNumber(BATTLEFIELD_WG_GRAVEYARD_MAX);
// Load from db
@@ -468,12 +468,12 @@ bool BattlefieldWG::SetupBattlefield()
BfGraveyardWG* graveyard = new BfGraveyardWG(this);
// When between games, the graveyard is controlled by the defending team
if (WGGraveYard[i].StartControl == TEAM_NEUTRAL)
graveyard->Initialize(m_DefenderTeam, WGGraveYard[i].GraveyardID);
if (WGGraveyard[i].StartControl == TEAM_NEUTRAL)
graveyard->Initialize(m_DefenderTeam, WGGraveyard[i].GraveyardID);
else
graveyard->Initialize(WGGraveYard[i].StartControl, WGGraveYard[i].GraveyardID);
graveyard->Initialize(WGGraveyard[i].StartControl, WGGraveyard[i].GraveyardID);
graveyard->SetTextId(WGGraveYard[i].TextID);
graveyard->SetTextId(WGGraveyard[i].TextID);
m_GraveyardList[i] = graveyard;
}
+1 -1
View File
@@ -460,7 +460,7 @@ void ArenaTeam::BroadcastPacket(WorldPacket* packet)
{
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
if (Player* player = ObjectAccessor::FindConnectedPlayer(itr->Guid))
player->GetSession()->SendPacket(packet);
player->SendDirectMessage(packet);
}
uint8 ArenaTeam::GetSlotByType(uint32 type)
+1 -1
View File
@@ -127,7 +127,7 @@ class TC_GAME_API ArenaTeam
static uint8 GetTypeBySlot(uint8 slot);
ObjectGuid GetCaptain() const { return CaptainGuid; }
std::string const& GetName() const { return TeamName; }
const ArenaTeamStats& GetStats() const { return Stats; }
ArenaTeamStats const& GetStats() const { return Stats; }
uint32 GetRating() const { return Stats.Rating; }
uint32 GetAverageMMR(Group* group) const;
@@ -153,7 +153,7 @@ void Battleground::Update(uint32 diff)
// [[ but if you use battleground object again (more battles possible to be played on 1 instance)
// then this condition should be removed and code:
// if (!GetInvitedCount(HORDE) && !GetInvitedCount(ALLIANCE))
// this->AddToFreeBGObjectsQueue(); // not yet implemented
// AddToFreeBGObjectsQueue(); // not yet implemented
// should be used instead of current
// ]]
// Battleground Template instance cannot be updated, because it would be deleted
@@ -1365,7 +1365,7 @@ void Battleground::RelocateDeadPlayers(ObjectGuid guideGuid)
continue;
if (!closestGrave)
closestGrave = GetClosestGraveYard(player);
closestGrave = GetClosestGraveyard(player);
if (closestGrave)
player->TeleportTo(closestGrave->Loc);
@@ -1825,9 +1825,9 @@ void Battleground::SetBgRaid(uint32 TeamID, Group* bg_raid)
old_raid = bg_raid;
}
WorldSafeLocsEntry const* Battleground::GetClosestGraveYard(Player* player)
WorldSafeLocsEntry const* Battleground::GetClosestGraveyard(Player* player)
{
return sObjectMgr->GetClosestGraveYard(*player, player->GetTeam(), player);
return sObjectMgr->GetClosestGraveyard(*player, player->GetTeam(), player);
}
void Battleground::StartCriteriaTimer(CriteriaTimedTypes type, uint32 entry)
+5 -5
View File
@@ -444,7 +444,7 @@ class TC_GAME_API Battleground
virtual void HandlePlayerResurrect(Player* /*player*/) { }
// Death related
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
virtual WorldSafeLocsEntry const* GetClosestGraveyard(Player* player);
virtual WorldSafeLocsEntry const* GetExploitTeleportLocation(Team /*team*/) { return nullptr; }
// GetExploitTeleportLocation(TeamId) must be implemented in the battleground subclass.
@@ -507,10 +507,10 @@ class TC_GAME_API Battleground
void EndNow();
void PlayerAddedToBGCheckIfBGIsRunning(Player* player);
Player* _GetPlayer(ObjectGuid guid, bool offlineRemove, const char* context) const;
Player* _GetPlayer(BattlegroundPlayerMap::iterator itr, const char* context) { return _GetPlayer(itr->first, itr->second.OfflineRemoveTime != 0, context); }
Player* _GetPlayer(BattlegroundPlayerMap::const_iterator itr, const char* context) const { return _GetPlayer(itr->first, itr->second.OfflineRemoveTime != 0, context); }
Player* _GetPlayerForTeam(uint32 teamId, BattlegroundPlayerMap::const_iterator itr, const char* context) const;
Player* _GetPlayer(ObjectGuid guid, bool offlineRemove, char const* context) const;
Player* _GetPlayer(BattlegroundPlayerMap::iterator itr, char const* context) { return _GetPlayer(itr->first, itr->second.OfflineRemoveTime != 0, context); }
Player* _GetPlayer(BattlegroundPlayerMap::const_iterator itr, char const* context) const { return _GetPlayer(itr->first, itr->second.OfflineRemoveTime != 0, context); }
Player* _GetPlayerForTeam(uint32 teamId, BattlegroundPlayerMap::const_iterator itr, char const* context) const;
/* Pre- and post-update hooks */
@@ -631,7 +631,7 @@ void BattlegroundAB::EndBattleground(uint32 winner)
Battleground::EndBattleground(winner);
}
WorldSafeLocsEntry const* BattlegroundAB::GetClosestGraveYard(Player* player)
WorldSafeLocsEntry const* BattlegroundAB::GetClosestGraveyard(Player* player)
{
TeamId teamIndex = GetTeamIndexByTeamId(player->GetTeam());
@@ -651,7 +651,7 @@ WorldSafeLocsEntry const* BattlegroundAB::GetClosestGraveYard(Player* player)
float mindist = 999999.0f;
for (uint8 i = 0; i < nodes.size(); ++i)
{
WorldSafeLocsEntry const*entry = sObjectMgr->GetWorldSafeLoc(BG_AB_GraveyardIds[nodes[i]]);
WorldSafeLocsEntry const* entry = sObjectMgr->GetWorldSafeLoc(BG_AB_GraveyardIds[nodes[i]]);
if (!entry)
continue;
float dist = (entry->Loc.GetPositionX() - plr_x) * (entry->Loc.GetPositionX() - plr_x) + (entry->Loc.GetPositionY() - plr_y) * (entry->Loc.GetPositionY() - plr_y);
@@ -322,7 +322,7 @@ class BattlegroundAB : public Battleground
bool SetupBattleground() override;
void Reset() override;
void EndBattleground(uint32 winner) override;
WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override;
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player) override;
WorldSafeLocsEntry const* GetExploitTeleportLocation(Team team) override;
/* Scorekeeping */
@@ -395,7 +395,7 @@ void BattlegroundAV::PostUpdateImpl(uint32 diff)
}
}
if (m_Mine_Timer <= 0)
m_Mine_Timer=AV_MINE_TICK_TIMER; //this is at the end, cause we need to update both mines
m_Mine_Timer = AV_MINE_TICK_TIMER; //this is at the end, cause we need to update both mines
//looks for all timers of the nodes and destroy the building (for graveyards the building wont get destroyed, it goes just to the other team
for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i)
@@ -1099,7 +1099,7 @@ void BattlegroundAV::SendMineWorldStates(uint32 mine)
UpdateWorldState(BG_AV_MineWorldStates[mine2][prevowner], 0);
}
WorldSafeLocsEntry const* BattlegroundAV::GetClosestGraveYard(Player* player)
WorldSafeLocsEntry const* BattlegroundAV::GetClosestGraveyard(Player* player)
{
WorldSafeLocsEntry const* pGraveyard = nullptr;
WorldSafeLocsEntry const* entry = nullptr;
@@ -1498,7 +1498,7 @@ void BattlegroundAV::ResetBGSubclass()
InitNode(i, HORDE, true);
InitNode(BG_AV_NODES_SNOWFALL_GRAVE, AV_NEUTRAL_TEAM, false); //give snowfall neutral owner
m_Mine_Timer=AV_MINE_TICK_TIMER;
m_Mine_Timer = AV_MINE_TICK_TIMER;
for (uint16 i = 0; i < AV_CPLACE_MAX+AV_STATICCPLACE_MAX; i++)
if (!BgCreatures[i].IsEmpty())
DelCreature(i);
@@ -1650,7 +1650,7 @@ class BattlegroundAV : public Battleground
void EndBattleground(uint32 winner) override;
WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override;
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player) override;
WorldSafeLocsEntry const* GetExploitTeleportLocation(Team team) override;
// Achievement: Av perfection and Everything counts
@@ -1687,7 +1687,7 @@ class BattlegroundAV : public Battleground
bool IsTower(BG_AV_Nodes node) { return m_Nodes[node].Tower; }
/*mine*/
void ChangeMineOwner(uint8 mine, uint32 team, bool initial=false);
void ChangeMineOwner(uint8 mine, uint32 team, bool initial = false);
/*worldstates*/
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& packet) override;
@@ -109,4 +109,5 @@ class BattlegroundDS : public Arena
uint32 _pipeKnockBackTimer;
uint8 _pipeKnockBackCount;
};
#endif
@@ -109,10 +109,10 @@ void BattlegroundEY::PostUpdateImpl(uint32 diff)
/*I used this order of calls, because although we will check if one player is in gameobject's distance 2 times
but we can count of players on current point in CheckSomeoneLeftPoint
*/
this->CheckSomeoneJoinedPoint();
CheckSomeoneJoinedPoint();
//check if player left point
this->CheckSomeoneLeftPoint();
this->UpdatePointStatuses();
CheckSomeoneLeftPoint();
UpdatePointStatuses();
m_TowerCapCheckTimer = BG_EY_FPOINTS_TICK_TIME;
}
}
@@ -791,10 +791,10 @@ void BattlegroundEY::EventTeamCapturedPoint(Player* player, uint32 Point)
if (!BgCreatures[Point].IsEmpty())
DelCreature(Point);
WorldSafeLocsEntry const* sg = sObjectMgr->GetWorldSafeLoc(m_CapturingPointTypes[Point].GraveYardId);
WorldSafeLocsEntry const* sg = sObjectMgr->GetWorldSafeLoc(m_CapturingPointTypes[Point].GraveyardId);
if (!sg || !AddSpiritGuide(Point, sg->Loc.GetPositionX(), sg->Loc.GetPositionY(), sg->Loc.GetPositionZ(), 3.124139f, GetTeamIndexByTeamId(Team)))
TC_LOG_ERROR("bg.battleground", "BatteGroundEY: Failed to spawn spirit guide. point: %u, team: %u, graveyard_id: %u",
Point, Team, m_CapturingPointTypes[Point].GraveYardId);
Point, Team, m_CapturingPointTypes[Point].GraveyardId);
// SpawnBGCreature(Point, RESPAWN_IMMEDIATELY);
@@ -916,7 +916,7 @@ void BattlegroundEY::FillInitialWorldStates(WorldPackets::WorldState::InitWorldS
}
}
WorldSafeLocsEntry const* BattlegroundEY::GetClosestGraveYard(Player* player)
WorldSafeLocsEntry const* BattlegroundEY::GetClosestGraveyard(Player* player)
{
uint32 g_id = 0;
@@ -953,9 +953,9 @@ WorldSafeLocsEntry const* BattlegroundEY::GetClosestGraveYard(Player* player)
{
if (m_PointOwnedByTeam[i] == player->GetTeam() && m_PointState[i] == EY_POINT_UNDER_CONTROL)
{
entry = sObjectMgr->GetWorldSafeLoc(m_CapturingPointTypes[i].GraveYardId);
entry = sObjectMgr->GetWorldSafeLoc(m_CapturingPointTypes[i].GraveyardId);
if (!entry)
TC_LOG_ERROR("bg.battleground", "BattlegroundEY: Graveyard %u could not be found.", m_CapturingPointTypes[i].GraveYardId);
TC_LOG_ERROR("bg.battleground", "BattlegroundEY: Graveyard %u could not be found.", m_CapturingPointTypes[i].GraveyardId);
else
{
distance = (entry->Loc.GetPositionX() - plr_x) * (entry->Loc.GetPositionX() - plr_x)
@@ -329,11 +329,11 @@ struct BattlegroundEYLosingPointStruct
struct BattlegroundEYCapturingPointStruct
{
BattlegroundEYCapturingPointStruct(uint32 _DespawnNeutralObjectType, uint32 _SpawnObjectTypeAlliance, uint32 _MessageIdAlliance, uint32 _SpawnObjectTypeHorde, uint32 _MessageIdHorde, uint32 _GraveYardId)
BattlegroundEYCapturingPointStruct(uint32 _DespawnNeutralObjectType, uint32 _SpawnObjectTypeAlliance, uint32 _MessageIdAlliance, uint32 _SpawnObjectTypeHorde, uint32 _MessageIdHorde, uint32 _GraveyardId)
: DespawnNeutralObjectType(_DespawnNeutralObjectType),
SpawnObjectTypeAlliance(_SpawnObjectTypeAlliance), MessageIdAlliance(_MessageIdAlliance),
SpawnObjectTypeHorde(_SpawnObjectTypeHorde), MessageIdHorde(_MessageIdHorde),
GraveYardId(_GraveYardId)
GraveyardId(_GraveyardId)
{ }
uint32 DespawnNeutralObjectType;
@@ -341,7 +341,7 @@ struct BattlegroundEYCapturingPointStruct
uint32 MessageIdAlliance;
uint32 SpawnObjectTypeHorde;
uint32 MessageIdHorde;
uint32 GraveYardId;
uint32 GraveyardId;
};
const uint8 BG_EY_TickPoints[EY_POINTS_MAX] = {1, 2, 5, 10};
@@ -424,7 +424,7 @@ class BattlegroundEY : public Battleground
void RemovePlayer(Player* player, ObjectGuid guid, uint32 team) override;
void HandleAreaTrigger(Player* source, uint32 trigger, bool entered) override;
void HandleKillPlayer(Player* player, Player* killer) override;
WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override;
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player) override;
WorldSafeLocsEntry const* GetExploitTeleportLocation(Team team) override;
bool SetupBattleground() override;
void Reset() override;
@@ -856,7 +856,7 @@ void BattlegroundIC::DestroyGate(Player* player, GameObject* go)
SendBroadcastText(textId, msgType);
}
WorldSafeLocsEntry const* BattlegroundIC::GetClosestGraveYard(Player* player)
WorldSafeLocsEntry const* BattlegroundIC::GetClosestGraveyard(Player* player)
{
TeamId teamIndex = GetTeamIndexByTeamId(player->GetTeam());
@@ -973,7 +973,7 @@ class BattlegroundIC : public Battleground
void DestroyGate(Player* player, GameObject* go) override;
WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override;
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player) override;
WorldSafeLocsEntry const* GetExploitTeleportLocation(Team team) override;
/* Scorekeeping */
@@ -687,7 +687,7 @@ void BattlegroundSA::DestroyGate(Player* /*player*/, GameObject* /*go*/)
{
}
WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveYard(Player* player)
WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveyard(Player* player)
{
uint32 safeloc = 0;
WorldSafeLocsEntry const* ret;
@@ -588,7 +588,7 @@ class BattlegroundSA : public Battleground
/// Called when a player kill a unit in bg
void HandleKillUnit(Creature* creature, Player* killer) override;
/// Return the nearest graveyard where player can respawn
WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override;
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player) override;
/// Called when someone activates an event
void ProcessEvent(WorldObject* /*obj*/, uint32 /*eventId*/, WorldObject* /*invoker*/ = nullptr) override;
/// Called when a player click on flag (graveyard flag)
@@ -814,7 +814,7 @@ bool BattlegroundWS::UpdatePlayerScore(Player* player, uint32 type, uint32 value
return true;
}
WorldSafeLocsEntry const* BattlegroundWS::GetClosestGraveYard(Player* player)
WorldSafeLocsEntry const* BattlegroundWS::GetClosestGraveyard(Player* player)
{
//if status in progress, it returns main graveyards with spiritguides
//else it will return the graveyard in the flagroom - this is especially good
@@ -245,7 +245,7 @@ class BattlegroundWS : public Battleground
bool SetupBattleground() override;
void Reset() override;
void EndBattleground(uint32 winner) override;
WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override;
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player) override;
WorldSafeLocsEntry const* GetExploitTeleportLocation(Team team) override;
void UpdateFlagState(uint32 team, uint32 value);
+1 -2
View File
@@ -24,6 +24,7 @@
#include <unordered_set>
class Player;
struct AreaTableEntry;
namespace WorldPackets
{
@@ -33,8 +34,6 @@ namespace WorldPackets
}
}
struct AreaTableEntry;
enum ChatNotify
{
CHAT_JOINED_NOTICE = 0x00, //+ "%s joined channel.";
@@ -185,8 +185,8 @@ struct ChannelOwnerAppend
{
explicit ChannelOwnerAppend(Channel const* channel, ObjectGuid const& ownerGuid) : _channel(channel), _ownerGuid(ownerGuid)
{
if (CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(_ownerGuid))
_ownerName = characterInfo->Name;
if (CharacterCacheEntry const* cInfo = sCharacterCache->GetCharacterCacheByGuid(_ownerGuid))
_ownerName = cInfo->Name;
}
static uint8 const NotificationType = CHAT_CHANNEL_OWNER_NOTICE;
+2 -1
View File
@@ -43,6 +43,7 @@
#include "World.h"
#include "WorldSession.h"
#include <random>
#include <sstream>
char const* const ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX] =
{
@@ -1125,7 +1126,7 @@ void ConditionMgr::LoadConditions(bool isReload)
}
cond->ReferenceId = uint32(abs(iConditionTypeOrReference));
const char* rowType = "reference template";
char const* rowType = "reference template";
if (iSourceTypeOrReferenceId >= 0)
rowType = "reference";
//check for useless data
+1
View File
@@ -262,6 +262,7 @@ TC_GAME_API void LoadM2Cameras(std::string const& dataPath)
if (!readCamera(cam, fileSize - m2start, header, cameraEntry))
TC_LOG_ERROR("server.loading", "Camera file %s is damaged. Camera references position beyond file end", filename.string().c_str());
}
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " cinematic waypoint sets in %u ms", sFlyByCameraStore.size(), GetMSTimeDiffToNow(oldMSTime));
}
+8 -8
View File
@@ -43,17 +43,17 @@
namespace lfg
{
LFGDungeonData::LFGDungeonData() : id(0), name(""), map(0), type(0), expansion(0), group(0), minlevel(0),
maxlevel(0), difficulty(DIFFICULTY_NONE), seasonal(false), x(0.0f), y(0.0f), z(0.0f), o(0.0f),
requiredItemLevel(0)
LFGDungeonData::LFGDungeonData() : id(0), name(), map(0), type(0), expansion(0), group(0), minlevel(0),
maxlevel(0), difficulty(DIFFICULTY_NONE), seasonal(false), x(0.0f), y(0.0f), z(0.0f), o(0.0f),
requiredItemLevel(0)
{
}
LFGDungeonData::LFGDungeonData(LFGDungeonsEntry const* dbc) : id(dbc->ID), name(dbc->Name[sWorld->GetDefaultDbcLocale()]), map(dbc->MapID),
type(uint8(dbc->TypeID)), expansion(uint8(dbc->ExpansionLevel)), group(uint8(dbc->GroupID)),
minlevel(uint8(dbc->MinLevel)), maxlevel(uint8(dbc->MaxLevel)), difficulty(Difficulty(dbc->DifficultyID)),
seasonal((dbc->Flags[0] & LFG_FLAG_SEASONAL) != 0), x(0.0f), y(0.0f), z(0.0f), o(0.0f),
requiredItemLevel(0)
type(uint8(dbc->TypeID)), expansion(uint8(dbc->ExpansionLevel)), group(uint8(dbc->GroupID)),
minlevel(uint8(dbc->MinLevel)), maxlevel(uint8(dbc->MaxLevel)), difficulty(Difficulty(dbc->DifficultyID)),
seasonal((dbc->Flags[0] & LFG_FLAG_SEASONAL) != 0), x(0.0f), y(0.0f), z(0.0f), o(0.0f),
requiredItemLevel(0)
{
}
@@ -1417,7 +1417,7 @@ void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId, Map const*
}
uint32 rDungeonId = 0;
const LfgDungeonSet& dungeons = GetSelectedDungeons(guid);
LfgDungeonSet const& dungeons = GetSelectedDungeons(guid);
if (!dungeons.empty())
rDungeonId = (*dungeons.begin());
@@ -42,7 +42,7 @@ class TC_GAME_API LfgPlayerData
// Queue
void SetRoles(uint8 roles);
void SetSelectedDungeons(const LfgDungeonSet& dungeons);
void SetSelectedDungeons(LfgDungeonSet const& dungeons);
// General
WorldPackets::LFG::RideTicket const& GetTicket() const;
+2 -2
View File
@@ -503,7 +503,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(GuidList check)
else
{
ObjectGuid gguid = *check.begin();
const LfgQueueData &queue = QueueDataStore[gguid];
LfgQueueData const& queue = QueueDataStore[gguid];
proposalDungeons = queue.dungeons;
proposalRoles = queue.roles;
LFGMgr::CheckGroupRoles(proposalRoles); // assing new roles
@@ -673,7 +673,7 @@ std::string LFGQueue::DumpCompatibleInfo(bool full /* = false */) const
{
o << " (";
bool first = true;
for (const auto& role : itr->second.roles)
for (auto const& role : itr->second.roles)
{
if (!first)
o << "|";

Some files were not shown because too many files have changed in this diff Show More