mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
Various Cleanups (game P)
This commit is contained in:
parent
94795f2bff
commit
98e1efd435
17 changed files with 3642 additions and 3615 deletions
|
|
@ -38,13 +38,13 @@ class Path
|
||||||
void resize(unsigned int sz) { i_nodes.resize(sz); }
|
void resize(unsigned int sz) { i_nodes.resize(sz); }
|
||||||
void crop(unsigned int start, unsigned int end)
|
void crop(unsigned int start, unsigned int end)
|
||||||
{
|
{
|
||||||
while(start && !i_nodes.empty())
|
while (start && !i_nodes.empty())
|
||||||
{
|
{
|
||||||
i_nodes.pop_front();
|
i_nodes.pop_front();
|
||||||
--start;
|
--start;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(end && !i_nodes.empty())
|
while (end && !i_nodes.empty())
|
||||||
{
|
{
|
||||||
i_nodes.pop_back();
|
i_nodes.pop_back();
|
||||||
--end;
|
--end;
|
||||||
|
|
@ -56,14 +56,14 @@ class Path
|
||||||
float GetTotalLength(uint32 start, uint32 end) const
|
float GetTotalLength(uint32 start, uint32 end) const
|
||||||
{
|
{
|
||||||
float len = 0.0f;
|
float len = 0.0f;
|
||||||
for(unsigned int idx=start+1; idx < end; ++idx)
|
for (unsigned int idx=start+1; idx < end; ++idx)
|
||||||
{
|
{
|
||||||
PathNode const& node = i_nodes[idx];
|
PathNode const& node = i_nodes[idx];
|
||||||
PathNode const& prev = i_nodes[idx-1];
|
PathNode const& prev = i_nodes[idx-1];
|
||||||
float xd = node.x - prev.x;
|
float xd = node.x - prev.x;
|
||||||
float yd = node.y - prev.y;
|
float yd = node.y - prev.y;
|
||||||
float zd = node.z - prev.z;
|
float zd = node.z - prev.z;
|
||||||
len += sqrtf( xd*xd + yd*yd + zd*zd );
|
len += sqrtf(xd*xd + yd*yd + zd*zd);
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +80,7 @@ class Path
|
||||||
float xd = x - node.x;
|
float xd = x - node.x;
|
||||||
float yd = y - node.y;
|
float yd = y - node.y;
|
||||||
float zd = z - node.z;
|
float zd = z - node.z;
|
||||||
len += sqrtf( xd*xd + yd*yd + zd*zd );
|
len += sqrtf(xd*xd + yd*yd + zd*zd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ bool PathFinder::calculate(float destX, float destY, float destZ, bool forceDest
|
||||||
// make sure navMesh works - we can run on map w/o mmap
|
// make sure navMesh works - we can run on map w/o mmap
|
||||||
// check if the start and end point have a .mmtile loaded (can we pass via not loaded tile on the way?)
|
// check if the start and end point have a .mmtile loaded (can we pass via not loaded tile on the way?)
|
||||||
if (!m_navMesh || !m_navMeshQuery || m_sourceUnit->hasUnitState(UNIT_STAT_IGNORE_PATHFINDING) ||
|
if (!m_navMesh || !m_navMeshQuery || m_sourceUnit->hasUnitState(UNIT_STAT_IGNORE_PATHFINDING) ||
|
||||||
!HaveTile(start) || !HaveTile(dest))
|
!HaveTile(start) || !HaveTile(dest))
|
||||||
{
|
{
|
||||||
BuildShortcut();
|
BuildShortcut();
|
||||||
m_type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
|
m_type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
|
||||||
|
|
@ -95,7 +95,7 @@ bool PathFinder::calculate(float destX, float destY, float destZ, bool forceDest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dtPolyRef PathFinder::getPathPolyByPosition(const dtPolyRef *polyPath, uint32 polyPathSize, const float* point, float *distance) const
|
dtPolyRef PathFinder::getPathPolyByPosition(const dtPolyRef* polyPath, uint32 polyPathSize, const float* point, float* distance) const
|
||||||
{
|
{
|
||||||
if (!polyPath || !polyPathSize)
|
if (!polyPath || !polyPathSize)
|
||||||
return INVALID_POLYREF;
|
return INVALID_POLYREF;
|
||||||
|
|
@ -118,7 +118,7 @@ dtPolyRef PathFinder::getPathPolyByPosition(const dtPolyRef *polyPath, uint32 po
|
||||||
minDist3d = dtVdistSqr(point, closestPoint);
|
minDist3d = dtVdistSqr(point, closestPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(minDist2d < 1.0f) // shortcut out - close enough for us
|
if (minDist2d < 1.0f) // shortcut out - close enough for us
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,13 +128,13 @@ dtPolyRef PathFinder::getPathPolyByPosition(const dtPolyRef *polyPath, uint32 po
|
||||||
return (minDist2d < 3.0f) ? nearestPoly : INVALID_POLYREF;
|
return (minDist2d < 3.0f) ? nearestPoly : INVALID_POLYREF;
|
||||||
}
|
}
|
||||||
|
|
||||||
dtPolyRef PathFinder::getPolyByLocation(const float* point, float *distance) const
|
dtPolyRef PathFinder::getPolyByLocation(const float* point, float* distance) const
|
||||||
{
|
{
|
||||||
// first we check the current path
|
// first we check the current path
|
||||||
// if the current path doesn't contain the current poly,
|
// if the current path doesn't contain the current poly,
|
||||||
// we need to use the expensive navMesh.findNearestPoly
|
// we need to use the expensive navMesh.findNearestPoly
|
||||||
dtPolyRef polyRef = getPathPolyByPosition(m_pathPolyRefs, m_polyLength, point, distance);
|
dtPolyRef polyRef = getPathPolyByPosition(m_pathPolyRefs, m_polyLength, point, distance);
|
||||||
if(polyRef != INVALID_POLYREF)
|
if (polyRef != INVALID_POLYREF)
|
||||||
return polyRef;
|
return polyRef;
|
||||||
|
|
||||||
// we don't have it in our old path
|
// we don't have it in our old path
|
||||||
|
|
@ -143,7 +143,7 @@ dtPolyRef PathFinder::getPolyByLocation(const float* point, float *distance) con
|
||||||
float extents[VERTEX_SIZE] = {3.0f, 5.0f, 3.0f}; // bounds of poly search area
|
float extents[VERTEX_SIZE] = {3.0f, 5.0f, 3.0f}; // bounds of poly search area
|
||||||
float closestPoint[VERTEX_SIZE] = {0.0f, 0.0f, 0.0f};
|
float closestPoint[VERTEX_SIZE] = {0.0f, 0.0f, 0.0f};
|
||||||
dtStatus result = m_navMeshQuery->findNearestPoly(point, extents, &m_filter, &polyRef, closestPoint);
|
dtStatus result = m_navMeshQuery->findNearestPoly(point, extents, &m_filter, &polyRef, closestPoint);
|
||||||
if(DT_SUCCESS == result && polyRef != INVALID_POLYREF)
|
if (DT_SUCCESS == result && polyRef != INVALID_POLYREF)
|
||||||
{
|
{
|
||||||
*distance = dtVdist(closestPoint, point);
|
*distance = dtVdist(closestPoint, point);
|
||||||
return polyRef;
|
return polyRef;
|
||||||
|
|
@ -153,7 +153,7 @@ dtPolyRef PathFinder::getPolyByLocation(const float* point, float *distance) con
|
||||||
// try with bigger search box
|
// try with bigger search box
|
||||||
extents[1] = 200.0f;
|
extents[1] = 200.0f;
|
||||||
result = m_navMeshQuery->findNearestPoly(point, extents, &m_filter, &polyRef, closestPoint);
|
result = m_navMeshQuery->findNearestPoly(point, extents, &m_filter, &polyRef, closestPoint);
|
||||||
if(DT_SUCCESS == result && polyRef != INVALID_POLYREF)
|
if (DT_SUCCESS == result && polyRef != INVALID_POLYREF)
|
||||||
{
|
{
|
||||||
*distance = dtVdist(closestPoint, point);
|
*distance = dtVdist(closestPoint, point);
|
||||||
return polyRef;
|
return polyRef;
|
||||||
|
|
@ -162,7 +162,7 @@ dtPolyRef PathFinder::getPolyByLocation(const float* point, float *distance) con
|
||||||
return INVALID_POLYREF;
|
return INVALID_POLYREF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathFinder::BuildPolyPath(const Vector3 &startPos, const Vector3 &endPos)
|
void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
|
||||||
{
|
{
|
||||||
// *** getting start/end poly logic ***
|
// *** getting start/end poly logic ***
|
||||||
|
|
||||||
|
|
@ -181,7 +181,7 @@ void PathFinder::BuildPolyPath(const Vector3 &startPos, const Vector3 &endPos)
|
||||||
DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ BuildPolyPath :: (startPoly == 0 || endPoly == 0)\n");
|
DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ BuildPolyPath :: (startPoly == 0 || endPoly == 0)\n");
|
||||||
BuildShortcut();
|
BuildShortcut();
|
||||||
m_type = (m_sourceUnit->GetTypeId() == TYPEID_UNIT && ((Creature*)m_sourceUnit)->CanFly())
|
m_type = (m_sourceUnit->GetTypeId() == TYPEID_UNIT && ((Creature*)m_sourceUnit)->CanFly())
|
||||||
? PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH) : PATHFIND_NOPATH;
|
? PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH) : PATHFIND_NOPATH;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -363,14 +363,14 @@ void PathFinder::BuildPolyPath(const Vector3 &startPos, const Vector3 &endPos)
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
dtStatus dtResult = m_navMeshQuery->findPath(
|
dtStatus dtResult = m_navMeshQuery->findPath(
|
||||||
startPoly, // start polygon
|
startPoly, // start polygon
|
||||||
endPoly, // end polygon
|
endPoly, // end polygon
|
||||||
startPoint, // start position
|
startPoint, // start position
|
||||||
endPoint, // end position
|
endPoint, // end position
|
||||||
&m_filter, // polygon search filter
|
&m_filter, // polygon search filter
|
||||||
m_pathPolyRefs, // [out] path
|
m_pathPolyRefs, // [out] path
|
||||||
(int*)&m_polyLength,
|
(int*)&m_polyLength,
|
||||||
MAX_PATH_LENGTH); // max number of polygons in output path
|
MAX_PATH_LENGTH); // max number of polygons in output path
|
||||||
|
|
||||||
if (!m_polyLength || dtResult != DT_SUCCESS)
|
if (!m_polyLength || dtResult != DT_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|
@ -392,7 +392,7 @@ void PathFinder::BuildPolyPath(const Vector3 &startPos, const Vector3 &endPos)
|
||||||
BuildPointPath(startPoint, endPoint);
|
BuildPointPath(startPoint, endPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathFinder::BuildPointPath(const float *startPoint, const float *endPoint)
|
void PathFinder::BuildPointPath(const float* startPoint, const float* endPoint)
|
||||||
{
|
{
|
||||||
float pathPoints[MAX_POINT_PATH_LENGTH*VERTEX_SIZE];
|
float pathPoints[MAX_POINT_PATH_LENGTH*VERTEX_SIZE];
|
||||||
uint32 pointCount = 0;
|
uint32 pointCount = 0;
|
||||||
|
|
@ -400,26 +400,26 @@ void PathFinder::BuildPointPath(const float *startPoint, const float *endPoint)
|
||||||
if (m_useStraightPath)
|
if (m_useStraightPath)
|
||||||
{
|
{
|
||||||
dtResult = m_navMeshQuery->findStraightPath(
|
dtResult = m_navMeshQuery->findStraightPath(
|
||||||
startPoint, // start position
|
startPoint, // start position
|
||||||
endPoint, // end position
|
endPoint, // end position
|
||||||
m_pathPolyRefs, // current path
|
m_pathPolyRefs, // current path
|
||||||
m_polyLength, // lenth of current path
|
m_polyLength, // lenth of current path
|
||||||
pathPoints, // [out] path corner points
|
pathPoints, // [out] path corner points
|
||||||
NULL, // [out] flags
|
NULL, // [out] flags
|
||||||
NULL, // [out] shortened path
|
NULL, // [out] shortened path
|
||||||
(int*)&pointCount,
|
(int*)&pointCount,
|
||||||
m_pointPathLimit); // maximum number of points/polygons to use
|
m_pointPathLimit); // maximum number of points/polygons to use
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dtResult = findSmoothPath(
|
dtResult = findSmoothPath(
|
||||||
startPoint, // start position
|
startPoint, // start position
|
||||||
endPoint, // end position
|
endPoint, // end position
|
||||||
m_pathPolyRefs, // current path
|
m_pathPolyRefs, // current path
|
||||||
m_polyLength, // length of current path
|
m_polyLength, // length of current path
|
||||||
pathPoints, // [out] path corner points
|
pathPoints, // [out] path corner points
|
||||||
(int*)&pointCount,
|
(int*)&pointCount,
|
||||||
m_pointPathLimit); // maximum number of points
|
m_pointPathLimit); // maximum number of points
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pointCount < 2 || dtResult != DT_SUCCESS)
|
if (pointCount < 2 || dtResult != DT_SUCCESS)
|
||||||
|
|
@ -441,12 +441,12 @@ void PathFinder::BuildPointPath(const float *startPoint, const float *endPoint)
|
||||||
setActualEndPosition(m_pathPoints[pointCount-1]);
|
setActualEndPosition(m_pathPoints[pointCount-1]);
|
||||||
|
|
||||||
// force the given destination, if needed
|
// force the given destination, if needed
|
||||||
if(m_forceDestination &&
|
if (m_forceDestination &&
|
||||||
(!(m_type & PATHFIND_NORMAL) || !inRange(getEndPosition(), getActualEndPosition(), 1.0f, 1.0f)))
|
(!(m_type & PATHFIND_NORMAL) || !inRange(getEndPosition(), getActualEndPosition(), 1.0f, 1.0f)))
|
||||||
{
|
{
|
||||||
// we may want to keep partial subpath
|
// we may want to keep partial subpath
|
||||||
if(dist3DSqr(getActualEndPosition(), getEndPosition()) <
|
if (dist3DSqr(getActualEndPosition(), getEndPosition()) <
|
||||||
0.3f * dist3DSqr(getStartPosition(), getEndPosition()))
|
0.3f * dist3DSqr(getStartPosition(), getEndPosition()))
|
||||||
{
|
{
|
||||||
setActualEndPosition(getEndPosition());
|
setActualEndPosition(getEndPosition());
|
||||||
m_pathPoints[m_pathPoints.size()-1] = getEndPosition();
|
m_pathPoints[m_pathPoints.size()-1] = getEndPosition();
|
||||||
|
|
@ -540,7 +540,7 @@ NavTerrain PathFinder::getNavTerrain(float x, float y, float z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PathFinder::HaveTile(const Vector3 &p) const
|
bool PathFinder::HaveTile(const Vector3& p) const
|
||||||
{
|
{
|
||||||
int tx, ty;
|
int tx, ty;
|
||||||
float point[VERTEX_SIZE] = {p.y, p.z, p.x};
|
float point[VERTEX_SIZE] = {p.y, p.z, p.x};
|
||||||
|
|
@ -550,7 +550,7 @@ bool PathFinder::HaveTile(const Vector3 &p) const
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 PathFinder::fixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath,
|
uint32 PathFinder::fixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath,
|
||||||
const dtPolyRef* visited, uint32 nvisited)
|
const dtPolyRef* visited, uint32 nvisited)
|
||||||
{
|
{
|
||||||
int32 furthestPath = -1;
|
int32 furthestPath = -1;
|
||||||
int32 furthestVisited = -1;
|
int32 furthestVisited = -1;
|
||||||
|
|
@ -596,8 +596,8 @@ uint32 PathFinder::fixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PathFinder::getSteerTarget(const float* startPos, const float* endPos,
|
bool PathFinder::getSteerTarget(const float* startPos, const float* endPos,
|
||||||
float minTargetDist, const dtPolyRef* path, uint32 pathSize,
|
float minTargetDist, const dtPolyRef* path, uint32 pathSize,
|
||||||
float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef)
|
float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef)
|
||||||
{
|
{
|
||||||
// Find steer target.
|
// Find steer target.
|
||||||
static const uint32 MAX_STEER_POINTS = 3;
|
static const uint32 MAX_STEER_POINTS = 3;
|
||||||
|
|
@ -606,7 +606,7 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos,
|
||||||
dtPolyRef steerPathPolys[MAX_STEER_POINTS];
|
dtPolyRef steerPathPolys[MAX_STEER_POINTS];
|
||||||
uint32 nsteerPath = 0;
|
uint32 nsteerPath = 0;
|
||||||
dtStatus dtResult = m_navMeshQuery->findStraightPath(startPos, endPos, path, pathSize,
|
dtStatus dtResult = m_navMeshQuery->findStraightPath(startPos, endPos, path, pathSize,
|
||||||
steerPath, steerPathFlags, steerPathPolys, (int*)&nsteerPath, MAX_STEER_POINTS);
|
steerPath, steerPathFlags, steerPathPolys, (int*)&nsteerPath, MAX_STEER_POINTS);
|
||||||
if (!nsteerPath || DT_SUCCESS != dtResult)
|
if (!nsteerPath || DT_SUCCESS != dtResult)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -616,7 +616,7 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos,
|
||||||
{
|
{
|
||||||
// Stop at Off-Mesh link or when point is further than slop away.
|
// Stop at Off-Mesh link or when point is further than slop away.
|
||||||
if ((steerPathFlags[ns] & DT_STRAIGHTPATH_OFFMESH_CONNECTION) ||
|
if ((steerPathFlags[ns] & DT_STRAIGHTPATH_OFFMESH_CONNECTION) ||
|
||||||
!inRangeYZX(&steerPath[ns*VERTEX_SIZE], startPos, minTargetDist, 1000.0f))
|
!inRangeYZX(&steerPath[ns*VERTEX_SIZE], startPos, minTargetDist, 1000.0f))
|
||||||
break;
|
break;
|
||||||
ns++;
|
ns++;
|
||||||
}
|
}
|
||||||
|
|
@ -633,8 +633,8 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos,
|
||||||
}
|
}
|
||||||
|
|
||||||
dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos,
|
dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos,
|
||||||
const dtPolyRef* polyPath, uint32 polyPathSize,
|
const dtPolyRef* polyPath, uint32 polyPathSize,
|
||||||
float* smoothPath, int* smoothPathSize, uint32 maxSmoothPathSize)
|
float* smoothPath, int* smoothPathSize, uint32 maxSmoothPathSize)
|
||||||
{
|
{
|
||||||
*smoothPathSize = 0;
|
*smoothPathSize = 0;
|
||||||
uint32 nsmoothPath = 0;
|
uint32 nsmoothPath = 0;
|
||||||
|
|
@ -644,10 +644,10 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos,
|
||||||
uint32 npolys = polyPathSize;
|
uint32 npolys = polyPathSize;
|
||||||
|
|
||||||
float iterPos[VERTEX_SIZE], targetPos[VERTEX_SIZE];
|
float iterPos[VERTEX_SIZE], targetPos[VERTEX_SIZE];
|
||||||
if(DT_SUCCESS != m_navMeshQuery->closestPointOnPolyBoundary(polys[0], startPos, iterPos))
|
if (DT_SUCCESS != m_navMeshQuery->closestPointOnPolyBoundary(polys[0], startPos, iterPos))
|
||||||
return DT_FAILURE;
|
return DT_FAILURE;
|
||||||
|
|
||||||
if(DT_SUCCESS != m_navMeshQuery->closestPointOnPolyBoundary(polys[npolys-1], endPos, targetPos))
|
if (DT_SUCCESS != m_navMeshQuery->closestPointOnPolyBoundary(polys[npolys-1], endPos, targetPos))
|
||||||
return DT_FAILURE;
|
return DT_FAILURE;
|
||||||
|
|
||||||
dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], iterPos);
|
dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], iterPos);
|
||||||
|
|
@ -763,13 +763,13 @@ bool PathFinder::inRangeYZX(const float* v1, const float* v2, float r, float h)
|
||||||
return (dx*dx + dz*dz) < r*r && fabsf(dy) < h;
|
return (dx*dx + dz*dz) < r*r && fabsf(dy) < h;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PathFinder::inRange(const Vector3 &p1, const Vector3 &p2, float r, float h) const
|
bool PathFinder::inRange(const Vector3& p1, const Vector3& p2, float r, float h) const
|
||||||
{
|
{
|
||||||
Vector3 d = p1-p2;
|
Vector3 d = p1-p2;
|
||||||
return (d.x*d.x + d.y*d.y) < r*r && fabsf(d.z) < h;
|
return (d.x*d.x + d.y*d.y) < r*r && fabsf(d.z) < h;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PathFinder::dist3DSqr(const Vector3 &p1, const Vector3 &p2) const
|
float PathFinder::dist3DSqr(const Vector3& p1, const Vector3& p2) const
|
||||||
{
|
{
|
||||||
return (p1-p2).squaredLength();
|
return (p1-p2).squaredLength();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,16 +106,16 @@ class PathFinder
|
||||||
m_pathPoints.clear();
|
m_pathPoints.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool inRange(const Vector3 &p1, const Vector3 &p2, float r, float h) const;
|
bool inRange(const Vector3& p1, const Vector3& p2, float r, float h) const;
|
||||||
float dist3DSqr(const Vector3 &p1, const Vector3 &p2) const;
|
float dist3DSqr(const Vector3& p1, const Vector3& p2) const;
|
||||||
bool inRangeYZX(const float* v1, const float* v2, float r, float h) const;
|
bool inRangeYZX(const float* v1, const float* v2, float r, float h) const;
|
||||||
|
|
||||||
dtPolyRef getPathPolyByPosition(const dtPolyRef *polyPath, uint32 polyPathSize, const float* point, float *distance = NULL) const;
|
dtPolyRef getPathPolyByPosition(const dtPolyRef* polyPath, uint32 polyPathSize, const float* point, float* distance = NULL) const;
|
||||||
dtPolyRef getPolyByLocation(const float* point, float *distance) const;
|
dtPolyRef getPolyByLocation(const float* point, float* distance) const;
|
||||||
bool HaveTile(const Vector3 &p) const;
|
bool HaveTile(const Vector3& p) const;
|
||||||
|
|
||||||
void BuildPolyPath(const Vector3 &startPos, const Vector3 &endPos);
|
void BuildPolyPath(const Vector3& startPos, const Vector3& endPos);
|
||||||
void BuildPointPath(const float *startPoint, const float *endPoint);
|
void BuildPointPath(const float* startPoint, const float* endPoint);
|
||||||
void BuildShortcut();
|
void BuildShortcut();
|
||||||
|
|
||||||
NavTerrain getNavTerrain(float x, float y, float z);
|
NavTerrain getNavTerrain(float x, float y, float z);
|
||||||
|
|
@ -129,8 +129,8 @@ class PathFinder
|
||||||
const dtPolyRef* path, uint32 pathSize, float* steerPos,
|
const dtPolyRef* path, uint32 pathSize, float* steerPos,
|
||||||
unsigned char& steerPosFlag, dtPolyRef& steerPosRef);
|
unsigned char& steerPosFlag, dtPolyRef& steerPosRef);
|
||||||
dtStatus findSmoothPath(const float* startPos, const float* endPos,
|
dtStatus findSmoothPath(const float* startPos, const float* endPos,
|
||||||
const dtPolyRef* polyPath, uint32 polyPathSize,
|
const dtPolyRef* polyPath, uint32 polyPathSize,
|
||||||
float* smoothPath, int* smoothPathSize, uint32 smoothPathMaxSize);
|
float* smoothPath, int* smoothPathSize, uint32 smoothPathMaxSize);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
506
src/game/Pet.cpp
506
src/game/Pet.cpp
File diff suppressed because it is too large
Load diff
|
|
@ -149,9 +149,9 @@ class MANGOS_DLL_SPEC Pet : public Creature
|
||||||
|
|
||||||
bool IsPermanentPetFor(Player* owner); // pet have tab in character windows and set UNIT_FIELD_PETNUMBER
|
bool IsPermanentPetFor(Player* owner); // pet have tab in character windows and set UNIT_FIELD_PETNUMBER
|
||||||
|
|
||||||
bool Create (uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, uint32 pet_number);
|
bool Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, uint32 pet_number);
|
||||||
bool CreateBaseAtCreature(Creature* creature);
|
bool CreateBaseAtCreature(Creature* creature);
|
||||||
bool LoadPetFromDB( Player* owner,uint32 petentry = 0,uint32 petnumber = 0, bool current = false );
|
bool LoadPetFromDB(Player* owner,uint32 petentry = 0,uint32 petnumber = 0, bool current = false);
|
||||||
void SavePetToDB(PetSaveMode mode);
|
void SavePetToDB(PetSaveMode mode);
|
||||||
void Unsummon(PetSaveMode mode, Unit* owner = NULL);
|
void Unsummon(PetSaveMode mode, Unit* owner = NULL);
|
||||||
static void DeleteFromDB(uint32 guidlow, bool separate_transaction = true);
|
static void DeleteFromDB(uint32 guidlow, bool separate_transaction = true);
|
||||||
|
|
@ -256,7 +256,7 @@ class MANGOS_DLL_SPEC Pet : public Creature
|
||||||
uint64 m_auraUpdateMask;
|
uint64 m_auraUpdateMask;
|
||||||
bool m_loading;
|
bool m_loading;
|
||||||
|
|
||||||
DeclinedName *m_declinedname;
|
DeclinedName* m_declinedname;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PetModeFlags m_petModeFlags;
|
PetModeFlags m_petModeFlags;
|
||||||
|
|
|
||||||
|
|
@ -28,21 +28,21 @@
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
|
||||||
int PetAI::Permissible(const Creature *creature)
|
int PetAI::Permissible(const Creature* creature)
|
||||||
{
|
{
|
||||||
if( creature->IsPet())
|
if (creature->IsPet())
|
||||||
return PERMIT_BASE_SPECIAL;
|
return PERMIT_BASE_SPECIAL;
|
||||||
|
|
||||||
return PERMIT_BASE_NO;
|
return PERMIT_BASE_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
PetAI::PetAI(Creature *c) : CreatureAI(c), i_tracker(TIME_INTERVAL_LOOK), inCombat(false)
|
PetAI::PetAI(Creature* c) : CreatureAI(c), i_tracker(TIME_INTERVAL_LOOK), inCombat(false)
|
||||||
{
|
{
|
||||||
m_AllySet.clear();
|
m_AllySet.clear();
|
||||||
UpdateAllies();
|
UpdateAllies();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetAI::MoveInLineOfSight(Unit *u)
|
void PetAI::MoveInLineOfSight(Unit* u)
|
||||||
{
|
{
|
||||||
if (m_creature->getVictim())
|
if (m_creature->getVictim())
|
||||||
return;
|
return;
|
||||||
|
|
@ -53,13 +53,13 @@ void PetAI::MoveInLineOfSight(Unit *u)
|
||||||
if (!m_creature->GetCharmInfo() || !m_creature->GetCharmInfo()->HasReactState(REACT_AGGRESSIVE))
|
if (!m_creature->GetCharmInfo() || !m_creature->GetCharmInfo()->HasReactState(REACT_AGGRESSIVE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (u->isTargetableForAttack() && m_creature->IsHostileTo( u ) &&
|
if (u->isTargetableForAttack() && m_creature->IsHostileTo(u) &&
|
||||||
u->isInAccessablePlaceFor(m_creature))
|
u->isInAccessablePlaceFor(m_creature))
|
||||||
{
|
{
|
||||||
float attackRadius = m_creature->GetAttackDistance(u);
|
float attackRadius = m_creature->GetAttackDistance(u);
|
||||||
if(m_creature->IsWithinDistInMap(u, attackRadius) && m_creature->GetDistanceZ(u) <= CREATURE_Z_ATTACK_RANGE)
|
if (m_creature->IsWithinDistInMap(u, attackRadius) && m_creature->GetDistanceZ(u) <= CREATURE_Z_ATTACK_RANGE)
|
||||||
{
|
{
|
||||||
if(m_creature->IsWithinLOSInMap(u))
|
if (m_creature->IsWithinLOSInMap(u))
|
||||||
{
|
{
|
||||||
AttackStart(u);
|
AttackStart(u);
|
||||||
u->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
|
u->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
|
||||||
|
|
@ -68,12 +68,12 @@ void PetAI::MoveInLineOfSight(Unit *u)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetAI::AttackStart(Unit *u)
|
void PetAI::AttackStart(Unit* u)
|
||||||
{
|
{
|
||||||
if(!u || (m_creature->IsPet() && ((Pet*)m_creature)->getPetType() == MINI_PET))
|
if (!u || (m_creature->IsPet() && ((Pet*)m_creature)->getPetType() == MINI_PET))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(m_creature->Attack(u,true))
|
if (m_creature->Attack(u,true))
|
||||||
{
|
{
|
||||||
// TMGs call CreatureRelocation which via MoveInLineOfSight can call this function
|
// TMGs call CreatureRelocation which via MoveInLineOfSight can call this function
|
||||||
// thus with the following clear the original TMG gets invalidated and crash, doh
|
// thus with the following clear the original TMG gets invalidated and crash, doh
|
||||||
|
|
@ -88,7 +88,7 @@ void PetAI::EnterEvadeMode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PetAI::IsVisible(Unit *pl) const
|
bool PetAI::IsVisible(Unit* pl) const
|
||||||
{
|
{
|
||||||
return _isVisible(pl);
|
return _isVisible(pl);
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +96,7 @@ bool PetAI::IsVisible(Unit *pl) const
|
||||||
bool PetAI::_needToStop() const
|
bool PetAI::_needToStop() const
|
||||||
{
|
{
|
||||||
// This is needed for charmed creatures, as once their target was reset other effects can trigger threat
|
// This is needed for charmed creatures, as once their target was reset other effects can trigger threat
|
||||||
if(m_creature->isCharmed() && m_creature->getVictim() == m_creature->GetCharmer())
|
if (m_creature->isCharmed() && m_creature->getVictim() == m_creature->GetCharmer())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return !m_creature->getVictim()->isTargetableForAttack();
|
return !m_creature->getVictim()->isTargetableForAttack();
|
||||||
|
|
@ -108,7 +108,7 @@ void PetAI::_stopAttack()
|
||||||
|
|
||||||
Unit* owner = m_creature->GetCharmerOrOwner();
|
Unit* owner = m_creature->GetCharmerOrOwner();
|
||||||
|
|
||||||
if(owner && m_creature->GetCharmInfo() && m_creature->GetCharmInfo()->HasCommandState(COMMAND_FOLLOW))
|
if (owner && m_creature->GetCharmInfo() && m_creature->GetCharmInfo()->HasCommandState(COMMAND_FOLLOW))
|
||||||
{
|
{
|
||||||
m_creature->GetMotionMaster()->MoveFollow(owner,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE);
|
m_creature->GetMotionMaster()->MoveFollow(owner,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE);
|
||||||
}
|
}
|
||||||
|
|
@ -178,9 +178,9 @@ void PetAI::UpdateAI(const uint32 diff)
|
||||||
{
|
{
|
||||||
AttackStart(owner->getAttackerForHelper());
|
AttackStart(owner->getAttackerForHelper());
|
||||||
}
|
}
|
||||||
else if(m_creature->GetCharmInfo()->HasCommandState(COMMAND_FOLLOW))
|
else if (m_creature->GetCharmInfo()->HasCommandState(COMMAND_FOLLOW))
|
||||||
{
|
{
|
||||||
if (!m_creature->hasUnitState(UNIT_STAT_FOLLOW) )
|
if (!m_creature->hasUnitState(UNIT_STAT_FOLLOW))
|
||||||
{
|
{
|
||||||
m_creature->GetMotionMaster()->MoveFollow(owner,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE);
|
m_creature->GetMotionMaster()->MoveFollow(owner,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE);
|
||||||
}
|
}
|
||||||
|
|
@ -199,7 +199,7 @@ void PetAI::UpdateAI(const uint32 diff)
|
||||||
if (!spellID)
|
if (!spellID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID);
|
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellID);
|
||||||
if (!spellInfo)
|
if (!spellInfo)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -236,7 +236,7 @@ void PetAI::UpdateAI(const uint32 diff)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Spell *spell = new Spell(m_creature, spellInfo, false);
|
Spell* spell = new Spell(m_creature, spellInfo, false);
|
||||||
|
|
||||||
if (inCombat && !m_creature->hasUnitState(UNIT_STAT_FOLLOW) && spell->CanAutoCast(m_creature->getVictim()))
|
if (inCombat && !m_creature->hasUnitState(UNIT_STAT_FOLLOW) && spell->CanAutoCast(m_creature->getVictim()))
|
||||||
{
|
{
|
||||||
|
|
@ -277,7 +277,7 @@ void PetAI::UpdateAI(const uint32 diff)
|
||||||
targetSpellStore.erase(targetSpellStore.begin() + index);
|
targetSpellStore.erase(targetSpellStore.begin() + index);
|
||||||
|
|
||||||
SpellCastTargets targets;
|
SpellCastTargets targets;
|
||||||
targets.setUnitTarget( target );
|
targets.setUnitTarget(target);
|
||||||
|
|
||||||
if (!m_creature->HasInArc(M_PI_F, target))
|
if (!m_creature->HasInArc(M_PI_F, target))
|
||||||
{
|
{
|
||||||
|
|
@ -286,7 +286,7 @@ void PetAI::UpdateAI(const uint32 diff)
|
||||||
m_creature->SendCreateUpdateToPlayer((Player*)target);
|
m_creature->SendCreateUpdateToPlayer((Player*)target);
|
||||||
|
|
||||||
if (owner && owner->GetTypeId() == TYPEID_PLAYER)
|
if (owner && owner->GetTypeId() == TYPEID_PLAYER)
|
||||||
m_creature->SendCreateUpdateToPlayer( (Player*)owner );
|
m_creature->SendCreateUpdateToPlayer((Player*)owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_creature->AddCreatureSpellCooldown(spell->m_spellInfo->Id);
|
m_creature->AddCreatureSpellCooldown(spell->m_spellInfo->Id);
|
||||||
|
|
@ -295,21 +295,21 @@ void PetAI::UpdateAI(const uint32 diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
// deleted cached Spell objects
|
// deleted cached Spell objects
|
||||||
for(TargetSpellList::const_iterator itr = targetSpellStore.begin(); itr != targetSpellStore.end(); ++itr)
|
for (TargetSpellList::const_iterator itr = targetSpellStore.begin(); itr != targetSpellStore.end(); ++itr)
|
||||||
delete itr->second;
|
delete itr->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PetAI::_isVisible(Unit *u) const
|
bool PetAI::_isVisible(Unit* u) const
|
||||||
{
|
{
|
||||||
return m_creature->IsWithinDist(u,sWorld.getConfig(CONFIG_FLOAT_SIGHT_GUARDER))
|
return m_creature->IsWithinDist(u,sWorld.getConfig(CONFIG_FLOAT_SIGHT_GUARDER))
|
||||||
&& u->isVisibleForOrDetect(m_creature,m_creature,true);
|
&& u->isVisibleForOrDetect(m_creature,m_creature,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetAI::UpdateAllies()
|
void PetAI::UpdateAllies()
|
||||||
{
|
{
|
||||||
Unit* owner = m_creature->GetCharmerOrOwner();
|
Unit* owner = m_creature->GetCharmerOrOwner();
|
||||||
Group *pGroup = NULL;
|
Group* pGroup = NULL;
|
||||||
|
|
||||||
m_updateAlliesTimer = 10*IN_MILLISECONDS; //update friendly targets every 10 seconds, lesser checks increase performance
|
m_updateAlliesTimer = 10*IN_MILLISECONDS; //update friendly targets every 10 seconds, lesser checks increase performance
|
||||||
|
|
||||||
|
|
@ -329,7 +329,7 @@ void PetAI::UpdateAllies()
|
||||||
m_AllySet.insert(m_creature->GetObjectGuid());
|
m_AllySet.insert(m_creature->GetObjectGuid());
|
||||||
if (pGroup) //add group
|
if (pGroup) //add group
|
||||||
{
|
{
|
||||||
for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
|
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||||
{
|
{
|
||||||
Player* target = itr->getSource();
|
Player* target = itr->getSource();
|
||||||
if (!target || !pGroup->SameSubGroup((Player*)owner, target))
|
if (!target || !pGroup->SameSubGroup((Player*)owner, target))
|
||||||
|
|
@ -345,10 +345,10 @@ void PetAI::UpdateAllies()
|
||||||
m_AllySet.insert(owner->GetObjectGuid());
|
m_AllySet.insert(owner->GetObjectGuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetAI::AttackedBy(Unit *attacker)
|
void PetAI::AttackedBy(Unit* attacker)
|
||||||
{
|
{
|
||||||
//when attacked, fight back in case 1)no victim already AND 2)not set to passive AND 3)not set to stay, unless can it can reach attacker with melee attack anyway
|
//when attacked, fight back in case 1)no victim already AND 2)not set to passive AND 3)not set to stay, unless can it can reach attacker with melee attack anyway
|
||||||
if(!m_creature->getVictim() && m_creature->GetCharmInfo() && !m_creature->GetCharmInfo()->HasReactState(REACT_PASSIVE) &&
|
if (!m_creature->getVictim() && m_creature->GetCharmInfo() && !m_creature->GetCharmInfo()->HasReactState(REACT_PASSIVE) &&
|
||||||
(!m_creature->GetCharmInfo()->HasCommandState(COMMAND_STAY) || m_creature->CanReachWithMeleeAttack(attacker)))
|
(!m_creature->GetCharmInfo()->HasCommandState(COMMAND_STAY) || m_creature->CanReachWithMeleeAttack(attacker)))
|
||||||
AttackStart(attacker);
|
AttackStart(attacker);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,19 +30,19 @@ class MANGOS_DLL_DECL PetAI : public CreatureAI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit PetAI(Creature *c);
|
explicit PetAI(Creature* c);
|
||||||
|
|
||||||
void MoveInLineOfSight(Unit *);
|
void MoveInLineOfSight(Unit*);
|
||||||
void AttackStart(Unit *);
|
void AttackStart(Unit*);
|
||||||
void EnterEvadeMode();
|
void EnterEvadeMode();
|
||||||
void AttackedBy(Unit*);
|
void AttackedBy(Unit*);
|
||||||
bool IsVisible(Unit *) const;
|
bool IsVisible(Unit*) const;
|
||||||
|
|
||||||
void UpdateAI(const uint32);
|
void UpdateAI(const uint32);
|
||||||
static int Permissible(const Creature *);
|
static int Permissible(const Creature*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _isVisible(Unit *) const;
|
bool _isVisible(Unit*) const;
|
||||||
bool _needToStop(void) const;
|
bool _needToStop(void) const;
|
||||||
void _stopAttack(void);
|
void _stopAttack(void);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data)
|
||||||
{
|
{
|
||||||
pet->SetInFront(unit_target);
|
pet->SetInFront(unit_target);
|
||||||
if (unit_target->GetTypeId() == TYPEID_PLAYER)
|
if (unit_target->GetTypeId() == TYPEID_PLAYER)
|
||||||
pet->SendCreateUpdateToPlayer( (Player*)unit_target );
|
pet->SendCreateUpdateToPlayer((Player*)unit_target);
|
||||||
}
|
}
|
||||||
else if (Unit* unit_target2 = spell->m_targets.getUnitTarget())
|
else if (Unit* unit_target2 = spell->m_targets.getUnitTarget())
|
||||||
{
|
{
|
||||||
|
|
@ -416,7 +416,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recv_data)
|
||||||
uint32 spell_id_0 = UNIT_ACTION_BUTTON_ACTION(data[0]);
|
uint32 spell_id_0 = UNIT_ACTION_BUTTON_ACTION(data[0]);
|
||||||
UnitActionBarEntry const* actionEntry_1 = charmInfo->GetActionBarEntry(position[1]);
|
UnitActionBarEntry const* actionEntry_1 = charmInfo->GetActionBarEntry(position[1]);
|
||||||
if (!actionEntry_1 || spell_id_0 != actionEntry_1->GetAction() ||
|
if (!actionEntry_1 || spell_id_0 != actionEntry_1->GetAction() ||
|
||||||
act_state_0 != actionEntry_1->GetType())
|
act_state_0 != actionEntry_1->GetType())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -426,7 +426,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recv_data)
|
||||||
uint32 spell_id_1 = UNIT_ACTION_BUTTON_ACTION(data[1]);
|
uint32 spell_id_1 = UNIT_ACTION_BUTTON_ACTION(data[1]);
|
||||||
UnitActionBarEntry const* actionEntry_0 = charmInfo->GetActionBarEntry(position[0]);
|
UnitActionBarEntry const* actionEntry_0 = charmInfo->GetActionBarEntry(position[0]);
|
||||||
if (!actionEntry_0 || spell_id_1 != actionEntry_0->GetAction() ||
|
if (!actionEntry_0 || spell_id_1 != actionEntry_0->GetAction() ||
|
||||||
act_state_1 != actionEntry_0->GetType())
|
act_state_1 != actionEntry_0->GetType())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -436,7 +436,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recv_data)
|
||||||
uint32 spell_id = UNIT_ACTION_BUTTON_ACTION(data[i]);
|
uint32 spell_id = UNIT_ACTION_BUTTON_ACTION(data[i]);
|
||||||
uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]);
|
uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]);
|
||||||
|
|
||||||
DETAIL_LOG( "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", _player->GetName(), position[i], spell_id, uint32(act_state));
|
DETAIL_LOG("Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", _player->GetName(), position[i], spell_id, uint32(act_state));
|
||||||
|
|
||||||
// if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add
|
// if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add
|
||||||
if (!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id)))
|
if (!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id)))
|
||||||
|
|
@ -478,10 +478,10 @@ void WorldSession::HandlePetRename(WorldPacket& recv_data)
|
||||||
recv_data >> isdeclined;
|
recv_data >> isdeclined;
|
||||||
|
|
||||||
Pet* pet = _player->GetMap()->GetPet(petGuid);
|
Pet* pet = _player->GetMap()->GetPet(petGuid);
|
||||||
// check it!
|
// check it!
|
||||||
if (!pet || pet->getPetType() != HUNTER_PET ||
|
if (!pet || pet->getPetType() != HUNTER_PET ||
|
||||||
!pet->HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) ||
|
!pet->HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) ||
|
||||||
pet->GetOwnerGuid() != _player->GetObjectGuid() || !pet->GetCharmInfo())
|
pet->GetOwnerGuid() != _player->GetObjectGuid() || !pet->GetCharmInfo())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PetNameInvalidReason res = ObjectMgr::CheckPetName(name);
|
PetNameInvalidReason res = ObjectMgr::CheckPetName(name);
|
||||||
|
|
@ -527,7 +527,7 @@ void WorldSession::HandlePetRename(WorldPacket& recv_data)
|
||||||
CharacterDatabase.escape_string(declinedname.name[i]);
|
CharacterDatabase.escape_string(declinedname.name[i]);
|
||||||
CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
|
CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
|
||||||
CharacterDatabase.PExecute("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%u','%s','%s','%s','%s','%s')",
|
CharacterDatabase.PExecute("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%u','%s','%s','%s','%s','%s')",
|
||||||
pet->GetCharmInfo()->GetPetNumber(), _player->GetGUIDLow(), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str());
|
pet->GetCharmInfo()->GetPetNumber(), _player->GetGUIDLow(), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
CharacterDatabase.escape_string(name);
|
CharacterDatabase.escape_string(name);
|
||||||
|
|
@ -620,7 +620,7 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pet->isCharmed())
|
if (pet->isCharmed())
|
||||||
// state can be used as boolean
|
// state can be used as boolean
|
||||||
pet->GetCharmInfo()->ToggleCreatureAutocast(spellid, state);
|
pet->GetCharmInfo()->ToggleCreatureAutocast(spellid, state);
|
||||||
else
|
else
|
||||||
((Pet*)pet)->ToggleAutocast(spellid, state);
|
((Pet*)pet)->ToggleAutocast(spellid, state);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
#define ARENA_TEAM_CHARTER_5v5_COST 2000000 // 200 G
|
#define ARENA_TEAM_CHARTER_5v5_COST 2000000 // 200 G
|
||||||
#define CHARTER_DISPLAY_ID 16161
|
#define CHARTER_DISPLAY_ID 16161
|
||||||
|
|
||||||
void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
|
void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("Received opcode CMSG_PETITION_BUY");
|
DEBUG_LOG("Received opcode CMSG_PETITION_BUY");
|
||||||
recv_data.hexlike();
|
recv_data.hexlike();
|
||||||
|
|
@ -82,7 +82,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
|
||||||
DEBUG_LOG("Petitioner %s tried sell petition: name %s", guidNPC.GetString().c_str(), name.c_str());
|
DEBUG_LOG("Petitioner %s tried sell petition: name %s", guidNPC.GetString().c_str(), name.c_str());
|
||||||
|
|
||||||
// prevent cheating
|
// prevent cheating
|
||||||
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guidNPC, UNIT_NPC_FLAG_PETITIONER);
|
Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guidNPC, UNIT_NPC_FLAG_PETITIONER);
|
||||||
if (!pCreature)
|
if (!pCreature)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("WORLD: HandlePetitionBuyOpcode - %s not found or you can't interact with him.", guidNPC.GetString().c_str());
|
DEBUG_LOG("WORLD: HandlePetitionBuyOpcode - %s not found or you can't interact with him.", guidNPC.GetString().c_str());
|
||||||
|
|
@ -90,17 +90,17 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove fake death
|
// remove fake death
|
||||||
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
||||||
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||||
|
|
||||||
uint32 charterid = 0;
|
uint32 charterid = 0;
|
||||||
uint32 cost = 0;
|
uint32 cost = 0;
|
||||||
uint32 type = 0;
|
uint32 type = 0;
|
||||||
if(pCreature->isTabardDesigner())
|
if (pCreature->isTabardDesigner())
|
||||||
{
|
{
|
||||||
// if tabard designer, then trying to buy a guild charter.
|
// if tabard designer, then trying to buy a guild charter.
|
||||||
// do not let if already in guild.
|
// do not let if already in guild.
|
||||||
if(_player->GetGuildId())
|
if (_player->GetGuildId())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
charterid = GUILD_CHARTER;
|
charterid = GUILD_CHARTER;
|
||||||
|
|
@ -110,13 +110,13 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: find correct opcode
|
// TODO: find correct opcode
|
||||||
if(_player->getLevel() < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
|
if (_player->getLevel() < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
|
||||||
{
|
{
|
||||||
SendNotification(LANG_ARENA_ONE_TOOLOW, sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL));
|
SendNotification(LANG_ARENA_ONE_TOOLOW, sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(clientIndex) // arenaSlot+1 as received from client (1 from 3 case)
|
switch (clientIndex) // arenaSlot+1 as received from client (1 from 3 case)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
charterid = ARENA_TEAM_CHARTER_2v2;
|
charterid = ARENA_TEAM_CHARTER_2v2;
|
||||||
|
|
@ -138,21 +138,21 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_player->GetArenaTeamId(clientIndex - 1)) // arenaSlot+1 as received from client
|
if (_player->GetArenaTeamId(clientIndex - 1)) // arenaSlot+1 as received from client
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ALREADY_IN_ARENA_TEAM);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ALREADY_IN_ARENA_TEAM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == 9)
|
if (type == 9)
|
||||||
{
|
{
|
||||||
if (sGuildMgr.GetGuildByName(name))
|
if (sGuildMgr.GetGuildByName(name))
|
||||||
{
|
{
|
||||||
SendGuildCommandResult(GUILD_CREATE_S, name, ERR_GUILD_NAME_EXISTS_S);
|
SendGuildCommandResult(GUILD_CREATE_S, name, ERR_GUILD_NAME_EXISTS_S);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(sObjectMgr.IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
|
if (sObjectMgr.IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
|
||||||
{
|
{
|
||||||
SendGuildCommandResult(GUILD_CREATE_S, name, ERR_GUILD_NAME_INVALID);
|
SendGuildCommandResult(GUILD_CREATE_S, name, ERR_GUILD_NAME_INVALID);
|
||||||
return;
|
return;
|
||||||
|
|
@ -160,42 +160,43 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(sObjectMgr.GetArenaTeamByName(name))
|
if (sObjectMgr.GetArenaTeamByName(name))
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(sObjectMgr.IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
|
if (sObjectMgr.IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_INVALID);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_INVALID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(charterid);
|
ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(charterid);
|
||||||
if(!pProto)
|
if (!pProto)
|
||||||
{
|
{
|
||||||
_player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, charterid, 0);
|
_player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, charterid, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_player->GetMoney() < cost)
|
if (_player->GetMoney() < cost)
|
||||||
{ //player hasn't got enough money
|
{
|
||||||
|
//player hasn't got enough money
|
||||||
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, charterid, 0);
|
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, charterid, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemPosCountVec dest;
|
ItemPosCountVec dest;
|
||||||
InventoryResult msg = _player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, charterid, pProto->BuyCount );
|
InventoryResult msg = _player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, charterid, pProto->BuyCount);
|
||||||
if(msg != EQUIP_ERR_OK)
|
if (msg != EQUIP_ERR_OK)
|
||||||
{
|
{
|
||||||
_player->SendEquipError(msg, NULL, NULL, charterid);
|
_player->SendEquipError(msg, NULL, NULL, charterid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_player->ModifyMoney(-(int32)cost);
|
_player->ModifyMoney(-(int32)cost);
|
||||||
Item *charter = _player->StoreNewItem(dest, charterid, true);
|
Item* charter = _player->StoreNewItem(dest, charterid, true);
|
||||||
if(!charter)
|
if (!charter)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
charter->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, charter->GetGUIDLow());
|
charter->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, charter->GetGUIDLow());
|
||||||
|
|
@ -206,7 +207,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
|
||||||
|
|
||||||
// a petition is invalid, if both the owner and the type matches
|
// a petition is invalid, if both the owner and the type matches
|
||||||
// we checked above, if this player is in an arenateam, so this must be data corruption
|
// we checked above, if this player is in an arenateam, so this must be data corruption
|
||||||
QueryResult *result = CharacterDatabase.PQuery("SELECT petitionguid FROM petition WHERE ownerguid = '%u' AND type = '%u'", _player->GetGUIDLow(), type);
|
QueryResult* result = CharacterDatabase.PQuery("SELECT petitionguid FROM petition WHERE ownerguid = '%u' AND type = '%u'", _player->GetGUIDLow(), type);
|
||||||
|
|
||||||
std::ostringstream ssInvalidPetitionGUIDs;
|
std::ostringstream ssInvalidPetitionGUIDs;
|
||||||
|
|
||||||
|
|
@ -214,9 +215,10 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Field *fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
ssInvalidPetitionGUIDs << "'" << fields[0].GetUInt32() << "' , ";
|
ssInvalidPetitionGUIDs << "'" << fields[0].GetUInt32() << "' , ";
|
||||||
} while (result->NextRow());
|
}
|
||||||
|
while (result->NextRow());
|
||||||
|
|
||||||
delete result;
|
delete result;
|
||||||
}
|
}
|
||||||
|
|
@ -230,13 +232,13 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
|
||||||
CharacterDatabase.PExecute("DELETE FROM petition WHERE petitionguid IN ( %s )", ssInvalidPetitionGUIDs.str().c_str());
|
CharacterDatabase.PExecute("DELETE FROM petition WHERE petitionguid IN ( %s )", ssInvalidPetitionGUIDs.str().c_str());
|
||||||
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE petitionguid IN ( %s )", ssInvalidPetitionGUIDs.str().c_str());
|
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE petitionguid IN ( %s )", ssInvalidPetitionGUIDs.str().c_str());
|
||||||
CharacterDatabase.PExecute("INSERT INTO petition (ownerguid, petitionguid, name, type) VALUES ('%u', '%u', '%s', '%u')",
|
CharacterDatabase.PExecute("INSERT INTO petition (ownerguid, petitionguid, name, type) VALUES ('%u', '%u', '%s', '%u')",
|
||||||
_player->GetGUIDLow(), charter->GetGUIDLow(), name.c_str(), type);
|
_player->GetGUIDLow(), charter->GetGUIDLow(), name.c_str(), type);
|
||||||
CharacterDatabase.CommitTransaction();
|
CharacterDatabase.CommitTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data)
|
void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recv_data)
|
||||||
{
|
{
|
||||||
// ok
|
// ok
|
||||||
DEBUG_LOG("Received opcode CMSG_PETITION_SHOW_SIGNATURES");
|
DEBUG_LOG("Received opcode CMSG_PETITION_SHOW_SIGNATURES");
|
||||||
//recv_data.hexlike();
|
//recv_data.hexlike();
|
||||||
|
|
||||||
|
|
@ -247,24 +249,24 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data)
|
||||||
// solve (possible) some strange compile problems with explicit use GUID_LOPART(petitionguid) at some GCC versions (wrong code optimization in compiler?)
|
// solve (possible) some strange compile problems with explicit use GUID_LOPART(petitionguid) at some GCC versions (wrong code optimization in compiler?)
|
||||||
uint32 petitionguid_low = petitionguid.GetCounter();
|
uint32 petitionguid_low = petitionguid.GetCounter();
|
||||||
|
|
||||||
QueryResult *result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", petitionguid_low);
|
QueryResult* result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", petitionguid_low);
|
||||||
if(!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
sLog.outError("any petition on server...");
|
sLog.outError("any petition on server...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Field *fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
uint32 type = fields[0].GetUInt32();
|
uint32 type = fields[0].GetUInt32();
|
||||||
delete result;
|
delete result;
|
||||||
|
|
||||||
// if guild petition and has guild => error, return;
|
// if guild petition and has guild => error, return;
|
||||||
if(type == 9 && _player->GetGuildId())
|
if (type == 9 && _player->GetGuildId())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", petitionguid_low);
|
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", petitionguid_low);
|
||||||
|
|
||||||
// result==NULL also correct in case no sign yet
|
// result==NULL also correct in case no sign yet
|
||||||
if(result)
|
if (result)
|
||||||
signs = (uint8)result->GetRowCount();
|
signs = (uint8)result->GetRowCount();
|
||||||
|
|
||||||
DEBUG_LOG("CMSG_PETITION_SHOW_SIGNATURES petition: %s", petitionguid.GetString().c_str());
|
DEBUG_LOG("CMSG_PETITION_SHOW_SIGNATURES petition: %s", petitionguid.GetString().c_str());
|
||||||
|
|
@ -275,9 +277,9 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data)
|
||||||
data << uint32(petitionguid_low); // guild guid (in mangos always same as GUID_LOPART(petitionguid)
|
data << uint32(petitionguid_low); // guild guid (in mangos always same as GUID_LOPART(petitionguid)
|
||||||
data << uint8(signs); // sign's count
|
data << uint8(signs); // sign's count
|
||||||
|
|
||||||
for(uint8 i = 1; i <= signs; ++i)
|
for (uint8 i = 1; i <= signs; ++i)
|
||||||
{
|
{
|
||||||
Field *fields2 = result->Fetch();
|
Field* fields2 = result->Fetch();
|
||||||
ObjectGuid signerGuid = ObjectGuid(HIGHGUID_PLAYER, fields2[0].GetUInt32());
|
ObjectGuid signerGuid = ObjectGuid(HIGHGUID_PLAYER, fields2[0].GetUInt32());
|
||||||
|
|
||||||
data << ObjectGuid(signerGuid); // Player GUID
|
data << ObjectGuid(signerGuid); // Player GUID
|
||||||
|
|
@ -289,7 +291,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data)
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandlePetitionQueryOpcode(WorldPacket & recv_data)
|
void WorldSession::HandlePetitionQueryOpcode(WorldPacket& recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("Received opcode CMSG_PETITION_QUERY");
|
DEBUG_LOG("Received opcode CMSG_PETITION_QUERY");
|
||||||
//recv_data.hexlike();
|
//recv_data.hexlike();
|
||||||
|
|
@ -312,11 +314,11 @@ void WorldSession::SendPetitionQueryOpcode(ObjectGuid petitionguid)
|
||||||
std::string name = "NO_NAME_FOR_GUID";
|
std::string name = "NO_NAME_FOR_GUID";
|
||||||
uint8 signs = 0;
|
uint8 signs = 0;
|
||||||
|
|
||||||
QueryResult *result = CharacterDatabase.PQuery(
|
QueryResult* result = CharacterDatabase.PQuery(
|
||||||
"SELECT ownerguid, name, "
|
"SELECT ownerguid, name, "
|
||||||
" (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs, "
|
" (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs, "
|
||||||
" type "
|
" type "
|
||||||
"FROM petition WHERE petitionguid = '%u'", petitionLowGuid, petitionLowGuid);
|
"FROM petition WHERE petitionguid = '%u'", petitionLowGuid, petitionLowGuid);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
|
|
@ -359,7 +361,7 @@ void WorldSession::SendPetitionQueryOpcode(ObjectGuid petitionguid)
|
||||||
data << uint32(0); // 11
|
data << uint32(0); // 11
|
||||||
data << uint32(0); // 13 count of next strings?
|
data << uint32(0); // 13 count of next strings?
|
||||||
|
|
||||||
for(int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
data << uint8(0); // some string
|
data << uint8(0); // some string
|
||||||
|
|
||||||
data << uint32(0); // 14
|
data << uint32(0); // 14
|
||||||
|
|
@ -372,7 +374,7 @@ void WorldSession::SendPetitionQueryOpcode(ObjectGuid petitionguid)
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data)
|
void WorldSession::HandlePetitionRenameOpcode(WorldPacket& recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("Received opcode MSG_PETITION_RENAME"); // ok
|
DEBUG_LOG("Received opcode MSG_PETITION_RENAME"); // ok
|
||||||
//recv_data.hexlike();
|
//recv_data.hexlike();
|
||||||
|
|
@ -384,13 +386,13 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data)
|
||||||
recv_data >> petitionGuid; // guid
|
recv_data >> petitionGuid; // guid
|
||||||
recv_data >> newname; // new name
|
recv_data >> newname; // new name
|
||||||
|
|
||||||
Item *item = _player->GetItemByGuid(petitionGuid);
|
Item* item = _player->GetItemByGuid(petitionGuid);
|
||||||
if(!item)
|
if (!item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QueryResult *result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", petitionGuid.GetCounter());
|
QueryResult* result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", petitionGuid.GetCounter());
|
||||||
|
|
||||||
if(result)
|
if (result)
|
||||||
{
|
{
|
||||||
Field* fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
type = fields[0].GetUInt32();
|
type = fields[0].GetUInt32();
|
||||||
|
|
@ -402,14 +404,14 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == 9)
|
if (type == 9)
|
||||||
{
|
{
|
||||||
if (sGuildMgr.GetGuildByName(newname))
|
if (sGuildMgr.GetGuildByName(newname))
|
||||||
{
|
{
|
||||||
SendGuildCommandResult(GUILD_CREATE_S, newname, ERR_GUILD_NAME_EXISTS_S);
|
SendGuildCommandResult(GUILD_CREATE_S, newname, ERR_GUILD_NAME_EXISTS_S);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(sObjectMgr.IsReservedName(newname) || !ObjectMgr::IsValidCharterName(newname))
|
if (sObjectMgr.IsReservedName(newname) || !ObjectMgr::IsValidCharterName(newname))
|
||||||
{
|
{
|
||||||
SendGuildCommandResult(GUILD_CREATE_S, newname, ERR_GUILD_NAME_INVALID);
|
SendGuildCommandResult(GUILD_CREATE_S, newname, ERR_GUILD_NAME_INVALID);
|
||||||
return;
|
return;
|
||||||
|
|
@ -417,12 +419,12 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(sObjectMgr.GetArenaTeamByName(newname))
|
if (sObjectMgr.GetArenaTeamByName(newname))
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, newname, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, newname, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(sObjectMgr.IsReservedName(newname) || !ObjectMgr::IsValidCharterName(newname))
|
if (sObjectMgr.IsReservedName(newname) || !ObjectMgr::IsValidCharterName(newname))
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, newname, "", ERR_ARENA_TEAM_NAME_INVALID);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, newname, "", ERR_ARENA_TEAM_NAME_INVALID);
|
||||||
return;
|
return;
|
||||||
|
|
@ -432,7 +434,7 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data)
|
||||||
std::string db_newname = newname;
|
std::string db_newname = newname;
|
||||||
CharacterDatabase.escape_string(db_newname);
|
CharacterDatabase.escape_string(db_newname);
|
||||||
CharacterDatabase.PExecute("UPDATE petition SET name = '%s' WHERE petitionguid = '%u'",
|
CharacterDatabase.PExecute("UPDATE petition SET name = '%s' WHERE petitionguid = '%u'",
|
||||||
db_newname.c_str(), petitionGuid.GetCounter());
|
db_newname.c_str(), petitionGuid.GetCounter());
|
||||||
|
|
||||||
DEBUG_LOG("Petition %s renamed to '%s'", petitionGuid.GetString().c_str(), newname.c_str());
|
DEBUG_LOG("Petition %s renamed to '%s'", petitionGuid.GetString().c_str(), newname.c_str());
|
||||||
|
|
||||||
|
|
@ -442,12 +444,12 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data)
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
|
void WorldSession::HandlePetitionSignOpcode(WorldPacket& recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("Received opcode CMSG_PETITION_SIGN"); // ok
|
DEBUG_LOG("Received opcode CMSG_PETITION_SIGN"); // ok
|
||||||
//recv_data.hexlike();
|
//recv_data.hexlike();
|
||||||
|
|
||||||
Field *fields;
|
Field* fields;
|
||||||
ObjectGuid petitionGuid;
|
ObjectGuid petitionGuid;
|
||||||
uint8 unk;
|
uint8 unk;
|
||||||
recv_data >> petitionGuid; // petition guid
|
recv_data >> petitionGuid; // petition guid
|
||||||
|
|
@ -455,13 +457,13 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
|
||||||
|
|
||||||
uint32 petitionLowGuid = petitionGuid.GetCounter();
|
uint32 petitionLowGuid = petitionGuid.GetCounter();
|
||||||
|
|
||||||
QueryResult *result = CharacterDatabase.PQuery(
|
QueryResult* result = CharacterDatabase.PQuery(
|
||||||
"SELECT ownerguid, "
|
"SELECT ownerguid, "
|
||||||
" (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs, "
|
" (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs, "
|
||||||
" type "
|
" type "
|
||||||
"FROM petition WHERE petitionguid = '%u'", petitionLowGuid, petitionLowGuid);
|
"FROM petition WHERE petitionguid = '%u'", petitionLowGuid, petitionLowGuid);
|
||||||
|
|
||||||
if(!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
sLog.outError("any petition on server...");
|
sLog.outError("any petition on server...");
|
||||||
return;
|
return;
|
||||||
|
|
@ -480,18 +482,18 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
|
||||||
|
|
||||||
// not let enemies sign guild charter
|
// not let enemies sign guild charter
|
||||||
if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) &&
|
if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) &&
|
||||||
GetPlayer()->GetTeam() != sObjectMgr.GetPlayerTeamByGUID(ownerGuid))
|
GetPlayer()->GetTeam() != sObjectMgr.GetPlayerTeamByGUID(ownerGuid))
|
||||||
{
|
{
|
||||||
if(type != 9)
|
if (type != 9)
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
|
||||||
else
|
else
|
||||||
SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_NOT_ALLIED);
|
SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_NOT_ALLIED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type != 9)
|
if (type != 9)
|
||||||
{
|
{
|
||||||
if(_player->getLevel() < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
|
if (_player->getLevel() < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", _player->GetName(), ERR_ARENA_TEAM_TARGET_TOO_LOW_S);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", _player->GetName(), ERR_ARENA_TEAM_TARGET_TOO_LOW_S);
|
||||||
return;
|
return;
|
||||||
|
|
@ -501,16 +503,16 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint8 slot = ArenaTeam::GetSlotByType(ArenaType(type));
|
uint8 slot = ArenaTeam::GetSlotByType(ArenaType(type));
|
||||||
if(slot >= MAX_ARENA_SLOT)
|
if (slot >= MAX_ARENA_SLOT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(_player->GetArenaTeamId(slot))
|
if (_player->GetArenaTeamId(slot))
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_IN_ARENA_TEAM_S);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_IN_ARENA_TEAM_S);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_player->GetArenaTeamIdInvited())
|
if (_player->GetArenaTeamIdInvited())
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S);
|
||||||
return;
|
return;
|
||||||
|
|
@ -518,26 +520,26 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(_player->GetGuildId())
|
if (_player->GetGuildId())
|
||||||
{
|
{
|
||||||
SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ERR_ALREADY_IN_GUILD_S);
|
SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ERR_ALREADY_IN_GUILD_S);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(_player->GetGuildIdInvited())
|
if (_player->GetGuildIdInvited())
|
||||||
{
|
{
|
||||||
SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ERR_ALREADY_INVITED_TO_GUILD_S);
|
SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ERR_ALREADY_INVITED_TO_GUILD_S);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(++signs > type) // client signs maximum
|
if (++signs > type) // client signs maximum
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//client doesn't allow to sign petition two times by one character, but not check sign by another character from same account
|
//client doesn't allow to sign petition two times by one character, but not check sign by another character from same account
|
||||||
//not allow sign another player from already sign player account
|
//not allow sign another player from already sign player account
|
||||||
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE player_account = '%u' AND petitionguid = '%u'", GetAccountId(), petitionLowGuid);
|
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE player_account = '%u' AND petitionguid = '%u'", GetAccountId(), petitionLowGuid);
|
||||||
|
|
||||||
if(result)
|
if (result)
|
||||||
{
|
{
|
||||||
delete result;
|
delete result;
|
||||||
WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4));
|
WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4));
|
||||||
|
|
@ -549,13 +551,13 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
|
|
||||||
// update for owner if online
|
// update for owner if online
|
||||||
if(Player *owner = sObjectMgr.GetPlayer(ownerGuid))
|
if (Player* owner = sObjectMgr.GetPlayer(ownerGuid))
|
||||||
owner->GetSession()->SendPacket(&data);
|
owner->GetSession()->SendPacket(&data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CharacterDatabase.PExecute("INSERT INTO petition_sign (ownerguid,petitionguid, playerguid, player_account) VALUES ('%u', '%u', '%u','%u')",
|
CharacterDatabase.PExecute("INSERT INTO petition_sign (ownerguid,petitionguid, playerguid, player_account) VALUES ('%u', '%u', '%u','%u')",
|
||||||
ownerLowGuid, petitionLowGuid, _player->GetGUIDLow(), GetAccountId());
|
ownerLowGuid, petitionLowGuid, _player->GetGUIDLow(), GetAccountId());
|
||||||
|
|
||||||
DEBUG_LOG("PETITION SIGN: %s by %s", petitionGuid.GetString().c_str(), _player->GetGuidStr().c_str());
|
DEBUG_LOG("PETITION SIGN: %s by %s", petitionGuid.GetString().c_str(), _player->GetGuidStr().c_str());
|
||||||
|
|
||||||
|
|
@ -573,11 +575,11 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
|
||||||
// item->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1+1, signs);
|
// item->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1+1, signs);
|
||||||
|
|
||||||
// update for owner if online
|
// update for owner if online
|
||||||
if(Player *owner = sObjectMgr.GetPlayer(ownerGuid))
|
if (Player* owner = sObjectMgr.GetPlayer(ownerGuid))
|
||||||
owner->GetSession()->SendPacket(&data);
|
owner->GetSession()->SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandlePetitionDeclineOpcode(WorldPacket & recv_data)
|
void WorldSession::HandlePetitionDeclineOpcode(WorldPacket& recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("Received opcode MSG_PETITION_DECLINE"); // ok
|
DEBUG_LOG("Received opcode MSG_PETITION_DECLINE"); // ok
|
||||||
//recv_data.hexlike();
|
//recv_data.hexlike();
|
||||||
|
|
@ -589,16 +591,16 @@ void WorldSession::HandlePetitionDeclineOpcode(WorldPacket & recv_data)
|
||||||
|
|
||||||
uint32 petitionLowGuid = petitionGuid.GetCounter();
|
uint32 petitionLowGuid = petitionGuid.GetCounter();
|
||||||
|
|
||||||
QueryResult *result = CharacterDatabase.PQuery("SELECT ownerguid FROM petition WHERE petitionguid = '%u'", petitionLowGuid);
|
QueryResult* result = CharacterDatabase.PQuery("SELECT ownerguid FROM petition WHERE petitionguid = '%u'", petitionLowGuid);
|
||||||
if (!result)
|
if (!result)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Field *fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
ObjectGuid ownerguid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
|
ObjectGuid ownerguid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
|
||||||
delete result;
|
delete result;
|
||||||
|
|
||||||
Player *owner = sObjectMgr.GetPlayer(ownerguid);
|
Player* owner = sObjectMgr.GetPlayer(ownerguid);
|
||||||
if(owner) // petition owner online
|
if (owner) // petition owner online
|
||||||
{
|
{
|
||||||
WorldPacket data(MSG_PETITION_DECLINE, 8);
|
WorldPacket data(MSG_PETITION_DECLINE, 8);
|
||||||
data << _player->GetObjectGuid();
|
data << _player->GetObjectGuid();
|
||||||
|
|
@ -606,7 +608,7 @@ void WorldSession::HandlePetitionDeclineOpcode(WorldPacket & recv_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data)
|
void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("Received opcode CMSG_OFFER_PETITION"); // ok
|
DEBUG_LOG("Received opcode CMSG_OFFER_PETITION"); // ok
|
||||||
//recv_data.hexlike();
|
//recv_data.hexlike();
|
||||||
|
|
@ -618,33 +620,33 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data)
|
||||||
recv_data >> petitionGuid; // petition guid
|
recv_data >> petitionGuid; // petition guid
|
||||||
recv_data >> playerGuid; // player guid
|
recv_data >> playerGuid; // player guid
|
||||||
|
|
||||||
Player *player = ObjectAccessor::FindPlayer(playerGuid);
|
Player* player = ObjectAccessor::FindPlayer(playerGuid);
|
||||||
if (!player)
|
if (!player)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/// Get petition type and check
|
/// Get petition type and check
|
||||||
QueryResult *result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", petitionGuid.GetCounter());
|
QueryResult* result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", petitionGuid.GetCounter());
|
||||||
if (!result)
|
if (!result)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Field *fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
uint32 type = fields[0].GetUInt32();
|
uint32 type = fields[0].GetUInt32();
|
||||||
delete result;
|
delete result;
|
||||||
|
|
||||||
DEBUG_LOG("OFFER PETITION: type %u petition %s to %s", type, petitionGuid.GetString().c_str(), playerGuid.GetString().c_str());
|
DEBUG_LOG("OFFER PETITION: type %u petition %s to %s", type, petitionGuid.GetString().c_str(), playerGuid.GetString().c_str());
|
||||||
|
|
||||||
if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != player->GetTeam() )
|
if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != player->GetTeam())
|
||||||
{
|
{
|
||||||
if(type != 9)
|
if (type != 9)
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
|
||||||
else
|
else
|
||||||
SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_NOT_ALLIED);
|
SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_NOT_ALLIED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type != 9)
|
if (type != 9)
|
||||||
{
|
{
|
||||||
if(player->getLevel() < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
|
if (player->getLevel() < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
|
||||||
{
|
{
|
||||||
// player is too low level to join an arena team
|
// player is too low level to join an arena team
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", player->GetName(), ERR_ARENA_TEAM_TARGET_TOO_LOW_S);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", player->GetName(), ERR_ARENA_TEAM_TARGET_TOO_LOW_S);
|
||||||
|
|
@ -655,17 +657,17 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint8 slot = ArenaTeam::GetSlotByType(ArenaType(type));
|
uint8 slot = ArenaTeam::GetSlotByType(ArenaType(type));
|
||||||
if(slot >= MAX_ARENA_SLOT)
|
if (slot >= MAX_ARENA_SLOT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(player->GetArenaTeamId(slot))
|
if (player->GetArenaTeamId(slot))
|
||||||
{
|
{
|
||||||
// player is already in an arena team
|
// player is already in an arena team
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", player->GetName(), ERR_ALREADY_IN_ARENA_TEAM_S);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", player->GetName(), ERR_ALREADY_IN_ARENA_TEAM_S);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player->GetArenaTeamIdInvited())
|
if (player->GetArenaTeamIdInvited())
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S);
|
||||||
return;
|
return;
|
||||||
|
|
@ -673,13 +675,13 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(player->GetGuildId())
|
if (player->GetGuildId())
|
||||||
{
|
{
|
||||||
SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ERR_ALREADY_IN_GUILD_S);
|
SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ERR_ALREADY_IN_GUILD_S);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player->GetGuildIdInvited())
|
if (player->GetGuildIdInvited())
|
||||||
{
|
{
|
||||||
SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ERR_ALREADY_INVITED_TO_GUILD_S);
|
SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ERR_ALREADY_INVITED_TO_GUILD_S);
|
||||||
return;
|
return;
|
||||||
|
|
@ -690,7 +692,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data)
|
||||||
uint8 signs = 0;
|
uint8 signs = 0;
|
||||||
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", petitionGuid.GetCounter());
|
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", petitionGuid.GetCounter());
|
||||||
// result==NULL also correct charter without signs
|
// result==NULL also correct charter without signs
|
||||||
if(result)
|
if (result)
|
||||||
signs = (uint8)result->GetRowCount();
|
signs = (uint8)result->GetRowCount();
|
||||||
|
|
||||||
/// Send response
|
/// Send response
|
||||||
|
|
@ -700,9 +702,9 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data)
|
||||||
data << uint32(petitionGuid.GetCounter()); // guild guid (in mangos always same as low part of petition guid)
|
data << uint32(petitionGuid.GetCounter()); // guild guid (in mangos always same as low part of petition guid)
|
||||||
data << uint8(signs); // sign's count
|
data << uint8(signs); // sign's count
|
||||||
|
|
||||||
for(uint8 i = 1; i <= signs; ++i)
|
for (uint8 i = 1; i <= signs; ++i)
|
||||||
{
|
{
|
||||||
Field *fields2 = result->Fetch();
|
Field* fields2 = result->Fetch();
|
||||||
ObjectGuid signerGuid = ObjectGuid(HIGHGUID_PLAYER, fields2[0].GetUInt32());
|
ObjectGuid signerGuid = ObjectGuid(HIGHGUID_PLAYER, fields2[0].GetUInt32());
|
||||||
|
|
||||||
data << ObjectGuid(signerGuid); // Player GUID
|
data << ObjectGuid(signerGuid); // Player GUID
|
||||||
|
|
@ -715,7 +717,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data)
|
||||||
player->GetSession()->SendPacket(&data);
|
player->GetSession()->SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("Received opcode CMSG_TURN_IN_PETITION"); // ok
|
DEBUG_LOG("Received opcode CMSG_TURN_IN_PETITION"); // ok
|
||||||
//recv_data.hexlike();
|
//recv_data.hexlike();
|
||||||
|
|
@ -732,10 +734,10 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
// data
|
// data
|
||||||
QueryResult *result = CharacterDatabase.PQuery("SELECT ownerguid, name, type FROM petition WHERE petitionguid = '%u'", petitionGuid.GetCounter());
|
QueryResult* result = CharacterDatabase.PQuery("SELECT ownerguid, name, type FROM petition WHERE petitionguid = '%u'", petitionGuid.GetCounter());
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
Field *fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
ownerGuid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
|
ownerGuid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
|
||||||
name = fields[1].GetCppString();
|
name = fields[1].GetCppString();
|
||||||
type = fields[2].GetUInt32();
|
type = fields[2].GetUInt32();
|
||||||
|
|
@ -747,9 +749,9 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == 9)
|
if (type == 9)
|
||||||
{
|
{
|
||||||
if(_player->GetGuildId())
|
if (_player->GetGuildId())
|
||||||
{
|
{
|
||||||
WorldPacket data(SMSG_TURN_IN_PETITION_RESULTS, 4);
|
WorldPacket data(SMSG_TURN_IN_PETITION_RESULTS, 4);
|
||||||
data << uint32(PETITION_TURN_ALREADY_IN_GUILD); // already in guild
|
data << uint32(PETITION_TURN_ALREADY_IN_GUILD); // already in guild
|
||||||
|
|
@ -793,7 +795,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == 9)
|
if (type == 9)
|
||||||
{
|
{
|
||||||
if (sGuildMgr.GetGuildByName(name))
|
if (sGuildMgr.GetGuildByName(name))
|
||||||
{
|
{
|
||||||
|
|
@ -804,7 +806,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(sObjectMgr.GetArenaTeamByName(name))
|
if (sObjectMgr.GetArenaTeamByName(name))
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
||||||
delete result;
|
delete result;
|
||||||
|
|
@ -813,7 +815,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// and at last charter item check
|
// and at last charter item check
|
||||||
Item *item = _player->GetItemByGuid(petitionGuid);
|
Item* item = _player->GetItemByGuid(petitionGuid);
|
||||||
if (!item)
|
if (!item)
|
||||||
{
|
{
|
||||||
delete result;
|
delete result;
|
||||||
|
|
@ -825,10 +827,10 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
||||||
// delete charter item
|
// delete charter item
|
||||||
_player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
|
_player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
|
||||||
|
|
||||||
if(type == 9) // create guild
|
if (type == 9) // create guild
|
||||||
{
|
{
|
||||||
Guild* guild = new Guild;
|
Guild* guild = new Guild;
|
||||||
if(!guild->Create(_player, name))
|
if (!guild->Create(_player, name))
|
||||||
{
|
{
|
||||||
delete guild;
|
delete guild;
|
||||||
delete result;
|
delete result;
|
||||||
|
|
@ -839,7 +841,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
||||||
sGuildMgr.AddGuild(guild);
|
sGuildMgr.AddGuild(guild);
|
||||||
|
|
||||||
// add members
|
// add members
|
||||||
for(uint8 i = 0; i < signs; ++i)
|
for (uint8 i = 0; i < signs; ++i)
|
||||||
{
|
{
|
||||||
Field* fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
|
|
||||||
|
|
@ -872,7 +874,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
||||||
DEBUG_LOG("PetitonsHandler: arena team added to objmrg");
|
DEBUG_LOG("PetitonsHandler: arena team added to objmrg");
|
||||||
|
|
||||||
// add members
|
// add members
|
||||||
for(uint8 i = 0; i < signs; ++i)
|
for (uint8 i = 0; i < signs; ++i)
|
||||||
{
|
{
|
||||||
Field* fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
ObjectGuid memberGUID = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
|
ObjectGuid memberGUID = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
|
||||||
|
|
@ -900,7 +902,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandlePetitionShowListOpcode(WorldPacket & recv_data)
|
void WorldSession::HandlePetitionShowListOpcode(WorldPacket& recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("Received CMSG_PETITION_SHOWLIST");
|
DEBUG_LOG("Received CMSG_PETITION_SHOWLIST");
|
||||||
//recv_data.hexlike();
|
//recv_data.hexlike();
|
||||||
|
|
@ -913,7 +915,7 @@ void WorldSession::HandlePetitionShowListOpcode(WorldPacket & recv_data)
|
||||||
|
|
||||||
void WorldSession::SendPetitionShowList(ObjectGuid guid)
|
void WorldSession::SendPetitionShowList(ObjectGuid guid)
|
||||||
{
|
{
|
||||||
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_PETITIONER);
|
Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_PETITIONER);
|
||||||
if (!pCreature)
|
if (!pCreature)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("WORLD: HandlePetitionShowListOpcode - %s not found or you can't interact with him.", guid.GetString().c_str());
|
DEBUG_LOG("WORLD: HandlePetitionShowListOpcode - %s not found or you can't interact with him.", guid.GetString().c_str());
|
||||||
|
|
@ -921,11 +923,11 @@ void WorldSession::SendPetitionShowList(ObjectGuid guid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove fake death
|
// remove fake death
|
||||||
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
||||||
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||||
|
|
||||||
uint8 count = 0;
|
uint8 count = 0;
|
||||||
if(pCreature->isTabardDesigner())
|
if (pCreature->isTabardDesigner())
|
||||||
count = 1;
|
count = 1;
|
||||||
else
|
else
|
||||||
count = 3;
|
count = 3;
|
||||||
|
|
@ -933,7 +935,7 @@ void WorldSession::SendPetitionShowList(ObjectGuid guid)
|
||||||
WorldPacket data(SMSG_PETITION_SHOWLIST, 8+1+4*6);
|
WorldPacket data(SMSG_PETITION_SHOWLIST, 8+1+4*6);
|
||||||
data << ObjectGuid(guid); // npc guid
|
data << ObjectGuid(guid); // npc guid
|
||||||
data << uint8(count); // count
|
data << uint8(count); // count
|
||||||
if(count == 1)
|
if (count == 1)
|
||||||
{
|
{
|
||||||
data << uint32(1); // index
|
data << uint32(1); // index
|
||||||
data << uint32(GUILD_CHARTER); // charter entry
|
data << uint32(GUILD_CHARTER); // charter entry
|
||||||
|
|
|
||||||
5459
src/game/Player.cpp
5459
src/game/Player.cpp
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -68,11 +68,11 @@ static DumpTable dumpTables[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
// Low level functions
|
// Low level functions
|
||||||
static bool findtoknth(std::string &str, int n, std::string::size_type &s, std::string::size_type &e)
|
static bool findtoknth(std::string& str, int n, std::string::size_type& s, std::string::size_type& e)
|
||||||
{
|
{
|
||||||
int i; s = e = 0;
|
int i; s = e = 0;
|
||||||
std::string::size_type size = str.size();
|
std::string::size_type size = str.size();
|
||||||
for(i = 1; s < size && i < n; s++) if(str[s] == ' ') ++i;
|
for (i = 1; s < size && i < n; s++) if (str[s] == ' ') ++i;
|
||||||
if (i < n)
|
if (i < n)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ static bool findtoknth(std::string &str, int n, std::string::size_type &s, std::
|
||||||
return e != std::string::npos;
|
return e != std::string::npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string gettoknth(std::string &str, int n)
|
std::string gettoknth(std::string& str, int n)
|
||||||
{
|
{
|
||||||
std::string::size_type s = 0, e = 0;
|
std::string::size_type s = 0, e = 0;
|
||||||
if (!findtoknth(str, n, s, e))
|
if (!findtoknth(str, n, s, e))
|
||||||
|
|
@ -90,7 +90,7 @@ std::string gettoknth(std::string &str, int n)
|
||||||
return str.substr(s, e-s);
|
return str.substr(s, e-s);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool findnth(std::string &str, int n, std::string::size_type &s, std::string::size_type &e)
|
bool findnth(std::string& str, int n, std::string::size_type& s, std::string::size_type& e)
|
||||||
{
|
{
|
||||||
s = str.find("VALUES ('")+9;
|
s = str.find("VALUES ('")+9;
|
||||||
if (s == std::string::npos)
|
if (s == std::string::npos)
|
||||||
|
|
@ -101,9 +101,10 @@ bool findnth(std::string &str, int n, std::string::size_type &s, std::string::si
|
||||||
e = str.find("'",s);
|
e = str.find("'",s);
|
||||||
if (e == std::string::npos)
|
if (e == std::string::npos)
|
||||||
return false;
|
return false;
|
||||||
} while(str[e-1] == '\\');
|
}
|
||||||
|
while (str[e-1] == '\\');
|
||||||
|
|
||||||
for(int i = 1; i < n; ++i)
|
for (int i = 1; i < n; ++i)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
@ -111,12 +112,13 @@ bool findnth(std::string &str, int n, std::string::size_type &s, std::string::si
|
||||||
e = str.find("'",s);
|
e = str.find("'",s);
|
||||||
if (e == std::string::npos)
|
if (e == std::string::npos)
|
||||||
return false;
|
return false;
|
||||||
} while (str[e-1] == '\\');
|
}
|
||||||
|
while (str[e-1] == '\\');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string gettablename(std::string &str)
|
std::string gettablename(std::string& str)
|
||||||
{
|
{
|
||||||
std::string::size_type s = 13;
|
std::string::size_type s = 13;
|
||||||
std::string::size_type e = str.find(_TABLE_SIM_, s);
|
std::string::size_type e = str.find(_TABLE_SIM_, s);
|
||||||
|
|
@ -126,7 +128,7 @@ std::string gettablename(std::string &str)
|
||||||
return str.substr(s, e-s);
|
return str.substr(s, e-s);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changenth(std::string &str, int n, const char *with, bool insert = false, bool nonzero = false)
|
bool changenth(std::string& str, int n, const char* with, bool insert = false, bool nonzero = false)
|
||||||
{
|
{
|
||||||
std::string::size_type s, e;
|
std::string::size_type s, e;
|
||||||
if (!findnth(str,n,s,e))
|
if (!findnth(str,n,s,e))
|
||||||
|
|
@ -142,7 +144,7 @@ bool changenth(std::string &str, int n, const char *with, bool insert = false, b
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getnth(std::string &str, int n)
|
std::string getnth(std::string& str, int n)
|
||||||
{
|
{
|
||||||
std::string::size_type s, e;
|
std::string::size_type s, e;
|
||||||
if (!findnth(str,n,s,e))
|
if (!findnth(str,n,s,e))
|
||||||
|
|
@ -151,7 +153,7 @@ std::string getnth(std::string &str, int n)
|
||||||
return str.substr(s, e-s);
|
return str.substr(s, e-s);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changetoknth(std::string &str, int n, const char *with, bool insert = false, bool nonzero = false)
|
bool changetoknth(std::string& str, int n, const char* with, bool insert = false, bool nonzero = false)
|
||||||
{
|
{
|
||||||
std::string::size_type s = 0, e = 0;
|
std::string::size_type s = 0, e = 0;
|
||||||
if (!findtoknth(str, n, s, e))
|
if (!findtoknth(str, n, s, e))
|
||||||
|
|
@ -166,7 +168,7 @@ bool changetoknth(std::string &str, int n, const char *with, bool insert = false
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 registerNewGuid(uint32 oldGuid, std::map<uint32, uint32> &guidMap, uint32 hiGuid)
|
uint32 registerNewGuid(uint32 oldGuid, std::map<uint32, uint32>& guidMap, uint32 hiGuid)
|
||||||
{
|
{
|
||||||
std::map<uint32, uint32>::const_iterator itr = guidMap.find(oldGuid);
|
std::map<uint32, uint32>::const_iterator itr = guidMap.find(oldGuid);
|
||||||
if (itr != guidMap.end())
|
if (itr != guidMap.end())
|
||||||
|
|
@ -177,7 +179,7 @@ uint32 registerNewGuid(uint32 oldGuid, std::map<uint32, uint32> &guidMap, uint32
|
||||||
return newguid;
|
return newguid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changeGuid(std::string &str, int n, std::map<uint32, uint32> &guidMap, uint32 hiGuid, bool nonzero = false)
|
bool changeGuid(std::string& str, int n, std::map<uint32, uint32>& guidMap, uint32 hiGuid, bool nonzero = false)
|
||||||
{
|
{
|
||||||
char chritem[20];
|
char chritem[20];
|
||||||
uint32 oldGuid = atoi(getnth(str, n).c_str());
|
uint32 oldGuid = atoi(getnth(str, n).c_str());
|
||||||
|
|
@ -190,7 +192,7 @@ bool changeGuid(std::string &str, int n, std::map<uint32, uint32> &guidMap, uint
|
||||||
return changenth(str, n, chritem, false, nonzero);
|
return changenth(str, n, chritem, false, nonzero);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changetokGuid(std::string &str, int n, std::map<uint32, uint32> &guidMap, uint32 hiGuid, bool nonzero = false)
|
bool changetokGuid(std::string& str, int n, std::map<uint32, uint32>& guidMap, uint32 hiGuid, bool nonzero = false)
|
||||||
{
|
{
|
||||||
char chritem[20];
|
char chritem[20];
|
||||||
uint32 oldGuid = atoi(gettoknth(str, n).c_str());
|
uint32 oldGuid = atoi(gettoknth(str, n).c_str());
|
||||||
|
|
@ -203,15 +205,15 @@ bool changetokGuid(std::string &str, int n, std::map<uint32, uint32> &guidMap, u
|
||||||
return changetoknth(str, n, chritem, false, nonzero);
|
return changetoknth(str, n, chritem, false, nonzero);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CreateDumpString(char const* tableName, QueryResult *result)
|
std::string CreateDumpString(char const* tableName, QueryResult* result)
|
||||||
{
|
{
|
||||||
if (!tableName || !result)
|
if (!tableName || !result)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << "INSERT INTO "<< _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES (";
|
ss << "INSERT INTO "<< _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES (";
|
||||||
Field *fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
for(uint32 i = 0; i < result->GetFieldCount(); ++i)
|
for (uint32 i = 0; i < result->GetFieldCount(); ++i)
|
||||||
{
|
{
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
ss << ", ";
|
ss << ", ";
|
||||||
|
|
@ -241,7 +243,7 @@ std::string PlayerDumpWriter::GenerateWhereStr(char const* field, GUIDs const& g
|
||||||
{
|
{
|
||||||
std::ostringstream wherestr;
|
std::ostringstream wherestr;
|
||||||
wherestr << field << " IN ('";
|
wherestr << field << " IN ('";
|
||||||
for(; itr != guids.end(); ++itr)
|
for (; itr != guids.end(); ++itr)
|
||||||
{
|
{
|
||||||
wherestr << *itr;
|
wherestr << *itr;
|
||||||
|
|
||||||
|
|
@ -259,7 +261,7 @@ std::string PlayerDumpWriter::GenerateWhereStr(char const* field, GUIDs const& g
|
||||||
return wherestr.str();
|
return wherestr.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoreGUID(QueryResult *result,uint32 field,std::set<uint32>& guids)
|
void StoreGUID(QueryResult* result,uint32 field,std::set<uint32>& guids)
|
||||||
{
|
{
|
||||||
Field* fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
uint32 guid = fields[field].GetUInt32();
|
uint32 guid = fields[field].GetUInt32();
|
||||||
|
|
@ -267,7 +269,7 @@ void StoreGUID(QueryResult *result,uint32 field,std::set<uint32>& guids)
|
||||||
guids.insert(guid);
|
guids.insert(guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoreGUID(QueryResult *result,uint32 data,uint32 field, std::set<uint32>& guids)
|
void StoreGUID(QueryResult* result,uint32 data,uint32 field, std::set<uint32>& guids)
|
||||||
{
|
{
|
||||||
Field* fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
std::string dataStr = fields[data].GetCppString();
|
std::string dataStr = fields[data].GetCppString();
|
||||||
|
|
@ -277,12 +279,12 @@ void StoreGUID(QueryResult *result,uint32 data,uint32 field, std::set<uint32>& g
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writing - High-level functions
|
// Writing - High-level functions
|
||||||
void PlayerDumpWriter::DumpTableContent(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type)
|
void PlayerDumpWriter::DumpTableContent(std::string& dump, uint32 guid, char const* tableFrom, char const* tableTo, DumpTableType type)
|
||||||
{
|
{
|
||||||
GUIDs const* guids = NULL;
|
GUIDs const* guids = NULL;
|
||||||
char const* fieldname = NULL;
|
char const* fieldname = NULL;
|
||||||
|
|
||||||
switch ( type )
|
switch (type)
|
||||||
{
|
{
|
||||||
case DTT_ITEM: fieldname = "guid"; guids = &items; break;
|
case DTT_ITEM: fieldname = "guid"; guids = &items; break;
|
||||||
case DTT_ITEM_GIFT: fieldname = "item_guid"; guids = &items; break;
|
case DTT_ITEM_GIFT: fieldname = "item_guid"; guids = &items; break;
|
||||||
|
|
@ -313,14 +315,14 @@ void PlayerDumpWriter::DumpTableContent(std::string& dump, uint32 guid, char con
|
||||||
else // not set case, get single guid string
|
else // not set case, get single guid string
|
||||||
wherestr = GenerateWhereStr(fieldname,guid);
|
wherestr = GenerateWhereStr(fieldname,guid);
|
||||||
|
|
||||||
QueryResult *result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str());
|
QueryResult* result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str());
|
||||||
if (!result)
|
if (!result)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// collect guids
|
// collect guids
|
||||||
switch ( type )
|
switch (type)
|
||||||
{
|
{
|
||||||
case DTT_INVENTORY:
|
case DTT_INVENTORY:
|
||||||
StoreGUID(result,3,items); break; // item guid collection (character_inventory.item)
|
StoreGUID(result,3,items); break; // item guid collection (character_inventory.item)
|
||||||
|
|
@ -340,7 +342,7 @@ void PlayerDumpWriter::DumpTableContent(std::string& dump, uint32 guid, char con
|
||||||
|
|
||||||
delete result;
|
delete result;
|
||||||
}
|
}
|
||||||
while(guids && guids_itr != guids->end()); // not set case iterate single time, set case iterate for all guids
|
while (guids && guids_itr != guids->end()); // not set case iterate single time, set case iterate for all guids
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PlayerDumpWriter::GetDump(uint32 guid)
|
std::string PlayerDumpWriter::GetDump(uint32 guid)
|
||||||
|
|
@ -356,7 +358,7 @@ std::string PlayerDumpWriter::GetDump(uint32 guid)
|
||||||
{
|
{
|
||||||
QueryFieldNames const& namesMap = result->GetFieldNames();
|
QueryFieldNames const& namesMap = result->GetFieldNames();
|
||||||
std::string reqName;
|
std::string reqName;
|
||||||
for(QueryFieldNames::const_iterator itr = namesMap.begin(); itr != namesMap.end(); ++itr)
|
for (QueryFieldNames::const_iterator itr = namesMap.begin(); itr != namesMap.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (itr->substr(0,9)=="required_")
|
if (itr->substr(0,9)=="required_")
|
||||||
{
|
{
|
||||||
|
|
@ -378,7 +380,7 @@ std::string PlayerDumpWriter::GetDump(uint32 guid)
|
||||||
else
|
else
|
||||||
sLog.outError("Character DB not have 'character_db_version' table, revision guard query not added to pdump.");
|
sLog.outError("Character DB not have 'character_db_version' table, revision guard query not added to pdump.");
|
||||||
|
|
||||||
for(DumpTable* itr = &dumpTables[0]; itr->isValid(); ++itr)
|
for (DumpTable* itr = &dumpTables[0]; itr->isValid(); ++itr)
|
||||||
DumpTableContent(dump, guid, itr->name, itr->name, itr->type);
|
DumpTableContent(dump, guid, itr->name, itr->name, itr->type);
|
||||||
|
|
||||||
// TODO: Add instance/group..
|
// TODO: Add instance/group..
|
||||||
|
|
@ -389,7 +391,7 @@ std::string PlayerDumpWriter::GetDump(uint32 guid)
|
||||||
|
|
||||||
DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, uint32 guid)
|
DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, uint32 guid)
|
||||||
{
|
{
|
||||||
FILE *fout = fopen(file.c_str(), "w");
|
FILE* fout = fopen(file.c_str(), "w");
|
||||||
if (!fout)
|
if (!fout)
|
||||||
return DUMP_FILE_OPEN_ERROR;
|
return DUMP_FILE_OPEN_ERROR;
|
||||||
|
|
||||||
|
|
@ -412,11 +414,11 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||||
if (charcount >= 10)
|
if (charcount >= 10)
|
||||||
return DUMP_TOO_MANY_CHARS;
|
return DUMP_TOO_MANY_CHARS;
|
||||||
|
|
||||||
FILE *fin = fopen(file.c_str(), "r");
|
FILE* fin = fopen(file.c_str(), "r");
|
||||||
if (!fin)
|
if (!fin)
|
||||||
return DUMP_FILE_OPEN_ERROR;
|
return DUMP_FILE_OPEN_ERROR;
|
||||||
|
|
||||||
QueryResult * result = NULL;
|
QueryResult* result = NULL;
|
||||||
char newguid[20], chraccount[20], newpetid[20], currpetid[20], lastpetid[20];
|
char newguid[20], chraccount[20], newpetid[20], currpetid[20], lastpetid[20];
|
||||||
|
|
||||||
// make sure the same guid doesn't already exist and is safe to use
|
// make sure the same guid doesn't already exist and is safe to use
|
||||||
|
|
@ -468,11 +470,11 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||||
PetIds petids;
|
PetIds petids;
|
||||||
|
|
||||||
CharacterDatabase.BeginTransaction();
|
CharacterDatabase.BeginTransaction();
|
||||||
while(!feof(fin))
|
while (!feof(fin))
|
||||||
{
|
{
|
||||||
if (!fgets(buf, 32000, fin))
|
if (!fgets(buf, 32000, fin))
|
||||||
{
|
{
|
||||||
if(feof(fin)) break;
|
if (feof(fin)) break;
|
||||||
ROLLBACK(DUMP_FILE_BROKEN);
|
ROLLBACK(DUMP_FILE_BROKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -506,7 +508,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||||
|
|
||||||
DumpTableType type = DTT_CHARACTER; //Fixed: Using uninitialized memory 'type'
|
DumpTableType type = DTT_CHARACTER; //Fixed: Using uninitialized memory 'type'
|
||||||
DumpTable* dTable = &dumpTables[0];
|
DumpTable* dTable = &dumpTables[0];
|
||||||
for(; dTable->isValid(); ++dTable)
|
for (; dTable->isValid(); ++dTable)
|
||||||
{
|
{
|
||||||
if (tn == dTable->name)
|
if (tn == dTable->name)
|
||||||
{
|
{
|
||||||
|
|
@ -524,7 +526,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||||
bool execute_ok = true; // false, if need skip soem query
|
bool execute_ok = true; // false, if need skip soem query
|
||||||
|
|
||||||
// change the data to server values
|
// change the data to server values
|
||||||
switch(type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case DTT_CHAR_TABLE:
|
case DTT_CHAR_TABLE:
|
||||||
if (!changenth(line, 1, newguid)) // character_*.guid update
|
if (!changenth(line, 1, newguid)) // character_*.guid update
|
||||||
|
|
@ -707,8 +709,8 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||||
ROLLBACK(DUMP_FILE_BROKEN);
|
ROLLBACK(DUMP_FILE_BROKEN);
|
||||||
if (!changeGuid(line, 2, eqsets, sObjectMgr.m_EquipmentSetIds.GetNextAfterMaxUsed()))
|
if (!changeGuid(line, 2, eqsets, sObjectMgr.m_EquipmentSetIds.GetNextAfterMaxUsed()))
|
||||||
ROLLBACK(DUMP_FILE_BROKEN); // character_equipmentsets.setguid
|
ROLLBACK(DUMP_FILE_BROKEN); // character_equipmentsets.setguid
|
||||||
for(int i = 0; i < 19; ++i) // character_equipmentsets.item0..item18
|
for (int i = 0; i < 19; ++i) // character_equipmentsets.item0..item18
|
||||||
if(!changeGuid(line, 6+i, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed()))
|
if (!changeGuid(line, 6+i, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed()))
|
||||||
ROLLBACK(DUMP_FILE_BROKEN);
|
ROLLBACK(DUMP_FILE_BROKEN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,11 @@ enum DumpTableType
|
||||||
DTT_CHARACTER, // -> guid, name // characters
|
DTT_CHARACTER, // -> guid, name // characters
|
||||||
|
|
||||||
DTT_CHAR_TABLE, // // character_account_data, character_achievement,
|
DTT_CHAR_TABLE, // // character_account_data, character_achievement,
|
||||||
// character_achievement_progress, character_action,
|
// character_achievement_progress, character_action,
|
||||||
// character_aura, character_glyphs,
|
// character_aura, character_glyphs,
|
||||||
// character_homebind, character_queststatus,
|
// character_homebind, character_queststatus,
|
||||||
// character_reputation, character_skills, character_spell,
|
// character_reputation, character_skills, character_spell,
|
||||||
// character_spell_cooldown, character_talent, character_ticket
|
// character_spell_cooldown, character_talent, character_ticket
|
||||||
|
|
||||||
DTT_CHAR_NAME_TABLE,// <- guid, name // character_declinedname
|
DTT_CHAR_NAME_TABLE,// <- guid, name // character_declinedname
|
||||||
|
|
||||||
|
|
@ -41,10 +41,10 @@ enum DumpTableType
|
||||||
DTT_INVENTORY, // -> item guids collection // character_inventory
|
DTT_INVENTORY, // -> item guids collection // character_inventory
|
||||||
|
|
||||||
DTT_MAIL, // -> mail ids collection // mail
|
DTT_MAIL, // -> mail ids collection // mail
|
||||||
// -> item_text
|
// -> item_text
|
||||||
|
|
||||||
DTT_MAIL_ITEM, // <- mail ids // mail_items
|
DTT_MAIL_ITEM, // <- mail ids // mail_items
|
||||||
// -> item guids collection
|
// -> item guids collection
|
||||||
|
|
||||||
DTT_ITEM, // <- item guids // item_instance
|
DTT_ITEM, // <- item guids // item_instance
|
||||||
|
|
||||||
|
|
@ -82,7 +82,7 @@ class PlayerDumpWriter : public PlayerDump
|
||||||
private:
|
private:
|
||||||
typedef std::set<uint32> GUIDs;
|
typedef std::set<uint32> GUIDs;
|
||||||
|
|
||||||
void DumpTableContent(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type);
|
void DumpTableContent(std::string& dump, uint32 guid, char const* tableFrom, char const* tableTo, DumpTableType type);
|
||||||
std::string GenerateWhereStr(char const* field, GUIDs const& guids, GUIDs::const_iterator& itr);
|
std::string GenerateWhereStr(char const* field, GUIDs const& guids, GUIDs::const_iterator& itr);
|
||||||
std::string GenerateWhereStr(char const* field, uint32 guid);
|
std::string GenerateWhereStr(char const* field, uint32 guid);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
//----- Point Movement Generator
|
//----- Point Movement Generator
|
||||||
template<class T>
|
template<class T>
|
||||||
void PointMovementGenerator<T>::Initialize(T &unit)
|
void PointMovementGenerator<T>::Initialize(T& unit)
|
||||||
{
|
{
|
||||||
if (!unit.IsStopped())
|
if (!unit.IsStopped())
|
||||||
unit.StopMoving();
|
unit.StopMoving();
|
||||||
|
|
@ -39,7 +39,7 @@ void PointMovementGenerator<T>::Initialize(T &unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void PointMovementGenerator<T>::Finalize(T &unit)
|
void PointMovementGenerator<T>::Finalize(T& unit)
|
||||||
{
|
{
|
||||||
unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
||||||
|
|
||||||
|
|
@ -48,13 +48,13 @@ void PointMovementGenerator<T>::Finalize(T &unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void PointMovementGenerator<T>::Interrupt(T &unit)
|
void PointMovementGenerator<T>::Interrupt(T& unit)
|
||||||
{
|
{
|
||||||
unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void PointMovementGenerator<T>::Reset(T &unit)
|
void PointMovementGenerator<T>::Reset(T& unit)
|
||||||
{
|
{
|
||||||
if (!unit.IsStopped())
|
if (!unit.IsStopped())
|
||||||
unit.StopMoving();
|
unit.StopMoving();
|
||||||
|
|
@ -63,12 +63,12 @@ void PointMovementGenerator<T>::Reset(T &unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool PointMovementGenerator<T>::Update(T &unit, const uint32 &diff)
|
bool PointMovementGenerator<T>::Update(T& unit, const uint32& diff)
|
||||||
{
|
{
|
||||||
if(!&unit)
|
if (!&unit)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(unit.hasUnitState(UNIT_STAT_CAN_NOT_MOVE))
|
if (unit.hasUnitState(UNIT_STAT_CAN_NOT_MOVE))
|
||||||
{
|
{
|
||||||
unit.clearUnitState(UNIT_STAT_ROAMING_MOVE);
|
unit.clearUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -84,7 +84,7 @@ void PointMovementGenerator<Player>::MovementInform(Player&)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void PointMovementGenerator<Creature>::MovementInform(Creature &unit)
|
void PointMovementGenerator<Creature>::MovementInform(Creature& unit)
|
||||||
{
|
{
|
||||||
if (unit.AI())
|
if (unit.AI())
|
||||||
unit.AI()->MovementInform(POINT_MOTION_TYPE, id);
|
unit.AI()->MovementInform(POINT_MOTION_TYPE, id);
|
||||||
|
|
@ -93,7 +93,7 @@ void PointMovementGenerator<Creature>::MovementInform(Creature &unit)
|
||||||
{
|
{
|
||||||
TemporarySummon* pSummon = (TemporarySummon*)(&unit);
|
TemporarySummon* pSummon = (TemporarySummon*)(&unit);
|
||||||
if (pSummon->GetSummonerGuid().IsCreatureOrVehicle())
|
if (pSummon->GetSummonerGuid().IsCreatureOrVehicle())
|
||||||
if(Creature* pSummoner = unit.GetMap()->GetCreature(pSummon->GetSummonerGuid()))
|
if (Creature* pSummoner = unit.GetMap()->GetCreature(pSummon->GetSummonerGuid()))
|
||||||
if (pSummoner->AI())
|
if (pSummoner->AI())
|
||||||
pSummoner->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id);
|
pSummoner->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id);
|
||||||
}
|
}
|
||||||
|
|
@ -107,10 +107,10 @@ template void PointMovementGenerator<Player>::Interrupt(Player&);
|
||||||
template void PointMovementGenerator<Creature>::Interrupt(Creature&);
|
template void PointMovementGenerator<Creature>::Interrupt(Creature&);
|
||||||
template void PointMovementGenerator<Player>::Reset(Player&);
|
template void PointMovementGenerator<Player>::Reset(Player&);
|
||||||
template void PointMovementGenerator<Creature>::Reset(Creature&);
|
template void PointMovementGenerator<Creature>::Reset(Creature&);
|
||||||
template bool PointMovementGenerator<Player>::Update(Player &, const uint32 &diff);
|
template bool PointMovementGenerator<Player>::Update(Player&, const uint32& diff);
|
||||||
template bool PointMovementGenerator<Creature>::Update(Creature&, const uint32 &diff);
|
template bool PointMovementGenerator<Creature>::Update(Creature&, const uint32& diff);
|
||||||
|
|
||||||
void AssistanceMovementGenerator::Finalize(Unit &unit)
|
void AssistanceMovementGenerator::Finalize(Unit& unit)
|
||||||
{
|
{
|
||||||
unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
||||||
|
|
||||||
|
|
@ -120,12 +120,12 @@ void AssistanceMovementGenerator::Finalize(Unit &unit)
|
||||||
unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY));
|
unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EffectMovementGenerator::Update(Unit &unit, const uint32 &)
|
bool EffectMovementGenerator::Update(Unit& unit, const uint32&)
|
||||||
{
|
{
|
||||||
return !unit.movespline->Finalized();
|
return !unit.movespline->Finalized();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectMovementGenerator::Finalize(Unit &unit)
|
void EffectMovementGenerator::Finalize(Unit& unit)
|
||||||
{
|
{
|
||||||
if (unit.GetTypeId() != TYPEID_UNIT)
|
if (unit.GetTypeId() != TYPEID_UNIT)
|
||||||
return;
|
return;
|
||||||
|
|
@ -135,7 +135,7 @@ void EffectMovementGenerator::Finalize(Unit &unit)
|
||||||
// Need restore previous movement since we have no proper states system
|
// Need restore previous movement since we have no proper states system
|
||||||
if (unit.isAlive() && !unit.hasUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_FLEEING))
|
if (unit.isAlive() && !unit.hasUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_FLEEING))
|
||||||
{
|
{
|
||||||
if (Unit * victim = unit.getVictim())
|
if (Unit* victim = unit.getVictim())
|
||||||
unit.GetMotionMaster()->MoveChase(victim);
|
unit.GetMotionMaster()->MoveChase(victim);
|
||||||
else
|
else
|
||||||
unit.GetMotionMaster()->Initialize();
|
unit.GetMotionMaster()->Initialize();
|
||||||
|
|
|
||||||
|
|
@ -25,19 +25,19 @@
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class MANGOS_DLL_SPEC PointMovementGenerator
|
class MANGOS_DLL_SPEC PointMovementGenerator
|
||||||
: public MovementGeneratorMedium< T, PointMovementGenerator<T> >
|
: public MovementGeneratorMedium< T, PointMovementGenerator<T> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PointMovementGenerator(uint32 _id, float _x, float _y, float _z, bool _generatePath) :
|
PointMovementGenerator(uint32 _id, float _x, float _y, float _z, bool _generatePath) :
|
||||||
id(_id), i_x(_x), i_y(_y), i_z(_z), m_generatePath(_generatePath) {}
|
id(_id), i_x(_x), i_y(_y), i_z(_z), m_generatePath(_generatePath) {}
|
||||||
|
|
||||||
void Initialize(T &);
|
void Initialize(T&);
|
||||||
void Finalize(T &);
|
void Finalize(T&);
|
||||||
void Interrupt(T &);
|
void Interrupt(T&);
|
||||||
void Reset(T &unit);
|
void Reset(T& unit);
|
||||||
bool Update(T &, const uint32 &diff);
|
bool Update(T&, const uint32& diff);
|
||||||
|
|
||||||
void MovementInform(T &);
|
void MovementInform(T&);
|
||||||
|
|
||||||
MovementGeneratorType GetMovementGeneratorType() const { return POINT_MOTION_TYPE; }
|
MovementGeneratorType GetMovementGeneratorType() const { return POINT_MOTION_TYPE; }
|
||||||
|
|
||||||
|
|
@ -49,14 +49,14 @@ class MANGOS_DLL_SPEC PointMovementGenerator
|
||||||
};
|
};
|
||||||
|
|
||||||
class MANGOS_DLL_SPEC AssistanceMovementGenerator
|
class MANGOS_DLL_SPEC AssistanceMovementGenerator
|
||||||
: public PointMovementGenerator<Creature>
|
: public PointMovementGenerator<Creature>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AssistanceMovementGenerator(float _x, float _y, float _z) :
|
AssistanceMovementGenerator(float _x, float _y, float _z) :
|
||||||
PointMovementGenerator<Creature>(0, _x, _y, _z, true) {}
|
PointMovementGenerator<Creature>(0, _x, _y, _z, true) {}
|
||||||
|
|
||||||
MovementGeneratorType GetMovementGeneratorType() const { return ASSISTANCE_MOTION_TYPE; }
|
MovementGeneratorType GetMovementGeneratorType() const { return ASSISTANCE_MOTION_TYPE; }
|
||||||
void Finalize(Unit &);
|
void Finalize(Unit&);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Does almost nothing - just doesn't allows previous movegen interrupt current effect. Can be reused for charge effect
|
// Does almost nothing - just doesn't allows previous movegen interrupt current effect. Can be reused for charge effect
|
||||||
|
|
@ -64,11 +64,11 @@ class EffectMovementGenerator : public MovementGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit EffectMovementGenerator(uint32 Id) : m_Id(Id) {}
|
explicit EffectMovementGenerator(uint32 Id) : m_Id(Id) {}
|
||||||
void Initialize(Unit &) {}
|
void Initialize(Unit&) {}
|
||||||
void Finalize(Unit &unit);
|
void Finalize(Unit& unit);
|
||||||
void Interrupt(Unit &) {}
|
void Interrupt(Unit&) {}
|
||||||
void Reset(Unit &) {}
|
void Reset(Unit&) {}
|
||||||
bool Update(Unit &u, const uint32 &);
|
bool Update(Unit& u, const uint32&);
|
||||||
MovementGeneratorType GetMovementGeneratorType() const { return EFFECT_MOTION_TYPE; }
|
MovementGeneratorType GetMovementGeneratorType() const { return EFFECT_MOTION_TYPE; }
|
||||||
private:
|
private:
|
||||||
uint32 m_Id;
|
uint32 m_Id;
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,7 @@ void PoolGroup<Pool>::RemoveOneRelation(uint16 child_pool_id)
|
||||||
{
|
{
|
||||||
for (PoolObjectList::iterator itr = ExplicitlyChanced.begin(); itr != ExplicitlyChanced.end(); ++itr)
|
for (PoolObjectList::iterator itr = ExplicitlyChanced.begin(); itr != ExplicitlyChanced.end(); ++itr)
|
||||||
{
|
{
|
||||||
if(itr->guid == child_pool_id)
|
if (itr->guid == child_pool_id)
|
||||||
{
|
{
|
||||||
ExplicitlyChanced.erase(itr);
|
ExplicitlyChanced.erase(itr);
|
||||||
break;
|
break;
|
||||||
|
|
@ -314,7 +314,7 @@ void PoolGroup<Pool>::RemoveOneRelation(uint16 child_pool_id)
|
||||||
}
|
}
|
||||||
for (PoolObjectList::iterator itr = EqualChanced.begin(); itr != EqualChanced.end(); ++itr)
|
for (PoolObjectList::iterator itr = EqualChanced.begin(); itr != EqualChanced.end(); ++itr)
|
||||||
{
|
{
|
||||||
if(itr->guid == child_pool_id)
|
if (itr->guid == child_pool_id)
|
||||||
{
|
{
|
||||||
EqualChanced.erase(itr);
|
EqualChanced.erase(itr);
|
||||||
break;
|
break;
|
||||||
|
|
@ -398,9 +398,9 @@ void PoolGroup<Creature>::Spawn1Object(MapPersistentState& mapState, PoolObject*
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if new spawn replaces a just despawned creature, not instantly spawn but set respawn timer
|
// if new spawn replaces a just despawned creature, not instantly spawn but set respawn timer
|
||||||
if(!instantly)
|
if (!instantly)
|
||||||
{
|
{
|
||||||
pCreature->SetRespawnTime( pCreature->GetRespawnDelay() );
|
pCreature->SetRespawnTime(pCreature->GetRespawnDelay());
|
||||||
if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY) || pCreature->IsWorldBoss())
|
if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY) || pCreature->IsWorldBoss())
|
||||||
pCreature->SaveRespawnTime();
|
pCreature->SaveRespawnTime();
|
||||||
}
|
}
|
||||||
|
|
@ -408,7 +408,7 @@ void PoolGroup<Creature>::Spawn1Object(MapPersistentState& mapState, PoolObject*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// for not loaded grid just update respawn time (avoid work for instances until implemented support)
|
// for not loaded grid just update respawn time (avoid work for instances until implemented support)
|
||||||
else if(!instantly)
|
else if (!instantly)
|
||||||
{
|
{
|
||||||
dataMapState->SaveCreatureRespawnTime(obj->guid, time(NULL) + data->spawntimesecs);
|
dataMapState->SaveCreatureRespawnTime(obj->guid, time(NULL) + data->spawntimesecs);
|
||||||
}
|
}
|
||||||
|
|
@ -444,9 +444,9 @@ void PoolGroup<GameObject>::Spawn1Object(MapPersistentState& mapState, PoolObjec
|
||||||
if (pGameobject->isSpawnedByDefault())
|
if (pGameobject->isSpawnedByDefault())
|
||||||
{
|
{
|
||||||
// if new spawn replaces a just despawned object, not instantly spawn but set respawn timer
|
// if new spawn replaces a just despawned object, not instantly spawn but set respawn timer
|
||||||
if(!instantly)
|
if (!instantly)
|
||||||
{
|
{
|
||||||
pGameobject->SetRespawnTime( pGameobject->GetRespawnDelay() );
|
pGameobject->SetRespawnTime(pGameobject->GetRespawnDelay());
|
||||||
if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY))
|
if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY))
|
||||||
pGameobject->SaveRespawnTime();
|
pGameobject->SaveRespawnTime();
|
||||||
}
|
}
|
||||||
|
|
@ -455,7 +455,7 @@ void PoolGroup<GameObject>::Spawn1Object(MapPersistentState& mapState, PoolObjec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// for not loaded grid just update respawn time (avoid work for instances until implemented support)
|
// for not loaded grid just update respawn time (avoid work for instances until implemented support)
|
||||||
else if(!instantly)
|
else if (!instantly)
|
||||||
{
|
{
|
||||||
// for spawned by default object only
|
// for spawned by default object only
|
||||||
if (data->spawntimesecs >= 0)
|
if (data->spawntimesecs >= 0)
|
||||||
|
|
@ -545,7 +545,7 @@ struct PoolMapChecker
|
||||||
if (mapEntry->Instanceable())
|
if (mapEntry->Instanceable())
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("`%s` has %s spawned at instanceable map %u when one or several other spawned at different map %u in pool id %i, skipped.",
|
sLog.outErrorDb("`%s` has %s spawned at instanceable map %u when one or several other spawned at different map %u in pool id %i, skipped.",
|
||||||
tableName, elementName, mapid, poolMapEntry->MapID, pool_id);
|
tableName, elementName, mapid, poolMapEntry->MapID, pool_id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -553,7 +553,7 @@ struct PoolMapChecker
|
||||||
if (poolMapEntry->Instanceable())
|
if (poolMapEntry->Instanceable())
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("`%s` has %s spawned at map %u when one or several other spawned at different instanceable map %u in pool id %i, skipped.",
|
sLog.outErrorDb("`%s` has %s spawned at map %u when one or several other spawned at different instanceable map %u in pool id %i, skipped.",
|
||||||
tableName, elementName, mapid, poolMapEntry->MapID, pool_id);
|
tableName, elementName, mapid, poolMapEntry->MapID, pool_id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -564,7 +564,7 @@ struct PoolMapChecker
|
||||||
|
|
||||||
void PoolManager::LoadFromDB()
|
void PoolManager::LoadFromDB()
|
||||||
{
|
{
|
||||||
QueryResult *result = WorldDatabase.Query("SELECT MAX(entry) FROM pool_template");
|
QueryResult* result = WorldDatabase.Query("SELECT MAX(entry) FROM pool_template");
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
sLog.outString(">> Table pool_template is empty.");
|
sLog.outString(">> Table pool_template is empty.");
|
||||||
|
|
@ -573,7 +573,7 @@ void PoolManager::LoadFromDB()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Field *fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
max_pool_id = fields[0].GetUInt16();
|
max_pool_id = fields[0].GetUInt16();
|
||||||
delete result;
|
delete result;
|
||||||
}
|
}
|
||||||
|
|
@ -595,7 +595,7 @@ void PoolManager::LoadFromDB()
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
Field *fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
|
|
||||||
bar.step();
|
bar.step();
|
||||||
|
|
||||||
|
|
@ -606,10 +606,11 @@ void PoolManager::LoadFromDB()
|
||||||
pPoolTemplate.description = fields[2].GetCppString();
|
pPoolTemplate.description = fields[2].GetCppString();
|
||||||
pPoolTemplate.AutoSpawn = true; // will update and later data loading
|
pPoolTemplate.AutoSpawn = true; // will update and later data loading
|
||||||
|
|
||||||
} while (result->NextRow());
|
}
|
||||||
|
while (result->NextRow());
|
||||||
|
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString( ">> Loaded %u objects pools", count );
|
sLog.outString(">> Loaded %u objects pools", count);
|
||||||
delete result;
|
delete result;
|
||||||
|
|
||||||
PoolMapChecker mapChecker(mPoolTemplate);
|
PoolMapChecker mapChecker(mPoolTemplate);
|
||||||
|
|
@ -628,7 +629,7 @@ void PoolManager::LoadFromDB()
|
||||||
bar2.step();
|
bar2.step();
|
||||||
|
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString(">> Loaded %u creatures in pools from `pool_creature`", count );
|
sLog.outString(">> Loaded %u creatures in pools from `pool_creature`", count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -636,7 +637,7 @@ void PoolManager::LoadFromDB()
|
||||||
BarGoLink bar2(result->GetRowCount());
|
BarGoLink bar2(result->GetRowCount());
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Field *fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
|
|
||||||
bar2.step();
|
bar2.step();
|
||||||
|
|
||||||
|
|
@ -647,7 +648,7 @@ void PoolManager::LoadFromDB()
|
||||||
CreatureData const* data = sObjectMgr.GetCreatureData(guid);
|
CreatureData const* data = sObjectMgr.GetCreatureData(guid);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("`pool_creature` has a non existing creature spawn (GUID: %u) defined for pool id (%u), skipped.", guid, pool_id );
|
sLog.outErrorDb("`pool_creature` has a non existing creature spawn (GUID: %u) defined for pool id (%u), skipped.", guid, pool_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (pool_id > max_pool_id)
|
if (pool_id > max_pool_id)
|
||||||
|
|
@ -664,7 +665,7 @@ void PoolManager::LoadFromDB()
|
||||||
if (!mapChecker.CheckAndRemember(data->mapid, pool_id, "pool_creature", "creature guid"))
|
if (!mapChecker.CheckAndRemember(data->mapid, pool_id, "pool_creature", "creature guid"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
PoolTemplateData *pPoolTemplate = &mPoolTemplate[pool_id];
|
PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id];
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
|
|
@ -675,9 +676,10 @@ void PoolManager::LoadFromDB()
|
||||||
SearchPair p(guid, pool_id);
|
SearchPair p(guid, pool_id);
|
||||||
mCreatureSearchMap.insert(p);
|
mCreatureSearchMap.insert(p);
|
||||||
|
|
||||||
} while (result->NextRow());
|
}
|
||||||
|
while (result->NextRow());
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString( ">> Loaded %u creatures in pools from `pool_creature`", count );
|
sLog.outString(">> Loaded %u creatures in pools from `pool_creature`", count);
|
||||||
delete result;
|
delete result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -690,14 +692,14 @@ void PoolManager::LoadFromDB()
|
||||||
bar2.step();
|
bar2.step();
|
||||||
|
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString(">> Loaded %u creatures in pools from `pool_creature_template`", count );
|
sLog.outString(">> Loaded %u creatures in pools from `pool_creature_template`", count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BarGoLink bar2(result->GetRowCount());
|
BarGoLink bar2(result->GetRowCount());
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Field *fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
|
|
||||||
bar2.step();
|
bar2.step();
|
||||||
|
|
||||||
|
|
@ -709,7 +711,7 @@ void PoolManager::LoadFromDB()
|
||||||
CreatureData const* data = sObjectMgr.GetCreatureData(guid);
|
CreatureData const* data = sObjectMgr.GetCreatureData(guid);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("`pool_creature_template` has a non existing creature spawn (GUID: %u Entry: %u) defined for pool id (%u), skipped.", guid, entry_id, pool_id );
|
sLog.outErrorDb("`pool_creature_template` has a non existing creature spawn (GUID: %u Entry: %u) defined for pool id (%u), skipped.", guid, entry_id, pool_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (pool_id > max_pool_id)
|
if (pool_id > max_pool_id)
|
||||||
|
|
@ -729,14 +731,14 @@ void PoolManager::LoadFromDB()
|
||||||
if (uint16 alt_pool_id = IsPartOfAPool<Creature>(guid))
|
if (uint16 alt_pool_id = IsPartOfAPool<Creature>(guid))
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("`pool_creature` has guid %u for pool %u that already added to pool %u from `pool_creature_template` for creature entry %u, skipped.",
|
sLog.outErrorDb("`pool_creature` has guid %u for pool %u that already added to pool %u from `pool_creature_template` for creature entry %u, skipped.",
|
||||||
guid, pool_id, alt_pool_id, entry_id);
|
guid, pool_id, alt_pool_id, entry_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mapChecker.CheckAndRemember(data->mapid, pool_id, "pool_creature_template", "creature guid"))
|
if (!mapChecker.CheckAndRemember(data->mapid, pool_id, "pool_creature_template", "creature guid"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
PoolTemplateData *pPoolTemplate = &mPoolTemplate[pool_id];
|
PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id];
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
|
|
@ -747,9 +749,10 @@ void PoolManager::LoadFromDB()
|
||||||
SearchPair p(guid, pool_id);
|
SearchPair p(guid, pool_id);
|
||||||
mCreatureSearchMap.insert(p);
|
mCreatureSearchMap.insert(p);
|
||||||
|
|
||||||
} while (result->NextRow());
|
}
|
||||||
|
while (result->NextRow());
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString(">> Loaded %u creatures in pools from `pool_creature_template`", count );
|
sLog.outString(">> Loaded %u creatures in pools from `pool_creature_template`", count);
|
||||||
delete result;
|
delete result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -767,7 +770,7 @@ void PoolManager::LoadFromDB()
|
||||||
bar2.step();
|
bar2.step();
|
||||||
|
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString(">> Loaded %u gameobject in pools from `pool_gameobject`", count );
|
sLog.outString(">> Loaded %u gameobject in pools from `pool_gameobject`", count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -775,7 +778,7 @@ void PoolManager::LoadFromDB()
|
||||||
BarGoLink bar2(result->GetRowCount());
|
BarGoLink bar2(result->GetRowCount());
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Field *fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
|
|
||||||
bar2.step();
|
bar2.step();
|
||||||
|
|
||||||
|
|
@ -786,15 +789,15 @@ void PoolManager::LoadFromDB()
|
||||||
GameObjectData const* data = sObjectMgr.GetGOData(guid);
|
GameObjectData const* data = sObjectMgr.GetGOData(guid);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("`pool_gameobject` has a non existing gameobject spawn (GUID: %u) defined for pool id (%u), skipped.", guid, pool_id );
|
sLog.outErrorDb("`pool_gameobject` has a non existing gameobject spawn (GUID: %u) defined for pool id (%u), skipped.", guid, pool_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GameObjectInfo const* goinfo = ObjectMgr::GetGameObjectInfo(data->id);
|
GameObjectInfo const* goinfo = ObjectMgr::GetGameObjectInfo(data->id);
|
||||||
if (goinfo->type != GAMEOBJECT_TYPE_CHEST &&
|
if (goinfo->type != GAMEOBJECT_TYPE_CHEST &&
|
||||||
goinfo->type != GAMEOBJECT_TYPE_GOOBER &&
|
goinfo->type != GAMEOBJECT_TYPE_GOOBER &&
|
||||||
goinfo->type != GAMEOBJECT_TYPE_FISHINGHOLE)
|
goinfo->type != GAMEOBJECT_TYPE_FISHINGHOLE)
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("`pool_gameobject` has a not lootable gameobject spawn (GUID: %u, type: %u) defined for pool id (%u), skipped.", guid, goinfo->type, pool_id );
|
sLog.outErrorDb("`pool_gameobject` has a not lootable gameobject spawn (GUID: %u, type: %u) defined for pool id (%u), skipped.", guid, goinfo->type, pool_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (pool_id > max_pool_id)
|
if (pool_id > max_pool_id)
|
||||||
|
|
@ -811,7 +814,7 @@ void PoolManager::LoadFromDB()
|
||||||
if (!mapChecker.CheckAndRemember(data->mapid, pool_id, "pool_gameobject", "gameobject guid"))
|
if (!mapChecker.CheckAndRemember(data->mapid, pool_id, "pool_gameobject", "gameobject guid"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
PoolTemplateData *pPoolTemplate = &mPoolTemplate[pool_id];
|
PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id];
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
|
|
@ -822,9 +825,10 @@ void PoolManager::LoadFromDB()
|
||||||
SearchPair p(guid, pool_id);
|
SearchPair p(guid, pool_id);
|
||||||
mGameobjectSearchMap.insert(p);
|
mGameobjectSearchMap.insert(p);
|
||||||
|
|
||||||
} while( result->NextRow() );
|
}
|
||||||
|
while (result->NextRow());
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString(">> Loaded %u gameobject in pools from `pool_gameobject`", count );
|
sLog.outString(">> Loaded %u gameobject in pools from `pool_gameobject`", count);
|
||||||
delete result;
|
delete result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -838,7 +842,7 @@ void PoolManager::LoadFromDB()
|
||||||
bar2.step();
|
bar2.step();
|
||||||
|
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString(">> Loaded %u gameobject in pools from `pool_gameobject_template`", count );
|
sLog.outString(">> Loaded %u gameobject in pools from `pool_gameobject_template`", count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -846,7 +850,7 @@ void PoolManager::LoadFromDB()
|
||||||
BarGoLink bar2(result->GetRowCount());
|
BarGoLink bar2(result->GetRowCount());
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Field *fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
|
|
||||||
bar2.step();
|
bar2.step();
|
||||||
|
|
||||||
|
|
@ -863,8 +867,8 @@ void PoolManager::LoadFromDB()
|
||||||
}
|
}
|
||||||
GameObjectInfo const* goinfo = ObjectMgr::GetGameObjectInfo(data->id);
|
GameObjectInfo const* goinfo = ObjectMgr::GetGameObjectInfo(data->id);
|
||||||
if (goinfo->type != GAMEOBJECT_TYPE_CHEST &&
|
if (goinfo->type != GAMEOBJECT_TYPE_CHEST &&
|
||||||
goinfo->type != GAMEOBJECT_TYPE_GOOBER &&
|
goinfo->type != GAMEOBJECT_TYPE_GOOBER &&
|
||||||
goinfo->type != GAMEOBJECT_TYPE_FISHINGHOLE)
|
goinfo->type != GAMEOBJECT_TYPE_FISHINGHOLE)
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("`pool_gameobject_template` has a not lootable gameobject spawn (GUID: %u Entry %u Type: %u) defined for pool id (%u), skipped.", guid, entry_id, goinfo->type, pool_id);
|
sLog.outErrorDb("`pool_gameobject_template` has a not lootable gameobject spawn (GUID: %u Entry %u Type: %u) defined for pool id (%u), skipped.", guid, entry_id, goinfo->type, pool_id);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -886,14 +890,14 @@ void PoolManager::LoadFromDB()
|
||||||
if (uint16 alt_pool_id = IsPartOfAPool<GameObject>(guid))
|
if (uint16 alt_pool_id = IsPartOfAPool<GameObject>(guid))
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("`pool_gameobject` has guid %u for pool %u that already added to pool %u from `pool_gameobject_template` for gameobject entry %u, skipped.",
|
sLog.outErrorDb("`pool_gameobject` has guid %u for pool %u that already added to pool %u from `pool_gameobject_template` for gameobject entry %u, skipped.",
|
||||||
guid, pool_id, alt_pool_id, entry_id);
|
guid, pool_id, alt_pool_id, entry_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mapChecker.CheckAndRemember(data->mapid, pool_id, "pool_gameobject_template", "gameobject guid"))
|
if (!mapChecker.CheckAndRemember(data->mapid, pool_id, "pool_gameobject_template", "gameobject guid"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
PoolTemplateData *pPoolTemplate = &mPoolTemplate[pool_id];
|
PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id];
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
|
|
@ -904,9 +908,10 @@ void PoolManager::LoadFromDB()
|
||||||
SearchPair p(guid, pool_id);
|
SearchPair p(guid, pool_id);
|
||||||
mGameobjectSearchMap.insert(p);
|
mGameobjectSearchMap.insert(p);
|
||||||
|
|
||||||
} while( result->NextRow() );
|
}
|
||||||
|
while (result->NextRow());
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString(">> Loaded %u gameobject in pools from `pool_gameobject_template`", count );
|
sLog.outString(">> Loaded %u gameobject in pools from `pool_gameobject_template`", count);
|
||||||
delete result;
|
delete result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -916,13 +921,13 @@ void PoolManager::LoadFromDB()
|
||||||
result = WorldDatabase.Query("SELECT pool_id, mother_pool, chance FROM pool_pool");
|
result = WorldDatabase.Query("SELECT pool_id, mother_pool, chance FROM pool_pool");
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
if( !result )
|
if (!result)
|
||||||
{
|
{
|
||||||
BarGoLink bar2(1);
|
BarGoLink bar2(1);
|
||||||
bar2.step();
|
bar2.step();
|
||||||
|
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString(">> Loaded %u pools in pools", count );
|
sLog.outString(">> Loaded %u pools in pools", count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -930,7 +935,7 @@ void PoolManager::LoadFromDB()
|
||||||
BarGoLink bar2(result->GetRowCount());
|
BarGoLink bar2(result->GetRowCount());
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Field *fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
|
|
||||||
bar2.step();
|
bar2.step();
|
||||||
|
|
||||||
|
|
@ -959,7 +964,7 @@ void PoolManager::LoadFromDB()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolTemplateData *pPoolTemplateMother = &mPoolTemplate[mother_pool_id];
|
PoolTemplateData* pPoolTemplateMother = &mPoolTemplate[mother_pool_id];
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
|
|
@ -973,13 +978,14 @@ void PoolManager::LoadFromDB()
|
||||||
// update top independent pool flag
|
// update top independent pool flag
|
||||||
mPoolTemplate[child_pool_id].AutoSpawn = false;
|
mPoolTemplate[child_pool_id].AutoSpawn = false;
|
||||||
|
|
||||||
} while( result->NextRow() );
|
}
|
||||||
|
while (result->NextRow());
|
||||||
|
|
||||||
// Now check for circular reference
|
// Now check for circular reference
|
||||||
for(uint16 i=0; i<max_pool_id; ++i)
|
for (uint16 i=0; i<max_pool_id; ++i)
|
||||||
{
|
{
|
||||||
std::set<uint16> checkedPools;
|
std::set<uint16> checkedPools;
|
||||||
for(SearchMap::iterator poolItr = mPoolSearchMap.find(i); poolItr != mPoolSearchMap.end(); poolItr = mPoolSearchMap.find(poolItr->second))
|
for (SearchMap::iterator poolItr = mPoolSearchMap.find(i); poolItr != mPoolSearchMap.end(); poolItr = mPoolSearchMap.find(poolItr->second))
|
||||||
{
|
{
|
||||||
// if child pool not have map data then it empty or have not checked child then will checked and all line later
|
// if child pool not have map data then it empty or have not checked child then will checked and all line later
|
||||||
if (MapEntry const* childMapEntry = mPoolTemplate[poolItr->first].mapEntry)
|
if (MapEntry const* childMapEntry = mPoolTemplate[poolItr->first].mapEntry)
|
||||||
|
|
@ -994,14 +1000,14 @@ void PoolManager::LoadFromDB()
|
||||||
}
|
}
|
||||||
|
|
||||||
checkedPools.insert(poolItr->first);
|
checkedPools.insert(poolItr->first);
|
||||||
if(checkedPools.find(poolItr->second) != checkedPools.end())
|
if (checkedPools.find(poolItr->second) != checkedPools.end())
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss<< "The pool(s) ";
|
ss<< "The pool(s) ";
|
||||||
for (std::set<uint16>::const_iterator itr=checkedPools.begin(); itr!=checkedPools.end(); ++itr)
|
for (std::set<uint16>::const_iterator itr=checkedPools.begin(); itr!=checkedPools.end(); ++itr)
|
||||||
ss << *itr << " ";
|
ss << *itr << " ";
|
||||||
ss << "create(s) a circular reference, which can cause the server to freeze.\nRemoving the last link between mother pool "
|
ss << "create(s) a circular reference, which can cause the server to freeze.\nRemoving the last link between mother pool "
|
||||||
<< poolItr->first << " and child pool " << poolItr->second;
|
<< poolItr->first << " and child pool " << poolItr->second;
|
||||||
sLog.outErrorDb("%s", ss.str().c_str());
|
sLog.outErrorDb("%s", ss.str().c_str());
|
||||||
mPoolPoolGroups[poolItr->second].RemoveOneRelation(poolItr->first);
|
mPoolPoolGroups[poolItr->second].RemoveOneRelation(poolItr->first);
|
||||||
mPoolSearchMap.erase(poolItr);
|
mPoolSearchMap.erase(poolItr);
|
||||||
|
|
@ -1012,12 +1018,12 @@ void PoolManager::LoadFromDB()
|
||||||
}
|
}
|
||||||
|
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString( ">> Loaded %u pools in mother pools", count );
|
sLog.outString(">> Loaded %u pools in mother pools", count);
|
||||||
delete result;
|
delete result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check chances integrity
|
// check chances integrity
|
||||||
for(uint16 pool_entry = 0; pool_entry < mPoolTemplate.size(); ++pool_entry)
|
for (uint16 pool_entry = 0; pool_entry < mPoolTemplate.size(); ++pool_entry)
|
||||||
{
|
{
|
||||||
if (mPoolTemplate[pool_entry].AutoSpawn)
|
if (mPoolTemplate[pool_entry].AutoSpawn)
|
||||||
{
|
{
|
||||||
|
|
@ -1034,7 +1040,7 @@ void PoolManager::LoadFromDB()
|
||||||
void PoolManager::Initialize(MapPersistentState* state)
|
void PoolManager::Initialize(MapPersistentState* state)
|
||||||
{
|
{
|
||||||
// spawn pools for expected map or for not initialized shared pools state for non-instanceable maps
|
// spawn pools for expected map or for not initialized shared pools state for non-instanceable maps
|
||||||
for(uint16 pool_entry = 0; pool_entry < mPoolTemplate.size(); ++pool_entry)
|
for (uint16 pool_entry = 0; pool_entry < mPoolTemplate.size(); ++pool_entry)
|
||||||
if (mPoolTemplate[pool_entry].AutoSpawn)
|
if (mPoolTemplate[pool_entry].AutoSpawn)
|
||||||
InitSpawnPool(*state, pool_entry);
|
InitSpawnPool(*state, pool_entry);
|
||||||
}
|
}
|
||||||
|
|
@ -1092,9 +1098,9 @@ void PoolManager::DespawnPool(MapPersistentState& mapState, uint16 pool_id)
|
||||||
bool PoolManager::CheckPool(uint16 pool_id) const
|
bool PoolManager::CheckPool(uint16 pool_id) const
|
||||||
{
|
{
|
||||||
return pool_id <= max_pool_id &&
|
return pool_id <= max_pool_id &&
|
||||||
mPoolGameobjectGroups[pool_id].CheckPool() &&
|
mPoolGameobjectGroups[pool_id].CheckPool() &&
|
||||||
mPoolCreatureGroups[pool_id].CheckPool() &&
|
mPoolCreatureGroups[pool_id].CheckPool() &&
|
||||||
mPoolPoolGroups[pool_id].CheckPool();
|
mPoolPoolGroups[pool_id].CheckPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method that check linking all elements to event
|
// Method that check linking all elements to event
|
||||||
|
|
@ -1139,7 +1145,7 @@ struct SpawnPoolInMapsWorker
|
||||||
explicit SpawnPoolInMapsWorker(PoolManager& mgr, uint32 pool_id, bool instantly)
|
explicit SpawnPoolInMapsWorker(PoolManager& mgr, uint32 pool_id, bool instantly)
|
||||||
: i_mgr(mgr), i_pool_id(pool_id), i_instantly(instantly) {}
|
: i_mgr(mgr), i_pool_id(pool_id), i_instantly(instantly) {}
|
||||||
|
|
||||||
void operator() (MapPersistentState* state)
|
void operator()(MapPersistentState* state)
|
||||||
{
|
{
|
||||||
i_mgr.SpawnPool(*state, i_pool_id, i_instantly);
|
i_mgr.SpawnPool(*state, i_pool_id, i_instantly);
|
||||||
}
|
}
|
||||||
|
|
@ -1167,7 +1173,7 @@ struct DespawnPoolInMapsWorker
|
||||||
explicit DespawnPoolInMapsWorker(PoolManager& mgr, uint32 pool_id)
|
explicit DespawnPoolInMapsWorker(PoolManager& mgr, uint32 pool_id)
|
||||||
: i_mgr(mgr), i_pool_id(pool_id) {}
|
: i_mgr(mgr), i_pool_id(pool_id) {}
|
||||||
|
|
||||||
void operator() (MapPersistentState* state)
|
void operator()(MapPersistentState* state)
|
||||||
{
|
{
|
||||||
i_mgr.DespawnPool(*state, i_pool_id);
|
i_mgr.DespawnPool(*state, i_pool_id);
|
||||||
}
|
}
|
||||||
|
|
@ -1202,7 +1208,7 @@ struct UpdatePoolInMapsWorker
|
||||||
explicit UpdatePoolInMapsWorker(PoolManager& mgr, uint32 pool_id, uint32 db_guid_or_pool_id)
|
explicit UpdatePoolInMapsWorker(PoolManager& mgr, uint32 pool_id, uint32 db_guid_or_pool_id)
|
||||||
: i_mgr(mgr), i_pool_id(pool_id), i_db_guid_or_pool_id(db_guid_or_pool_id) {}
|
: i_mgr(mgr), i_pool_id(pool_id), i_db_guid_or_pool_id(db_guid_or_pool_id) {}
|
||||||
|
|
||||||
void operator() (MapPersistentState* state)
|
void operator()(MapPersistentState* state)
|
||||||
{
|
{
|
||||||
i_mgr.UpdatePool<T>(*state, i_pool_id, i_db_guid_or_pool_id);
|
i_mgr.UpdatePool<T>(*state, i_pool_id, i_db_guid_or_pool_id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ struct PoolTemplateData
|
||||||
PoolTemplateData() : mapEntry(NULL), MaxLimit(0), AutoSpawn(false) {}
|
PoolTemplateData() : mapEntry(NULL), MaxLimit(0), AutoSpawn(false) {}
|
||||||
|
|
||||||
MapEntry const* mapEntry; // Map id used for pool creature/gameobject spams. In case non-instanceable map
|
MapEntry const* mapEntry; // Map id used for pool creature/gameobject spams. In case non-instanceable map
|
||||||
// it can be not unique but base at sharing same pool system dynamic data in this case this is not important.
|
// it can be not unique but base at sharing same pool system dynamic data in this case this is not important.
|
||||||
// NULL is no spawns by some reason
|
// NULL is no spawns by some reason
|
||||||
uint32 MaxLimit;
|
uint32 MaxLimit;
|
||||||
bool AutoSpawn; // spawn at pool system start (not part of another pool and not part of event spawn)
|
bool AutoSpawn; // spawn at pool system start (not part of another pool and not part of event spawn)
|
||||||
std::string description;
|
std::string description;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue