From 98e1efd4356a596cb105821cc84cf997b18ccd30 Mon Sep 17 00:00:00 2001 From: Schmoozerd Date: Thu, 19 Jul 2012 21:51:30 +0200 Subject: [PATCH] Various Cleanups (game P) --- src/game/Path.h | 10 +- src/game/PathFinder.cpp | 100 +- src/game/PathFinder.h | 18 +- src/game/Pet.cpp | 506 +-- src/game/Pet.h | 6 +- src/game/PetAI.cpp | 56 +- src/game/PetAI.h | 12 +- src/game/PetHandler.cpp | 18 +- src/game/PetitionsHandler.cpp | 222 +- src/game/Player.cpp | 5459 ++++++++++++++------------- src/game/Player.h | 564 +-- src/game/PlayerDump.cpp | 74 +- src/game/PlayerDump.h | 16 +- src/game/PointMovementGenerator.cpp | 30 +- src/game/PointMovementGenerator.h | 30 +- src/game/PoolManager.cpp | 132 +- src/game/PoolManager.h | 4 +- 17 files changed, 3642 insertions(+), 3615 deletions(-) diff --git a/src/game/Path.h b/src/game/Path.h index 30a0c083d..0ae170c56 100644 --- a/src/game/Path.h +++ b/src/game/Path.h @@ -38,13 +38,13 @@ class Path void resize(unsigned int sz) { i_nodes.resize(sz); } void crop(unsigned int start, unsigned int end) { - while(start && !i_nodes.empty()) + while (start && !i_nodes.empty()) { i_nodes.pop_front(); --start; } - while(end && !i_nodes.empty()) + while (end && !i_nodes.empty()) { i_nodes.pop_back(); --end; @@ -56,14 +56,14 @@ class Path float GetTotalLength(uint32 start, uint32 end) const { 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& prev = i_nodes[idx-1]; float xd = node.x - prev.x; float yd = node.y - prev.y; float zd = node.z - prev.z; - len += sqrtf( xd*xd + yd*yd + zd*zd ); + len += sqrtf(xd*xd + yd*yd + zd*zd); } return len; } @@ -80,7 +80,7 @@ class Path float xd = x - node.x; float yd = y - node.y; float zd = z - node.z; - len += sqrtf( xd*xd + yd*yd + zd*zd ); + len += sqrtf(xd*xd + yd*yd + zd*zd); } return len; diff --git a/src/game/PathFinder.cpp b/src/game/PathFinder.cpp index 1c0b54414..d3d72d456 100644 --- a/src/game/PathFinder.cpp +++ b/src/game/PathFinder.cpp @@ -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 // 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) || - !HaveTile(start) || !HaveTile(dest)) + !HaveTile(start) || !HaveTile(dest)) { BuildShortcut(); 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) return INVALID_POLYREF; @@ -118,7 +118,7 @@ dtPolyRef PathFinder::getPathPolyByPosition(const dtPolyRef *polyPath, uint32 po 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; } @@ -128,13 +128,13 @@ dtPolyRef PathFinder::getPathPolyByPosition(const dtPolyRef *polyPath, uint32 po 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 // if the current path doesn't contain the current poly, // we need to use the expensive navMesh.findNearestPoly dtPolyRef polyRef = getPathPolyByPosition(m_pathPolyRefs, m_polyLength, point, distance); - if(polyRef != INVALID_POLYREF) + if (polyRef != INVALID_POLYREF) return polyRef; // 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 closestPoint[VERTEX_SIZE] = {0.0f, 0.0f, 0.0f}; 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); return polyRef; @@ -153,7 +153,7 @@ dtPolyRef PathFinder::getPolyByLocation(const float* point, float *distance) con // try with bigger search box extents[1] = 200.0f; 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); return polyRef; @@ -162,7 +162,7 @@ dtPolyRef PathFinder::getPolyByLocation(const float* point, float *distance) con 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 *** @@ -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"); BuildShortcut(); 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; } @@ -363,14 +363,14 @@ void PathFinder::BuildPolyPath(const Vector3 &startPos, const Vector3 &endPos) clear(); dtStatus dtResult = m_navMeshQuery->findPath( - startPoly, // start polygon - endPoly, // end polygon - startPoint, // start position - endPoint, // end position - &m_filter, // polygon search filter - m_pathPolyRefs, // [out] path - (int*)&m_polyLength, - MAX_PATH_LENGTH); // max number of polygons in output path + startPoly, // start polygon + endPoly, // end polygon + startPoint, // start position + endPoint, // end position + &m_filter, // polygon search filter + m_pathPolyRefs, // [out] path + (int*)&m_polyLength, + MAX_PATH_LENGTH); // max number of polygons in output path if (!m_polyLength || dtResult != DT_SUCCESS) { @@ -392,7 +392,7 @@ void PathFinder::BuildPolyPath(const Vector3 &startPos, const Vector3 &endPos) 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]; uint32 pointCount = 0; @@ -400,26 +400,26 @@ void PathFinder::BuildPointPath(const float *startPoint, const float *endPoint) if (m_useStraightPath) { dtResult = m_navMeshQuery->findStraightPath( - startPoint, // start position - endPoint, // end position - m_pathPolyRefs, // current path - m_polyLength, // lenth of current path - pathPoints, // [out] path corner points - NULL, // [out] flags - NULL, // [out] shortened path - (int*)&pointCount, - m_pointPathLimit); // maximum number of points/polygons to use + startPoint, // start position + endPoint, // end position + m_pathPolyRefs, // current path + m_polyLength, // lenth of current path + pathPoints, // [out] path corner points + NULL, // [out] flags + NULL, // [out] shortened path + (int*)&pointCount, + m_pointPathLimit); // maximum number of points/polygons to use } else { dtResult = findSmoothPath( - startPoint, // start position - endPoint, // end position - m_pathPolyRefs, // current path - m_polyLength, // length of current path - pathPoints, // [out] path corner points - (int*)&pointCount, - m_pointPathLimit); // maximum number of points + startPoint, // start position + endPoint, // end position + m_pathPolyRefs, // current path + m_polyLength, // length of current path + pathPoints, // [out] path corner points + (int*)&pointCount, + m_pointPathLimit); // maximum number of points } if (pointCount < 2 || dtResult != DT_SUCCESS) @@ -441,12 +441,12 @@ void PathFinder::BuildPointPath(const float *startPoint, const float *endPoint) setActualEndPosition(m_pathPoints[pointCount-1]); // force the given destination, if needed - if(m_forceDestination && - (!(m_type & PATHFIND_NORMAL) || !inRange(getEndPosition(), getActualEndPosition(), 1.0f, 1.0f))) + if (m_forceDestination && + (!(m_type & PATHFIND_NORMAL) || !inRange(getEndPosition(), getActualEndPosition(), 1.0f, 1.0f))) { // we may want to keep partial subpath - if(dist3DSqr(getActualEndPosition(), getEndPosition()) < - 0.3f * dist3DSqr(getStartPosition(), getEndPosition())) + if (dist3DSqr(getActualEndPosition(), getEndPosition()) < + 0.3f * dist3DSqr(getStartPosition(), getEndPosition())) { setActualEndPosition(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; 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, - const dtPolyRef* visited, uint32 nvisited) + const dtPolyRef* visited, uint32 nvisited) { int32 furthestPath = -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, - float minTargetDist, const dtPolyRef* path, uint32 pathSize, - float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef) + float minTargetDist, const dtPolyRef* path, uint32 pathSize, + float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef) { // Find steer target. 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]; uint32 nsteerPath = 0; 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) 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. 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; ns++; } @@ -633,8 +633,8 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos, } dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos, - const dtPolyRef* polyPath, uint32 polyPathSize, - float* smoothPath, int* smoothPathSize, uint32 maxSmoothPathSize) + const dtPolyRef* polyPath, uint32 polyPathSize, + float* smoothPath, int* smoothPathSize, uint32 maxSmoothPathSize) { *smoothPathSize = 0; uint32 nsmoothPath = 0; @@ -644,10 +644,10 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos, uint32 npolys = polyPathSize; 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; - 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; 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; } -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; 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(); } diff --git a/src/game/PathFinder.h b/src/game/PathFinder.h index f1145211c..d521de1d3 100644 --- a/src/game/PathFinder.h +++ b/src/game/PathFinder.h @@ -106,16 +106,16 @@ class PathFinder m_pathPoints.clear(); } - bool inRange(const Vector3 &p1, const Vector3 &p2, float r, float h) const; - float dist3DSqr(const Vector3 &p1, const Vector3 &p2) const; + bool inRange(const Vector3& p1, const Vector3& p2, float r, float h) const; + float dist3DSqr(const Vector3& p1, const Vector3& p2) 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 getPolyByLocation(const float* point, float *distance) const; - bool HaveTile(const Vector3 &p) const; + dtPolyRef getPathPolyByPosition(const dtPolyRef* polyPath, uint32 polyPathSize, const float* point, float* distance = NULL) const; + dtPolyRef getPolyByLocation(const float* point, float* distance) const; + bool HaveTile(const Vector3& p) const; - void BuildPolyPath(const Vector3 &startPos, const Vector3 &endPos); - void BuildPointPath(const float *startPoint, const float *endPoint); + void BuildPolyPath(const Vector3& startPos, const Vector3& endPos); + void BuildPointPath(const float* startPoint, const float* endPoint); void BuildShortcut(); NavTerrain getNavTerrain(float x, float y, float z); @@ -129,8 +129,8 @@ class PathFinder const dtPolyRef* path, uint32 pathSize, float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef); dtStatus findSmoothPath(const float* startPos, const float* endPos, - const dtPolyRef* polyPath, uint32 polyPathSize, - float* smoothPath, int* smoothPathSize, uint32 smoothPathMaxSize); + const dtPolyRef* polyPath, uint32 polyPathSize, + float* smoothPath, int* smoothPathSize, uint32 smoothPathMaxSize); }; #endif diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 2c521b058..0733b15a4 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -29,11 +29,11 @@ #include "Util.h" Pet::Pet(PetType type) : -Creature(CREATURE_SUBTYPE_PET), -m_resetTalentsCost(0), m_resetTalentsTime(0), m_usedTalentCount(0), -m_removed(false), m_happinessTimer(7500), m_petType(type), m_duration(0), -m_bonusdamage(0), m_auraUpdateMask(0), m_loading(false), -m_declinedname(NULL), m_petModeFlags(PET_MODE_DEFAULT) + Creature(CREATURE_SUBTYPE_PET), + m_resetTalentsCost(0), m_resetTalentsTime(0), m_usedTalentCount(0), + m_removed(false), m_happinessTimer(7500), m_petType(type), m_duration(0), + m_bonusdamage(0), m_auraUpdateMask(0), m_loading(false), + m_declinedname(NULL), m_petModeFlags(PET_MODE_DEFAULT) { m_name = "Pet"; m_regenTimer = 4000; @@ -41,11 +41,11 @@ m_declinedname(NULL), m_petModeFlags(PET_MODE_DEFAULT) // pets always have a charminfo, even if they are not actually charmed CharmInfo* charmInfo = InitCharmInfo(this); - if(type == MINI_PET) // always passive + if (type == MINI_PET) // always passive charmInfo->SetReactState(REACT_PASSIVE); - else if(type == PROTECTOR_PET) // always defensive + else if (type == PROTECTOR_PET) // always defensive charmInfo->SetReactState(REACT_DEFENSIVE); - else if(type == GUARDIAN_PET) // always aggressive + else if (type == GUARDIAN_PET) // always aggressive charmInfo->SetReactState(REACT_AGGRESSIVE); } @@ -57,7 +57,7 @@ Pet::~Pet() void Pet::AddToWorld() { ///- Register the pet for guid lookup - if(!IsInWorld()) + if (!IsInWorld()) GetMap()->GetObjectsStore().insert(GetObjectGuid(), (Pet*)this); Unit::AddToWorld(); @@ -66,48 +66,48 @@ void Pet::AddToWorld() void Pet::RemoveFromWorld() { ///- Remove the pet from the accessor - if(IsInWorld()) + if (IsInWorld()) GetMap()->GetObjectsStore().erase(GetObjectGuid(), (Pet*)NULL); ///- Don't call the function for Creature, normal mobs + totems go in a different storage Unit::RemoveFromWorld(); } -bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool current ) +bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool current) { m_loading = true; uint32 ownerid = owner->GetGUIDLow(); - QueryResult *result; + QueryResult* result; if (petnumber) // known petnumber entry 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " - "FROM character_pet WHERE owner = '%u' AND id = '%u'", - ownerid, petnumber); + "FROM character_pet WHERE owner = '%u' AND id = '%u'", + ownerid, petnumber); else if (current) // current pet (slot 0) 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " - "FROM character_pet WHERE owner = '%u' AND slot = '%u'", - ownerid, PET_SAVE_AS_CURRENT ); + "FROM character_pet WHERE owner = '%u' AND slot = '%u'", + ownerid, PET_SAVE_AS_CURRENT); else if (petentry) // known petentry entry (unique for summoned pet, but non unique for hunter pet (only from current or not stabled pets) // 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " - "FROM character_pet WHERE owner = '%u' AND entry = '%u' AND (slot = '%u' OR slot > '%u') ", - ownerid, petentry,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT); + "FROM character_pet WHERE owner = '%u' AND entry = '%u' AND (slot = '%u' OR slot > '%u') ", + ownerid, petentry,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT); else // any current or other non-stabled pet (for hunter "call pet") // 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " - "FROM character_pet WHERE owner = '%u' AND (slot = '%u' OR slot > '%u') ", - ownerid,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT); + "FROM character_pet WHERE owner = '%u' AND (slot = '%u' OR slot > '%u') ", + ownerid,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT); - if(!result) + if (!result) return false; - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); // update for case of current pet "slot = 0" petentry = fields[1].GetUInt32(); @@ -117,7 +117,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool return false; } - CreatureInfo const *creatureInfo = ObjectMgr::GetCreatureTemplate(petentry); + CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(petentry); if (!creatureInfo) { sLog.outError("Pet entry %u does not exist but used at pet load (owner: %s).", petentry, owner->GetGuidStr().c_str()); @@ -139,7 +139,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool } PetType pet_type = PetType(fields[18].GetUInt8()); - if(pet_type == HUNTER_PET) + if (pet_type == HUNTER_PET) { if (!creatureInfo->isTameable(owner->CanTameExoticPets())) { @@ -157,7 +157,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool return false; } - Map *map = owner->GetMap(); + Map* map = owner->GetMap(); CreatureCreatePos pos(owner, owner->GetOrientation(), PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); @@ -173,7 +173,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool SetUInt32Value(UNIT_CREATED_BY_SPELL, summon_spell_id); // reget for sure use real creature info selected for Pet at load/creating - CreatureInfo const *cinfo = GetCreatureInfo(); + CreatureInfo const* cinfo = GetCreatureInfo(); if (cinfo->type == CREATURE_TYPE_CRITTER) { AIM_Initialize(); @@ -206,10 +206,10 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool sLog.outError("Pet have incorrect type (%u) for pet loading.", getPetType()); } - if(owner->IsPvP()) + if (owner->IsPvP()) SetPvP(true); - if(owner->IsFFAPvP()) + if (owner->IsFFAPvP()) SetFFAPvP(true); SetCanModifyStats(true); @@ -300,7 +300,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool if (owner->GetTypeId() == TYPEID_PLAYER) { ((Player*)owner)->PetSpellInitialize(); - if(((Player*)owner)->GetGroup()) + if (((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_PET); ((Player*)owner)->SendTalentsInfoData(true); @@ -310,14 +310,14 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool { result = CharacterDatabase.PQuery("SELECT genitive, dative, accusative, instrumental, prepositional FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", owner->GetGUIDLow(), GetCharmInfo()->GetPetNumber()); - if(result) + if (result) { - if(m_declinedname) + if (m_declinedname) delete m_declinedname; m_declinedname = new DeclinedName; - Field *fields2 = result->Fetch(); - for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) + Field* fields2 = result->Fetch(); + for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) m_declinedname->name[i] = fields2[i].GetCppString(); delete result; @@ -355,10 +355,10 @@ void Pet::SavePetToDB(PetSaveMode mode) mode = PET_SAVE_NOT_IN_SLOT; // not save pet as current if another pet temporary unsummoned else if (mode == PET_SAVE_AS_CURRENT && pOwner->GetTemporaryUnsummonedPetNumber() && - pOwner->GetTemporaryUnsummonedPetNumber() != m_charmInfo->GetPetNumber()) + pOwner->GetTemporaryUnsummonedPetNumber() != m_charmInfo->GetPetNumber()) { // pet will lost anyway at restore temporary unsummoned - if(getPetType()==HUNTER_PET) + if (getPetType()==HUNTER_PET) return; // for warlock case @@ -406,8 +406,8 @@ void Pet::SavePetToDB(PetSaveMode mode) // save pet SqlStatement savePet = CharacterDatabase.CreateStatement(insPet, "INSERT INTO character_pet ( id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, " - "curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType) " - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + "curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); savePet.addUInt32(m_charmInfo->GetPetNumber()); savePet.addUInt32(GetEntry()); @@ -424,7 +424,7 @@ void Pet::SavePetToDB(PetSaveMode mode) savePet.addUInt32(GetPower(POWER_HAPPINESS)); std::ostringstream ss; - for(uint32 i = ACTION_BAR_INDEX_START; i < ACTION_BAR_INDEX_END; ++i) + for (uint32 i = ACTION_BAR_INDEX_START; i < ACTION_BAR_INDEX_END; ++i) { ss << uint32(m_charmInfo->GetActionBarEntry(i)->GetType()) << " " << uint32(m_charmInfo->GetActionBarEntry(i)->GetAction()) << " "; @@ -449,7 +449,7 @@ void Pet::SavePetToDB(PetSaveMode mode) void Pet::DeleteFromDB(uint32 guidlow, bool separate_transaction) { - if(separate_transaction) + if (separate_transaction) CharacterDatabase.BeginTransaction(); static SqlStatementID delPet ; @@ -473,17 +473,17 @@ void Pet::DeleteFromDB(uint32 guidlow, bool separate_transaction) stmt = CharacterDatabase.CreateStatement(delSpellCD, "DELETE FROM pet_spell_cooldown WHERE guid = ?"); stmt.PExecute(guidlow); - if(separate_transaction) + if (separate_transaction) CharacterDatabase.CommitTransaction(); } void Pet::SetDeathState(DeathState s) // overwrite virtual Creature::SetDeathState and Unit::SetDeathState { Creature::SetDeathState(s); - if(getDeathState()==CORPSE) + if (getDeathState()==CORPSE) { //remove summoned pet (no corpse) - if(getPetType()==SUMMON_PET) + if (getPetType()==SUMMON_PET) Unsummon(PET_SAVE_NOT_IN_SLOT); // other will despawn at corpse desppawning (Pet::Update code) else @@ -494,13 +494,13 @@ void Pet::SetDeathState(DeathState s) // overwrite virtual //lose happiness when died and not in BG/Arena MapEntry const* mapEntry = sMapStore.LookupEntry(GetMapId()); - if(!mapEntry || (mapEntry->map_type != MAP_ARENA && mapEntry->map_type != MAP_BATTLEGROUND)) + if (!mapEntry || (mapEntry->map_type != MAP_ARENA && mapEntry->map_type != MAP_BATTLEGROUND)) ModifyPower(POWER_HAPPINESS, -HAPPINESS_LEVEL_SIZE); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } } - else if(getDeathState()==ALIVE) + else if (getDeathState()==ALIVE) { RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); CastPetAuras(true); @@ -509,10 +509,10 @@ void Pet::SetDeathState(DeathState s) // overwrite virtual void Pet::Update(uint32 update_diff, uint32 diff) { - if(m_removed) // pet already removed, just wait in remove queue, no updates + if (m_removed) // pet already removed, just wait in remove queue, no updates return; - switch( m_deathState ) + switch (m_deathState) { case CORPSE: { @@ -529,8 +529,8 @@ void Pet::Update(uint32 update_diff, uint32 diff) // unsummon pet that lost owner Unit* owner = GetOwner(); if (!owner || - (!IsWithinDistInMap(owner, GetMap()->GetVisibilityDistance()) && (owner->GetCharmGuid() && (owner->GetCharmGuid() != GetObjectGuid()))) || - (isControlled() && !owner->GetPetGuid())) + (!IsWithinDistInMap(owner, GetMap()->GetVisibilityDistance()) && (owner->GetCharmGuid() && (owner->GetCharmGuid() != GetObjectGuid()))) || + (isControlled() && !owner->GetPetGuid())) { Unsummon(PET_SAVE_REAGENTS); return; @@ -547,7 +547,7 @@ void Pet::Update(uint32 update_diff, uint32 diff) if (m_duration > 0) { - if(m_duration > (int32)update_diff) + if (m_duration > (int32)update_diff) m_duration -= (int32)update_diff; else { @@ -564,7 +564,7 @@ void Pet::Update(uint32 update_diff, uint32 diff) Creature::Update(update_diff, diff); } -void Pet::RegenerateAll( uint32 update_diff ) +void Pet::RegenerateAll(uint32 update_diff) { //regenerate focus for hunter pets or energy for deathknight's ghoul if (m_regenTimer <= update_diff) @@ -592,7 +592,7 @@ void Pet::RegenerateAll( uint32 update_diff ) if (getPetType() != HUNTER_PET) return; - if(m_happinessTimer <= update_diff) + if (m_happinessTimer <= update_diff) { LooseHappiness(); m_happinessTimer = 7500; @@ -632,7 +632,7 @@ void Pet::Regenerate(Powers power) // Apply modifiers (if any). AuraList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT); - for(AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i) + for (AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i) if ((*i)->GetModifier()->m_miscvalue == int32(power)) addvalue *= ((*i)->GetModifier()->m_amount + 100) / 100.0f; @@ -645,16 +645,16 @@ void Pet::LooseHappiness() if (curValue <= 0) return; int32 addvalue = 670; //value is 70/35/17/8/4 (per min) * 1000 / 8 (timer 7.5 secs) - if(isInCombat()) //we know in combat happiness fades faster, multiplier guess + if (isInCombat()) //we know in combat happiness fades faster, multiplier guess addvalue = int32(addvalue * 1.5); ModifyPower(POWER_HAPPINESS, -addvalue); } HappinessState Pet::GetHappinessState() { - if(GetPower(POWER_HAPPINESS) < HAPPINESS_LEVEL_SIZE) + if (GetPower(POWER_HAPPINESS) < HAPPINESS_LEVEL_SIZE) return UNHAPPY; - else if(GetPower(POWER_HAPPINESS) >= HAPPINESS_LEVEL_SIZE * 2) + else if (GetPower(POWER_HAPPINESS) >= HAPPINESS_LEVEL_SIZE * 2) return HAPPY; else return CONTENT; @@ -665,33 +665,33 @@ bool Pet::CanTakeMoreActiveSpells(uint32 spellid) uint8 activecount = 1; uint32 chainstartstore[ACTIVE_SPELLS_MAX]; - if(IsPassiveSpell(spellid)) + if (IsPassiveSpell(spellid)) return true; chainstartstore[0] = sSpellMgr.GetFirstSpellInChain(spellid); for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) { - if(itr->second.state == PETSPELL_REMOVED) + if (itr->second.state == PETSPELL_REMOVED) continue; - if(IsPassiveSpell(itr->first)) + if (IsPassiveSpell(itr->first)) continue; uint32 chainstart = sSpellMgr.GetFirstSpellInChain(itr->first); uint8 x; - for(x = 0; x < activecount; x++) + for (x = 0; x < activecount; x++) { - if(chainstart == chainstartstore[x]) + if (chainstart == chainstartstore[x]) break; } - if(x == activecount) //spellchain not yet saved -> add active count + if (x == activecount) //spellchain not yet saved -> add active count { ++activecount; - if(activecount > ACTIVE_SPELLS_MAX) + if (activecount > ACTIVE_SPELLS_MAX) return false; chainstartstore[x] = chainstart; } @@ -706,7 +706,7 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/) CombatStop(); - if(owner) + if (owner) { if (GetOwnerGuid() != owner->GetObjectGuid()) return; @@ -718,18 +718,18 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/) // not save secondary permanent pet as current if (mode == PET_SAVE_AS_CURRENT && p_owner->GetTemporaryUnsummonedPetNumber() && - p_owner->GetTemporaryUnsummonedPetNumber() != GetCharmInfo()->GetPetNumber()) + p_owner->GetTemporaryUnsummonedPetNumber() != GetCharmInfo()->GetPetNumber()) mode = PET_SAVE_NOT_IN_SLOT; if (mode == PET_SAVE_REAGENTS) { //returning of reagents only for players, so best done here uint32 spellId = GetUInt32Value(UNIT_CREATED_BY_SPELL); - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (spellInfo) { - for(uint32 i = 0; i < MAX_SPELL_REAGENTS; ++i) + for (uint32 i = 0; i < MAX_SPELL_REAGENTS; ++i) { if (spellInfo->Reagent[i] > 0) { @@ -756,7 +756,7 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/) } // only if current pet in slot - switch(getPetType()) + switch (getPetType()) { case MINI_PET: if (p_owner) @@ -780,13 +780,13 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/) void Pet::GivePetXP(uint32 xp) { - if(getPetType() != HUNTER_PET) + if (getPetType() != HUNTER_PET) return; - if ( xp < 1 ) + if (xp < 1) return; - if(!isAlive()) + if (!isAlive()) return; uint32 level = getLevel(); @@ -800,7 +800,7 @@ void Pet::GivePetXP(uint32 xp) uint32 curXP = GetUInt32Value(UNIT_FIELD_PETEXPERIENCE); uint32 newXP = curXP + xp; - while( newXP >= nextLvlXP && level < maxlevel) + while (newXP >= nextLvlXP && level < maxlevel) { newXP -= nextLvlXP; ++level; @@ -831,7 +831,7 @@ void Pet::GivePetLevel(uint32 level) bool Pet::CreateBaseAtCreature(Creature* creature) { - if(!creature) + if (!creature) { sLog.outError("CRITICAL: NULL pointer passed into CreateBaseAtCreature()"); return false; @@ -846,14 +846,14 @@ bool Pet::CreateBaseAtCreature(Creature* creature) if (!Create(guid, pos, creature->GetCreatureInfo(), pet_number)) return false; - CreatureInfo const *cinfo = GetCreatureInfo(); - if(!cinfo) + CreatureInfo const* cinfo = GetCreatureInfo(); + if (!cinfo) { sLog.outError("CreateBaseAtCreature() failed, creatureInfo is missing!"); return false; } - if(cinfo->type == CREATURE_TYPE_CRITTER) + if (cinfo->type == CREATURE_TYPE_CRITTER) { setPetType(MINI_PET); return true; @@ -868,12 +868,12 @@ bool Pet::CreateBaseAtCreature(Creature* creature) SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(creature->getLevel())); SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); - if(CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family)) + if (CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family)) SetName(cFamily->Name[sWorld.GetDefaultDbcLocale()]); else SetName(creature->GetNameForLocaleIdx(sObjectMgr.GetDBCLocaleIndex())); - if(cinfo->type == CREATURE_TYPE_BEAST) + if (cinfo->type == CREATURE_TYPE_BEAST) { SetByteValue(UNIT_FIELD_BYTES_0, 1, CLASS_WARRIOR); SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_NONE); @@ -887,13 +887,13 @@ bool Pet::CreateBaseAtCreature(Creature* creature) bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) { - CreatureInfo const *cinfo = GetCreatureInfo(); + CreatureInfo const* cinfo = GetCreatureInfo(); MANGOS_ASSERT(cinfo); - if(!owner) + if (!owner) { owner = GetOwner(); - if(!owner) + if (!owner) { sLog.outError("attempt to summon pet (Entry %u) without owner! Attempt terminated.", cinfo->Entry); return false; @@ -933,7 +933,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0); CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family); - if(cFamily && cFamily->minScale > 0.0f && getPetType()==HUNTER_PET) + if (cFamily && cFamily->minScale > 0.0f && getPetType()==HUNTER_PET) { float scale; if (getLevel() >= cFamily->maxScaleLevel) @@ -950,7 +950,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) int32 createResistance[MAX_SPELL_SCHOOL] = {0,0,0,0,0,0,0}; - if(getPetType() != HUNTER_PET) + if (getPetType() != HUNTER_PET) { createResistance[SPELL_SCHOOL_HOLY] = cinfo->resistance1; createResistance[SPELL_SCHOOL_FIRE] = cinfo->resistance2; @@ -960,13 +960,13 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) createResistance[SPELL_SCHOOL_ARCANE] = cinfo->resistance6; } - switch(getPetType()) + switch (getPetType()) { case SUMMON_PET: { - if(owner->GetTypeId() == TYPEID_PLAYER) + if (owner->GetTypeId() == TYPEID_PLAYER) { - switch(owner->getClass()) + switch (owner->getClass()) { case CLASS_WARLOCK: { @@ -976,17 +976,17 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) uint32 shadow = owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW); uint32 val = (fire > shadow) ? fire : shadow; - SetBonusDamage(int32 (val * 0.15f)); + SetBonusDamage(int32(val * 0.15f)); //bonusAP += val * 0.57; break; } case CLASS_MAGE: { - //40% damage bonus of mage's frost damage + //40% damage bonus of mage's frost damage float val = owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST) * 0.4f; - if(val < 0) + if (val < 0) val = 0; - SetBonusDamage( int32(val)); + SetBonusDamage(int32(val)); break; } default: @@ -994,21 +994,21 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) } } - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)) ); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4)) ); + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); //SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, float(cinfo->attackpower)); PetLevelInfo const* pInfo = sObjectMgr.GetPetLevelInfo(creature_ID, petlevel); - if(pInfo) // exist in DB + if (pInfo) // exist in DB { SetCreateHealth(pInfo->health); SetCreateMana(pInfo->mana); - if(pInfo->armor > 0) + if (pInfo->armor > 0) SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(pInfo->armor)); - for(int stat = 0; stat < MAX_STATS; ++stat) + for (int stat = 0; stat < MAX_STATS; ++stat) { SetCreateStat(Stats(stat), float(pInfo->stats[stat])); } @@ -1018,8 +1018,8 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) sLog.outErrorDb("Summoned pet (Entry: %u) not have pet stats data in DB",cinfo->Entry); // remove elite bonuses included in DB values - SetCreateHealth(uint32(((float(cinfo->maxhealth) / cinfo->maxlevel) / (1 + 2 * cinfo->rank)) * petlevel) ); - SetCreateMana( uint32(((float(cinfo->maxmana) / cinfo->maxlevel) / (1 + 2 * cinfo->rank)) * petlevel) ); + SetCreateHealth(uint32(((float(cinfo->maxhealth) / cinfo->maxlevel) / (1 + 2 * cinfo->rank)) * petlevel)); + SetCreateMana(uint32(((float(cinfo->maxmana) / cinfo->maxlevel) / (1 + 2 * cinfo->rank)) * petlevel)); SetCreateStat(STAT_STRENGTH, 22); SetCreateStat(STAT_AGILITY, 22); @@ -1034,20 +1034,20 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(petlevel)); //these formula may not be correct; however, it is designed to be close to what it should be //this makes dps 0.5 of pets level - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)) ); + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); //damage range is then petlevel / 2 - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4)) ); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); //damage is increased afterwards as strength and pet scaling modify attack power //stored standard pet stats are entry 1 in pet_levelinfo PetLevelInfo const* pInfo = sObjectMgr.GetPetLevelInfo(creature_ID, petlevel); - if(pInfo) // exist in DB + if (pInfo) // exist in DB { SetCreateHealth(pInfo->health); SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(pInfo->armor)); //SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, float(cinfo->attackpower)); - for( int i = STAT_STRENGTH; i < MAX_STATS; ++i) + for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) { SetCreateStat(Stats(i), float(pInfo->stats[i])); } @@ -1057,7 +1057,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) sLog.outErrorDb("Hunter pet levelstats missing in DB"); // remove elite bonuses included in DB values - SetCreateHealth( uint32(((float(cinfo->maxhealth) / cinfo->maxlevel) / (1 + 2 * cinfo->rank)) * petlevel) ); + SetCreateHealth(uint32(((float(cinfo->maxhealth) / cinfo->maxlevel) / (1 + 2 * cinfo->rank)) * petlevel)); SetCreateStat(STAT_STRENGTH, 22); SetCreateStat(STAT_AGILITY, 22); @@ -1104,11 +1104,11 @@ bool Pet::HaveInDiet(ItemPrototype const* item) const return false; CreatureInfo const* cInfo = GetCreatureInfo(); - if(!cInfo) + if (!cInfo) return false; CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->family); - if(!cFamily) + if (!cFamily) return false; uint32 diet = cFamily->petFoodMask; @@ -1119,13 +1119,13 @@ bool Pet::HaveInDiet(ItemPrototype const* item) const uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel) { // -5 or greater food level - if(getLevel() <= itemlevel + 5) //possible to feed level 60 pet with level 55 level food for full effect + if (getLevel() <= itemlevel + 5) //possible to feed level 60 pet with level 55 level food for full effect return 35000; // -10..-6 - else if(getLevel() <= itemlevel + 10) //pure guess, but sounds good + else if (getLevel() <= itemlevel + 10) //pure guess, but sounds good return 17000; // -14..-11 - else if(getLevel() <= itemlevel + 14) //level 55 food gets green on 70, makes sense to me + else if (getLevel() <= itemlevel + 14) //level 55 food gets green on 70, makes sense to me return 8000; // -15 or less else @@ -1137,9 +1137,9 @@ void Pet::_LoadSpellCooldowns() m_CreatureSpellCooldowns.clear(); m_CreatureCategoryCooldowns.clear(); - QueryResult *result = CharacterDatabase.PQuery("SELECT spell,time FROM pet_spell_cooldown WHERE guid = '%u'",m_charmInfo->GetPetNumber()); + QueryResult* result = CharacterDatabase.PQuery("SELECT spell,time FROM pet_spell_cooldown WHERE guid = '%u'",m_charmInfo->GetPetNumber()); - if(result) + if (result) { time_t curTime = time(NULL); @@ -1149,19 +1149,19 @@ void Pet::_LoadSpellCooldowns() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 spell_id = fields[0].GetUInt32(); time_t db_time = (time_t)fields[1].GetUInt64(); - if(!sSpellStore.LookupEntry(spell_id)) + if (!sSpellStore.LookupEntry(spell_id)) { sLog.outError("Pet %u have unknown spell %u in `pet_spell_cooldown`, skipping.",m_charmInfo->GetPetNumber(),spell_id); continue; } // skip outdated cooldown - if(db_time <= curTime) + if (db_time <= curTime) continue; data << uint32(spell_id); @@ -1171,11 +1171,11 @@ void Pet::_LoadSpellCooldowns() DEBUG_LOG("Pet (Number: %u) spell %u cooldown loaded (%u secs).", m_charmInfo->GetPetNumber(), spell_id, uint32(db_time-curTime)); } - while( result->NextRow() ); + while (result->NextRow()); delete result; - if(!m_CreatureSpellCooldowns.empty() && GetOwner()) + if (!m_CreatureSpellCooldowns.empty() && GetOwner()) { ((Player*)GetOwner())->GetSession()->SendPacket(&data); } @@ -1193,9 +1193,9 @@ void Pet::_SaveSpellCooldowns() time_t curTime = time(NULL); // remove oudated and save active - for(CreatureSpellCooldowns::iterator itr = m_CreatureSpellCooldowns.begin();itr != m_CreatureSpellCooldowns.end();) + for (CreatureSpellCooldowns::iterator itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end();) { - if(itr->second <= curTime) + if (itr->second <= curTime) m_CreatureSpellCooldowns.erase(itr++); else { @@ -1208,17 +1208,17 @@ void Pet::_SaveSpellCooldowns() void Pet::_LoadSpells() { - QueryResult *result = CharacterDatabase.PQuery("SELECT spell,active FROM pet_spell WHERE guid = '%u'",m_charmInfo->GetPetNumber()); + QueryResult* result = CharacterDatabase.PQuery("SELECT spell,active FROM pet_spell WHERE guid = '%u'",m_charmInfo->GetPetNumber()); - if(result) + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); addSpell(fields[0].GetUInt32(), ActiveStates(fields[1].GetUInt8()), PETSPELL_UNCHANGED); } - while( result->NextRow() ); + while (result->NextRow()); delete result; } @@ -1237,30 +1237,30 @@ void Pet::_SaveSpells() if (itr->second.type == PETSPELL_FAMILY) continue; - switch(itr->second.state) + switch (itr->second.state) { case PETSPELL_REMOVED: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(delSpell, "DELETE FROM pet_spell WHERE guid = ? and spell = ?"); - stmt.PExecute(m_charmInfo->GetPetNumber(), itr->first); - m_spells.erase(itr); - } - continue; + { + SqlStatement stmt = CharacterDatabase.CreateStatement(delSpell, "DELETE FROM pet_spell WHERE guid = ? and spell = ?"); + stmt.PExecute(m_charmInfo->GetPetNumber(), itr->first); + m_spells.erase(itr); + } + continue; case PETSPELL_CHANGED: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(delSpell, "DELETE FROM pet_spell WHERE guid = ? and spell = ?"); - stmt.PExecute(m_charmInfo->GetPetNumber(), itr->first); + { + SqlStatement stmt = CharacterDatabase.CreateStatement(delSpell, "DELETE FROM pet_spell WHERE guid = ? and spell = ?"); + stmt.PExecute(m_charmInfo->GetPetNumber(), itr->first); - stmt = CharacterDatabase.CreateStatement(insSpell, "INSERT INTO pet_spell (guid,spell,active) VALUES (?, ?, ?)"); - stmt.PExecute(m_charmInfo->GetPetNumber(), itr->first, uint32(itr->second.active)); - } - break; + stmt = CharacterDatabase.CreateStatement(insSpell, "INSERT INTO pet_spell (guid,spell,active) VALUES (?, ?, ?)"); + stmt.PExecute(m_charmInfo->GetPetNumber(), itr->first, uint32(itr->second.active)); + } + break; case PETSPELL_NEW: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(insSpell, "INSERT INTO pet_spell (guid,spell,active) VALUES (?, ?, ?)"); - stmt.PExecute(m_charmInfo->GetPetNumber(), itr->first, uint32(itr->second.active)); - } - break; + { + SqlStatement stmt = CharacterDatabase.CreateStatement(insSpell, "INSERT INTO pet_spell (guid,spell,active) VALUES (?, ?, ?)"); + stmt.PExecute(m_charmInfo->GetPetNumber(), itr->first, uint32(itr->second.active)); + } + break; case PETSPELL_UNCHANGED: continue; } @@ -1273,13 +1273,13 @@ void Pet::_LoadAuras(uint32 timediff) { RemoveAllAuras(); - QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,item_guid,spell,stackcount,remaincharges,basepoints0,basepoints1,basepoints2,periodictime0,periodictime1,periodictime2,maxduration,remaintime,effIndexMask FROM pet_aura WHERE guid = '%u'", m_charmInfo->GetPetNumber()); + QueryResult* result = CharacterDatabase.PQuery("SELECT caster_guid,item_guid,spell,stackcount,remaincharges,basepoints0,basepoints1,basepoints2,periodictime0,periodictime1,periodictime2,maxduration,remaintime,effIndexMask FROM pet_aura WHERE guid = '%u'", m_charmInfo->GetPetNumber()); - if(result) + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); ObjectGuid casterGuid = ObjectGuid(fields[0].GetUInt64()); uint32 item_lowguid = fields[1].GetUInt32(); uint32 spellid = fields[2].GetUInt32(); @@ -1328,7 +1328,7 @@ void Pet::_LoadAuras(uint32 timediff) else if (!stackcount) stackcount = 1; - SpellAuraHolder *holder = CreateSpellAuraHolder(spellproto, this, NULL); + SpellAuraHolder* holder = CreateSpellAuraHolder(spellproto, this, NULL); holder->SetLoadedState(casterGuid, ObjectGuid(HIGHGUID_ITEM, item_lowguid), stackcount, remaincharges, maxduration, remaintime); for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) @@ -1349,7 +1349,7 @@ void Pet::_LoadAuras(uint32 timediff) else delete holder; } - while( result->NextRow() ); + while (result->NextRow()); delete result; } @@ -1369,20 +1369,20 @@ void Pet::_SaveAuras() return; stmt = CharacterDatabase.CreateStatement(insAuras, "INSERT INTO pet_aura (guid, caster_guid, item_guid, spell, stackcount, remaincharges, " - "basepoints0, basepoints1, basepoints2, periodictime0, periodictime1, periodictime2, maxduration, remaintime, effIndexMask) " - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + "basepoints0, basepoints1, basepoints2, periodictime0, periodictime1, periodictime2, maxduration, remaintime, effIndexMask) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); - for(SpellAuraHolderMap::const_iterator itr = auraHolders.begin(); itr != auraHolders.end(); ++itr) + for (SpellAuraHolderMap::const_iterator itr = auraHolders.begin(); itr != auraHolders.end(); ++itr) { - SpellAuraHolder *holder = itr->second; + SpellAuraHolder* holder = itr->second; bool save = true; for (int32 j = 0; j < MAX_EFFECT_INDEX; ++j) { SpellEntry const* spellInfo = holder->GetSpellProto(); if (spellInfo->EffectApplyAuraName[j] == SPELL_AURA_MOD_STEALTH || - spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AREA_AURA_OWNER || - spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AREA_AURA_PET ) + spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AREA_AURA_OWNER || + spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AREA_AURA_PET) { save = false; break; @@ -1402,7 +1402,7 @@ void Pet::_SaveAuras() damage[i] = 0; periodicTime[i] = 0; - if (Aura *aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) + if (Aura* aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) { // don't save not own area auras if (aur->IsAreaAura() && holder->GetCasterGuid() != GetObjectGuid()) @@ -1440,11 +1440,11 @@ void Pet::_SaveAuras() bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpellState state /*= PETSPELL_NEW*/, PetSpellType type /*= PETSPELL_NORMAL*/) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); if (!spellInfo) { // do pet spell book cleanup - if(state == PETSPELL_UNCHANGED) // spell load case + if (state == PETSPELL_UNCHANGED) // spell load case { sLog.outError("Pet::addSpell: nonexistent in SpellStore spell #%u request, deleting for all pets in `pet_spell`.",spell_id); CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE spell = '%u'",spell_id); @@ -1468,9 +1468,9 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel // can be in case spell loading but learned at some previous spell loading itr->second.state = PETSPELL_UNCHANGED; - if(active == ACT_ENABLED) + if (active == ACT_ENABLED) ToggleAutocast(spell_id, true); - else if(active == ACT_DISABLED) + else if (active == ACT_DISABLED) ToggleAutocast(spell_id, false); return false; @@ -1485,9 +1485,9 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel newspell.state = state; newspell.type = type; - if(active == ACT_DECIDE) //active was not used before, so we save it's autocast/passive state here + if (active == ACT_DECIDE) //active was not used before, so we save it's autocast/passive state here { - if(IsPassiveSpell(spellInfo)) + if (IsPassiveSpell(spellInfo)) newspell.active = ACT_PASSIVE; else newspell.active = ACT_DISABLED; @@ -1496,38 +1496,38 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel newspell.active = active; // talent: unlearn all other talent ranks (high and low) - if(TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id)) + if (TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id)) { - if(TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id )) + if (TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentPos->talent_id)) { - for(int i=0; i < MAX_TALENT_RANK; ++i) + for (int i=0; i < MAX_TALENT_RANK; ++i) { // skip learning spell and no rank spell case uint32 rankSpellId = talentInfo->RankID[i]; - if(!rankSpellId || rankSpellId==spell_id) + if (!rankSpellId || rankSpellId==spell_id) continue; // skip unknown ranks - if(!HasSpell(rankSpellId)) + if (!HasSpell(rankSpellId)) continue; removeSpell(rankSpellId,false,false); } } } - else if(sSpellMgr.GetSpellRank(spell_id)!=0) + else if (sSpellMgr.GetSpellRank(spell_id)!=0) { for (PetSpellMap::const_iterator itr2 = m_spells.begin(); itr2 != m_spells.end(); ++itr2) { - if(itr2->second.state == PETSPELL_REMOVED) continue; + if (itr2->second.state == PETSPELL_REMOVED) continue; - if( sSpellMgr.IsRankSpellDueToSpell(spellInfo,itr2->first) ) + if (sSpellMgr.IsRankSpellDueToSpell(spellInfo,itr2->first)) { // replace by new high rank - if(sSpellMgr.IsHighRankOfSpell(spell_id,itr2->first)) + if (sSpellMgr.IsHighRankOfSpell(spell_id,itr2->first)) { newspell.active = itr2->second.active; - if(newspell.active == ACT_ENABLED) + if (newspell.active == ACT_ENABLED) ToggleAutocast(itr2->first, false); oldspell_id = itr2->first; @@ -1535,7 +1535,7 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel break; } // ignore new lesser rank - else if(sSpellMgr.IsHighRankOfSpell(itr2->first,spell_id)) + else if (sSpellMgr.IsHighRankOfSpell(itr2->first,spell_id)) return false; } } @@ -1548,7 +1548,7 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel else m_charmInfo->AddSpellToActionBar(spell_id, ActiveStates(newspell.active)); - if(newspell.active == ACT_ENABLED) + if (newspell.active == ACT_ENABLED) ToggleAutocast(spell_id, true); uint32 talentCost = GetTalentSpellCost(spell_id); @@ -1566,10 +1566,10 @@ bool Pet::learnSpell(uint32 spell_id) if (!addSpell(spell_id)) return false; - if(!m_loading) + if (!m_loading) { Unit* owner = GetOwner(); - if(owner && owner->GetTypeId() == TYPEID_PLAYER) + if (owner && owner->GetTypeId() == TYPEID_PLAYER) { WorldPacket data(SMSG_PET_LEARNED_SPELL, 4); data << uint32(spell_id); @@ -1585,13 +1585,13 @@ void Pet::InitLevelupSpellsForLevel() { uint32 level = getLevel(); - if(PetLevelupSpellSet const *levelupSpells = GetCreatureInfo()->family ? sSpellMgr.GetPetLevelupSpellList(GetCreatureInfo()->family) : NULL) + if (PetLevelupSpellSet const* levelupSpells = GetCreatureInfo()->family ? sSpellMgr.GetPetLevelupSpellList(GetCreatureInfo()->family) : NULL) { // PetLevelupSpellSet ordered by levels, process in reversed order - for(PetLevelupSpellSet::const_reverse_iterator itr = levelupSpells->rbegin(); itr != levelupSpells->rend(); ++itr) + for (PetLevelupSpellSet::const_reverse_iterator itr = levelupSpells->rbegin(); itr != levelupSpells->rend(); ++itr) { // will called first if level down - if(itr->first > level) + if (itr->first > level) unlearnSpell(itr->second,true); // will learn prev rank if any // will called if level up else @@ -1602,16 +1602,16 @@ void Pet::InitLevelupSpellsForLevel() int32 petSpellsId = GetCreatureInfo()->PetSpellDataId ? -(int32)GetCreatureInfo()->PetSpellDataId : GetEntry(); // default spells (can be not learned if pet level (as owner level decrease result for example) less first possible in normal game) - if(PetDefaultSpellsEntry const *defSpells = sSpellMgr.GetPetDefaultSpellsEntry(petSpellsId)) + if (PetDefaultSpellsEntry const* defSpells = sSpellMgr.GetPetDefaultSpellsEntry(petSpellsId)) { - for(int i = 0; i < MAX_CREATURE_SPELL_DATA_SLOT; ++i) + for (int i = 0; i < MAX_CREATURE_SPELL_DATA_SLOT; ++i) { SpellEntry const* spellEntry = sSpellStore.LookupEntry(defSpells->spellid[i]); - if(!spellEntry) + if (!spellEntry) continue; // will called first if level down - if(spellEntry->spellLevel > level) + if (spellEntry->spellLevel > level) unlearnSpell(spellEntry->Id,true); // will called if level up else @@ -1622,13 +1622,13 @@ void Pet::InitLevelupSpellsForLevel() bool Pet::unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab) { - if(removeSpell(spell_id,learn_prev,clear_ab)) + if (removeSpell(spell_id,learn_prev,clear_ab)) { - if(!m_loading) + if (!m_loading) { if (Unit* owner = GetOwner()) { - if(owner->GetTypeId() == TYPEID_PLAYER) + if (owner->GetTypeId() == TYPEID_PLAYER) { WorldPacket data(SMSG_PET_REMOVED_SPELL, 4); data << uint32(spell_id); @@ -1647,10 +1647,10 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) if (itr == m_spells.end()) return false; - if(itr->second.state == PETSPELL_REMOVED) + if (itr->second.state == PETSPELL_REMOVED) return false; - if(itr->second.state == PETSPELL_NEW) + if (itr->second.state == PETSPELL_NEW) m_spells.erase(itr); else itr->second.state = PETSPELL_REMOVED; @@ -1670,7 +1670,7 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) if (learn_prev) { - if (uint32 prev_id = sSpellMgr.GetPrevSpellInChain (spell_id)) + if (uint32 prev_id = sSpellMgr.GetPrevSpellInChain(spell_id)) learnSpell(prev_id); else learn_prev = false; @@ -1679,7 +1679,7 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) // if remove last rank or non-ranked then update action bar at server and client if need if (clear_ab && !learn_prev && m_charmInfo->RemoveSpellFromActionBar(spell_id)) { - if(!m_loading) + if (!m_loading) { // need update action bar for last removed rank if (Unit* owner = GetOwner()) @@ -1693,10 +1693,10 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) void Pet::CleanupActionBar() { - for(int i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) - if(UnitActionBarEntry const* ab = m_charmInfo->GetActionBarEntry(i)) - if(uint32 action = ab->GetAction()) - if(ab->IsActionBarForSpell() && !HasSpell(action)) + for (int i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) + if (UnitActionBarEntry const* ab = m_charmInfo->GetActionBarEntry(i)) + if (uint32 action = ab->GetAction()) + if (ab->IsActionBarForSpell() && !HasSpell(action)) m_charmInfo->SetActionBar(i,0,ACT_DISABLED); } @@ -1712,23 +1712,23 @@ void Pet::InitPetCreateSpells() bool Pet::resetTalents(bool no_cost) { - Unit *owner = GetOwner(); + Unit* owner = GetOwner(); if (!owner || owner->GetTypeId()!=TYPEID_PLAYER) return false; // not need after this call - if(((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS)) + if (((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS)) ((Player*)owner)->RemoveAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS,true); - CreatureInfo const * ci = GetCreatureInfo(); - if(!ci) + CreatureInfo const* ci = GetCreatureInfo(); + if (!ci) return false; // Check pet talent type - CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family); - if(!pet_family || pet_family->petTalentType < 0) + CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->family); + if (!pet_family || pet_family->petTalentType < 0) return false; - Player *player = (Player *)owner; + Player* player = (Player*)owner; if (m_usedTalentCount == 0) { @@ -1738,30 +1738,30 @@ bool Pet::resetTalents(bool no_cost) uint32 cost = 0; - if(!no_cost) + if (!no_cost) { cost = resetTalentsCost(); if (player->GetMoney() < cost) { - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0); + player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0); return false; } } for (unsigned int i = 0; i < sTalentStore.GetNumRows(); ++i) { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); + TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); if (!talentInfo) continue; - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); - if(!talentTabInfo) + if (!talentTabInfo) continue; // unlearn only talents for pets family talent type - if(!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) + if (!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) continue; for (int j = 0; j < MAX_TALENT_RANK; j++) @@ -1771,7 +1771,7 @@ bool Pet::resetTalents(bool no_cost) UpdateFreeTalentPoints(false); - if(!no_cost) + if (!no_cost) { player->ModifyMoney(-(int32)cost); @@ -1785,30 +1785,30 @@ bool Pet::resetTalents(bool no_cost) void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) { // not need after this call - if(((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS)) + if (((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS)) ((Player*)owner)->RemoveAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS,true); // reset for online - if(online_pet) + if (online_pet) online_pet->resetTalents(true); // now need only reset for offline pets (all pets except online case) uint32 except_petnumber = online_pet ? online_pet->GetCharmInfo()->GetPetNumber() : 0; - QueryResult *resultPets = CharacterDatabase.PQuery( - "SELECT id FROM character_pet WHERE owner = '%u' AND id <> '%u'", - owner->GetGUIDLow(),except_petnumber); + QueryResult* resultPets = CharacterDatabase.PQuery( + "SELECT id FROM character_pet WHERE owner = '%u' AND id <> '%u'", + owner->GetGUIDLow(),except_petnumber); // no offline pets - if(!resultPets) + if (!resultPets) return; - QueryResult *result = CharacterDatabase.PQuery( - "SELECT DISTINCT pet_spell.spell FROM pet_spell, character_pet " - "WHERE character_pet.owner = '%u' AND character_pet.id = pet_spell.guid AND character_pet.id <> %u", - owner->GetGUIDLow(),except_petnumber); + QueryResult* result = CharacterDatabase.PQuery( + "SELECT DISTINCT pet_spell.spell FROM pet_spell, character_pet " + "WHERE character_pet.owner = '%u' AND character_pet.id = pet_spell.guid AND character_pet.id <> %u", + owner->GetGUIDLow(),except_petnumber); - if(!result) + if (!result) { delete resultPets; return; @@ -1820,18 +1820,18 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) do { - Field *fields = resultPets->Fetch(); + Field* fields = resultPets->Fetch(); uint32 id = fields[0].GetUInt32(); - if(need_comma) + if (need_comma) ss << ","; ss << id; need_comma = true; } - while( resultPets->NextRow() ); + while (resultPets->NextRow()); delete resultPets; @@ -1840,25 +1840,25 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) bool need_execute = false; do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 spell = fields[0].GetUInt32(); - if(!GetTalentSpellCost(spell)) + if (!GetTalentSpellCost(spell)) continue; - if(need_execute) + if (need_execute) ss << ","; ss << spell; need_execute = true; } - while( result->NextRow() ); + while (result->NextRow()); delete result; - if(!need_execute) + if (!need_execute) return; ss << ")"; @@ -1876,7 +1876,7 @@ void Pet::UpdateFreeTalentPoints(bool resetIfNeed) // Remove all talent points (except for admin pets) if (resetIfNeed) { - Unit *owner = GetOwner(); + Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER || ((Player*)owner)->GetSession()->GetSecurity() < SEC_ADMINISTRATOR) resetTalents(true); else @@ -1894,11 +1894,11 @@ void Pet::InitTalentForLevel() { UpdateFreeTalentPoints(); - Unit *owner = GetOwner(); + Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; - if(!m_loading) + if (!m_loading) ((Player*)owner)->SendTalentsInfoData(true); } @@ -1907,13 +1907,13 @@ uint32 Pet::resetTalentsCost() const uint32 days = uint32(sWorld.GetGameTime() - m_resetTalentsTime)/DAY; // The first time reset costs 10 silver; after 1 day cost is reset to 10 silver - if(m_resetTalentsCost < 10*SILVER || days > 0) + if (m_resetTalentsCost < 10*SILVER || days > 0) return 10*SILVER; // then 50 silver - else if(m_resetTalentsCost < 50*SILVER) + else if (m_resetTalentsCost < 50*SILVER) return 50*SILVER; // then 1 gold - else if(m_resetTalentsCost < 1*GOLD) + else if (m_resetTalentsCost < 1*GOLD) return 1*GOLD; // then increasing at a rate of 1 gold; cap 10 gold else @@ -1924,21 +1924,21 @@ uint8 Pet::GetMaxTalentPointsForLevel(uint32 level) { uint8 points = (level >= 20) ? ((level - 16) / 4) : 0; // Mod points from owner SPELL_AURA_MOD_PET_TALENT_POINTS - if (Unit *owner = GetOwner()) + if (Unit* owner = GetOwner()) points+=owner->GetTotalAuraModifier(SPELL_AURA_MOD_PET_TALENT_POINTS); return points; } void Pet::ToggleAutocast(uint32 spellid, bool apply) { - if(IsPassiveSpell(spellid)) + if (IsPassiveSpell(spellid)) return; PetSpellMap::iterator itr = m_spells.find(spellid); uint32 i; - if(apply) + if (apply) { for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i) ; // just search @@ -1947,10 +1947,10 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply) { m_autospells.push_back(spellid); - if(itr->second.active != ACT_ENABLED) + if (itr->second.active != ACT_ENABLED) { itr->second.active = ACT_ENABLED; - if(itr->second.state != PETSPELL_NEW) + if (itr->second.state != PETSPELL_NEW) itr->second.state = PETSPELL_CHANGED; } } @@ -1964,10 +1964,10 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply) if (i < m_autospells.size()) { m_autospells.erase(itr2); - if(itr->second.active != ACT_DISABLED) + if (itr->second.active != ACT_DISABLED) { itr->second.active = ACT_DISABLED; - if(itr->second.state != PETSPELL_NEW) + if (itr->second.state != PETSPELL_NEW) itr->second.state = PETSPELL_CHANGED; } } @@ -1976,13 +1976,13 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply) bool Pet::IsPermanentPetFor(Player* owner) { - switch(getPetType()) + switch (getPetType()) { case SUMMON_PET: - switch(owner->getClass()) + switch (owner->getClass()) { - // oddly enough, Mage's Water Elemental is still treated as temporary pet with Glyph of Eternal Water - // i.e. does not unsummon at mounting, gets dismissed at teleport etc. + // oddly enough, Mage's Water Elemental is still treated as temporary pet with Glyph of Eternal Water + // i.e. does not unsummon at mounting, gets dismissed at teleport etc. case CLASS_WARLOCK: return GetCreatureInfo()->type == CREATURE_TYPE_DEMON; case CLASS_DEATH_KNIGHT: @@ -2025,24 +2025,24 @@ bool Pet::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* ci bool Pet::HasSpell(uint32 spell) const { PetSpellMap::const_iterator itr = m_spells.find(spell); - return (itr != m_spells.end() && itr->second.state != PETSPELL_REMOVED ); + return (itr != m_spells.end() && itr->second.state != PETSPELL_REMOVED); } // Get all passive spells in our skill line void Pet::LearnPetPassives() { CreatureInfo const* cInfo = GetCreatureInfo(); - if(!cInfo) + if (!cInfo) return; CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->family); - if(!cFamily) + if (!cFamily) return; PetFamilySpellsStore::const_iterator petStore = sPetFamilySpellsStore.find(cFamily->ID); - if(petStore != sPetFamilySpellsStore.end()) + if (petStore != sPetFamilySpellsStore.end()) { - for(PetFamilySpellsSet::const_iterator petSet = petStore->second.begin(); petSet != petStore->second.end(); ++petSet) + for (PetFamilySpellsSet::const_iterator petSet = petStore->second.begin(); petSet != petStore->second.end(); ++petSet) addSpell(*petSet, ACT_DECIDE, PETSPELL_NEW, PETSPELL_FAMILY); } } @@ -2050,15 +2050,15 @@ void Pet::LearnPetPassives() void Pet::CastPetAuras(bool current) { Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId()!=TYPEID_PLAYER) + if (!owner || owner->GetTypeId()!=TYPEID_PLAYER) return; - for(PetAuraSet::const_iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end();) + for (PetAuraSet::const_iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end();) { PetAura const* pa = *itr; ++itr; - if(!current && pa->IsRemovedOnChangePet()) + if (!current && pa->IsRemovedOnChangePet()) owner->RemovePetAura(pa); else CastPetAura(pa); @@ -2068,10 +2068,10 @@ void Pet::CastPetAuras(bool current) void Pet::CastPetAura(PetAura const* aura) { uint32 auraId = aura->GetAura(GetEntry()); - if(!auraId) + if (!auraId) return; - if(auraId == 35696) // Demonic Knowledge + if (auraId == 35696) // Demonic Knowledge { int32 basePoints = int32(aura->GetDamage() * (GetStat(STAT_STAMINA) + GetStat(STAT_INTELLECT)) / 100); CastCustomSpell(this, auraId, &basePoints, NULL, NULL, true); @@ -2083,7 +2083,7 @@ void Pet::CastPetAura(PetAura const* aura) struct DoPetLearnSpell { DoPetLearnSpell(Pet& _pet) : pet(_pet) {} - void operator() (uint32 spell_id) { pet.learnSpell(spell_id); } + void operator()(uint32 spell_id) { pet.learnSpell(spell_id); } Pet& pet; }; @@ -2101,13 +2101,13 @@ void Pet::SynchronizeLevelWithOwner() if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; - switch(getPetType()) + switch (getPetType()) { - // always same level + // always same level case SUMMON_PET: GivePetLevel(owner->getLevel()); break; - // can't be greater owner level + // can't be greater owner level case HUNTER_PET: if (getLevel() > owner->getLevel()) GivePetLevel(owner->getLevel()); @@ -2127,7 +2127,7 @@ void Pet::ApplyModeFlags(PetModeFlags mode, bool apply) m_petModeFlags = PetModeFlags(m_petModeFlags & ~mode); Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId()!=TYPEID_PLAYER) + if (!owner || owner->GetTypeId()!=TYPEID_PLAYER) return; WorldPacket data(SMSG_PET_MODE, 12); diff --git a/src/game/Pet.h b/src/game/Pet.h index bd53105a9..923a8685e 100644 --- a/src/game/Pet.h +++ b/src/game/Pet.h @@ -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 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 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 Unsummon(PetSaveMode mode, Unit* owner = NULL); static void DeleteFromDB(uint32 guidlow, bool separate_transaction = true); @@ -256,7 +256,7 @@ class MANGOS_DLL_SPEC Pet : public Creature uint64 m_auraUpdateMask; bool m_loading; - DeclinedName *m_declinedname; + DeclinedName* m_declinedname; private: PetModeFlags m_petModeFlags; diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index a09ee2466..140290ac7 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -28,21 +28,21 @@ #include "World.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_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(); UpdateAllies(); } -void PetAI::MoveInLineOfSight(Unit *u) +void PetAI::MoveInLineOfSight(Unit* u) { if (m_creature->getVictim()) return; @@ -53,13 +53,13 @@ void PetAI::MoveInLineOfSight(Unit *u) if (!m_creature->GetCharmInfo() || !m_creature->GetCharmInfo()->HasReactState(REACT_AGGRESSIVE)) return; - if (u->isTargetableForAttack() && m_creature->IsHostileTo( u ) && - u->isInAccessablePlaceFor(m_creature)) + if (u->isTargetableForAttack() && m_creature->IsHostileTo(u) && + u->isInAccessablePlaceFor(m_creature)) { 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); 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; - if(m_creature->Attack(u,true)) + if (m_creature->Attack(u,true)) { // TMGs call CreatureRelocation which via MoveInLineOfSight can call this function // 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); } @@ -96,7 +96,7 @@ bool PetAI::IsVisible(Unit *pl) const bool PetAI::_needToStop() const { // 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 !m_creature->getVictim()->isTargetableForAttack(); @@ -108,7 +108,7 @@ void PetAI::_stopAttack() 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); } @@ -178,9 +178,9 @@ void PetAI::UpdateAI(const uint32 diff) { 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); } @@ -199,7 +199,7 @@ void PetAI::UpdateAI(const uint32 diff) if (!spellID) continue; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellID); if (!spellInfo) continue; @@ -236,7 +236,7 @@ void PetAI::UpdateAI(const uint32 diff) 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())) { @@ -277,7 +277,7 @@ void PetAI::UpdateAI(const uint32 diff) targetSpellStore.erase(targetSpellStore.begin() + index); SpellCastTargets targets; - targets.setUnitTarget( target ); + targets.setUnitTarget(target); if (!m_creature->HasInArc(M_PI_F, target)) { @@ -286,7 +286,7 @@ void PetAI::UpdateAI(const uint32 diff) m_creature->SendCreateUpdateToPlayer((Player*)target); if (owner && owner->GetTypeId() == TYPEID_PLAYER) - m_creature->SendCreateUpdateToPlayer( (Player*)owner ); + m_creature->SendCreateUpdateToPlayer((Player*)owner); } m_creature->AddCreatureSpellCooldown(spell->m_spellInfo->Id); @@ -295,21 +295,21 @@ void PetAI::UpdateAI(const uint32 diff) } // 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; } } -bool PetAI::_isVisible(Unit *u) const +bool PetAI::_isVisible(Unit* u) const { 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() { 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 @@ -329,7 +329,7 @@ void PetAI::UpdateAllies() m_AllySet.insert(m_creature->GetObjectGuid()); 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(); if (!target || !pGroup->SameSubGroup((Player*)owner, target)) @@ -345,10 +345,10 @@ void PetAI::UpdateAllies() 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 - if(!m_creature->getVictim() && m_creature->GetCharmInfo() && !m_creature->GetCharmInfo()->HasReactState(REACT_PASSIVE) && - (!m_creature->GetCharmInfo()->HasCommandState(COMMAND_STAY) || m_creature->CanReachWithMeleeAttack(attacker))) + if (!m_creature->getVictim() && m_creature->GetCharmInfo() && !m_creature->GetCharmInfo()->HasReactState(REACT_PASSIVE) && + (!m_creature->GetCharmInfo()->HasCommandState(COMMAND_STAY) || m_creature->CanReachWithMeleeAttack(attacker))) AttackStart(attacker); } diff --git a/src/game/PetAI.h b/src/game/PetAI.h index 7a8907adc..d91310596 100644 --- a/src/game/PetAI.h +++ b/src/game/PetAI.h @@ -30,19 +30,19 @@ class MANGOS_DLL_DECL PetAI : public CreatureAI { public: - explicit PetAI(Creature *c); + explicit PetAI(Creature* c); - void MoveInLineOfSight(Unit *); - void AttackStart(Unit *); + void MoveInLineOfSight(Unit*); + void AttackStart(Unit*); void EnterEvadeMode(); void AttackedBy(Unit*); - bool IsVisible(Unit *) const; + bool IsVisible(Unit*) const; void UpdateAI(const uint32); - static int Permissible(const Creature *); + static int Permissible(const Creature*); private: - bool _isVisible(Unit *) const; + bool _isVisible(Unit*) const; bool _needToStop(void) const; void _stopAttack(void); diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index 8bc306492..e40a7f9d7 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -207,7 +207,7 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data) { pet->SetInFront(unit_target); 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()) { @@ -416,7 +416,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recv_data) uint32 spell_id_0 = UNIT_ACTION_BUTTON_ACTION(data[0]); UnitActionBarEntry const* actionEntry_1 = charmInfo->GetActionBarEntry(position[1]); if (!actionEntry_1 || spell_id_0 != actionEntry_1->GetAction() || - act_state_0 != actionEntry_1->GetType()) + act_state_0 != actionEntry_1->GetType()) return; } @@ -426,7 +426,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recv_data) uint32 spell_id_1 = UNIT_ACTION_BUTTON_ACTION(data[1]); UnitActionBarEntry const* actionEntry_0 = charmInfo->GetActionBarEntry(position[0]); if (!actionEntry_0 || spell_id_1 != actionEntry_0->GetAction() || - act_state_1 != actionEntry_0->GetType()) + act_state_1 != actionEntry_0->GetType()) return; } } @@ -436,7 +436,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recv_data) uint32 spell_id = UNIT_ACTION_BUTTON_ACTION(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 (!((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; Pet* pet = _player->GetMap()->GetPet(petGuid); - // check it! + // check it! if (!pet || pet->getPetType() != HUNTER_PET || - !pet->HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) || - pet->GetOwnerGuid() != _player->GetObjectGuid() || !pet->GetCharmInfo()) + !pet->HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) || + pet->GetOwnerGuid() != _player->GetObjectGuid() || !pet->GetCharmInfo()) return; PetNameInvalidReason res = ObjectMgr::CheckPetName(name); @@ -527,7 +527,7 @@ void WorldSession::HandlePetRename(WorldPacket& recv_data) 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("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); @@ -620,7 +620,7 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket) } if (pet->isCharmed()) - // state can be used as boolean + // state can be used as boolean pet->GetCharmInfo()->ToggleCreatureAutocast(spellid, state); else ((Pet*)pet)->ToggleAutocast(spellid, state); diff --git a/src/game/PetitionsHandler.cpp b/src/game/PetitionsHandler.cpp index 1889178b0..29cba1231 100644 --- a/src/game/PetitionsHandler.cpp +++ b/src/game/PetitionsHandler.cpp @@ -47,7 +47,7 @@ #define ARENA_TEAM_CHARTER_5v5_COST 2000000 // 200 G #define CHARTER_DISPLAY_ID 16161 -void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) +void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recv_data) { DEBUG_LOG("Received opcode CMSG_PETITION_BUY"); 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()); // prevent cheating - Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guidNPC, UNIT_NPC_FLAG_PETITIONER); + Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guidNPC, UNIT_NPC_FLAG_PETITIONER); if (!pCreature) { 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 - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); uint32 charterid = 0; uint32 cost = 0; uint32 type = 0; - if(pCreature->isTabardDesigner()) + if (pCreature->isTabardDesigner()) { // if tabard designer, then trying to buy a guild charter. // do not let if already in guild. - if(_player->GetGuildId()) + if (_player->GetGuildId()) return; charterid = GUILD_CHARTER; @@ -110,13 +110,13 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) else { // 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)); 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: charterid = ARENA_TEAM_CHARTER_2v2; @@ -138,21 +138,21 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) 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); return; } } - if(type == 9) + if (type == 9) { if (sGuildMgr.GetGuildByName(name)) { SendGuildCommandResult(GUILD_CREATE_S, name, ERR_GUILD_NAME_EXISTS_S); return; } - if(sObjectMgr.IsReservedName(name) || !ObjectMgr::IsValidCharterName(name)) + if (sObjectMgr.IsReservedName(name) || !ObjectMgr::IsValidCharterName(name)) { SendGuildCommandResult(GUILD_CREATE_S, name, ERR_GUILD_NAME_INVALID); return; @@ -160,42 +160,43 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) } else { - if(sObjectMgr.GetArenaTeamByName(name)) + if (sObjectMgr.GetArenaTeamByName(name)) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S); 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); return; } } - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(charterid); - if(!pProto) + ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(charterid); + if (!pProto) { _player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, charterid, 0); return; } - if(_player->GetMoney() < cost) - { //player hasn't got enough money + if (_player->GetMoney() < cost) + { + //player hasn't got enough money _player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, charterid, 0); return; } ItemPosCountVec dest; - InventoryResult msg = _player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, charterid, pProto->BuyCount ); - if(msg != EQUIP_ERR_OK) + InventoryResult msg = _player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, charterid, pProto->BuyCount); + if (msg != EQUIP_ERR_OK) { _player->SendEquipError(msg, NULL, NULL, charterid); return; } _player->ModifyMoney(-(int32)cost); - Item *charter = _player->StoreNewItem(dest, charterid, true); - if(!charter) + Item* charter = _player->StoreNewItem(dest, charterid, true); + if (!charter) return; 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 // 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; @@ -214,9 +215,10 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); ssInvalidPetitionGUIDs << "'" << fields[0].GetUInt32() << "' , "; - } while (result->NextRow()); + } + while (result->NextRow()); 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_sign WHERE petitionguid IN ( %s )", ssInvalidPetitionGUIDs.str().c_str()); 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(); } -void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data) +void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recv_data) { - // ok + // ok DEBUG_LOG("Received opcode CMSG_PETITION_SHOW_SIGNATURES"); //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?) uint32 petitionguid_low = petitionguid.GetCounter(); - QueryResult *result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", petitionguid_low); - if(!result) + QueryResult* result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", petitionguid_low); + if (!result) { sLog.outError("any petition on server..."); return; } - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 type = fields[0].GetUInt32(); delete result; // if guild petition and has guild => error, return; - if(type == 9 && _player->GetGuildId()) + if (type == 9 && _player->GetGuildId()) return; result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", petitionguid_low); // result==NULL also correct in case no sign yet - if(result) + if (result) signs = (uint8)result->GetRowCount(); 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 << 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()); data << ObjectGuid(signerGuid); // Player GUID @@ -289,7 +291,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data) SendPacket(&data); } -void WorldSession::HandlePetitionQueryOpcode(WorldPacket & recv_data) +void WorldSession::HandlePetitionQueryOpcode(WorldPacket& recv_data) { DEBUG_LOG("Received opcode CMSG_PETITION_QUERY"); //recv_data.hexlike(); @@ -312,11 +314,11 @@ void WorldSession::SendPetitionQueryOpcode(ObjectGuid petitionguid) std::string name = "NO_NAME_FOR_GUID"; uint8 signs = 0; - QueryResult *result = CharacterDatabase.PQuery( - "SELECT ownerguid, name, " - " (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs, " - " type " - "FROM petition WHERE petitionguid = '%u'", petitionLowGuid, petitionLowGuid); + QueryResult* result = CharacterDatabase.PQuery( + "SELECT ownerguid, name, " + " (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs, " + " type " + "FROM petition WHERE petitionguid = '%u'", petitionLowGuid, petitionLowGuid); if (result) { @@ -359,7 +361,7 @@ void WorldSession::SendPetitionQueryOpcode(ObjectGuid petitionguid) data << uint32(0); // 11 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 << uint32(0); // 14 @@ -372,7 +374,7 @@ void WorldSession::SendPetitionQueryOpcode(ObjectGuid petitionguid) SendPacket(&data); } -void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data) +void WorldSession::HandlePetitionRenameOpcode(WorldPacket& recv_data) { DEBUG_LOG("Received opcode MSG_PETITION_RENAME"); // ok //recv_data.hexlike(); @@ -384,13 +386,13 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data) recv_data >> petitionGuid; // guid recv_data >> newname; // new name - Item *item = _player->GetItemByGuid(petitionGuid); - if(!item) + Item* item = _player->GetItemByGuid(petitionGuid); + if (!item) 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(); type = fields[0].GetUInt32(); @@ -402,14 +404,14 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data) return; } - if(type == 9) + if (type == 9) { if (sGuildMgr.GetGuildByName(newname)) { SendGuildCommandResult(GUILD_CREATE_S, newname, ERR_GUILD_NAME_EXISTS_S); return; } - if(sObjectMgr.IsReservedName(newname) || !ObjectMgr::IsValidCharterName(newname)) + if (sObjectMgr.IsReservedName(newname) || !ObjectMgr::IsValidCharterName(newname)) { SendGuildCommandResult(GUILD_CREATE_S, newname, ERR_GUILD_NAME_INVALID); return; @@ -417,12 +419,12 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data) } else { - if(sObjectMgr.GetArenaTeamByName(newname)) + if (sObjectMgr.GetArenaTeamByName(newname)) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, newname, "", ERR_ARENA_TEAM_NAME_EXISTS_S); 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); return; @@ -432,7 +434,7 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data) std::string db_newname = newname; CharacterDatabase.escape_string(db_newname); 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()); @@ -442,12 +444,12 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data) SendPacket(&data); } -void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) +void WorldSession::HandlePetitionSignOpcode(WorldPacket& recv_data) { DEBUG_LOG("Received opcode CMSG_PETITION_SIGN"); // ok //recv_data.hexlike(); - Field *fields; + Field* fields; ObjectGuid petitionGuid; uint8 unk; recv_data >> petitionGuid; // petition guid @@ -455,13 +457,13 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) uint32 petitionLowGuid = petitionGuid.GetCounter(); - QueryResult *result = CharacterDatabase.PQuery( - "SELECT ownerguid, " - " (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs, " - " type " - "FROM petition WHERE petitionguid = '%u'", petitionLowGuid, petitionLowGuid); + QueryResult* result = CharacterDatabase.PQuery( + "SELECT ownerguid, " + " (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs, " + " type " + "FROM petition WHERE petitionguid = '%u'", petitionLowGuid, petitionLowGuid); - if(!result) + if (!result) { sLog.outError("any petition on server..."); return; @@ -480,18 +482,18 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) // not let enemies sign guild charter 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); else SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_NOT_ALLIED); 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); return; @@ -501,16 +503,16 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) return; uint8 slot = ArenaTeam::GetSlotByType(ArenaType(type)); - if(slot >= MAX_ARENA_SLOT) + if (slot >= MAX_ARENA_SLOT) return; - if(_player->GetArenaTeamId(slot)) + if (_player->GetArenaTeamId(slot)) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_IN_ARENA_TEAM_S); return; } - if(_player->GetArenaTeamIdInvited()) + if (_player->GetArenaTeamIdInvited()) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); return; @@ -518,26 +520,26 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) } else { - if(_player->GetGuildId()) + if (_player->GetGuildId()) { SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ERR_ALREADY_IN_GUILD_S); return; } - if(_player->GetGuildIdInvited()) + if (_player->GetGuildIdInvited()) { SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ERR_ALREADY_INVITED_TO_GUILD_S); return; } } - if(++signs > type) // client signs maximum + if (++signs > type) // client signs maximum return; //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 result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE player_account = '%u' AND petitionguid = '%u'", GetAccountId(), petitionLowGuid); - if(result) + if (result) { delete result; WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4)); @@ -549,13 +551,13 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) SendPacket(&data); // update for owner if online - if(Player *owner = sObjectMgr.GetPlayer(ownerGuid)) + if (Player* owner = sObjectMgr.GetPlayer(ownerGuid)) owner->GetSession()->SendPacket(&data); return; } 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()); @@ -573,11 +575,11 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) // item->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1+1, signs); // update for owner if online - if(Player *owner = sObjectMgr.GetPlayer(ownerGuid)) + if (Player* owner = sObjectMgr.GetPlayer(ownerGuid)) owner->GetSession()->SendPacket(&data); } -void WorldSession::HandlePetitionDeclineOpcode(WorldPacket & recv_data) +void WorldSession::HandlePetitionDeclineOpcode(WorldPacket& recv_data) { DEBUG_LOG("Received opcode MSG_PETITION_DECLINE"); // ok //recv_data.hexlike(); @@ -589,16 +591,16 @@ void WorldSession::HandlePetitionDeclineOpcode(WorldPacket & recv_data) 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) return; - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); ObjectGuid ownerguid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()); delete result; - Player *owner = sObjectMgr.GetPlayer(ownerguid); - if(owner) // petition owner online + Player* owner = sObjectMgr.GetPlayer(ownerguid); + if (owner) // petition owner online { WorldPacket data(MSG_PETITION_DECLINE, 8); 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 //recv_data.hexlike(); @@ -618,33 +620,33 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) recv_data >> petitionGuid; // petition guid recv_data >> playerGuid; // player guid - Player *player = ObjectAccessor::FindPlayer(playerGuid); + Player* player = ObjectAccessor::FindPlayer(playerGuid); if (!player) return; /// 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) return; - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 type = fields[0].GetUInt32(); delete result; 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); else SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_NOT_ALLIED); 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 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; uint8 slot = ArenaTeam::GetSlotByType(ArenaType(type)); - if(slot >= MAX_ARENA_SLOT) + if (slot >= MAX_ARENA_SLOT) return; - if(player->GetArenaTeamId(slot)) + if (player->GetArenaTeamId(slot)) { // player is already in an arena team SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", player->GetName(), ERR_ALREADY_IN_ARENA_TEAM_S); return; } - if(player->GetArenaTeamIdInvited()) + if (player->GetArenaTeamIdInvited()) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); return; @@ -673,13 +675,13 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) } else { - if(player->GetGuildId()) + if (player->GetGuildId()) { SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ERR_ALREADY_IN_GUILD_S); return; } - if(player->GetGuildIdInvited()) + if (player->GetGuildIdInvited()) { SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ERR_ALREADY_INVITED_TO_GUILD_S); return; @@ -690,7 +692,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) uint8 signs = 0; result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", petitionGuid.GetCounter()); // result==NULL also correct charter without signs - if(result) + if (result) signs = (uint8)result->GetRowCount(); /// 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 << 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()); data << ObjectGuid(signerGuid); // Player GUID @@ -715,7 +717,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_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 //recv_data.hexlike(); @@ -732,10 +734,10 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) std::string name; // 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) { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); ownerGuid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()); name = fields[1].GetCppString(); type = fields[2].GetUInt32(); @@ -747,9 +749,9 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) return; } - if(type == 9) + if (type == 9) { - if(_player->GetGuildId()) + if (_player->GetGuildId()) { WorldPacket data(SMSG_TURN_IN_PETITION_RESULTS, 4); data << uint32(PETITION_TURN_ALREADY_IN_GUILD); // already in guild @@ -793,7 +795,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) return; } - if(type == 9) + if (type == 9) { if (sGuildMgr.GetGuildByName(name)) { @@ -804,7 +806,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) } else { - if(sObjectMgr.GetArenaTeamByName(name)) + if (sObjectMgr.GetArenaTeamByName(name)) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S); delete result; @@ -813,7 +815,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) } // and at last charter item check - Item *item = _player->GetItemByGuid(petitionGuid); + Item* item = _player->GetItemByGuid(petitionGuid); if (!item) { delete result; @@ -825,10 +827,10 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) // delete charter item _player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true); - if(type == 9) // create guild + if (type == 9) // create guild { Guild* guild = new Guild; - if(!guild->Create(_player, name)) + if (!guild->Create(_player, name)) { delete guild; delete result; @@ -839,7 +841,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) sGuildMgr.AddGuild(guild); // add members - for(uint8 i = 0; i < signs; ++i) + for (uint8 i = 0; i < signs; ++i) { Field* fields = result->Fetch(); @@ -872,7 +874,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) DEBUG_LOG("PetitonsHandler: arena team added to objmrg"); // add members - for(uint8 i = 0; i < signs; ++i) + for (uint8 i = 0; i < signs; ++i) { Field* fields = result->Fetch(); ObjectGuid memberGUID = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()); @@ -900,7 +902,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) SendPacket(&data); } -void WorldSession::HandlePetitionShowListOpcode(WorldPacket & recv_data) +void WorldSession::HandlePetitionShowListOpcode(WorldPacket& recv_data) { DEBUG_LOG("Received CMSG_PETITION_SHOWLIST"); //recv_data.hexlike(); @@ -913,7 +915,7 @@ void WorldSession::HandlePetitionShowListOpcode(WorldPacket & recv_data) 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) { 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 - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); uint8 count = 0; - if(pCreature->isTabardDesigner()) + if (pCreature->isTabardDesigner()) count = 1; else count = 3; @@ -933,7 +935,7 @@ void WorldSession::SendPetitionShowList(ObjectGuid guid) WorldPacket data(SMSG_PETITION_SHOWLIST, 8+1+4*6); data << ObjectGuid(guid); // npc guid data << uint8(count); // count - if(count == 1) + if (count == 1) { data << uint32(1); // index data << uint32(GUILD_CHARTER); // charter entry diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 5c24fedbf..05e6a2c55 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -142,24 +142,24 @@ PlayerTaxi::PlayerTaxi() void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint32 level) { // class specific initial known nodes - switch(chrClass) + switch (chrClass) { case CLASS_DEATH_KNIGHT: { - for(int i = 0; i < TaxiMaskSize; ++i) + for (int i = 0; i < TaxiMaskSize; ++i) m_taximask[i] |= sOldContinentsNodesMask[i]; break; } } // race specific initial known nodes: capital and taxi hub masks - switch(race) + switch (race) { case RACE_HUMAN: SetTaximaskNode(2); break; // Human case RACE_ORC: SetTaximaskNode(23); break; // Orc case RACE_DWARF: SetTaximaskNode(6); break; // Dwarf case RACE_NIGHTELF: SetTaximaskNode(26); - SetTaximaskNode(27); break; // Night Elf + SetTaximaskNode(27); break; // Night Elf case RACE_UNDEAD: SetTaximaskNode(11); break; // Undead case RACE_TAUREN: SetTaximaskNode(22); break; // Tauren case RACE_GNOME: SetTaximaskNode(6); break; // Gnome @@ -169,13 +169,13 @@ void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint32 leve } // new continent starting masks (It will be accessible only at new map) - switch(Player::TeamForRace(race)) + switch (Player::TeamForRace(race)) { case ALLIANCE: SetTaximaskNode(100); break; case HORDE: SetTaximaskNode(99); break; } // level dependent taxi hubs - if(level>=68) + if (level>=68) SetTaximaskNode(213); //Shattered Sun Staging Area } @@ -186,16 +186,16 @@ void PlayerTaxi::LoadTaxiMask(const char* data) int index; Tokens::iterator iter; for (iter = tokens.begin(), index = 0; - (index < TaxiMaskSize) && (iter != tokens.end()); ++iter, ++index) + (index < TaxiMaskSize) && (iter != tokens.end()); ++iter, ++index) { // load and set bits only for existing taxi nodes m_taximask[index] = sTaxiNodesMask[index] & uint32(atol((*iter).c_str())); } } -void PlayerTaxi::AppendTaximaskTo( ByteBuffer& data, bool all ) +void PlayerTaxi::AppendTaximaskTo(ByteBuffer& data, bool all) { - if(all) + if (all) { for (uint8 i=0; ic_str())); AddTaxiDestination(node); } - if(m_TaxiDestinations.empty()) + if (m_TaxiDestinations.empty()) return true; // Check integrity - if(m_TaxiDestinations.size() < 2) + if (m_TaxiDestinations.size() < 2) return false; - for(size_t i = 1; i < m_TaxiDestinations.size(); ++i) + for (size_t i = 1; i < m_TaxiDestinations.size(); ++i) { uint32 cost; uint32 path; @@ -244,12 +244,12 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, Team std::string PlayerTaxi::SaveTaxiDestinationsToString() { - if(m_TaxiDestinations.empty()) + if (m_TaxiDestinations.empty()) return ""; std::ostringstream ss; - for(size_t i=0; i < m_TaxiDestinations.size(); ++i) + for (size_t i=0; i < m_TaxiDestinations.size(); ++i) ss << m_TaxiDestinations[i] << " "; return ss.str(); @@ -257,7 +257,7 @@ std::string PlayerTaxi::SaveTaxiDestinationsToString() uint32 PlayerTaxi::GetCurrentTaxiPath() const { - if(m_TaxiDestinations.size() < 2) + if (m_TaxiDestinations.size() < 2) return 0; uint32 path; @@ -270,7 +270,7 @@ uint32 PlayerTaxi::GetCurrentTaxiPath() const std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi) { - for(int i = 0; i < TaxiMaskSize; ++i) + for (int i = 0; i < TaxiMaskSize; ++i) ss << taxi.m_taximask[i] << " "; return ss; } @@ -281,14 +281,14 @@ TradeData* TradeData::GetTraderData() const return m_trader->GetTradeData(); } -Item* TradeData::GetItem( TradeSlots slot ) const +Item* TradeData::GetItem(TradeSlots slot) const { return m_items[slot] ? m_player->GetItemByGuid(m_items[slot]) : NULL; } -bool TradeData::HasItem( ObjectGuid item_guid ) const +bool TradeData::HasItem(ObjectGuid item_guid) const { - for(int i = 0; i < TRADE_SLOT_COUNT; ++i) + for (int i = 0; i < TRADE_SLOT_COUNT; ++i) if (m_items[i] == item_guid) return true; return false; @@ -300,7 +300,7 @@ Item* TradeData::GetSpellCastItem() const return m_spellCastItem ? m_player->GetItemByGuid(m_spellCastItem) : NULL; } -void TradeData::SetItem( TradeSlots slot, Item* item ) +void TradeData::SetItem(TradeSlots slot, Item* item) { ObjectGuid itemGuid = item ? item->GetObjectGuid() : ObjectGuid(); @@ -322,7 +322,7 @@ void TradeData::SetItem( TradeSlots slot, Item* item ) SetSpell(0); } -void TradeData::SetSpell( uint32 spell_id, Item* castItem /*= NULL*/ ) +void TradeData::SetSpell(uint32 spell_id, Item* castItem /*= NULL*/) { ObjectGuid itemGuid = castItem ? castItem->GetObjectGuid() : ObjectGuid(); @@ -339,7 +339,7 @@ void TradeData::SetSpell( uint32 spell_id, Item* castItem /*= NULL*/ ) Update(false); // send spell info to caster self } -void TradeData::SetMoney( uint32 money ) +void TradeData::SetMoney(uint32 money) { if (m_money == money) return; @@ -352,7 +352,7 @@ void TradeData::SetMoney( uint32 money ) Update(); } -void TradeData::Update( bool for_trader /*= true*/ ) +void TradeData::Update(bool for_trader /*= true*/) { if (for_trader) m_trader->GetSession()->SendUpdateTrade(true); // player state for trader @@ -377,7 +377,7 @@ void TradeData::SetAccepted(bool state, bool crosssend /*= false*/) UpdateMask Player::updateVisualBits; -Player::Player (WorldSession *session): Unit(), m_mover(this), m_camera(this), m_achievementMgr(this), m_reputationMgr(this) +Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_achievementMgr(this), m_reputationMgr(this) { m_transport = 0; @@ -394,11 +394,11 @@ Player::Player (WorldSession *session): Unit(), m_mover(this), m_camera(this), m m_session = session; m_ExtraFlags = 0; - if(GetSession()->GetSecurity() >= SEC_GAMEMASTER) + if (GetSession()->GetSecurity() >= SEC_GAMEMASTER) SetAcceptTicket(true); // players always accept - if(GetSession()->GetSecurity() == SEC_PLAYER) + if (GetSession()->GetSecurity() == SEC_PLAYER) SetAcceptWhispers(true); m_comboPoints = 0; @@ -451,7 +451,7 @@ Player::Player (WorldSession *session): Unit(), m_mover(this), m_camera(this), m m_cinematic = 0; - PlayerTalkClass = new PlayerMenu( GetSession() ); + PlayerTalkClass = new PlayerMenu(GetSession()); m_currentBuybackSlot = BUYBACK_SLOT_START; m_DailyQuestChanged = false; @@ -560,7 +560,7 @@ Player::Player (WorldSession *session): Unit(), m_mover(this), m_camera(this), m m_cachedGS = 0; } -Player::~Player () +Player::~Player() { CleanupsBeforeDelete(); @@ -568,15 +568,15 @@ Player::~Player () //m_social = NULL; // Note: buy back item already deleted from DB when player was saved - for(int i = 0; i < PLAYER_SLOTS_COUNT; ++i) + for (int i = 0; i < PLAYER_SLOTS_COUNT; ++i) { - if(m_items[i]) + if (m_items[i]) delete m_items[i]; } CleanupChannels(); //all mailed items should be deleted, also all mail should be deallocated - for (PlayerMails::const_iterator itr = m_mail.begin(); itr != m_mail.end();++itr) + for (PlayerMails::const_iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) delete *itr; for (ItemMap::const_iterator iter = mMitems.begin(); iter != mMitems.end(); ++iter) @@ -589,13 +589,13 @@ Player::~Player () m_transport->RemovePassenger(this); } - for(size_t x = 0; x < ItemSetEff.size(); x++) - if(ItemSetEff[x]) + for (size_t x = 0; x < ItemSetEff.size(); x++) + if (ItemSetEff[x]) delete ItemSetEff[x]; // clean up player-instance binds, may unload some instance saves - for(uint8 i = 0; i < MAX_DIFFICULTY; ++i) - for(BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) + for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) + for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) itr->second.state->RemovePlayer(this); delete m_declinedname; @@ -604,7 +604,7 @@ Player::~Player () void Player::CleanupsBeforeDelete() { - if(m_uint32Values) // only for fully created Object + if (m_uint32Values) // only for fully created Object { TradeCancel(false); DuelComplete(DUEL_INTERUPTED); @@ -612,7 +612,7 @@ void Player::CleanupsBeforeDelete() Unit::CleanupsBeforeDelete(); } -bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 /*outfitId */) +bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 /*outfitId */) { //FIXME: outfitId not used in player creating @@ -621,14 +621,14 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 m_name = name; PlayerInfo const* info = sObjectMgr.GetPlayerInfo(race, class_); - if(!info) + if (!info) { sLog.outError("Player have incorrect race/class pair. Can't be loaded."); return false; } ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(class_); - if(!cEntry) + if (!cEntry) { sLog.outError("Class %u not found in DBC (Wrong DBC files?)",class_); return false; @@ -660,8 +660,8 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 InitDisplayIds(); // model, scale and model data - SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP ); - SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE ); + SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER); SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); // fix cast time showed in spell tooltip on client SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); // default for players in 3.0.3 @@ -679,28 +679,28 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 SetUInt16Value(PLAYER_BYTES_3, 0, gender); // only GENDER_MALE/GENDER_FEMALE (1 bit) allowed, drunk state = 0 SetByteValue(PLAYER_BYTES_3, 3, 0); // BattlefieldArenaFaction (0 or 1) - SetUInt32Value( PLAYER_GUILDID, 0 ); - SetUInt32Value( PLAYER_GUILDRANK, 0 ); - SetUInt32Value( PLAYER_GUILD_TIMESTAMP, 0 ); + SetUInt32Value(PLAYER_GUILDID, 0); + SetUInt32Value(PLAYER_GUILDRANK, 0); + SetUInt32Value(PLAYER_GUILD_TIMESTAMP, 0); - for(int i = 0; i < KNOWN_TITLES_SIZE; ++i) + for (int i = 0; i < KNOWN_TITLES_SIZE; ++i) SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES + i, 0); // 0=disabled - SetUInt32Value( PLAYER_CHOSEN_TITLE, 0 ); + SetUInt32Value(PLAYER_CHOSEN_TITLE, 0); - SetUInt32Value( PLAYER_FIELD_KILLS, 0 ); - SetUInt32Value( PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 0 ); - SetUInt32Value( PLAYER_FIELD_TODAY_CONTRIBUTION, 0 ); - SetUInt32Value( PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0 ); + SetUInt32Value(PLAYER_FIELD_KILLS, 0); + SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 0); + SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, 0); + SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0); // set starting level uint32 start_level = getClass() != CLASS_DEATH_KNIGHT - ? sWorld.getConfig(CONFIG_UINT32_START_PLAYER_LEVEL) - : sWorld.getConfig(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL); + ? sWorld.getConfig(CONFIG_UINT32_START_PLAYER_LEVEL) + : sWorld.getConfig(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL); if (GetSession()->GetSecurity() >= SEC_MODERATOR) { uint32 gm_level = sWorld.getConfig(CONFIG_UINT32_START_GM_LEVEL); - if(gm_level > start_level) + if (gm_level > start_level) start_level = gm_level; } @@ -708,7 +708,7 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 InitRunes(); - SetUInt32Value (PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_UINT32_START_PLAYER_MONEY)); + SetUInt32Value(PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_UINT32_START_PLAYER_MONEY)); SetHonorPoints(sWorld.getConfig(CONFIG_UINT32_START_HONOR_POINTS)); SetArenaPoints(sWorld.getConfig(CONFIG_UINT32_START_ARENA_POINTS)); @@ -734,7 +734,7 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); } - if(getPowerType() != POWER_MANA) // hide additional mana bar if we have no mana + if (getPowerType() != POWER_MANA) // hide additional mana bar if we have no mana { SetPower(POWER_MANA, 0); SetMaxPower(POWER_MANA, 0); @@ -753,9 +753,9 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 CharStartOutfitEntry const* oEntry = NULL; for (uint32 i = 1; i < sCharStartOutfitStore.GetNumRows(); ++i) { - if(CharStartOutfitEntry const* entry = sCharStartOutfitStore.LookupEntry(i)) + if (CharStartOutfitEntry const* entry = sCharStartOutfitStore.LookupEntry(i)) { - if(entry->RaceClassGender == raceClassGender) + if (entry->RaceClassGender == raceClassGender) { oEntry = entry; break; @@ -763,27 +763,27 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 } } - if(oEntry) + if (oEntry) { - for(int j = 0; j < MAX_OUTFIT_ITEMS; ++j) + for (int j = 0; j < MAX_OUTFIT_ITEMS; ++j) { - if(oEntry->ItemId[j] <= 0) + if (oEntry->ItemId[j] <= 0) continue; uint32 item_id = oEntry->ItemId[j]; // just skip, reported in ObjectMgr::LoadItemPrototypes ItemPrototype const* iProto = ObjectMgr::GetItemPrototype(item_id); - if(!iProto) + if (!iProto) continue; // BuyCount by default int32 count = iProto->BuyCount; // special amount for foor/drink - if(iProto->Class==ITEM_CLASS_CONSUMABLE && iProto->SubClass==ITEM_SUBCLASS_FOOD) + if (iProto->Class==ITEM_CLASS_CONSUMABLE && iProto->SubClass==ITEM_SUBCLASS_FOOD) { - switch(iProto->Spells[0].SpellCategory) + switch (iProto->Spells[0].SpellCategory) { case 11: // food count = getClass()==CLASS_DEATH_KNIGHT ? 10 : 4; @@ -792,7 +792,7 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 count = 2; break; } - if(iProto->Stackable < count) + if (iProto->Stackable < count) count = iProto->Stackable; } @@ -826,7 +826,7 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 if (msg == EQUIP_ERR_OK) { RemoveItem(INVENTORY_SLOT_BAG_0, i,true); - pItem = StoreItem( sDest, pItem, true); + pItem = StoreItem(sDest, pItem, true); } // if this is ammo then use it @@ -846,28 +846,28 @@ bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount) DEBUG_LOG("STORAGE: Creating initial item, itemId = %u, count = %u",titem_id, titem_amount); // attempt equip by one - while(titem_amount > 0) + while (titem_amount > 0) { uint16 eDest; - uint8 msg = CanEquipNewItem( NULL_SLOT, eDest, titem_id, false ); - if( msg != EQUIP_ERR_OK ) + uint8 msg = CanEquipNewItem(NULL_SLOT, eDest, titem_id, false); + if (msg != EQUIP_ERR_OK) break; - EquipNewItem( eDest, titem_id, true); + EquipNewItem(eDest, titem_id, true); AutoUnequipOffhandIfNeed(); --titem_amount; } - if(titem_amount == 0) + if (titem_amount == 0) return true; // equipped // attempt store ItemPosCountVec sDest; // store in main bag to simplify second pass (special bags can be not equipped yet at this moment) - uint8 msg = CanStoreNewItem( INVENTORY_SLOT_BAG_0, NULL_SLOT, sDest, titem_id, titem_amount ); - if( msg == EQUIP_ERR_OK ) + uint8 msg = CanStoreNewItem(INVENTORY_SLOT_BAG_0, NULL_SLOT, sDest, titem_id, titem_amount); + if (msg == EQUIP_ERR_OK) { - StoreNewItem( sDest, titem_id, true, Item::GenerateItemRandomPropertyId(titem_id) ); + StoreNewItem(sDest, titem_id, true, Item::GenerateItemRandomPropertyId(titem_id)); return true; // stored } @@ -907,7 +907,7 @@ void Player::SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 Curre data << Regen; data << (uint8)0; data << (uint32)0; // spell id - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } void Player::StopMirrorTimer(MirrorTimerType Type) @@ -915,12 +915,12 @@ void Player::StopMirrorTimer(MirrorTimerType Type) m_MirrorTimer[Type] = DISABLED_MIRROR_TIMER; WorldPacket data(SMSG_STOP_MIRROR_TIMER, 4); data << (uint32)Type; - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) { - if(!isAlive() || isGameMaster()) + if (!isAlive() || isGameMaster()) return 0; // Absorb, resist some environmental damage type @@ -945,9 +945,9 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) uint32 final_damage = DealDamage(this, damage, NULL, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - if(!isAlive()) + if (!isAlive()) { - if(type==DAMAGE_FALL) // DealDamage not apply item durability loss at self damage + if (type==DAMAGE_FALL) // DealDamage not apply item durability loss at self damage { DEBUG_LOG("We are fall to death, loosing 10 percents durability"); DurabilityLossAll(0.10f,false); @@ -973,11 +973,11 @@ int32 Player::getMaxTimer(MirrorTimerType timer) case BREATH_TIMER: { if (!isAlive() || HasAuraType(SPELL_AURA_WATER_BREATHING) || - GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_BREATH_GMLEVEL)) + GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_BREATH_GMLEVEL)) return DISABLED_MIRROR_TIMER; int32 UnderWaterTime = sWorld.getConfig(CONFIG_UINT32_TIMERBAR_BREATH_MAX)*IN_MILLISECONDS; AuraList const& mModWaterBreathing = GetAurasByType(SPELL_AURA_MOD_WATER_BREATHING); - for(AuraList::const_iterator i = mModWaterBreathing.begin(); i != mModWaterBreathing.end(); ++i) + for (AuraList::const_iterator i = mModWaterBreathing.begin(); i != mModWaterBreathing.end(); ++i) UnderWaterTime = uint32(UnderWaterTime * (100.0f + (*i)->GetModifier()->m_amount) / 100.0f); return UnderWaterTime; } @@ -1127,11 +1127,11 @@ void Player::HandleSobering() DrunkenState Player::GetDrunkenstateByValue(uint16 value) { - if(value >= 23000) + if (value >= 23000) return DRUNKEN_SMASHED; - if(value >= 12800) + if (value >= 12800) return DRUNKEN_DRUNK; - if(value & 0xFFFE) + if (value & 0xFFFE) return DRUNKEN_TIPSY; return DRUNKEN_SOBER; } @@ -1146,12 +1146,12 @@ void Player::SetDrunkValue(uint16 newDrunkenValue, uint32 itemId) uint32 newDrunkenState = Player::GetDrunkenstateByValue(m_drunk); // special drunk invisibility detection - if(newDrunkenState >= DRUNKEN_DRUNK) + if (newDrunkenState >= DRUNKEN_DRUNK) m_detectInvisibilityMask |= (1<<6); else m_detectInvisibilityMask &= ~(1<<6); - if(newDrunkenState == oldDrunkenState) + if (newDrunkenState == oldDrunkenState) return; WorldPacket data(SMSG_CROSSED_INEBRIATION_THRESHOLD, (8+4+4)); @@ -1267,7 +1267,7 @@ void Player::Update(uint32 update_diff, uint32 p_time) if (m_weaponChangeTimer > 0) { - if(update_diff >= m_weaponChangeTimer) + if (update_diff >= m_weaponChangeTimer) m_weaponChangeTimer = 0; else m_weaponChangeTimer -= update_diff; @@ -1394,7 +1394,7 @@ void Player::SetDeathState(DeathState s) bool cur = isAlive(); - if(s == JUST_DIED && cur) + if (s == JUST_DIED && cur) { // drunken state is cleared on death SetDrunkValue(0); @@ -1413,7 +1413,7 @@ void Player::SetDeathState(DeathState s) ressSpellId = GetUInt32Value(PLAYER_SELF_RES_SPELL); // passive spell - if(!ressSpellId) + if (!ressSpellId) ressSpellId = GetResurrectionSpellId(); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP, 1); @@ -1427,21 +1427,21 @@ void Player::SetDeathState(DeathState s) Unit::SetDeathState(s); // restore resurrection spell id for player after aura remove - if(s == JUST_DIED && cur && ressSpellId) + if (s == JUST_DIED && cur && ressSpellId) SetUInt32Value(PLAYER_SELF_RES_SPELL, ressSpellId); - if(isAlive() && !cur) + if (isAlive() && !cur) { //clear aura case after resurrection by another way (spells will be applied before next death) SetUInt32Value(PLAYER_SELF_RES_SPELL, 0); // restore default warrior stance - if(getClass()== CLASS_WARRIOR) + if (getClass()== CLASS_WARRIOR) CastSpell(this,SPELL_ID_PASSIVE_BATTLE_STANCE,true); } } -bool Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) +bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data) { // 0 1 2 3 4 5 6 7 // "SELECT characters.guid, characters.name, characters.race, characters.class, characters.gender, characters.playerBytes, characters.playerBytes2, characters.level, " @@ -1450,14 +1450,14 @@ bool Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) // 15 16 17 18 19 20 // "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.equipmentCache, character_declinedname.genitive " - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 guid = fields[0].GetUInt32(); uint8 pRace = fields[2].GetUInt8(); uint8 pClass = fields[3].GetUInt8(); - PlayerInfo const *info = sObjectMgr.GetPlayerInfo(pRace, pClass); - if(!info) + PlayerInfo const* info = sObjectMgr.GetPlayerInfo(pRace, pClass); + if (!info) { sLog.outError("Player %u has incorrect race/class pair. Don't build enum.", guid); return false; @@ -1491,17 +1491,17 @@ bool Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) uint32 char_flags = 0; uint32 playerFlags = fields[14].GetUInt32(); uint32 atLoginFlags = fields[15].GetUInt32(); - if(playerFlags & PLAYER_FLAGS_HIDE_HELM) + if (playerFlags & PLAYER_FLAGS_HIDE_HELM) char_flags |= CHARACTER_FLAG_HIDE_HELM; - if(playerFlags & PLAYER_FLAGS_HIDE_CLOAK) + if (playerFlags & PLAYER_FLAGS_HIDE_CLOAK) char_flags |= CHARACTER_FLAG_HIDE_CLOAK; - if(playerFlags & PLAYER_FLAGS_GHOST) + if (playerFlags & PLAYER_FLAGS_GHOST) char_flags |= CHARACTER_FLAG_GHOST; - if(atLoginFlags & AT_LOGIN_RENAME) + if (atLoginFlags & AT_LOGIN_RENAME) char_flags |= CHARACTER_FLAG_RENAME; - if(sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED)) + if (sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED)) { - if(!fields[20].GetCppString().empty()) + if (!fields[20].GetCppString().empty()) char_flags |= CHARACTER_FLAG_DECLINED; } else @@ -1524,7 +1524,7 @@ bool Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) { uint32 entry = fields[16].GetUInt32(); CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(entry); - if(cInfo) + if (cInfo) { petDisplayId = fields[17].GetUInt32(); petLevel = fields[18].GetUInt32(); @@ -1543,8 +1543,8 @@ bool Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) { uint32 visualbase = slot * 2; uint32 item_id = GetUInt32ValueFromArray(data, visualbase); - const ItemPrototype * proto = ObjectMgr::GetItemPrototype(item_id); - if(!proto) + const ItemPrototype* proto = ObjectMgr::GetItemPrototype(item_id); + if (!proto) { *p_data << uint32(0); *p_data << uint8(0); @@ -1552,14 +1552,14 @@ bool Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) continue; } - SpellItemEnchantmentEntry const *enchant = NULL; + SpellItemEnchantmentEntry const* enchant = NULL; uint32 enchants = GetUInt32ValueFromArray(data, visualbase + 1); - for(uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot <= TEMP_ENCHANTMENT_SLOT; ++enchantSlot) + for (uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot <= TEMP_ENCHANTMENT_SLOT; ++enchantSlot) { // values stored in 2 uint16 uint32 enchantId = 0x0000FFFF & (enchants >> enchantSlot*16); - if(!enchantId) + if (!enchantId) continue; if ((enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId))) @@ -1621,7 +1621,7 @@ uint8 Player::GetChatTag() const bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options) { - if(!MapManager::IsValidMapCoord(mapid, x, y, z, orientation)) + if (!MapManager::IsValidMapCoord(mapid, x, y, z, orientation)) { sLog.outError("TeleportTo: invalid map %d or absent instance template.", mapid); return false; @@ -1634,15 +1634,15 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // don't let enter battlegrounds without assigned battleground id (for example through areatrigger)... // don't let gm level > 1 either - if(!InBattleGround() && mEntry->IsBattleGroundOrArena()) + if (!InBattleGround() && mEntry->IsBattleGroundOrArena()) return false; // client without expansion support - if(GetSession()->Expansion() < mEntry->Expansion()) + if (GetSession()->Expansion() < mEntry->Expansion()) { DEBUG_LOG("Player %s using client without required expansion tried teleport to non accessible map %u", GetName(), mapid); - if(GetTransport()) + if (GetTransport()) RepopAtGraveyard(); // teleport to near graveyard if on transport, looks blizz like :) SendTransferAborted(mapid, TRANSFER_ABORT_INSUF_EXPAN_LVL, mEntry->Expansion()); @@ -1695,7 +1695,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati if (!(options & TELE_TO_NOT_UNSUMMON_PET)) { //same map, only remove pet if out of range for new position - if(pet && !pet->IsWithinDist3d(x, y, z, GetMap()->GetVisibilityDistance())) + if (pet && !pet->IsWithinDist3d(x, y, z, GetMap()->GetVisibilityDistance())) UnsummonPetTemporaryIfAny(); } @@ -1710,7 +1710,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // at client packet MSG_MOVE_TELEPORT_ACK SetSemaphoreTeleportNear(true); // near teleport, triggering send MSG_MOVE_TELEPORT_ACK from client at landing - if(!GetSession()->PlayerLogout()) + if (!GetSession()->PlayerLogout()) { WorldPacket data; BuildTeleportAckMsg(data, x, y, z, orientation); @@ -1731,7 +1731,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // If the map is not created, assume it is possible to enter it. // It will be created in the WorldPortAck. DungeonPersistentState* state = GetBoundInstanceSaveForSelfOrGroup(mapid); - Map *map = sMapMgr.FindMap(mapid, state ? state->GetInstanceId() : 0); + Map* map = sMapMgr.FindMap(mapid, state ? state->GetInstanceId() : 0); if (!map || map->CanEnter(this)) { //lets reset near teleport flag if it wasn't reset during chained teleports @@ -1760,7 +1760,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // Note: at battleground join battleground id set before teleport // and we already will found "current" battleground // just need check that this is targeted map or leave - if(bg->GetMapId() != mapid) + if (bg->GetMapId() != mapid) LeaveBattleground(false); // don't teleport to entry point } @@ -1840,7 +1840,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati data << float(final_o); } - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); SendSavedInstances(); } } @@ -1859,35 +1859,35 @@ bool Player::TeleportToBGEntryPoint() void Player::ProcessDelayedOperations() { - if(m_DelayedOperations == 0) + if (m_DelayedOperations == 0) return; - if(m_DelayedOperations & DELAYED_RESURRECT_PLAYER) + if (m_DelayedOperations & DELAYED_RESURRECT_PLAYER) { ResurrectPlayer(0.0f, false); - if(GetMaxHealth() > m_resurrectHealth) - SetHealth( m_resurrectHealth ); + if (GetMaxHealth() > m_resurrectHealth) + SetHealth(m_resurrectHealth); else - SetHealth( GetMaxHealth() ); + SetHealth(GetMaxHealth()); - if(GetMaxPower(POWER_MANA) > m_resurrectMana) - SetPower(POWER_MANA, m_resurrectMana ); + if (GetMaxPower(POWER_MANA) > m_resurrectMana) + SetPower(POWER_MANA, m_resurrectMana); else - SetPower(POWER_MANA, GetMaxPower(POWER_MANA) ); + SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); - SetPower(POWER_RAGE, 0 ); - SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY) ); + SetPower(POWER_RAGE, 0); + SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); SpawnCorpseBones(); } - if(m_DelayedOperations & DELAYED_SAVE_PLAYER) + if (m_DelayedOperations & DELAYED_SAVE_PLAYER) { SaveToDB(); } - if(m_DelayedOperations & DELAYED_SPELL_CAST_DESERTER) + if (m_DelayedOperations & DELAYED_SPELL_CAST_DESERTER) { CastSpell(this, 26013, true); // Deserter } @@ -1924,18 +1924,18 @@ void Player::AddToWorld() ///- The player should only be added when logging in Unit::AddToWorld(); - for(int i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) + for (int i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) { - if(m_items[i]) + if (m_items[i]) m_items[i]->AddToWorld(); } } void Player::RemoveFromWorld() { - for(int i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) + for (int i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) { - if(m_items[i]) + if (m_items[i]) m_items[i]->RemoveFromWorld(); } @@ -1948,13 +1948,13 @@ void Player::RemoveFromWorld() Unit::RemoveFromWorld(); } -void Player::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker ) +void Player::RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacker) { float addRage; float rageconversion = float((0.0091107836 * getLevel()*getLevel())+3.225598133*getLevel())+4.2652911f; - if(attacker) + if (attacker) { addRage = ((damage/rageconversion*7.5f + weaponSpeedHitFactor)/2.0f); @@ -1979,13 +1979,13 @@ void Player::RegenerateAll(uint32 diff) { // Not in combat or they have regeneration if (!isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) || - HasAuraType(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT) || IsPolymorphed() ) + HasAuraType(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT) || IsPolymorphed()) { RegenerateHealth(diff); if (!isInCombat() && !HasAuraType(SPELL_AURA_INTERRUPT_REGEN)) { Regenerate(POWER_RAGE, diff); - if(getClass() == CLASS_DEATH_KNIGHT) + if (getClass() == CLASS_DEATH_KNIGHT) Regenerate(POWER_RUNIC_POWER, diff); } } @@ -2047,13 +2047,13 @@ void Player::Regenerate(Powers power, uint32 diff) if (getClass() != CLASS_DEATH_KNIGHT) break; - for(uint32 rune = 0; rune < MAX_RUNES; ++rune) + for (uint32 rune = 0; rune < MAX_RUNES; ++rune) { - if(uint16 cd = GetRuneCooldown(rune)) // if we have cooldown, reduce it... + if (uint16 cd = GetRuneCooldown(rune)) // if we have cooldown, reduce it... { uint32 cd_diff = diff; AuraList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT); - for(AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i) + for (AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i) if ((*i)->GetModifier()->m_miscvalue == int32(power) && (*i)->GetMiscBValue()==GetCurrentRune(rune)) cd_diff = cd_diff * ((*i)->GetModifier()->m_amount + 100) / 100; @@ -2069,10 +2069,10 @@ void Player::Regenerate(Powers power, uint32 diff) // Mana regen calculated in Player::UpdateManaRegen() // Exist only for POWER_MANA, POWER_ENERGY, POWER_FOCUS auras - if(power != POWER_MANA) + if (power != POWER_MANA) { AuraList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT); - for(AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i) + for (AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i) if ((*i)->GetModifier()->m_miscvalue == int32(power)) addvalue *= ((*i)->GetModifier()->m_amount + 100) / 100.0f; } @@ -2088,7 +2088,7 @@ void Player::Regenerate(Powers power, uint32 diff) } else { - if(curValue <= uint32(addvalue)) + if (curValue <= uint32(addvalue)) curValue = 0; else curValue -= uint32(addvalue); @@ -2108,29 +2108,29 @@ void Player::RegenerateHealth(uint32 diff) float addvalue = 0.0f; // polymorphed case - if ( IsPolymorphed() ) + if (IsPolymorphed()) addvalue = (float)GetMaxHealth()/3; // normal regen case (maybe partly in combat case) - else if (!isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) ) + else if (!isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT)) { addvalue = OCTRegenHPPerSpirit()* HealthIncreaseRate; if (!isInCombat()) { AuraList const& mModHealthRegenPct = GetAurasByType(SPELL_AURA_MOD_HEALTH_REGEN_PERCENT); - for(AuraList::const_iterator i = mModHealthRegenPct.begin(); i != mModHealthRegenPct.end(); ++i) + for (AuraList::const_iterator i = mModHealthRegenPct.begin(); i != mModHealthRegenPct.end(); ++i) addvalue *= (100.0f + (*i)->GetModifier()->m_amount) / 100.0f; } - else if(HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT)) + else if (HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT)) addvalue *= GetTotalAuraModifier(SPELL_AURA_MOD_REGEN_DURING_COMBAT) / 100.0f; - if(!IsStandState()) + if (!IsStandState()) addvalue *= 1.5; } // always regeneration bonus (including combat) addvalue += GetTotalAuraModifier(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT); - if(addvalue < 0) + if (addvalue < 0) addvalue = 0; addvalue *= (float)diff / REGEN_TIME_FULL; @@ -2149,12 +2149,12 @@ Creature* Player::GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask) return NULL; // exist (we need look pets also for some interaction (quest/etc) - Creature *unit = GetMap()->GetAnyTypeCreature(guid); + Creature* unit = GetMap()->GetAnyTypeCreature(guid); if (!unit) return NULL; // appropriate npc type - if (npcflagmask && !unit->HasFlag( UNIT_NPC_FLAGS, npcflagmask )) + if (npcflagmask && !unit->HasFlag(UNIT_NPC_FLAGS, npcflagmask)) return NULL; if (npcflagmask == UNIT_NPC_FLAG_STABLEMASTER) @@ -2195,15 +2195,15 @@ GameObject* Player::GetGameObjectIfCanInteractWith(ObjectGuid guid, uint32 gameo if (hasUnitState(UNIT_STAT_CAN_NOT_REACT_OR_LOST_CONTROL)) return NULL; - if (GameObject *go = GetMap()->GetGameObject(guid)) + if (GameObject* go = GetMap()->GetGameObject(guid)) { if (uint32(go->GetGoType()) == gameobject_type || gameobject_type == MAX_GAMEOBJECT_TYPE) { float maxdist; - switch(go->GetGoType()) + switch (go->GetGoType()) { - // TODO: find out how the client calculates the maximal usage distance to spellless working - // gameobjects like guildbanks and mailboxes - 10.0 is a just an abitrary choosen number + // TODO: find out how the client calculates the maximal usage distance to spellless working + // gameobjects like guildbanks and mailboxes - 10.0 is a just an abitrary choosen number case GAMEOBJECT_TYPE_GUILD_BANK: case GAMEOBJECT_TYPE_MAILBOX: maxdist = 10.0f; @@ -2220,7 +2220,7 @@ GameObject* Player::GetGameObjectIfCanInteractWith(ObjectGuid guid, uint32 gameo return go; sLog.outError("GetGameObjectIfCanInteractWith: GameObject '%s' [GUID: %u] is too far away from player %s [GUID: %u] to be used by him (distance=%f, maximal %f is allowed)", - go->GetGOInfo()->name, go->GetGUIDLow(), GetName(), GetGUIDLow(), go->GetDistance(this), maxdist); + go->GetGOInfo()->name, go->GetGUIDLow(), GetName(), GetGUIDLow(), go->GetDistance(this), maxdist); } } return NULL; @@ -2233,7 +2233,7 @@ bool Player::IsUnderWater() const void Player::SetInWater(bool apply) { - if(m_isInWater==apply) + if (m_isInWater==apply) return; //define player in water by opcodes @@ -2301,7 +2301,7 @@ void Player::SetGameMaster(bool on) CallForAllControlledUnits(SetGameMasterOffHelper(getFaction()), CONTROLLED_PET|CONTROLLED_TOTEMS|CONTROLLED_GUARDIANS|CONTROLLED_CHARM); // restore FFA PvP Server state - if(sWorld.IsFFAPvPRealm()) + if (sWorld.IsFFAPvPRealm()) SetFFAPvP(true); // restore FFA PvP area state, remove not allowed for GM mounts @@ -2317,14 +2317,14 @@ void Player::SetGameMaster(bool on) void Player::SetGMVisible(bool on) { - if(on) + if (on) { m_ExtraFlags &= ~PLAYER_EXTRA_GM_INVISIBLE; //remove flag // Reapply stealth/invisibility if active or show if not any - if(HasAuraType(SPELL_AURA_MOD_STEALTH)) + if (HasAuraType(SPELL_AURA_MOD_STEALTH)) SetVisibility(VISIBILITY_GROUP_STEALTH); - else if(HasAuraType(SPELL_AURA_MOD_INVISIBILITY)) + else if (HasAuraType(SPELL_AURA_MOD_INVISIBILITY)) SetVisibility(VISIBILITY_GROUP_INVISIBILITY); else SetVisibility(VISIBILITY_ON); @@ -2342,7 +2342,7 @@ void Player::SetGMVisible(bool on) bool Player::IsGroupVisibleFor(Player* p) const { - switch(sWorld.getConfig(CONFIG_UINT32_GROUP_VISIBILITY)) + switch (sWorld.getConfig(CONFIG_UINT32_GROUP_VISIBILITY)) { default: return IsInSameGroupWith(p); case 1: return IsInSameRaidWith(p); @@ -2353,7 +2353,7 @@ bool Player::IsGroupVisibleFor(Player* p) const bool Player::IsInSameGroupWith(Player const* p) const { return (p==this || (GetGroup() != NULL && - GetGroup()->SameSubGroup((Player*)this, (Player*)p))); + GetGroup()->SameSubGroup((Player*)this, (Player*)p))); } ///- If the player is invited, remove him. If the group if then only 1 person, disband the group. @@ -2361,14 +2361,14 @@ bool Player::IsInSameGroupWith(Player const* p) const void Player::UninviteFromGroup() { Group* group = GetGroupInvite(); - if(!group) + if (!group) return; group->RemoveInvite(this); - if(group->GetMembersCount() <= 1) // group has just 1 member => disband + if (group->GetMembersCount() <= 1) // group has just 1 member => disband { - if(group->IsCreated()) + if (group->IsCreated()) { group->Disband(true); sObjectMgr.RemoveGroup(group); @@ -2400,7 +2400,7 @@ void Player::SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 RestXP) data << (victim ? victim->GetObjectGuid() : ObjectGuid());// guid data << uint32(GivenXP+RestXP); // given experience data << uint8(victim ? 0 : 1); // 00-kill_xp type, 01-non_kill_xp type - if(victim) + if (victim) { data << uint32(GivenXP); // experience without rested bonus data << float(1); // 1 - none 0 - 100% group bonus output @@ -2411,30 +2411,30 @@ void Player::SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 RestXP) void Player::GiveXP(uint32 xp, Unit* victim) { - if ( xp < 1 ) + if (xp < 1) return; - if(!isAlive()) + if (!isAlive()) return; uint32 level = getLevel(); // XP to money conversion processed in Player::RewardQuest - if(level >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) + if (level >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) return; - if(victim) + if (victim) { // handle SPELL_AURA_MOD_KILL_XP_PCT auras Unit::AuraList const& ModXPPctAuras = GetAurasByType(SPELL_AURA_MOD_KILL_XP_PCT); - for(Unit::AuraList::const_iterator i = ModXPPctAuras.begin();i != ModXPPctAuras.end(); ++i) + for (Unit::AuraList::const_iterator i = ModXPPctAuras.begin(); i != ModXPPctAuras.end(); ++i) xp = uint32(xp*(1.0f + (*i)->GetModifier()->m_amount / 100.0f)); } else { // handle SPELL_AURA_MOD_QUEST_XP_PCT auras Unit::AuraList const& ModXPPctAuras = GetAurasByType(SPELL_AURA_MOD_QUEST_XP_PCT); - for(Unit::AuraList::const_iterator i = ModXPPctAuras.begin();i != ModXPPctAuras.end(); ++i) + for (Unit::AuraList::const_iterator i = ModXPPctAuras.begin(); i != ModXPPctAuras.end(); ++i) xp = uint32(xp*(1.0f + (*i)->GetModifier()->m_amount / 100.0f)); } @@ -2447,11 +2447,11 @@ void Player::GiveXP(uint32 xp, Unit* victim) uint32 nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP); uint32 newXP = curXP + xp + rested_bonus_xp; - while( newXP >= nextLvlXP && level < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL) ) + while (newXP >= nextLvlXP && level < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) { newXP -= nextLvlXP; - if ( level < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL) ) + if (level < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) GiveLevel(level + 1); level = getLevel(); @@ -2465,7 +2465,7 @@ void Player::GiveXP(uint32 xp, Unit* victim) // Current player experience not update (must be update by caller) void Player::GiveLevel(uint32 level) { - if ( level == getLevel() ) + if (level == getLevel()) return; PlayerLevelInfo info; @@ -2487,7 +2487,7 @@ void Player::GiveLevel(uint32 level) data << uint32(0); data << uint32(0); // end for - for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) // Stats loop (0-4) + for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) // Stats loop (0-4) data << uint32(int32(info.stats[i]) - GetCreateStat(Stats(i))); GetSession()->SendPacket(&data); @@ -2501,10 +2501,10 @@ void Player::GiveLevel(uint32 level) SetLevel(level); - UpdateSkillsForLevel (); + UpdateSkillsForLevel(); // save base values (bonuses already included in stored stats - for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) + for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetCreateStat(Stats(i), info.stats[i]); SetCreateHealth(classInfo.basehealth); @@ -2521,7 +2521,7 @@ void Player::GiveLevel(uint32 level) SetHealth(GetMaxHealth()); SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); - if(GetPower(POWER_RAGE) > GetMaxPower(POWER_RAGE)) + if (GetPower(POWER_RAGE) > GetMaxPower(POWER_RAGE)) SetPower(POWER_RAGE, GetMaxPower(POWER_RAGE)); SetPower(POWER_FOCUS, 0); SetPower(POWER_HAPPINESS, 0); @@ -2580,7 +2580,7 @@ void Player::InitTalentForLevel() void Player::InitStatsForLevel(bool reapplyMods) { - if(reapplyMods) //reapply stats values only on .reset stats (level) command + if (reapplyMods) //reapply stats values only on .reset stats (level) command _RemoveAllStatBonuses(); PlayerClassLevelInfo classInfo; @@ -2589,22 +2589,22 @@ void Player::InitStatsForLevel(bool reapplyMods) PlayerLevelInfo info; sObjectMgr.GetPlayerLevelInfo(getRace(),getClass(),getLevel(),&info); - SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL) ); + SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)); SetUInt32Value(PLAYER_NEXT_LEVEL_XP, sObjectMgr.GetXPForLevel(getLevel())); // reset before any aura state sources (health set/aura apply) SetUInt32Value(UNIT_FIELD_AURASTATE, 0); - UpdateSkillsForLevel (); + UpdateSkillsForLevel(); // set default cast time multiplier SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); // save base values (bonuses already included in stored stats - for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) + for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetCreateStat(Stats(i), info.stats[i]); - for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) + for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetStat(Stats(i), info.stats[i]); SetCreateHealth(classInfo.basehealth); @@ -2617,7 +2617,7 @@ void Player::InitStatsForLevel(bool reapplyMods) InitStatBuffMods(); //reset rating fields values - for(uint16 index = PLAYER_FIELD_COMBAT_RATING_1; index < PLAYER_FIELD_COMBAT_RATING_1 + MAX_COMBAT_RATING; ++index) + for (uint16 index = PLAYER_FIELD_COMBAT_RATING_1; index < PLAYER_FIELD_COMBAT_RATING_1 + MAX_COMBAT_RATING; ++index) SetUInt32Value(index, 0); SetUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS,0); @@ -2629,22 +2629,22 @@ void Player::InitStatsForLevel(bool reapplyMods) } //reset attack power, damage and attack speed fields - SetFloatValue(UNIT_FIELD_BASEATTACKTIME, 2000.0f ); - SetFloatValue(UNIT_FIELD_BASEATTACKTIME + 1, 2000.0f ); // offhand attack time - SetFloatValue(UNIT_FIELD_RANGEDATTACKTIME, 2000.0f ); + SetFloatValue(UNIT_FIELD_BASEATTACKTIME, 2000.0f); + SetFloatValue(UNIT_FIELD_BASEATTACKTIME + 1, 2000.0f); // offhand attack time + SetFloatValue(UNIT_FIELD_RANGEDATTACKTIME, 2000.0f); - SetFloatValue(UNIT_FIELD_MINDAMAGE, 0.0f ); - SetFloatValue(UNIT_FIELD_MAXDAMAGE, 0.0f ); - SetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, 0.0f ); - SetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, 0.0f ); - SetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE, 0.0f ); - SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE, 0.0f ); + SetFloatValue(UNIT_FIELD_MINDAMAGE, 0.0f); + SetFloatValue(UNIT_FIELD_MAXDAMAGE, 0.0f); + SetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, 0.0f); + SetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, 0.0f); + SetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE, 0.0f); + SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE, 0.0f); - SetInt32Value(UNIT_FIELD_ATTACK_POWER, 0 ); - SetInt32Value(UNIT_FIELD_ATTACK_POWER_MODS, 0 ); + SetInt32Value(UNIT_FIELD_ATTACK_POWER, 0); + SetInt32Value(UNIT_FIELD_ATTACK_POWER_MODS, 0); SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER,0.0f); - SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER, 0 ); - SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS,0 ); + SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER, 0); + SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS,0); SetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER,0.0f); // Base crit values (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset @@ -2677,13 +2677,13 @@ void Player::InitStatsForLevel(bool reapplyMods) SetUInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,0); SetUInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE,0); - for(int i = 0; i < MAX_SPELL_SCHOOL; ++i) + for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) { SetUInt32Value(UNIT_FIELD_POWER_COST_MODIFIER+i,0); SetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+i,0.0f); } // Reset no reagent cost field - for(int i = 0; i < 3; ++i) + for (int i = 0; i < 3; ++i) SetUInt32Value(PLAYER_NO_REAGENT_COST_1 + i, 0); // Init data for form but skip reapply item mods for form InitDataForForm(reapplyMods); @@ -2698,14 +2698,14 @@ void Player::InitStatsForLevel(bool reapplyMods) SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // cleanup unit flags (will be re-applied if need at aura load). - RemoveFlag( UNIT_FIELD_FLAGS, - UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_NOT_ATTACKABLE_1 | - UNIT_FLAG_OOC_NOT_ATTACKABLE | UNIT_FLAG_PASSIVE | UNIT_FLAG_LOOTING | - UNIT_FLAG_PET_IN_COMBAT | UNIT_FLAG_SILENCED | UNIT_FLAG_PACIFIED | - UNIT_FLAG_STUNNED | UNIT_FLAG_IN_COMBAT | UNIT_FLAG_DISARMED | - UNIT_FLAG_CONFUSED | UNIT_FLAG_FLEEING | UNIT_FLAG_NOT_SELECTABLE | - UNIT_FLAG_SKINNABLE | UNIT_FLAG_MOUNT | UNIT_FLAG_TAXI_FLIGHT ); - SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE ); // must be set + RemoveFlag(UNIT_FIELD_FLAGS, + UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_NOT_ATTACKABLE_1 | + UNIT_FLAG_OOC_NOT_ATTACKABLE | UNIT_FLAG_PASSIVE | UNIT_FLAG_LOOTING | + UNIT_FLAG_PET_IN_COMBAT | UNIT_FLAG_SILENCED | UNIT_FLAG_PACIFIED | + UNIT_FLAG_STUNNED | UNIT_FLAG_IN_COMBAT | UNIT_FLAG_DISARMED | + UNIT_FLAG_CONFUSED | UNIT_FLAG_FLEEING | UNIT_FLAG_NOT_SELECTABLE | + UNIT_FLAG_SKINNABLE | UNIT_FLAG_MOUNT | UNIT_FLAG_TAXI_FLIGHT); + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); // must be set SetFlag(UNIT_FIELD_FLAGS_2,UNIT_FLAG2_REGENERATE_POWER);// must be set @@ -2716,16 +2716,16 @@ void Player::InitStatsForLevel(bool reapplyMods) RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP | UNIT_BYTE2_FLAG_SANCTUARY); // restore if need some important flags - SetUInt32Value(PLAYER_FIELD_BYTES2, 0 ); // flags empty by default + SetUInt32Value(PLAYER_FIELD_BYTES2, 0); // flags empty by default - if(reapplyMods) //reapply stats values only on .reset stats (level) command + if (reapplyMods) //reapply stats values only on .reset stats (level) command _ApplyAllStatBonuses(); // set current level health and mana/energy to maximum after applying all mods. SetHealth(GetMaxHealth()); SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); - if(GetPower(POWER_RAGE) > GetMaxPower(POWER_RAGE)) + if (GetPower(POWER_RAGE) > GetMaxPower(POWER_RAGE)) SetPower(POWER_RAGE, GetMaxPower(POWER_RAGE)); SetPower(POWER_FOCUS, 0); SetPower(POWER_HAPPINESS, 0); @@ -2751,10 +2751,10 @@ void Player::SendInitialSpells() for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) { - if(itr->second.state == PLAYERSPELL_REMOVED) + if (itr->second.state == PLAYERSPELL_REMOVED) continue; - if(!itr->second.active || itr->second.disabled) + if (!itr->second.active || itr->second.disabled) continue; data << uint32(itr->first); @@ -2767,10 +2767,10 @@ void Player::SendInitialSpells() uint16 spellCooldowns = m_spellCooldowns.size(); data << uint16(spellCooldowns); - for(SpellCooldowns::const_iterator itr=m_spellCooldowns.begin(); itr!=m_spellCooldowns.end(); ++itr) + for (SpellCooldowns::const_iterator itr=m_spellCooldowns.begin(); itr!=m_spellCooldowns.end(); ++itr) { - SpellEntry const *sEntry = sSpellStore.LookupEntry(itr->first); - if(!sEntry) + SpellEntry const* sEntry = sSpellStore.LookupEntry(itr->first); + if (!sEntry) continue; data << uint32(itr->first); @@ -2779,7 +2779,7 @@ void Player::SendInitialSpells() data << uint16(sEntry->Category); // spell category // send infinity cooldown in special format - if(itr->second.end >= infTime) + if (itr->second.end >= infTime) { data << uint32(1); // cooldown data << uint32(0x80000000); // category cooldown @@ -2788,7 +2788,7 @@ void Player::SendInitialSpells() time_t cooldown = itr->second.end > curTime ? (itr->second.end-curTime)*IN_MILLISECONDS : 0; - if(sEntry->Category) // may be wrong, but anyway better than nothing... + if (sEntry->Category) // may be wrong, but anyway better than nothing... { data << uint32(0); // cooldown data << uint32(cooldown); // category cooldown @@ -2802,12 +2802,12 @@ void Player::SendInitialSpells() GetSession()->SendPacket(&data); - DETAIL_LOG( "CHARACTER: Sent Initial Spells" ); + DETAIL_LOG("CHARACTER: Sent Initial Spells"); } void Player::RemoveMail(uint32 id) { - for(PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end();++itr) + for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) { if ((*itr)->messageID == id) { @@ -2824,9 +2824,9 @@ void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResp data << (uint32) mailId; data << (uint32) mailAction; data << (uint32) mailError; - if ( mailError == MAIL_ERR_EQUIP_ERROR ) + if (mailError == MAIL_ERR_EQUIP_ERROR) data << (uint32) equipError; - else if( mailAction == MAIL_ITEM_TAKEN ) + else if (mailAction == MAIL_ITEM_TAKEN) { data << (uint32) item_guid; // item guid low? data << (uint32) item_count; // item count? @@ -2849,39 +2849,39 @@ void Player::UpdateNextMailTimeAndUnreads() time_t cTime = time(NULL); m_nextMailDelivereTime = 0; unReadMails = 0; - for(PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) + for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) { - if((*itr)->deliver_time > cTime) + if ((*itr)->deliver_time > cTime) { - if(!m_nextMailDelivereTime || m_nextMailDelivereTime > (*itr)->deliver_time) + if (!m_nextMailDelivereTime || m_nextMailDelivereTime > (*itr)->deliver_time) m_nextMailDelivereTime = (*itr)->deliver_time; } - else if(((*itr)->checked & MAIL_CHECK_MASK_READ) == 0) + else if (((*itr)->checked & MAIL_CHECK_MASK_READ) == 0) ++unReadMails; } } void Player::AddNewMailDeliverTime(time_t deliver_time) { - if(deliver_time <= time(NULL)) // ready now + if (deliver_time <= time(NULL)) // ready now { ++unReadMails; SendNewMail(); } else // not ready and no have ready mails { - if(!m_nextMailDelivereTime || m_nextMailDelivereTime > deliver_time) + if (!m_nextMailDelivereTime || m_nextMailDelivereTime > deliver_time) m_nextMailDelivereTime = deliver_time; } } bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependent, bool disabled) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); if (!spellInfo) { // do character spell book cleanup (all characters) - if(!IsInWorld() && !learning) // spell load case + if (!IsInWorld() && !learning) // spell load case { sLog.outError("Player::addSpell: nonexistent in SpellStore spell #%u request, deleting for all characters in `character_spell`.",spell_id); CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'",spell_id); @@ -2892,10 +2892,10 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen return false; } - if(!SpellMgr::IsSpellValid(spellInfo,this,false)) + if (!SpellMgr::IsSpellValid(spellInfo,this,false)) { // do character spell book cleanup (all characters) - if(!IsInWorld() && !learning) // spell load case + if (!IsInWorld() && !learning) // spell load case { sLog.outError("Player::addSpell: Broken spell #%u learning not allowed, deleting for all characters in `character_spell`.",spell_id); CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'",spell_id); @@ -2917,12 +2917,12 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen { uint32 next_active_spell_id = 0; // fix activate state for non-stackable low rank (and find next spell for !active case) - if(sSpellMgr.IsRankedSpellNonStackableInSpellBook(spellInfo)) + if (sSpellMgr.IsRankedSpellNonStackableInSpellBook(spellInfo)) { SpellChainMapNext const& nextMap = sSpellMgr.GetSpellChainNext(); - for(SpellChainMapNext::const_iterator next_itr = nextMap.lower_bound(spell_id); next_itr != nextMap.upper_bound(spell_id); ++next_itr) + for (SpellChainMapNext::const_iterator next_itr = nextMap.lower_bound(spell_id); next_itr != nextMap.upper_bound(spell_id); ++next_itr) { - if(HasSpell(next_itr->second)) + if (HasSpell(next_itr->second)) { // high rank already known so this must !active active = false; @@ -2933,10 +2933,10 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen } // not do anything if already known in expected state - if(itr->second.state != PLAYERSPELL_REMOVED && itr->second.active == active && - itr->second.dependent == dependent && itr->second.disabled == disabled) + if (itr->second.state != PLAYERSPELL_REMOVED && itr->second.active == active && + itr->second.dependent == dependent && itr->second.disabled == disabled) { - if(!IsInWorld() && !learning) // explicitly load from DB and then exist in it already and set correctly + if (!IsInWorld() && !learning) // explicitly load from DB and then exist in it already and set correctly itr->second.state = PLAYERSPELL_UNCHANGED; return false; @@ -2952,29 +2952,29 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen } // update active state for known spell - if(itr->second.active != active && itr->second.state != PLAYERSPELL_REMOVED && !itr->second.disabled) + if (itr->second.active != active && itr->second.state != PLAYERSPELL_REMOVED && !itr->second.disabled) { itr->second.active = active; - if(!IsInWorld() && !learning && !dependent_set) // explicitly load from DB and then exist in it already and set correctly + if (!IsInWorld() && !learning && !dependent_set) // explicitly load from DB and then exist in it already and set correctly itr->second.state = PLAYERSPELL_UNCHANGED; - else if(itr->second.state != PLAYERSPELL_NEW) + else if (itr->second.state != PLAYERSPELL_NEW) itr->second.state = PLAYERSPELL_CHANGED; - if(active) + if (active) { if (IsNeedCastPassiveLikeSpellAtLearn(spellInfo)) - CastSpell (this, spell_id, true); + CastSpell(this, spell_id, true); } - else if(IsInWorld()) + else if (IsInWorld()) { - if(next_active_spell_id) + if (next_active_spell_id) { // update spell ranks in spellbook and action bar WorldPacket data(SMSG_SUPERCEDED_SPELL, 4 + 4); data << uint32(spell_id); data << uint32(next_active_spell_id); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } else { @@ -2987,52 +2987,52 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen return active; // learn (show in spell book if active now) } - if(itr->second.disabled != disabled && itr->second.state != PLAYERSPELL_REMOVED) + if (itr->second.disabled != disabled && itr->second.state != PLAYERSPELL_REMOVED) { - if(itr->second.state != PLAYERSPELL_NEW) + if (itr->second.state != PLAYERSPELL_NEW) itr->second.state = PLAYERSPELL_CHANGED; itr->second.disabled = disabled; - if(disabled) + if (disabled) return false; disabled_case = true; } - else switch(itr->second.state) - { - case PLAYERSPELL_UNCHANGED: // known saved spell - return false; - case PLAYERSPELL_REMOVED: // re-learning removed not saved spell + else switch (itr->second.state) { - m_spells.erase(itr); - state = PLAYERSPELL_CHANGED; - break; // need re-add - } - default: // known not saved yet spell (new or modified) - { - // can be in case spell loading but learned at some previous spell loading - if(!IsInWorld() && !learning && !dependent_set) - itr->second.state = PLAYERSPELL_UNCHANGED; + case PLAYERSPELL_UNCHANGED: // known saved spell + return false; + case PLAYERSPELL_REMOVED: // re-learning removed not saved spell + { + m_spells.erase(itr); + state = PLAYERSPELL_CHANGED; + break; // need re-add + } + default: // known not saved yet spell (new or modified) + { + // can be in case spell loading but learned at some previous spell loading + if (!IsInWorld() && !learning && !dependent_set) + itr->second.state = PLAYERSPELL_UNCHANGED; - return false; + return false; + } } - } } TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id); - if(!disabled_case) // skip new spell adding if spell already known (disabled spells case) + if (!disabled_case) // skip new spell adding if spell already known (disabled spells case) { // talent: unlearn all other talent ranks (high and low) if (talentPos) { - if(TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id )) + if (TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentPos->talent_id)) { - for(int i=0; i < MAX_TALENT_RANK; ++i) + for (int i=0; i < MAX_TALENT_RANK; ++i) { // skip learning spell and no rank spell case uint32 rankSpellId = talentInfo->RankID[i]; - if(!rankSpellId || rankSpellId == spell_id) + if (!rankSpellId || rankSpellId == spell_id) continue; removeSpell(rankSpellId, false, false); @@ -3040,9 +3040,9 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen } } // non talent spell: learn low ranks (recursive call) - else if(uint32 prev_spell = sSpellMgr.GetPrevSpellInChain(spell_id)) + else if (uint32 prev_spell = sSpellMgr.GetPrevSpellInChain(spell_id)) { - if(!IsInWorld() || disabled) // at spells loading, no output, but allow save + if (!IsInWorld() || disabled) // at spells loading, no output, but allow save addSpell(prev_spell, active, true, true, disabled); else // at normal learning learnSpell(prev_spell, true); @@ -3055,47 +3055,47 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen newspell.disabled = disabled; // replace spells in action bars and spellbook to bigger rank if only one spell rank must be accessible - if(newspell.active && !newspell.disabled && sSpellMgr.IsRankedSpellNonStackableInSpellBook(spellInfo)) + if (newspell.active && !newspell.disabled && sSpellMgr.IsRankedSpellNonStackableInSpellBook(spellInfo)) { - for( PlayerSpellMap::iterator itr2 = m_spells.begin(); itr2 != m_spells.end(); ++itr2 ) + for (PlayerSpellMap::iterator itr2 = m_spells.begin(); itr2 != m_spells.end(); ++itr2) { - if(itr2->second.state == PLAYERSPELL_REMOVED) continue; - SpellEntry const *i_spellInfo = sSpellStore.LookupEntry(itr2->first); - if(!i_spellInfo) continue; + if (itr2->second.state == PLAYERSPELL_REMOVED) continue; + SpellEntry const* i_spellInfo = sSpellStore.LookupEntry(itr2->first); + if (!i_spellInfo) continue; - if( sSpellMgr.IsRankSpellDueToSpell(spellInfo, itr2->first) ) + if (sSpellMgr.IsRankSpellDueToSpell(spellInfo, itr2->first)) { - if(itr2->second.active) + if (itr2->second.active) { - if(sSpellMgr.IsHighRankOfSpell(spell_id,itr2->first)) + if (sSpellMgr.IsHighRankOfSpell(spell_id,itr2->first)) { - if(IsInWorld()) // not send spell (re-/over-)learn packets at loading + if (IsInWorld()) // not send spell (re-/over-)learn packets at loading { WorldPacket data(SMSG_SUPERCEDED_SPELL, 4 + 4); data << uint32(itr2->first); data << uint32(spell_id); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } // mark old spell as disable (SMSG_SUPERCEDED_SPELL replace it in client by new) itr2->second.active = false; - if(itr2->second.state != PLAYERSPELL_NEW) + if (itr2->second.state != PLAYERSPELL_NEW) itr2->second.state = PLAYERSPELL_CHANGED; superceded_old = true; // new spell replace old in action bars and spell book. } - else if(sSpellMgr.IsHighRankOfSpell(itr2->first,spell_id)) + else if (sSpellMgr.IsHighRankOfSpell(itr2->first,spell_id)) { - if(IsInWorld()) // not send spell (re-/over-)learn packets at loading + if (IsInWorld()) // not send spell (re-/over-)learn packets at loading { WorldPacket data(SMSG_SUPERCEDED_SPELL, 4 + 4); data << uint32(spell_id); data << uint32(itr2->first); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } // mark new spell as disable (not learned yet for client and will not learned) newspell.active = false; - if(newspell.state != PLAYERSPELL_NEW) + if (newspell.state != PLAYERSPELL_NEW) newspell.state = PLAYERSPELL_CHANGED; } } @@ -3142,7 +3142,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen // update free primary prof.points (if any, can be none in case GM .learn prof. learning) if (uint32 freeProfs = GetFreePrimaryProfessionPoints()) { - if(sSpellMgr.IsPrimaryProfessionFirstRankSpell(spell_id)) + if (sSpellMgr.IsPrimaryProfessionFirstRankSpell(spell_id)) SetFreePrimaryProfessions(freeProfs-1); } @@ -3189,9 +3189,9 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen else { // not ranked skills - for(SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx) + for (SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx) { - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId); + SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId); if (!pSkill) continue; @@ -3199,19 +3199,19 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen continue; if (_spell_idx->second->learnOnGetSkill == ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL || - // lockpicking/runeforging special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL - ((pSkill->id==SKILL_LOCKPICKING || pSkill->id==SKILL_RUNEFORGING) && _spell_idx->second->max_value==0)) + // lockpicking/runeforging special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL + ((pSkill->id==SKILL_LOCKPICKING || pSkill->id==SKILL_RUNEFORGING) && _spell_idx->second->max_value==0)) { - switch(GetSkillRangeType(pSkill, _spell_idx->second->racemask != 0)) + switch (GetSkillRangeType(pSkill, _spell_idx->second->racemask != 0)) { case SKILL_RANGE_LANGUAGE: - SetSkill(pSkill->id, 300, 300 ); + SetSkill(pSkill->id, 300, 300); break; case SKILL_RANGE_LEVEL: - SetSkill(pSkill->id, 1, GetMaxSkillValueForLevel() ); + SetSkill(pSkill->id, 1, GetMaxSkillValueForLevel()); break; case SKILL_RANGE_MONO: - SetSkill(pSkill->id, 1, 1 ); + SetSkill(pSkill->id, 1, 1); break; default: break; @@ -3223,7 +3223,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen // learn dependent spells SpellLearnSpellMapBounds spell_bounds = sSpellMgr.GetSpellLearnSpellMapBounds(spell_id); - for(SpellLearnSpellMap::const_iterator itr2 = spell_bounds.first; itr2 != spell_bounds.second; ++itr2) + for (SpellLearnSpellMap::const_iterator itr2 = spell_bounds.first; itr2 != spell_bounds.second; ++itr2) { if (!itr2->second.autoLearned) { @@ -3237,7 +3237,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen if (!GetSession()->PlayerLoading()) { // not ranked skills - for(SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx) + for (SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx) { GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE,_spell_idx->second->skillId); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS,_spell_idx->second->skillId); @@ -3287,10 +3287,10 @@ void Player::learnSpell(uint32 spell_id, bool dependent) } // learn all disabled higher ranks (recursive) - if(disabled) + if (disabled) { SpellChainMapNext const& nextMap = sSpellMgr.GetSpellChainNext(); - for(SpellChainMapNext::const_iterator i = nextMap.lower_bound(spell_id); i != nextMap.upper_bound(spell_id); ++i) + for (SpellChainMapNext::const_iterator i = nextMap.lower_bound(spell_id); i != nextMap.upper_bound(spell_id); ++i) { PlayerSpellMap::iterator iter = m_spells.find(i->second); if (iter != m_spells.end() && iter->second.disabled) @@ -3310,8 +3310,8 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo // unlearn non talent higher ranks (recursive) SpellChainMapNext const& nextMap = sSpellMgr.GetSpellChainNext(); - for(SpellChainMapNext::const_iterator itr2 = nextMap.lower_bound(spell_id); itr2 != nextMap.upper_bound(spell_id); ++itr2) - if(HasSpell(itr2->second) && !GetTalentSpellPos(itr2->second)) + for (SpellChainMapNext::const_iterator itr2 = nextMap.lower_bound(spell_id); itr2 != nextMap.upper_bound(spell_id); ++itr2) + if (HasSpell(itr2->second) && !GetTalentSpellPos(itr2->second)) removeSpell(itr2->second, disabled, false); // re-search, it can be corrupted in prev loop @@ -3325,12 +3325,12 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo if (disabled) { itr->second.disabled = disabled; - if(itr->second.state != PLAYERSPELL_NEW) + if (itr->second.state != PLAYERSPELL_NEW) itr->second.state = PLAYERSPELL_CHANGED; } else { - if(itr->second.state == PLAYERSPELL_NEW) + if (itr->second.state == PLAYERSPELL_NEW) m_spells.erase(itr); else itr->second.state = PLAYERSPELL_REMOVED; @@ -3339,8 +3339,8 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo RemoveAurasDueToSpell(spell_id); // remove pet auras - for(int i = 0; i < MAX_EFFECT_INDEX; ++i) - if(PetAura const* petSpell = sSpellMgr.GetPetAura(spell_id, SpellEffectIndex(i))) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + if (PetAura const* petSpell = sSpellMgr.GetPetAura(spell_id, SpellEffectIndex(i))) RemovePetAura(petSpell); TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id); @@ -3356,12 +3356,12 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo m_talents[m_activeSpec].erase(iter); } else - sLog.outError("removeSpell: Player (GUID: %u) has talent spell (id: %u) but doesn't have talent",GetGUIDLow(), spell_id ); + sLog.outError("removeSpell: Player (GUID: %u) has talent spell (id: %u) but doesn't have talent",GetGUIDLow(), spell_id); // free talent points uint32 talentCosts = GetTalentSpellCost(talentPos); - if(talentCosts < m_usedTalentCount) + if (talentCosts < m_usedTalentCount) m_usedTalentCount -= talentCosts; else m_usedTalentCount = 0; @@ -3370,26 +3370,26 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo } // update free primary prof.points (if not overflow setting, can be in case GM use before .learn prof. learning) - if(sSpellMgr.IsPrimaryProfessionFirstRankSpell(spell_id)) + if (sSpellMgr.IsPrimaryProfessionFirstRankSpell(spell_id)) { uint32 freeProfs = GetFreePrimaryProfessionPoints()+1; uint32 maxProfs = GetSession()->GetSecurity() < AccountTypes(sWorld.getConfig(CONFIG_UINT32_TRADE_SKILL_GMIGNORE_MAX_PRIMARY_COUNT)) ? sWorld.getConfig(CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL) : 10; - if(freeProfs <= maxProfs) + if (freeProfs <= maxProfs) SetFreePrimaryProfessions(freeProfs); } // remove dependent skill SpellLearnSkillNode const* spellLearnSkill = sSpellMgr.GetSpellLearnSkill(spell_id); - if(spellLearnSkill) + if (spellLearnSkill) { uint32 prev_spell = sSpellMgr.GetPrevSpellInChain(spell_id); - if(!prev_spell) // first rank, remove skill + if (!prev_spell) // first rank, remove skill SetSkill(spellLearnSkill->skill, 0, 0); else { // search prev. skill setting by spell ranks chain SpellLearnSkillNode const* prevSkill = sSpellMgr.GetSpellLearnSkill(prev_spell); - while(!prevSkill && prev_spell) + while (!prevSkill && prev_spell) { prev_spell = sSpellMgr.GetPrevSpellInChain(prev_spell); prevSkill = sSpellMgr.GetSpellLearnSkill(sSpellMgr.GetFirstSpellInChain(prev_spell)); @@ -3420,20 +3420,20 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo // not ranked skills SkillLineAbilityMapBounds bounds = sSpellMgr.GetSkillLineAbilityMapBounds(spell_id); - for(SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx) + for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx) { - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId); + SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId); if (!pSkill) continue; if ((_spell_idx->second->learnOnGetSkill == ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL && - pSkill->categoryId != SKILL_CATEGORY_CLASS) ||// not unlearn class skills (spellbook/talent pages) - // lockpicking/runeforging special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL - ((pSkill->id == SKILL_LOCKPICKING || pSkill->id == SKILL_RUNEFORGING) && _spell_idx->second->max_value == 0)) + pSkill->categoryId != SKILL_CATEGORY_CLASS) ||// not unlearn class skills (spellbook/talent pages) + // lockpicking/runeforging special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL + ((pSkill->id == SKILL_LOCKPICKING || pSkill->id == SKILL_RUNEFORGING) && _spell_idx->second->max_value == 0)) { // not reset skills for professions and racial abilities if ((pSkill->categoryId == SKILL_CATEGORY_SECONDARY || pSkill->categoryId == SKILL_CATEGORY_PROFESSION) && - (IsProfessionSkill(pSkill->id) || _spell_idx->second->racemask != 0)) + (IsProfessionSkill(pSkill->id) || _spell_idx->second->racemask != 0)) continue; SetSkill(pSkill->id, 0, 0); @@ -3444,20 +3444,20 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo // remove dependent spells SpellLearnSpellMapBounds spell_bounds = sSpellMgr.GetSpellLearnSpellMapBounds(spell_id); - for(SpellLearnSpellMap::const_iterator itr2 = spell_bounds.first; itr2 != spell_bounds.second; ++itr2) + for (SpellLearnSpellMap::const_iterator itr2 = spell_bounds.first; itr2 != spell_bounds.second; ++itr2) removeSpell(itr2->second.spell, disabled); // activate lesser rank in spellbook/action bar, and cast it if need bool prev_activate = false; - if (uint32 prev_id = sSpellMgr.GetPrevSpellInChain (spell_id)) + if (uint32 prev_id = sSpellMgr.GetPrevSpellInChain(spell_id)) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); // if talent then lesser rank also talent and need learn if (talentPos) { - if(learn_low_rank) + if (learn_low_rank) learnSpell(prev_id, false); } // if ranked non-stackable spell: need activate lesser rank and update dependence state @@ -3483,7 +3483,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo WorldPacket data(SMSG_SUPERCEDED_SPELL, 4 + 4); data << uint32(spell_id); data << uint32(prev_id); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); prev_activate = true; } } @@ -3494,7 +3494,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo // for Titan's Grip and shaman Dual-wield if (CanDualWield() || CanTitanGrip()) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); if (CanDualWield() && IsSpellHaveEffect(spellInfo, SPELL_EFFECT_DUAL_WIELD)) SetCanDualWield(false); @@ -3508,7 +3508,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo } // for talents and normal spell unlearn that allow offhand use for some weapons - if(sWorld.getConfig(CONFIG_BOOL_OFFHAND_CHECK_AT_TALENTS_RESET)) + if (sWorld.getConfig(CONFIG_BOOL_OFFHAND_CHECK_AT_TALENTS_RESET)) AutoUnequipOffhandIfNeed(); // remove from spell book if not replaced by lesser rank @@ -3520,11 +3520,11 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo } } -void Player::RemoveSpellCooldown( uint32 spell_id, bool update /* = false */ ) +void Player::RemoveSpellCooldown(uint32 spell_id, bool update /* = false */) { m_spellCooldowns.erase(spell_id); - if(update) + if (update) SendClearCooldown(spell_id, this); } @@ -3549,15 +3549,15 @@ void Player::RemoveArenaSpellCooldowns() // remove cooldowns on spells that has < 15 min CD SpellCooldowns::iterator itr, next; // iterate spell cooldowns - for(itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end(); itr = next) + for (itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); itr = next) { next = itr; ++next; - SpellEntry const * entry = sSpellStore.LookupEntry(itr->first); + SpellEntry const* entry = sSpellStore.LookupEntry(itr->first); // check if spellentry is present and if the cooldown is less than 15 mins - if( entry && - entry->RecoveryTime <= 15 * MINUTE * IN_MILLISECONDS && - entry->CategoryRecoveryTime <= 15 * MINUTE * IN_MILLISECONDS ) + if (entry && + entry->RecoveryTime <= 15 * MINUTE * IN_MILLISECONDS && + entry->CategoryRecoveryTime <= 15 * MINUTE * IN_MILLISECONDS) { // remove & notify RemoveSpellCooldown(itr->first, true); @@ -3567,48 +3567,48 @@ void Player::RemoveArenaSpellCooldowns() void Player::RemoveAllSpellCooldown() { - if(!m_spellCooldowns.empty()) + if (!m_spellCooldowns.empty()) { - for(SpellCooldowns::const_iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end(); ++itr) + for (SpellCooldowns::const_iterator itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); ++itr) SendClearCooldown(itr->first, this); m_spellCooldowns.clear(); } } -void Player::_LoadSpellCooldowns(QueryResult *result) +void Player::_LoadSpellCooldowns(QueryResult* result) { // some cooldowns can be already set at aura loading... //QueryResult *result = CharacterDatabase.PQuery("SELECT spell,item,time FROM character_spell_cooldown WHERE guid = '%u'",GetGUIDLow()); - if(result) + if (result) { time_t curTime = time(NULL); do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 spell_id = fields[0].GetUInt32(); uint32 item_id = fields[1].GetUInt32(); time_t db_time = (time_t)fields[2].GetUInt64(); - if(!sSpellStore.LookupEntry(spell_id)) + if (!sSpellStore.LookupEntry(spell_id)) { sLog.outError("Player %u has unknown spell %u in `character_spell_cooldown`, skipping.",GetGUIDLow(),spell_id); continue; } // skip outdated cooldown - if(db_time <= curTime) + if (db_time <= curTime) continue; AddSpellCooldown(spell_id, item_id, db_time); DEBUG_LOG("Player (GUID: %u) spell %u, item %u cooldown loaded (%u secs).", GetGUIDLow(), spell_id, item_id, uint32(db_time-curTime)); } - while( result->NextRow() ); + while (result->NextRow()); delete result; } @@ -3626,11 +3626,11 @@ void Player::_SaveSpellCooldowns() time_t infTime = curTime + infinityCooldownDelayCheck; // remove outdated and save active - for(SpellCooldowns::iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end();) + for (SpellCooldowns::iterator itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end();) { - if(itr->second.end <= curTime) + if (itr->second.end <= curTime) m_spellCooldowns.erase(itr++); - else if(itr->second.end <= infTime) // not save locked cooldowns, it will be reset or set at reload + else if (itr->second.end <= infTime) // not save locked cooldowns, it will be reset or set at reload { stmt = CharacterDatabase.CreateStatement(insertSpellCooldown, "INSERT INTO character_spell_cooldown (guid,spell,item,time) VALUES( ?, ?, ?, ?)"); stmt.PExecute(GetGUIDLow(), itr->first, itr->second.itemid, uint64(itr->second.end)); @@ -3644,18 +3644,18 @@ void Player::_SaveSpellCooldowns() uint32 Player::resetTalentsCost() const { // The first time reset costs 1 gold - if(m_resetTalentsCost < 1*GOLD) + if (m_resetTalentsCost < 1*GOLD) return 1*GOLD; // then 5 gold - else if(m_resetTalentsCost < 5*GOLD) + else if (m_resetTalentsCost < 5*GOLD) return 5*GOLD; // After that it increases in increments of 5 gold - else if(m_resetTalentsCost < 10*GOLD) + else if (m_resetTalentsCost < 10*GOLD) return 10*GOLD; else { time_t months = (sWorld.GetGameTime() - m_resetTalentsTime)/MONTH; - if(months > 0) + if (months > 0) { // This cost will be reduced by a rate of 5 gold per month int32 new_cost = int32((m_resetTalentsCost) - 5*GOLD*months); @@ -3667,7 +3667,7 @@ uint32 Player::resetTalentsCost() const // After that it increases in increments of 5 gold int32 new_cost = m_resetTalentsCost + 5*GOLD; // until it hits a cap of 50 gold. - if(new_cost > 50*GOLD) + if (new_cost > 50*GOLD) new_cost = 50*GOLD; return new_cost; } @@ -3677,7 +3677,7 @@ uint32 Player::resetTalentsCost() const bool Player::resetTalents(bool no_cost, bool all_specs) { // not need after this call - if(HasAtLoginFlag(AT_LOGIN_RESET_TALENTS) && all_specs) + if (HasAtLoginFlag(AT_LOGIN_RESET_TALENTS) && all_specs) RemoveAtLoginFlag(AT_LOGIN_RESET_TALENTS,true); if (m_usedTalentCount == 0 && !all_specs) @@ -3688,13 +3688,13 @@ bool Player::resetTalents(bool no_cost, bool all_specs) uint32 cost = 0; - if(!no_cost) + if (!no_cost) { cost = resetTalentsCost(); if (GetMoney() < cost) { - SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0); + SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0); return false; } } @@ -3750,16 +3750,16 @@ bool Player::resetTalents(bool no_cost, bool all_specs) { switch (iter->second.state) { - case PLAYERSPELL_REMOVED: - ++iter; - break; - case PLAYERSPELL_NEW: - m_talents[spec].erase(iter++); - break; - default: - iter->second.state = PLAYERSPELL_REMOVED; - ++iter; - break; + case PLAYERSPELL_REMOVED: + ++iter; + break; + case PLAYERSPELL_NEW: + m_talents[spec].erase(iter++); + break; + default: + iter->second.state = PLAYERSPELL_REMOVED; + ++iter; + break; } } } @@ -3767,7 +3767,7 @@ bool Player::resetTalents(bool no_cost, bool all_specs) UpdateFreeTalentPoints(false); - if(!no_cost) + if (!no_cost) { ModifyMoney(-(int32)cost); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS, cost); @@ -3791,7 +3791,7 @@ bool Player::resetTalents(bool no_cost, bool all_specs) Mail* Player::GetMail(uint32 id) { - for(PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) + for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) { if ((*itr)->messageID == id) { @@ -3801,25 +3801,25 @@ Mail* Player::GetMail(uint32 id) return NULL; } -void Player::_SetCreateBits(UpdateMask *updateMask, Player *target) const +void Player::_SetCreateBits(UpdateMask* updateMask, Player* target) const { - if(target == this) + if (target == this) { Object::_SetCreateBits(updateMask, target); } else { - for(uint16 index = 0; index < m_valuesCount; index++) + for (uint16 index = 0; index < m_valuesCount; index++) { - if(GetUInt32Value(index) != 0 && updateVisualBits.GetBit(index)) + if (GetUInt32Value(index) != 0 && updateVisualBits.GetBit(index)) updateMask->SetBit(index); } } } -void Player::_SetUpdateBits(UpdateMask *updateMask, Player *target) const +void Player::_SetUpdateBits(UpdateMask* updateMask, Player* target) const { - if(target == this) + if (target == this) { Object::_SetUpdateBits(updateMask, target); } @@ -3902,11 +3902,11 @@ void Player::InitVisibleBits() updateVisualBits.SetBit(PLAYER_GUILD_TIMESTAMP); // PLAYER_QUEST_LOG_x also visible bit on official (but only on party/raid)... - for(uint16 i = PLAYER_QUEST_LOG_1_1; i < PLAYER_QUEST_LOG_25_2; i += MAX_QUEST_OFFSET) + for (uint16 i = PLAYER_QUEST_LOG_1_1; i < PLAYER_QUEST_LOG_25_2; i += MAX_QUEST_OFFSET) updateVisualBits.SetBit(i); // Players visible items are not inventory stuff - for(uint16 i = 0; i < EQUIPMENT_SLOT_END; ++i) + for (uint16 i = 0; i < EQUIPMENT_SLOT_END; ++i) { uint32 offset = i * 2; @@ -3919,63 +3919,63 @@ void Player::InitVisibleBits() updateVisualBits.SetBit(PLAYER_CHOSEN_TITLE); } -void Player::BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const +void Player::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const { - if(target == this) + if (target == this) { - for(int i = 0; i < EQUIPMENT_SLOT_END; ++i) + for (int i = 0; i < EQUIPMENT_SLOT_END; ++i) { - if(m_items[i] == NULL) + if (m_items[i] == NULL) continue; - m_items[i]->BuildCreateUpdateBlockForPlayer( data, target ); + m_items[i]->BuildCreateUpdateBlockForPlayer(data, target); } - for(int i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) + for (int i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) { - if(m_items[i] == NULL) + if (m_items[i] == NULL) continue; - m_items[i]->BuildCreateUpdateBlockForPlayer( data, target ); + m_items[i]->BuildCreateUpdateBlockForPlayer(data, target); } - for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) + for (int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) { - if(m_items[i] == NULL) + if (m_items[i] == NULL) continue; - m_items[i]->BuildCreateUpdateBlockForPlayer( data, target ); + m_items[i]->BuildCreateUpdateBlockForPlayer(data, target); } } - Unit::BuildCreateUpdateBlockForPlayer( data, target ); + Unit::BuildCreateUpdateBlockForPlayer(data, target); } -void Player::DestroyForPlayer( Player *target, bool anim ) const +void Player::DestroyForPlayer(Player* target, bool anim) const { - Unit::DestroyForPlayer( target, anim ); + Unit::DestroyForPlayer(target, anim); - for(int i = 0; i < INVENTORY_SLOT_BAG_END; ++i) + for (int i = 0; i < INVENTORY_SLOT_BAG_END; ++i) { - if(m_items[i] == NULL) + if (m_items[i] == NULL) continue; - m_items[i]->DestroyForPlayer( target ); + m_items[i]->DestroyForPlayer(target); } - if(target == this) + if (target == this) { - for(int i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) + for (int i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) { - if(m_items[i] == NULL) + if (m_items[i] == NULL) continue; - m_items[i]->DestroyForPlayer( target ); + m_items[i]->DestroyForPlayer(target); } - for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) + for (int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) { - if(m_items[i] == NULL) + if (m_items[i] == NULL) continue; - m_items[i]->DestroyForPlayer( target ); + m_items[i]->DestroyForPlayer(target); } } } @@ -3984,14 +3984,14 @@ bool Player::HasSpell(uint32 spell) const { PlayerSpellMap::const_iterator itr = m_spells.find(spell); return (itr != m_spells.end() && itr->second.state != PLAYERSPELL_REMOVED && - !itr->second.disabled); + !itr->second.disabled); } bool Player::HasActiveSpell(uint32 spell) const { PlayerSpellMap::const_iterator itr = m_spells.find(spell); return (itr != m_spells.end() && itr->second.state != PLAYERSPELL_REMOVED && - itr->second.active && !itr->second.disabled); + itr->second.active && !itr->second.disabled); } TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell, uint32 reqLevel) const @@ -4017,14 +4017,14 @@ TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell if (getLevel() < reqLevel) return TRAINER_SPELL_RED; - if(SpellChainNode const* spell_chain = sSpellMgr.GetSpellChainNode(trainer_spell->learnedSpell)) + if (SpellChainNode const* spell_chain = sSpellMgr.GetSpellChainNode(trainer_spell->learnedSpell)) { // check prev.rank requirement - if(spell_chain->prev && !HasSpell(spell_chain->prev)) + if (spell_chain->prev && !HasSpell(spell_chain->prev)) return TRAINER_SPELL_RED; // check additional spell requirement - if(spell_chain->req && !HasSpell(spell_chain->req)) + if (spell_chain->req && !HasSpell(spell_chain->req)) return TRAINER_SPELL_RED; } @@ -4039,11 +4039,11 @@ TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell // secondary prof. or not prof. spell uint32 skill = spell->EffectMiscValue[1]; - if(spell->Effect[1] != SPELL_EFFECT_SKILL || !IsPrimaryProfessionSkill(skill)) + if (spell->Effect[1] != SPELL_EFFECT_SKILL || !IsPrimaryProfessionSkill(skill)) return TRAINER_SPELL_GREEN; // check primary prof. limit - if(sSpellMgr.IsPrimaryProfessionFirstRankSpell(spell->Id) && GetFreePrimaryProfessionPoints() == 0) + if (sSpellMgr.IsPrimaryProfessionFirstRankSpell(spell->Id) && GetFreePrimaryProfessionPoints() == 0) return TRAINER_SPELL_GREEN_DISABLED; return TRAINER_SPELL_GREEN; @@ -4097,7 +4097,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe LeaveAllArenaTeams(playerguid); // the player was uninvited already on logout so just remove from group - QueryResult *resultGroup = CharacterDatabase.PQuery("SELECT groupId FROM group_member WHERE memberGuid='%u'", lowguid); + QueryResult* resultGroup = CharacterDatabase.PQuery("SELECT groupId FROM group_member WHERE memberGuid='%u'", lowguid); if (resultGroup) { uint32 groupId = (*resultGroup)[0].GetUInt32(); @@ -4109,18 +4109,18 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe // remove signs from petitions (also remove petitions if owner); RemovePetitionsAndSigns(playerguid, 10); - switch(charDelete_method) + switch (charDelete_method) { - // completely remove from the database + // completely remove from the database case 0: { // return back all mails with COD and Item 0 1 2 3 4 5 6 7 - QueryResult *resultMail = CharacterDatabase.PQuery("SELECT id,messageType,mailTemplateId,sender,subject,body,money,has_items FROM mail WHERE receiver='%u' AND has_items<>0 AND cod<>0", lowguid); + QueryResult* resultMail = CharacterDatabase.PQuery("SELECT id,messageType,mailTemplateId,sender,subject,body,money,has_items FROM mail WHERE receiver='%u' AND has_items<>0 AND cod<>0", lowguid); if (resultMail) { do { - Field *fields = resultMail->Fetch(); + Field* fields = resultMail->Fetch(); uint32 mail_id = fields[0].GetUInt32(); uint16 mailType = fields[1].GetUInt16(); @@ -4138,7 +4138,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe // mail not from player if (mailType != MAIL_NORMAL) { - if(has_items) + if (has_items) CharacterDatabase.PExecute("DELETE FROM mail_items WHERE mail_id = '%u'", mail_id); continue; } @@ -4153,12 +4153,12 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe { // data needs to be at first place for Item::LoadFromDB // 0 1 2 3 - QueryResult *resultItems = CharacterDatabase.PQuery("SELECT data,text,item_guid,item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail_id); + QueryResult* resultItems = CharacterDatabase.PQuery("SELECT data,text,item_guid,item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail_id); if (resultItems) { do { - Field *fields2 = resultItems->Fetch(); + Field* fields2 = resultItems->Fetch(); uint32 item_guidlow = fields2[2].GetUInt32(); uint32 item_template = fields2[3].GetUInt32(); @@ -4170,7 +4170,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe continue; } - Item *pItem = NewItemOrBag(itemProto); + Item* pItem = NewItemOrBag(itemProto); if (!pItem->LoadFromDB(item_guidlow, fields2, playerguid)) { pItem->FSetState(ITEM_REMOVED); @@ -4199,10 +4199,10 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe // unsummon and delete for pets in world is not required: player deleted from CLI or character list with not loaded pet. // Get guids of character's pets, will deleted in transaction - QueryResult *resultPets = CharacterDatabase.PQuery("SELECT id FROM character_pet WHERE owner = '%u'", lowguid); + QueryResult* resultPets = CharacterDatabase.PQuery("SELECT id FROM character_pet WHERE owner = '%u'", lowguid); // delete char from friends list when selected chars is online (non existing - error) - QueryResult *resultFriend = CharacterDatabase.PQuery("SELECT DISTINCT guid FROM character_social WHERE friend = '%u'", lowguid); + QueryResult* resultFriend = CharacterDatabase.PQuery("SELECT DISTINCT guid FROM character_social WHERE friend = '%u'", lowguid); // NOW we can finally clear other DB data related to character CharacterDatabase.BeginTransaction(); @@ -4210,11 +4210,12 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe { do { - Field *fields3 = resultPets->Fetch(); + Field* fields3 = resultPets->Fetch(); uint32 petguidlow = fields3[0].GetUInt32(); //do not create separate transaction for pet delete otherwise we will get fatal error! Pet::DeleteFromDB(petguidlow, false); - } while (resultPets->NextRow()); + } + while (resultPets->NextRow()); delete resultPets; } @@ -4232,7 +4233,8 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe sSocialMgr.SendFriendStatus(sFriend, FRIEND_REMOVED, playerguid, false); } } - } while (resultFriend->NextRow()); + } + while (resultFriend->NextRow()); delete resultFriend; } @@ -4308,16 +4310,17 @@ void Player::DeleteOldCharacters(uint32 keepDays) { sLog.outString("Player::DeleteOldChars: Deleting all characters which have been deleted %u days before...", keepDays); - QueryResult *resultChars = CharacterDatabase.PQuery("SELECT guid, deleteInfos_Account FROM characters WHERE deleteDate IS NOT NULL AND deleteDate < '" UI64FMTD "'", uint64(time(NULL) - time_t(keepDays * DAY))); + QueryResult* resultChars = CharacterDatabase.PQuery("SELECT guid, deleteInfos_Account FROM characters WHERE deleteDate IS NOT NULL AND deleteDate < '" UI64FMTD "'", uint64(time(NULL) - time_t(keepDays * DAY))); if (resultChars) { sLog.outString("Player::DeleteOldChars: Found %u character(s) to delete",uint32(resultChars->GetRowCount())); do { - Field *charFields = resultChars->Fetch(); + Field* charFields = resultChars->Fetch(); ObjectGuid guid = ObjectGuid(HIGHGUID_PLAYER, charFields[0].GetUInt32()); Player::DeleteFromDB(guid, charFields[1].GetUInt32(), true, true); - } while(resultChars->NextRow()); + } + while (resultChars->NextRow()); delete resultChars; } } @@ -4325,7 +4328,7 @@ void Player::DeleteOldCharacters(uint32 keepDays) void Player::SetMovement(PlayerMovementType pType) { WorldPacket data; - switch(pType) + switch (pType) { case MOVE_ROOT: data.Initialize(SMSG_FORCE_MOVE_ROOT, GetPackGUID().size()+4); break; case MOVE_UNROOT: data.Initialize(SMSG_FORCE_MOVE_UNROOT, GetPackGUID().size()+4); break; @@ -4337,7 +4340,7 @@ void Player::SetMovement(PlayerMovementType pType) } data << GetPackGUID(); data << uint32(0); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } /* Preconditions: @@ -4350,7 +4353,7 @@ void Player::BuildPlayerRepop() data << GetPackGUID(); GetSession()->SendPacket(&data); - if(getRace() == RACE_NIGHTELF) + if (getRace() == RACE_NIGHTELF) CastSpell(this, 20584, true); // auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form) CastSpell(this, 8326, true); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?) @@ -4359,15 +4362,15 @@ void Player::BuildPlayerRepop() // there we must send 888 opcode // the player cannot have a corpse already, only bones which are not returned by GetCorpse - if(GetCorpse()) + if (GetCorpse()) { sLog.outError("BuildPlayerRepop: player %s(%d) already has a corpse", GetName(), GetGUIDLow()); MANGOS_ASSERT(false); } // create a corpse and place it at the player's location - Corpse *corpse = CreateCorpse(); - if(!corpse) + Corpse* corpse = CreateCorpse(); + if (!corpse) { sLog.outError("Error creating corpse for Player %s [%u]", GetName(), GetGUIDLow()); return; @@ -4375,10 +4378,10 @@ void Player::BuildPlayerRepop() GetMap()->Add(corpse); // convert player body to ghost - SetHealth( 1 ); + SetHealth(1); SetMovement(MOVE_WATER_WALK); - if(!GetSession()->isLogingOut()) + if (!GetSession()->isLogingOut()) SetMovement(MOVE_UNROOT); // BG - remove insignia related @@ -4411,7 +4414,7 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) SetDeathState(ALIVE); - if(getRace() == RACE_NIGHTELF) + if (getRace() == RACE_NIGHTELF) RemoveAurasDueToSpell(20584); // speed bonuses RemoveAurasDueToSpell(8326); // SPELL_AURA_GHOST @@ -4421,7 +4424,7 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) m_deathTimer = 0; // set health/powers (0- will be set in caller) - if(restore_percent>0.0f) + if (restore_percent>0.0f) { SetHealth(uint32(GetMaxHealth()*restore_percent)); SetPower(POWER_MANA, uint32(GetMaxPower(POWER_MANA)*restore_percent)); @@ -4439,7 +4442,7 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) // update visibility of player for nearby cameras UpdateObjectVisibility(); - if(!applySickness) + if (!applySickness) return; //Characters from level 1-10 are not affected by resurrection sickness. @@ -4448,13 +4451,13 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) //Characters level 20 and up suffer from ten minutes of sickness. int32 startLevel = sWorld.getConfig(CONFIG_INT32_DEATH_SICKNESS_LEVEL); - if(int32(getLevel()) >= startLevel) + if (int32(getLevel()) >= startLevel) { // set resurrection sickness CastSpell(this,SPELL_ID_PASSIVE_RESURRECTION_SICKNESS,true); // not full duration - if(int32(getLevel()) < startLevel+9) + if (int32(getLevel()) < startLevel+9) { int32 delta = (int32(getLevel()) - startLevel + 1)*MINUTE; @@ -4495,7 +4498,7 @@ Corpse* Player::CreateCorpse() // prevent existence 2 corpse for player SpawnCorpseBones(); - Corpse *corpse = new Corpse( (m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH) ? CORPSE_RESURRECTABLE_PVP : CORPSE_RESURRECTABLE_PVE ); + Corpse* corpse = new Corpse((m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH) ? CORPSE_RESURRECTABLE_PVP : CORPSE_RESURRECTABLE_PVE); SetPvPDeath(false); if (!corpse->Create(sObjectMgr.GenerateCorpseLowGuid(), this)) @@ -4526,11 +4529,11 @@ Corpse* Player::CreateCorpse() flags |= CORPSE_FLAG_HIDE_CLOAK; if (InBattleGround() && !InArena()) flags |= CORPSE_FLAG_LOOTABLE; // to be able to remove insignia - corpse->SetUInt32Value( CORPSE_FIELD_FLAGS, flags ); + corpse->SetUInt32Value(CORPSE_FIELD_FLAGS, flags); - corpse->SetUInt32Value( CORPSE_FIELD_DISPLAY_ID, GetNativeDisplayId() ); + corpse->SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, GetNativeDisplayId()); - corpse->SetUInt32Value( CORPSE_FIELD_GUILD, GetGuildId() ); + corpse->SetUInt32Value(CORPSE_FIELD_GUILD, GetGuildId()); uint32 iDisplayID; uint32 iIventoryType; @@ -4558,7 +4561,7 @@ Corpse* Player::CreateCorpse() void Player::SpawnCorpseBones() { - if(sObjectAccessor.ConvertCorpseForPlayer(GetObjectGuid())) + if (sObjectAccessor.ConvertCorpseForPlayer(GetObjectGuid())) if (!GetSession()->PlayerLogoutWithSave()) // at logout we will already store the player SaveToDB(); // prevent loading as ghost without corpse } @@ -4570,43 +4573,43 @@ Corpse* Player::GetCorpse() const void Player::DurabilityLossAll(double percent, bool inventory) { - for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) - if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) DurabilityLoss(pItem,percent); - if(inventory) + if (inventory) { // bags not have durability // for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) - if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) DurabilityLoss(pItem,percent); // keys not have durability //for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; ++i) - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) - if(Item* pItem = GetItemByPos( i, j )) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) + if (Item* pItem = GetItemByPos(i, j)) DurabilityLoss(pItem,percent); } } void Player::DurabilityLoss(Item* item, double percent) { - if(!item ) + if (!item) return; uint32 pMaxDurability = item ->GetUInt32Value(ITEM_FIELD_MAXDURABILITY); - if(!pMaxDurability) + if (!pMaxDurability) return; uint32 pDurabilityLoss = uint32(pMaxDurability*percent); - if(pDurabilityLoss < 1 ) + if (pDurabilityLoss < 1) pDurabilityLoss = 1; DurabilityPointsLoss(item,pDurabilityLoss); @@ -4614,26 +4617,26 @@ void Player::DurabilityLoss(Item* item, double percent) void Player::DurabilityPointsLossAll(int32 points, bool inventory) { - for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) - if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) DurabilityPointsLoss(pItem,points); - if(inventory) + if (inventory) { // bags not have durability // for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) - if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) DurabilityPointsLoss(pItem,points); // keys not have durability //for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; ++i) - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) - if(Item* pItem = GetItemByPos( i, j )) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) + if (Item* pItem = GetItemByPos(i, j)) DurabilityPointsLoss(pItem,points); } } @@ -4652,13 +4655,13 @@ void Player::DurabilityPointsLoss(Item* item, int32 points) if (pOldDurability != pNewDurability) { // modify item stats _before_ Durability set to 0 to pass _ApplyItemMods internal check - if ( pNewDurability == 0 && pOldDurability > 0 && item->IsEquipped()) + if (pNewDurability == 0 && pOldDurability > 0 && item->IsEquipped()) _ApplyItemMods(item,item->GetSlot(), false); item->SetUInt32Value(ITEM_FIELD_DURABILITY, pNewDurability); // modify item stats _after_ restore durability to pass _ApplyItemMods internal check - if ( pNewDurability > 0 && pOldDurability == 0 && item->IsEquipped()) + if (pNewDurability > 0 && pOldDurability == 0 && item->IsEquipped()) _ApplyItemMods(item,item->GetSlot(), true); item->SetState(ITEM_CHANGED, this); @@ -4667,7 +4670,7 @@ void Player::DurabilityPointsLoss(Item* item, int32 points) void Player::DurabilityPointLossForEquipSlot(EquipmentSlots slot) { - if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, slot )) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) DurabilityPointsLoss(pItem,1); } @@ -4675,15 +4678,15 @@ uint32 Player::DurabilityRepairAll(bool cost, float discountMod, bool guildBank) { uint32 TotalCost = 0; // equipped, backpack, bags itself - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) - TotalCost += DurabilityRepair(( (INVENTORY_SLOT_BAG_0 << 8) | i ),cost,discountMod, guildBank); + for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) + TotalCost += DurabilityRepair(((INVENTORY_SLOT_BAG_0 << 8) | i),cost,discountMod, guildBank); // bank, buyback and keys not repaired // items in inventory bags - for(int j = INVENTORY_SLOT_BAG_START; j < INVENTORY_SLOT_BAG_END; ++j) - for(int i = 0; i < MAX_BAG_SIZE; ++i) - TotalCost += DurabilityRepair(( (j << 8) | i ),cost,discountMod, guildBank); + for (int j = INVENTORY_SLOT_BAG_START; j < INVENTORY_SLOT_BAG_END; ++j) + for (int i = 0; i < MAX_BAG_SIZE; ++i) + TotalCost += DurabilityRepair(((j << 8) | i),cost,discountMod, guildBank); return TotalCost; } @@ -4692,32 +4695,32 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g Item* item = GetItemByPos(pos); uint32 TotalCost = 0; - if(!item) + if (!item) return TotalCost; uint32 maxDurability = item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY); - if(!maxDurability) + if (!maxDurability) return TotalCost; uint32 curDurability = item->GetUInt32Value(ITEM_FIELD_DURABILITY); - if(cost) + if (cost) { uint32 LostDurability = maxDurability - curDurability; - if(LostDurability>0) + if (LostDurability>0) { - ItemPrototype const *ditemProto = item->GetProto(); + ItemPrototype const* ditemProto = item->GetProto(); - DurabilityCostsEntry const *dcost = sDurabilityCostsStore.LookupEntry(ditemProto->ItemLevel); - if(!dcost) + DurabilityCostsEntry const* dcost = sDurabilityCostsStore.LookupEntry(ditemProto->ItemLevel); + if (!dcost) { sLog.outError("RepairDurability: Wrong item lvl %u", ditemProto->ItemLevel); return TotalCost; } uint32 dQualitymodEntryId = (ditemProto->Quality+1)*2; - DurabilityQualityEntry const *dQualitymodEntry = sDurabilityQualityStore.LookupEntry(dQualitymodEntryId); - if(!dQualitymodEntry) + DurabilityQualityEntry const* dQualitymodEntry = sDurabilityQualityStore.LookupEntry(dQualitymodEntryId); + if (!dQualitymodEntry) { sLog.outError("RepairDurability: Wrong dQualityModEntry %u", dQualitymodEntryId); return TotalCost; @@ -4770,7 +4773,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g return TotalCost; } else - ModifyMoney( -int32(costs) ); + ModifyMoney(-int32(costs)); } } @@ -4778,7 +4781,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g item->SetState(ITEM_CHANGED, this); // reapply mods for total broken and repaired item if equipped - if(IsEquipmentPos(pos) && !curDurability) + if (IsEquipmentPos(pos) && !curDurability) _ApplyItemMods(item,pos & 255, true); return TotalCost; } @@ -4788,7 +4791,7 @@ void Player::RepopAtGraveyard() // note: this can be called also when the player is alive // for example from WorldSession::HandleMovementOpcodes - AreaTableEntry const *zone = GetAreaEntryByAreaID(GetAreaId()); + AreaTableEntry const* zone = GetAreaEntryByAreaID(GetAreaId()); // Such zones are considered unreachable as a ghost and the player must be automatically revived if ((!isAlive() && zone && zone->flags & AREA_FLAG_NEED_FLY) || GetTransport()) @@ -4797,23 +4800,23 @@ void Player::RepopAtGraveyard() SpawnCorpseBones(); } - WorldSafeLocsEntry const *ClosestGrave = NULL; + WorldSafeLocsEntry const* ClosestGrave = NULL; // Special handle for battleground maps - if( BattleGround *bg = GetBattleGround() ) + if (BattleGround* bg = GetBattleGround()) ClosestGrave = bg->GetClosestGraveYard(this); else - ClosestGrave = sObjectMgr.GetClosestGraveYard( GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeam() ); + ClosestGrave = sObjectMgr.GetClosestGraveYard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeam()); // stop countdown until repop m_deathTimer = 0; // if no grave found, stay at the current location // and don't show spirit healer location - if(ClosestGrave) + if (ClosestGrave) { TeleportTo(ClosestGrave->map_id, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, GetOrientation()); - if(isDead()) // not send if alive, because it used in TeleportTo() + if (isDead()) // not send if alive, because it used in TeleportTo() { WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // show spirit healer position on minimap data << ClosestGrave->map_id; @@ -4825,12 +4828,12 @@ void Player::RepopAtGraveyard() } } -void Player::JoinedChannel(Channel *c) +void Player::JoinedChannel(Channel* c) { m_channels.push_back(c); } -void Player::LeftChannel(Channel *c) +void Player::LeftChannel(Channel* c) { m_channels.remove(c); } @@ -4849,34 +4852,34 @@ void Player::CleanupChannels() DEBUG_LOG("Player: channels cleaned up!"); } -void Player::UpdateLocalChannels(uint32 newZone ) +void Player::UpdateLocalChannels(uint32 newZone) { - if(m_channels.empty()) + if (m_channels.empty()) return; AreaTableEntry const* current_zone = GetAreaEntryByAreaID(newZone); - if(!current_zone) + if (!current_zone) return; ChannelMgr* cMgr = channelMgr(GetTeam()); - if(!cMgr) + if (!cMgr) return; std::string current_zone_name = current_zone->area_name[GetSession()->GetSessionDbcLocale()]; - for(JoinedChannelsList::iterator i = m_channels.begin(), next; i != m_channels.end(); i = next) + for (JoinedChannelsList::iterator i = m_channels.begin(), next; i != m_channels.end(); i = next) { next = i; ++next; // skip non built-in channels - if(!(*i)->IsConstant()) + if (!(*i)->IsConstant()) continue; ChatChannelsEntry const* ch = GetChannelEntryFor((*i)->GetChannelId()); - if(!ch) + if (!ch) continue; - if((ch->flags & 4) == 4) // global channel without zone name in pattern + if ((ch->flags & 4) == 4) // global channel without zone name in pattern continue; // new channel @@ -4900,7 +4903,7 @@ void Player::UpdateLocalChannels(uint32 newZone ) void Player::LeaveLFGChannel() { - for(JoinedChannelsList::iterator i = m_channels.begin(); i != m_channels.end(); ++i ) + for (JoinedChannelsList::iterator i = m_channels.begin(); i != m_channels.end(); ++i) { if ((*i)->IsLFG()) { @@ -4914,7 +4917,7 @@ void Player::UpdateDefense() { uint32 defense_skill_gain = sWorld.getConfig(CONFIG_UINT32_SKILL_GAIN_DEFENSE); - if(UpdateSkill(SKILL_DEFENSE,defense_skill_gain)) + if (UpdateSkill(SKILL_DEFENSE,defense_skill_gain)) { // update dependent from defense skill part UpdateDefenseBonusesMod(); @@ -4923,7 +4926,7 @@ void Player::UpdateDefense() void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply) { - if(modGroup >= BASEMOD_END || modType >= MOD_END) + if (modGroup >= BASEMOD_END || modType >= MOD_END) { sLog.outError("ERROR in HandleBaseModValue(): nonexistent BaseModGroup of wrong BaseModType!"); return; @@ -4931,13 +4934,13 @@ void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, floa float val = 1.0f; - switch(modType) + switch (modType) { case FLAT_MOD: m_auraBaseMod[modGroup][modType] += apply ? amount : -amount; break; case PCT_MOD: - if(amount <= -100.0f) + if (amount <= -100.0f) amount = -200.0f; val = (100.0f + amount) / 100.0f; @@ -4945,10 +4948,10 @@ void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, floa break; } - if(!CanModifyStats()) + if (!CanModifyStats()) return; - switch(modGroup) + switch (modGroup) { case CRIT_PERCENTAGE: UpdateCritPercentage(BASE_ATTACK); break; case RANGED_CRIT_PERCENTAGE: UpdateCritPercentage(RANGED_ATTACK); break; @@ -4960,13 +4963,13 @@ void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, floa float Player::GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const { - if(modGroup >= BASEMOD_END || modType > MOD_END) + if (modGroup >= BASEMOD_END || modType > MOD_END) { sLog.outError("trial to access nonexistent BaseModGroup or wrong BaseModType!"); return 0.0f; } - if(modType == PCT_MOD && m_auraBaseMod[modGroup][PCT_MOD] <= 0.0f) + if (modType == PCT_MOD && m_auraBaseMod[modGroup][PCT_MOD] <= 0.0f) return 0.0f; return m_auraBaseMod[modGroup][modType]; @@ -4974,13 +4977,13 @@ float Player::GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const float Player::GetTotalBaseModValue(BaseModGroup modGroup) const { - if(modGroup >= BASEMOD_END) + if (modGroup >= BASEMOD_END) { sLog.outError("wrong BaseModGroup in GetTotalBaseModValue()!"); return 0.0f; } - if(m_auraBaseMod[modGroup][PCT_MOD] <= 0.0f) + if (m_auraBaseMod[modGroup][PCT_MOD] <= 0.0f) return 0.0f; return m_auraBaseMod[modGroup][FLAT_MOD] * m_auraBaseMod[modGroup][PCT_MOD]; @@ -5002,8 +5005,8 @@ float Player::GetMeleeCritFromAgility() if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; - GtChanceToMeleeCritBaseEntry const *critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass-1); - GtChanceToMeleeCritEntry const *critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtChanceToMeleeCritBaseEntry const* critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass-1); + GtChanceToMeleeCritEntry const* critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); if (critBase==NULL || critRatio==NULL) return 0.0f; @@ -5011,37 +5014,37 @@ float Player::GetMeleeCritFromAgility() return crit*100.0f; } -void Player::GetDodgeFromAgility(float &diminishing, float &nondiminishing) +void Player::GetDodgeFromAgility(float& diminishing, float& nondiminishing) { // Table for base dodge values const float dodge_base[MAX_CLASSES] = { - 0.036640f, // Warrior - 0.034943f, // Paladin + 0.036640f, // Warrior + 0.034943f, // Paladin -0.040873f, // Hunter - 0.020957f, // Rogue - 0.034178f, // Priest - 0.036640f, // DK - 0.021080f, // Shaman - 0.036587f, // Mage - 0.024211f, // Warlock - 0.0f, // ?? - 0.056097f // Druid + 0.020957f, // Rogue + 0.034178f, // Priest + 0.036640f, // DK + 0.021080f, // Shaman + 0.036587f, // Mage + 0.024211f, // Warlock + 0.0f, // ?? + 0.056097f // Druid }; // Crit/agility to dodge/agility coefficient multipliers; 3.2.0 increased required agility by 15% const float crit_to_dodge[MAX_CLASSES] = { - 0.85f/1.15f, // Warrior - 1.00f/1.15f, // Paladin - 1.11f/1.15f, // Hunter - 2.00f/1.15f, // Rogue - 1.00f/1.15f, // Priest - 0.85f/1.15f, // DK - 1.60f/1.15f, // Shaman - 1.00f/1.15f, // Mage - 0.97f/1.15f, // Warlock (?) - 0.0f, // ?? - 2.00f/1.15f // Druid + 0.85f/1.15f, // Warrior + 1.00f/1.15f, // Paladin + 1.11f/1.15f, // Hunter + 2.00f/1.15f, // Rogue + 1.00f/1.15f, // Priest + 0.85f/1.15f, // DK + 1.60f/1.15f, // Shaman + 1.00f/1.15f, // Mage + 0.97f/1.15f, // Warlock (?) + 0.0f, // ?? + 2.00f/1.15f // Druid }; uint32 level = getLevel(); @@ -5050,7 +5053,7 @@ void Player::GetDodgeFromAgility(float &diminishing, float &nondiminishing) if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; // Dodge per agility is proportional to crit per agility, which is available from DBC files - GtChanceToMeleeCritEntry const *dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtChanceToMeleeCritEntry const* dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); if (dodgeRatio==NULL || pclass > MAX_CLASSES) return; @@ -5069,8 +5072,8 @@ float Player::GetSpellCritFromIntellect() if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; - GtChanceToSpellCritBaseEntry const *critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass-1); - GtChanceToSpellCritEntry const *critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtChanceToSpellCritBaseEntry const* critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass-1); + GtChanceToSpellCritEntry const* critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); if (critBase==NULL || critRatio==NULL) return 0.0f; @@ -5084,9 +5087,9 @@ float Player::GetRatingMultiplier(CombatRating cr) const if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; - GtCombatRatingsEntry const *Rating = sGtCombatRatingsStore.LookupEntry(cr*GT_MAX_LEVEL+level-1); + GtCombatRatingsEntry const* Rating = sGtCombatRatingsStore.LookupEntry(cr*GT_MAX_LEVEL+level-1); // gtOCTClassCombatRatingScalarStore.dbc starts with 1, CombatRating with zero, so cr+1 - GtOCTClassCombatRatingScalarEntry const *classRating = sGtOCTClassCombatRatingScalarStore.LookupEntry((getClass()-1)*GT_MAX_RATING+cr+1); + GtOCTClassCombatRatingScalarEntry const* classRating = sGtOCTClassCombatRatingScalarStore.LookupEntry((getClass()-1)*GT_MAX_RATING+cr+1); if (!Rating || !classRating) return 1.0f; // By default use minimum coefficient (not must be called) @@ -5119,8 +5122,8 @@ float Player::OCTRegenHPPerSpirit() if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; - GtOCTRegenHPEntry const *baseRatio = sGtOCTRegenHPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - GtRegenHPPerSptEntry const *moreRatio = sGtRegenHPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtOCTRegenHPEntry const* baseRatio = sGtOCTRegenHPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtRegenHPPerSptEntry const* moreRatio = sGtRegenHPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); if (baseRatio==NULL || moreRatio==NULL) return 0.0f; @@ -5141,7 +5144,7 @@ float Player::OCTRegenMPPerSpirit() if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; // GtOCTRegenMPEntry const *baseRatio = sGtOCTRegenMPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - GtRegenMPPerSptEntry const *moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtRegenMPPerSptEntry const* moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); if (moreRatio==NULL) return 0.0f; @@ -5190,7 +5193,7 @@ void Player::UpdateRating(CombatRating cr) // Apply bonus from SPELL_AURA_MOD_RATING_FROM_STAT // stat used stored in miscValueB for this aura AuraList const& modRatingFromStat = GetAurasByType(SPELL_AURA_MOD_RATING_FROM_STAT); - for(AuraList::const_iterator i = modRatingFromStat.begin();i != modRatingFromStat.end(); ++i) + for (AuraList::const_iterator i = modRatingFromStat.begin(); i != modRatingFromStat.end(); ++i) if ((*i)->GetMiscValue() & (1<GetMiscBValue())) * (*i)->GetModifier()->m_amount / 100.0f); if (amount < 0) @@ -5224,18 +5227,18 @@ void Player::UpdateRating(CombatRating cr) UpdateSpellHitChances(); break; case CR_CRIT_MELEE: - if(affectStats) + if (affectStats) { UpdateCritPercentage(BASE_ATTACK); UpdateCritPercentage(OFF_ATTACK); } break; case CR_CRIT_RANGED: - if(affectStats) + if (affectStats) UpdateCritPercentage(RANGED_ATTACK); break; case CR_CRIT_SPELL: - if(affectStats) + if (affectStats) UpdateAllSpellCritChances(); break; case CR_HIT_TAKEN_MELEE: // Implemented in Unit::MeleeMissChanceCalc @@ -5257,14 +5260,14 @@ void Player::UpdateRating(CombatRating cr) case CR_WEAPON_SKILL_RANGED: break; case CR_EXPERTISE: - if(affectStats) + if (affectStats) { UpdateExpertise(BASE_ATTACK); UpdateExpertise(OFF_ATTACK); } break; case CR_ARMOR_PENETRATION: - if(affectStats) + if (affectStats) UpdateArmorPenetration(); break; } @@ -5272,19 +5275,19 @@ void Player::UpdateRating(CombatRating cr) void Player::UpdateAllRatings() { - for(int cr = 0; cr < MAX_COMBAT_RATING; ++cr) + for (int cr = 0; cr < MAX_COMBAT_RATING; ++cr) UpdateRating(CombatRating(cr)); } void Player::SetRegularAttackTime() { - for(int i = 0; i < MAX_ATTACK; ++i) + for (int i = 0; i < MAX_ATTACK; ++i) { - Item *tmpitem = GetWeaponForAttack(WeaponAttackType(i),true,false); + Item* tmpitem = GetWeaponForAttack(WeaponAttackType(i),true,false); if (tmpitem) { - ItemPrototype const *proto = tmpitem->GetProto(); - if(proto->Delay) + ItemPrototype const* proto = tmpitem->GetProto(); + if (proto->Delay) SetAttackTime(WeaponAttackType(i), proto->Delay); else SetAttackTime(WeaponAttackType(i), BASE_ATTACK_TIME); @@ -5295,11 +5298,11 @@ void Player::SetRegularAttackTime() //skill+step, checking for max value bool Player::UpdateSkill(uint32 skill_id, uint32 step) { - if(!skill_id) + if (!skill_id) return false; SkillStatusMap::iterator itr = mSkillStatus.find(skill_id); - if(itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) return false; uint32 valueIndex = PLAYER_SKILL_VALUE_INDEX(itr->second.pos); @@ -5313,11 +5316,11 @@ bool Player::UpdateSkill(uint32 skill_id, uint32 step) if (value*512 < max*urand(0,512)) { uint32 new_value = value+step; - if(new_value > max) + if (new_value > max) new_value = max; SetUInt32Value(valueIndex,MAKE_SKILL_VALUE(new_value,max)); - if(itr->second.uState != SKILL_NEW) + if (itr->second.uState != SKILL_NEW) itr->second.uState = SKILL_CHANGED; GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL,skill_id); return true; @@ -5328,11 +5331,11 @@ bool Player::UpdateSkill(uint32 skill_id, uint32 step) inline int SkillGainChance(uint32 SkillValue, uint32 GrayLevel, uint32 GreenLevel, uint32 YellowLevel) { - if ( SkillValue >= GrayLevel ) + if (SkillValue >= GrayLevel) return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_GREY)*10; - if ( SkillValue >= GreenLevel ) + if (SkillValue >= GreenLevel) return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_GREEN)*10; - if ( SkillValue >= YellowLevel ) + if (SkillValue >= YellowLevel) return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_YELLOW)*10; return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_ORANGE)*10; } @@ -5343,7 +5346,7 @@ bool Player::UpdateCraftSkill(uint32 spellid) SkillLineAbilityMapBounds bounds = sSpellMgr.GetSkillLineAbilityMapBounds(spellid); - for(SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx) + for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx) { if (_spell_idx->second->skillId) { @@ -5360,16 +5363,16 @@ bool Player::UpdateCraftSkill(uint32 spellid) uint32 craft_skill_gain = sWorld.getConfig(CONFIG_UINT32_SKILL_GAIN_CRAFTING); return UpdateSkillPro(_spell_idx->second->skillId, SkillGainChance(SkillValue, - _spell_idx->second->max_value, - (_spell_idx->second->max_value + _spell_idx->second->min_value)/2, - _spell_idx->second->min_value), - craft_skill_gain); + _spell_idx->second->max_value, + (_spell_idx->second->max_value + _spell_idx->second->min_value)/2, + _spell_idx->second->min_value), + craft_skill_gain); } } return false; } -bool Player::UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator ) +bool Player::UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator) { DEBUG_LOG("UpdateGatherSkill(SkillId %d SkillLevel %d RedLevel %d)", SkillId, SkillValue, RedLevel); @@ -5384,7 +5387,7 @@ bool Player::UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLeve case SKILL_INSCRIPTION: return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator,gathering_skill_gain); case SKILL_SKINNING: - if( sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_SKINNING_STEPS)==0) + if (sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_SKINNING_STEPS)==0) return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator,gathering_skill_gain); else return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator) >> (SkillValue/sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_SKINNING_STEPS)), gathering_skill_gain); @@ -5418,17 +5421,17 @@ static uint32 bonusSkillLevels[] = {75,150,225,300,375,450}; bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) { DEBUG_LOG("UpdateSkillPro(SkillId %d, Chance %3.1f%%)", SkillId, Chance/10.0); - if ( !SkillId ) + if (!SkillId) return false; - if(Chance <= 0) // speedup in 0 chance case + if (Chance <= 0) // speedup in 0 chance case { DEBUG_LOG("Player::UpdateSkillPro Chance=%3.1f%% missed", Chance/10.0); return false; } SkillStatusMap::iterator itr = mSkillStatus.find(SkillId); - if(itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) return false; uint32 valueIndex = PLAYER_SKILL_VALUE_INDEX(itr->second.pos); @@ -5437,25 +5440,25 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) uint16 SkillValue = SKILL_VALUE(data); uint16 MaxValue = SKILL_MAX(data); - if ( !MaxValue || !SkillValue || SkillValue >= MaxValue ) + if (!MaxValue || !SkillValue || SkillValue >= MaxValue) return false; int32 Roll = irand(1,1000); - if ( Roll <= Chance ) + if (Roll <= Chance) { uint32 new_value = SkillValue+step; - if(new_value > MaxValue) + if (new_value > MaxValue) new_value = MaxValue; SetUInt32Value(valueIndex,MAKE_SKILL_VALUE(new_value,MaxValue)); - if(itr->second.uState != SKILL_NEW) + if (itr->second.uState != SKILL_NEW) itr->second.uState = SKILL_CHANGED; - for(uint32* bsl = &bonusSkillLevels[0]; *bsl; ++bsl) + for (uint32* bsl = &bonusSkillLevels[0]; *bsl; ++bsl) { - if((SkillValue < *bsl && new_value >= *bsl)) + if ((SkillValue < *bsl && new_value >= *bsl)) { - learnSkillRewardedSpells( SkillId, new_value); + learnSkillRewardedSpells(SkillId, new_value); break; } } @@ -5492,19 +5495,19 @@ void Player::UpdateWeaponSkill(WeaponAttackType attType) UpdateAllCritPercentages(); } -void Player::UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool defence) +void Player::UpdateCombatSkills(Unit* pVictim, WeaponAttackType attType, bool defence) { uint32 plevel = getLevel(); // if defense than pVictim == attacker uint32 greylevel = MaNGOS::XP::GetGrayLevel(plevel); uint32 moblevel = pVictim->GetLevelForTarget(this); - if(moblevel < greylevel) + if (moblevel < greylevel) return; if (moblevel > plevel + 5) moblevel = plevel + 5; uint32 lvldif = moblevel - greylevel; - if(lvldif < 3) + if (lvldif < 3) lvldif = 3; int32 skilldif = 5 * plevel - (defence ? GetBaseDefenseSkillValue() : GetBaseWeaponSkillValue(attType)); @@ -5515,14 +5518,14 @@ void Player::UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool de return; float chance = float(3 * lvldif * skilldif) / plevel; - if(!defence) + if (!defence) chance *= 0.1f * GetStat(STAT_INTELLECT); chance = chance < 1.0f ? 1.0f : chance; //minimum chance to increase skill is 1% - if(roll_chance_f(chance)) + if (roll_chance_f(chance)) { - if(defence) + if (defence) UpdateDefense(); else UpdateWeaponSkill(attType); @@ -5534,7 +5537,7 @@ void Player::UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool de void Player::ModifySkillBonus(uint32 skillid,int32 val, bool talent) { SkillStatusMap::const_iterator itr = mSkillStatus.find(skillid); - if(itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) return; uint32 bonusIndex = PLAYER_SKILL_BONUS_INDEX(itr->second.pos); @@ -5543,7 +5546,7 @@ void Player::ModifySkillBonus(uint32 skillid,int32 val, bool talent) int16 temp_bonus = SKILL_TEMP_BONUS(bonus_val); int16 perm_bonus = SKILL_PERM_BONUS(bonus_val); - if(talent) // permanent bonus stored in high part + if (talent) // permanent bonus stored in high part SetUInt32Value(bonusIndex,MAKE_SKILL_BONUS(temp_bonus,perm_bonus+val)); else // temporary/item bonus stored in low part SetUInt32Value(bonusIndex,MAKE_SKILL_BONUS(temp_bonus+val,perm_bonus)); @@ -5556,18 +5559,18 @@ void Player::UpdateSkillsForLevel() bool alwaysMaxSkill = sWorld.getConfig(CONFIG_BOOL_ALWAYS_MAX_SKILL_FOR_LEVEL); - for(SkillStatusMap::iterator itr = mSkillStatus.begin(); itr != mSkillStatus.end(); ++itr) + for (SkillStatusMap::iterator itr = mSkillStatus.begin(); itr != mSkillStatus.end(); ++itr) { - if(itr->second.uState == SKILL_DELETED) + if (itr->second.uState == SKILL_DELETED) continue; uint32 pskill = itr->first; - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(pskill); - if(!pSkill) + SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(pskill); + if (!pSkill) continue; - if(GetSkillRangeType(pSkill,false) != SKILL_RANGE_LEVEL) + if (GetSkillRangeType(pSkill,false) != SKILL_RANGE_LEVEL) continue; uint32 valueIndex = PLAYER_SKILL_VALUE_INDEX(itr->second.pos); @@ -5576,20 +5579,20 @@ void Player::UpdateSkillsForLevel() uint32 val = SKILL_VALUE(data); /// update only level dependent max skill values - if(max!=1) + if (max!=1) { /// maximize skill always - if(alwaysMaxSkill) + if (alwaysMaxSkill) { SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(maxSkill,maxSkill)); - if(itr->second.uState != SKILL_NEW) + if (itr->second.uState != SKILL_NEW) itr->second.uState = SKILL_CHANGED; GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, pskill); } - else if(max != maxconfskill) /// update max skill value if current max skill not maximized + else if (max != maxconfskill) /// update max skill value if current max skill not maximized { SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(val,maxSkill)); - if(itr->second.uState != SKILL_NEW) + if (itr->second.uState != SKILL_NEW) itr->second.uState = SKILL_CHANGED; } } @@ -5598,28 +5601,28 @@ void Player::UpdateSkillsForLevel() void Player::UpdateSkillsToMaxSkillsForLevel() { - for(SkillStatusMap::iterator itr = mSkillStatus.begin(); itr != mSkillStatus.end(); ++itr) + for (SkillStatusMap::iterator itr = mSkillStatus.begin(); itr != mSkillStatus.end(); ++itr) { - if(itr->second.uState == SKILL_DELETED) + if (itr->second.uState == SKILL_DELETED) continue; uint32 pskill = itr->first; - if( IsProfessionOrRidingSkill(pskill)) + if (IsProfessionOrRidingSkill(pskill)) continue; uint32 valueIndex = PLAYER_SKILL_VALUE_INDEX(itr->second.pos); uint32 data = GetUInt32Value(valueIndex); uint32 max = SKILL_MAX(data); - if(max > 1) + if (max > 1) { SetUInt32Value(valueIndex,MAKE_SKILL_VALUE(max,max)); - if(itr->second.uState != SKILL_NEW) + if (itr->second.uState != SKILL_NEW) itr->second.uState = SKILL_CHANGED; GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, pskill); } - if(pskill == SKILL_DEFENSE) + if (pskill == SKILL_DEFENSE) UpdateDefenseBonusesMod(); } } @@ -5628,21 +5631,21 @@ void Player::UpdateSkillsToMaxSkillsForLevel() // To "remove" a skill line, set it's values to zero void Player::SetSkill(uint16 id, uint16 currVal, uint16 maxVal, uint16 step /*=0*/) { - if(!id) + if (!id) return; SkillStatusMap::iterator itr = mSkillStatus.find(id); // has skill - if(itr != mSkillStatus.end() && itr->second.uState != SKILL_DELETED) + if (itr != mSkillStatus.end() && itr->second.uState != SKILL_DELETED) { - if(currVal) + if (currVal) { if (step) // need update step SetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos), MAKE_PAIR32(id, step)); // update value SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos), MAKE_SKILL_VALUE(currVal, maxVal)); - if(itr->second.uState != SKILL_NEW) + if (itr->second.uState != SKILL_NEW) itr->second.uState = SKILL_CHANGED; learnSkillRewardedSpells(id, currVal); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, id); @@ -5656,26 +5659,26 @@ void Player::SetSkill(uint16 id, uint16 currVal, uint16 maxVal, uint16 step /*=0 SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos), 0); // mark as deleted or simply remove from map if not saved yet - if(itr->second.uState != SKILL_NEW) + if (itr->second.uState != SKILL_NEW) itr->second.uState = SKILL_DELETED; else mSkillStatus.erase(itr); // remove all spells that related to this skill for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) - if(SkillLineAbilityEntry const *pAbility = sSkillLineAbilityStore.LookupEntry(j)) + if (SkillLineAbilityEntry const* pAbility = sSkillLineAbilityStore.LookupEntry(j)) if (pAbility->skillId == id) removeSpell(sSpellMgr.GetFirstSpellInChain(pAbility->spellId)); } } - else if(currVal) // add + else if (currVal) // add { for (int i = 0; i < PLAYER_MAX_SKILLS; ++i) { if (!GetUInt32Value(PLAYER_SKILL_INDEX(i))) { - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(id); - if(!pSkill) + SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(id); + if (!pSkill) { sLog.outError("Skill not found in SkillLineStore: skill #%u", id); return; @@ -5687,7 +5690,7 @@ void Player::SetSkill(uint16 id, uint16 currVal, uint16 maxVal, uint16 step /*=0 GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, id); // insert new entry or update if not deleted old entry yet - if(itr != mSkillStatus.end()) + if (itr != mSkillStatus.end()) { itr->second.pos = i; itr->second.uState = SKILL_CHANGED; @@ -5700,13 +5703,13 @@ void Player::SetSkill(uint16 id, uint16 currVal, uint16 maxVal, uint16 step /*=0 // temporary bonuses AuraList const& mModSkill = GetAurasByType(SPELL_AURA_MOD_SKILL); - for(AuraList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j) + for (AuraList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j) if ((*j)->GetModifier()->m_miscvalue == int32(id)) (*j)->ApplyModifier(true); // permanent bonuses AuraList const& mModSkillTalent = GetAurasByType(SPELL_AURA_MOD_SKILL_TALENT); - for(AuraList::const_iterator j = mModSkillTalent.begin(); j != mModSkillTalent.end(); ++j) + for (AuraList::const_iterator j = mModSkillTalent.begin(); j != mModSkillTalent.end(); ++j) if ((*j)->GetModifier()->m_miscvalue == int32(id)) (*j)->ApplyModifier(true); @@ -5720,7 +5723,7 @@ void Player::SetSkill(uint16 id, uint16 currVal, uint16 maxVal, uint16 step /*=0 bool Player::HasSkill(uint32 skill) const { - if(!skill) + if (!skill) return false; SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); @@ -5729,11 +5732,11 @@ bool Player::HasSkill(uint32 skill) const uint16 Player::GetSkillValue(uint32 skill) const { - if(!skill) + if (!skill) return 0; SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); - if(itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) return 0; uint32 bonus = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos)); @@ -5746,11 +5749,11 @@ uint16 Player::GetSkillValue(uint32 skill) const uint16 Player::GetMaxSkillValue(uint32 skill) const { - if(!skill) + if (!skill) return 0; SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); - if(itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) return 0; uint32 bonus = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos)); @@ -5763,11 +5766,11 @@ uint16 Player::GetMaxSkillValue(uint32 skill) const uint16 Player::GetPureMaxSkillValue(uint32 skill) const { - if(!skill) + if (!skill) return 0; SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); - if(itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) return 0; return SKILL_MAX(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos))); @@ -5775,11 +5778,11 @@ uint16 Player::GetPureMaxSkillValue(uint32 skill) const uint16 Player::GetBaseSkillValue(uint32 skill) const { - if(!skill) + if (!skill) return 0; SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); - if(itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) return 0; int32 result = int32(SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos)))); @@ -5789,11 +5792,11 @@ uint16 Player::GetBaseSkillValue(uint32 skill) const uint16 Player::GetPureSkillValue(uint32 skill) const { - if(!skill) + if (!skill) return 0; SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); - if(itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) return 0; return SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos))); @@ -5801,11 +5804,11 @@ uint16 Player::GetPureSkillValue(uint32 skill) const int16 Player::GetSkillPermBonusValue(uint32 skill) const { - if(!skill) + if (!skill) return 0; SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); - if(itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) return 0; return SKILL_PERM_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos))); @@ -5813,11 +5816,11 @@ int16 Player::GetSkillPermBonusValue(uint32 skill) const int16 Player::GetSkillTempBonusValue(uint32 skill) const { - if(!skill) + if (!skill) return 0; SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); - if(itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) return 0; return SKILL_TEMP_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos))); @@ -5825,98 +5828,98 @@ int16 Player::GetSkillTempBonusValue(uint32 skill) const void Player::SendInitialActionButtons() const { - DETAIL_LOG( "Initializing Action Buttons for '%u' spec '%u'", GetGUIDLow(), m_activeSpec); + DETAIL_LOG("Initializing Action Buttons for '%u' spec '%u'", GetGUIDLow(), m_activeSpec); WorldPacket data(SMSG_ACTION_BUTTONS, 1+(MAX_ACTION_BUTTONS*4)); data << uint8(1); // talent spec amount (in packet) ActionButtonList const& currentActionButtonList = m_actionButtons[m_activeSpec]; - for(uint8 button = 0; button < MAX_ACTION_BUTTONS; ++button) + for (uint8 button = 0; button < MAX_ACTION_BUTTONS; ++button) { ActionButtonList::const_iterator itr = currentActionButtonList.find(button); - if(itr != currentActionButtonList.end() && itr->second.uState != ACTIONBUTTON_DELETED) + if (itr != currentActionButtonList.end() && itr->second.uState != ACTIONBUTTON_DELETED) data << uint32(itr->second.packedData); else data << uint32(0); } - GetSession()->SendPacket( &data ); - DETAIL_LOG( "Action Buttons for '%u' spec '%u' Initialized", GetGUIDLow(), m_activeSpec ); + GetSession()->SendPacket(&data); + DETAIL_LOG("Action Buttons for '%u' spec '%u' Initialized", GetGUIDLow(), m_activeSpec); } void Player::SendLockActionButtons() const { - DETAIL_LOG( "Locking Action Buttons for '%u' spec '%u'", GetGUIDLow(), m_activeSpec); + DETAIL_LOG("Locking Action Buttons for '%u' spec '%u'", GetGUIDLow(), m_activeSpec); WorldPacket data(SMSG_ACTION_BUTTONS, 1); // sending 2 locks actions bars, neither user can remove buttons, nor client removes buttons at spell unlearn // they remain locked until server sends new action buttons data << uint8(2); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type, Player* player, bool msg) { - if(button >= MAX_ACTION_BUTTONS) + if (button >= MAX_ACTION_BUTTONS) { if (msg) { if (player) - sLog.outError( "Action %u not added into button %u for player %s: button must be < %u", action, button, player->GetName(), MAX_ACTION_BUTTONS ); + sLog.outError("Action %u not added into button %u for player %s: button must be < %u", action, button, player->GetName(), MAX_ACTION_BUTTONS); else - sLog.outError( "Table `playercreateinfo_action` have action %u into button %u : button must be < %u", action, button, MAX_ACTION_BUTTONS ); + sLog.outError("Table `playercreateinfo_action` have action %u into button %u : button must be < %u", action, button, MAX_ACTION_BUTTONS); } return false; } - if(action >= MAX_ACTION_BUTTON_ACTION_VALUE) + if (action >= MAX_ACTION_BUTTON_ACTION_VALUE) { if (msg) { if (player) - sLog.outError( "Action %u not added into button %u for player %s: action must be < %u", action, button, player->GetName(), MAX_ACTION_BUTTON_ACTION_VALUE ); + sLog.outError("Action %u not added into button %u for player %s: action must be < %u", action, button, player->GetName(), MAX_ACTION_BUTTON_ACTION_VALUE); else - sLog.outError( "Table `playercreateinfo_action` have action %u into button %u : action must be < %u", action, button, MAX_ACTION_BUTTON_ACTION_VALUE ); + sLog.outError("Table `playercreateinfo_action` have action %u into button %u : action must be < %u", action, button, MAX_ACTION_BUTTON_ACTION_VALUE); } return false; } - switch(type) + switch (type) { case ACTION_BUTTON_SPELL: { SpellEntry const* spellProto = sSpellStore.LookupEntry(action); - if(!spellProto) + if (!spellProto) { if (msg) { if (player) - sLog.outError( "Spell action %u not added into button %u for player %s: spell not exist", action, button, player->GetName() ); + sLog.outError("Spell action %u not added into button %u for player %s: spell not exist", action, button, player->GetName()); else - sLog.outError( "Table `playercreateinfo_action` have spell action %u into button %u: spell not exist", action, button ); + sLog.outError("Table `playercreateinfo_action` have spell action %u into button %u: spell not exist", action, button); } return false; } - if(player) + if (player) { - if(!player->HasSpell(spellProto->Id)) + if (!player->HasSpell(spellProto->Id)) { if (msg) - sLog.outError( "Spell action %u not added into button %u for player %s: player don't known this spell", action, button, player->GetName() ); + sLog.outError("Spell action %u not added into button %u for player %s: player don't known this spell", action, button, player->GetName()); return false; } - else if(IsPassiveSpell(spellProto)) + else if (IsPassiveSpell(spellProto)) { if (msg) - sLog.outError( "Spell action %u not added into button %u for player %s: spell is passive", action, button, player->GetName() ); + sLog.outError("Spell action %u not added into button %u for player %s: spell is passive", action, button, player->GetName()); return false; } // current range for button of totem bar is from ACTION_BUTTON_SHAMAN_TOTEMS_BAR to (but not including) ACTION_BUTTON_SHAMAN_TOTEMS_BAR + 12 - else if(button >= ACTION_BUTTON_SHAMAN_TOTEMS_BAR && button < (ACTION_BUTTON_SHAMAN_TOTEMS_BAR + 12) - && !spellProto->HasAttribute(SPELL_ATTR_EX7_TOTEM_SPELL)) + else if (button >= ACTION_BUTTON_SHAMAN_TOTEMS_BAR && button < (ACTION_BUTTON_SHAMAN_TOTEMS_BAR + 12) + && !spellProto->HasAttribute(SPELL_ATTR_EX7_TOTEM_SPELL)) { if (msg) - sLog.outError( "Spell action %u not added into button %u for player %s: attempt to add non totem spell to totem bar", action, button, player->GetName() ); + sLog.outError("Spell action %u not added into button %u for player %s: attempt to add non totem spell to totem bar", action, button, player->GetName()); return false; } } @@ -5924,14 +5927,14 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type, Pl } case ACTION_BUTTON_ITEM: { - if(!ObjectMgr::GetItemPrototype(action)) + if (!ObjectMgr::GetItemPrototype(action)) { if (msg) { if (player) - sLog.outError( "Item action %u not added into button %u for player %s: item not exist", action, button, player->GetName() ); + sLog.outError("Item action %u not added into button %u for player %s: item not exist", action, button, player->GetName()); else - sLog.outError( "Table `playercreateinfo_action` have item action %u into button %u: item not exist", action, button ); + sLog.outError("Table `playercreateinfo_action` have item action %u into button %u: item not exist", action, button); } return false; } @@ -5988,20 +5991,20 @@ ActionButton const* Player::GetActionButton(uint8 button) bool Player::SetPosition(float x, float y, float z, float orientation, bool teleport) { // prevent crash when a bad coord is sent by the client - if(!MaNGOS::IsValidMapCoord(x,y,z,orientation)) + if (!MaNGOS::IsValidMapCoord(x,y,z,orientation)) { DEBUG_LOG("Player::SetPosition(%f, %f, %f, %f, %d) .. bad coordinates for player %d!",x,y,z,orientation,teleport,GetGUIDLow()); return false; } - Map *m = GetMap(); + Map* m = GetMap(); const float old_x = GetPositionX(); const float old_y = GetPositionY(); const float old_z = GetPositionZ(); const float old_r = GetOrientation(); - if( teleport || old_x != x || old_y != y || old_z != z || old_r != orientation ) + if (teleport || old_x != x || old_y != y || old_z != z || old_r != orientation) { if (teleport || old_x != x || old_y != y || old_z != z) RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING); @@ -6044,7 +6047,7 @@ void Player::SaveRecallPosition() m_recallO = GetOrientation(); } -void Player::SendMessageToSet(WorldPacket *data, bool self) +void Player::SendMessageToSet(WorldPacket* data, bool self) { if (IsInWorld()) GetMap()->MessageBroadcast(this, data, false); @@ -6055,7 +6058,7 @@ void Player::SendMessageToSet(WorldPacket *data, bool self) GetSession()->SendPacket(data); } -void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self) +void Player::SendMessageToSetInRange(WorldPacket* data, float dist, bool self) { if (IsInWorld()) GetMap()->MessageDistBroadcast(this, data, dist, false); @@ -6064,7 +6067,7 @@ void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self) GetSession()->SendPacket(data); } -void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only) +void Player::SendMessageToSetInRange(WorldPacket* data, float dist, bool self, bool own_team_only) { if (IsInWorld()) GetMap()->MessageDistBroadcast(this, data, dist, false, own_team_only); @@ -6073,7 +6076,7 @@ void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self, b GetSession()->SendPacket(data); } -void Player::SendDirectMessage(WorldPacket *data) +void Player::SendDirectMessage(WorldPacket* data) { GetSession()->SendPacket(data); } @@ -6137,12 +6140,12 @@ void Player::CheckAreaExploreAndOutdoor() GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA); - AreaTableEntry const *p = GetAreaEntryByAreaFlagAndMap(areaFlag,GetMapId()); - if(!p) + AreaTableEntry const* p = GetAreaEntryByAreaFlagAndMap(areaFlag,GetMapId()); + if (!p) { sLog.outError("PLAYER: Player %u discovered unknown area (x: %f y: %f map: %u", GetGUIDLow(), GetPositionX(),GetPositionY(),GetMapId()); } - else if(p->area_level > 0) + else if (p->area_level > 0) { uint32 area = p->ID; if (getLevel() >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) @@ -6172,7 +6175,7 @@ void Player::CheckAreaExploreAndOutdoor() XP = uint32(sObjectMgr.GetBaseXP(p->area_level)*sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE)); } - GiveXP( XP, NULL ); + GiveXP(XP, NULL); SendExplorationExperience(area,XP); } DETAIL_LOG("PLAYER: Player %u discovered a new area: %u", GetGUIDLow(), area); @@ -6189,7 +6192,7 @@ Team Player::TeamForRace(uint8 race) return ALLIANCE; } - switch(rEntry->TeamID) + switch (rEntry->TeamID) { case 7: return ALLIANCE; case 1: return HORDE; @@ -6202,7 +6205,7 @@ Team Player::TeamForRace(uint8 race) uint32 Player::getFactionForRace(uint8 race) { ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race); - if(!rEntry) + if (!rEntry) { sLog.outError("Race %u not found in DBC: wrong DBC files?",uint32(race)); return 0; @@ -6258,7 +6261,7 @@ int32 Player::CalculateReputationGain(ReputationSource source, int32 rep, int32 return 0; // Multiply result with the faction specific rate - if (const RepRewardRate *repData = sObjectMgr.GetRepRewardRate(faction)) + if (const RepRewardRate* repData = sObjectMgr.GetRepRewardRate(faction)) { float repRate = 0.0f; switch (source) @@ -6285,22 +6288,22 @@ int32 Player::CalculateReputationGain(ReputationSource source, int32 rep, int32 } //Calculates how many reputation points player gains in victim's enemy factions -void Player::RewardReputation(Unit *pVictim, float rate) +void Player::RewardReputation(Unit* pVictim, float rate) { - if(!pVictim || pVictim->GetTypeId() == TYPEID_PLAYER) + if (!pVictim || pVictim->GetTypeId() == TYPEID_PLAYER) return; // used current difficulty creature entry instead normal version (GetEntry()) ReputationOnKillEntry const* Rep = sObjectMgr.GetReputationOnKillEntry(((Creature*)pVictim)->GetCreatureInfo()->Entry); - if(!Rep) + if (!Rep) return; - if(Rep->repfaction1 && (!Rep->team_dependent || GetTeam()==ALLIANCE)) + if (Rep->repfaction1 && (!Rep->team_dependent || GetTeam()==ALLIANCE)) { int32 donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, Rep->repvalue1, Rep->repfaction1, pVictim->getLevel()); donerep1 = int32(donerep1*rate); - FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1); + FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1); uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1); if (factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1) GetReputationMgr().ModifyReputation(factionEntry1, donerep1); @@ -6308,17 +6311,17 @@ void Player::RewardReputation(Unit *pVictim, float rate) // Wiki: Team factions value divided by 2 if (factionEntry1 && Rep->is_teamaward1) { - FactionEntry const *team1_factionEntry = sFactionStore.LookupEntry(factionEntry1->team); - if(team1_factionEntry) + FactionEntry const* team1_factionEntry = sFactionStore.LookupEntry(factionEntry1->team); + if (team1_factionEntry) GetReputationMgr().ModifyReputation(team1_factionEntry, donerep1 / 2); } } - if(Rep->repfaction2 && (!Rep->team_dependent || GetTeam()==HORDE)) + if (Rep->repfaction2 && (!Rep->team_dependent || GetTeam()==HORDE)) { int32 donerep2 = CalculateReputationGain(REPUTATION_SOURCE_KILL, Rep->repvalue2, Rep->repfaction2, pVictim->getLevel()); donerep2 = int32(donerep2*rate); - FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2); + FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2); uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2); if (factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2) GetReputationMgr().ModifyReputation(factionEntry2, donerep2); @@ -6326,18 +6329,18 @@ void Player::RewardReputation(Unit *pVictim, float rate) // Wiki: Team factions value divided by 2 if (factionEntry2 && Rep->is_teamaward2) { - FactionEntry const *team2_factionEntry = sFactionStore.LookupEntry(factionEntry2->team); - if(team2_factionEntry) + FactionEntry const* team2_factionEntry = sFactionStore.LookupEntry(factionEntry2->team); + if (team2_factionEntry) GetReputationMgr().ModifyReputation(team2_factionEntry, donerep2 / 2); } } } //Calculate how many reputation points player gain with the quest -void Player::RewardReputation(Quest const *pQuest) +void Player::RewardReputation(Quest const* pQuest) { // quest reputation reward/loss - for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) + for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) { if (!pQuest->RewRepFaction[i]) continue; @@ -6355,7 +6358,7 @@ void Player::RewardReputation(Quest const *pQuest) uint32 row = ((pQuest->RewRepValueId[i] < 0) ? 1 : 0) + 1; uint32 field = abs(pQuest->RewRepValueId[i]); - if (const QuestFactionRewardEntry *pRow = sQuestFactionRewardStore.LookupEntry(row)) + if (const QuestFactionRewardEntry* pRow = sQuestFactionRewardStore.LookupEntry(row)) { int32 repPoints = pRow->rewardValue[field]; @@ -6384,14 +6387,14 @@ void Player::UpdateHonorFields() time_t now = time(NULL); time_t today = (time(NULL) / DAY) * DAY; - if(m_lastHonorUpdateTime < today) + if (m_lastHonorUpdateTime < today) { time_t yesterday = today - DAY; uint16 kills_today = PAIR32_LOPART(GetUInt32Value(PLAYER_FIELD_KILLS)); // update yesterday's contribution - if(m_lastHonorUpdateTime >= yesterday ) + if (m_lastHonorUpdateTime >= yesterday) { SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION)); @@ -6413,7 +6416,7 @@ void Player::UpdateHonorFields() ///Calculate the amount of honor gained based on the victim ///and the size of the group for which the honor is divided ///An exact honor value can also be given (overriding the calcs) -bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor) +bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, float honor) { // do not reward honor in arenas, but enable onkill spellproc if (InArena()) @@ -6446,7 +6449,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor) if (uVictim->GetTypeId() == TYPEID_PLAYER) { - Player *pVictim = (Player *)uVictim; + Player* pVictim = (Player*)uVictim; if (GetTeam() == pVictim->GetTeam() && !sWorld.IsFFAPvPRealm()) return false; @@ -6464,7 +6467,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor) // [29..38] Other title and player name // [39+] Nothing uint32 victim_title = pVictim->GetUInt32Value(PLAYER_CHOSEN_TITLE); - // Get Killer titles, CharTitlesEntry::bit_index + // Get Killer titles, CharTitlesEntry::bit_index // Ranks: // title[1..14] -> rank[5..18] // title[15..28] -> rank[5..18] @@ -6501,7 +6504,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor) } else { - Creature *cVictim = (Creature *)uVictim; + Creature* cVictim = (Creature*)uVictim; if (!cVictim->IsRacialLeader()) return false; @@ -6591,7 +6594,7 @@ uint32 Player::GetGuildIdFromDB(ObjectGuid guid) uint32 Player::GetRankFromDB(ObjectGuid guid) { - QueryResult *result = CharacterDatabase.PQuery("SELECT rank FROM guild_member WHERE guid='%u'", guid.GetCounter()); + QueryResult* result = CharacterDatabase.PQuery("SELECT rank FROM guild_member WHERE guid='%u'", guid.GetCounter()); if (result) { uint32 v = result->Fetch()[0].GetUInt32(); @@ -6604,7 +6607,7 @@ uint32 Player::GetRankFromDB(ObjectGuid guid) uint32 Player::GetArenaTeamIdFromDB(ObjectGuid guid, ArenaType type) { - QueryResult *result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u' AND type='%u' LIMIT 1", guid.GetCounter(), type); + QueryResult* result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u' AND type='%u' LIMIT 1", guid.GetCounter(), type); if (!result) return 0; @@ -6616,7 +6619,7 @@ uint32 Player::GetArenaTeamIdFromDB(ObjectGuid guid, ArenaType type) uint32 Player::GetZoneIdFromDB(ObjectGuid guid) { uint32 lowguid = guid.GetCounter(); - QueryResult *result = CharacterDatabase.PQuery("SELECT zone FROM characters WHERE guid='%u'", lowguid); + QueryResult* result = CharacterDatabase.PQuery("SELECT zone FROM characters WHERE guid='%u'", lowguid); if (!result) return 0; Field* fields = result->Fetch(); @@ -6627,7 +6630,7 @@ uint32 Player::GetZoneIdFromDB(ObjectGuid guid) { // stored zone is zero, use generic and slow zone detection result = CharacterDatabase.PQuery("SELECT map,position_x,position_y,position_z FROM characters WHERE guid='%u'", lowguid); - if( !result ) + if (!result) return 0; fields = result->Fetch(); uint32 map = fields[0].GetUInt32(); @@ -6649,7 +6652,7 @@ uint32 Player::GetLevelFromDB(ObjectGuid guid) { uint32 lowguid = guid.GetCounter(); - QueryResult *result = CharacterDatabase.PQuery("SELECT level FROM characters WHERE guid='%u'", lowguid); + QueryResult* result = CharacterDatabase.PQuery("SELECT level FROM characters WHERE guid='%u'", lowguid); if (!result) return 0; @@ -6677,7 +6680,7 @@ void Player::UpdateArea(uint32 newArea) { // remove ffa flag only if not ffapvp realm // removal in sanctuaries and capitals is handled in zone update - if(IsFFAPvP() && !sWorld.IsFFAPvPRealm()) + if (IsFFAPvP() && !sWorld.IsFFAPvPRealm()) SetFFAPvP(false); } @@ -6698,27 +6701,27 @@ void Player::UpdateArea(uint32 newArea) bool Player::CanUseOutdoorCapturePoint() { return CanUseCapturePoint() && - (IsPvP() || sWorld.IsPvPRealm()) && - !HasMovementFlag(MOVEFLAG_FLYING) && - !IsTaxiFlying() && - !isGameMaster(); + (IsPvP() || sWorld.IsPvPRealm()) && + !HasMovementFlag(MOVEFLAG_FLYING) && + !IsTaxiFlying() && + !isGameMaster(); } void Player::UpdateZone(uint32 newZone, uint32 newArea) { AreaTableEntry const* zone = GetAreaEntryByAreaID(newZone); - if(!zone) + if (!zone) return; - if(m_zoneUpdateId != newZone) + if (m_zoneUpdateId != newZone) { SendInitWorldStates(newZone, newArea); // only if really enters to new zone, not just area change, works strange... if (sWorld.getConfig(CONFIG_BOOL_WEATHER)) { - if(Weather *wth = sWorld.FindWeather(zone->ID)) + if (Weather* wth = sWorld.FindWeather(zone->ID)) wth->SendWeatherUpdateToPlayer(this); - else if(!sWorld.AddWeather(zone->ID)) + else if (!sWorld.AddWeather(zone->ID)) { // send fine weather packet to remove old zone's weather Weather::SendFineWeatherUpdateToPlayer(this); @@ -6734,7 +6737,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) // in PvP, any not controlled zone (except zone->team == 6, default case) // in PvE, only opposition team capital - switch(zone->team) + switch (zone->team) { case AREATEAM_ALLY: pvpInfo.inHostileArea = GetTeam() != ALLIANCE && (sWorld.IsPvPRealm() || zone->flags & AREA_FLAG_CAPITAL); @@ -6751,21 +6754,21 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) break; } - if(pvpInfo.inHostileArea) // in hostile area + if (pvpInfo.inHostileArea) // in hostile area { - if(!IsPvP() || pvpInfo.endTimer != 0) + if (!IsPvP() || pvpInfo.endTimer != 0) UpdatePvP(true, true); } else // in friendly area { - if(IsPvP() && !HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_IN_PVP) && pvpInfo.endTimer == 0) + if (IsPvP() && !HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_IN_PVP) && pvpInfo.endTimer == 0) pvpInfo.endTimer = time(0); // start toggle-off } - if(zone->flags & AREA_FLAG_SANCTUARY) // in sanctuary + if (zone->flags & AREA_FLAG_SANCTUARY) // in sanctuary { SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SANCTUARY); - if(sWorld.IsFFAPvPRealm()) + if (sWorld.IsFFAPvPRealm()) SetFFAPvP(false); } else @@ -6773,7 +6776,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SANCTUARY); } - if(zone->flags & AREA_FLAG_CAPITAL) // in capital city + if (zone->flags & AREA_FLAG_CAPITAL) // in capital city SetRestType(REST_TYPE_IN_CITY); else if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) && GetRestType() != REST_TYPE_IN_TAVERN) // resting and not in tavern (leave city then); tavern leave handled in CheckAreaExploreAndOutdoor @@ -6781,17 +6784,17 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) // remove items with area/map limitations (delete only for alive player to allow back in ghost mode) // if player resurrected at teleport this will be applied in resurrect code - if(isAlive()) - DestroyZoneLimitedItem( true, newZone ); + if (isAlive()) + DestroyZoneLimitedItem(true, newZone); // check some item equip limitations (in result lost CanTitanGrip at talent reset, for example) AutoUnequipOffhandIfNeed(); // recent client version not send leave/join channel packets for built-in local channels - UpdateLocalChannels( newZone ); + UpdateLocalChannels(newZone); // group update - if(GetGroup()) + if (GetGroup()) SetGroupUpdateFlag(GROUP_UPDATE_FLAG_ZONE); UpdateZoneDependentAuras(); @@ -6878,7 +6881,7 @@ void Player::DuelComplete(DuelCompleteType type) auras2remove.push_back(i->second->GetId()); } - for(size_t i=0; iopponent->RemoveAurasDueToSpell(auras2remove[i]); auras2remove.clear(); @@ -6916,46 +6919,46 @@ void Player::DuelComplete(DuelCompleteType type) //---------------------------------------------------------// -void Player::_ApplyItemMods(Item *item, uint8 slot,bool apply) +void Player::_ApplyItemMods(Item* item, uint8 slot,bool apply) { - if(slot >= INVENTORY_SLOT_BAG_END || !item) + if (slot >= INVENTORY_SLOT_BAG_END || !item) return; // not apply/remove mods for broken item - if(item->IsBroken()) + if (item->IsBroken()) return; - ItemPrototype const *proto = item->GetProto(); + ItemPrototype const* proto = item->GetProto(); - if(!proto) + if (!proto) return; DETAIL_LOG("applying mods for item %u ",item->GetGUIDLow()); uint32 attacktype = Player::GetAttackBySlot(slot); - if(attacktype < MAX_ATTACK) + if (attacktype < MAX_ATTACK) _ApplyWeaponDependentAuraMods(item,WeaponAttackType(attacktype),apply); _ApplyItemBonuses(proto,slot,apply); - if( slot==EQUIPMENT_SLOT_RANGED ) + if (slot==EQUIPMENT_SLOT_RANGED) _ApplyAmmoBonuses(); ApplyItemEquipSpell(item,apply); ApplyEnchantment(item, apply); - if(proto->Socket[0].Color) //only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items + if (proto->Socket[0].Color) //only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items CorrectMetaGemEnchants(slot, apply); DEBUG_LOG("_ApplyItemMods complete."); } -void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool apply, bool only_level_scale /*= false*/) +void Player::_ApplyItemBonuses(ItemPrototype const* proto, uint8 slot, bool apply, bool only_level_scale /*= false*/) { if (slot >= INVENTORY_SLOT_BAG_END || !proto) return; - ScalingStatDistributionEntry const *ssd = proto->ScalingStatDistribution ? sScalingStatDistributionStore.LookupEntry(proto->ScalingStatDistribution) : NULL; + ScalingStatDistributionEntry const* ssd = proto->ScalingStatDistribution ? sScalingStatDistributionStore.LookupEntry(proto->ScalingStatDistribution) : NULL; if (only_level_scale && !ssd) return; @@ -6964,7 +6967,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl if (ssd && ssd_level > ssd->MaxLevel) ssd_level = ssd->MaxLevel; - ScalingStatValuesEntry const *ssv = proto->ScalingStatValue ? sScalingStatValuesStore.LookupEntry(ssd_level) : NULL; + ScalingStatValuesEntry const* ssv = proto->ScalingStatValue ? sScalingStatValuesStore.LookupEntry(ssd_level) : NULL; if (only_level_scale && !ssv) return; @@ -6988,7 +6991,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl val = proto->ItemStat[i].ItemStatValue; } - if(val == 0) + if (val == 0) continue; switch (statType) @@ -7132,7 +7135,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl case ITEM_MOD_BLOCK_VALUE: HandleBaseModValue(SHIELD_BLOCK_VALUE, FLAT_MOD, float(val), apply); break; - // deprecated item mods + // deprecated item mods case ITEM_MOD_FERAL_ATTACK_POWER: case ITEM_MOD_SPELL_HEALING_DONE: case ITEM_MOD_SPELL_DAMAGE_DONE: @@ -7141,7 +7144,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl } // Apply Spell Power from ScalingStatValue if set - if(ssv) + if (ssv) { if (int32 spellbonus = ssv->getSpellBonus(proto->ScalingStatValue)) ApplySpellPowerBonus(spellbonus, apply); @@ -7160,7 +7163,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl if (armor) { - switch(proto->InventoryType) + switch (proto->InventoryType) { case INVTYPE_TRINKET: case INVTYPE_NECK: @@ -7198,13 +7201,13 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl WeaponAttackType attType = BASE_ATTACK; float damage = 0.0f; - if( slot == EQUIPMENT_SLOT_RANGED && ( - proto->InventoryType == INVTYPE_RANGED || proto->InventoryType == INVTYPE_THROWN || - proto->InventoryType == INVTYPE_RANGEDRIGHT )) + if (slot == EQUIPMENT_SLOT_RANGED && ( + proto->InventoryType == INVTYPE_RANGED || proto->InventoryType == INVTYPE_THROWN || + proto->InventoryType == INVTYPE_RANGEDRIGHT)) { attType = RANGED_ATTACK; } - else if(slot==EQUIPMENT_SLOT_OFFHAND) + else if (slot==EQUIPMENT_SLOT_OFFHAND) { attType = OFF_ATTACK; } @@ -7222,14 +7225,14 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl maxDamage = 1.3f * average; } } - if (minDamage > 0 ) + if (minDamage > 0) { damage = apply ? minDamage : BASE_MINDAMAGE; SetBaseWeaponDamage(attType, MINDAMAGE, damage); //sLog.outError("applying mindam: assigning %f to weapon mindamage, now is: %f", damage, GetWeaponDamageRange(attType, MINDAMAGE)); } - if (maxDamage > 0 ) + if (maxDamage > 0) { damage = apply ? maxDamage : BASE_MAXDAMAGE; SetBaseWeaponDamage(attType, MAXDAMAGE, damage); @@ -7254,67 +7257,67 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl if (proto->Delay) { - if(slot == EQUIPMENT_SLOT_RANGED) + if (slot == EQUIPMENT_SLOT_RANGED) SetAttackTime(RANGED_ATTACK, apply ? proto->Delay: BASE_ATTACK_TIME); - else if(slot==EQUIPMENT_SLOT_MAINHAND) + else if (slot==EQUIPMENT_SLOT_MAINHAND) SetAttackTime(BASE_ATTACK, apply ? proto->Delay: BASE_ATTACK_TIME); - else if(slot==EQUIPMENT_SLOT_OFFHAND) + else if (slot==EQUIPMENT_SLOT_OFFHAND) SetAttackTime(OFF_ATTACK, apply ? proto->Delay: BASE_ATTACK_TIME); } - if(CanModifyStats() && (damage || proto->Delay)) + if (CanModifyStats() && (damage || proto->Delay)) UpdateDamagePhysical(attType); } -void Player::_ApplyWeaponDependentAuraMods(Item *item,WeaponAttackType attackType,bool apply) +void Player::_ApplyWeaponDependentAuraMods(Item* item,WeaponAttackType attackType,bool apply) { AuraList const& auraCritList = GetAurasByType(SPELL_AURA_MOD_CRIT_PERCENT); - for(AuraList::const_iterator itr = auraCritList.begin(); itr!=auraCritList.end();++itr) + for (AuraList::const_iterator itr = auraCritList.begin(); itr!=auraCritList.end(); ++itr) _ApplyWeaponDependentAuraCritMod(item,attackType,*itr,apply); AuraList const& auraDamageFlatList = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE); - for(AuraList::const_iterator itr = auraDamageFlatList.begin(); itr!=auraDamageFlatList.end();++itr) + for (AuraList::const_iterator itr = auraDamageFlatList.begin(); itr!=auraDamageFlatList.end(); ++itr) _ApplyWeaponDependentAuraDamageMod(item,attackType,*itr,apply); AuraList const& auraDamagePCTList = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); - for(AuraList::const_iterator itr = auraDamagePCTList.begin(); itr!=auraDamagePCTList.end();++itr) + for (AuraList::const_iterator itr = auraDamagePCTList.begin(); itr!=auraDamagePCTList.end(); ++itr) _ApplyWeaponDependentAuraDamageMod(item,attackType,*itr,apply); } -void Player::_ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply) +void Player::_ApplyWeaponDependentAuraCritMod(Item* item, WeaponAttackType attackType, Aura* aura, bool apply) { // generic not weapon specific case processes in aura code - if(aura->GetSpellProto()->EquippedItemClass == -1) + if (aura->GetSpellProto()->EquippedItemClass == -1) return; BaseModGroup mod = BASEMOD_END; - switch(attackType) + switch (attackType) { case BASE_ATTACK: mod = CRIT_PERCENTAGE; break; - case OFF_ATTACK: mod = OFFHAND_CRIT_PERCENTAGE;break; + case OFF_ATTACK: mod = OFFHAND_CRIT_PERCENTAGE; break; case RANGED_ATTACK: mod = RANGED_CRIT_PERCENTAGE; break; default: return; } if (item->IsFitToSpellRequirements(aura->GetSpellProto())) { - HandleBaseModValue(mod, FLAT_MOD, float (aura->GetModifier()->m_amount), apply); + HandleBaseModValue(mod, FLAT_MOD, float(aura->GetModifier()->m_amount), apply); } } -void Player::_ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply) +void Player::_ApplyWeaponDependentAuraDamageMod(Item* item, WeaponAttackType attackType, Aura* aura, bool apply) { // ignore spell mods for not wands Modifier const* modifier = aura->GetModifier(); - if((modifier->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)==0 && (getClassMask() & CLASSMASK_WAND_USERS)==0) + if ((modifier->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)==0 && (getClassMask() & CLASSMASK_WAND_USERS)==0) return; // generic not weapon specific case processes in aura code - if(aura->GetSpellProto()->EquippedItemClass == -1) + if (aura->GetSpellProto()->EquippedItemClass == -1) return; UnitMods unitMod = UNIT_MOD_END; - switch(attackType) + switch (attackType) { case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break; case OFF_ATTACK: unitMod = UNIT_MOD_DAMAGE_OFFHAND; break; @@ -7323,7 +7326,7 @@ void Player::_ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType att } UnitModifierType unitModType = TOTAL_VALUE; - switch(modifier->m_auraname) + switch (modifier->m_auraname) { case SPELL_AURA_MOD_DAMAGE_DONE: unitModType = TOTAL_VALUE; break; case SPELL_AURA_MOD_DAMAGE_PERCENT_DONE: unitModType = TOTAL_PCT; break; @@ -7336,13 +7339,13 @@ void Player::_ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType att } } -void Player::ApplyItemEquipSpell(Item *item, bool apply, bool form_change) +void Player::ApplyItemEquipSpell(Item* item, bool apply, bool form_change) { - if(!item) + if (!item) return; - ItemPrototype const *proto = item->GetProto(); - if(!proto) + ItemPrototype const* proto = item->GetProto(); + if (!proto) return; for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) @@ -7350,7 +7353,7 @@ void Player::ApplyItemEquipSpell(Item *item, bool apply, bool form_change) _Spell const& spellData = proto->Spells[i]; // no spell - if(!spellData.SpellId ) + if (!spellData.SpellId) continue; if (apply) @@ -7370,7 +7373,7 @@ void Player::ApplyItemEquipSpell(Item *item, bool apply, bool form_change) // check if it is valid spell SpellEntry const* spellproto = sSpellStore.LookupEntry(spellData.SpellId); - if(!spellproto) + if (!spellproto) continue; ApplyEquipSpell(spellproto,item,apply,form_change); @@ -7379,7 +7382,7 @@ void Player::ApplyItemEquipSpell(Item *item, bool apply, bool form_change) void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change) { - if(apply) + if (apply) { // Cannot be used in this stance/form if (GetErrorAtShapeshiftedCast(spellInfo, GetShapeshiftForm()) != SPELL_CAST_OK) @@ -7393,17 +7396,17 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellInfo->Id); for (SpellAuraHolderMap::const_iterator iter = spair.first; iter != spair.second; ++iter) { - if(!item || iter->second->GetCastItemGuid() == item->GetObjectGuid()) + if (!item || iter->second->GetCastItemGuid() == item->GetObjectGuid()) { found = true; break; } } - if(found) + if (found) break; } - if(found) // and skip re-cast already active aura at form change + if (found) // and skip re-cast already active aura at form change return; } @@ -7431,7 +7434,7 @@ void Player::UpdateEquipSpellsAtFormChange() { for (int i = 0; i < INVENTORY_SLOT_BAG_END; ++i) { - if(m_items[i] && !m_items[i]->IsBroken()) + if (m_items[i] && !m_items[i]->IsBroken()) { ApplyItemEquipSpell(m_items[i],false,true); // remove spells that not fit to form ApplyItemEquipSpell(m_items[i],true,true); // add spells that fit form but not active @@ -7439,16 +7442,16 @@ void Player::UpdateEquipSpellsAtFormChange() } // item set bonuses not dependent from item broken state - for(size_t setindex = 0; setindex < ItemSetEff.size(); ++setindex) + for (size_t setindex = 0; setindex < ItemSetEff.size(); ++setindex) { ItemSetEffect* eff = ItemSetEff[setindex]; - if(!eff) + if (!eff) continue; - for(uint32 y=0;y<8; ++y) + for (uint32 y=0; y<8; ++y) { SpellEntry const* spellInfo = eff->spells[y]; - if(!spellInfo) + if (!spellInfo) continue; ApplyEquipSpell(spellInfo,NULL,false,true); // remove spells that not fit to form @@ -7470,12 +7473,12 @@ void Player::UpdateEquipSpellsAtFormChange() * function will call after it in some way if need. */ -void Player::ApplyItemOnStoreSpell(Item *item, bool apply) +void Player::ApplyItemOnStoreSpell(Item* item, bool apply) { if (!item) return; - ItemPrototype const *proto = item->GetProto(); + ItemPrototype const* proto = item->GetProto(); if (!proto) return; @@ -7507,7 +7510,7 @@ void Player::DestroyItemWithOnStoreSpell(Item* item, uint32 spellId) if (!item) return; - ItemPrototype const *proto = item->GetProto(); + ItemPrototype const* proto = item->GetProto(); if (!proto) return; @@ -7529,7 +7532,7 @@ void Player::DestroyItemWithOnStoreSpell(Item* item, uint32 spellId) /// handles unique effect of Deadly Poison: apply poison of the other weapon when already at max. stack -void Player::_HandleDeadlyPoison(Unit* Target, WeaponAttackType attType, SpellEntry const *spellInfo) +void Player::_HandleDeadlyPoison(Unit* Target, WeaponAttackType attType, SpellEntry const* spellInfo) { SpellAuraHolder const* dPoison = NULL; SpellAuraHolderConstBounds holders = Target->GetSpellAuraHolderBounds(spellInfo->Id); @@ -7543,7 +7546,7 @@ void Player::_HandleDeadlyPoison(Unit* Target, WeaponAttackType attType, SpellEn } if (dPoison && dPoison->GetStackAmount() == spellInfo->StackAmount) { - Item *otherWeapon = GetWeaponForAttack(attType == BASE_ATTACK ? OFF_ATTACK : BASE_ATTACK ); + Item* otherWeapon = GetWeaponForAttack(attType == BASE_ATTACK ? OFF_ATTACK : BASE_ATTACK); if (!otherWeapon) return; @@ -7570,15 +7573,15 @@ void Player::_HandleDeadlyPoison(Unit* Target, WeaponAttackType attType, SpellEn void Player::CastItemCombatSpell(Unit* Target, WeaponAttackType attType) { - Item *item = GetWeaponForAttack(attType, true, false); - if(!item) + Item* item = GetWeaponForAttack(attType, true, false); + if (!item) return; - ItemPrototype const *proto = item->GetProto(); - if(!proto) + ItemPrototype const* proto = item->GetProto(); + if (!proto) return; - if (!Target || Target == this ) + if (!Target || Target == this) return; for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) @@ -7586,32 +7589,32 @@ void Player::CastItemCombatSpell(Unit* Target, WeaponAttackType attType) _Spell const& spellData = proto->Spells[i]; // no spell - if(!spellData.SpellId ) + if (!spellData.SpellId) continue; // wrong triggering type - if(spellData.SpellTrigger != ITEM_SPELLTRIGGER_CHANCE_ON_HIT) + if (spellData.SpellTrigger != ITEM_SPELLTRIGGER_CHANCE_ON_HIT) continue; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellData.SpellId); - if(!spellInfo) + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellData.SpellId); + if (!spellInfo) { sLog.outError("WORLD: unknown Item spellid %i", spellData.SpellId); continue; } // not allow proc extra attack spell at extra attack - if( m_extraAttacks && IsSpellHaveEffect(spellInfo,SPELL_EFFECT_ADD_EXTRA_ATTACKS) ) + if (m_extraAttacks && IsSpellHaveEffect(spellInfo,SPELL_EFFECT_ADD_EXTRA_ATTACKS)) return; float chance = (float)spellInfo->procChance; - if(spellData.SpellPPMRate) + if (spellData.SpellPPMRate) { uint32 WeaponSpeed = proto->Delay; chance = GetPPMProcChance(WeaponSpeed, spellData.SpellPPMRate); } - else if(chance > 100.0f) + else if (chance > 100.0f) { chance = GetWeaponProcChance(); } @@ -7621,11 +7624,11 @@ void Player::CastItemCombatSpell(Unit* Target, WeaponAttackType attType) } // item combat enchantments - for(int e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot) + for (int e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot) { uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot)); - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) continue; + SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if (!pEnchant) continue; for (int s = 0; s < 3; ++s) { uint32 proc_spell_id = pEnchant->spellid[s]; @@ -7633,7 +7636,7 @@ void Player::CastItemCombatSpell(Unit* Target, WeaponAttackType attType) if (pEnchant->type[s] != ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) continue; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(proc_spell_id); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(proc_spell_id); if (!spellInfo) { sLog.outError("Player::CastItemCombatSpell Enchant %i, cast unknown spell %i", pEnchant->ID, proc_spell_id); @@ -7644,8 +7647,8 @@ void Player::CastItemCombatSpell(Unit* Target, WeaponAttackType attType) float ppmRate = sSpellMgr.GetItemEnchantProcChance(spellInfo->Id); float chance = ppmRate - ? GetPPMProcChance(proto->Delay, ppmRate) - : pEnchant->amount[s] != 0 ? float(pEnchant->amount[s]) : GetWeaponProcChance(); + ? GetPPMProcChance(proto->Delay, ppmRate) + : pEnchant->amount[s] != 0 ? float(pEnchant->amount[s]) : GetWeaponProcChance(); ApplySpellMod(spellInfo->Id,SPELLMOD_CHANCE_OF_SUCCESS, chance); @@ -7668,7 +7671,7 @@ void Player::CastItemCombatSpell(Unit* Target, WeaponAttackType attType) } } -void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex) +void Player::CastItemUseSpell(Item* item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex) { ItemPrototype const* proto = item->GetProto(); // special learning case @@ -7677,7 +7680,7 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c uint32 learn_spell_id = proto->Spells[0].SpellId; uint32 learning_spell_id = proto->Spells[1].SpellId; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(learn_spell_id); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(learn_spell_id); if (!spellInfo) { sLog.outError("Player::CastItemUseSpell: Item (Entry: %u) in have wrong spell id %u, ignoring ",proto->ItemId, learn_spell_id); @@ -7685,7 +7688,7 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c return; } - Spell *spell = new Spell(this, spellInfo, false); + Spell* spell = new Spell(this, spellInfo, false); spell->m_CastItem = item; spell->m_cast_count = cast_count; //set count of casts spell->m_currentBasePoints[EFFECT_INDEX_0] = learning_spell_id; @@ -7697,7 +7700,7 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c int count = 0; // item spells casted at use - for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) + for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { _Spell const& spellData = proto->Spells[i]; @@ -7709,14 +7712,14 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c if (spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) continue; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellData.SpellId); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellData.SpellId); if (!spellInfo) { sLog.outError("Player::CastItemUseSpell: Item (Entry: %u) in have wrong spell id %u, ignoring",proto->ItemId, spellData.SpellId); continue; } - Spell *spell = new Spell(this, spellInfo, (count > 0)); + Spell* spell = new Spell(this, spellInfo, (count > 0)); spell->m_CastItem = item; spell->m_cast_count = cast_count; // set count of casts spell->m_glyphIndex = glyphIndex; // glyph index @@ -7729,7 +7732,7 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c for (int e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot) { uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot)); - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) continue; @@ -7738,14 +7741,14 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c if (pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_USE_SPELL) continue; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(pEnchant->spellid[s]); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(pEnchant->spellid[s]); if (!spellInfo) { sLog.outError("Player::CastItemUseSpell Enchant %i, cast unknown spell %i", pEnchant->ID, pEnchant->spellid[s]); continue; } - Spell *spell = new Spell(this, spellInfo, (count > 0)); + Spell* spell = new Spell(this, spellInfo, (count > 0)); spell->m_CastItem = item; spell->m_cast_count = cast_count; // set count of casts spell->m_glyphIndex = glyphIndex; // glyph index @@ -7762,17 +7765,17 @@ void Player::_RemoveAllItemMods() for (int i = 0; i < INVENTORY_SLOT_BAG_END; ++i) { - if(m_items[i]) + if (m_items[i]) { - ItemPrototype const *proto = m_items[i]->GetProto(); - if(!proto) + ItemPrototype const* proto = m_items[i]->GetProto(); + if (!proto) continue; // item set bonuses not dependent from item broken state - if(proto->ItemSet) + if (proto->ItemSet) RemoveItemsSetItem(this,proto); - if(m_items[i]->IsBroken()) + if (m_items[i]->IsBroken()) continue; ApplyItemEquipSpell(m_items[i],false); @@ -7782,21 +7785,21 @@ void Player::_RemoveAllItemMods() for (int i = 0; i < INVENTORY_SLOT_BAG_END; ++i) { - if(m_items[i]) + if (m_items[i]) { - if(m_items[i]->IsBroken()) + if (m_items[i]->IsBroken()) continue; - ItemPrototype const *proto = m_items[i]->GetProto(); - if(!proto) + ItemPrototype const* proto = m_items[i]->GetProto(); + if (!proto) continue; uint32 attacktype = Player::GetAttackBySlot(i); - if(attacktype < MAX_ATTACK) + if (attacktype < MAX_ATTACK) _ApplyWeaponDependentAuraMods(m_items[i],WeaponAttackType(attacktype),false); _ApplyItemBonuses(proto,i, false); - if( i == EQUIPMENT_SLOT_RANGED ) + if (i == EQUIPMENT_SLOT_RANGED) _ApplyAmmoBonuses(); } } @@ -7810,39 +7813,39 @@ void Player::_ApplyAllItemMods() for (int i = 0; i < INVENTORY_SLOT_BAG_END; ++i) { - if(m_items[i]) + if (m_items[i]) { - if(m_items[i]->IsBroken()) + if (m_items[i]->IsBroken()) continue; - ItemPrototype const *proto = m_items[i]->GetProto(); - if(!proto) + ItemPrototype const* proto = m_items[i]->GetProto(); + if (!proto) continue; uint32 attacktype = Player::GetAttackBySlot(i); - if(attacktype < MAX_ATTACK) + if (attacktype < MAX_ATTACK) _ApplyWeaponDependentAuraMods(m_items[i],WeaponAttackType(attacktype),true); _ApplyItemBonuses(proto,i, true); - if( i == EQUIPMENT_SLOT_RANGED ) + if (i == EQUIPMENT_SLOT_RANGED) _ApplyAmmoBonuses(); } } for (int i = 0; i < INVENTORY_SLOT_BAG_END; ++i) { - if(m_items[i]) + if (m_items[i]) { - ItemPrototype const *proto = m_items[i]->GetProto(); - if(!proto) + ItemPrototype const* proto = m_items[i]->GetProto(); + if (!proto) continue; // item set bonuses not dependent from item broken state - if(proto->ItemSet) + if (proto->ItemSet) AddItemsSetItem(this,m_items[i]); - if(m_items[i]->IsBroken()) + if (m_items[i]->IsBroken()) continue; ApplyItemEquipSpell(m_items[i],true); @@ -7857,13 +7860,13 @@ void Player::_ApplyAllLevelScaleItemMods(bool apply) { for (int i = 0; i < INVENTORY_SLOT_BAG_END; ++i) { - if(m_items[i]) + if (m_items[i]) { - if(m_items[i]->IsBroken()) + if (m_items[i]->IsBroken()) continue; - ItemPrototype const *proto = m_items[i]->GetProto(); - if(!proto) + ItemPrototype const* proto = m_items[i]->GetProto(); + if (!proto) continue; _ApplyItemBonuses(proto,i, apply, true); @@ -7875,50 +7878,50 @@ void Player::_ApplyAmmoBonuses() { // check ammo uint32 ammo_id = GetUInt32Value(PLAYER_AMMO_ID); - if(!ammo_id) + if (!ammo_id) return; float currentAmmoDPS; - ItemPrototype const *ammo_proto = ObjectMgr::GetItemPrototype( ammo_id ); - if( !ammo_proto || ammo_proto->Class!=ITEM_CLASS_PROJECTILE || !CheckAmmoCompatibility(ammo_proto)) + ItemPrototype const* ammo_proto = ObjectMgr::GetItemPrototype(ammo_id); + if (!ammo_proto || ammo_proto->Class!=ITEM_CLASS_PROJECTILE || !CheckAmmoCompatibility(ammo_proto)) currentAmmoDPS = 0.0f; else currentAmmoDPS = ammo_proto->Damage[0].DamageMin; - if(currentAmmoDPS == GetAmmoDPS()) + if (currentAmmoDPS == GetAmmoDPS()) return; m_ammoDPS = currentAmmoDPS; - if(CanModifyStats()) + if (CanModifyStats()) UpdateDamagePhysical(RANGED_ATTACK); } -bool Player::CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const +bool Player::CheckAmmoCompatibility(const ItemPrototype* ammo_proto) const { - if(!ammo_proto) + if (!ammo_proto) return false; // check ranged weapon - Item *weapon = GetWeaponForAttack( RANGED_ATTACK, true, false ); + Item* weapon = GetWeaponForAttack(RANGED_ATTACK, true, false); if (!weapon) return false; ItemPrototype const* weapon_proto = weapon->GetProto(); - if(!weapon_proto || weapon_proto->Class!=ITEM_CLASS_WEAPON ) + if (!weapon_proto || weapon_proto->Class!=ITEM_CLASS_WEAPON) return false; // check ammo ws. weapon compatibility - switch(weapon_proto->SubClass) + switch (weapon_proto->SubClass) { case ITEM_SUBCLASS_WEAPON_BOW: case ITEM_SUBCLASS_WEAPON_CROSSBOW: - if(ammo_proto->SubClass!=ITEM_SUBCLASS_ARROW) + if (ammo_proto->SubClass!=ITEM_SUBCLASS_ARROW) return false; break; case ITEM_SUBCLASS_WEAPON_GUN: - if(ammo_proto->SubClass!=ITEM_SUBCLASS_BULLET) + if (ammo_proto->SubClass!=ITEM_SUBCLASS_BULLET) return false; break; default: @@ -7936,20 +7939,20 @@ void Player::RemovedInsignia(Player* looterPlr) return; // If not released spirit, do it ! - if(m_deathTimer > 0) + if (m_deathTimer > 0) { m_deathTimer = 0; BuildPlayerRepop(); RepopAtGraveyard(); } - Corpse *corpse = GetCorpse(); + Corpse* corpse = GetCorpse(); if (!corpse) return; // We have to convert player corpse to bones, not to be able to resurrect there // SpawnCorpseBones isn't handy, 'cos it saves player while he in BG - Corpse *bones = sObjectAccessor.ConvertCorpseForPlayer(GetObjectGuid(), true); + Corpse* bones = sObjectAccessor.ConvertCorpseForPlayer(GetObjectGuid(), true); if (!bones) return; @@ -7965,10 +7968,10 @@ void Player::RemovedInsignia(Player* looterPlr) void Player::SendLootRelease(ObjectGuid guid) { - WorldPacket data( SMSG_LOOT_RELEASE_RESPONSE, (8+1) ); + WorldPacket data(SMSG_LOOT_RELEASE_RESPONSE, (8+1)); data << guid; data << uint8(1); - SendDirectMessage( &data ); + SendDirectMessage(&data); } void Player::SendLoot(ObjectGuid guid, LootType loot_type) @@ -7980,12 +7983,12 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) PermissionTypes permission = ALL_PERMISSION; DEBUG_LOG("Player::SendLoot"); - switch(guid.GetHigh()) + switch (guid.GetHigh()) { case HIGHGUID_GAMEOBJECT: { DEBUG_LOG(" IS_GAMEOBJECT_GUID(guid)"); - GameObject *go = GetMap()->GetGameObject(guid); + GameObject* go = GetMap()->GetGameObject(guid); // not check distance for GO in case owned GO (fishing bobber case, for example) // And permit out of range GO with no owner in case fishing hole @@ -8009,7 +8012,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) { uint32 lootid = go->GetGOInfo()->GetLootId(); if ((go->GetEntry() == BG_AV_OBJECTID_MINE_N || go->GetEntry() == BG_AV_OBJECTID_MINE_S)) - if (BattleGround *bg = GetBattleGround()) + if (BattleGround* bg = GetBattleGround()) if (bg->GetTypeID() == BATTLEGROUND_AV) if (!(((BattleGroundAV*)bg)->PlayerCanDoMineQuest(go->GetEntry(), GetTeam()))) { @@ -8090,7 +8093,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) } case HIGHGUID_ITEM: { - Item *item = GetItemByGuid( guid ); + Item* item = GetItemByGuid(guid); if (!item) { @@ -8106,7 +8109,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) { item->loot.clear(); - switch(loot_type) + switch (loot_type) { case LOOT_DISENCHANTING: loot->FillLoot(item->GetProto()->DisenchantID, LootTemplates_Disenchant, this, true); @@ -8131,9 +8134,9 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) } case HIGHGUID_CORPSE: // remove insignia { - Corpse *bones = GetMap()->GetCorpse(guid); + Corpse* bones = GetMap()->GetCorpse(guid); - if (!bones || !((loot_type == LOOT_CORPSE) || (loot_type == LOOT_INSIGNIA)) || (bones->GetType() != CORPSE_BONES) ) + if (!bones || !((loot_type == LOOT_CORPSE) || (loot_type == LOOT_INSIGNIA)) || (bones->GetType() != CORPSE_BONES)) { SendLootRelease(guid); return; @@ -8150,7 +8153,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) loot->FillLoot(0, LootTemplates_Creature, this, false); // It may need a better formula // Now it works like this: lvl10: ~6copper, lvl70: ~9silver - bones->loot.gold = (uint32)( urand(50, 150) * 0.016f * pow( ((float)pLevel)/5.76f, 2.5f) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY) ); + bones->loot.gold = (uint32)(urand(50, 150) * 0.016f * pow(((float)pLevel)/5.76f, 2.5f) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); } if (bones->lootRecipient != this) @@ -8162,7 +8165,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) case HIGHGUID_UNIT: case HIGHGUID_VEHICLE: { - Creature *creature = GetMap()->GetCreature(guid); + Creature* creature = GetMap()->GetCreature(guid); // must be in range and creature must be alive for pickpocket and must be dead for another loot if (!creature || creature->isAlive()!=(loot_type == LOOT_PICKPOCKETING) || !creature->IsWithinDistInMap(this,INTERACTION_DISTANCE)) @@ -8199,7 +8202,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) else { // the player whose group may loot the corpse - Player *recipient = creature->GetLootRecipient(); + Player* recipient = creature->GetLootRecipient(); if (!recipient) { creature->SetLootRecipient(this); @@ -8263,7 +8266,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) // set group rights only for loot_type != LOOT_SKINNING else { - if(Group* group = creature->GetGroupLootRecipient()) + if (Group* group = creature->GetGroupLootRecipient()) { if (group == GetGroup()) { @@ -8300,7 +8303,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) SetLootGuid(guid); // LOOT_INSIGNIA and LOOT_FISHINGHOLE unsupported by client - switch(loot_type) + switch (loot_type) { case LOOT_INSIGNIA: loot_type = LOOT_SKINNING; break; case LOOT_FISHING_FAIL: loot_type = LOOT_FISHING; break; @@ -8328,14 +8331,14 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) void Player::SendNotifyLootMoneyRemoved() { WorldPacket data(SMSG_LOOT_CLEAR_MONEY, 0); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } void Player::SendNotifyLootItemRemoved(uint8 lootSlot) { WorldPacket data(SMSG_LOOT_REMOVED, 1); data << uint8(lootSlot); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } void Player::SendUpdateWorldState(uint32 Field, uint32 Value) @@ -8621,21 +8624,21 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid) FillInitialWorldState(data, count, 0x8d5, 0x0); // 2261 4 FillInitialWorldState(data, count, 0x8d4, 0x0); // 2260 5 FillInitialWorldState(data, count, 0x8d3, 0x0); // 2259 6 - // 3191 7 Current arena season + // 3191 7 Current arena season FillInitialWorldState(data, count, 0xC77, sWorld.getConfig(CONFIG_UINT32_ARENA_SEASON_ID)); - // 3901 8 Previous arena season + // 3901 8 Previous arena season FillInitialWorldState(data, count, 0xF3D, sWorld.getConfig(CONFIG_UINT32_ARENA_SEASON_PREVIOUS_ID)); FillInitialWorldState(data, count, 0xED9, 1); // 3801 9 0 - Battle for Wintergrasp in progress, 1 - otherwise - // 4354 10 Time when next Battle for Wintergrasp starts + // 4354 10 Time when next Battle for Wintergrasp starts FillInitialWorldState(data, count, 0x1102, uint32(time(NULL) + 9000)); - if(mapid == 530) // Outland + if (mapid == 530) // Outland { FillInitialWorldState(data, count, 0x9bf, 0x0); // 2495 FillInitialWorldState(data, count, 0x9bd, 0xF); // 2493 FillInitialWorldState(data, count, 0x9bb, 0xF); // 2491 } - switch(zoneid) + switch (zoneid) { case 1: case 11: @@ -8729,9 +8732,9 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid) void Player::FillBGWeekendWorldStates(WorldPacket& data, uint32& count) { - for(uint32 i = 1; i < sBattlemasterListStore.GetNumRows(); ++i) + for (uint32 i = 1; i < sBattlemasterListStore.GetNumRows(); ++i) { - BattlemasterListEntry const * bl = sBattlemasterListStore.LookupEntry(i); + BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(i); if (bl && bl->HolidayWorldStateId) { if (BattleGroundMgr::IsBGWeekend(BattleGroundTypeId(bl->id))) @@ -8746,10 +8749,10 @@ uint32 Player::GetXPRestBonus(uint32 xp) { uint32 rested_bonus = (uint32)GetRestBonus(); // xp for each rested bonus - if(rested_bonus > xp) // max rested_bonus == xp or (r+x) = 200% xp + if (rested_bonus > xp) // max rested_bonus == xp or (r+x) = 200% xp rested_bonus = xp; - SetRestBonus( GetRestBonus() - rested_bonus); + SetRestBonus(GetRestBonus() - rested_bonus); DETAIL_LOG("Player gain %u xp (+ %u Rested Bonus). Rested points=%f",xp+rested_bonus,rested_bonus,GetRestBonus()); return rested_bonus; @@ -8759,7 +8762,7 @@ void Player::SetBindPoint(ObjectGuid guid) { WorldPacket data(SMSG_BINDER_CONFIRM, 8); data << ObjectGuid(guid); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } void Player::SendTalentWipeConfirm(ObjectGuid guid) @@ -8767,37 +8770,37 @@ void Player::SendTalentWipeConfirm(ObjectGuid guid) WorldPacket data(MSG_TALENT_WIPE_CONFIRM, (8+4)); data << ObjectGuid(guid); data << uint32(resetTalentsCost()); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } void Player::SendPetSkillWipeConfirm() { Pet* pet = GetPet(); - if(!pet) + if (!pet) return; WorldPacket data(SMSG_PET_UNLEARN_CONFIRM, (8+4)); data << ObjectGuid(pet->GetObjectGuid()); data << uint32(pet->resetTalentsCost()); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } /*********************************************************/ /*** STORAGE SYSTEM ***/ /*********************************************************/ -void Player::SetVirtualItemSlot( uint8 i, Item* item) +void Player::SetVirtualItemSlot(uint8 i, Item* item) { MANGOS_ASSERT(i < 3); - if(i < 2 && item) + if (i < 2 && item) { - if(!item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) + if (!item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) return; uint32 charges = item->GetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT); - if(charges == 0) + if (charges == 0) return; - if(charges > 1) + if (charges > 1) item->SetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT,charges-1); - else if(charges <= 1) + else if (charges <= 1) { ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,false); item->ClearEnchantment(TEMP_ENCHANTMENT_SLOT); @@ -8805,7 +8808,7 @@ void Player::SetVirtualItemSlot( uint8 i, Item* item) } } -void Player::SetSheath( SheathState sheathed ) +void Player::SetSheath(SheathState sheathed) { switch (sheathed) { @@ -8834,7 +8837,7 @@ void Player::SetSheath( SheathState sheathed ) Unit::SetSheath(sheathed); // this must visualize Sheath changing for other players... } -uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const +uint8 Player::FindEquipSlot(ItemPrototype const* proto, uint32 slot, bool swap) const { uint8 pClass = getClass(); @@ -8843,7 +8846,7 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap slots[1] = NULL_SLOT; slots[2] = NULL_SLOT; slots[3] = NULL_SLOT; - switch( proto->InventoryType ) + switch (proto->InventoryType) { case INVTYPE_HEAD: slots[0] = EQUIPMENT_SLOT_HEAD; @@ -8895,7 +8898,7 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap // suggest offhand slot only if know dual wielding // (this will be replace mainhand weapon at auto equip instead unwonted "you don't known dual wielding" ... - if(CanDualWield()) + if (CanDualWield()) slots[1] = EQUIPMENT_SLOT_OFFHAND; break; }; @@ -8936,7 +8939,7 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap break; case INVTYPE_RELIC: { - switch(proto->SubClass) + switch (proto->SubClass) { case ITEM_SUBCLASS_ARMOR_LIBRAM: if (pClass == CLASS_PALADIN) @@ -8965,13 +8968,13 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap return NULL_SLOT; } - if( slot != NULL_SLOT ) + if (slot != NULL_SLOT) { - if( swap || !GetItemByPos( INVENTORY_SLOT_BAG_0, slot ) ) + if (swap || !GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) { for (int i = 0; i < 4; ++i) { - if ( slots[i] == slot ) + if (slots[i] == slot) return slot; } } @@ -8981,10 +8984,10 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap // search free slot at first for (int i = 0; i < 4; ++i) { - if ( slots[i] != NULL_SLOT && !GetItemByPos( INVENTORY_SLOT_BAG_0, slots[i] ) ) + if (slots[i] != NULL_SLOT && !GetItemByPos(INVENTORY_SLOT_BAG_0, slots[i])) { // in case 2hand equipped weapon (without titan grip) offhand slot empty but not free - if(slots[i]!=EQUIPMENT_SLOT_OFFHAND || !IsTwoHandUsed()) + if (slots[i]!=EQUIPMENT_SLOT_OFFHAND || !IsTwoHandUsed()) return slots[i]; } } @@ -8992,7 +8995,7 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap // if not found free and can swap return first appropriate from used for (int i = 0; i < 4; ++i) { - if ( slots[i] != NULL_SLOT && swap ) + if (slots[i] != NULL_SLOT && swap) return slots[i]; } } @@ -9001,62 +9004,62 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap return NULL_SLOT; } -InventoryResult Player::CanUnequipItems( uint32 item, uint32 count ) const +InventoryResult Player::CanUnequipItems(uint32 item, uint32 count) const { - Item *pItem; + Item* pItem; uint32 tempcount = 0; InventoryResult res = EQUIP_ERR_OK; - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i) + for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i) { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item ) + pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && pItem->GetEntry() == item) { InventoryResult ires = CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false); - if(ires == EQUIP_ERR_OK) + if (ires == EQUIP_ERR_OK) { tempcount += pItem->GetCount(); - if( tempcount >= count ) + if (tempcount >= count) return EQUIP_ERR_OK; } else res = ires; } } - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) + for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item ) + pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && pItem->GetEntry() == item) { tempcount += pItem->GetCount(); - if( tempcount >= count ) + if (tempcount >= count) return EQUIP_ERR_OK; } } - for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) + for (int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item ) + pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && pItem->GetEntry() == item) { tempcount += pItem->GetCount(); - if( tempcount >= count ) + if (tempcount >= count) return EQUIP_ERR_OK; } } - Bag *pBag; - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + Bag* pBag; + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { - pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) + pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pBag) { - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { - pItem = GetItemByPos( i, j ); - if( pItem && pItem->GetEntry() == item ) + pItem = GetItemByPos(i, j); + if (pItem && pItem->GetEntry() == item) { tempcount += pItem->GetCount(); - if( tempcount >= count ) + if (tempcount >= count) return EQUIP_ERR_OK; } } @@ -9070,56 +9073,56 @@ InventoryResult Player::CanUnequipItems( uint32 item, uint32 count ) const uint32 Player::GetItemCount(uint32 item, bool inBankAlso, Item* skipItem) const { uint32 count = 0; - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) + for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem != skipItem && pItem->GetEntry() == item ) + Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && pItem != skipItem && pItem->GetEntry() == item) count += pItem->GetCount(); } - for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) + for (int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem != skipItem && pItem->GetEntry() == item ) + Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && pItem != skipItem && pItem->GetEntry() == item) count += pItem->GetCount(); } - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { - Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) + Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pBag) count += pBag->GetItemCount(item,skipItem); } - if(skipItem && skipItem->GetProto()->GemProperties) + if (skipItem && skipItem->GetProto()->GemProperties) { - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) + for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem != skipItem && pItem->GetProto()->Socket[0].Color ) + Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && pItem != skipItem && pItem->GetProto()->Socket[0].Color) count += pItem->GetGemCountWithID(item); } } - if(inBankAlso) + if (inBankAlso) { - for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i) + for (int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i) { - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem != skipItem && pItem->GetEntry() == item ) + Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && pItem != skipItem && pItem->GetEntry() == item) count += pItem->GetCount(); } - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) + for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) { - Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) + Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pBag) count += pBag->GetItemCount(item,skipItem); } - if(skipItem && skipItem->GetProto()->GemProperties) + if (skipItem && skipItem->GetProto()->GemProperties) { - for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i) + for (int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i) { - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem != skipItem && pItem->GetProto()->Socket[0].Color ) + Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && pItem != skipItem && pItem->GetProto()->Socket[0].Color) count += pItem->GetGemCountWithID(item); } } @@ -9128,49 +9131,49 @@ uint32 Player::GetItemCount(uint32 item, bool inBankAlso, Item* skipItem) const return count; } -uint32 Player::GetItemCountWithLimitCategory( uint32 limitCategory, Item* skipItem) const +uint32 Player::GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem) const { uint32 count = 0; - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) - if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetProto()->ItemLimitCategory == limitCategory && pItem != skipItem) count += pItem->GetCount(); - for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) - if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetProto()->ItemLimitCategory == limitCategory && pItem != skipItem) count += pItem->GetCount(); - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) count += pBag->GetItemCountWithLimitCategory(limitCategory, skipItem); - for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i) - if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetProto()->ItemLimitCategory == limitCategory && pItem != skipItem) count += pItem->GetCount(); - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) + for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) count += pBag->GetItemCountWithLimitCategory(limitCategory, skipItem); return count; } -Item* Player::GetItemByEntry( uint32 item ) const +Item* Player::GetItemByEntry(uint32 item) const { - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) - if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetEntry() == item) return pItem; - for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) - if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetEntry() == item) return pItem; - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i)) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (Item* itemPtr = pBag->GetItemByEntry(item)) return itemPtr; @@ -9179,18 +9182,18 @@ Item* Player::GetItemByEntry( uint32 item ) const Item* Player::GetItemByLimitedCategory(uint32 limitedCategory) const { - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) - if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetProto()->ItemLimitCategory == limitedCategory) return pItem; - for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) - if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetProto()->ItemLimitCategory == limitedCategory) return pItem; - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i)) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (Item* itemPtr = pBag->GetItemByLimitedCategory(limitedCategory)) return itemPtr; @@ -9199,31 +9202,31 @@ Item* Player::GetItemByLimitedCategory(uint32 limitedCategory) const Item* Player::GetItemByGuid(ObjectGuid guid) const { - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) - if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetObjectGuid() == guid) return pItem; - for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) - if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetObjectGuid() == guid) return pItem; - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - if (Bag *pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) if (Item* pItem = pBag->GetItemByPos(j)) if (pItem->GetObjectGuid() == guid) return pItem; - for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i) - if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetObjectGuid() == guid) return pItem; - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) - if (Bag *pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) if (Item* pItem = pBag->GetItemByPos(j)) if (pItem->GetObjectGuid() == guid) return pItem; @@ -9231,22 +9234,22 @@ Item* Player::GetItemByGuid(ObjectGuid guid) const return NULL; } -Item* Player::GetItemByPos( uint16 pos ) const +Item* Player::GetItemByPos(uint16 pos) const { uint8 bag = pos >> 8; uint8 slot = pos & 255; - return GetItemByPos( bag, slot ); + return GetItemByPos(bag, slot); } -Item* Player::GetItemByPos( uint8 bag, uint8 slot ) const +Item* Player::GetItemByPos(uint8 bag, uint8 slot) const { - if( bag == INVENTORY_SLOT_BAG_0 && ( slot < BANK_SLOT_BAG_END || (slot >= KEYRING_SLOT_START && slot < CURRENCYTOKEN_SLOT_END )) ) + if (bag == INVENTORY_SLOT_BAG_0 && (slot < BANK_SLOT_BAG_END || (slot >= KEYRING_SLOT_START && slot < CURRENCYTOKEN_SLOT_END))) return m_items[slot]; else if ((bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END) - || (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END) ) + || (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END)) { - Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); - if ( pBag ) + Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag); + if (pBag) return pBag->GetItemByPos(slot); } return NULL; @@ -9301,9 +9304,9 @@ Item* Player::GetShield(bool useable) const return item; } -uint32 Player::GetAttackBySlot( uint8 slot ) +uint32 Player::GetAttackBySlot(uint8 slot) { - switch(slot) + switch (slot) { case EQUIPMENT_SLOT_MAINHAND: return BASE_ATTACK; case EQUIPMENT_SLOT_OFFHAND: return OFF_ATTACK; @@ -9312,54 +9315,54 @@ uint32 Player::GetAttackBySlot( uint8 slot ) } } -bool Player::IsInventoryPos( uint8 bag, uint8 slot ) +bool Player::IsInventoryPos(uint8 bag, uint8 slot) { - if( bag == INVENTORY_SLOT_BAG_0 && slot == NULL_SLOT ) + if (bag == INVENTORY_SLOT_BAG_0 && slot == NULL_SLOT) return true; - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= INVENTORY_SLOT_ITEM_START && slot < INVENTORY_SLOT_ITEM_END ) ) + if (bag == INVENTORY_SLOT_BAG_0 && (slot >= INVENTORY_SLOT_ITEM_START && slot < INVENTORY_SLOT_ITEM_END)) return true; - if( bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END ) + if (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END) return true; - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= KEYRING_SLOT_START && slot < CURRENCYTOKEN_SLOT_END ) ) + if (bag == INVENTORY_SLOT_BAG_0 && (slot >= KEYRING_SLOT_START && slot < CURRENCYTOKEN_SLOT_END)) return true; return false; } -bool Player::IsEquipmentPos( uint8 bag, uint8 slot ) +bool Player::IsEquipmentPos(uint8 bag, uint8 slot) { - if( bag == INVENTORY_SLOT_BAG_0 && ( slot < EQUIPMENT_SLOT_END ) ) + if (bag == INVENTORY_SLOT_BAG_0 && (slot < EQUIPMENT_SLOT_END)) return true; - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= INVENTORY_SLOT_BAG_START && slot < INVENTORY_SLOT_BAG_END ) ) + if (bag == INVENTORY_SLOT_BAG_0 && (slot >= INVENTORY_SLOT_BAG_START && slot < INVENTORY_SLOT_BAG_END)) return true; return false; } -bool Player::IsBankPos( uint8 bag, uint8 slot ) +bool Player::IsBankPos(uint8 bag, uint8 slot) { - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= BANK_SLOT_ITEM_START && slot < BANK_SLOT_ITEM_END ) ) + if (bag == INVENTORY_SLOT_BAG_0 && (slot >= BANK_SLOT_ITEM_START && slot < BANK_SLOT_ITEM_END)) return true; - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END ) ) + if (bag == INVENTORY_SLOT_BAG_0 && (slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END)) return true; - if( bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END ) + if (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END) return true; return false; } -bool Player::IsBagPos( uint16 pos ) +bool Player::IsBagPos(uint16 pos) { uint8 bag = pos >> 8; uint8 slot = pos & 255; - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= INVENTORY_SLOT_BAG_START && slot < INVENTORY_SLOT_BAG_END ) ) + if (bag == INVENTORY_SLOT_BAG_0 && (slot >= INVENTORY_SLOT_BAG_START && slot < INVENTORY_SLOT_BAG_END)) return true; - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END ) ) + if (bag == INVENTORY_SLOT_BAG_0 && (slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END)) return true; return false; } -bool Player::IsValidPos( uint8 bag, uint8 slot, bool explicit_pos ) const +bool Player::IsValidPos(uint8 bag, uint8 slot, bool explicit_pos) const { // post selected - if(bag == NULL_BAG && !explicit_pos) + if (bag == NULL_BAG && !explicit_pos) return true; if (bag == INVENTORY_SLOT_BAG_0) @@ -9398,8 +9401,8 @@ bool Player::IsValidPos( uint8 bag, uint8 slot, bool explicit_pos ) const // bag content slots if (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END) { - Bag* pBag = (Bag*)GetItemByPos (INVENTORY_SLOT_BAG_0, bag); - if(!pBag) + Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag); + if (!pBag) return false; // any post selected @@ -9410,10 +9413,10 @@ bool Player::IsValidPos( uint8 bag, uint8 slot, bool explicit_pos ) const } // bank bag content slots - if( bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END ) + if (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END) { - Bag* pBag = (Bag*)GetItemByPos (INVENTORY_SLOT_BAG_0, bag); - if(!pBag) + Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag); + if (!pBag) return false; // any post selected @@ -9428,12 +9431,12 @@ bool Player::IsValidPos( uint8 bag, uint8 slot, bool explicit_pos ) const } -bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const +bool Player::HasItemCount(uint32 item, uint32 count, bool inBankAlso) const { uint32 tempcount = 0; - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) + for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade()) { tempcount += pItem->GetCount(); @@ -9441,9 +9444,9 @@ bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const return true; } } - for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) + for (int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade()) { tempcount += pItem->GetCount(); @@ -9451,13 +9454,13 @@ bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const return true; } } - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { - if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) { - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { - Item* pItem = GetItemByPos( i, j ); + Item* pItem = GetItemByPos(i, j); if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade()) { tempcount += pItem->GetCount(); @@ -9468,11 +9471,11 @@ bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const } } - if(inBankAlso) + if (inBankAlso) { - for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i) + for (int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i) { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade()) { tempcount += pItem->GetCount(); @@ -9480,13 +9483,13 @@ bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const return true; } } - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) + for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) { - if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) { - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { - Item* pItem = GetItemByPos( i, j ); + Item* pItem = GetItemByPos(i, j); if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade()) { tempcount += pItem->GetCount(); @@ -9501,36 +9504,36 @@ bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const return false; } -bool Player::HasItemOrGemWithIdEquipped( uint32 item, uint32 count, uint8 except_slot ) const +bool Player::HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_slot) const { uint32 tempcount = 0; - for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) + for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) { - if(i==int(except_slot)) + if (i==int(except_slot)) continue; - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item) + Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && pItem->GetEntry() == item) { tempcount += pItem->GetCount(); - if( tempcount >= count ) + if (tempcount >= count) return true; } } - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item); + ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item); if (pProto && pProto->GemProperties) { - for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) + for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) { - if(i==int(except_slot)) + if (i==int(except_slot)) continue; - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetProto()->Socket[0].Color) + Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && pItem->GetProto()->Socket[0].Color) { tempcount += pItem->GetGemCountWithID(item); - if( tempcount >= count ) + if (tempcount >= count) return true; } } @@ -9539,33 +9542,33 @@ bool Player::HasItemOrGemWithIdEquipped( uint32 item, uint32 count, uint8 except return false; } -bool Player::HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory, uint32 count, uint8 except_slot ) const +bool Player::HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot) const { uint32 tempcount = 0; - for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) + for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) { - if(i==int(except_slot)) + if (i==int(except_slot)) continue; - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (!pItem) continue; - ItemPrototype const *pProto = pItem->GetProto(); + ItemPrototype const* pProto = pItem->GetProto(); if (!pProto) continue; if (pProto->ItemLimitCategory == limitCategory) { tempcount += pItem->GetCount(); - if( tempcount >= count ) + if (tempcount >= count) return true; } - if( pProto->Socket[0].Color) + if (pProto->Socket[0].Color) { tempcount += pItem->GetGemCountWithLimitCategory(limitCategory); - if( tempcount >= count ) + if (tempcount >= count) return true; } } @@ -9575,7 +9578,7 @@ bool Player::HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory, uint32 InventoryResult Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count) const { - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(entry); + ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(entry); if (!pProto) { if (no_space_count) @@ -9602,7 +9605,7 @@ InventoryResult Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Ite ItemLimitCategoryEntry const* limitEntry = sItemLimitCategoryStore.LookupEntry(pProto->ItemLimitCategory); if (!limitEntry) { - if(no_space_count) + if (no_space_count) *no_space_count = count; return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; } @@ -9623,29 +9626,29 @@ InventoryResult Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Ite return EQUIP_ERR_OK; } -bool Player::HasItemTotemCategory( uint32 TotemCategory ) const +bool Player::HasItemTotemCategory(uint32 TotemCategory) const { - Item *pItem; - for(uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) + Item* pItem; + for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) + pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory)) return true; } - for(uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) + for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) + pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory)) return true; } - for(uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { - if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) { - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { - pItem = GetItemByPos( i, j ); - if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) + pItem = GetItemByPos(i, j); + if (pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory)) return true; } } @@ -9653,9 +9656,9 @@ bool Player::HasItemTotemCategory( uint32 TotemCategory ) const return false; } -InventoryResult Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool swap, Item* pSrcItem ) const +InventoryResult Player::_CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const* pProto, uint32& count, bool swap, Item* pSrcItem) const { - Item* pItem2 = GetItemByPos( bag, slot ); + Item* pItem2 = GetItemByPos(bag, slot); // ignore move item (this slot will be empty at move) if (pItem2==pSrcItem) @@ -9682,7 +9685,7 @@ InventoryResult Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, Ite } else { - Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); + Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag); if (!pBag) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; @@ -9724,14 +9727,14 @@ InventoryResult Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, Ite return EQUIP_ERR_OK; } -InventoryResult Player::_CanStoreItem_InBag( uint8 bag, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot ) const +InventoryResult Player::_CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, ItemPrototype const* pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const { // skip specific bag already processed in first called _CanStoreItem_InBag if (bag == skip_bag) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; // skip nonexistent bag or self targeted bag - Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); + Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag); if (!pBag || pBag==pSrcItem) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; @@ -9746,13 +9749,13 @@ InventoryResult Player::_CanStoreItem_InBag( uint8 bag, ItemPosCountVec &dest, I if (!ItemCanGoIntoBag(pProto,pBagProto)) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot if (j==skip_slot) continue; - Item* pItem2 = GetItemByPos( bag, j ); + Item* pItem2 = GetItemByPos(bag, j); // ignore move item (this slot will be empty at move) if (pItem2 == pSrcItem) @@ -9791,15 +9794,15 @@ InventoryResult Player::_CanStoreItem_InBag( uint8 bag, ItemPosCountVec &dest, I return EQUIP_ERR_OK; } -InventoryResult Player::_CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot ) const +InventoryResult Player::_CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemPrototype const* pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const { - for(uint32 j = slot_begin; j < slot_end; ++j) + for (uint32 j = slot_begin; j < slot_end; ++j) { // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot if (INVENTORY_SLOT_BAG_0==skip_bag && j==skip_slot) continue; - Item* pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, j ); + Item* pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, j); // ignore move item (this slot will be empty at move) if (pItem2 == pSrcItem) @@ -9838,11 +9841,11 @@ InventoryResult Player::_CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 return EQUIP_ERR_OK; } -InventoryResult Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 entry, uint32 count, Item *pItem, bool swap, uint32* no_space_count ) const +InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem, bool swap, uint32* no_space_count) const { - DEBUG_LOG( "STORAGE: CanStoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, entry, count); + DEBUG_LOG("STORAGE: CanStoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, entry, count); - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(entry); + ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(entry); if (!pProto) { if (no_space_count) @@ -9977,7 +9980,7 @@ InventoryResult Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &d } // search free slot in bag for place to - if(bag == INVENTORY_SLOT_BAG_0) // inventory + if (bag == INVENTORY_SLOT_BAG_0) // inventory { // search free slot - keyring case if (pProto->BagFamily & BAG_FAMILY_MASK_KEYS) @@ -10126,7 +10129,7 @@ InventoryResult Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &d if (pProto->BagFamily) { - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { res = _CanStoreItem_InBag(i,dest,pProto,count,true,false,pItem,bag,slot); if (res != EQUIP_ERR_OK) @@ -10144,7 +10147,7 @@ InventoryResult Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &d } } - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { res = _CanStoreItem_InBag(i,dest,pProto,count,true,true,pItem,bag,slot); if (res != EQUIP_ERR_OK) @@ -10207,7 +10210,7 @@ InventoryResult Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &d } } - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { res = _CanStoreItem_InBag(i,dest,pProto,count,false,false,pItem,bag,slot); if (res != EQUIP_ERR_OK) @@ -10248,7 +10251,7 @@ InventoryResult Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &d return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; } - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { res = _CanStoreItem_InBag(i,dest,pProto,count,false,true,pItem,bag,slot); if (res != EQUIP_ERR_OK) @@ -10272,9 +10275,9 @@ InventoryResult Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &d } ////////////////////////////////////////////////////////////////////////// -InventoryResult Player::CanStoreItems( Item **pItems,int count) const +InventoryResult Player::CanStoreItems(Item** pItems,int count) const { - Item *pItem2; + Item* pItem2; // fill space table int inv_slot_items[INVENTORY_SLOT_ITEM_END-INVENTORY_SLOT_ITEM_START]; @@ -10287,9 +10290,9 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const memset(inv_keys,0,sizeof(int)*(KEYRING_SLOT_END-KEYRING_SLOT_START)); memset(inv_tokens,0,sizeof(int)*(CURRENCYTOKEN_SLOT_END-CURRENCYTOKEN_SLOT_START)); - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) + for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) { - pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (pItem2 && !pItem2->IsInTrade()) { @@ -10297,9 +10300,9 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const } } - for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; ++i) + for (int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; ++i) { - pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (pItem2 && !pItem2->IsInTrade()) { @@ -10307,9 +10310,9 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const } } - for(int i = CURRENCYTOKEN_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) + for (int i = CURRENCYTOKEN_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) { - pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (pItem2 && !pItem2->IsInTrade()) { @@ -10317,13 +10320,13 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const } } - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { - if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) { - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { - pItem2 = GetItemByPos( i, j ); + pItem2 = GetItemByPos(i, j); if (pItem2 && !pItem2->IsInTrade()) { inv_bags[i-INVENTORY_SLOT_BAG_START][j] = pItem2->GetCount(); @@ -10335,13 +10338,13 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const // check free space for all items for (int k = 0; k < count; ++k) { - Item *pItem = pItems[k]; + Item* pItem = pItems[k]; // no item if (!pItem) continue; - DEBUG_LOG( "STORAGE: CanStoreItems %i. item = %u, count = %u", k+1, pItem->GetEntry(), pItem->GetCount()); - ItemPrototype const *pProto = pItem->GetProto(); + DEBUG_LOG("STORAGE: CanStoreItems %i. item = %u, count = %u", k+1, pItem->GetEntry(), pItem->GetCount()); + ItemPrototype const* pProto = pItem->GetProto(); // strange item if (!pProto) @@ -10355,8 +10358,8 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const if (pItem->IsBindedNotWith(this)) return EQUIP_ERR_DONT_OWN_THAT_ITEM; - Bag *pBag; - ItemPrototype const *pBagProto; + Bag* pBag; + ItemPrototype const* pBagProto; // item is 'one item only' InventoryResult res = CanTakeMoreSimilarItems(pItem); @@ -10368,9 +10371,9 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const { bool b_found = false; - for(int t = KEYRING_SLOT_START; t < KEYRING_SLOT_END; ++t) + for (int t = KEYRING_SLOT_START; t < KEYRING_SLOT_END; ++t) { - pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); + pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, t); if (pItem2 && pItem2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inv_keys[t-KEYRING_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) { inv_keys[t-KEYRING_SLOT_START] += pItem->GetCount(); @@ -10380,9 +10383,9 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const } if (b_found) continue; - for(int t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; ++t) + for (int t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; ++t) { - pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); + pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, t); if (pItem2 && pItem2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inv_tokens[t-CURRENCYTOKEN_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) { inv_tokens[t-CURRENCYTOKEN_SLOT_START] += pItem->GetCount(); @@ -10392,9 +10395,9 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const } if (b_found) continue; - for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; ++t) + for (int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; ++t) { - pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); + pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, t); if (pItem2 && pItem2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inv_slot_items[t-INVENTORY_SLOT_ITEM_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) { inv_slot_items[t-INVENTORY_SLOT_ITEM_START] += pItem->GetCount(); @@ -10404,14 +10407,14 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const } if (b_found) continue; - for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; ++t) + for (int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; ++t) { - pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); + pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, t); if (pBag) { - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { - pItem2 = GetItemByPos( t, j ); + pItem2 = GetItemByPos(t, j); if (pItem2 && pItem2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inv_bags[t-INVENTORY_SLOT_BAG_START][j] + pItem->GetCount() <= pProto->GetMaxStackSize()) { inv_bags[t-INVENTORY_SLOT_BAG_START][j] += pItem->GetCount(); @@ -10431,7 +10434,7 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const if (pProto->BagFamily & BAG_FAMILY_MASK_KEYS) { uint32 keyringSize = GetMaxKeyringSize(); - for(uint32 t = KEYRING_SLOT_START; t < KEYRING_SLOT_START+keyringSize; ++t) + for (uint32 t = KEYRING_SLOT_START; t < KEYRING_SLOT_START+keyringSize; ++t) { if (inv_keys[t-KEYRING_SLOT_START] == 0) { @@ -10446,7 +10449,7 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const if (pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS) { - for(uint32 t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; ++t) + for (uint32 t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; ++t) { if (inv_tokens[t-CURRENCYTOKEN_SLOT_START] == 0) { @@ -10459,18 +10462,18 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const if (b_found) continue; - for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; ++t) + for (int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; ++t) { - pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); + pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, t); if (pBag) { pBagProto = pBag->GetProto(); // not plain container check if (pBagProto && (pBagProto->Class != ITEM_CLASS_CONTAINER || pBagProto->SubClass != ITEM_SUBCLASS_CONTAINER) && - ItemCanGoIntoBag(pProto,pBagProto) ) + ItemCanGoIntoBag(pProto,pBagProto)) { - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { if (inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0) { @@ -10487,7 +10490,7 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const // search free slot bool b_found = false; - for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; ++t) + for (int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; ++t) { if (inv_slot_items[t-INVENTORY_SLOT_ITEM_START] == 0) { @@ -10499,9 +10502,9 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const if (b_found) continue; // search free slot in bags - for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; ++t) + for (int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; ++t) { - pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); + pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, t); if (pBag) { pBagProto = pBag->GetProto(); @@ -10510,7 +10513,7 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const if (pBagProto && (pBagProto->Class != ITEM_CLASS_CONTAINER || pBagProto->SubClass != ITEM_SUBCLASS_CONTAINER)) continue; - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { if (inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0) { @@ -10531,13 +10534,13 @@ InventoryResult Player::CanStoreItems( Item **pItems,int count) const } ////////////////////////////////////////////////////////////////////////// -InventoryResult Player::CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap ) const +InventoryResult Player::CanEquipNewItem(uint8 slot, uint16& dest, uint32 item, bool swap) const { dest = 0; - Item *pItem = Item::CreateItem( item, 1, this ); + Item* pItem = Item::CreateItem(item, 1, this); if (pItem) { - InventoryResult result = CanEquipItem(slot, dest, pItem, swap ); + InventoryResult result = CanEquipItem(slot, dest, pItem, swap); delete pItem; return result; } @@ -10545,13 +10548,13 @@ InventoryResult Player::CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, return EQUIP_ERR_ITEM_NOT_FOUND; } -InventoryResult Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool direct_action ) const +InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool swap, bool direct_action) const { dest = 0; if (pItem) { - DEBUG_LOG( "STORAGE: CanEquipItem slot = %u, item = %u, count = %u", slot, pItem->GetEntry(), pItem->GetCount()); - ItemPrototype const *pProto = pItem->GetProto(); + DEBUG_LOG("STORAGE: CanEquipItem slot = %u, item = %u, count = %u", slot, pItem->GetEntry(), pItem->GetCount()); + ItemPrototype const* pProto = pItem->GetProto(); if (pProto) { // item used @@ -10598,12 +10601,12 @@ InventoryResult Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, boo return EQUIP_ERR_CANT_DO_RIGHT_NOW; } - ScalingStatDistributionEntry const *ssd = pProto->ScalingStatDistribution ? sScalingStatDistributionStore.LookupEntry(pProto->ScalingStatDistribution) : 0; + ScalingStatDistributionEntry const* ssd = pProto->ScalingStatDistribution ? sScalingStatDistributionStore.LookupEntry(pProto->ScalingStatDistribution) : 0; // check allowed level (extend range to upper values if MaxLevel more or equal max player level, this let GM set high level with 1...max range items) if (ssd && ssd->MaxLevel < DEFAULT_MAX_LEVEL && ssd->MaxLevel < getLevel()) return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; - uint8 eslot = FindEquipSlot( pProto, slot, swap ); + uint8 eslot = FindEquipSlot(pProto, slot, swap); if (eslot == NULL_SLOT) return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; @@ -10630,8 +10633,8 @@ InventoryResult Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, boo { if (pBagProto->Class==pProto->Class && (!swap || pBag->GetSlot() != eslot)) return (pBagProto->SubClass == ITEM_SUBCLASS_AMMO_POUCH) - ? EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH - : EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER; + ? EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH + : EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER; } } } @@ -10671,11 +10674,11 @@ InventoryResult Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, boo if (!CanTitanGrip()) { // offhand item must can be stored in inventory for offhand item and it also must be unequipped - Item *offItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND ); + Item* offItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); ItemPosCountVec off_dest; if (offItem && (!direct_action || - CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND,false) != EQUIP_ERR_OK || - CanStoreItem( NULL_BAG, NULL_SLOT, off_dest, offItem, false ) != EQUIP_ERR_OK )) + CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND,false) != EQUIP_ERR_OK || + CanStoreItem(NULL_BAG, NULL_SLOT, off_dest, offItem, false) != EQUIP_ERR_OK)) return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_INVENTORY_FULL; } } @@ -10687,7 +10690,7 @@ InventoryResult Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, boo return !swap ? EQUIP_ERR_ITEM_NOT_FOUND : EQUIP_ERR_ITEMS_CANT_BE_SWAPPED; } -InventoryResult Player::CanUnequipItem( uint16 pos, bool swap ) const +InventoryResult Player::CanUnequipItem(uint16 pos, bool swap) const { // Applied only to equipped items and bank bags if (!IsEquipmentPos(pos) && !IsBagPos(pos)) @@ -10699,9 +10702,9 @@ InventoryResult Player::CanUnequipItem( uint16 pos, bool swap ) const if (!pItem) return EQUIP_ERR_OK; - DEBUG_LOG( "STORAGE: CanUnequipItem slot = %u, item = %u, count = %u", pos, pItem->GetEntry(), pItem->GetCount()); + DEBUG_LOG("STORAGE: CanUnequipItem slot = %u, item = %u, count = %u", pos, pItem->GetEntry(), pItem->GetCount()); - ItemPrototype const *pProto = pItem->GetProto(); + ItemPrototype const* pProto = pItem->GetProto(); if (!pProto) return EQUIP_ERR_ITEM_NOT_FOUND; @@ -10712,13 +10715,13 @@ InventoryResult Player::CanUnequipItem( uint16 pos, bool swap ) const // do not allow unequipping gear except weapons, offhands, projectiles, relics in // - combat // - in-progress arenas - if( !pProto->CanChangeEquipStateInCombat() ) + if (!pProto->CanChangeEquipStateInCombat()) { - if( isInCombat() ) + if (isInCombat()) return EQUIP_ERR_NOT_IN_COMBAT; - if(BattleGround* bg = GetBattleGround()) - if( bg->isArena() && bg->GetStatus() == STATUS_IN_PROGRESS ) + if (BattleGround* bg = GetBattleGround()) + if (bg->isArena() && bg->GetStatus() == STATUS_IN_PROGRESS) return EQUIP_ERR_NOT_DURING_ARENA_MATCH; } @@ -10726,21 +10729,21 @@ InventoryResult Player::CanUnequipItem( uint16 pos, bool swap ) const if (GetSession()->isLogingOut()) return EQUIP_ERR_YOU_ARE_STUNNED; - if(!swap && pItem->IsBag() && !((Bag*)pItem)->IsEmpty()) + if (!swap && pItem->IsBag() && !((Bag*)pItem)->IsEmpty()) return EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS; return EQUIP_ERR_OK; } -InventoryResult Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *pItem, bool swap, bool not_loading ) const +InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap, bool not_loading) const { if (!pItem) return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND; uint32 count = pItem->GetCount(); - DEBUG_LOG( "STORAGE: CanBankItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, pItem->GetEntry(), pItem->GetCount()); - ItemPrototype const *pProto = pItem->GetProto(); + DEBUG_LOG("STORAGE: CanBankItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, pItem->GetEntry(), pItem->GetCount()); + ItemPrototype const* pProto = pItem->GetProto(); if (!pProto) return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND; @@ -10767,7 +10770,7 @@ InventoryResult Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &des if (slot - BANK_SLOT_BAG_START >= GetBankBagSlotCount()) return EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT; - res = CanUseItem( pItem, not_loading ); + res = CanUseItem(pItem, not_loading); if (res != EQUIP_ERR_OK) return res; } @@ -10783,61 +10786,61 @@ InventoryResult Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &des // not specific slot or have space for partly store only in specific slot // in specific bag - if( bag != NULL_BAG ) + if (bag != NULL_BAG) { - if( pProto->InventoryType == INVTYPE_BAG ) + if (pProto->InventoryType == INVTYPE_BAG) { - Bag *pBag = (Bag*)pItem; - if( pBag && !pBag->IsEmpty() ) + Bag* pBag = (Bag*)pItem; + if (pBag && !pBag->IsEmpty()) return EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG; } // search stack in bag for merge to - if( pProto->Stackable != 1 ) + if (pProto->Stackable != 1) { - if( bag == INVENTORY_SLOT_BAG_0 ) + if (bag == INVENTORY_SLOT_BAG_0) { res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) + if (res!=EQUIP_ERR_OK) return res; - if(count==0) + if (count==0) return EQUIP_ERR_OK; } else { res = _CanStoreItem_InBag(bag,dest,pProto,count,true,false,pItem,NULL_BAG,slot); - if(res!=EQUIP_ERR_OK) + if (res!=EQUIP_ERR_OK) res = _CanStoreItem_InBag(bag,dest,pProto,count,true,true,pItem,NULL_BAG,slot); - if(res!=EQUIP_ERR_OK) + if (res!=EQUIP_ERR_OK) return res; - if(count==0) + if (count==0) return EQUIP_ERR_OK; } } // search free slot in bag - if( bag == INVENTORY_SLOT_BAG_0 ) + if (bag == INVENTORY_SLOT_BAG_0) { res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) + if (res!=EQUIP_ERR_OK) return res; - if(count==0) + if (count==0) return EQUIP_ERR_OK; } else { res = _CanStoreItem_InBag(bag, dest, pProto, count, false, false, pItem, NULL_BAG, slot); - if(res != EQUIP_ERR_OK) + if (res != EQUIP_ERR_OK) res = _CanStoreItem_InBag(bag, dest, pProto, count, false, true, pItem, NULL_BAG, slot); - if(res != EQUIP_ERR_OK) + if (res != EQUIP_ERR_OK) return res; - if(count == 0) + if (count == 0) return EQUIP_ERR_OK; } } @@ -10845,80 +10848,80 @@ InventoryResult Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &des // not specific bag or have space for partly store only in specific bag // search stack for merge to - if( pProto->Stackable != 1 ) + if (pProto->Stackable != 1) { // in slots res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); - if(res != EQUIP_ERR_OK) + if (res != EQUIP_ERR_OK) return res; - if(count == 0) + if (count == 0) return EQUIP_ERR_OK; // in special bags - if( pProto->BagFamily ) + if (pProto->BagFamily) { - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) + for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) { res = _CanStoreItem_InBag(i,dest,pProto,count,true,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) + if (res!=EQUIP_ERR_OK) continue; - if(count==0) + if (count==0) return EQUIP_ERR_OK; } } - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) + for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) { res = _CanStoreItem_InBag(i,dest,pProto,count,true,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) + if (res!=EQUIP_ERR_OK) continue; - if(count==0) + if (count==0) return EQUIP_ERR_OK; } } // search free place in special bag - if( pProto->BagFamily ) + if (pProto->BagFamily) { - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) + for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) { res = _CanStoreItem_InBag(i,dest,pProto,count,false,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) + if (res!=EQUIP_ERR_OK) continue; - if(count==0) + if (count==0) return EQUIP_ERR_OK; } } // search free space res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) + if (res!=EQUIP_ERR_OK) return res; - if(count==0) + if (count==0) return EQUIP_ERR_OK; - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) + for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) { res = _CanStoreItem_InBag(i,dest,pProto,count,false,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) + if (res!=EQUIP_ERR_OK) continue; - if(count==0) + if (count==0) return EQUIP_ERR_OK; } return EQUIP_ERR_BANK_FULL; } -InventoryResult Player::CanUseItem(Item *pItem, bool direct_action) const +InventoryResult Player::CanUseItem(Item* pItem, bool direct_action) const { if (pItem) { - DEBUG_LOG( "STORAGE: CanUseItem item = %u", pItem->GetEntry()); + DEBUG_LOG("STORAGE: CanUseItem item = %u", pItem->GetEntry()); if (!isAlive() && direct_action) return EQUIP_ERR_YOU_ARE_DEAD; @@ -10926,7 +10929,7 @@ InventoryResult Player::CanUseItem(Item *pItem, bool direct_action) const //if (isStunned()) // return EQUIP_ERR_YOU_ARE_STUNNED; - ItemPrototype const *pProto = pItem->GetProto(); + ItemPrototype const* pProto = pItem->GetProto(); if (pProto) { if (pItem->IsBindedNotWith(this)) @@ -10944,14 +10947,14 @@ InventoryResult Player::CanUseItem(Item *pItem, bool direct_action) const if (pProto->Class != ITEM_CLASS_ARMOR) return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; - ScalingStatDistributionEntry const *ssd = pProto->ScalingStatDistribution ? sScalingStatDistributionStore.LookupEntry(pProto->ScalingStatDistribution) : NULL; + ScalingStatDistributionEntry const* ssd = pProto->ScalingStatDistribution ? sScalingStatDistributionStore.LookupEntry(pProto->ScalingStatDistribution) : NULL; if (!ssd) return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; bool allowScaleSkill = false; for (uint32 i = 0; i < sSkillLineAbilityStore.GetNumRows(); ++i) { - SkillLineAbilityEntry const *skillInfo = sSkillLineAbilityStore.LookupEntry(i); + SkillLineAbilityEntry const* skillInfo = sSkillLineAbilityStore.LookupEntry(i); if (!skillInfo) continue; @@ -10983,11 +10986,11 @@ InventoryResult Player::CanUseItem(Item *pItem, bool direct_action) const return EQUIP_ERR_ITEM_NOT_FOUND; } -InventoryResult Player::CanUseItem( ItemPrototype const *pProto ) const +InventoryResult Player::CanUseItem(ItemPrototype const* pProto) const { // Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player - if( pProto ) + if (pProto) { if ((pProto->Flags2 & ITEM_FLAG2_HORDE_ONLY) && GetTeam() != HORDE) return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM; @@ -10998,18 +11001,18 @@ InventoryResult Player::CanUseItem( ItemPrototype const *pProto ) const if ((pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0) return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM; - if( pProto->RequiredSkill != 0 ) + if (pProto->RequiredSkill != 0) { - if( GetSkillValue( pProto->RequiredSkill ) == 0 ) + if (GetSkillValue(pProto->RequiredSkill) == 0) return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; - else if( GetSkillValue( pProto->RequiredSkill ) < pProto->RequiredSkillRank ) + else if (GetSkillValue(pProto->RequiredSkill) < pProto->RequiredSkillRank) return EQUIP_ERR_CANT_EQUIP_SKILL; } - if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) ) + if (pProto->RequiredSpell != 0 && !HasSpell(pProto->RequiredSpell)) return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; - if( getLevel() < pProto->RequiredLevel ) + if (getLevel() < pProto->RequiredLevel) return EQUIP_ERR_CANT_EQUIP_LEVEL_I; return EQUIP_ERR_OK; @@ -11017,17 +11020,17 @@ InventoryResult Player::CanUseItem( ItemPrototype const *pProto ) const return EQUIP_ERR_ITEM_NOT_FOUND; } -InventoryResult Player::CanUseAmmo( uint32 item ) const +InventoryResult Player::CanUseAmmo(uint32 item) const { - DEBUG_LOG( "STORAGE: CanUseAmmo item = %u", item); - if( !isAlive() ) + DEBUG_LOG("STORAGE: CanUseAmmo item = %u", item); + if (!isAlive()) return EQUIP_ERR_YOU_ARE_DEAD; //if( isStunned() ) // return EQUIP_ERR_YOU_ARE_STUNNED; - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype( item ); - if( pProto ) + ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item); + if (pProto) { - if( pProto->InventoryType!= INVTYPE_AMMO ) + if (pProto->InventoryType!= INVTYPE_AMMO) return EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE; InventoryResult msg = CanUseItem(pProto); @@ -11039,7 +11042,7 @@ InventoryResult Player::CanUseAmmo( uint32 item ) const */ // Requires No Ammo - if(GetDummyAura(46699)) + if (GetDummyAura(46699)) return EQUIP_ERR_BAG_FULL6; return EQUIP_ERR_OK; @@ -11047,19 +11050,19 @@ InventoryResult Player::CanUseAmmo( uint32 item ) const return EQUIP_ERR_ITEM_NOT_FOUND; } -void Player::SetAmmo( uint32 item ) +void Player::SetAmmo(uint32 item) { - if(!item) + if (!item) return; // already set - if( GetUInt32Value(PLAYER_AMMO_ID) == item ) + if (GetUInt32Value(PLAYER_AMMO_ID) == item) return; // check ammo if (item) { - InventoryResult msg = CanUseAmmo( item ); + InventoryResult msg = CanUseAmmo(item); if (msg != EQUIP_ERR_OK) { SendEquipError(msg, NULL, NULL, item); @@ -11083,38 +11086,38 @@ void Player::RemoveAmmo() } // Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case. -Item* Player::StoreNewItem( ItemPosCountVec const& dest, uint32 item, bool update,int32 randomPropertyId ) +Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update,int32 randomPropertyId) { uint32 count = 0; - for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) + for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) count += itr->count; - Item *pItem = Item::CreateItem(item, count, this, randomPropertyId); + Item* pItem = Item::CreateItem(item, count, this, randomPropertyId); if (pItem) { - ItemAddedQuestCheck( item, count ); + ItemAddedQuestCheck(item, count); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, item, count); - pItem = StoreItem( dest, pItem, update ); + pItem = StoreItem(dest, pItem, update); } return pItem; } -Item* Player::StoreItem( ItemPosCountVec const& dest, Item* pItem, bool update ) +Item* Player::StoreItem(ItemPosCountVec const& dest, Item* pItem, bool update) { - if( !pItem ) + if (!pItem) return NULL; Item* lastItem = pItem; uint32 entry = pItem->GetEntry(); - for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ) + for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end();) { uint16 pos = itr->pos; uint32 count = itr->count; ++itr; - if(itr == dest.end()) + if (itr == dest.end()) { lastItem = _StoreItem(pos,pItem,count,false,update); break; @@ -11128,17 +11131,17 @@ Item* Player::StoreItem( ItemPosCountVec const& dest, Item* pItem, bool update ) } // Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case. -Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update ) +Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool update) { - if( !pItem ) + if (!pItem) return NULL; uint8 bag = pos >> 8; uint8 slot = pos & 255; - DEBUG_LOG( "STORAGE: StoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, pItem->GetEntry(), count); + DEBUG_LOG("STORAGE: StoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, pItem->GetEntry(), count); - Item *pItem2 = GetItemByPos( bag, slot ); + Item* pItem2 = GetItemByPos(bag, slot); if (!pItem2) { @@ -11151,9 +11154,9 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo return NULL; if (pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || - pItem->GetProto()->Bonding == BIND_QUEST_ITEM || - (pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos))) - pItem->SetBinding( true ); + pItem->GetProto()->Bonding == BIND_QUEST_ITEM || + (pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos))) + pItem->SetBinding(true); if (bag == INVENTORY_SLOT_BAG_0) { @@ -11162,8 +11165,8 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetObjectGuid()); pItem->SetGuidValue(ITEM_FIELD_OWNER, GetObjectGuid()); - pItem->SetSlot( slot ); - pItem->SetContainer( NULL ); + pItem->SetSlot(slot); + pItem->SetContainer(NULL); // need update known currency if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END) @@ -11172,18 +11175,18 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo if (IsInWorld() && update) { pItem->AddToWorld(); - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendCreateUpdateToPlayer(this); } pItem->SetState(ITEM_CHANGED, this); } - else if (Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag )) + else if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag)) { - pBag->StoreItem( slot, pItem, update ); + pBag->StoreItem(slot, pItem, update); if (IsInWorld() && update) { pItem->AddToWorld(); - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendCreateUpdateToPlayer(this); } pItem->SetState(ITEM_CHANGED, this); pBag->SetState(ITEM_CHANGED, this); @@ -11200,13 +11203,13 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo else { if (pItem2->GetProto()->Bonding == BIND_WHEN_PICKED_UP || - pItem2->GetProto()->Bonding == BIND_QUEST_ITEM || - (pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos))) + pItem2->GetProto()->Bonding == BIND_QUEST_ITEM || + (pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos))) pItem2->SetBinding(true); - pItem2->SetCount( pItem2->GetCount() + count ); + pItem2->SetCount(pItem2->GetCount() + count); if (IsInWorld() && update) - pItem2->SendCreateUpdateToPlayer( this ); + pItem2->SendCreateUpdateToPlayer(this); if (!clone) { @@ -11214,7 +11217,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo if (IsInWorld() && update) { pItem->RemoveFromWorld(); - pItem->DestroyForPlayer( this ); + pItem->DestroyForPlayer(this); } RemoveEnchantmentDurations(pItem); @@ -11233,19 +11236,19 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo } } -Item* Player::EquipNewItem( uint16 pos, uint32 item, bool update ) +Item* Player::EquipNewItem(uint16 pos, uint32 item, bool update) { - if (Item *pItem = Item::CreateItem(item, 1, this)) + if (Item* pItem = Item::CreateItem(item, 1, this)) { - ItemAddedQuestCheck( item, 1 ); + ItemAddedQuestCheck(item, 1); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, item, 1); - return EquipItem( pos, pItem, update ); + return EquipItem(pos, pItem, update); } return NULL; } -Item* Player::EquipItem( uint16 pos, Item *pItem, bool update ) +Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) { AddEnchantmentDurations(pItem); AddItemDurations(pItem); @@ -11253,14 +11256,14 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update ) uint8 bag = pos >> 8; uint8 slot = pos & 255; - Item *pItem2 = GetItemByPos(bag, slot); + Item* pItem2 = GetItemByPos(bag, slot); if (!pItem2) { - VisualizeItem( slot, pItem); + VisualizeItem(slot, pItem); if (isAlive()) { - ItemPrototype const *pProto = pItem->GetProto(); + ItemPrototype const* pProto = pItem->GetProto(); // item set bonuses applied only at equip and removed at unequip, and still active for broken items if (pProto && pProto->ItemSet) @@ -11299,17 +11302,17 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update ) if (IsInWorld() && update) { pItem->AddToWorld(); - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendCreateUpdateToPlayer(this); } ApplyEquipCooldown(pItem); - if( slot == EQUIPMENT_SLOT_MAINHAND ) + if (slot == EQUIPMENT_SLOT_MAINHAND) { UpdateExpertise(BASE_ATTACK); UpdateArmorPenetration(); } - else if( slot == EQUIPMENT_SLOT_OFFHAND ) + else if (slot == EQUIPMENT_SLOT_OFFHAND) { UpdateExpertise(OFF_ATTACK); UpdateArmorPenetration(); @@ -11317,16 +11320,16 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update ) } else { - pItem2->SetCount( pItem2->GetCount() + pItem->GetCount() ); + pItem2->SetCount(pItem2->GetCount() + pItem->GetCount()); if (IsInWorld() && update) - pItem2->SendCreateUpdateToPlayer( this ); + pItem2->SendCreateUpdateToPlayer(this); // delete item (it not in any slot currently) //pItem->DeleteFromDB(); if (IsInWorld() && update) { pItem->RemoveFromWorld(); - pItem->DestroyForPlayer( this ); + pItem->DestroyForPlayer(this); } RemoveEnchantmentDurations(pItem); @@ -11351,21 +11354,21 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update ) return pItem; } -void Player::QuickEquipItem( uint16 pos, Item *pItem) +void Player::QuickEquipItem(uint16 pos, Item* pItem) { - if( pItem ) + if (pItem) { AddEnchantmentDurations(pItem); AddItemDurations(pItem); ApplyItemOnStoreSpell(pItem, true); uint8 slot = pos & 255; - VisualizeItem( slot, pItem); + VisualizeItem(slot, pItem); - if( IsInWorld() ) + if (IsInWorld()) { pItem->AddToWorld(); - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendCreateUpdateToPlayer(this); } // Apply Titan's Grip damage penalty if necessary if ((slot == EQUIPMENT_SLOT_MAINHAND || slot == EQUIPMENT_SLOT_OFFHAND) && CanTitanGrip() && HasTwoHandWeaponInOneHand() && !HasAura(49152)) @@ -11376,9 +11379,9 @@ void Player::QuickEquipItem( uint16 pos, Item *pItem) } } -void Player::SetVisibleItemSlot(uint8 slot, Item *pItem) +void Player::SetVisibleItemSlot(uint8 slot, Item* pItem) { - if(pItem) + if (pItem) { SetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + (slot * 2), pItem->GetEntry()); SetUInt16Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (slot * 2), 0, pItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT)); @@ -11391,63 +11394,63 @@ void Player::SetVisibleItemSlot(uint8 slot, Item *pItem) } } -void Player::VisualizeItem( uint8 slot, Item *pItem) +void Player::VisualizeItem(uint8 slot, Item* pItem) { - if(!pItem) + if (!pItem) return; // check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory) - if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM ) - pItem->SetBinding( true ); + if (pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM) + pItem->SetBinding(true); - DEBUG_LOG( "STORAGE: EquipItem slot = %u, item = %u", slot, pItem->GetEntry()); + DEBUG_LOG("STORAGE: EquipItem slot = %u, item = %u", slot, pItem->GetEntry()); m_items[slot] = pItem; SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetObjectGuid()); pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetObjectGuid()); pItem->SetGuidValue(ITEM_FIELD_OWNER, GetObjectGuid()); - pItem->SetSlot( slot ); - pItem->SetContainer( NULL ); + pItem->SetSlot(slot); + pItem->SetContainer(NULL); - if( slot < EQUIPMENT_SLOT_END ) + if (slot < EQUIPMENT_SLOT_END) SetVisibleItemSlot(slot, pItem); pItem->SetState(ITEM_CHANGED, this); } -void Player::RemoveItem( uint8 bag, uint8 slot, bool update ) +void Player::RemoveItem(uint8 bag, uint8 slot, bool update) { // note: removeitem does not actually change the item // it only takes the item out of storage temporarily // note2: if removeitem is to be used for delinking // the item must be removed from the player's updatequeue - if (Item *pItem = GetItemByPos(bag, slot)) + if (Item* pItem = GetItemByPos(bag, slot)) { - DEBUG_LOG( "STORAGE: RemoveItem bag = %u, slot = %u, item = %u", bag, slot, pItem->GetEntry()); + DEBUG_LOG("STORAGE: RemoveItem bag = %u, slot = %u, item = %u", bag, slot, pItem->GetEntry()); RemoveEnchantmentDurations(pItem); RemoveItemDurations(pItem); - if( bag == INVENTORY_SLOT_BAG_0 ) + if (bag == INVENTORY_SLOT_BAG_0) { - if ( slot < INVENTORY_SLOT_BAG_END ) + if (slot < INVENTORY_SLOT_BAG_END) { - ItemPrototype const *pProto = pItem->GetProto(); + ItemPrototype const* pProto = pItem->GetProto(); // item set bonuses applied only at equip and removed at unequip, and still active for broken items - if(pProto && pProto->ItemSet) + if (pProto && pProto->ItemSet) RemoveItemsSetItem(this, pProto); _ApplyItemMods(pItem, slot, false); // remove item dependent auras and casts (only weapon and armor slots) - if(slot < EQUIPMENT_SLOT_END) + if (slot < EQUIPMENT_SLOT_END) { RemoveItemDependentAurasAndCasts(pItem); // remove held enchantments, update expertise - if ( slot == EQUIPMENT_SLOT_MAINHAND ) + if (slot == EQUIPMENT_SLOT_MAINHAND) { if (pItem->GetItemSuffixFactor()) { @@ -11463,7 +11466,7 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update ) UpdateExpertise(BASE_ATTACK); UpdateArmorPenetration(); } - else if( slot == EQUIPMENT_SLOT_OFFHAND ) + else if (slot == EQUIPMENT_SLOT_OFFHAND) { UpdateExpertise(OFF_ATTACK); UpdateArmorPenetration(); @@ -11477,7 +11480,7 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update ) m_items[slot] = NULL; SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid()); - if ( slot < EQUIPMENT_SLOT_END ) + if (slot < EQUIPMENT_SLOT_END) { SetVisibleItemSlot(slot, NULL); // Remove Titan's Grip damage penalty if necessary @@ -11487,25 +11490,25 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update ) } else { - Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); - if( pBag ) + Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag); + if (pBag) pBag->RemoveItem(slot, update); } pItem->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid()); // pItem->SetGuidValue(ITEM_FIELD_OWNER, ObjectGuid()); not clear owner at remove (it will be set at store). This used in mail and auction code - pItem->SetSlot( NULL_SLOT ); + pItem->SetSlot(NULL_SLOT); //ApplyItemOnStoreSpell, for avoid re-apply will remove at _adding_ to not appropriate slot if (IsInWorld() && update) - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendCreateUpdateToPlayer(this); } } // Common operation need to remove item from inventory without delete in trade, auction, guild bank, mail.... void Player::MoveItemFromInventory(uint8 bag, uint8 slot, bool update) { - if(Item* it = GetItemByPos(bag,slot)) + if (Item* it = GetItemByPos(bag,slot)) { ItemRemovedQuestCheck(it->GetEntry(), it->GetCount()); RemoveItem(bag, slot, update); @@ -11515,10 +11518,10 @@ void Player::MoveItemFromInventory(uint8 bag, uint8 slot, bool update) ApplyItemOnStoreSpell(it, false); it->RemoveFromUpdateQueueOf(this); - if(it->IsInWorld()) + if (it->IsInWorld()) { it->RemoveFromWorld(); - it->DestroyForPlayer( this ); + it->DestroyForPlayer(this); } } } @@ -11534,10 +11537,10 @@ void Player::MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool Item* pLastItem = StoreItem(dest, pItem, update); // only set if not merged to existing stack (pItem can be deleted already but we can compare pointers any way) - if(pLastItem == pItem) + if (pLastItem == pItem) { // update owner for last item (this can be original item with wrong owner - if(pLastItem->GetOwnerGuid() != GetObjectGuid()) + if (pLastItem->GetOwnerGuid() != GetObjectGuid()) pLastItem->SetOwnerGuid(GetObjectGuid()); // if this original item then it need create record in inventory @@ -11546,12 +11549,12 @@ void Player::MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool } } -void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) +void Player::DestroyItem(uint8 bag, uint8 slot, bool update) { - Item *pItem = GetItemByPos( bag, slot ); - if( pItem ) + Item* pItem = GetItemByPos(bag, slot); + if (pItem) { - DEBUG_LOG( "STORAGE: DestroyItem bag = %u, slot = %u, item = %u", bag, slot, pItem->GetEntry()); + DEBUG_LOG("STORAGE: DestroyItem bag = %u, slot = %u, item = %u", bag, slot, pItem->GetEntry()); // start from destroy contained items (only equipped bag can have its) if (pItem->IsBag() && pItem->IsEquipped()) // this also prevent infinity loop if empty bag stored in bag==slot @@ -11574,36 +11577,36 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) if (IsEquipmentPos(bag, slot) || IsInventoryPos(bag, slot)) ApplyItemOnStoreSpell(pItem, false); - ItemRemovedQuestCheck( pItem->GetEntry(), pItem->GetCount() ); + ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount()); - if( bag == INVENTORY_SLOT_BAG_0 ) + if (bag == INVENTORY_SLOT_BAG_0) { SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid()); // equipment and equipped bags can have applied bonuses - if ( slot < INVENTORY_SLOT_BAG_END ) + if (slot < INVENTORY_SLOT_BAG_END) { - ItemPrototype const *pProto = pItem->GetProto(); + ItemPrototype const* pProto = pItem->GetProto(); // item set bonuses applied only at equip and removed at unequip, and still active for broken items - if(pProto && pProto->ItemSet) + if (pProto && pProto->ItemSet) RemoveItemsSetItem(this, pProto); _ApplyItemMods(pItem, slot, false); } - if ( slot < EQUIPMENT_SLOT_END ) + if (slot < EQUIPMENT_SLOT_END) { // remove item dependent auras and casts (only weapon and armor slots) RemoveItemDependentAurasAndCasts(pItem); // update expertise - if( slot == EQUIPMENT_SLOT_MAINHAND ) + if (slot == EQUIPMENT_SLOT_MAINHAND) { UpdateExpertise(BASE_ATTACK); UpdateArmorPenetration(); } - else if( slot == EQUIPMENT_SLOT_OFFHAND ) + else if (slot == EQUIPMENT_SLOT_OFFHAND) { UpdateExpertise(OFF_ATTACK); UpdateArmorPenetration(); @@ -11618,7 +11621,7 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) m_items[slot] = NULL; } - else if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag )) + else if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag)) pBag->RemoveItem(slot, update); if (IsInWorld() && update) @@ -11629,7 +11632,7 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) //pItem->SetOwnerGUID(0); pItem->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid()); - pItem->SetSlot( NULL_SLOT ); + pItem->SetSlot(NULL_SLOT); pItem->SetState(ITEM_REMOVED, this); } } @@ -11822,88 +11825,88 @@ void Player::DestroyItemCount(uint32 item, uint32 count, bool update, bool unequ } } -void Player::DestroyZoneLimitedItem( bool update, uint32 new_zone ) +void Player::DestroyZoneLimitedItem(bool update, uint32 new_zone) { - DEBUG_LOG( "STORAGE: DestroyZoneLimitedItem in map %u and area %u", GetMapId(), new_zone ); + DEBUG_LOG("STORAGE: DestroyZoneLimitedItem in map %u and area %u", GetMapId(), new_zone); // in inventory - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) - if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(), new_zone)) - DestroyItem( INVENTORY_SLOT_BAG_0, i, update); + DestroyItem(INVENTORY_SLOT_BAG_0, i, update); - for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) - if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + for (int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(), new_zone)) - DestroyItem( INVENTORY_SLOT_BAG_0, i, update); + DestroyItem(INVENTORY_SLOT_BAG_0, i, update); // in inventory bags - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) if (Item* pItem = pBag->GetItemByPos(j)) if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(), new_zone)) DestroyItem(i, j, update); // in equipment and bag list - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i) - if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->IsLimitedToAnotherMapOrZone(GetMapId(), new_zone)) - DestroyItem( INVENTORY_SLOT_BAG_0, i, update); + DestroyItem(INVENTORY_SLOT_BAG_0, i, update); } -void Player::DestroyConjuredItems( bool update ) +void Player::DestroyConjuredItems(bool update) { // used when entering arena // destroys all conjured items - DEBUG_LOG( "STORAGE: DestroyConjuredItems" ); + DEBUG_LOG("STORAGE: DestroyConjuredItems"); // in inventory - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) - if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->IsConjuredConsumable()) - DestroyItem( INVENTORY_SLOT_BAG_0, i, update); + DestroyItem(INVENTORY_SLOT_BAG_0, i, update); // in inventory bags - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) if (Item* pItem = pBag->GetItemByPos(j)) if (pItem->IsConjuredConsumable()) - DestroyItem( i, j, update); + DestroyItem(i, j, update); // in equipment and bag list - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i) - if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i) + if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->IsConjuredConsumable()) - DestroyItem( INVENTORY_SLOT_BAG_0, i, update); + DestroyItem(INVENTORY_SLOT_BAG_0, i, update); } -void Player::DestroyItemCount( Item* pItem, uint32 &count, bool update ) +void Player::DestroyItemCount(Item* pItem, uint32& count, bool update) { - if(!pItem) + if (!pItem) return; - DEBUG_LOG( "STORAGE: DestroyItemCount item (GUID: %u, Entry: %u) count = %u", pItem->GetGUIDLow(),pItem->GetEntry(), count); + DEBUG_LOG("STORAGE: DestroyItemCount item (GUID: %u, Entry: %u) count = %u", pItem->GetGUIDLow(),pItem->GetEntry(), count); - if( pItem->GetCount() <= count ) + if (pItem->GetCount() <= count) { count -= pItem->GetCount(); - DestroyItem( pItem->GetBagSlot(),pItem->GetSlot(), update); + DestroyItem(pItem->GetBagSlot(),pItem->GetSlot(), update); } else { - ItemRemovedQuestCheck( pItem->GetEntry(), count); - pItem->SetCount( pItem->GetCount() - count ); + ItemRemovedQuestCheck(pItem->GetEntry(), count); + pItem->SetCount(pItem->GetCount() - count); count = 0; if (IsInWorld() && update) - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendCreateUpdateToPlayer(this); pItem->SetState(ITEM_CHANGED, this); } } -void Player::SplitItem( uint16 src, uint16 dst, uint32 count ) +void Player::SplitItem(uint16 src, uint16 dst, uint32 count) { uint8 srcbag = src >> 8; uint8 srcslot = src & 255; @@ -11911,106 +11914,106 @@ void Player::SplitItem( uint16 src, uint16 dst, uint32 count ) uint8 dstbag = dst >> 8; uint8 dstslot = dst & 255; - Item *pSrcItem = GetItemByPos( srcbag, srcslot ); + Item* pSrcItem = GetItemByPos(srcbag, srcslot); if (!pSrcItem) { - SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, pSrcItem, NULL ); + SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pSrcItem, NULL); return; } if (pSrcItem->HasGeneratedLoot()) // prevent split looting item (stackable items can has only temporary loot and this meaning that loot window open) { //best error message found for attempting to split while looting - SendEquipError( EQUIP_ERR_COULDNT_SPLIT_ITEMS, pSrcItem, NULL ); + SendEquipError(EQUIP_ERR_COULDNT_SPLIT_ITEMS, pSrcItem, NULL); return; } // not let split all items (can be only at cheating) if (pSrcItem->GetCount() == count) { - SendEquipError( EQUIP_ERR_COULDNT_SPLIT_ITEMS, pSrcItem, NULL ); + SendEquipError(EQUIP_ERR_COULDNT_SPLIT_ITEMS, pSrcItem, NULL); return; } // not let split more existing items (can be only at cheating) if (pSrcItem->GetCount() < count) { - SendEquipError( EQUIP_ERR_TRIED_TO_SPLIT_MORE_THAN_COUNT, pSrcItem, NULL ); + SendEquipError(EQUIP_ERR_TRIED_TO_SPLIT_MORE_THAN_COUNT, pSrcItem, NULL); return; } - DEBUG_LOG( "STORAGE: SplitItem bag = %u, slot = %u, item = %u, count = %u", dstbag, dstslot, pSrcItem->GetEntry(), count); - Item *pNewItem = pSrcItem->CloneItem( count, this ); + DEBUG_LOG("STORAGE: SplitItem bag = %u, slot = %u, item = %u, count = %u", dstbag, dstslot, pSrcItem->GetEntry(), count); + Item* pNewItem = pSrcItem->CloneItem(count, this); if (!pNewItem) { - SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, pSrcItem, NULL ); + SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pSrcItem, NULL); return; } if (IsInventoryPos(dst)) { // change item amount before check (for unique max count check) - pSrcItem->SetCount( pSrcItem->GetCount() - count ); + pSrcItem->SetCount(pSrcItem->GetCount() - count); ItemPosCountVec dest; - InventoryResult msg = CanStoreItem( dstbag, dstslot, dest, pNewItem, false ); + InventoryResult msg = CanStoreItem(dstbag, dstslot, dest, pNewItem, false); if (msg != EQUIP_ERR_OK) { delete pNewItem; - pSrcItem->SetCount( pSrcItem->GetCount() + count ); - SendEquipError( msg, pSrcItem, NULL ); + pSrcItem->SetCount(pSrcItem->GetCount() + count); + SendEquipError(msg, pSrcItem, NULL); return; } if (IsInWorld()) - pSrcItem->SendCreateUpdateToPlayer( this ); + pSrcItem->SendCreateUpdateToPlayer(this); pSrcItem->SetState(ITEM_CHANGED, this); - StoreItem( dest, pNewItem, true); + StoreItem(dest, pNewItem, true); } - else if (IsBankPos (dst)) + else if (IsBankPos(dst)) { // change item amount before check (for unique max count check) - pSrcItem->SetCount( pSrcItem->GetCount() - count ); + pSrcItem->SetCount(pSrcItem->GetCount() - count); ItemPosCountVec dest; - InventoryResult msg = CanBankItem( dstbag, dstslot, dest, pNewItem, false ); - if( msg != EQUIP_ERR_OK ) - { - delete pNewItem; - pSrcItem->SetCount( pSrcItem->GetCount() + count ); - SendEquipError( msg, pSrcItem, NULL ); - return; - } - - if (IsInWorld()) - pSrcItem->SendCreateUpdateToPlayer( this ); - pSrcItem->SetState(ITEM_CHANGED, this); - BankItem( dest, pNewItem, true); - } - else if (IsEquipmentPos (dst)) - { - // change item amount before check (for unique max count check), provide space for splitted items - pSrcItem->SetCount( pSrcItem->GetCount() - count ); - - uint16 dest; - InventoryResult msg = CanEquipItem( dstslot, dest, pNewItem, false ); + InventoryResult msg = CanBankItem(dstbag, dstslot, dest, pNewItem, false); if (msg != EQUIP_ERR_OK) { delete pNewItem; - pSrcItem->SetCount( pSrcItem->GetCount() + count ); - SendEquipError( msg, pSrcItem, NULL ); + pSrcItem->SetCount(pSrcItem->GetCount() + count); + SendEquipError(msg, pSrcItem, NULL); return; } if (IsInWorld()) - pSrcItem->SendCreateUpdateToPlayer( this ); + pSrcItem->SendCreateUpdateToPlayer(this); pSrcItem->SetState(ITEM_CHANGED, this); - EquipItem( dest, pNewItem, true); + BankItem(dest, pNewItem, true); + } + else if (IsEquipmentPos(dst)) + { + // change item amount before check (for unique max count check), provide space for splitted items + pSrcItem->SetCount(pSrcItem->GetCount() - count); + + uint16 dest; + InventoryResult msg = CanEquipItem(dstslot, dest, pNewItem, false); + if (msg != EQUIP_ERR_OK) + { + delete pNewItem; + pSrcItem->SetCount(pSrcItem->GetCount() + count); + SendEquipError(msg, pSrcItem, NULL); + return; + } + + if (IsInWorld()) + pSrcItem->SendCreateUpdateToPlayer(this); + pSrcItem->SetState(ITEM_CHANGED, this); + EquipItem(dest, pNewItem, true); AutoUnequipOffhandIfNeed(); } } -void Player::SwapItem( uint16 src, uint16 dst ) +void Player::SwapItem(uint16 src, uint16 dst) { uint8 srcbag = src >> 8; uint8 srcslot = src & 255; @@ -12018,17 +12021,17 @@ void Player::SwapItem( uint16 src, uint16 dst ) uint8 dstbag = dst >> 8; uint8 dstslot = dst & 255; - Item *pSrcItem = GetItemByPos( srcbag, srcslot ); - Item *pDstItem = GetItemByPos( dstbag, dstslot ); + Item* pSrcItem = GetItemByPos(srcbag, srcslot); + Item* pDstItem = GetItemByPos(dstbag, dstslot); if (!pSrcItem) return; - DEBUG_LOG( "STORAGE: SwapItem bag = %u, slot = %u, item = %u", dstbag, dstslot, pSrcItem->GetEntry()); + DEBUG_LOG("STORAGE: SwapItem bag = %u, slot = %u, item = %u", dstbag, dstslot, pSrcItem->GetEntry()); if (!isAlive()) { - SendEquipError( EQUIP_ERR_YOU_ARE_DEAD, pSrcItem, pDstItem ); + SendEquipError(EQUIP_ERR_YOU_ARE_DEAD, pSrcItem, pDstItem); return; } @@ -12038,10 +12041,10 @@ void Player::SwapItem( uint16 src, uint16 dst ) if (IsEquipmentPos(src) || IsBagPos(src)) { // bags can be swapped with empty bag slots, or with empty bag (items move possibility checked later) - InventoryResult msg = CanUnequipItem( src, !IsBagPos ( src ) || IsBagPos ( dst ) || (pDstItem && pDstItem->IsBag() && ((Bag*)pDstItem)->IsEmpty())); + InventoryResult msg = CanUnequipItem(src, !IsBagPos(src) || IsBagPos(dst) || (pDstItem && pDstItem->IsBag() && ((Bag*)pDstItem)->IsEmpty())); if (msg != EQUIP_ERR_OK) { - SendEquipError( msg, pSrcItem, pDstItem ); + SendEquipError(msg, pSrcItem, pDstItem); return; } } @@ -12049,14 +12052,14 @@ void Player::SwapItem( uint16 src, uint16 dst ) // prevent put equipped/bank bag in self if (IsBagPos(src) && srcslot == dstbag) { - SendEquipError( EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pSrcItem, pDstItem ); + SendEquipError(EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pSrcItem, pDstItem); return; } // prevent put equipped/bank bag in self if (IsBagPos(dst) && dstslot == srcbag) { - SendEquipError( EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pDstItem, pSrcItem ); + SendEquipError(EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pDstItem, pSrcItem); return; } @@ -12065,13 +12068,13 @@ void Player::SwapItem( uint16 src, uint16 dst ) if (pDstItem) { // check unequip potability for equipped items and bank bags - if(IsEquipmentPos ( dst ) || IsBagPos ( dst )) + if (IsEquipmentPos(dst) || IsBagPos(dst)) { // bags can be swapped with empty bag slots, or with empty bag (items move possibility checked later) - InventoryResult msg = CanUnequipItem( dst, !IsBagPos ( dst ) || IsBagPos ( src ) || (pSrcItem->IsBag() && ((Bag*)pSrcItem)->IsEmpty())); - if(msg != EQUIP_ERR_OK) + InventoryResult msg = CanUnequipItem(dst, !IsBagPos(dst) || IsBagPos(src) || (pSrcItem->IsBag() && ((Bag*)pSrcItem)->IsEmpty())); + if (msg != EQUIP_ERR_OK) { - SendEquipError( msg, pSrcItem, pDstItem ); + SendEquipError(msg, pSrcItem, pDstItem); return; } } @@ -12081,41 +12084,41 @@ void Player::SwapItem( uint16 src, uint16 dst ) // or swap empty bag with another empty or not empty bag (with items exchange) // Move case - if( !pDstItem ) + if (!pDstItem) { - if( IsInventoryPos( dst ) ) + if (IsInventoryPos(dst)) { ItemPosCountVec dest; - InventoryResult msg = CanStoreItem( dstbag, dstslot, dest, pSrcItem, false ); - if( msg != EQUIP_ERR_OK ) + InventoryResult msg = CanStoreItem(dstbag, dstslot, dest, pSrcItem, false); + if (msg != EQUIP_ERR_OK) { - SendEquipError( msg, pSrcItem, NULL ); + SendEquipError(msg, pSrcItem, NULL); return; } RemoveItem(srcbag, srcslot, true); - StoreItem( dest, pSrcItem, true); + StoreItem(dest, pSrcItem, true); } - else if( IsBankPos ( dst ) ) + else if (IsBankPos(dst)) { ItemPosCountVec dest; - InventoryResult msg = CanBankItem( dstbag, dstslot, dest, pSrcItem, false); - if( msg != EQUIP_ERR_OK ) + InventoryResult msg = CanBankItem(dstbag, dstslot, dest, pSrcItem, false); + if (msg != EQUIP_ERR_OK) { - SendEquipError( msg, pSrcItem, NULL ); + SendEquipError(msg, pSrcItem, NULL); return; } RemoveItem(srcbag, srcslot, true); - BankItem( dest, pSrcItem, true); + BankItem(dest, pSrcItem, true); } - else if( IsEquipmentPos ( dst ) ) + else if (IsEquipmentPos(dst)) { uint16 dest; - InventoryResult msg = CanEquipItem( dstslot, dest, pSrcItem, false ); - if( msg != EQUIP_ERR_OK ) + InventoryResult msg = CanEquipItem(dstslot, dest, pSrcItem, false); + if (msg != EQUIP_ERR_OK) { - SendEquipError( msg, pSrcItem, NULL ); + SendEquipError(msg, pSrcItem, NULL); return; } @@ -12128,47 +12131,47 @@ void Player::SwapItem( uint16 src, uint16 dst ) } // attempt merge to / fill target item - if(!pSrcItem->IsBag() && !pDstItem->IsBag()) + if (!pSrcItem->IsBag() && !pDstItem->IsBag()) { InventoryResult msg; ItemPosCountVec sDest; uint16 eDest; - if( IsInventoryPos( dst ) ) - msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, false ); - else if( IsBankPos ( dst ) ) - msg = CanBankItem( dstbag, dstslot, sDest, pSrcItem, false ); - else if( IsEquipmentPos ( dst ) ) - msg = CanEquipItem( dstslot, eDest, pSrcItem, false ); + if (IsInventoryPos(dst)) + msg = CanStoreItem(dstbag, dstslot, sDest, pSrcItem, false); + else if (IsBankPos(dst)) + msg = CanBankItem(dstbag, dstslot, sDest, pSrcItem, false); + else if (IsEquipmentPos(dst)) + msg = CanEquipItem(dstslot, eDest, pSrcItem, false); else return; // can be merge/fill - if(msg == EQUIP_ERR_OK) + if (msg == EQUIP_ERR_OK) { - if( pSrcItem->GetCount() + pDstItem->GetCount() <= pSrcItem->GetProto()->GetMaxStackSize()) + if (pSrcItem->GetCount() + pDstItem->GetCount() <= pSrcItem->GetProto()->GetMaxStackSize()) { RemoveItem(srcbag, srcslot, true); - if( IsInventoryPos( dst ) ) - StoreItem( sDest, pSrcItem, true); - else if( IsBankPos ( dst ) ) - BankItem( sDest, pSrcItem, true); - else if( IsEquipmentPos ( dst ) ) + if (IsInventoryPos(dst)) + StoreItem(sDest, pSrcItem, true); + else if (IsBankPos(dst)) + BankItem(sDest, pSrcItem, true); + else if (IsEquipmentPos(dst)) { - EquipItem( eDest, pSrcItem, true); + EquipItem(eDest, pSrcItem, true); AutoUnequipOffhandIfNeed(); } } else { - pSrcItem->SetCount( pSrcItem->GetCount() + pDstItem->GetCount() - pSrcItem->GetProto()->GetMaxStackSize()); - pDstItem->SetCount( pSrcItem->GetProto()->GetMaxStackSize()); + pSrcItem->SetCount(pSrcItem->GetCount() + pDstItem->GetCount() - pSrcItem->GetProto()->GetMaxStackSize()); + pDstItem->SetCount(pSrcItem->GetProto()->GetMaxStackSize()); pSrcItem->SetState(ITEM_CHANGED, this); pDstItem->SetState(ITEM_CHANGED, this); - if( IsInWorld() ) + if (IsInWorld()) { - pSrcItem->SendCreateUpdateToPlayer( this ); - pDstItem->SendCreateUpdateToPlayer( this ); + pSrcItem->SendCreateUpdateToPlayer(this); + pDstItem->SendCreateUpdateToPlayer(this); } } return; @@ -12181,69 +12184,69 @@ void Player::SwapItem( uint16 src, uint16 dst ) // check src->dest move possibility ItemPosCountVec sDest; uint16 eDest = 0; - if( IsInventoryPos( dst ) ) - msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, true ); - else if( IsBankPos( dst ) ) - msg = CanBankItem( dstbag, dstslot, sDest, pSrcItem, true ); - else if( IsEquipmentPos( dst ) ) + if (IsInventoryPos(dst)) + msg = CanStoreItem(dstbag, dstslot, sDest, pSrcItem, true); + else if (IsBankPos(dst)) + msg = CanBankItem(dstbag, dstslot, sDest, pSrcItem, true); + else if (IsEquipmentPos(dst)) { - msg = CanEquipItem( dstslot, eDest, pSrcItem, true ); - if( msg == EQUIP_ERR_OK ) - msg = CanUnequipItem( eDest, true ); + msg = CanEquipItem(dstslot, eDest, pSrcItem, true); + if (msg == EQUIP_ERR_OK) + msg = CanUnequipItem(eDest, true); } - if( msg != EQUIP_ERR_OK ) + if (msg != EQUIP_ERR_OK) { - SendEquipError( msg, pSrcItem, pDstItem ); + SendEquipError(msg, pSrcItem, pDstItem); return; } // check dest->src move possibility ItemPosCountVec sDest2; uint16 eDest2 = 0; - if( IsInventoryPos( src ) ) - msg = CanStoreItem( srcbag, srcslot, sDest2, pDstItem, true ); - else if( IsBankPos( src ) ) - msg = CanBankItem( srcbag, srcslot, sDest2, pDstItem, true ); - else if( IsEquipmentPos( src ) ) + if (IsInventoryPos(src)) + msg = CanStoreItem(srcbag, srcslot, sDest2, pDstItem, true); + else if (IsBankPos(src)) + msg = CanBankItem(srcbag, srcslot, sDest2, pDstItem, true); + else if (IsEquipmentPos(src)) { - msg = CanEquipItem( srcslot, eDest2, pDstItem, true); - if( msg == EQUIP_ERR_OK ) - msg = CanUnequipItem( eDest2, true); + msg = CanEquipItem(srcslot, eDest2, pDstItem, true); + if (msg == EQUIP_ERR_OK) + msg = CanUnequipItem(eDest2, true); } - if( msg != EQUIP_ERR_OK ) + if (msg != EQUIP_ERR_OK) { - SendEquipError( msg, pDstItem, pSrcItem ); + SendEquipError(msg, pDstItem, pSrcItem); return; } // Check bag swap with item exchange (one from empty in not bag possition (equipped (not possible in fact) or store) - if(pSrcItem->IsBag() && pDstItem->IsBag()) + if (pSrcItem->IsBag() && pDstItem->IsBag()) { Bag* emptyBag = NULL; Bag* fullBag = NULL; - if(((Bag*)pSrcItem)->IsEmpty() && !IsBagPos(src)) + if (((Bag*)pSrcItem)->IsEmpty() && !IsBagPos(src)) { emptyBag = (Bag*)pSrcItem; fullBag = (Bag*)pDstItem; } - else if(((Bag*)pDstItem)->IsEmpty() && !IsBagPos(dst)) + else if (((Bag*)pDstItem)->IsEmpty() && !IsBagPos(dst)) { emptyBag = (Bag*)pDstItem; fullBag = (Bag*)pSrcItem; } // bag swap (with items exchange) case - if(emptyBag && fullBag) + if (emptyBag && fullBag) { ItemPrototype const* emotyProto = emptyBag->GetProto(); uint32 count = 0; - for(uint32 i=0; i < fullBag->GetBagSize(); ++i) + for (uint32 i=0; i < fullBag->GetBagSize(); ++i) { - Item *bagItem = fullBag->GetItemByPos(i); + Item* bagItem = fullBag->GetItemByPos(i); if (!bagItem) continue; @@ -12251,7 +12254,7 @@ void Player::SwapItem( uint16 src, uint16 dst ) if (!bagItemProto || !ItemCanGoIntoBag(bagItemProto, emotyProto)) { // one from items not go to empty target bag - SendEquipError( EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pSrcItem, pDstItem ); + SendEquipError(EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pSrcItem, pDstItem); return; } @@ -12261,15 +12264,15 @@ void Player::SwapItem( uint16 src, uint16 dst ) if (count > emptyBag->GetBagSize()) { // too small targeted bag - SendEquipError( EQUIP_ERR_ITEMS_CANT_BE_SWAPPED, pSrcItem, pDstItem ); + SendEquipError(EQUIP_ERR_ITEMS_CANT_BE_SWAPPED, pSrcItem, pDstItem); return; } // Items swap count = 0; // will pos in new bag - for(uint32 i = 0; i< fullBag->GetBagSize(); ++i) + for (uint32 i = 0; i< fullBag->GetBagSize(); ++i) { - Item *bagItem = fullBag->GetItemByPos(i); + Item* bagItem = fullBag->GetItemByPos(i); if (!bagItem) continue; @@ -12305,7 +12308,7 @@ void Player::SwapItem( uint16 src, uint16 dst ) AutoUnequipOffhandIfNeed(); } -void Player::AddItemToBuyBackSlot( Item *pItem ) +void Player::AddItemToBuyBackSlot(Item* pItem) { if (pItem) { @@ -12313,10 +12316,10 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) // if current back slot non-empty search oldest or free if (m_items[slot]) { - uint32 oldest_time = GetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 ); + uint32 oldest_time = GetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1); uint32 oldest_slot = BUYBACK_SLOT_START; - for(uint32 i = BUYBACK_SLOT_START+1; i < BUYBACK_SLOT_END; ++i ) + for (uint32 i = BUYBACK_SLOT_START+1; i < BUYBACK_SLOT_END; ++i) { // found empty if (!m_items[i]) @@ -12325,7 +12328,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) break; } - uint32 i_time = GetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + i - BUYBACK_SLOT_START); + uint32 i_time = GetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + i - BUYBACK_SLOT_START); if (oldest_time > i_time) { @@ -12338,8 +12341,8 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) slot = oldest_slot; } - RemoveItemFromBuyBackSlot( slot, true ); - DEBUG_LOG( "STORAGE: AddItemToBuyBackSlot item = %u, slot = %u", pItem->GetEntry(), slot); + RemoveItemFromBuyBackSlot(slot, true); + DEBUG_LOG("STORAGE: AddItemToBuyBackSlot item = %u, slot = %u", pItem->GetEntry(), slot); m_items[slot] = pItem; time_t base = time(NULL); @@ -12347,11 +12350,11 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) uint32 eslot = slot - BUYBACK_SLOT_START; SetGuidValue(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), pItem->GetObjectGuid()); - if (ItemPrototype const *pProto = pItem->GetProto()) - SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, pProto->SellPrice * pItem->GetCount() ); + if (ItemPrototype const* pProto = pItem->GetProto()) + SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, pProto->SellPrice * pItem->GetCount()); else - SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0 ); - SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, (uint32)etime ); + SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0); + SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, (uint32)etime); // move to next (for non filled list is move most optimized choice) if (m_currentBuybackSlot < BUYBACK_SLOT_END - 1) @@ -12359,24 +12362,24 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) } } -Item* Player::GetItemFromBuyBackSlot( uint32 slot ) +Item* Player::GetItemFromBuyBackSlot(uint32 slot) { - DEBUG_LOG( "STORAGE: GetItemFromBuyBackSlot slot = %u", slot); + DEBUG_LOG("STORAGE: GetItemFromBuyBackSlot slot = %u", slot); if (slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END) return m_items[slot]; return NULL; } -void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) +void Player::RemoveItemFromBuyBackSlot(uint32 slot, bool del) { - DEBUG_LOG( "STORAGE: RemoveItemFromBuyBackSlot slot = %u", slot); + DEBUG_LOG("STORAGE: RemoveItemFromBuyBackSlot slot = %u", slot); if (slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END) { - Item *pItem = m_items[slot]; + Item* pItem = m_items[slot]; if (pItem) { pItem->RemoveFromWorld(); - if(del) pItem->SetState(ITEM_REMOVED, this); + if (del) pItem->SetState(ITEM_REMOVED, this); } m_items[slot] = NULL; @@ -12392,9 +12395,9 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) } } -void Player::SendEquipError( InventoryResult msg, Item* pItem, Item *pItem2, uint32 itemid /*= 0*/ ) const +void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint32 itemid /*= 0*/) const { - DEBUG_LOG( "WORLD: Sent SMSG_INVENTORY_CHANGE_FAILURE (%u)", msg); + DEBUG_LOG("WORLD: Sent SMSG_INVENTORY_CHANGE_FAILURE (%u)", msg); WorldPacket data(SMSG_INVENTORY_CHANGE_FAILURE, 1+8+8+1); data << uint8(msg); @@ -12404,7 +12407,7 @@ void Player::SendEquipError( InventoryResult msg, Item* pItem, Item *pItem2, uin data << (pItem2 ? pItem2->GetObjectGuid() : ObjectGuid()); data << uint8(0); // bag type subclass, used with EQUIP_ERR_EVENT_AUTOEQUIP_BIND_CONFIRM and EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG2 - switch(msg) + switch (msg) { case EQUIP_ERR_CANT_EQUIP_LEVEL_I: case EQUIP_ERR_PURCHASE_LEVEL_TOO_LOW: @@ -12435,10 +12438,10 @@ void Player::SendEquipError( InventoryResult msg, Item* pItem, Item *pItem2, uin GetSession()->SendPacket(&data); } -void Player::SendBuyError( BuyResult msg, Creature* pCreature, uint32 item, uint32 param ) +void Player::SendBuyError(BuyResult msg, Creature* pCreature, uint32 item, uint32 param) { - DEBUG_LOG( "WORLD: Sent SMSG_BUY_FAILED" ); - WorldPacket data( SMSG_BUY_FAILED, (8+4+4+1) ); + DEBUG_LOG("WORLD: Sent SMSG_BUY_FAILED"); + WorldPacket data(SMSG_BUY_FAILED, (8+4+4+1)); data << (pCreature ? pCreature->GetObjectGuid() : ObjectGuid()); data << uint32(item); if (param > 0) @@ -12447,10 +12450,10 @@ void Player::SendBuyError( BuyResult msg, Creature* pCreature, uint32 item, uint GetSession()->SendPacket(&data); } -void Player::SendSellError( SellResult msg, Creature* pCreature, ObjectGuid itemGuid, uint32 param ) +void Player::SendSellError(SellResult msg, Creature* pCreature, ObjectGuid itemGuid, uint32 param) { - DEBUG_LOG( "WORLD: Sent SMSG_SELL_ITEM" ); - WorldPacket data( SMSG_SELL_ITEM,(8+8+(param?4:0)+1)); // last check 2.0.10 + DEBUG_LOG("WORLD: Sent SMSG_SELL_ITEM"); + WorldPacket data(SMSG_SELL_ITEM,(8+8+(param?4:0)+1)); // last check 2.0.10 data << (pCreature ? pCreature->GetObjectGuid() : ObjectGuid()); data << ObjectGuid(itemGuid); if (param > 0) @@ -12486,7 +12489,7 @@ void Player::UpdateItemDuration(uint32 time, bool realtimeonly) DEBUG_LOG("Player::UpdateItemDuration(%u,%u)", time, realtimeonly); - for(ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ) + for (ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end();) { Item* item = *itr; ++itr; // current element can be erased in UpdateDuration @@ -12498,7 +12501,7 @@ void Player::UpdateItemDuration(uint32 time, bool realtimeonly) void Player::UpdateEnchantTime(uint32 time) { - for(EnchantDurationList::iterator itr = m_enchantDuration.begin(),next;itr != m_enchantDuration.end();itr=next) + for (EnchantDurationList::iterator itr = m_enchantDuration.begin(),next; itr != m_enchantDuration.end(); itr=next) { MANGOS_ASSERT(itr->item); next = itr; @@ -12520,9 +12523,9 @@ void Player::UpdateEnchantTime(uint32 time) } } -void Player::AddEnchantmentDurations(Item *item) +void Player::AddEnchantmentDurations(Item* item) { - for(int x = 0; x < MAX_ENCHANTMENT_SLOT; ++x) + for (int x = 0; x < MAX_ENCHANTMENT_SLOT; ++x) { if (!item->GetEnchantmentId(EnchantmentSlot(x))) continue; @@ -12533,9 +12536,9 @@ void Player::AddEnchantmentDurations(Item *item) } } -void Player::RemoveEnchantmentDurations(Item *item) +void Player::RemoveEnchantmentDurations(Item* item) { - for(EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end();) + for (EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end();) { if (itr->item == item) { @@ -12551,7 +12554,7 @@ void Player::RemoveEnchantmentDurations(Item *item) void Player::RemoveAllEnchantments(EnchantmentSlot slot) { // remove enchantments from equipped items first to clean up the m_enchantDuration list - for(EnchantDurationList::iterator itr = m_enchantDuration.begin(), next; itr != m_enchantDuration.end(); itr = next) + for (EnchantDurationList::iterator itr = m_enchantDuration.begin(), next; itr != m_enchantDuration.end(); itr = next) { next = itr; if (itr->slot == slot) @@ -12573,22 +12576,22 @@ void Player::RemoveAllEnchantments(EnchantmentSlot slot) // remove enchants from inventory items // NOTE: no need to remove these from stats, since these aren't equipped // in inventory - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) + for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetEnchantmentId(slot)) pItem->ClearEnchantment(slot); // in inventory bags - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - if (Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) if (Item* pItem = pBag->GetItemByPos(j)) if (pItem->GetEnchantmentId(slot)) pItem->ClearEnchantment(slot); } // duration == 0 will remove item enchant -void Player::AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration) +void Player::AddEnchantmentDuration(Item* item,EnchantmentSlot slot,uint32 duration) { if (!item) return; @@ -12596,7 +12599,7 @@ void Player::AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 durat if (slot >= MAX_ENCHANTMENT_SLOT) return; - for(EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) + for (EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) { if (itr->item == item && itr->slot == slot) { @@ -12605,20 +12608,20 @@ void Player::AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 durat break; } } - if (item && duration > 0 ) + if (item && duration > 0) { GetSession()->SendItemEnchantTimeUpdate(GetObjectGuid(), item->GetObjectGuid(), slot, uint32(duration/1000)); m_enchantDuration.push_back(EnchantDuration(item, slot, duration)); } } -void Player::ApplyEnchantment(Item *item,bool apply) +void Player::ApplyEnchantment(Item* item,bool apply) { - for(uint32 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot) + for (uint32 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot) ApplyEnchantment(item, EnchantmentSlot(slot), apply); } -void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool apply_dur, bool ignore_condition) +void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool apply_dur, bool ignore_condition) { if (!item) return; @@ -12633,7 +12636,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool if (!enchant_id) return; - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) return; @@ -12648,7 +12651,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool uint32 enchant_amount = pEnchant->amount[s]; uint32 enchant_spell_id = pEnchant->spellid[s]; - switch(enchant_display_type) + switch (enchant_display_type) { case ITEM_ENCHANTMENT_TYPE_NONE: break; @@ -12673,15 +12676,15 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool // Random Property Exist - try found basepoints for spell (basepoints depends from item suffix factor) if (item->GetItemRandomPropertyId()) { - ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); if (item_rand) { // Search enchant_amount for (int k = 0; k < 3; ++k) { - if(item_rand->enchant_id[k] == enchant_id) + if (item_rand->enchant_id[k] == enchant_id) { - basepoints = int32((item_rand->prefix[k] * item->GetItemSuffixFactor()) / 10000 ); + basepoints = int32((item_rand->prefix[k] * item->GetItemSuffixFactor()) / 10000); break; } } @@ -12701,14 +12704,14 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool case ITEM_ENCHANTMENT_TYPE_RESISTANCE: if (!enchant_amount) { - ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); - if(item_rand) + ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + if (item_rand) { for (int k = 0; k < 3; ++k) { - if(item_rand->enchant_id[k] == enchant_id) + if (item_rand->enchant_id[k] == enchant_id) { - enchant_amount = uint32((item_rand->prefix[k] * item->GetItemSuffixFactor()) / 10000 ); + enchant_amount = uint32((item_rand->prefix[k] * item->GetItemSuffixFactor()) / 10000); break; } } @@ -12721,14 +12724,14 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool { if (!enchant_amount) { - ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); - if(item_rand_suffix) + ItemRandomSuffixEntry const* item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + if (item_rand_suffix) { for (int k = 0; k < 3; ++k) { - if(item_rand_suffix->enchant_id[k] == enchant_id) + if (item_rand_suffix->enchant_id[k] == enchant_id) { - enchant_amount = uint32((item_rand_suffix->prefix[k] * item->GetItemSuffixFactor()) / 10000 ); + enchant_amount = uint32((item_rand_suffix->prefix[k] * item->GetItemSuffixFactor()) / 10000); break; } } @@ -12913,15 +12916,15 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool } case ITEM_ENCHANTMENT_TYPE_TOTEM: // Shaman Rockbiter Weapon { - if(getClass() == CLASS_SHAMAN) + if (getClass() == CLASS_SHAMAN) { float addValue = 0.0f; - if(item->GetSlot() == EQUIPMENT_SLOT_MAINHAND) + if (item->GetSlot() == EQUIPMENT_SLOT_MAINHAND) { addValue = float(enchant_amount * item->GetProto()->Delay / 1000.0f); HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, addValue, apply); } - else if(item->GetSlot() == EQUIPMENT_SLOT_OFFHAND ) + else if (item->GetSlot() == EQUIPMENT_SLOT_OFFHAND) { addValue = float(enchant_amount * item->GetProto()->Delay / 1000.0f); HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, addValue, apply); @@ -12943,20 +12946,20 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool } // visualize enchantment at player and equipped items - if(slot == PERM_ENCHANTMENT_SLOT) + if (slot == PERM_ENCHANTMENT_SLOT) SetUInt16Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (item->GetSlot() * 2), 0, apply ? item->GetEnchantmentId(slot) : 0); - if(slot == TEMP_ENCHANTMENT_SLOT) + if (slot == TEMP_ENCHANTMENT_SLOT) SetUInt16Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (item->GetSlot() * 2), 1, apply ? item->GetEnchantmentId(slot) : 0); - if(apply_dur) + if (apply_dur) { - if(apply) + if (apply) { // set duration uint32 duration = item->GetEnchantmentDuration(slot); - if(duration > 0) + if (duration > 0) AddEnchantmentDuration(item, slot, duration); } else @@ -12969,7 +12972,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool void Player::SendEnchantmentDurations() { - for(EnchantDurationList::const_iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) + for (EnchantDurationList::const_iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) { GetSession()->SendItemEnchantTimeUpdate(GetObjectGuid(), itr->item->GetObjectGuid(), itr->slot, uint32(itr->leftduration) / 1000); } @@ -12977,25 +12980,25 @@ void Player::SendEnchantmentDurations() void Player::SendItemDurations() { - for(ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ++itr) + for (ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ++itr) { (*itr)->SendTimeUpdate(this); } } -void Player::SendNewItem(Item *item, uint32 count, bool received, bool created, bool broadcast) +void Player::SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast) { - if(!item) // prevent crash + if (!item) // prevent crash return; - // last check 2.0.10 - WorldPacket data( SMSG_ITEM_PUSH_RESULT, (8+4+4+4+1+4+4+4+4+4) ); + // last check 2.0.10 + WorldPacket data(SMSG_ITEM_PUSH_RESULT, (8+4+4+4+1+4+4+4+4+4)); data << GetObjectGuid(); // player GUID data << uint32(received); // 0=looted, 1=from npc data << uint32(created); // 0=received, 1=created data << uint32(1); // IsShowChatMessage data << uint8(item->GetBagSlot()); // bagslot - // item slot, but when added to stack: 0xFFFFFFFF + // item slot, but when added to stack: 0xFFFFFFFF data << uint32((item->GetCount() == count) ? item->GetSlot() : -1); data << uint32(item->GetEntry()); // item id data << uint32(item->GetItemSuffixFactor()); // SuffixFactor @@ -13013,7 +13016,7 @@ void Player::SendNewItem(Item *item, uint32 count, bool received, bool created, /*** GOSSIP SYSTEM ***/ /*********************************************************/ -void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId) +void Player::PrepareGossipMenu(WorldObject* pSource, uint32 menuId) { PlayerMenu* pMenu = PlayerTalkClass; pMenu->ClearMenus(); @@ -13031,7 +13034,7 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId) bool canTalkToCredit = pSource->GetTypeId() == TYPEID_UNIT; - for(GossipMenuItemsMap::const_iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr) + for (GossipMenuItemsMap::const_iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr) { bool hasMenuItem = true; @@ -13044,40 +13047,40 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId) continue; } else if (!itr->second.conditionId) - { - if (itr->second.cond_1 && !sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_1)) { - if (itr->second.option_id == GOSSIP_OPTION_QUESTGIVER) - canSeeQuests = false; - continue; - } + if (itr->second.cond_1 && !sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_1)) + { + if (itr->second.option_id == GOSSIP_OPTION_QUESTGIVER) + canSeeQuests = false; + continue; + } - if (itr->second.cond_2 && !sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_2)) - { - if (itr->second.option_id == GOSSIP_OPTION_QUESTGIVER) - canSeeQuests = false; - continue; - } + if (itr->second.cond_2 && !sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_2)) + { + if (itr->second.option_id == GOSSIP_OPTION_QUESTGIVER) + canSeeQuests = false; + continue; + } - if (itr->second.cond_3 && !sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_3)) - { - if (itr->second.option_id == GOSSIP_OPTION_QUESTGIVER) - canSeeQuests = false; - continue; + if (itr->second.cond_3 && !sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_3)) + { + if (itr->second.option_id == GOSSIP_OPTION_QUESTGIVER) + canSeeQuests = false; + continue; + } } } - } if (pSource->GetTypeId() == TYPEID_UNIT) { - Creature *pCreature = (Creature*)pSource; + Creature* pCreature = (Creature*)pSource; uint32 npcflags = pCreature->GetUInt32Value(UNIT_NPC_FLAGS); if (!(itr->second.npc_option_npcflag & npcflags)) continue; - switch(itr->second.option_id) + switch (itr->second.option_id) { case GOSSIP_OPTION_GOSSIP: if (itr->second.action_menu_id != 0) // has sub menu (or close gossip), so do not "talk" with this NPC yet @@ -13120,7 +13123,7 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId) case GOSSIP_OPTION_UNLEARNPETSKILLS: if (pCreature->GetCreatureInfo()->trainer_type != TRAINER_TYPE_PETS || pCreature->GetCreatureInfo()->trainer_class != CLASS_HUNTER) hasMenuItem = false; - else if (Pet * pet = GetPet()) + else if (Pet* pet = GetPet()) { if (pet->getPetType() != HUNTER_PET || pet->m_spells.size() <= 1) hasMenuItem = false; @@ -13156,9 +13159,9 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId) } else if (pSource->GetTypeId() == TYPEID_GAMEOBJECT) { - GameObject *pGo = (GameObject*)pSource; + GameObject* pGo = (GameObject*)pSource; - switch(itr->second.option_id) + switch (itr->second.option_id) { case GOSSIP_OPTION_QUESTGIVER: hasMenuItem = false; @@ -13184,7 +13187,7 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId) { uint32 idxEntry = MAKE_PAIR32(menuId, itr->second.id); - if (GossipMenuItemsLocale const *no = sObjectMgr.GetGossipMenuItemsLocale(idxEntry)) + if (GossipMenuItemsLocale const* no = sObjectMgr.GetGossipMenuItemsLocale(idxEntry)) { if (no->OptionText.size() > (size_t)loc_idx && !no->OptionText[loc_idx].empty()) strOptionText = no->OptionText[loc_idx]; @@ -13225,7 +13228,7 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId) }*/ } -void Player::SendPreparedGossip(WorldObject *pSource) +void Player::SendPreparedGossip(WorldObject* pSource) { if (!pSource) return; @@ -13397,7 +13400,7 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me } } -uint32 Player::GetGossipTextId(WorldObject *pSource) +uint32 Player::GetGossipTextId(WorldObject* pSource) { if (!pSource || pSource->GetTypeId() != TYPEID_UNIT) return DEFAULT_GOSSIP_MESSAGE; @@ -13429,23 +13432,23 @@ uint32 Player::GetGossipTextId(uint32 menuId, WorldObject* pSource) break; } else if (!itr->second.conditionId) - { - if (sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_1) && sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_2)) { - textId = itr->second.text_id; + if (sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_1) && sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_2)) + { + textId = itr->second.text_id; - // Start related script - if (itr->second.script_id) - GetMap()->ScriptsStart(sGossipScripts, itr->second.script_id, this, pSource); - break; + // Start related script + if (itr->second.script_id) + GetMap()->ScriptsStart(sGossipScripts, itr->second.script_id, this, pSource); + break; + } } } - } return textId; } -uint32 Player::GetDefaultGossipMenuForSource(WorldObject *pSource) +uint32 Player::GetDefaultGossipMenuForSource(WorldObject* pSource) { if (pSource->GetTypeId() == TYPEID_UNIT) return ((Creature*)pSource)->GetCreatureInfo()->GossipMenuId; @@ -13465,7 +13468,7 @@ void Player::PrepareQuestMenu(ObjectGuid guid) QuestRelationsMapBounds irbounds; // pets also can have quests - if (Creature *pCreature = GetMap()->GetAnyTypeCreature(guid)) + if (Creature* pCreature = GetMap()->GetAnyTypeCreature(guid)) { rbounds = sObjectMgr.GetCreatureQuestRelationsMapBounds(pCreature->GetEntry()); irbounds = sObjectMgr.GetCreatureQuestInvolvedRelationsMapBounds(pCreature->GetEntry()); @@ -13474,10 +13477,10 @@ void Player::PrepareQuestMenu(ObjectGuid guid) { //we should obtain map pointer from GetMap() in 99% of cases. Special case //only for quests which cast teleport spells on player - Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId()); + Map* _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId()); MANGOS_ASSERT(_map); - if (GameObject *pGameObject = _map->GetGameObject(guid)) + if (GameObject* pGameObject = _map->GetGameObject(guid)) { rbounds = sObjectMgr.GetGOQuestRelationsMapBounds(pGameObject->GetEntry()); irbounds = sObjectMgr.GetGOQuestInvolvedRelationsMapBounds(pGameObject->GetEntry()); @@ -13486,10 +13489,10 @@ void Player::PrepareQuestMenu(ObjectGuid guid) return; } - QuestMenu &qm = PlayerTalkClass->GetQuestMenu(); + QuestMenu& qm = PlayerTalkClass->GetQuestMenu(); qm.ClearMenu(); - for(QuestRelationsMap::const_iterator itr = irbounds.first; itr != irbounds.second; ++itr) + for (QuestRelationsMap::const_iterator itr = irbounds.first; itr != irbounds.second; ++itr) { uint32 quest_id = itr->second; @@ -13508,7 +13511,7 @@ void Player::PrepareQuestMenu(ObjectGuid guid) qm.AddMenuItem(quest_id, 2); } - for(QuestRelationsMap::const_iterator itr = rbounds.first; itr != rbounds.second; ++itr) + for (QuestRelationsMap::const_iterator itr = rbounds.first; itr != rbounds.second; ++itr) { uint32 quest_id = itr->second; @@ -13567,7 +13570,7 @@ void Player::SendPreparedQuest(ObjectGuid guid) std::string title = ""; // need pet case for some quests - if (Creature *pCreature = GetMap()->GetAnyTypeCreature(guid)) + if (Creature* pCreature = GetMap()->GetAnyTypeCreature(guid)) { uint32 textid = GetGossipTextId(pCreature); @@ -13595,7 +13598,7 @@ void Player::SendPreparedQuest(ObjectGuid guid) } } -bool Player::IsActiveQuest( uint32 quest_id ) const +bool Player::IsActiveQuest(uint32 quest_id) const { QuestStatusMap::const_iterator itr = mQuestStatus.find(quest_id); @@ -13619,11 +13622,11 @@ bool Player::IsCurrentQuest(uint32 quest_id, uint8 completed_or_not) const } } -Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const *pQuest) +Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const* pQuest) { QuestRelationsMapBounds rbounds; - if (Creature *pCreature = GetMap()->GetAnyTypeCreature(guid)) + if (Creature* pCreature = GetMap()->GetAnyTypeCreature(guid)) { rbounds = sObjectMgr.GetCreatureQuestRelationsMapBounds(pCreature->GetEntry()); } @@ -13631,10 +13634,10 @@ Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const *pQuest) { //we should obtain map pointer from GetMap() in 99% of cases. Special case //only for quests which cast teleport spells on player - Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId()); + Map* _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId()); MANGOS_ASSERT(_map); - if (GameObject *pGameObject = _map->GetGameObject(guid)) + if (GameObject* pGameObject = _map->GetGameObject(guid)) { rbounds = sObjectMgr.GetGOQuestRelationsMapBounds(pGameObject->GetEntry()); } @@ -13643,7 +13646,7 @@ Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const *pQuest) } uint32 nextQuestID = pQuest->GetNextQuestInChain(); - for(QuestRelationsMap::const_iterator itr = rbounds.first; itr != rbounds.second; ++itr) + for (QuestRelationsMap::const_iterator itr = rbounds.first; itr != rbounds.second; ++itr) { if (itr->second == nextQuestID) return sObjectMgr.GetQuestTemplate(nextQuestID); @@ -13652,14 +13655,14 @@ Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const *pQuest) return NULL; } -bool Player::CanSeeStartQuest(Quest const *pQuest) const +bool Player::CanSeeStartQuest(Quest const* pQuest) const { if (SatisfyQuestClass(pQuest, false) && SatisfyQuestRace(pQuest, false) && SatisfyQuestSkill(pQuest, false) && - SatisfyQuestExclusiveGroup(pQuest, false) && SatisfyQuestReputation(pQuest, false) && - SatisfyQuestPreviousQuest(pQuest, false) && SatisfyQuestNextChain(pQuest, false) && - SatisfyQuestPrevChain(pQuest, false) && SatisfyQuestDay(pQuest, false) && SatisfyQuestWeek(pQuest, false) && - SatisfyQuestMonth(pQuest, false) && - pQuest->IsActive()) + SatisfyQuestExclusiveGroup(pQuest, false) && SatisfyQuestReputation(pQuest, false) && + SatisfyQuestPreviousQuest(pQuest, false) && SatisfyQuestNextChain(pQuest, false) && + SatisfyQuestPrevChain(pQuest, false) && SatisfyQuestDay(pQuest, false) && SatisfyQuestWeek(pQuest, false) && + SatisfyQuestMonth(pQuest, false) && + pQuest->IsActive()) { return int32(getLevel()) + sWorld.getConfig(CONFIG_INT32_QUEST_HIGH_LEVEL_HIDE_DIFF) >= int32(pQuest->GetMinLevel()); } @@ -13667,18 +13670,18 @@ bool Player::CanSeeStartQuest(Quest const *pQuest) const return false; } -bool Player::CanTakeQuest(Quest const *pQuest, bool msg) const +bool Player::CanTakeQuest(Quest const* pQuest, bool msg) const { return SatisfyQuestStatus(pQuest, msg) && SatisfyQuestExclusiveGroup(pQuest, msg) && - SatisfyQuestClass(pQuest, msg) && SatisfyQuestRace(pQuest, msg) && SatisfyQuestLevel(pQuest, msg) && - SatisfyQuestSkill(pQuest, msg) && SatisfyQuestReputation(pQuest, msg) && - SatisfyQuestPreviousQuest(pQuest, msg) && SatisfyQuestTimed(pQuest, msg) && - SatisfyQuestNextChain(pQuest, msg) && SatisfyQuestPrevChain(pQuest, msg) && - SatisfyQuestDay(pQuest, msg) && SatisfyQuestWeek(pQuest, msg) && SatisfyQuestMonth(pQuest, msg) && - pQuest->IsActive(); + SatisfyQuestClass(pQuest, msg) && SatisfyQuestRace(pQuest, msg) && SatisfyQuestLevel(pQuest, msg) && + SatisfyQuestSkill(pQuest, msg) && SatisfyQuestReputation(pQuest, msg) && + SatisfyQuestPreviousQuest(pQuest, msg) && SatisfyQuestTimed(pQuest, msg) && + SatisfyQuestNextChain(pQuest, msg) && SatisfyQuestPrevChain(pQuest, msg) && + SatisfyQuestDay(pQuest, msg) && SatisfyQuestWeek(pQuest, msg) && SatisfyQuestMonth(pQuest, msg) && + pQuest->IsActive(); } -bool Player::CanAddQuest(Quest const *pQuest, bool msg) const +bool Player::CanAddQuest(Quest const* pQuest, bool msg) const { if (!SatisfyQuestLog(msg)) return false; @@ -13712,7 +13715,7 @@ bool Player::CanCompleteQuest(uint32 quest_id) const { // a few checks, not all "satisfy" is needed if (SatisfyQuestPreviousQuest(qInfo, false) && SatisfyQuestLevel(qInfo, false) && - SatisfyQuestSkill(qInfo, false) && SatisfyQuestRace(qInfo, false) && SatisfyQuestClass(qInfo, false)) + SatisfyQuestSkill(qInfo, false) && SatisfyQuestRace(qInfo, false) && SatisfyQuestClass(qInfo, false)) return true; return false; @@ -13730,7 +13733,7 @@ bool Player::CanCompleteQuest(uint32 quest_id) const if (qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAG_DELIVER)) { - for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { if (qInfo->ReqItemCount[i] != 0 && q_status.m_itemcount[i] < qInfo->ReqItemCount[i]) return false; @@ -13739,7 +13742,7 @@ bool Player::CanCompleteQuest(uint32 quest_id) const if (qInfo->HasSpecialFlag(QuestSpecialFlags(QUEST_SPECIAL_FLAG_KILL_OR_CAST | QUEST_SPECIAL_FLAG_SPEAKTO))) { - for(int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) { if (qInfo->ReqCreatureOrGOId[i] == 0) continue; @@ -13768,7 +13771,7 @@ bool Player::CanCompleteQuest(uint32 quest_id) const return true; } -bool Player::CanCompleteRepeatableQuest(Quest const *pQuest) const +bool Player::CanCompleteRepeatableQuest(Quest const* pQuest) const { // Solve problem that player don't have the quest and try complete it. // if repeatable she must be able to complete event if player don't have it. @@ -13777,7 +13780,7 @@ bool Player::CanCompleteRepeatableQuest(Quest const *pQuest) const return false; if (pQuest->HasSpecialFlag(QUEST_SPECIAL_FLAG_DELIVER)) - for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) if (pQuest->ReqItemId[i] && pQuest->ReqItemCount[i] && !HasItemCount(pQuest->ReqItemId[i], pQuest->ReqItemCount[i])) return false; @@ -13787,7 +13790,7 @@ bool Player::CanCompleteRepeatableQuest(Quest const *pQuest) const return true; } -bool Player::CanRewardQuest(Quest const *pQuest, bool msg) const +bool Player::CanRewardQuest(Quest const* pQuest, bool msg) const { // not auto complete quest and not completed quest (only cheating case, then ignore without message) if (!pQuest->IsAutoComplete() && GetQuestStatus(pQuest->GetQuestId()) != QUEST_STATUS_COMPLETE) @@ -13804,10 +13807,10 @@ bool Player::CanRewardQuest(Quest const *pQuest, bool msg) const // prevent receive reward with quest items in bank if (pQuest->HasSpecialFlag(QUEST_SPECIAL_FLAG_DELIVER)) { - for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { if (pQuest->ReqItemCount[i] != 0 && - GetItemCount(pQuest->ReqItemId[i]) < pQuest->ReqItemCount[i]) + GetItemCount(pQuest->ReqItemId[i]) < pQuest->ReqItemCount[i]) { if (msg) SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL, pQuest->ReqItemId[i]); @@ -13824,7 +13827,7 @@ bool Player::CanRewardQuest(Quest const *pQuest, bool msg) const return true; } -bool Player::CanRewardQuest(Quest const *pQuest, uint32 reward, bool msg) const +bool Player::CanRewardQuest(Quest const* pQuest, uint32 reward, bool msg) const { // prevent receive reward with quest items in bank or for not completed quest if (!CanRewardQuest(pQuest,msg)) @@ -13835,7 +13838,7 @@ bool Player::CanRewardQuest(Quest const *pQuest, uint32 reward, bool msg) const if (pQuest->RewChoiceItemId[reward]) { ItemPosCountVec dest; - InventoryResult res = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewChoiceItemId[reward], pQuest->RewChoiceItemCount[reward] ); + InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, pQuest->RewChoiceItemId[reward], pQuest->RewChoiceItemCount[reward]); if (res != EQUIP_ERR_OK) { SendEquipError(res, NULL, NULL, pQuest->RewChoiceItemId[reward]); @@ -13851,7 +13854,7 @@ bool Player::CanRewardQuest(Quest const *pQuest, uint32 reward, bool msg) const if (pQuest->RewItemId[i]) { ItemPosCountVec dest; - InventoryResult res = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewItemId[i], pQuest->RewItemCount[i] ); + InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, pQuest->RewItemId[i], pQuest->RewItemCount[i]); if (res != EQUIP_ERR_OK) { SendEquipError(res, NULL, NULL); @@ -13871,9 +13874,9 @@ void Player::SendPetTameFailure(PetTameFailureReason reason) GetSession()->SendPacket(&data); } -void Player::AddQuest( Quest const *pQuest, Object *questGiver ) +void Player::AddQuest(Quest const* pQuest, Object* questGiver) { - uint16 log_slot = FindQuestSlot( 0 ); + uint16 log_slot = FindQuestSlot(0); MANGOS_ASSERT(log_slot < MAX_QUEST_LOG_SIZE); uint32 quest_id = pQuest->GetQuestId(); @@ -13887,18 +13890,18 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver ) if (pQuest->HasSpecialFlag(QUEST_SPECIAL_FLAG_DELIVER)) { - for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) questStatusData.m_itemcount[i] = 0; } if (pQuest->HasSpecialFlag(QuestSpecialFlags(QUEST_SPECIAL_FLAG_KILL_OR_CAST | QUEST_SPECIAL_FLAG_SPEAKTO))) { - for(int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) questStatusData.m_creatureOrGOcount[i] = 0; } - if( pQuest->GetRepObjectiveFaction() ) - if(FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->GetRepObjectiveFaction())) + if (pQuest->GetRepObjectiveFaction()) + if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->GetRepObjectiveFaction())) GetReputationMgr().SetVisible(factionEntry); uint32 qtime = 0; @@ -13907,10 +13910,10 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver ) uint32 limittime = pQuest->GetLimitTime(); // shared timed quest - if(questGiver && questGiver->GetTypeId()==TYPEID_PLAYER) + if (questGiver && questGiver->GetTypeId()==TYPEID_PLAYER) limittime = ((Player*)questGiver)->getQuestStatusMap()[quest_id].m_timer / IN_MILLISECONDS; - AddTimedQuest( quest_id ); + AddTimedQuest(quest_id); questStatusData.m_timer = limittime * IN_MILLISECONDS; qtime = static_cast(time(NULL)) + limittime; } @@ -13950,7 +13953,7 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver ) { // destroy not required for quest finish quest starting item bool notRequiredItem = true; - for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { if (pQuest->ReqItemId[i] == questGiver->GetEntry()) { @@ -13968,18 +13971,18 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver ) GiveQuestSourceItemIfNeed(pQuest); - AdjustQuestReqItemCount( pQuest, questStatusData ); + AdjustQuestReqItemCount(pQuest, questStatusData); // Some spells applied at quest activation SpellAreaForQuestMapBounds saBounds = sSpellMgr.GetSpellAreaForQuestMapBounds(quest_id,true); - if(saBounds.first != saBounds.second) + if (saBounds.first != saBounds.second) { uint32 zone, area; GetZoneAndAreaId(zone,area); - for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) - if(itr->second->autocast && itr->second->IsFitToRequirements(this,zone,area)) - if (!HasAura(itr->second->spellId, EFFECT_INDEX_0) ) + for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) + if (itr->second->autocast && itr->second->IsFitToRequirements(this,zone,area)) + if (!HasAura(itr->second->spellId, EFFECT_INDEX_0)) CastSpell(this,itr->second->spellId,true); } @@ -14010,13 +14013,13 @@ void Player::IncompleteQuest(uint32 quest_id) { SetQuestStatus(quest_id, QUEST_STATUS_INCOMPLETE); - uint16 log_slot = FindQuestSlot( quest_id ); + uint16 log_slot = FindQuestSlot(quest_id); if (log_slot < MAX_QUEST_LOG_SIZE) RemoveQuestSlotState(log_slot, QUEST_STATE_COMPLETE); } } -void Player::RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver, bool announce) +void Player::RewardQuest(Quest const* pQuest, uint32 reward, Object* questGiver, bool announce) { uint32 quest_id = pQuest->GetQuestId(); @@ -14049,7 +14052,7 @@ void Player::RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver, ItemPosCountVec dest; if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, pQuest->RewChoiceItemCount[reward]) == EQUIP_ERR_OK) { - Item* item = StoreNewItem( dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); + Item* item = StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); SendNewItem(item, pQuest->RewChoiceItemCount[reward], true, false); } } @@ -14064,7 +14067,7 @@ void Player::RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver, ItemPosCountVec dest; if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, pQuest->RewItemCount[i]) == EQUIP_ERR_OK) { - Item* item = StoreNewItem( dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); + Item* item = StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); SendNewItem(item, pQuest->RewItemCount[i], true, false); } } @@ -14157,7 +14160,7 @@ void Player::RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver, bool handled = false; - switch(questGiver->GetTypeId()) + switch (questGiver->GetTypeId()) { case TYPEID_UNIT: handled = sScriptMgr.OnQuestRewarded(this, (Creature*)questGiver, pQuest); @@ -14191,7 +14194,7 @@ void Player::RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver, { GetZoneAndAreaId(zone,area); - for(SpellAreaForAreaMap::const_iterator itr = saEndBounds.first; itr != saEndBounds.second; ++itr) + for (SpellAreaForAreaMap::const_iterator itr = saEndBounds.first; itr != saEndBounds.second; ++itr) if (!itr->second->IsFitToRequirements(this, zone, area)) RemoveAurasDueToSpell(itr->second->spellId); } @@ -14203,7 +14206,7 @@ void Player::RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver, if (!zone || !area) GetZoneAndAreaId(zone, area); - for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) + for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) if (itr->second->autocast && itr->second->IsFitToRequirements(this, zone, area)) if (!HasAura(itr->second->spellId, EFFECT_INDEX_0)) CastSpell(this, itr->second->spellId, true); @@ -14292,7 +14295,7 @@ bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) const if (qInfo->prevQuests.empty()) return true; - for(Quest::PrevQuests::const_iterator iter = qInfo->prevQuests.begin(); iter != qInfo->prevQuests.end(); ++iter) + for (Quest::PrevQuests::const_iterator iter = qInfo->prevQuests.begin(); iter != qInfo->prevQuests.end(); ++iter) { uint32 prevId = abs(*iter); @@ -14314,7 +14317,7 @@ bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) const MANGOS_ASSERT(bounds.first != bounds.second); // always must be found if qPrevInfo->ExclusiveGroup != 0 - for(ExclusiveQuestGroupsMap::const_iterator iter2 = bounds.first; iter2 != bounds.second; ++iter2) + for (ExclusiveQuestGroupsMap::const_iterator iter2 = bounds.first; iter2 != bounds.second; ++iter2) { uint32 exclude_Id = iter2->second; @@ -14348,7 +14351,7 @@ bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) const MANGOS_ASSERT(bounds.first != bounds.second); // always must be found if qPrevInfo->ExclusiveGroup != 0 - for(ExclusiveQuestGroupsMap::const_iterator iter2 = bounds.first; iter2 != bounds.second; ++iter2) + for (ExclusiveQuestGroupsMap::const_iterator iter2 = bounds.first; iter2 != bounds.second; ++iter2) { uint32 exclude_Id = iter2->second; @@ -14475,7 +14478,7 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const MANGOS_ASSERT(bounds.first != bounds.second); // must always be found if qInfo->ExclusiveGroup != 0 - for(ExclusiveQuestGroupsMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter) + for (ExclusiveQuestGroupsMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter) { uint32 exclude_Id = iter->second; @@ -14497,7 +14500,7 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const // alternative quest already started or completed if (i_exstatus != mQuestStatus.end() && - (i_exstatus->second.m_status == QUEST_STATUS_COMPLETE || i_exstatus->second.m_status == QUEST_STATUS_INCOMPLETE)) + (i_exstatus->second.m_status == QUEST_STATUS_COMPLETE || i_exstatus->second.m_status == QUEST_STATUS_INCOMPLETE)) { if (msg) SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); @@ -14517,7 +14520,7 @@ bool Player::SatisfyQuestNextChain(Quest const* qInfo, bool msg) const // next quest in chain already started or completed QuestStatusMap::const_iterator itr = mQuestStatus.find(qInfo->GetNextQuestInChain()); if (itr != mQuestStatus.end() && - (itr->second.m_status == QUEST_STATUS_COMPLETE || itr->second.m_status == QUEST_STATUS_INCOMPLETE)) + (itr->second.m_status == QUEST_STATUS_COMPLETE || itr->second.m_status == QUEST_STATUS_INCOMPLETE)) { if (msg) SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); @@ -14537,7 +14540,7 @@ bool Player::SatisfyQuestPrevChain(Quest const* qInfo, bool msg) const if (qInfo->prevChainQuests.empty()) return true; - for(Quest::PrevChainQuests::const_iterator iter = qInfo->prevChainQuests.begin(); iter != qInfo->prevChainQuests.end(); ++iter) + for (Quest::PrevChainQuests::const_iterator iter = qInfo->prevChainQuests.begin(); iter != qInfo->prevChainQuests.end(); ++iter) { uint32 prevId = *iter; @@ -14566,7 +14569,7 @@ bool Player::SatisfyQuestDay(Quest const* qInfo, bool msg) const return true; bool have_slot = false; - for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) { uint32 id = GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx); if (qInfo->GetQuestId()==id) @@ -14605,7 +14608,7 @@ bool Player::SatisfyQuestMonth(Quest const* qInfo, bool msg) const return m_monthlyquests.find(qInfo->GetQuestId()) == m_monthlyquests.end(); } -bool Player::CanGiveQuestSourceItemIfNeed( Quest const *pQuest, ItemPosCountVec* dest) const +bool Player::CanGiveQuestSourceItemIfNeed(Quest const* pQuest, ItemPosCountVec* dest) const { if (uint32 srcitem = pQuest->GetSrcItemId()) { @@ -14622,55 +14625,55 @@ bool Player::CanGiveQuestSourceItemIfNeed( Quest const *pQuest, ItemPosCountVec* if (!dest) { ItemPosCountVec destTemp; - msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, destTemp, srcitem, count ); + msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, destTemp, srcitem, count); } else - msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, *dest, srcitem, count ); + msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, *dest, srcitem, count); if (msg == EQUIP_ERR_OK) return true; else - SendEquipError( msg, NULL, NULL, srcitem ); + SendEquipError(msg, NULL, NULL, srcitem); return false; } return true; } -void Player::GiveQuestSourceItemIfNeed(Quest const *pQuest) +void Player::GiveQuestSourceItemIfNeed(Quest const* pQuest) { ItemPosCountVec dest; if (CanGiveQuestSourceItemIfNeed(pQuest, &dest) && !dest.empty()) { uint32 count = 0; - for(ItemPosCountVec::const_iterator c_itr = dest.begin(); c_itr != dest.end(); ++c_itr) + for (ItemPosCountVec::const_iterator c_itr = dest.begin(); c_itr != dest.end(); ++c_itr) count += c_itr->count; - Item * item = StoreNewItem(dest, pQuest->GetSrcItemId(), true); + Item* item = StoreNewItem(dest, pQuest->GetSrcItemId(), true); SendNewItem(item, count, true, false); } } -bool Player::TakeQuestSourceItem( uint32 quest_id, bool msg ) +bool Player::TakeQuestSourceItem(uint32 quest_id, bool msg) { Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest_id); - if( qInfo ) + if (qInfo) { uint32 srcitem = qInfo->GetSrcItemId(); - if( srcitem > 0 ) + if (srcitem > 0) { uint32 count = qInfo->GetSrcItemCount(); - if( count <= 0 ) + if (count <= 0) count = 1; // exist one case when destroy source quest item not possible: // non un-equippable item (equipped non-empty bag, for example) InventoryResult res = CanUnequipItems(srcitem,count); - if(res != EQUIP_ERR_OK) + if (res != EQUIP_ERR_OK) { - if(msg) - SendEquipError( res, NULL, NULL, srcitem ); + if (msg) + SendEquipError(res, NULL, NULL, srcitem); return false; } @@ -14680,15 +14683,15 @@ bool Player::TakeQuestSourceItem( uint32 quest_id, bool msg ) return true; } -bool Player::GetQuestRewardStatus( uint32 quest_id ) const +bool Player::GetQuestRewardStatus(uint32 quest_id) const { Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest_id); - if( qInfo ) + if (qInfo) { // for repeatable quests: rewarded field is set after first reward only to prevent getting XP more than once - QuestStatusMap::const_iterator itr = mQuestStatus.find( quest_id ); - if( itr != mQuestStatus.end() && itr->second.m_status != QUEST_STATUS_NONE - && !qInfo->IsRepeatable() ) + QuestStatusMap::const_iterator itr = mQuestStatus.find(quest_id); + if (itr != mQuestStatus.end() && itr->second.m_status != QUEST_STATUS_NONE + && !qInfo->IsRepeatable()) return itr->second.m_rewarded; return false; @@ -14696,12 +14699,12 @@ bool Player::GetQuestRewardStatus( uint32 quest_id ) const return false; } -QuestStatus Player::GetQuestStatus( uint32 quest_id ) const +QuestStatus Player::GetQuestStatus(uint32 quest_id) const { - if( quest_id ) + if (quest_id) { - QuestStatusMap::const_iterator itr = mQuestStatus.find( quest_id ); - if( itr != mQuestStatus.end() ) + QuestStatusMap::const_iterator itr = mQuestStatus.find(quest_id); + if (itr != mQuestStatus.end()) return itr->second.m_status; } return QUEST_STATUS_NONE; @@ -14735,24 +14738,24 @@ void Player::SetQuestStatus(uint32 quest_id, QuestStatus status) uint32 Player::GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry) { Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest_id); - if( !qInfo ) + if (!qInfo) return 0; for (int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) - if ( qInfo->ReqCreatureOrGOId[j] == entry ) + if (qInfo->ReqCreatureOrGOId[j] == entry) return mQuestStatus[quest_id].m_creatureOrGOcount[j]; return 0; } -void Player::AdjustQuestReqItemCount( Quest const* pQuest, QuestStatusData& questStatusData ) +void Player::AdjustQuestReqItemCount(Quest const* pQuest, QuestStatusData& questStatusData) { if (pQuest->HasSpecialFlag(QUEST_SPECIAL_FLAG_DELIVER)) { - for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { uint32 reqitemcount = pQuest->ReqItemCount[i]; - if( reqitemcount != 0 ) + if (reqitemcount != 0) { uint32 curitemcount = GetItemCount(pQuest->ReqItemId[i], true); @@ -14763,25 +14766,25 @@ void Player::AdjustQuestReqItemCount( Quest const* pQuest, QuestStatusData& ques } } -uint16 Player::FindQuestSlot( uint32 quest_id ) const +uint16 Player::FindQuestSlot(uint32 quest_id) const { - for ( uint16 i = 0; i < MAX_QUEST_LOG_SIZE; ++i ) - if ( GetQuestSlotQuestId(i) == quest_id ) + for (uint16 i = 0; i < MAX_QUEST_LOG_SIZE; ++i) + if (GetQuestSlotQuestId(i) == quest_id) return i; return MAX_QUEST_LOG_SIZE; } -void Player::AreaExploredOrEventHappens( uint32 questId ) +void Player::AreaExploredOrEventHappens(uint32 questId) { - if( questId ) + if (questId) { - uint16 log_slot = FindQuestSlot( questId ); - if( log_slot < MAX_QUEST_LOG_SIZE) + uint16 log_slot = FindQuestSlot(questId); + if (log_slot < MAX_QUEST_LOG_SIZE) { QuestStatusData& q_status = mQuestStatus[questId]; - if(!q_status.m_explored) + if (!q_status.m_explored) { SetQuestSlotState(log_slot, QUEST_STATE_COMPLETE); SendQuestCompleteEvent(questId); @@ -14791,22 +14794,22 @@ void Player::AreaExploredOrEventHappens( uint32 questId ) q_status.uState = QUEST_CHANGED; } } - if( CanCompleteQuest( questId ) ) - CompleteQuest( questId ); + if (CanCompleteQuest(questId)) + CompleteQuest(questId); } } //not used in mangosd, function for external script library -void Player::GroupEventHappens( uint32 questId, WorldObject const* pEventObject ) +void Player::GroupEventHappens(uint32 questId, WorldObject const* pEventObject) { - if( Group *pGroup = GetGroup() ) + if (Group* pGroup = GetGroup()) { - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player *pGroupGuy = itr->getSource(); + Player* pGroupGuy = itr->getSource(); // for any leave or dead (with not released body) group member at appropriate distance - if( pGroupGuy && pGroupGuy->IsAtGroupRewardDistance(pEventObject) && !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST) ) + if (pGroupGuy && pGroupGuy->IsAtGroupRewardDistance(pEventObject) && !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) pGroupGuy->AreaExploredOrEventHappens(questId); } } @@ -14814,17 +14817,17 @@ void Player::GroupEventHappens( uint32 questId, WorldObject const* pEventObject AreaExploredOrEventHappens(questId); } -void Player::ItemAddedQuestCheck( uint32 entry, uint32 count ) +void Player::ItemAddedQuestCheck(uint32 entry, uint32 count) { - for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i ) + for (int i = 0; i < MAX_QUEST_LOG_SIZE; ++i) { uint32 questid = GetQuestSlotQuestId(i); - if ( questid == 0 ) + if (questid == 0) continue; QuestStatusData& q_status = mQuestStatus[questid]; - if ( q_status.m_status != QUEST_STATUS_INCOMPLETE ) + if (q_status.m_status != QUEST_STATUS_INCOMPLETE) continue; Quest const* qInfo = sObjectMgr.GetQuestTemplate(questid); @@ -14834,19 +14837,19 @@ void Player::ItemAddedQuestCheck( uint32 entry, uint32 count ) for (int j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j) { uint32 reqitem = qInfo->ReqItemId[j]; - if ( reqitem == entry ) + if (reqitem == entry) { uint32 reqitemcount = qInfo->ReqItemCount[j]; uint32 curitemcount = q_status.m_itemcount[j]; - if ( curitemcount < reqitemcount ) + if (curitemcount < reqitemcount) { - uint32 additemcount = ( curitemcount + count <= reqitemcount ? count : reqitemcount - curitemcount); + uint32 additemcount = (curitemcount + count <= reqitemcount ? count : reqitemcount - curitemcount); q_status.m_itemcount[j] += additemcount; if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; } - if ( CanCompleteQuest( questid ) ) - CompleteQuest( questid ); + if (CanCompleteQuest(questid)) + CompleteQuest(questid); return; } } @@ -14854,15 +14857,15 @@ void Player::ItemAddedQuestCheck( uint32 entry, uint32 count ) UpdateForQuestWorldObjects(); } -void Player::ItemRemovedQuestCheck( uint32 entry, uint32 count ) +void Player::ItemRemovedQuestCheck(uint32 entry, uint32 count) { - for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i ) + for (int i = 0; i < MAX_QUEST_LOG_SIZE; ++i) { uint32 questid = GetQuestSlotQuestId(i); - if(!questid) + if (!questid) continue; Quest const* qInfo = sObjectMgr.GetQuestTemplate(questid); - if ( !qInfo ) + if (!qInfo) continue; if (!qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAG_DELIVER)) continue; @@ -14870,23 +14873,23 @@ void Player::ItemRemovedQuestCheck( uint32 entry, uint32 count ) for (int j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j) { uint32 reqitem = qInfo->ReqItemId[j]; - if ( reqitem == entry ) + if (reqitem == entry) { QuestStatusData& q_status = mQuestStatus[questid]; uint32 reqitemcount = qInfo->ReqItemCount[j]; uint32 curitemcount; - if( q_status.m_status != QUEST_STATUS_COMPLETE ) + if (q_status.m_status != QUEST_STATUS_COMPLETE) curitemcount = q_status.m_itemcount[j]; else curitemcount = GetItemCount(entry, true); - if ( curitemcount < reqitemcount + count ) + if (curitemcount < reqitemcount + count) { - uint32 remitemcount = ( curitemcount <= reqitemcount ? count : count + reqitemcount - curitemcount); + uint32 remitemcount = (curitemcount <= reqitemcount ? count : count + reqitemcount - curitemcount); q_status.m_itemcount[j] = curitemcount - remitemcount; if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; - IncompleteQuest( questid ); + IncompleteQuest(questid); } return; } @@ -14895,25 +14898,25 @@ void Player::ItemRemovedQuestCheck( uint32 entry, uint32 count ) UpdateForQuestWorldObjects(); } -void Player::KilledMonster( CreatureInfo const* cInfo, ObjectGuid guid ) +void Player::KilledMonster(CreatureInfo const* cInfo, ObjectGuid guid) { - if(cInfo->Entry) + if (cInfo->Entry) KilledMonsterCredit(cInfo->Entry, guid); - for(int i = 0; i < MAX_KILL_CREDIT; ++i) - if(cInfo->KillCredit[i]) + for (int i = 0; i < MAX_KILL_CREDIT; ++i) + if (cInfo->KillCredit[i]) KilledMonsterCredit(cInfo->KillCredit[i], guid); } -void Player::KilledMonsterCredit( uint32 entry, ObjectGuid guid ) +void Player::KilledMonsterCredit(uint32 entry, ObjectGuid guid) { uint32 addkillcount = 1; GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, entry, addkillcount); - for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i ) + for (int i = 0; i < MAX_QUEST_LOG_SIZE; ++i) { uint32 questid = GetQuestSlotQuestId(i); - if(!questid) + if (!questid) continue; Quest const* qInfo = sObjectMgr.GetQuestTemplate(questid); @@ -14932,7 +14935,7 @@ void Player::KilledMonsterCredit( uint32 entry, ObjectGuid guid ) continue; // skip Cast at creature objective - if (qInfo->ReqSpell[j] !=0 ) + if (qInfo->ReqSpell[j] !=0) continue; uint32 reqkill = qInfo->ReqCreatureOrGOId[j]; @@ -14947,11 +14950,11 @@ void Player::KilledMonsterCredit( uint32 entry, ObjectGuid guid ) if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; - SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, q_status.m_creatureOrGOcount[j]); + SendQuestUpdateAddCreatureOrGo(qInfo, guid, j, q_status.m_creatureOrGOcount[j]); } - if (CanCompleteQuest( questid )) - CompleteQuest( questid ); + if (CanCompleteQuest(questid)) + CompleteQuest(questid); // same objective target can be in many active quests, but not in 2 objectives for single quest (code optimization). continue; @@ -14962,12 +14965,12 @@ void Player::KilledMonsterCredit( uint32 entry, ObjectGuid guid ) } } -void Player::CastedCreatureOrGO( uint32 entry, ObjectGuid guid, uint32 spell_id, bool original_caster ) +void Player::CastedCreatureOrGO(uint32 entry, ObjectGuid guid, uint32 spell_id, bool original_caster) { bool isCreature = guid.IsCreatureOrVehicle(); uint32 addCastCount = 1; - for(int i = 0; i < MAX_QUEST_LOG_SIZE; ++i) + for (int i = 0; i < MAX_QUEST_LOG_SIZE; ++i) { uint32 questid = GetQuestSlotQuestId(i); if (!questid) @@ -15023,7 +15026,7 @@ void Player::CastedCreatureOrGO( uint32 entry, ObjectGuid guid, uint32 spell_id, if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; - SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, q_status.m_creatureOrGOcount[j]); + SendQuestUpdateAddCreatureOrGo(qInfo, guid, j, q_status.m_creatureOrGOcount[j]); } if (CanCompleteQuest(questid)) @@ -15035,52 +15038,52 @@ void Player::CastedCreatureOrGO( uint32 entry, ObjectGuid guid, uint32 spell_id, } } -void Player::TalkedToCreature( uint32 entry, ObjectGuid guid ) +void Player::TalkedToCreature(uint32 entry, ObjectGuid guid) { uint32 addTalkCount = 1; - for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i ) + for (int i = 0; i < MAX_QUEST_LOG_SIZE; ++i) { uint32 questid = GetQuestSlotQuestId(i); - if(!questid) + if (!questid) continue; Quest const* qInfo = sObjectMgr.GetQuestTemplate(questid); - if ( !qInfo ) + if (!qInfo) continue; QuestStatusData& q_status = mQuestStatus[questid]; - if ( q_status.m_status == QUEST_STATUS_INCOMPLETE ) + if (q_status.m_status == QUEST_STATUS_INCOMPLETE) { if (qInfo->HasSpecialFlag(QuestSpecialFlags(QUEST_SPECIAL_FLAG_KILL_OR_CAST | QUEST_SPECIAL_FLAG_SPEAKTO))) { for (int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) { - // skip spell casts and Gameobject objectives - if(qInfo->ReqSpell[j] > 0 || qInfo->ReqCreatureOrGOId[j] < 0) + // skip spell casts and Gameobject objectives + if (qInfo->ReqSpell[j] > 0 || qInfo->ReqCreatureOrGOId[j] < 0) continue; uint32 reqTarget = 0; - if(qInfo->ReqCreatureOrGOId[j] > 0) // creature activate objectives - // checked at quest_template loading + if (qInfo->ReqCreatureOrGOId[j] > 0) // creature activate objectives + // checked at quest_template loading reqTarget = qInfo->ReqCreatureOrGOId[j]; else continue; - if ( reqTarget == entry ) + if (reqTarget == entry) { uint32 reqTalkCount = qInfo->ReqCreatureOrGOCount[j]; uint32 curTalkCount = q_status.m_creatureOrGOcount[j]; - if ( curTalkCount < reqTalkCount ) + if (curTalkCount < reqTalkCount) { q_status.m_creatureOrGOcount[j] = curTalkCount + addTalkCount; if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; - SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, q_status.m_creatureOrGOcount[j]); + SendQuestUpdateAddCreatureOrGo(qInfo, guid, j, q_status.m_creatureOrGOcount[j]); } - if ( CanCompleteQuest( questid ) ) - CompleteQuest( questid ); + if (CanCompleteQuest(questid)) + CompleteQuest(questid); // same objective target can be in many active quests, but not in 2 objectives for single quest (code optimization). continue; @@ -15091,57 +15094,57 @@ void Player::TalkedToCreature( uint32 entry, ObjectGuid guid ) } } -void Player::MoneyChanged( uint32 count ) +void Player::MoneyChanged(uint32 count) { - for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i ) + for (int i = 0; i < MAX_QUEST_LOG_SIZE; ++i) { uint32 questid = GetQuestSlotQuestId(i); if (!questid) continue; Quest const* qInfo = sObjectMgr.GetQuestTemplate(questid); - if( qInfo && qInfo->GetRewOrReqMoney() < 0 ) + if (qInfo && qInfo->GetRewOrReqMoney() < 0) { QuestStatusData& q_status = mQuestStatus[questid]; - if( q_status.m_status == QUEST_STATUS_INCOMPLETE ) + if (q_status.m_status == QUEST_STATUS_INCOMPLETE) { - if(int32(count) >= -qInfo->GetRewOrReqMoney()) + if (int32(count) >= -qInfo->GetRewOrReqMoney()) { - if ( CanCompleteQuest( questid ) ) - CompleteQuest( questid ); + if (CanCompleteQuest(questid)) + CompleteQuest(questid); } } - else if( q_status.m_status == QUEST_STATUS_COMPLETE ) + else if (q_status.m_status == QUEST_STATUS_COMPLETE) { - if(int32(count) < -qInfo->GetRewOrReqMoney()) - IncompleteQuest( questid ); + if (int32(count) < -qInfo->GetRewOrReqMoney()) + IncompleteQuest(questid); } } } } -void Player::ReputationChanged(FactionEntry const* factionEntry ) +void Player::ReputationChanged(FactionEntry const* factionEntry) { - for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i ) + for (int i = 0; i < MAX_QUEST_LOG_SIZE; ++i) { - if(uint32 questid = GetQuestSlotQuestId(i)) + if (uint32 questid = GetQuestSlotQuestId(i)) { - if(Quest const* qInfo = sObjectMgr.GetQuestTemplate(questid)) + if (Quest const* qInfo = sObjectMgr.GetQuestTemplate(questid)) { - if(qInfo->GetRepObjectiveFaction() == factionEntry->ID ) + if (qInfo->GetRepObjectiveFaction() == factionEntry->ID) { QuestStatusData& q_status = mQuestStatus[questid]; - if( q_status.m_status == QUEST_STATUS_INCOMPLETE ) + if (q_status.m_status == QUEST_STATUS_INCOMPLETE) { - if(GetReputationMgr().GetReputation(factionEntry) >= qInfo->GetRepObjectiveValue()) - if ( CanCompleteQuest( questid ) ) - CompleteQuest( questid ); + if (GetReputationMgr().GetReputation(factionEntry) >= qInfo->GetRepObjectiveValue()) + if (CanCompleteQuest(questid)) + CompleteQuest(questid); } - else if( q_status.m_status == QUEST_STATUS_COMPLETE ) + else if (q_status.m_status == QUEST_STATUS_COMPLETE) { - if(GetReputationMgr().GetReputation(factionEntry) < qInfo->GetRepObjectiveValue()) - IncompleteQuest( questid ); + if (GetReputationMgr().GetReputation(factionEntry) < qInfo->GetRepObjectiveValue()) + IncompleteQuest(questid); } } } @@ -15149,16 +15152,16 @@ void Player::ReputationChanged(FactionEntry const* factionEntry ) } } -bool Player::HasQuestForItem( uint32 itemid ) const +bool Player::HasQuestForItem(uint32 itemid) const { - for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i ) + for (int i = 0; i < MAX_QUEST_LOG_SIZE; ++i) { uint32 questid = GetQuestSlotQuestId(i); - if ( questid == 0 ) + if (questid == 0) continue; QuestStatusMap::const_iterator qs_itr = mQuestStatus.find(questid); - if(qs_itr == mQuestStatus.end()) + if (qs_itr == mQuestStatus.end()) continue; QuestStatusData const& q_status = qs_itr->second; @@ -15166,7 +15169,7 @@ bool Player::HasQuestForItem( uint32 itemid ) const if (q_status.m_status == QUEST_STATUS_INCOMPLETE) { Quest const* qinfo = sObjectMgr.GetQuestTemplate(questid); - if(!qinfo) + if (!qinfo) continue; // hide quest if player is in raid-group and quest is no raid quest @@ -15177,7 +15180,7 @@ bool Player::HasQuestForItem( uint32 itemid ) const // This part for ReqItem drop for (int j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j) { - if(itemid == qinfo->ReqItemId[j] && q_status.m_itemcount[j] < qinfo->ReqItemCount[j] ) + if (itemid == qinfo->ReqItemId[j] && q_status.m_itemcount[j] < qinfo->ReqItemCount[j]) return true; } // This part - for ReqSource @@ -15186,7 +15189,7 @@ bool Player::HasQuestForItem( uint32 itemid ) const // examined item is a source item if (qinfo->ReqSourceId[j] == itemid) { - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid); + ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid); // 'unique' item if (pProto->MaxCount && (int32)GetItemCount(itemid,true) < pProto->MaxCount) @@ -15197,7 +15200,8 @@ bool Player::HasQuestForItem( uint32 itemid ) const { if (GetItemCount(itemid,true) < qinfo->ReqSourceCount[j]) return true; - } else if ((int32)GetItemCount(itemid,true) < pProto->Stackable) + } + else if ((int32)GetItemCount(itemid,true) < pProto->Stackable) return true; } } @@ -15218,14 +15222,14 @@ void Player::SendQuestCompleteEvent(uint32 quest_id) } } -void Player::SendQuestReward( Quest const *pQuest, uint32 XP, Object * questGiver ) +void Player::SendQuestReward(Quest const* pQuest, uint32 XP, Object* questGiver) { uint32 questid = pQuest->GetQuestId(); - DEBUG_LOG( "WORLD: Sent SMSG_QUESTGIVER_QUEST_COMPLETE quest = %u", questid ); - WorldPacket data( SMSG_QUESTGIVER_QUEST_COMPLETE, (4+4+4+4+4) ); + DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_COMPLETE quest = %u", questid); + WorldPacket data(SMSG_QUESTGIVER_QUEST_COMPLETE, (4+4+4+4+4)); data << uint32(questid); - if ( getLevel() < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL) ) + if (getLevel() < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) { data << uint32(XP); data << uint32(pQuest->GetRewOrReqMoney()); @@ -15239,37 +15243,37 @@ void Player::SendQuestReward( Quest const *pQuest, uint32 XP, Object * questGive data << uint32(10*MaNGOS::Honor::hk_honor_at_level(getLevel(), pQuest->GetRewHonorAddition())); data << uint32(pQuest->GetBonusTalents()); // bonus talents data << uint32(0); // arena points - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } -void Player::SendQuestFailed( uint32 quest_id, InventoryResult reason) +void Player::SendQuestFailed(uint32 quest_id, InventoryResult reason) { - if( quest_id ) + if (quest_id) { - WorldPacket data( SMSG_QUESTGIVER_QUEST_FAILED, 4+4 ); + WorldPacket data(SMSG_QUESTGIVER_QUEST_FAILED, 4+4); data << uint32(quest_id); data << uint32(reason); // failed reason (valid reasons: 4, 16, 50, 17, 74, other values show default message) - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_FAILED"); } } -void Player::SendQuestTimerFailed( uint32 quest_id ) +void Player::SendQuestTimerFailed(uint32 quest_id) { - if( quest_id ) + if (quest_id) { - WorldPacket data( SMSG_QUESTUPDATE_FAILEDTIMER, 4 ); + WorldPacket data(SMSG_QUESTUPDATE_FAILEDTIMER, 4); data << uint32(quest_id); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); DEBUG_LOG("WORLD: Sent SMSG_QUESTUPDATE_FAILEDTIMER"); } } -void Player::SendCanTakeQuestResponse( uint32 msg ) const +void Player::SendCanTakeQuestResponse(uint32 msg) const { - WorldPacket data( SMSG_QUESTGIVER_QUEST_INVALID, 4 ); + WorldPacket data(SMSG_QUESTGIVER_QUEST_INVALID, 4); data << uint32(msg); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_INVALID"); } @@ -15291,19 +15295,19 @@ void Player::SendQuestConfirmAccept(const Quest* pQuest, Player* pReceiver) } } -void Player::SendPushToPartyResponse( Player *pPlayer, uint32 msg ) +void Player::SendPushToPartyResponse(Player* pPlayer, uint32 msg) { - if( pPlayer ) + if (pPlayer) { - WorldPacket data( MSG_QUEST_PUSH_RESULT, (8+1) ); + WorldPacket data(MSG_QUEST_PUSH_RESULT, (8+1)); data << pPlayer->GetObjectGuid(); data << uint8(msg); // valid values: 0-8 - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); DEBUG_LOG("WORLD: Sent MSG_QUEST_PUSH_RESULT"); } } -void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, ObjectGuid guid, uint32 creatureOrGO_idx, uint32 count) +void Player::SendQuestUpdateAddCreatureOrGo(Quest const* pQuest, ObjectGuid guid, uint32 creatureOrGO_idx, uint32 count) { MANGOS_ASSERT(count < 65536 && "mob/GO count store in 16 bits 2^16 = 65536 (0..65536)"); @@ -15312,8 +15316,8 @@ void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, ObjectGuid gui // client expected gameobject template id in form (id|0x80000000) entry = (-entry) | 0x80000000; - WorldPacket data( SMSG_QUESTUPDATE_ADD_KILL, (4*4+8) ); - DEBUG_LOG( "WORLD: Sent SMSG_QUESTUPDATE_ADD_KILL" ); + WorldPacket data(SMSG_QUESTUPDATE_ADD_KILL, (4*4+8)); + DEBUG_LOG("WORLD: Sent SMSG_QUESTUPDATE_ADD_KILL"); data << uint32(pQuest->GetQuestId()); data << uint32(entry); data << uint32(count); @@ -15321,7 +15325,7 @@ void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, ObjectGuid gui data << guid; GetSession()->SendPacket(&data); - uint16 log_slot = FindQuestSlot( pQuest->GetQuestId() ); + uint16 log_slot = FindQuestSlot(pQuest->GetQuestId()); if (log_slot < MAX_QUEST_LOG_SIZE) SetQuestSlotCounter(log_slot, creatureOrGO_idx, count); } @@ -15332,21 +15336,21 @@ void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, ObjectGuid gui void Player::_LoadDeclinedNames(QueryResult* result) { - if(!result) + if (!result) return; - if(m_declinedname) + if (m_declinedname) delete m_declinedname; m_declinedname = new DeclinedName; - Field *fields = result->Fetch(); - for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) + Field* fields = result->Fetch(); + for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) m_declinedname->name[i] = fields[i].GetCppString(); delete result; } -void Player::_LoadArenaTeamInfo(QueryResult *result) +void Player::_LoadArenaTeamInfo(QueryResult* result) { // arenateamid, played_week, played_season, personal_rating memset((void*)&m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1], 0, sizeof(uint32) * MAX_ARENA_SLOT * ARENA_TEAM_END); @@ -15355,7 +15359,7 @@ void Player::_LoadArenaTeamInfo(QueryResult *result) do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 arenateamid = fields[0].GetUInt32(); uint32 played_week = fields[1].GetUInt32(); @@ -15364,7 +15368,7 @@ void Player::_LoadArenaTeamInfo(QueryResult *result) uint32 personal_rating = fields[4].GetUInt32(); ArenaTeam* aTeam = sObjectMgr.GetArenaTeamById(arenateamid); - if(!aTeam) + if (!aTeam) { sLog.outError("Player::_LoadArenaTeamInfo: couldn't load arenateam %u", arenateamid); continue; @@ -15379,11 +15383,12 @@ void Player::_LoadArenaTeamInfo(QueryResult *result) SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_WINS_SEASON, wons_season); SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_PERSONAL_RATING, personal_rating); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } -void Player::_LoadEquipmentSets(QueryResult *result) +void Player::_LoadEquipmentSets(QueryResult* result) { // SetPQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, ignore_mask, item0, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = '%u' ORDER BY setindex", GUID_LOPART(m_guid)); if (!result) @@ -15392,7 +15397,7 @@ void Player::_LoadEquipmentSets(QueryResult *result) uint32 count = 0; do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); EquipmentSet eqSet; @@ -15403,16 +15408,17 @@ void Player::_LoadEquipmentSets(QueryResult *result) eqSet.IgnoreMask = fields[4].GetUInt32(); eqSet.state = EQUIPMENT_SET_UNCHANGED; - for(uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) + for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) eqSet.Items[i] = fields[5+i].GetUInt32(); m_EquipmentSets[index] = eqSet; ++count; - if(count >= MAX_EQUIPMENT_SET_INDEX) // client limit + if (count >= MAX_EQUIPMENT_SET_INDEX) // client limit break; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } @@ -15422,7 +15428,7 @@ void Player::_LoadBGData(QueryResult* result) return; // Expecting only one row - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); /* bgInstanceID, bgTeam, x, y, z, o, map, taxi[0], taxi[1], mountSpell */ m_bgData.bgInstanceID = fields[0].GetUInt32(); m_bgData.bgTeam = Team(fields[1].GetUInt32()); @@ -15440,11 +15446,11 @@ void Player::_LoadBGData(QueryResult* result) bool Player::LoadPositionFromDB(ObjectGuid guid, uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight) { - QueryResult *result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,taxi_path FROM characters WHERE guid = '%u'", guid.GetCounter()); - if(!result) + QueryResult* result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,taxi_path FROM characters WHERE guid = '%u'", guid.GetCounter()); + if (!result) return false; - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); x = fields[0].GetFloat(); y = fields[1].GetFloat(); @@ -15459,12 +15465,12 @@ bool Player::LoadPositionFromDB(ObjectGuid guid, uint32& mapid, float& x, float& void Player::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 count) { - if(!data) + if (!data) return; Tokens tokens = StrSplit(data, " "); - if(tokens.size() != count) + if (tokens.size() != count) return; Tokens::iterator iter; @@ -15475,7 +15481,7 @@ void Player::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 cou } } -bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) +bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) { // 0 1 2 3 4 5 6 7 8 9 10 11 //SELECT guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags," @@ -15487,39 +15493,39 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) //"arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk," // 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 //"health, power1, power2, power3, power4, power5, power6, power7, specCount, activeSpec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid)); - QueryResult *result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM); + QueryResult* result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM); - if(!result) + if (!result) { sLog.outError("%s not found in table `characters`, can't load. ", guid.GetString().c_str()); return false; } - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 dbAccountId = fields[1].GetUInt32(); // check if the character's account in the db and the logged in account match. // player should be able to load/delete character only with correct account! - if( dbAccountId != GetSession()->GetAccountId() ) + if (dbAccountId != GetSession()->GetAccountId()) { sLog.outError("%s loading from wrong account (is: %u, should be: %u)", - guid.GetString().c_str(), GetSession()->GetAccountId(), dbAccountId); + guid.GetString().c_str(), GetSession()->GetAccountId(), dbAccountId); delete result; return false; } - Object::_Create(guid.GetCounter(), 0, HIGHGUID_PLAYER ); + Object::_Create(guid.GetCounter(), 0, HIGHGUID_PLAYER); m_name = fields[2].GetCppString(); // check name limitations if (ObjectMgr::CheckPlayerName(m_name) != CHAR_NAME_SUCCESS || - (GetSession()->GetSecurity() == SEC_PLAYER && sObjectMgr.IsReservedName(m_name))) + (GetSession()->GetSecurity() == SEC_PLAYER && sObjectMgr.IsReservedName(m_name))) { delete result; CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid ='%u'", - uint32(AT_LOGIN_RENAME), guid.GetCounter()); + uint32(AT_LOGIN_RENAME), guid.GetCounter()); return false; } @@ -15548,7 +15554,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) m_achievementMgr.LoadFromDB(holder->GetResult(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS), holder->GetResult(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS)); uint32 money = fields[8].GetUInt32(); - if(money > MAX_MONEY_AMOUNT) + if (money > MAX_MONEY_AMOUNT) money = MAX_MONEY_AMOUNT; SetMoney(money); @@ -15570,7 +15576,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) SetByteValue(PLAYER_FIELD_BYTES, 2, fields[64].GetUInt8()); // cleanup inventory related item value fields (its will be filled correctly in _LoadInventory) - for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) + for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) { SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid()); SetVisibleItemSlot(slot, NULL); @@ -15591,7 +15597,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) SetCharm(NULL); // load home bind and check in same time class/race pair, it used later for restore broken positions - if(!_LoadHomeBind(holder->GetResult(PLAYER_LOGIN_QUERY_LOADHOMEBIND))) + if (!_LoadHomeBind(holder->GetResult(PLAYER_LOGIN_QUERY_LOADHOMEBIND))) { delete result; return false; @@ -15605,7 +15611,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) SetLocationMapId(fields[15].GetUInt32()); uint32 difficulty = fields[38].GetUInt32(); - if(difficulty >= MAX_DUNGEON_DIFFICULTY) + if (difficulty >= MAX_DUNGEON_DIFFICULTY) difficulty = DUNGEON_DIFFICULTY_NORMAL; SetDungeonDifficulty(Difficulty(difficulty)); // may be changed in _LoadGroup @@ -15616,18 +15622,18 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) SetArenaPoints(fields[39].GetUInt32()); // check arena teams integrity - for(uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot) + for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot) { uint32 arena_team_id = GetArenaTeamId(arena_slot); if (!arena_team_id) continue; - if (ArenaTeam * at = sObjectMgr.GetArenaTeamById(arena_team_id)) + if (ArenaTeam* at = sObjectMgr.GetArenaTeamById(arena_team_id)) if (at->HaveMember(GetObjectGuid())) continue; // arena team not exist or not member, cleanup fields - for(int j = 0; j < ARENA_TEAM_END; ++j) + for (int j = 0; j < ARENA_TEAM_END; ++j) SetArenaTeamInfoField(arena_slot, ArenaTeamInfoType(j), 0); } @@ -15644,7 +15650,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) if (!IsPositionValid()) { sLog.outError("%s have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", - guid.GetString().c_str(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + guid.GetString().c_str(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); RelocateToHomebind(); transGUID = 0; @@ -15656,7 +15662,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) if (m_bgData.bgInstanceID) //saved in BattleGround { - BattleGround *currentBg = sBattleGroundMgr.GetBattleGround(m_bgData.bgInstanceID, BATTLEGROUND_TYPE_NONE); + BattleGround* currentBg = sBattleGroundMgr.GetBattleGround(m_bgData.bgInstanceID, BATTLEGROUND_TYPE_NONE); bool player_at_bg = currentBg && currentBg->IsPlayerInBattleGround(GetObjectGuid()); @@ -15695,7 +15701,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) MapEntry const* mapEntry = sMapStore.LookupEntry(GetMapId()); // if server restart after player save in BG or area // player can have current coordinates in to BG/Arena map, fix this - if(!mapEntry || mapEntry->IsBattleGroundOrArena()) + if (!mapEntry || mapEntry->IsBattleGroundOrArena()) { const WorldLocation& _loc = GetBattleGroundEntryPoint(); SetLocationMapId(_loc.mapid); @@ -15712,15 +15718,15 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) { m_movementInfo.SetTransportData(ObjectGuid(HIGHGUID_MO_TRANSPORT,transGUID), fields[26].GetFloat(), fields[27].GetFloat(), fields[28].GetFloat(), fields[29].GetFloat(), 0, -1); - if( !MaNGOS::IsValidMapCoord( - GetPositionX() + m_movementInfo.GetTransportPos()->x, GetPositionY() + m_movementInfo.GetTransportPos()->y, - GetPositionZ() + m_movementInfo.GetTransportPos()->z, GetOrientation() + m_movementInfo.GetTransportPos()->o) || - // transport size limited - m_movementInfo.GetTransportPos()->x > 50 || m_movementInfo.GetTransportPos()->y > 50 || m_movementInfo.GetTransportPos()->z > 50 ) + if (!MaNGOS::IsValidMapCoord( + GetPositionX() + m_movementInfo.GetTransportPos()->x, GetPositionY() + m_movementInfo.GetTransportPos()->y, + GetPositionZ() + m_movementInfo.GetTransportPos()->z, GetOrientation() + m_movementInfo.GetTransportPos()->o) || + // transport size limited + m_movementInfo.GetTransportPos()->x > 50 || m_movementInfo.GetTransportPos()->y > 50 || m_movementInfo.GetTransportPos()->z > 50) { sLog.outError("%s have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", - guid.GetString().c_str(), GetPositionX() + m_movementInfo.GetTransportPos()->x, GetPositionY() + m_movementInfo.GetTransportPos()->y, - GetPositionZ() + m_movementInfo.GetTransportPos()->z, GetOrientation() + m_movementInfo.GetTransportPos()->o); + guid.GetString().c_str(), GetPositionX() + m_movementInfo.GetTransportPos()->x, GetPositionY() + m_movementInfo.GetTransportPos()->y, + GetPositionZ() + m_movementInfo.GetTransportPos()->z, GetOrientation() + m_movementInfo.GetTransportPos()->o); RelocateToHomebind(); @@ -15734,11 +15740,11 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) { for (MapManager::TransportSet::const_iterator iter = sMapMgr.m_Transports.begin(); iter != sMapMgr.m_Transports.end(); ++iter) { - if( (*iter)->GetGUIDLow() == transGUID) + if ((*iter)->GetGUIDLow() == transGUID) { MapEntry const* transMapEntry = sMapStore.LookupEntry((*iter)->GetMapId()); // client without expansion support - if(GetSession()->Expansion() < transMapEntry->Expansion()) + if (GetSession()->Expansion() < transMapEntry->Expansion()) { DEBUG_LOG("Player %s using client without required expansion tried login at transport at non accessible map %u", GetName(), (*iter)->GetMapId()); break; @@ -15751,10 +15757,10 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) } } - if(!m_transport) + if (!m_transport) { sLog.outError("%s have problems with transport guid (%u). Teleport to default race/class locations.", - guid.GetString().c_str(), transGUID); + guid.GetString().c_str(), transGUID); RelocateToHomebind(); @@ -15767,7 +15773,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) { MapEntry const* mapEntry = sMapStore.LookupEntry(GetMapId()); // client without expansion support - if(GetSession()->Expansion() < mapEntry->Expansion()) + if (GetSession()->Expansion() < mapEntry->Expansion()) { DEBUG_LOG("Player %s using client without required expansion tried login at non accessible map %u", GetName(), GetMapId()); RelocateToHomebind(); @@ -15781,10 +15787,10 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) SetMap(sMapMgr.CreateMap(GetMapId(), this)); // if the player is in an instance and it has been reset in the meantime teleport him to the entrance - if(GetInstanceId() && !state) + if (GetInstanceId() && !state) { AreaTrigger const* at = sObjectMgr.GetMapEntranceTrigger(GetMapId()); - if(at) + if (at) Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation); else sLog.outError("Player %s(GUID: %u) logged in to a reset instance (map: %u) and there is no area-trigger leading to this map. Thus he can't be ported back to the entrance. This _might_ be an exploit attempt.", GetName(), GetGUIDLow(), GetMapId()); @@ -15801,7 +15807,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) // set value, including drunk invisibility detection // calculate sobering. after 15 minutes logged out, the player will be sober again float soberFactor; - if(time_diff > 15*MINUTE) + if (time_diff > 15*MINUTE) soberFactor = 0; else soberFactor = 1-time_diff/(15.0f*MINUTE); @@ -15816,17 +15822,17 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) m_resetTalentsTime = time_t(fields[25].GetUInt64()); // reserve some flags - uint32 old_safe_flags = GetUInt32Value(PLAYER_FLAGS) & ( PLAYER_FLAGS_HIDE_CLOAK | PLAYER_FLAGS_HIDE_HELM ); + uint32 old_safe_flags = GetUInt32Value(PLAYER_FLAGS) & (PLAYER_FLAGS_HIDE_CLOAK | PLAYER_FLAGS_HIDE_HELM); - if( HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM) ) + if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM)) SetUInt32Value(PLAYER_FLAGS, 0 | old_safe_flags); - m_taxi.LoadTaxiMask( fields[17].GetString() ); // must be before InitTaxiNodesForLevel + m_taxi.LoadTaxiMask(fields[17].GetString()); // must be before InitTaxiNodesForLevel uint32 extraflags = fields[31].GetUInt32(); m_stableSlots = fields[32].GetUInt32(); - if(m_stableSlots > MAX_PET_STABLES) + if (m_stableSlots > MAX_PET_STABLES) { sLog.outError("Player can have not more %u stable slots, but have in DB %u",MAX_PET_STABLES,uint32(m_stableSlots)); m_stableSlots = MAX_PET_STABLES; @@ -15840,7 +15846,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) UpdateHonorFields(); m_deathExpireTime = (time_t)fields[36].GetUInt64(); - if(m_deathExpireTime > now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP) + if (m_deathExpireTime > now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP) m_deathExpireTime = now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP-1; std::string taxi_nodes = fields[37].GetCppString(); @@ -15860,8 +15866,8 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) // reset some aura modifiers before aura apply SetGuidValue(PLAYER_FARSIGHT, ObjectGuid()); - SetUInt32Value(PLAYER_TRACK_CREATURES, 0 ); - SetUInt32Value(PLAYER_TRACK_RESOURCES, 0 ); + SetUInt32Value(PLAYER_TRACK_CREATURES, 0); + SetUInt32Value(PLAYER_TRACK_RESOURCES, 0); // cleanup aura list explicitly before skill load where some spells can be applied RemoveAllAuras(); @@ -15889,8 +15895,8 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) //speed collect rest bonus in offline, in logout, in tavern, city (section/in hour) float bubble1 = 0.125f; float bubble = fields[23].GetUInt32() > 0 - ? bubble1*sWorld.getConfig(CONFIG_FLOAT_RATE_REST_OFFLINE_IN_TAVERN_OR_CITY) - : bubble0*sWorld.getConfig(CONFIG_FLOAT_RATE_REST_OFFLINE_IN_WILDERNESS); + ? bubble1*sWorld.getConfig(CONFIG_FLOAT_RATE_REST_OFFLINE_IN_TAVERN_OR_CITY) + : bubble0*sWorld.getConfig(CONFIG_FLOAT_RATE_REST_OFFLINE_IN_WILDERNESS); SetRestBonus(GetRestBonus()+ time_diff*((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)/72000)*bubble); } @@ -15914,7 +15920,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) ApplyGlyphs(true); // add ghost flag (must be after aura load: PLAYER_FLAGS_GHOST set in aura) - if( HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST) ) + if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) m_deathState = DEAD; _LoadSpells(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSPELLS)); @@ -15986,7 +15992,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) m_taxi.ClearTaxiDestinations(); } - if(uint32 node_id = m_taxi.GetTaxiSource()) + if (uint32 node_id = m_taxi.GetTaxiSource()) { // save source node as recall coord to prevent recall and fall from sky TaxiNodesEntry const* nodeEntry = sTaxiNodesStore.LookupEntry(node_id); @@ -16006,7 +16012,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) // Spell code allow apply any auras to dead character in load time in aura/spell/item loading // Do now before stats re-calculation cleanup for ghost state unexpected auras - if(!isAlive()) + if (!isAlive()) RemoveAllAurasOnDeath(); //apply all stat bonuses from items and auras @@ -16016,7 +16022,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) // restore remembered power/health values (but not more max values) uint32 savedhealth = fields[50].GetUInt32(); SetHealth(savedhealth > GetMaxHealth() ? GetMaxHealth() : savedhealth); - for(uint32 i = 0; i < MAX_POWERS; ++i) + for (uint32 i = 0; i < MAX_POWERS; ++i) { uint32 savedpower = fields[51+i].GetUInt32(); SetPower(Powers(i),savedpower > GetMaxPower(Powers(i)) ? GetMaxPower(Powers(i)) : savedpower); @@ -16029,59 +16035,59 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) delete result; // GM state - if(GetSession()->GetSecurity() > SEC_PLAYER) + if (GetSession()->GetSecurity() > SEC_PLAYER) { - switch(sWorld.getConfig(CONFIG_UINT32_GM_LOGIN_STATE)) + switch (sWorld.getConfig(CONFIG_UINT32_GM_LOGIN_STATE)) { default: case 0: break; // disable case 1: SetGameMaster(true); break; // enable case 2: // save state - if(extraflags & PLAYER_EXTRA_GM_ON) + if (extraflags & PLAYER_EXTRA_GM_ON) SetGameMaster(true); break; } - switch(sWorld.getConfig(CONFIG_UINT32_GM_VISIBLE_STATE)) + switch (sWorld.getConfig(CONFIG_UINT32_GM_VISIBLE_STATE)) { default: case 0: SetGMVisible(false); break; // invisible case 1: break; // visible case 2: // save state - if(extraflags & PLAYER_EXTRA_GM_INVISIBLE) + if (extraflags & PLAYER_EXTRA_GM_INVISIBLE) SetGMVisible(false); break; } - switch(sWorld.getConfig(CONFIG_UINT32_GM_ACCEPT_TICKETS)) + switch (sWorld.getConfig(CONFIG_UINT32_GM_ACCEPT_TICKETS)) { default: case 0: break; // disable case 1: SetAcceptTicket(true); break; // enable case 2: // save state - if(extraflags & PLAYER_EXTRA_GM_ACCEPT_TICKETS) - SetAcceptTicket(true); - break; + if (extraflags & PLAYER_EXTRA_GM_ACCEPT_TICKETS) + SetAcceptTicket(true); + break; } - switch(sWorld.getConfig(CONFIG_UINT32_GM_CHAT)) + switch (sWorld.getConfig(CONFIG_UINT32_GM_CHAT)) { default: case 0: break; // disable case 1: SetGMChat(true); break; // enable case 2: // save state - if(extraflags & PLAYER_EXTRA_GM_CHAT) + if (extraflags & PLAYER_EXTRA_GM_CHAT) SetGMChat(true); break; } - switch(sWorld.getConfig(CONFIG_UINT32_GM_WISPERING_TO)) + switch (sWorld.getConfig(CONFIG_UINT32_GM_WISPERING_TO)) { default: case 0: break; // disable case 1: SetAcceptWhispers(true); break; // enable case 2: // save state - if(extraflags & PLAYER_EXTRA_ACCEPT_WHISPERS) + if (extraflags & PLAYER_EXTRA_ACCEPT_WHISPERS) SetAcceptWhispers(true); break; } @@ -16122,51 +16128,51 @@ bool Player::isAllowedToLoot(Creature* creature) return !creature->HasLootRecipient(); } -void Player::_LoadActions(QueryResult *result) +void Player::_LoadActions(QueryResult* result) { - for(int i = 0; i < MAX_TALENT_SPEC_COUNT; ++i) + for (int i = 0; i < MAX_TALENT_SPEC_COUNT; ++i) m_actionButtons[i].clear(); //QueryResult *result = CharacterDatabase.PQuery("SELECT spec, button,action,type FROM character_action WHERE guid = '%u' ORDER BY button",GetGUIDLow()); - if(result) + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint8 spec = fields[0].GetUInt8(); uint8 button = fields[1].GetUInt8(); uint32 action = fields[2].GetUInt32(); uint8 type = fields[3].GetUInt8(); - if(ActionButton* ab = addActionButton(spec, button, action, type)) + if (ActionButton* ab = addActionButton(spec, button, action, type)) ab->uState = ACTIONBUTTON_UNCHANGED; else { - sLog.outError( " ...at loading, and will deleted in DB also"); + sLog.outError(" ...at loading, and will deleted in DB also"); // Will deleted in DB at next save (it can create data until save but marked as deleted) m_actionButtons[spec][button].uState = ACTIONBUTTON_DELETED; } } - while( result->NextRow() ); + while (result->NextRow()); delete result; } } -void Player::_LoadAuras(QueryResult *result, uint32 timediff) +void Player::_LoadAuras(QueryResult* result, uint32 timediff) { //RemoveAllAuras(); -- some spells casted before aura load, for example in LoadSkills, aura list explicitly cleaned early //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,item_guid,spell,stackcount,remaincharges,basepoints0,basepoints1,basepoints2,periodictime0,periodictime1,periodictime2,maxduration,remaintime,effIndexMask FROM character_aura WHERE guid = '%u'",GetGUIDLow()); - if(result) + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); ObjectGuid caster_guid = ObjectGuid(fields[0].GetUInt64()); uint32 item_lowguid = fields[1].GetUInt32(); uint32 spellid = fields[2].GetUInt32(); @@ -16211,7 +16217,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) else if (!stackcount) stackcount = 1; - SpellAuraHolder *holder = CreateSpellAuraHolder(spellproto, this, NULL); + SpellAuraHolder* holder = CreateSpellAuraHolder(spellproto, this, NULL); holder->SetLoadedState(caster_guid, ObjectGuid(HIGHGUID_ITEM, item_lowguid), stackcount, remaincharges, maxduration, remaintime); for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) @@ -16239,17 +16245,17 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) else delete holder; } - while( result->NextRow() ); + while (result->NextRow()); delete result; } - if(getClass() == CLASS_WARRIOR && !HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) + if (getClass() == CLASS_WARRIOR && !HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) CastSpell(this,SPELL_ID_PASSIVE_BATTLE_STANCE,true); } -void Player::_LoadGlyphs(QueryResult *result) +void Player::_LoadGlyphs(QueryResult* result) { - if(!result) + if (!result) return; // 0 1 2 @@ -16257,26 +16263,26 @@ void Player::_LoadGlyphs(QueryResult *result) do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint8 spec = fields[0].GetUInt8(); uint8 slot = fields[1].GetUInt8(); uint32 glyph = fields[2].GetUInt32(); - GlyphPropertiesEntry const *gp = sGlyphPropertiesStore.LookupEntry(glyph); - if(!gp) + GlyphPropertiesEntry const* gp = sGlyphPropertiesStore.LookupEntry(glyph); + if (!gp) { sLog.outError("Player %s has not existing glyph entry %u on index %u, spec %u", m_name.c_str(), glyph, slot, spec); continue; } - GlyphSlotEntry const *gs = sGlyphSlotStore.LookupEntry(GetGlyphSlot(slot)); + GlyphSlotEntry const* gs = sGlyphSlotStore.LookupEntry(GetGlyphSlot(slot)); if (!gs) { sLog.outError("Player %s has not existing glyph slot entry %u on index %u, spec %u", m_name.c_str(), GetGlyphSlot(slot), slot, spec); continue; } - if(gp->TypeFlags != gs->TypeFlags) + if (gp->TypeFlags != gs->TypeFlags) { sLog.outError("Player %s has glyph with typeflags %u in slot with typeflags %u, removing.", m_name.c_str(), gp->TypeFlags, gs->TypeFlags); continue; @@ -16284,7 +16290,8 @@ void Player::_LoadGlyphs(QueryResult *result) m_glyphs[spec][slot].id = glyph; - } while( result->NextRow() ); + } + while (result->NextRow()); delete result; @@ -16293,15 +16300,15 @@ void Player::_LoadGlyphs(QueryResult *result) void Player::LoadCorpse() { - if( isAlive() ) + if (isAlive()) { sObjectAccessor.ConvertCorpseForPlayer(GetObjectGuid()); } else { - if(Corpse *corpse = GetCorpse()) + if (Corpse* corpse = GetCorpse()) { - ApplyModByteFlag(PLAYER_FIELD_BYTES, 0, PLAYER_FIELD_BYTE_RELEASE_TIMER, corpse && !sMapStore.LookupEntry(corpse->GetMapId())->Instanceable() ); + ApplyModByteFlag(PLAYER_FIELD_BYTES, 0, PLAYER_FIELD_BYTE_RELEASE_TIMER, corpse && !sMapStore.LookupEntry(corpse->GetMapId())->Instanceable()); } else { @@ -16311,7 +16318,7 @@ void Player::LoadCorpse() } } -void Player::_LoadInventory(QueryResult *result, uint32 timediff) +void Player::_LoadInventory(QueryResult* result, uint32 timediff) { //QueryResult *result = CharacterDatabase.PQuery("SELECT data,text,bag,slot,item,item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u' ORDER BY bag,slot", GetGUIDLow()); std::map bagMap; // fast guid lookup for bags @@ -16330,27 +16337,27 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) m_itemUpdateQueueBlocked = true; do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 bag_guid = fields[2].GetUInt32(); uint8 slot = fields[3].GetUInt8(); uint32 item_lowguid = fields[4].GetUInt32(); uint32 item_id = fields[5].GetUInt32(); - ItemPrototype const * proto = ObjectMgr::GetItemPrototype(item_id); + ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_id); if (!proto) { CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid); CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_lowguid); - sLog.outError( "Player::_LoadInventory: Player %s has an unknown item (id: #%u) in inventory, deleted.", GetName(),item_id ); + sLog.outError("Player::_LoadInventory: Player %s has an unknown item (id: #%u) in inventory, deleted.", GetName(),item_id); continue; } - Item *item = NewItemOrBag(proto); + Item* item = NewItemOrBag(proto); if (!item->LoadFromDB(item_lowguid, fields, GetObjectGuid())) { - sLog.outError( "Player::_LoadInventory: Player %s has broken item (id: #%u) in inventory, deleted.", GetName(),item_id ); + sLog.outError("Player::_LoadInventory: Player %s has broken item (id: #%u) in inventory, deleted.", GetName(),item_id); CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid); item->FSetState(ITEM_REMOVED); item->SaveToDB(); // it also deletes item object ! @@ -16380,29 +16387,29 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) // the item/bag is not in a bag if (!bag_guid) { - item->SetContainer( NULL ); + item->SetContainer(NULL); item->SetSlot(slot); - if (IsInventoryPos( INVENTORY_SLOT_BAG_0, slot)) + if (IsInventoryPos(INVENTORY_SLOT_BAG_0, slot)) { ItemPosCountVec dest; - if (CanStoreItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false) == EQUIP_ERR_OK) + if (CanStoreItem(INVENTORY_SLOT_BAG_0, slot, dest, item, false) == EQUIP_ERR_OK) item = StoreItem(dest, item, true); else success = false; } - else if (IsEquipmentPos( INVENTORY_SLOT_BAG_0, slot)) + else if (IsEquipmentPos(INVENTORY_SLOT_BAG_0, slot)) { uint16 dest; - if (CanEquipItem( slot, dest, item, false, false ) == EQUIP_ERR_OK) + if (CanEquipItem(slot, dest, item, false, false) == EQUIP_ERR_OK) QuickEquipItem(dest, item); else success = false; } - else if (IsBankPos( INVENTORY_SLOT_BAG_0, slot)) + else if (IsBankPos(INVENTORY_SLOT_BAG_0, slot)) { ItemPosCountVec dest; - if (CanBankItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false, false ) == EQUIP_ERR_OK) + if (CanBankItem(INVENTORY_SLOT_BAG_0, slot, dest, item, false, false) == EQUIP_ERR_OK) item = BankItem(dest, item, true); else success = false; @@ -16452,20 +16459,21 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid); problematicItems.push_back(item); } - } while (result->NextRow()); + } + while (result->NextRow()); delete result; m_itemUpdateQueueBlocked = false; // send by mail problematic items - while(!problematicItems.empty()) + while (!problematicItems.empty()) { std::string subject = GetSession()->GetMangosString(LANG_NOT_EQUIPPED_ITEM); // fill mail MailDraft draft(subject, "There's were problems with equipping item(s)."); - for(int i = 0; !problematicItems.empty() && i < MAX_MAIL_ITEMS; ++i) + for (int i = 0; !problematicItems.empty() && i < MAX_MAIL_ITEMS; ++i) { Item* item = problematicItems.front(); problematicItems.pop_front(); @@ -16481,7 +16489,7 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) _ApplyAllItemMods(); } -void Player::_LoadItemLoot(QueryResult *result) +void Player::_LoadItemLoot(QueryResult* result) { //QueryResult *result = CharacterDatabase.PQuery("SELECT guid,itemid,amount,suffix,property FROM item_loot WHERE guid = '%u'", GetGUIDLow()); @@ -16489,7 +16497,7 @@ void Player::_LoadItemLoot(QueryResult *result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 item_guid = fields[0].GetUInt32(); Item* item = GetItemByGuid(ObjectGuid(HIGHGUID_ITEM, item_guid)); @@ -16497,54 +16505,55 @@ void Player::_LoadItemLoot(QueryResult *result) if (!item) { CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u'", item_guid); - sLog.outError("Player::_LoadItemLoot: Player %s has loot for nonexistent item (GUID: %u) in `item_loot`, deleted.", GetName(), item_guid ); + sLog.outError("Player::_LoadItemLoot: Player %s has loot for nonexistent item (GUID: %u) in `item_loot`, deleted.", GetName(), item_guid); continue; } item->LoadLootFromDB(fields); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } } // load mailed item which should receive current player -void Player::_LoadMailedItems(QueryResult *result) +void Player::_LoadMailedItems(QueryResult* result) { // data needs to be at first place for Item::LoadFromDB // 0 1 2 3 4 // "SELECT data, text, mail_id, item_guid, item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE receiver = '%u'", GUID_LOPART(m_guid) - if(!result) + if (!result) return; do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 mail_id = fields[2].GetUInt32(); uint32 item_guid_low = fields[3].GetUInt32(); uint32 item_template = fields[4].GetUInt32(); Mail* mail = GetMail(mail_id); - if(!mail) + if (!mail) continue; mail->AddItem(item_guid_low, item_template); - ItemPrototype const *proto = ObjectMgr::GetItemPrototype(item_template); + ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_template); - if(!proto) + if (!proto) { - sLog.outError( "Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template,mail->messageID); + sLog.outError("Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template,mail->messageID); CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low); CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guid_low); continue; } - Item *item = NewItemOrBag(proto); + Item* item = NewItemOrBag(proto); if (!item->LoadFromDB(item_guid_low, fields, GetObjectGuid())) { - sLog.outError( "Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, item_guid_low); + sLog.outError("Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, item_guid_low); CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low); item->FSetState(ITEM_REMOVED); item->SaveToDB(); // it also deletes item object ! @@ -16552,23 +16561,24 @@ void Player::_LoadMailedItems(QueryResult *result) } AddMItem(item); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } -void Player::_LoadMails(QueryResult *result) +void Player::_LoadMails(QueryResult* result) { m_mail.clear(); // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 //"SELECT id,messageType,sender,receiver,subject,body,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId,has_items FROM mail WHERE receiver = '%u' ORDER BY id DESC", GetGUIDLow() - if(!result) + if (!result) return; do { - Field *fields = result->Fetch(); - Mail *m = new Mail; + Field* fields = result->Fetch(); + Mail* m = new Mail; m->messageID = fields[0].GetUInt32(); m->messageType = fields[1].GetUInt8(); m->sender = fields[2].GetUInt32(); @@ -16586,7 +16596,7 @@ void Player::_LoadMails(QueryResult *result) if (m->mailTemplateId && !sMailTemplateStore.LookupEntry(m->mailTemplateId)) { - sLog.outError( "Player::_LoadMail - Mail (%u) have nonexistent MailTemplateId (%u), remove at load", m->messageID, m->mailTemplateId); + sLog.outError("Player::_LoadMail - Mail (%u) have nonexistent MailTemplateId (%u), remove at load", m->messageID, m->mailTemplateId); m->mailTemplateId = 0; } @@ -16597,7 +16607,8 @@ void Player::_LoadMails(QueryResult *result) if (m->mailTemplateId && !m->has_items) m->prepareTemplateItems(this); - } while( result->NextRow() ); + } + while (result->NextRow()); delete result; } @@ -16605,15 +16616,15 @@ void Player::LoadPet() { // fixme: the pet should still be loaded if the player is not in world // just not added to the map - if(IsInWorld()) + if (IsInWorld()) { - Pet *pet = new Pet; - if(!pet->LoadPetFromDB(this, 0, 0, true)) + Pet* pet = new Pet; + if (!pet->LoadPetFromDB(this, 0, 0, true)) delete pet; } } -void Player::_LoadQuestStatus(QueryResult *result) +void Player::_LoadQuestStatus(QueryResult* result) { mQuestStatus.clear(); @@ -16622,22 +16633,22 @@ void Player::_LoadQuestStatus(QueryResult *result) //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 //QueryResult *result = CharacterDatabase.PQuery("SELECT quest, status, rewarded, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, itemcount1, itemcount2, itemcount3, itemcount4, itemcount5, itemcount6 FROM character_queststatus WHERE guid = '%u'", GetGUIDLow()); - if(result) + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 quest_id = fields[0].GetUInt32(); - // used to be new, no delete? + // used to be new, no delete? Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id); - if( pQuest ) + if (pQuest) { // find or create QuestStatusData& questStatusData = mQuestStatus[quest_id]; uint32 qstatus = fields[1].GetUInt32(); - if(qstatus < MAX_QUEST_STATUS) + if (qstatus < MAX_QUEST_STATUS) questStatusData.m_status = QuestStatus(qstatus); else { @@ -16645,14 +16656,14 @@ void Player::_LoadQuestStatus(QueryResult *result) sLog.outError("Player %s have invalid quest %d status (%d), replaced by QUEST_STATUS_NONE(0).",GetName(),quest_id,qstatus); } - questStatusData.m_rewarded = ( fields[2].GetUInt8() > 0 ); - questStatusData.m_explored = ( fields[3].GetUInt8() > 0 ); + questStatusData.m_rewarded = (fields[2].GetUInt8() > 0); + questStatusData.m_explored = (fields[3].GetUInt8() > 0); time_t quest_time = time_t(fields[4].GetUInt64()); if (pQuest->HasSpecialFlag(QUEST_SPECIAL_FLAG_TIMED) && !GetQuestRewardStatus(quest_id) && questStatusData.m_status != QUEST_STATUS_NONE) { - AddTimedQuest( quest_id ); + AddTimedQuest(quest_id); if (quest_time <= sWorld.GetGameTime()) questStatusData.m_timer = 1; @@ -16677,10 +16688,10 @@ void Player::_LoadQuestStatus(QueryResult *result) // add to quest log if (slot < MAX_QUEST_LOG_SIZE && - ((questStatusData.m_status == QUEST_STATUS_INCOMPLETE || - questStatusData.m_status == QUEST_STATUS_COMPLETE || - questStatusData.m_status == QUEST_STATUS_FAILED) && - (!questStatusData.m_rewarded || pQuest->IsRepeatable()))) + ((questStatusData.m_status == QUEST_STATUS_INCOMPLETE || + questStatusData.m_status == QUEST_STATUS_COMPLETE || + questStatusData.m_status == QUEST_STATUS_FAILED) && + (!questStatusData.m_rewarded || pQuest->IsRepeatable()))) { SetQuestSlot(slot, quest_id, uint32(quest_time)); @@ -16693,67 +16704,67 @@ void Player::_LoadQuestStatus(QueryResult *result) if (questStatusData.m_status == QUEST_STATUS_FAILED) SetQuestSlotState(slot, QUEST_STATE_FAIL); - for(uint8 idx = 0; idx < QUEST_OBJECTIVES_COUNT; ++idx) - if(questStatusData.m_creatureOrGOcount[idx]) + for (uint8 idx = 0; idx < QUEST_OBJECTIVES_COUNT; ++idx) + if (questStatusData.m_creatureOrGOcount[idx]) SetQuestSlotCounter(slot, idx, questStatusData.m_creatureOrGOcount[idx]); ++slot; } - if(questStatusData.m_rewarded) + if (questStatusData.m_rewarded) { // learn rewarded spell if unknown learnQuestRewardedSpells(pQuest); // set rewarded title if any - if(pQuest->GetCharTitleId()) + if (pQuest->GetCharTitleId()) { - if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId())) + if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId())) SetTitle(titleEntry); } - if(pQuest->GetBonusTalents()) + if (pQuest->GetBonusTalents()) m_questRewardTalentCount += pQuest->GetBonusTalents(); } DEBUG_LOG("Quest status is {%u} for quest {%u} for player (GUID: %u)", questStatusData.m_status, quest_id, GetGUIDLow()); } } - while( result->NextRow() ); + while (result->NextRow()); delete result; } // clear quest log tail - for ( uint16 i = slot; i < MAX_QUEST_LOG_SIZE; ++i ) + for (uint16 i = slot; i < MAX_QUEST_LOG_SIZE; ++i) SetQuestSlot(i, 0); } -void Player::_LoadDailyQuestStatus(QueryResult *result) +void Player::_LoadDailyQuestStatus(QueryResult* result) { - for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0); //QueryResult *result = CharacterDatabase.PQuery("SELECT quest FROM character_queststatus_daily WHERE guid = '%u'", GetGUIDLow()); - if(result) + if (result) { uint32 quest_daily_idx = 0; do { - if(quest_daily_idx >= PLAYER_MAX_DAILY_QUESTS) // max amount with exist data in query + if (quest_daily_idx >= PLAYER_MAX_DAILY_QUESTS) // max amount with exist data in query { sLog.outError("Player (GUID: %u) have more 25 daily quest records in `charcter_queststatus_daily`",GetGUIDLow()); break; } - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 quest_id = fields[0].GetUInt32(); Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id); - if( !pQuest ) + if (!pQuest) continue; SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id); @@ -16761,7 +16772,7 @@ void Player::_LoadDailyQuestStatus(QueryResult *result) DEBUG_LOG("Daily quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow()); } - while( result->NextRow() ); + while (result->NextRow()); delete result; } @@ -16769,7 +16780,7 @@ void Player::_LoadDailyQuestStatus(QueryResult *result) m_DailyQuestChanged = false; } -void Player::_LoadWeeklyQuestStatus(QueryResult *result) +void Player::_LoadWeeklyQuestStatus(QueryResult* result) { m_weeklyquests.clear(); @@ -16779,7 +16790,7 @@ void Player::_LoadWeeklyQuestStatus(QueryResult *result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 quest_id = fields[0].GetUInt32(); @@ -16791,14 +16802,14 @@ void Player::_LoadWeeklyQuestStatus(QueryResult *result) DEBUG_LOG("Weekly quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow()); } - while( result->NextRow() ); + while (result->NextRow()); delete result; } m_WeeklyQuestChanged = false; } -void Player::_LoadMonthlyQuestStatus(QueryResult *result) +void Player::_LoadMonthlyQuestStatus(QueryResult* result) { m_monthlyquests.clear(); @@ -16808,7 +16819,7 @@ void Player::_LoadMonthlyQuestStatus(QueryResult *result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 quest_id = fields[0].GetUInt32(); @@ -16820,7 +16831,7 @@ void Player::_LoadMonthlyQuestStatus(QueryResult *result) DEBUG_LOG("Monthly quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow()); } - while( result->NextRow() ); + while (result->NextRow()); delete result; } @@ -16828,50 +16839,50 @@ void Player::_LoadMonthlyQuestStatus(QueryResult *result) m_MonthlyQuestChanged = false; } -void Player::_LoadSpells(QueryResult *result) +void Player::_LoadSpells(QueryResult* result) { //QueryResult *result = CharacterDatabase.PQuery("SELECT spell,active,disabled FROM character_spell WHERE guid = '%u'",GetGUIDLow()); - if(result) + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 spell_id = fields[0].GetUInt32(); // skip talents & drop unneeded data - if(GetTalentSpellPos(spell_id)) + if (GetTalentSpellPos(spell_id)) { sLog.outError("Player::_LoadSpells: %s has talent spell %u in character_spell, removing it.", - GetGuidStr().c_str(), spell_id); + GetGuidStr().c_str(), spell_id); CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'", spell_id); continue; } addSpell(spell_id, fields[1].GetBool(), false, false, fields[2].GetBool()); } - while( result->NextRow() ); + while (result->NextRow()); delete result; } } -void Player::_LoadTalents(QueryResult *result) +void Player::_LoadTalents(QueryResult* result) { //QueryResult *result = CharacterDatabase.PQuery("SELECT talent_id, current_rank, spec FROM character_talent WHERE guid = '%u'",GetGUIDLow()); if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 talent_id = fields[0].GetUInt32(); TalentEntry const* talentInfo = sTalentStore.LookupEntry(talent_id); if (!talentInfo) { - sLog.outError("Player::_LoadTalents:Player (GUID: %u) has invalid talent_id: %u , this talent will be deleted from character_talent",GetGUIDLow(), talent_id ); + sLog.outError("Player::_LoadTalents:Player (GUID: %u) has invalid talent_id: %u , this talent will be deleted from character_talent",GetGUIDLow(), talent_id); CharacterDatabase.PExecute("DELETE FROM character_talent WHERE talent_id = '%u'", talent_id); continue; } @@ -16880,7 +16891,7 @@ void Player::_LoadTalents(QueryResult *result) if (!talentTabInfo) { - sLog.outError("Player::_LoadTalents:Player (GUID: %u) has invalid talentTabInfo: %u for talentID: %u , this talent will be deleted from character_talent",GetGUIDLow(), talentInfo->TalentTab, talentInfo->TalentID ); + sLog.outError("Player::_LoadTalents:Player (GUID: %u) has invalid talentTabInfo: %u for talentID: %u , this talent will be deleted from character_talent",GetGUIDLow(), talentInfo->TalentTab, talentInfo->TalentID); CharacterDatabase.PExecute("DELETE FROM character_talent WHERE talent_id = '%u'", talent_id); continue; } @@ -16888,7 +16899,7 @@ void Player::_LoadTalents(QueryResult *result) // prevent load talent for different class (cheating) if ((getClassMask() & talentTabInfo->ClassMask) == 0) { - sLog.outError("Player::_LoadTalents:Player (GUID: %u) has talent with ClassMask: %u , but Player's ClassMask is: %u , talentID: %u , this talent will be deleted from character_talent",GetGUIDLow(), talentTabInfo->ClassMask, getClassMask() ,talentInfo->TalentID ); + sLog.outError("Player::_LoadTalents:Player (GUID: %u) has talent with ClassMask: %u , but Player's ClassMask is: %u , talentID: %u , this talent will be deleted from character_talent",GetGUIDLow(), talentTabInfo->ClassMask, getClassMask() ,talentInfo->TalentID); CharacterDatabase.PExecute("DELETE FROM character_talent WHERE guid = '%u' AND talent_id = '%u'", GetGUIDLow(), talent_id); continue; } @@ -16897,7 +16908,7 @@ void Player::_LoadTalents(QueryResult *result) if (currentRank > MAX_TALENT_RANK || talentInfo->RankID[currentRank] == 0) { - sLog.outError("Player::_LoadTalents:Player (GUID: %u) has invalid talent rank: %u , talentID: %u , this talent will be deleted from character_talent",GetGUIDLow(), currentRank, talentInfo->TalentID ); + sLog.outError("Player::_LoadTalents:Player (GUID: %u) has invalid talent rank: %u , talentID: %u , this talent will be deleted from character_talent",GetGUIDLow(), currentRank, talentInfo->TalentID); CharacterDatabase.PExecute("DELETE FROM character_talent WHERE guid = '%u' AND talent_id = '%u'", GetGUIDLow(), talent_id); continue; } @@ -16934,7 +16945,7 @@ void Player::_LoadTalents(QueryResult *result) } } -void Player::_LoadGroup(QueryResult *result) +void Player::_LoadGroup(QueryResult* result) { //QueryResult *result = CharacterDatabase.PQuery("SELECT groupId FROM group_member WHERE memberGuid='%u'", GetGUIDLow()); if (result) @@ -16956,19 +16967,19 @@ void Player::_LoadGroup(QueryResult *result) } } -void Player::_LoadBoundInstances(QueryResult *result) +void Player::_LoadBoundInstances(QueryResult* result) { - for(uint8 i = 0; i < MAX_DIFFICULTY; ++i) + for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) m_boundInstances[i].clear(); - Group *group = GetGroup(); + Group* group = GetGroup(); //QueryResult *result = CharacterDatabase.PQuery("SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid)); - if(result) + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bool perm = fields[1].GetBool(); uint32 mapId = fields[2].GetUInt32(); uint32 instanceId = fields[0].GetUInt32(); @@ -16980,14 +16991,14 @@ void Player::_LoadBoundInstances(QueryResult *result) // and in that case it is not used MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); - if(!mapEntry || !mapEntry->IsDungeon()) + if (!mapEntry || !mapEntry->IsDungeon()) { sLog.outError("_LoadBoundInstances: player %s(%d) has bind to nonexistent or not dungeon map %d", GetName(), GetGUIDLow(), mapId); CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u' AND instance = '%u'", GetGUIDLow(), instanceId); continue; } - if(difficulty >= MAX_DIFFICULTY) + if (difficulty >= MAX_DIFFICULTY) { sLog.outError("_LoadBoundInstances: player %s(%d) has bind to nonexistent difficulty %d instance for map %u", GetName(), GetGUIDLow(), difficulty, mapId); CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u' AND instance = '%u'", GetGUIDLow(), instanceId); @@ -16995,26 +17006,27 @@ void Player::_LoadBoundInstances(QueryResult *result) } MapDifficulty const* mapDiff = GetMapDifficultyData(mapId,Difficulty(difficulty)); - if(!mapDiff) + if (!mapDiff) { sLog.outError("_LoadBoundInstances: player %s(%d) has bind to nonexistent difficulty %d instance for map %u", GetName(), GetGUIDLow(), difficulty, mapId); CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u' AND instance = '%u'", GetGUIDLow(), instanceId); continue; } - if(!perm && group) + if (!perm && group) { sLog.outError("_LoadBoundInstances: %s is in group (Id: %d) but has a non-permanent character bind to map %d,%d,%d", - GetGuidStr().c_str(), group->GetId(), mapId, instanceId, difficulty); + GetGuidStr().c_str(), group->GetId(), mapId, instanceId, difficulty); CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u' AND instance = '%u'", - GetGUIDLow(), instanceId); + GetGUIDLow(), instanceId); continue; } // since non permanent binds are always solo bind, they can always be reset - DungeonPersistentState *state = (DungeonPersistentState*)sMapPersistentStateMgr.AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, !perm, true); - if(state) BindToInstance(state, perm, true); - } while(result->NextRow()); + DungeonPersistentState* state = (DungeonPersistentState*)sMapPersistentStateMgr.AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, !perm, true); + if (state) BindToInstance(state, perm, true); + } + while (result->NextRow()); delete result; } } @@ -17023,11 +17035,11 @@ InstancePlayerBind* Player::GetBoundInstance(uint32 mapid, Difficulty difficulty { // some instances only have one difficulty MapDifficulty const* mapDiff = GetMapDifficultyData(mapid,difficulty); - if(!mapDiff) + if (!mapDiff) return NULL; BoundInstancesMap::iterator itr = m_boundInstances[difficulty].find(mapid); - if(itr != m_boundInstances[difficulty].end()) + if (itr != m_boundInstances[difficulty].end()) return &itr->second; else return NULL; @@ -17039,19 +17051,19 @@ void Player::UnbindInstance(uint32 mapid, Difficulty difficulty, bool unload) UnbindInstance(itr, difficulty, unload); } -void Player::UnbindInstance(BoundInstancesMap::iterator &itr, Difficulty difficulty, bool unload) +void Player::UnbindInstance(BoundInstancesMap::iterator& itr, Difficulty difficulty, bool unload) { - if(itr != m_boundInstances[difficulty].end()) + if (itr != m_boundInstances[difficulty].end()) { if (!unload) CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u' AND instance = '%u'", - GetGUIDLow(), itr->second.state->GetInstanceId()); + GetGUIDLow(), itr->second.state->GetInstanceId()); itr->second.state->RemovePlayer(this); // state can become invalid m_boundInstances[difficulty].erase(itr++); } } -InstancePlayerBind* Player::BindToInstance(DungeonPersistentState *state, bool permanent, bool load) +InstancePlayerBind* Player::BindToInstance(DungeonPersistentState* state, bool permanent, bool load) { if (state) { @@ -17059,16 +17071,16 @@ InstancePlayerBind* Player::BindToInstance(DungeonPersistentState *state, bool p if (bind.state) { // update the state when the group kills a boss - if(permanent != bind.perm || state != bind.state) + if (permanent != bind.perm || state != bind.state) if (!load) CharacterDatabase.PExecute("UPDATE character_instance SET instance = '%u', permanent = '%u' WHERE guid = '%u' AND instance = '%u'", - state->GetInstanceId(), permanent, GetGUIDLow(), bind.state->GetInstanceId()); + state->GetInstanceId(), permanent, GetGUIDLow(), bind.state->GetInstanceId()); } else { if (!load) CharacterDatabase.PExecute("INSERT INTO character_instance (guid, instance, permanent) VALUES ('%u', '%u', '%u')", - GetGUIDLow(), state->GetInstanceId(), permanent); + GetGUIDLow(), state->GetInstanceId(), permanent); } if (bind.state != state) @@ -17085,7 +17097,7 @@ InstancePlayerBind* Player::BindToInstance(DungeonPersistentState *state, bool p bind.perm = permanent; if (!load) DEBUG_LOG("Player::BindToInstance: %s(%d) is now bound to map %d, instance %d, difficulty %d", - GetName(), GetGUIDLow(), state->GetMapId(), state->GetInstanceId(), state->GetDifficulty()); + GetName(), GetGUIDLow(), state->GetMapId(), state->GetInstanceId(), state->GetDifficulty()); return &bind; } else @@ -17098,16 +17110,16 @@ DungeonPersistentState* Player::GetBoundInstanceSaveForSelfOrGroup(uint32 mapid) if (!mapEntry) return NULL; - InstancePlayerBind *pBind = GetBoundInstance(mapid, GetDifficulty(mapEntry->IsRaid())); - DungeonPersistentState *state = pBind ? pBind->state : NULL; + InstancePlayerBind* pBind = GetBoundInstance(mapid, GetDifficulty(mapEntry->IsRaid())); + DungeonPersistentState* state = pBind ? pBind->state : NULL; // the player's permanent player bind is taken into consideration first // then the player's group bind and finally the solo bind. if (!pBind || !pBind->perm) { - InstanceGroupBind *groupBind = NULL; + InstanceGroupBind* groupBind = NULL; // use the player's difficulty setting (it may not be the same as the group's) - if (Group *group = GetGroup()) + if (Group* group = GetGroup()) if (groupBind = group->GetBoundInstance(mapid, this)) state = groupBind->state; } @@ -17126,13 +17138,13 @@ void Player::SendRaidInfo() time_t now = time(NULL); - for(int i = 0; i < MAX_DIFFICULTY; ++i) + for (int i = 0; i < MAX_DIFFICULTY; ++i) { for (BoundInstancesMap::const_iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) { if (itr->second.perm) { - DungeonPersistentState *state = itr->second.state; + DungeonPersistentState* state = itr->second.state; data << uint32(state->GetMapId()); // map id data << uint32(state->GetDifficulty()); // difficulty data << ObjectGuid(state->GetInstanceGuid());// instance guid @@ -17155,11 +17167,11 @@ void Player::SendSavedInstances() bool hasBeenSaved = false; WorldPacket data; - for(uint8 i = 0; i < MAX_DIFFICULTY; ++i) + for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { for (BoundInstancesMap::const_iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) { - if(itr->second.perm) // only permanent binds are sent + if (itr->second.perm) // only permanent binds are sent { hasBeenSaved = true; break; @@ -17172,14 +17184,14 @@ void Player::SendSavedInstances() data << uint32(hasBeenSaved); GetSession()->SendPacket(&data); - if(!hasBeenSaved) + if (!hasBeenSaved) return; - for(uint8 i = 0; i < MAX_DIFFICULTY; ++i) + for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { for (BoundInstancesMap::const_iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) { - if(itr->second.perm) + if (itr->second.perm) { data.Initialize(SMSG_UPDATE_LAST_INSTANCE); data << uint32(itr->second.state->GetMapId()); @@ -17190,7 +17202,7 @@ void Player::SendSavedInstances() } /// convert the player's binds to the group -void Player::ConvertInstancesToGroup(Player *player, Group *group, ObjectGuid player_guid) +void Player::ConvertInstancesToGroup(Player* player, Group* group, ObjectGuid player_guid) { bool has_binds = false; bool has_solo = false; @@ -17209,7 +17221,7 @@ void Player::ConvertInstancesToGroup(Player *player, Group *group, ObjectGuid pl if (player) { - for(uint8 i = 0; i < MAX_DIFFICULTY; ++i) + for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { for (BoundInstancesMap::iterator itr = player->m_boundInstances[i].begin(); itr != player->m_boundInstances[i].end();) { @@ -17242,10 +17254,10 @@ void Player::ConvertInstancesToGroup(Player *player, Group *group, ObjectGuid pl CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u' AND permanent = 0", player_lowguid); } -bool Player::_LoadHomeBind(QueryResult *result) +bool Player::_LoadHomeBind(QueryResult* result) { - PlayerInfo const *info = sObjectMgr.GetPlayerInfo(getRace(), getClass()); - if(!info) + PlayerInfo const* info = sObjectMgr.GetPlayerInfo(getRace(), getClass()); + if (!info) { sLog.outError("Player have incorrect race/class pair. Can't be loaded."); return false; @@ -17255,7 +17267,7 @@ bool Player::_LoadHomeBind(QueryResult *result) //QueryResult *result = CharacterDatabase.PQuery("SELECT map,zone,position_x,position_y,position_z FROM character_homebind WHERE guid = '%u'", GUID_LOPART(playerGuid)); if (result) { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); m_homebindMapId = fields[0].GetUInt32(); m_homebindAreaId = fields[1].GetUInt16(); m_homebindX = fields[2].GetFloat(); @@ -17266,8 +17278,8 @@ bool Player::_LoadHomeBind(QueryResult *result) MapEntry const* bindMapEntry = sMapStore.LookupEntry(m_homebindMapId); // accept saved data only for valid position (and non instanceable), and accessable - if( MapManager::IsValidMapCoord(m_homebindMapId,m_homebindX,m_homebindY,m_homebindZ) && - !bindMapEntry->Instanceable() && GetSession()->Expansion() >= bindMapEntry->Expansion()) + if (MapManager::IsValidMapCoord(m_homebindMapId,m_homebindX,m_homebindY,m_homebindZ) && + !bindMapEntry->Instanceable() && GetSession()->Expansion() >= bindMapEntry->Expansion()) { ok = true; } @@ -17275,7 +17287,7 @@ bool Player::_LoadHomeBind(QueryResult *result) CharacterDatabase.PExecute("DELETE FROM character_homebind WHERE guid = '%u'", GetGUIDLow()); } - if(!ok) + if (!ok) { m_homebindMapId = info->mapId; m_homebindAreaId = info->areaId; @@ -17287,7 +17299,7 @@ bool Player::_LoadHomeBind(QueryResult *result) } DEBUG_LOG("Setting player home position: mapid is: %u, zoneid is %u, X is %f, Y is %f, Z is %f", - m_homebindMapId, m_homebindAreaId, m_homebindX, m_homebindY, m_homebindZ); + m_homebindMapId, m_homebindAreaId, m_homebindX, m_homebindY, m_homebindZ); return true; } @@ -17303,7 +17315,7 @@ void Player::SaveToDB() m_nextSave = sWorld.getConfig(CONFIG_UINT32_INTERVAL_SAVE); //lets allow only players in world to be saved - if(IsBeingTeleportedFar()) + if (IsBeingTeleportedFar()) { ScheduleDelayedOperation(DELAYED_SAVE_PLAYER); return; @@ -17324,21 +17336,21 @@ void Player::SaveToDB() stmt.PExecute(GetGUIDLow()); SqlStatement uberInsert = CharacterDatabase.CreateStatement(insChar, "INSERT INTO characters (guid,account,name,race,class,gender,level,xp,money,playerBytes,playerBytes2,playerFlags," - "map, dungeon_difficulty, position_x, position_y, position_z, orientation, " - "taximask, online, cinematic, " - "totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, " - "trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, " - "death_expire_time, taxi_path, arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, " - "todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, health, power1, power2, power3, " - "power4, power5, power6, power7, specCount, activeSpec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars) " - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " - "?, ?, ?, ?, ?, ?, " - "?, ?, ?, " - "?, ?, ?, ?, ?, ?, ?, " - "?, ?, ?, ?, ?, ?, ?, ?, ?, " - "?, ?, ?, ?, ?, ?, ?, " - "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " - "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); + "map, dungeon_difficulty, position_x, position_y, position_z, orientation, " + "taximask, online, cinematic, " + "totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, " + "trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, " + "death_expire_time, taxi_path, arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, " + "todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, health, power1, power2, power3, " + "power4, power5, power6, power7, specCount, activeSpec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, ?, " + "?, ?, ?, " + "?, ?, ?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); uberInsert.addUInt32(GetGUIDLow()); uberInsert.addUInt32(GetSession()->GetAccountId()); @@ -17353,7 +17365,7 @@ void Player::SaveToDB() uberInsert.addUInt32(GetUInt32Value(PLAYER_BYTES_2)); uberInsert.addUInt32(GetUInt32Value(PLAYER_FLAGS)); - if(!IsBeingTeleported()) + if (!IsBeingTeleported()) { uberInsert.addUInt32(GetMapId()); uberInsert.addUInt32(uint32(GetDungeonDifficulty())); @@ -17386,8 +17398,8 @@ void Player::SaveToDB() uberInsert.addFloat(finiteAlways(m_rest_bonus)); uberInsert.addUInt64(uint64(time(NULL))); uberInsert.addUInt32(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0); - //save, far from tavern/city - //save, but in tavern/city + //save, far from tavern/city + //save, but in tavern/city uberInsert.addUInt32(m_resetTalentsCost); uberInsert.addUInt64(uint64(m_resetTalentsTime)); @@ -17417,7 +17429,7 @@ void Player::SaveToDB() uberInsert.addUInt32(GetHonorPoints()); - uberInsert.addUInt32(GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION) ); + uberInsert.addUInt32(GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION)); uberInsert.addUInt32(GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION)); @@ -17438,19 +17450,19 @@ void Player::SaveToDB() uberInsert.addUInt32(GetHealth()); - for(uint32 i = 0; i < MAX_POWERS; ++i) + for (uint32 i = 0; i < MAX_POWERS; ++i) uberInsert.addUInt32(GetPower(Powers(i))); uberInsert.addUInt32(uint32(m_specsCount)); uberInsert.addUInt32(uint32(m_activeSpec)); - for(uint32 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i ) //string + for (uint32 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i) //string { ss << GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + i) << " "; } uberInsert.addString(ss); - for(uint32 i = 0; i < EQUIPMENT_SLOT_END * 2; ++i ) //string + for (uint32 i = 0; i < EQUIPMENT_SLOT_END * 2; ++i) //string { ss << GetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + i) << " "; } @@ -17458,7 +17470,7 @@ void Player::SaveToDB() uberInsert.addUInt32(GetUInt32Value(PLAYER_AMMO_ID)); - for(uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i ) //string + for (uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i) //string { ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << " "; } @@ -17522,48 +17534,48 @@ void Player::_SaveActions() static SqlStatementID updateAction ; static SqlStatementID deleteAction ; - for(int i = 0; i < MAX_TALENT_SPEC_COUNT; ++i) + for (int i = 0; i < MAX_TALENT_SPEC_COUNT; ++i) { - for(ActionButtonList::iterator itr = m_actionButtons[i].begin(); itr != m_actionButtons[i].end(); ) + for (ActionButtonList::iterator itr = m_actionButtons[i].begin(); itr != m_actionButtons[i].end();) { switch (itr->second.uState) { case ACTIONBUTTON_NEW: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(insertAction, "INSERT INTO character_action (guid,spec, button,action,type) VALUES (?, ?, ?, ?, ?)"); - stmt.addUInt32(GetGUIDLow()); - stmt.addUInt32(i); - stmt.addUInt32(uint32(itr->first)); - stmt.addUInt32(itr->second.GetAction()); - stmt.addUInt32(uint32(itr->second.GetType())); - stmt.Execute(); - itr->second.uState = ACTIONBUTTON_UNCHANGED; - ++itr; - } - break; + { + SqlStatement stmt = CharacterDatabase.CreateStatement(insertAction, "INSERT INTO character_action (guid,spec, button,action,type) VALUES (?, ?, ?, ?, ?)"); + stmt.addUInt32(GetGUIDLow()); + stmt.addUInt32(i); + stmt.addUInt32(uint32(itr->first)); + stmt.addUInt32(itr->second.GetAction()); + stmt.addUInt32(uint32(itr->second.GetType())); + stmt.Execute(); + itr->second.uState = ACTIONBUTTON_UNCHANGED; + ++itr; + } + break; case ACTIONBUTTON_CHANGED: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(updateAction, "UPDATE character_action SET action = ?, type = ? WHERE guid = ? AND button = ? AND spec = ?"); - stmt.addUInt32(itr->second.GetAction()); - stmt.addUInt32(uint32(itr->second.GetType())); - stmt.addUInt32(GetGUIDLow()); - stmt.addUInt32(uint32(itr->first)); - stmt.addUInt32(i); - stmt.Execute(); - itr->second.uState = ACTIONBUTTON_UNCHANGED; - ++itr; - } - break; + { + SqlStatement stmt = CharacterDatabase.CreateStatement(updateAction, "UPDATE character_action SET action = ?, type = ? WHERE guid = ? AND button = ? AND spec = ?"); + stmt.addUInt32(itr->second.GetAction()); + stmt.addUInt32(uint32(itr->second.GetType())); + stmt.addUInt32(GetGUIDLow()); + stmt.addUInt32(uint32(itr->first)); + stmt.addUInt32(i); + stmt.Execute(); + itr->second.uState = ACTIONBUTTON_UNCHANGED; + ++itr; + } + break; case ACTIONBUTTON_DELETED: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(deleteAction, "DELETE FROM character_action WHERE guid = ? AND button = ? AND spec = ?"); - stmt.addUInt32(GetGUIDLow()); - stmt.addUInt32(uint32(itr->first)); - stmt.addUInt32(i); - stmt.Execute(); - m_actionButtons[i].erase(itr++); - } - break; + { + SqlStatement stmt = CharacterDatabase.CreateStatement(deleteAction, "DELETE FROM character_action WHERE guid = ? AND button = ? AND spec = ?"); + stmt.addUInt32(GetGUIDLow()); + stmt.addUInt32(uint32(itr->first)); + stmt.addUInt32(i); + stmt.Execute(); + m_actionButtons[i].erase(itr++); + } + break; default: ++itr; break; @@ -17586,12 +17598,12 @@ void Player::_SaveAuras() return; stmt = CharacterDatabase.CreateStatement(insertAuras, "INSERT INTO character_aura (guid, caster_guid, item_guid, spell, stackcount, remaincharges, " - "basepoints0, basepoints1, basepoints2, periodictime0, periodictime1, periodictime2, maxduration, remaintime, effIndexMask) " - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + "basepoints0, basepoints1, basepoints2, periodictime0, periodictime1, periodictime2, maxduration, remaintime, effIndexMask) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); - for(SpellAuraHolderMap::const_iterator itr = auraHolders.begin(); itr != auraHolders.end(); ++itr) + for (SpellAuraHolderMap::const_iterator itr = auraHolders.begin(); itr != auraHolders.end(); ++itr) { - SpellAuraHolder *holder = itr->second; + SpellAuraHolder* holder = itr->second; //skip all holders from spells that are passive or channeled //do not save single target holders (unless they were cast by the player) if (!holder->IsPassive() && !IsChanneledSpell(holder->GetSpellProto()) && (holder->GetCasterGuid() == GetObjectGuid() || !holder->IsSingleTarget())) @@ -17605,7 +17617,7 @@ void Player::_SaveAuras() damage[i] = 0; periodicTime[i] = 0; - if (Aura *aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) + if (Aura* aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) { // don't save not own area auras if (aur->IsAreaAura() && holder->GetCasterGuid() != GetObjectGuid()) @@ -17651,26 +17663,26 @@ void Player::_SaveGlyphs() { for (uint8 slot = 0; slot < MAX_GLYPH_SLOT_INDEX; ++slot) { - switch(m_glyphs[spec][slot].uState) + switch (m_glyphs[spec][slot].uState) { case GLYPH_NEW: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(insertGlyph, "INSERT INTO character_glyphs (guid, spec, slot, glyph) VALUES (?, ?, ?, ?)"); - stmt.PExecute(GetGUIDLow(), spec, slot, m_glyphs[spec][slot].GetId()); - } - break; + { + SqlStatement stmt = CharacterDatabase.CreateStatement(insertGlyph, "INSERT INTO character_glyphs (guid, spec, slot, glyph) VALUES (?, ?, ?, ?)"); + stmt.PExecute(GetGUIDLow(), spec, slot, m_glyphs[spec][slot].GetId()); + } + break; case GLYPH_CHANGED: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(updateGlyph, "UPDATE character_glyphs SET glyph = ? WHERE guid = ? AND spec = ? AND slot = ?"); - stmt.PExecute(m_glyphs[spec][slot].GetId(), GetGUIDLow(), spec, slot); - } - break; + { + SqlStatement stmt = CharacterDatabase.CreateStatement(updateGlyph, "UPDATE character_glyphs SET glyph = ? WHERE guid = ? AND spec = ? AND slot = ?"); + stmt.PExecute(m_glyphs[spec][slot].GetId(), GetGUIDLow(), spec, slot); + } + break; case GLYPH_DELETED: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(deleteGlyph, "DELETE FROM character_glyphs WHERE guid = ? AND spec = ? AND slot = ?"); - stmt.PExecute(GetGUIDLow(), spec, slot); - } - break; + { + SqlStatement stmt = CharacterDatabase.CreateStatement(deleteGlyph, "DELETE FROM character_glyphs WHERE guid = ? AND spec = ? AND slot = ?"); + stmt.PExecute(GetGUIDLow(), spec, slot); + } + break; case GLYPH_UNCHANGED: break; } @@ -17685,7 +17697,7 @@ void Player::_SaveInventory() // and remove those that aren't already for (uint8 i = BUYBACK_SLOT_START; i < BUYBACK_SLOT_END; ++i) { - Item *item = m_items[i]; + Item* item = m_items[i]; if (!item || item->GetState() == ITEM_NEW) continue; static SqlStatementID delInv ; @@ -17701,7 +17713,7 @@ void Player::_SaveInventory() } // update enchantment durations - for(EnchantDurationList::const_iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();++itr) + for (EnchantDurationList::const_iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) { itr->item->SetEnchantmentDuration(itr->slot,itr->leftduration); } @@ -17711,11 +17723,11 @@ void Player::_SaveInventory() // do not save if the update queue is corrupt bool error = false; - for(size_t i = 0; i < m_itemUpdateQueue.size(); ++i) + for (size_t i = 0; i < m_itemUpdateQueue.size(); ++i) { - Item *item = m_itemUpdateQueue[i]; - if(!item || item->GetState() == ITEM_REMOVED) continue; - Item *test = GetItemByPos( item->GetBagSlot(), item->GetSlot()); + Item* item = m_itemUpdateQueue[i]; + if (!item || item->GetState() == ITEM_REMOVED) continue; + Item* test = GetItemByPos(item->GetBagSlot(), item->GetSlot()); if (test == NULL) { @@ -17740,44 +17752,44 @@ void Player::_SaveInventory() static SqlStatementID updateInventory ; static SqlStatementID deleteInventory ; - for(size_t i = 0; i < m_itemUpdateQueue.size(); ++i) + for (size_t i = 0; i < m_itemUpdateQueue.size(); ++i) { - Item *item = m_itemUpdateQueue[i]; - if(!item) continue; + Item* item = m_itemUpdateQueue[i]; + if (!item) continue; - Bag *container = item->GetContainer(); + Bag* container = item->GetContainer(); uint32 bag_guid = container ? container->GetGUIDLow() : 0; - switch(item->GetState()) + switch (item->GetState()) { case ITEM_NEW: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(insertInventory, "INSERT INTO character_inventory (guid,bag,slot,item,item_template) VALUES (?, ?, ?, ?, ?)"); - stmt.addUInt32(GetGUIDLow()); - stmt.addUInt32(bag_guid); - stmt.addUInt8(item->GetSlot()); - stmt.addUInt32(item->GetGUIDLow()); - stmt.addUInt32(item->GetEntry()); - stmt.Execute(); - } - break; + { + SqlStatement stmt = CharacterDatabase.CreateStatement(insertInventory, "INSERT INTO character_inventory (guid,bag,slot,item,item_template) VALUES (?, ?, ?, ?, ?)"); + stmt.addUInt32(GetGUIDLow()); + stmt.addUInt32(bag_guid); + stmt.addUInt8(item->GetSlot()); + stmt.addUInt32(item->GetGUIDLow()); + stmt.addUInt32(item->GetEntry()); + stmt.Execute(); + } + break; case ITEM_CHANGED: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(updateInventory, "UPDATE character_inventory SET guid = ?, bag = ?, slot = ?, item_template = ? WHERE item = ?"); - stmt.addUInt32(GetGUIDLow()); - stmt.addUInt32(bag_guid); - stmt.addUInt8(item->GetSlot()); - stmt.addUInt32(item->GetEntry()); - stmt.addUInt32(item->GetGUIDLow()); - stmt.Execute(); - } - break; + { + SqlStatement stmt = CharacterDatabase.CreateStatement(updateInventory, "UPDATE character_inventory SET guid = ?, bag = ?, slot = ?, item_template = ? WHERE item = ?"); + stmt.addUInt32(GetGUIDLow()); + stmt.addUInt32(bag_guid); + stmt.addUInt8(item->GetSlot()); + stmt.addUInt32(item->GetEntry()); + stmt.addUInt32(item->GetGUIDLow()); + stmt.Execute(); + } + break; case ITEM_REMOVED: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(deleteInventory, "DELETE FROM character_inventory WHERE item = ?"); - stmt.PExecute(item->GetGUIDLow()); - } - break; + { + SqlStatement stmt = CharacterDatabase.CreateStatement(deleteInventory, "DELETE FROM character_inventory WHERE item = ?"); + stmt.PExecute(item->GetGUIDLow()); + } + break; case ITEM_UNCHANGED: break; } @@ -17798,7 +17810,7 @@ void Player::_SaveMail() for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) { - Mail *m = (*itr); + Mail* m = (*itr); if (m->state == MAIL_STATE_CHANGED) { SqlStatement stmt = CharacterDatabase.CreateStatement(updateMail, "UPDATE mail SET has_items = ?, expire_time = ?, deliver_time = ?, money = ?, cod = ?, checked = ? WHERE id = ?"); @@ -17811,11 +17823,11 @@ void Player::_SaveMail() stmt.addUInt32(m->messageID); stmt.Execute(); - if(m->removedItems.size()) + if (m->removedItems.size()) { stmt = CharacterDatabase.CreateStatement(deleteMailItems, "DELETE FROM mail_items WHERE item_guid = ?"); - for(std::vector::const_iterator itr2 = m->removedItems.begin(); itr2 != m->removedItems.end(); ++itr2) + for (std::vector::const_iterator itr2 = m->removedItems.begin(); itr2 != m->removedItems.end(); ++itr2) stmt.PExecute(*itr2); m->removedItems.clear(); @@ -17827,7 +17839,7 @@ void Player::_SaveMail() if (m->HasItems()) { SqlStatement stmt = CharacterDatabase.CreateStatement(deleteItem, "DELETE FROM item_instance WHERE guid = ?"); - for(MailItemInfoVec::const_iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) + for (MailItemInfoVec::const_iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) stmt.PExecute(itr2->item_guid); } @@ -17840,7 +17852,7 @@ void Player::_SaveMail() } //deallocate deleted mails... - for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ) + for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end();) { if ((*itr)->state == MAIL_STATE_DELETED) { @@ -17863,46 +17875,46 @@ void Player::_SaveQuestStatus() static SqlStatementID updateQuestStatus ; // we don't need transactions here. - for( QuestStatusMap::iterator i = mQuestStatus.begin( ); i != mQuestStatus.end( ); ++i ) + for (QuestStatusMap::iterator i = mQuestStatus.begin(); i != mQuestStatus.end(); ++i) { switch (i->second.uState) { case QUEST_NEW : - { - SqlStatement stmt = CharacterDatabase.CreateStatement(insertQuestStatus, "INSERT INTO character_queststatus (guid,quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4,itemcount5,itemcount6) " - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + { + SqlStatement stmt = CharacterDatabase.CreateStatement(insertQuestStatus, "INSERT INTO character_queststatus (guid,quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4,itemcount5,itemcount6) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); - stmt.addUInt32(GetGUIDLow()); - stmt.addUInt32(i->first); - stmt.addUInt8(i->second.m_status); - stmt.addUInt8(i->second.m_rewarded); - stmt.addUInt8(i->second.m_explored); - stmt.addUInt64(uint64(i->second.m_timer / IN_MILLISECONDS+ sWorld.GetGameTime())); - for (int k = 0; k < QUEST_OBJECTIVES_COUNT; ++k) - stmt.addUInt32(i->second.m_creatureOrGOcount[k]); - for (int k = 0; k < QUEST_ITEM_OBJECTIVES_COUNT; ++k) - stmt.addUInt32(i->second.m_itemcount[k]); - stmt.Execute(); - } - break; + stmt.addUInt32(GetGUIDLow()); + stmt.addUInt32(i->first); + stmt.addUInt8(i->second.m_status); + stmt.addUInt8(i->second.m_rewarded); + stmt.addUInt8(i->second.m_explored); + stmt.addUInt64(uint64(i->second.m_timer / IN_MILLISECONDS+ sWorld.GetGameTime())); + for (int k = 0; k < QUEST_OBJECTIVES_COUNT; ++k) + stmt.addUInt32(i->second.m_creatureOrGOcount[k]); + for (int k = 0; k < QUEST_ITEM_OBJECTIVES_COUNT; ++k) + stmt.addUInt32(i->second.m_itemcount[k]); + stmt.Execute(); + } + break; case QUEST_CHANGED : - { - SqlStatement stmt = CharacterDatabase.CreateStatement(updateQuestStatus, "UPDATE character_queststatus SET status = ?,rewarded = ?,explored = ?,timer = ?," - "mobcount1 = ?,mobcount2 = ?,mobcount3 = ?,mobcount4 = ?,itemcount1 = ?,itemcount2 = ?,itemcount3 = ?,itemcount4 = ?,itemcount5 = ?,itemcount6 = ? WHERE guid = ? AND quest = ?"); + { + SqlStatement stmt = CharacterDatabase.CreateStatement(updateQuestStatus, "UPDATE character_queststatus SET status = ?,rewarded = ?,explored = ?,timer = ?," + "mobcount1 = ?,mobcount2 = ?,mobcount3 = ?,mobcount4 = ?,itemcount1 = ?,itemcount2 = ?,itemcount3 = ?,itemcount4 = ?,itemcount5 = ?,itemcount6 = ? WHERE guid = ? AND quest = ?"); - stmt.addUInt8(i->second.m_status); - stmt.addUInt8(i->second.m_rewarded); - stmt.addUInt8(i->second.m_explored); - stmt.addUInt64(uint64(i->second.m_timer / IN_MILLISECONDS + sWorld.GetGameTime())); - for (int k = 0; k < QUEST_OBJECTIVES_COUNT; ++k) - stmt.addUInt32(i->second.m_creatureOrGOcount[k]); - for (int k = 0; k < QUEST_ITEM_OBJECTIVES_COUNT; ++k) - stmt.addUInt32(i->second.m_itemcount[k]); - stmt.addUInt32(GetGUIDLow()); - stmt.addUInt32(i->first); - stmt.Execute(); - } - break; + stmt.addUInt8(i->second.m_status); + stmt.addUInt8(i->second.m_rewarded); + stmt.addUInt8(i->second.m_explored); + stmt.addUInt64(uint64(i->second.m_timer / IN_MILLISECONDS + sWorld.GetGameTime())); + for (int k = 0; k < QUEST_OBJECTIVES_COUNT; ++k) + stmt.addUInt32(i->second.m_creatureOrGOcount[k]); + for (int k = 0; k < QUEST_ITEM_OBJECTIVES_COUNT; ++k) + stmt.addUInt32(i->second.m_itemcount[k]); + stmt.addUInt32(GetGUIDLow()); + stmt.addUInt32(i->first); + stmt.Execute(); + } + break; case QUEST_UNCHANGED: break; }; @@ -17924,7 +17936,7 @@ void Player::_SaveDailyQuestStatus() stmtDel.PExecute(GetGUIDLow()); - for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) stmtIns.PExecute(GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)); @@ -17984,18 +17996,18 @@ void Player::_SaveSkills() static SqlStatementID updSkills ; // we don't need transactions here. - for( SkillStatusMap::iterator itr = mSkillStatus.begin(); itr != mSkillStatus.end(); ) + for (SkillStatusMap::iterator itr = mSkillStatus.begin(); itr != mSkillStatus.end();) { - if(itr->second.uState == SKILL_UNCHANGED) + if (itr->second.uState == SKILL_UNCHANGED) { ++itr; continue; } - if(itr->second.uState == SKILL_DELETED) + if (itr->second.uState == SKILL_DELETED) { SqlStatement stmt = CharacterDatabase.CreateStatement(delSkills, "DELETE FROM character_skills WHERE guid = ? AND skill = ?"); - stmt.PExecute(GetGUIDLow(), itr->first ); + stmt.PExecute(GetGUIDLow(), itr->first); mSkillStatus.erase(itr++); continue; } @@ -18007,17 +18019,17 @@ void Player::_SaveSkills() switch (itr->second.uState) { case SKILL_NEW: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(insSkills, "INSERT INTO character_skills (guid, skill, value, max) VALUES (?, ?, ?, ?)"); - stmt.PExecute(GetGUIDLow(), itr->first, value, max); - } - break; + { + SqlStatement stmt = CharacterDatabase.CreateStatement(insSkills, "INSERT INTO character_skills (guid, skill, value, max) VALUES (?, ?, ?, ?)"); + stmt.PExecute(GetGUIDLow(), itr->first, value, max); + } + break; case SKILL_CHANGED: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(updSkills, "UPDATE character_skills SET value = ?, max = ? WHERE guid = ? AND skill = ?"); - stmt.PExecute(value, max, GetGUIDLow(), itr->first ); - } - break; + { + SqlStatement stmt = CharacterDatabase.CreateStatement(updSkills, "UPDATE character_skills SET value = ?, max = ? WHERE guid = ? AND skill = ?"); + stmt.PExecute(value, max, GetGUIDLow(), itr->first); + } + break; case SKILL_UNCHANGED: case SKILL_DELETED: MANGOS_ASSERT(false); @@ -18097,7 +18109,7 @@ void Player::_SaveTalents() void Player::_SaveStats() { // check if stat saving is enabled and if char level is high enough - if(!sWorld.getConfig(CONFIG_UINT32_MIN_LEVEL_STAT_SAVE) || getLevel() < sWorld.getConfig(CONFIG_UINT32_MIN_LEVEL_STAT_SAVE)) + if (!sWorld.getConfig(CONFIG_UINT32_MIN_LEVEL_STAT_SAVE) || getLevel() < sWorld.getConfig(CONFIG_UINT32_MIN_LEVEL_STAT_SAVE)) return; static SqlStatementID delStats ; @@ -18107,18 +18119,18 @@ void Player::_SaveStats() stmt.PExecute(GetGUIDLow()); stmt = CharacterDatabase.CreateStatement(insertStats, "INSERT INTO character_stats (guid, maxhealth, maxpower1, maxpower2, maxpower3, maxpower4, maxpower5, maxpower6, maxpower7, " - "strength, agility, stamina, intellect, spirit, armor, resHoly, resFire, resNature, resFrost, resShadow, resArcane, " - "blockPct, dodgePct, parryPct, critPct, rangedCritPct, spellCritPct, attackPower, rangedAttackPower, spellPower) " - "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + "strength, agility, stamina, intellect, spirit, armor, resHoly, resFire, resNature, resFrost, resShadow, resArcane, " + "blockPct, dodgePct, parryPct, critPct, rangedCritPct, spellCritPct, attackPower, rangedAttackPower, spellPower) " + "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); stmt.addUInt32(GetGUIDLow()); stmt.addUInt32(GetMaxHealth()); - for(int i = 0; i < MAX_POWERS; ++i) + for (int i = 0; i < MAX_POWERS; ++i) stmt.addUInt32(GetMaxPower(Powers(i))); - for(int i = 0; i < MAX_STATS; ++i) + for (int i = 0; i < MAX_STATS; ++i) stmt.addFloat(GetStat(Stats(i))); // armor + school resistances - for(int i = 0; i < MAX_SPELL_SCHOOL; ++i) + for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) stmt.addUInt32(GetResistance(SpellSchools(i))); stmt.addFloat(GetFloatValue(PLAYER_BLOCK_PERCENTAGE)); stmt.addFloat(GetFloatValue(PLAYER_DODGE_PERCENTAGE)); @@ -18136,7 +18148,7 @@ void Player::_SaveStats() void Player::outDebugStatsValues() const { // optimize disabled debug output - if(!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG) || sLog.HasLogFilter(LOG_FILTER_PLAYER_STATS)) + if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG) || sLog.HasLogFilter(LOG_FILTER_PLAYER_STATS)) return; sLog.outDebug("HP is: \t\t\t%u\t\tMP is: \t\t\t%u",GetMaxHealth(), GetMaxPower(POWER_MANA)); @@ -18160,22 +18172,22 @@ void Player::outDebugStatsValues() const void Player::UpdateSpeakTime() { // ignore chat spam protection for GMs in any mode - if(GetSession()->GetSecurity() > SEC_PLAYER) + if (GetSession()->GetSecurity() > SEC_PLAYER) return; - time_t current = time (NULL); - if(m_speakTime > current) + time_t current = time(NULL); + if (m_speakTime > current) { uint32 max_count = sWorld.getConfig(CONFIG_UINT32_CHATFLOOD_MESSAGE_COUNT); - if(!max_count) + if (!max_count) return; ++m_speakCount; - if(m_speakCount >= max_count) + if (m_speakCount >= max_count) { // prevent overwrite mute time, if message send just before mutes set, for example. time_t new_mute = current + sWorld.getConfig(CONFIG_UINT32_CHATFLOOD_MUTE_TIME); - if(GetSession()->m_muteTime < new_mute) + if (GetSession()->m_muteTime < new_mute) GetSession()->m_muteTime = new_mute; m_speakCount = 0; @@ -18189,7 +18201,7 @@ void Player::UpdateSpeakTime() bool Player::CanSpeak() const { - return GetSession()->m_muteTime <= time (NULL); + return GetSession()->m_muteTime <= time(NULL); } /*********************************************************/ @@ -18199,16 +18211,16 @@ bool Player::CanSpeak() const void Player::SendAttackSwingNotInRange() { WorldPacket data(SMSG_ATTACKSWING_NOTINRANGE, 0); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } void Player::SavePositionInDB(ObjectGuid guid, uint32 mapid, float x, float y, float z, float o, uint32 zone) { std::ostringstream ss; ss << "UPDATE characters SET position_x='"<= tokens.size()) + if (index >= tokens.size()) return; tokens[index] = buf; @@ -18245,37 +18257,37 @@ void Player::Customize(ObjectGuid guid, uint8 gender, uint8 skin, uint8 face, ui void Player::SendAttackSwingDeadTarget() { WorldPacket data(SMSG_ATTACKSWING_DEADTARGET, 0); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } void Player::SendAttackSwingCantAttack() { WorldPacket data(SMSG_ATTACKSWING_CANT_ATTACK, 0); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } void Player::SendAttackSwingCancelAttack() { WorldPacket data(SMSG_CANCEL_COMBAT, 0); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } void Player::SendAttackSwingBadFacingAttack() { WorldPacket data(SMSG_ATTACKSWING_BADFACING, 0); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } -void Player::SendAutoRepeatCancel(Unit *target) +void Player::SendAutoRepeatCancel(Unit* target) { WorldPacket data(SMSG_CANCEL_AUTO_REPEAT, target->GetPackGUID().size()); data << target->GetPackGUID(); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } void Player::SendExplorationExperience(uint32 Area, uint32 Experience) { - WorldPacket data( SMSG_EXPLORATION_EXPERIENCE, 8 ); + WorldPacket data(SMSG_EXPLORATION_EXPERIENCE, 8); data << uint32(Area); data << uint32(Experience); GetSession()->SendPacket(&data); @@ -18318,8 +18330,8 @@ void Player::ResetInstances(InstanceResetMethod method, bool isRaid) for (BoundInstancesMap::iterator itr = m_boundInstances[diff].begin(); itr != m_boundInstances[diff].end();) { - DungeonPersistentState *state = itr->second.state; - const MapEntry *entry = sMapStore.LookupEntry(itr->first); + DungeonPersistentState* state = itr->second.state; + const MapEntry* entry = sMapStore.LookupEntry(itr->first); if (!entry || entry->IsRaid() != isRaid || !state->CanReset()) { ++itr; @@ -18337,7 +18349,7 @@ void Player::ResetInstances(InstanceResetMethod method, bool isRaid) } // if the map is loaded, reset it - if (Map *map = sMapMgr.FindMap(state->GetMapId(), state->GetInstanceId())) + if (Map* map = sMapMgr.FindMap(state->GetMapId(), state->GetInstanceId())) if (map->IsDungeon()) ((DungeonMap*)map)->Reset(method); @@ -18376,7 +18388,7 @@ void Player::SendResetInstanceFailed(uint32 reason, uint32 MapId) ///checks the 15 afk reports per 5 minutes limit void Player::UpdateAfkReport(time_t currTime) { - if(m_bgData.bgAfkReportedTimer <= currTime) + if (m_bgData.bgAfkReportedTimer <= currTime) { m_bgData.bgAfkReportedCount = 0; m_bgData.bgAfkReportedTimer = currTime+5*MINUTE; @@ -18385,9 +18397,9 @@ void Player::UpdateAfkReport(time_t currTime) void Player::UpdateContestedPvP(uint32 diff) { - if(!m_contestedPvPTimer||isInCombat()) + if (!m_contestedPvPTimer||isInCombat()) return; - if(m_contestedPvPTimer <= diff) + if (m_contestedPvPTimer <= diff) { ResetContestedPvP(); } @@ -18397,9 +18409,9 @@ void Player::UpdateContestedPvP(uint32 diff) void Player::UpdatePvPFlag(time_t currTime) { - if(!IsPvP()) + if (!IsPvP()) return; - if(pvpInfo.endTimer == 0 || currTime < (pvpInfo.endTimer + 300)) + if (pvpInfo.endTimer == 0 || currTime < (pvpInfo.endTimer + 300)) return; UpdatePvP(false); @@ -18407,7 +18419,7 @@ void Player::UpdatePvPFlag(time_t currTime) void Player::UpdateDuelFlag(time_t currTime) { - if(!duel || duel->startTimer == 0 ||currTime < duel->startTimer + 3) + if (!duel || duel->startTimer == 0 ||currTime < duel->startTimer + 3) return; SetUInt32Value(PLAYER_DUEL_TEAM, 1); @@ -18425,7 +18437,7 @@ void Player::RemovePet(PetSaveMode mode) pet->Unsummon(mode, this); } -void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const +void Player::BuildPlayerChat(WorldPacket* data, uint8 msgtype, const std::string& text, uint32 language) const { *data << uint8(msgtype); *data << uint32(language); @@ -18455,7 +18467,7 @@ void Player::TextEmote(const std::string& text) { WorldPacket data(SMSG_MESSAGECHAT, 200); BuildPlayerChat(&data, CHAT_MSG_EMOTE, text, LANG_UNIVERSAL); - SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_TEXTEMOTE),true, !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT) ); + SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_TEXTEMOTE),true, !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT)); } void Player::Whisper(const std::string& text, uint32 language, ObjectGuid receiver) @@ -18463,7 +18475,7 @@ void Player::Whisper(const std::string& text, uint32 language, ObjectGuid receiv if (language != LANG_ADDON) // if not addon data language = LANG_UNIVERSAL; // whispers should always be readable - Player *rPlayer = sObjectMgr.GetPlayer(receiver); + Player* rPlayer = sObjectMgr.GetPlayer(receiver); WorldPacket data(SMSG_MESSAGECHAT, 200); BuildPlayerChat(&data, CHAT_MSG_WHISPER, text, language); @@ -18494,12 +18506,12 @@ void Player::PetSpellInitialize() { Pet* pet = GetPet(); - if(!pet) + if (!pet) return; DEBUG_LOG("Pet Spells Groups"); - CharmInfo *charmInfo = pet->GetCharmInfo(); + CharmInfo* charmInfo = pet->GetCharmInfo(); WorldPacket data(SMSG_PET_SPELLS, 8+2+4+4+4*MAX_UNIT_ACTION_BAR_INDEX+1+1); data << pet->GetObjectGuid(); @@ -18521,7 +18533,7 @@ void Player::PetSpellInitialize() // spells loop for (PetSpellMap::const_iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr) { - if(itr->second.state == PETSPELL_REMOVED) + if (itr->second.state == PETSPELL_REMOVED) continue; data << uint32(MAKE_UNIT_ACTION_BUTTON(itr->first,itr->second.active)); @@ -18536,7 +18548,7 @@ void Player::PetSpellInitialize() time_t curTime = time(NULL); - for(CreatureSpellCooldowns::const_iterator itr = pet->m_CreatureSpellCooldowns.begin(); itr != pet->m_CreatureSpellCooldowns.end(); ++itr) + for (CreatureSpellCooldowns::const_iterator itr = pet->m_CreatureSpellCooldowns.begin(); itr != pet->m_CreatureSpellCooldowns.end(); ++itr) { time_t cooldown = (itr->second > curTime) ? (itr->second - curTime) * IN_MILLISECONDS : 0; @@ -18546,7 +18558,7 @@ void Player::PetSpellInitialize() data << uint32(0); // category cooldown } - for(CreatureSpellCooldowns::const_iterator itr = pet->m_CreatureCategoryCooldowns.begin(); itr != pet->m_CreatureCategoryCooldowns.end(); ++itr) + for (CreatureSpellCooldowns::const_iterator itr = pet->m_CreatureCategoryCooldowns.begin(); itr != pet->m_CreatureCategoryCooldowns.end(); ++itr) { time_t cooldown = (itr->second > curTime) ? (itr->second - curTime) * IN_MILLISECONDS : 0; @@ -18575,12 +18587,12 @@ void Player::PossessSpellInitialize() { Unit* charm = GetCharm(); - if(!charm) + if (!charm) return; - CharmInfo *charmInfo = charm->GetCharmInfo(); + CharmInfo* charmInfo = charm->GetCharmInfo(); - if(!charmInfo) + if (!charmInfo) { sLog.outError("Player::PossessSpellInitialize(): charm (GUID: %u TypeId: %u) has no charminfo!", charm->GetGUIDLow(),charm->GetTypeId()); return; @@ -18604,11 +18616,11 @@ void Player::CharmSpellInitialize() { Unit* charm = GetCharm(); - if(!charm) + if (!charm) return; - CharmInfo *charmInfo = charm->GetCharmInfo(); - if(!charmInfo) + CharmInfo* charmInfo = charm->GetCharmInfo(); + if (!charmInfo) { sLog.outError("Player::CharmSpellInitialize(): the player's charm (GUID: %u TypeId: %u) has no charminfo!", charm->GetGUIDLow(),charm->GetTypeId()); return; @@ -18616,15 +18628,15 @@ void Player::CharmSpellInitialize() uint8 addlist = 0; - if(charm->GetTypeId() != TYPEID_PLAYER) + if (charm->GetTypeId() != TYPEID_PLAYER) { - CreatureInfo const *cinfo = ((Creature*)charm)->GetCreatureInfo(); + CreatureInfo const* cinfo = ((Creature*)charm)->GetCreatureInfo(); - if(cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK) + if (cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK) { - for(uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) + for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) { - if(charmInfo->GetCharmSpell(i)->GetAction()) + if (charmInfo->GetCharmSpell(i)->GetAction()) ++addlist; } } @@ -18635,7 +18647,7 @@ void Player::CharmSpellInitialize() data << uint16(0); data << uint32(0); - if(charm->GetTypeId() != TYPEID_PLAYER) + if (charm->GetTypeId() != TYPEID_PLAYER) data << uint8(charmInfo->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0); else data << uint8(0) << uint8(0) << uint16(0); @@ -18644,12 +18656,12 @@ void Player::CharmSpellInitialize() data << uint8(addlist); - if(addlist) + if (addlist) { - for(uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) + for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) { - CharmSpellEntry *cspell = charmInfo->GetCharmSpell(i); - if(cspell->GetAction()) + CharmSpellEntry* cspell = charmInfo->GetCharmSpell(i); + if (cspell->GetAction()) data << uint32(cspell->packedData); } } @@ -18671,7 +18683,7 @@ void Player::AddSpellMod(Aura* aura, bool apply) Modifier const* mod = aura->GetModifier(); uint16 Opcode= (mod->m_auraname == SPELL_AURA_ADD_FLAT_MODIFIER) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER; - for(int eff = 0; eff < 96; ++eff) + for (int eff = 0; eff < 96; ++eff) { uint64 _mask = 0; uint32 _mask2= 0; @@ -18704,7 +18716,7 @@ void Player::AddSpellMod(Aura* aura, bool apply) m_spellMods[mod->m_miscvalue].remove(aura); } -template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell) +template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell const* spell) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) @@ -18714,7 +18726,7 @@ template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &bas int32 totalflat = 0; for (AuraList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr) { - Aura *aura = *itr; + Aura* aura = *itr; Modifier const* mod = aura->GetModifier(); @@ -18731,7 +18743,7 @@ template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &bas // special case (skip >10sec spell casts for instant cast setting) if (mod->m_miscvalue == SPELLMOD_CASTING_TIME - && basevalue >= T(10*IN_MILLISECONDS) && mod->m_amount <= -100) + && basevalue >= T(10*IN_MILLISECONDS) && mod->m_amount <= -100) continue; totalpct += mod->m_amount; @@ -18743,52 +18755,54 @@ template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &bas return T(diff); } -template int32 Player::ApplySpellMod(uint32 spellId, SpellModOp op, int32 &basevalue, Spell const* spell); -template uint32 Player::ApplySpellMod(uint32 spellId, SpellModOp op, uint32 &basevalue, Spell const* spell); -template float Player::ApplySpellMod(uint32 spellId, SpellModOp op, float &basevalue, Spell const* spell); +template int32 Player::ApplySpellMod(uint32 spellId, SpellModOp op, int32& basevalue, Spell const* spell); +template uint32 Player::ApplySpellMod(uint32 spellId, SpellModOp op, uint32& basevalue, Spell const* spell); +template float Player::ApplySpellMod(uint32 spellId, SpellModOp op, float& basevalue, Spell const* spell); // send Proficiency void Player::SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) { WorldPacket data(SMSG_SET_PROFICIENCY, 1 + 4); data << uint8(itemClass) << uint32(itemSubclassMask); - GetSession()->SendPacket (&data); + GetSession()->SendPacket(&data); } void Player::RemovePetitionsAndSigns(ObjectGuid guid, uint32 type) { uint32 lowguid = guid.GetCounter(); - QueryResult *result = NULL; - if(type == 10) + QueryResult* result = NULL; + if (type == 10) result = CharacterDatabase.PQuery("SELECT ownerguid,petitionguid FROM petition_sign WHERE playerguid = '%u'", lowguid); else result = CharacterDatabase.PQuery("SELECT ownerguid,petitionguid FROM petition_sign WHERE playerguid = '%u' AND type = '%u'", lowguid, type); - if(result) + if (result) { do // this part effectively does nothing, since the deletion / modification only takes place _after_ the PetitionQuery. Though I don't know if the result remains intact if I execute the delete query beforehand. - { // and SendPetitionQueryOpcode reads data from the DB - Field *fields = result->Fetch(); + { + // and SendPetitionQueryOpcode reads data from the DB + Field* fields = result->Fetch(); ObjectGuid ownerguid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()); ObjectGuid petitionguid = ObjectGuid(HIGHGUID_ITEM, fields[1].GetUInt32()); // send update if charter owner in game Player* owner = sObjectMgr.GetPlayer(ownerguid); - if(owner) + if (owner) owner->GetSession()->SendPetitionQueryOpcode(petitionguid); - } while ( result->NextRow() ); + } + while (result->NextRow()); delete result; - if(type==10) + if (type==10) CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u'", lowguid); else CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u' AND type = '%u'", lowguid, type); } CharacterDatabase.BeginTransaction(); - if(type == 10) + if (type == 10) { CharacterDatabase.PExecute("DELETE FROM petition WHERE ownerguid = '%u'", lowguid); CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE ownerguid = '%u'", lowguid); @@ -18804,34 +18818,35 @@ void Player::RemovePetitionsAndSigns(ObjectGuid guid, uint32 type) void Player::LeaveAllArenaTeams(ObjectGuid guid) { uint32 lowguid = guid.GetCounter(); - QueryResult *result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u'", lowguid); + QueryResult* result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u'", lowguid); if (!result) return; do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); if (uint32 at_id = fields[0].GetUInt32()) - if (ArenaTeam * at = sObjectMgr.GetArenaTeamById(at_id)) + if (ArenaTeam* at = sObjectMgr.GetArenaTeamById(at_id)) at->DelMember(guid); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } -void Player::SetRestBonus (float rest_bonus_new) +void Player::SetRestBonus(float rest_bonus_new) { // Prevent resting on max level - if(getLevel() >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) + if (getLevel() >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) rest_bonus_new = 0; - if(rest_bonus_new < 0) + if (rest_bonus_new < 0) rest_bonus_new = 0; float rest_bonus_max = (float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)*1.5f/2.0f; - if(rest_bonus_new > rest_bonus_max) + if (rest_bonus_new > rest_bonus_max) m_rest_bonus = rest_bonus_max; else m_rest_bonus = rest_bonus_new; @@ -18858,7 +18873,7 @@ void Player::HandleStealthedUnitsDetection() for (std::list::const_iterator i = stealthedUnits.begin(); i != stealthedUnits.end(); ++i) { - if((*i)==this) + if ((*i)==this) continue; bool hasAtClient = HaveAtClient((*i)); @@ -18866,7 +18881,7 @@ void Player::HandleStealthedUnitsDetection() if (hasDetected) { - if(!hasAtClient) + if (!hasAtClient) { ObjectGuid i_guid = (*i)->GetObjectGuid(); (*i)->SendCreateUpdateToPlayer(this); @@ -18876,13 +18891,13 @@ void Player::HandleStealthedUnitsDetection() // target aura duration for caster show only if target exist at caster client // send data at target visibility change (adding to client) - if((*i)!=this && (*i)->isType(TYPEMASK_UNIT)) + if ((*i)!=this && (*i)->isType(TYPEMASK_UNIT)) SendAurasForTarget(*i); } } else { - if(hasAtClient) + if (hasAtClient) { (*i)->DestroyForPlayer(this); m_clientGUIDs.erase((*i)->GetObjectGuid()); @@ -18893,11 +18908,11 @@ void Player::HandleStealthedUnitsDetection() bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc /*= NULL*/, uint32 spellid /*= 0*/) { - if(nodes.size() < 2) + if (nodes.size() < 2) return false; // not let cheating with start flight in time of logout process || if casting not finished || while in combat || if not use Spell's with EffectSendTaxi - if(GetSession()->isLogingOut() || isInCombat()) + if (GetSession()->isLogingOut() || isInCombat()) { WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); data << uint32(ERR_TAXIPLAYERBUSY); @@ -18905,7 +18920,7 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc return false; } - if(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE)) + if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE)) return false; // taximaster case @@ -18929,7 +18944,7 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc } // not let cheating with start flight in time of logout process || if casting not finished || while in combat || if not use Spell's with EffectSendTaxi - if(IsNonMeleeSpellCasted(false)) + if (IsNonMeleeSpellCasted(false)) { WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); data << uint32(ERR_TAXIPLAYERBUSY); @@ -18972,10 +18987,10 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc if (node->x != 0.0f || node->y != 0.0f || node->z != 0.0f) { if (node->map_id != GetMapId() || - (node->x - GetPositionX())*(node->x - GetPositionX())+ - (node->y - GetPositionY())*(node->y - GetPositionY())+ - (node->z - GetPositionZ())*(node->z - GetPositionZ()) > - (2*INTERACTION_DISTANCE)*(2*INTERACTION_DISTANCE)*(2*INTERACTION_DISTANCE)) + (node->x - GetPositionX())*(node->x - GetPositionX())+ + (node->y - GetPositionY())*(node->y - GetPositionY())+ + (node->z - GetPositionZ())*(node->z - GetPositionZ()) > + (2*INTERACTION_DISTANCE)*(2*INTERACTION_DISTANCE)*(2*INTERACTION_DISTANCE)) { WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); data << uint32(ERR_TAXITOOFARAWAY); @@ -19013,14 +19028,14 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc uint32 prevnode = sourcenode; uint32 lastnode = 0; - for(uint32 i = 1; i < nodes.size(); ++i) + for (uint32 i = 1; i < nodes.size(); ++i) { uint32 path, cost; lastnode = nodes[i]; sObjectMgr.GetTaxiPath(prevnode, lastnode, path, cost); - if(!path) + if (!path) { m_taxi.ClearTaxiDestinations(); return false; @@ -19028,7 +19043,7 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc totalcost += cost; - if(prevnode == sourcenode) + if (prevnode == sourcenode) sourcepath = path; m_taxi.AddTaxiDestination(lastnode); @@ -19054,7 +19069,7 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc if (npc) totalcost = (uint32)ceil(totalcost*GetReputationPriceDiscount(npc)); - if(money < totalcost) + if (money < totalcost) { WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); data << uint32(ERR_TAXINOTENOUGHMONEY); @@ -19082,10 +19097,10 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc return true; } -bool Player::ActivateTaxiPathTo( uint32 taxi_path_id, uint32 spellid /*= 0*/ ) +bool Player::ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid /*= 0*/) { TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(taxi_path_id); - if(!entry) + if (!entry) return false; std::vector nodes; @@ -19103,7 +19118,7 @@ void Player::ContinueTaxiFlight() if (!sourceNode) return; - DEBUG_LOG( "WORLD: Restart character %u taxi flight", GetGUIDLow() ); + DEBUG_LOG("WORLD: Restart character %u taxi flight", GetGUIDLow()); uint32 mountDisplayId = sObjectMgr.GetTaxiMountDisplayId(sourceNode, GetTeam(), true); uint32 path = m_taxi.GetCurrentTaxiPath(); @@ -19119,7 +19134,7 @@ void Player::ContinueTaxiFlight() (nodeList[0].y-GetPositionY())*(nodeList[0].y-GetPositionY())+ (nodeList[0].z-GetPositionZ())*(nodeList[0].z-GetPositionZ()); - for(uint32 i = 1; i < nodeList.size(); ++i) + for (uint32 i = 1; i < nodeList.size(); ++i) { TaxiPathNodeEntry const& node = nodeList[i]; TaxiPathNodeEntry const& prevNode = nodeList[i-1]; @@ -19150,19 +19165,19 @@ void Player::ContinueTaxiFlight() GetSession()->SendDoFlight(mountDisplayId, path, startNode); } -void Player::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs ) +void Player::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) { - // last check 2.0.10 + // last check 2.0.10 WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+m_spells.size()*8); data << GetObjectGuid(); data << uint8(0x0); // flags (0x1, 0x2) time_t curTime = time(NULL); - for(PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) + for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) { if (itr->second.state == PLAYERSPELL_REMOVED) continue; uint32 unSpellId = itr->first; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(unSpellId); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(unSpellId); if (!spellInfo) { MANGOS_ASSERT(spellInfo); @@ -19173,7 +19188,7 @@ void Player::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs ) if (spellInfo->HasAttribute(SPELL_ATTR_DISABLED_WHILE_ACTIVE)) continue; - if((idSchoolMask & GetSpellSchoolMask(spellInfo)) && GetSpellCooldownDelay(unSpellId) < unTimeMs ) + if ((idSchoolMask & GetSpellSchoolMask(spellInfo)) && GetSpellCooldownDelay(unSpellId) < unTimeMs) { data << uint32(unSpellId); data << uint32(unTimeMs); // in m.secs @@ -19188,7 +19203,7 @@ void Player::InitDataForForm(bool reapplyMods) ShapeshiftForm form = GetShapeshiftForm(); SpellShapeshiftFormEntry const* ssEntry = sSpellShapeshiftFormStore.LookupEntry(form); - if(ssEntry && ssEntry->attackSpeed) + if (ssEntry && ssEntry->attackSpeed) { SetAttackTime(BASE_ATTACK,ssEntry->attackSpeed); SetAttackTime(OFF_ATTACK,ssEntry->attackSpeed); @@ -19197,25 +19212,25 @@ void Player::InitDataForForm(bool reapplyMods) else SetRegularAttackTime(); - switch(form) + switch (form) { case FORM_CAT: { - if(getPowerType()!=POWER_ENERGY) + if (getPowerType()!=POWER_ENERGY) setPowerType(POWER_ENERGY); break; } case FORM_BEAR: case FORM_DIREBEAR: { - if(getPowerType()!=POWER_RAGE) + if (getPowerType()!=POWER_RAGE) setPowerType(POWER_RAGE); break; } default: // 0, for example { ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(getClass()); - if(cEntry && cEntry->powerType < MAX_POWERS && uint32(getPowerType()) != cEntry->powerType) + if (cEntry && cEntry->powerType < MAX_POWERS && uint32(getPowerType()) != cEntry->powerType) setPowerType(Powers(cEntry->powerType)); break; } @@ -19231,8 +19246,8 @@ void Player::InitDataForForm(bool reapplyMods) void Player::InitDisplayIds() { - PlayerInfo const *info = sObjectMgr.GetPlayerInfo(getRace(), getClass()); - if(!info) + PlayerInfo const* info = sObjectMgr.GetPlayerInfo(getRace(), getClass()); + if (!info) { sLog.outError("Player %u has incorrect race/class pair. Can't init display ids.", GetGUIDLow()); return; @@ -19242,15 +19257,15 @@ void Player::InitDisplayIds() SetObjectScale(DEFAULT_OBJECT_SCALE); uint8 gender = getGender(); - switch(gender) + switch (gender) { case GENDER_FEMALE: - SetDisplayId(info->displayId_f ); - SetNativeDisplayId(info->displayId_f ); + SetDisplayId(info->displayId_f); + SetNativeDisplayId(info->displayId_f); break; case GENDER_MALE: - SetDisplayId(info->displayId_m ); - SetNativeDisplayId(info->displayId_m ); + SetDisplayId(info->displayId_m); + SetNativeDisplayId(info->displayId_m); break; default: sLog.outError("Invalid gender %u for player",gender); @@ -19283,14 +19298,14 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin if (!isAlive()) return false; - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item); + ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item); if (!pProto) { SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, item, 0); return false; } - Creature *pCreature = GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR); + Creature* pCreature = GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR); if (!pCreature) { DEBUG_LOG("WORLD: BuyItemFromVendor - %s not found or you can't interact with him.", vendorGuid.GetString().c_str()); @@ -19329,7 +19344,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin // possible item converted for BoA case ItemPrototype const* crProto = ObjectMgr::GetItemPrototype(crItem->item); if (crProto->Flags & ITEM_FLAG_BOA && crProto->RequiredReputationFaction && - uint32(GetReputationRank(crProto->RequiredReputationFaction)) >= crProto->RequiredReputationRank) + uint32(GetReputationRank(crProto->RequiredReputationFaction)) >= crProto->RequiredReputationRank) converted = (sObjectMgr.GetItemConvert(crItem->item, getRaceMask()) != 0); if (!converted) @@ -19485,14 +19500,14 @@ uint32 Player::GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot) // the personal rating of the arena team must match the required limit as well // so return max[in arenateams](min(personalrating[teamtype], teamrating[teamtype])) uint32 max_personal_rating = 0; - for(int i = minarenaslot; i < MAX_ARENA_SLOT; ++i) + for (int i = minarenaslot; i < MAX_ARENA_SLOT; ++i) { - if(ArenaTeam * at = sObjectMgr.GetArenaTeamById(GetArenaTeamId(i))) + if (ArenaTeam* at = sObjectMgr.GetArenaTeamById(GetArenaTeamId(i))) { uint32 p_rating = GetArenaPersonalRating(i); uint32 t_rating = at->GetRating(); p_rating = p_rating < t_rating ? p_rating : t_rating; - if(max_personal_rating < p_rating) + if (max_personal_rating < p_rating) max_personal_rating = p_rating; } } @@ -19504,7 +19519,7 @@ void Player::UpdateHomebindTime(uint32 time) // GMs never get homebind timer online if (m_InstanceValid || isGameMaster()) { - if(m_HomebindTimer) // instance valid, but timer not reset + if (m_HomebindTimer) // instance valid, but timer not reset { // hide reminder WorldPacket data(SMSG_RAID_GROUP_ONLY, 4+4); @@ -19540,14 +19555,14 @@ void Player::UpdateHomebindTime(uint32 time) void Player::UpdatePvP(bool state, bool ovrride) { - if(!state || ovrride) + if (!state || ovrride) { SetPvP(state); pvpInfo.endTimer = 0; } else { - if(pvpInfo.endTimer != 0) + if (pvpInfo.endTimer != 0) pvpInfo.endTimer = time(NULL); else SetPvP(state); @@ -19569,7 +19584,7 @@ void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 it { if (ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemId)) { - for(int idx = 0; idx < MAX_ITEM_PROTO_SPELLS; ++idx) + for (int idx = 0; idx < MAX_ITEM_PROTO_SPELLS; ++idx) { if (proto->Spells[idx].SpellId == spellInfo->Id) { @@ -19639,7 +19654,7 @@ void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 it SpellCategoryStore::const_iterator i_scstore = sSpellCategoryStore.find(cat); if (i_scstore != sSpellCategoryStore.end()) { - for(SpellCategorySet::const_iterator i_scset = i_scstore->second.begin(); i_scset != i_scstore->second.end(); ++i_scset) + for (SpellCategorySet::const_iterator i_scset = i_scstore->second.begin(); i_scset != i_scstore->second.end(); ++i_scset) { if (*i_scset == spellInfo->Id) // skip main spell, already handled above continue; @@ -19658,7 +19673,7 @@ void Player::AddSpellCooldown(uint32 spellid, uint32 itemid, time_t end_time) m_spellCooldowns[spellid] = sc; } -void Player::SendCooldownEvent(SpellEntry const *spellInfo, uint32 itemId, Spell* spell) +void Player::SendCooldownEvent(SpellEntry const* spellInfo, uint32 itemId, Spell* spell) { // start cooldowns at server side, if any AddSpellAndCategoryCooldowns(spellInfo, itemId, spell); @@ -19673,17 +19688,17 @@ void Player::SendCooldownEvent(SpellEntry const *spellInfo, uint32 itemId, Spell void Player::UpdatePotionCooldown(Spell* spell) { // no potion used in combat or still in combat - if(!m_lastPotionId || isInCombat()) + if (!m_lastPotionId || isInCombat()) return; // Call not from spell cast, send cooldown event for item spells if no in combat - if(!spell) + if (!spell) { // spell/item pair let set proper cooldown (except nonexistent charged spell cooldown spellmods for potions) - if(ItemPrototype const* proto = ObjectMgr::GetItemPrototype(m_lastPotionId)) - for(int idx = 0; idx < 5; ++idx) - if(proto->Spells[idx].SpellId && proto->Spells[idx].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE) - if(SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[idx].SpellId)) + if (ItemPrototype const* proto = ObjectMgr::GetItemPrototype(m_lastPotionId)) + for (int idx = 0; idx < 5; ++idx) + if (proto->Spells[idx].SpellId && proto->Spells[idx].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE) + if (SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[idx].SpellId)) SendCooldownEvent(spellInfo,m_lastPotionId); } // from spell cases (m_lastPotionId set in Spell::SendSpellCooldown) @@ -19693,54 +19708,54 @@ void Player::UpdatePotionCooldown(Spell* spell) m_lastPotionId = 0; } - //slot to be excluded while counting +//slot to be excluded while counting bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) { - if(!enchantmentcondition) + if (!enchantmentcondition) return true; - SpellItemEnchantmentConditionEntry const *Condition = sSpellItemEnchantmentConditionStore.LookupEntry(enchantmentcondition); + SpellItemEnchantmentConditionEntry const* Condition = sSpellItemEnchantmentConditionStore.LookupEntry(enchantmentcondition); - if(!Condition) + if (!Condition) return true; uint8 curcount[4] = {0, 0, 0, 0}; //counting current equipped gem colors - for(uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) + for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) { - if(i == slot) + if (i == slot) continue; - Item *pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if(pItem2 && !pItem2->IsBroken() && pItem2->GetProto()->Socket[0].Color) + Item* pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem2 && !pItem2->IsBroken() && pItem2->GetProto()->Socket[0].Color) { - for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) { uint32 enchant_id = pItem2->GetEnchantmentId(EnchantmentSlot(enchant_slot)); - if(!enchant_id) + if (!enchant_id) continue; SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!enchantEntry) + if (!enchantEntry) continue; uint32 gemid = enchantEntry->GemID; - if(!gemid) + if (!gemid) continue; ItemPrototype const* gemProto = sItemStorage.LookupEntry(gemid); - if(!gemProto) + if (!gemProto) continue; GemPropertiesEntry const* gemProperty = sGemPropertiesStore.LookupEntry(gemProto->GemProperties); - if(!gemProperty) + if (!gemProperty) continue; uint8 GemColor = gemProperty->color; - for(uint8 b = 0, tmpcolormask = 1; b < 4; b++, tmpcolormask <<= 1) + for (uint8 b = 0, tmpcolormask = 1; b < 4; b++, tmpcolormask <<= 1) { - if(tmpcolormask & GemColor) + if (tmpcolormask & GemColor) ++curcount[b]; } } @@ -19749,9 +19764,9 @@ bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) bool activate = true; - for(int i = 0; i < 5; ++i) + for (int i = 0; i < 5; ++i) { - if(!Condition->Color[i]) + if (!Condition->Color[i]) continue; uint32 _cur_gem = curcount[Condition->Color[i] - 1]; @@ -19759,7 +19774,7 @@ bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) // if have use them as count, else use from Condition uint32 _cmp_gem = Condition->CompareColor[i] ? curcount[Condition->CompareColor[i] - 1]: Condition->Value[i]; - switch(Condition->Comparator[i]) + switch (Condition->Comparator[i]) { case 2: // requires less than ( || ) gems activate &= (_cur_gem < _cmp_gem) ? true : false; @@ -19780,38 +19795,38 @@ bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) void Player::CorrectMetaGemEnchants(uint8 exceptslot, bool apply) { - //cycle all equipped items - for(uint32 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) + //cycle all equipped items + for (uint32 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) { //enchants for the slot being socketed are handled by Player::ApplyItemMods - if(slot == exceptslot) + if (slot == exceptslot) continue; - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, slot ); + Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if(!pItem || !pItem->GetProto()->Socket[0].Color) + if (!pItem || !pItem->GetProto()->Socket[0].Color) continue; - for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) { uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); - if(!enchant_id) + if (!enchant_id) continue; SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!enchantEntry) + if (!enchantEntry) continue; uint32 condition = enchantEntry->EnchantmentCondition; - if(condition) + if (condition) { - //was enchant active with/without item? + //was enchant active with/without item? bool wasactive = EnchantmentFitsRequirements(condition, apply ? exceptslot : -1); - //should it now be? - if(wasactive != EnchantmentFitsRequirements(condition, apply ? -1 : exceptslot)) + //should it now be? + if (wasactive != EnchantmentFitsRequirements(condition, apply ? -1 : exceptslot)) { // ignore item gem conditions - //if state changed, (dis)apply enchant + //if state changed, (dis)apply enchant ApplyEnchantment(pItem, EnchantmentSlot(enchant_slot), !wasactive, true, true); } } @@ -19819,35 +19834,35 @@ void Player::CorrectMetaGemEnchants(uint8 exceptslot, bool apply) } } - //if false -> then toggled off if was on| if true -> toggled on if was off AND meets requirements +//if false -> then toggled off if was on| if true -> toggled on if was off AND meets requirements void Player::ToggleMetaGemsActive(uint8 exceptslot, bool apply) { //cycle all equipped items - for(int slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) + for (int slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) { //enchants for the slot being socketed are handled by WorldSession::HandleSocketOpcode(WorldPacket& recv_data) - if(slot == exceptslot) + if (slot == exceptslot) continue; - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, slot ); + Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if(!pItem || !pItem->GetProto()->Socket[0].Color) //if item has no sockets or no item is equipped go to next item + if (!pItem || !pItem->GetProto()->Socket[0].Color) //if item has no sockets or no item is equipped go to next item continue; //cycle all (gem)enchants - for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) { uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); - if(!enchant_id) //if no enchant go to next enchant(slot) + if (!enchant_id) //if no enchant go to next enchant(slot) continue; SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!enchantEntry) + if (!enchantEntry) continue; //only metagems to be (de)activated, so only enchants with condition uint32 condition = enchantEntry->EnchantmentCondition; - if(condition) + if (condition) ApplyEnchantment(pItem,EnchantmentSlot(enchant_slot), apply); } } @@ -19882,7 +19897,7 @@ void Player::SetBattleGroundEntryPoint() m_bgData.mountSpell = 0; // If map is dungeon find linked graveyard - if(GetMap()->IsDungeon()) + if (GetMap()->IsDungeon()) { if (const WorldSafeLocsEntry* entry = sObjectMgr.GetClosestGraveYard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeam())) { @@ -19909,17 +19924,17 @@ void Player::SetBattleGroundEntryPoint() void Player::LeaveBattleground(bool teleportToEntryPoint) { - if(BattleGround *bg = GetBattleGround()) + if (BattleGround* bg = GetBattleGround()) { bg->RemovePlayerAtLeave(GetObjectGuid(), teleportToEntryPoint, true); // call after remove to be sure that player resurrected for correct cast - if( bg->isBattleGround() && !isGameMaster() && sWorld.getConfig(CONFIG_BOOL_BATTLEGROUND_CAST_DESERTER) ) + if (bg->isBattleGround() && !isGameMaster() && sWorld.getConfig(CONFIG_BOOL_BATTLEGROUND_CAST_DESERTER)) { - if( bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN ) + if (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN) { //lets check if player was teleported from BG and schedule delayed Deserter spell cast - if(IsBeingTeleportedFar()) + if (IsBeingTeleportedFar()) { ScheduleDelayedOperation(DELAYED_SPELL_CAST_DESERTER); return; @@ -19934,7 +19949,7 @@ void Player::LeaveBattleground(bool teleportToEntryPoint) bool Player::CanJoinToBattleground() const { // check Deserter debuff - if(GetDummyAura(26013)) + if (GetDummyAura(26013)) return false; return true; @@ -19943,7 +19958,7 @@ bool Player::CanJoinToBattleground() const bool Player::CanReportAfkDueToLimit() { // a player can complain about 15 people per 5 minutes - if(m_bgData.bgAfkReportedCount++ >= 15) + if (m_bgData.bgAfkReportedCount++ >= 15) return false; return true; @@ -19952,16 +19967,16 @@ bool Player::CanReportAfkDueToLimit() ///This player has been blamed to be inactive in a battleground void Player::ReportedAfkBy(Player* reporter) { - BattleGround *bg = GetBattleGround(); - if(!bg || bg != reporter->GetBattleGround() || GetTeam() != reporter->GetTeam()) + BattleGround* bg = GetBattleGround(); + if (!bg || bg != reporter->GetBattleGround() || GetTeam() != reporter->GetTeam()) return; // check if player has 'Idle' or 'Inactive' debuff - if(m_bgData.bgAfkReporter.find(reporter->GetGUIDLow()) == m_bgData.bgAfkReporter.end() && !HasAura(43680, EFFECT_INDEX_0) && !HasAura(43681, EFFECT_INDEX_0) && reporter->CanReportAfkDueToLimit()) + if (m_bgData.bgAfkReporter.find(reporter->GetGUIDLow()) == m_bgData.bgAfkReporter.end() && !HasAura(43680, EFFECT_INDEX_0) && !HasAura(43681, EFFECT_INDEX_0) && reporter->CanReportAfkDueToLimit()) { m_bgData.bgAfkReporter.insert(reporter->GetGUIDLow()); // 3 players have to complain to apply debuff - if(m_bgData.bgAfkReporter.size() >= 3) + if (m_bgData.bgAfkReporter.size() >= 3) { // cast 'Idle' spell CastSpell(this, 43680, true); @@ -19970,7 +19985,7 @@ void Player::ReportedAfkBy(Player* reporter) } } -bool Player::IsVisibleInGridForPlayer( Player* pl ) const +bool Player::IsVisibleInGridForPlayer(Player* pl) const { // gamemaster in GM mode see all, including ghosts if (pl->isGameMaster() && GetSession()->GetSecurity() <= pl->GetSession()->GetSecurity()) @@ -19991,7 +20006,7 @@ bool Player::IsVisibleInGridForPlayer( Player* pl ) const // Dead player see live players near own corpse if (isAlive()) { - if (Corpse *corpse = pl->GetCorpse()) + if (Corpse* corpse = pl->GetCorpse()) { // 20 - aggro distance for same level, 25 - max additional distance if player level less that creature level if (corpse->IsWithinDistInMap(this, (20 + 25) * sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO))) @@ -20003,7 +20018,7 @@ bool Player::IsVisibleInGridForPlayer( Player* pl ) const return false; } -bool Player::IsVisibleGloballyFor( Player* u ) const +bool Player::IsVisibleGloballyFor(Player* u) const { if (!u) return false; @@ -20042,9 +20057,9 @@ inline void BeforeVisibilityDestroy(Creature* t, Player* p) void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* target) { - if(HaveAtClient(target)) + if (HaveAtClient(target)) { - if(!target->isVisibleForInState(this, viewPoint, true)) + if (!target->isVisibleForInState(this, viewPoint, true)) { ObjectGuid t_guid = target->GetObjectGuid(); @@ -20065,17 +20080,17 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe } else { - if(target->isVisibleForInState(this, viewPoint, false)) + if (target->isVisibleForInState(this, viewPoint, false)) { target->SendCreateUpdateToPlayer(this); - if(target->GetTypeId()!=TYPEID_GAMEOBJECT||!((GameObject*)target)->IsTransport()) + if (target->GetTypeId()!=TYPEID_GAMEOBJECT||!((GameObject*)target)->IsTransport()) m_clientGUIDs.insert(target->GetObjectGuid()); DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "Object %u (Type: %u) is visible now for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),GetGUIDLow(),GetDistance(target)); // target aura duration for caster show only if target exist at caster client // send data at target visibility change (adding to client) - if(target!=this && target->isType(TYPEMASK_UNIT)) + if (target!=this && target->isType(TYPEMASK_UNIT)) SendAurasForTarget((Unit*)target); } } @@ -20090,16 +20105,16 @@ inline void UpdateVisibilityOf_helper(GuidSet& s64, T* target) template<> inline void UpdateVisibilityOf_helper(GuidSet& s64, GameObject* target) { - if(!target->IsTransport()) + if (!target->IsTransport()) s64.insert(target->GetObjectGuid()); } template void Player::UpdateVisibilityOf(WorldObject const* viewPoint, T* target, UpdateData& data, std::set& visibleNow) { - if(HaveAtClient(target)) + if (HaveAtClient(target)) { - if(!target->isVisibleForInState(this,viewPoint,true)) + if (!target->isVisibleForInState(this,viewPoint,true)) { BeforeVisibilityDestroy(target,this); @@ -20113,7 +20128,7 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, T* target, UpdateD } else { - if(target->isVisibleForInState(this,viewPoint,false)) + if (target->isVisibleForInState(this,viewPoint,false)) { visibleNow.insert(target); target->BuildCreateUpdateBlockForPlayer(&data, this); @@ -20137,7 +20152,7 @@ void Player::SetPhaseMask(uint32 newPhaseMask, bool update) newPhaseMask = PHASEMASK_ANYWHERE; // phase auras normally not expected at BG but anyway better check - if (BattleGround *bg = GetBattleGround()) + if (BattleGround* bg = GetBattleGround()) bg->EventPlayerDroppedFlag(this); Unit::SetPhaseMask(newPhaseMask, update); @@ -20147,13 +20162,13 @@ void Player::SetPhaseMask(uint32 newPhaseMask, bool update) void Player::InitPrimaryProfessions() { uint32 maxProfs = GetSession()->GetSecurity() < AccountTypes(sWorld.getConfig(CONFIG_UINT32_TRADE_SKILL_GMIGNORE_MAX_PRIMARY_COUNT)) - ? sWorld.getConfig(CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL) : 10; + ? sWorld.getConfig(CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL) : 10; SetFreePrimaryProfessions(maxProfs); } void Player::SendComboPoints() { - Unit *combotarget = ObjectAccessor::GetUnit(*this, m_comboTargetGuid); + Unit* combotarget = ObjectAccessor::GetUnit(*this, m_comboTargetGuid); if (combotarget) { WorldPacket data(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size()+1); @@ -20172,20 +20187,20 @@ void Player::SendComboPoints() void Player::AddComboPoints(Unit* target, int8 count) { - if(!count) + if (!count) return; // without combo points lost (duration checked in aura) RemoveSpellsCausingAura(SPELL_AURA_RETAIN_COMBO_POINTS); - if(target->GetObjectGuid() == m_comboTargetGuid) + if (target->GetObjectGuid() == m_comboTargetGuid) { m_comboPoints += count; } else { if (m_comboTargetGuid) - if(Unit* target2 = ObjectAccessor::GetUnit(*this, m_comboTargetGuid)) + if (Unit* target2 = ObjectAccessor::GetUnit(*this, m_comboTargetGuid)) target2->RemoveComboPointHolder(GetGUIDLow()); m_comboTargetGuid = target->GetObjectGuid(); @@ -20212,15 +20227,15 @@ void Player::ClearComboPoints() SendComboPoints(); - if(Unit* target = ObjectAccessor::GetUnit(*this,m_comboTargetGuid)) + if (Unit* target = ObjectAccessor::GetUnit(*this,m_comboTargetGuid)) target->RemoveComboPointHolder(GetGUIDLow()); m_comboTargetGuid.Clear(); } -void Player::SetGroup(Group *group, int8 subgroup) +void Player::SetGroup(Group* group, int8 subgroup) { - if(group == NULL) + if (group == NULL) m_group.unlink(); else { @@ -20262,7 +20277,7 @@ void Player::SendInitialPacketsBeforeAddToMap() SendInitialActionButtons(); m_reputationMgr.SendInitialReputations(); - if(!isAlive()) + if (!isAlive()) SendCorpseReclaimDelay(true); SendInitWorldStates(GetZoneId(), GetAreaId()); @@ -20275,7 +20290,7 @@ void Player::SendInitialPacketsBeforeAddToMap() data << uint32(secsToTimeBitFields(sWorld.GetGameTime())); data << (float)0.01666667f; // game speed data << uint32(0); // added in 3.1.2 - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); // SMSG_TALENTS_INFO x 2 for pet (unspent points and talents in separate packets...) // SMSG_PET_GUIDS @@ -20309,18 +20324,18 @@ void Player::SendInitialPacketsAfterAddToMap() SPELL_AURA_FEATHER_FALL, SPELL_AURA_HOVER, SPELL_AURA_SAFE_FALL, SPELL_AURA_FLY, SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED, SPELL_AURA_NONE }; - for(AuraType const* itr = &auratypes[0]; itr && itr[0] != SPELL_AURA_NONE; ++itr) + for (AuraType const* itr = &auratypes[0]; itr && itr[0] != SPELL_AURA_NONE; ++itr) { Unit::AuraList const& auraList = GetAurasByType(*itr); - if(!auraList.empty()) + if (!auraList.empty()) auraList.front()->ApplyModifier(true,true); } - if(HasAuraType(SPELL_AURA_MOD_STUN)) + if (HasAuraType(SPELL_AURA_MOD_STUN)) SetMovement(MOVE_ROOT); // manual send package (have code in ApplyModifier(true,true); that don't must be re-applied. - if(HasAuraType(SPELL_AURA_MOD_ROOT)) + if (HasAuraType(SPELL_AURA_MOD_ROOT)) { WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10); data2 << GetPackGUID(); @@ -20337,12 +20352,12 @@ void Player::SendUpdateToOutOfRangeGroupMembers() { if (m_groupUpdateMask == GROUP_UPDATE_FLAG_NONE) return; - if(Group* group = GetGroup()) + if (Group* group = GetGroup()) group->UpdatePlayerOutOfRange(this); m_groupUpdateMask = GROUP_UPDATE_FLAG_NONE; m_auraUpdateMask = 0; - if(Pet *pet = GetPet()) + if (Pet* pet = GetPet()) pet->ResetAuraUpdateMask(); } @@ -20351,7 +20366,7 @@ void Player::SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg) WorldPacket data(SMSG_TRANSFER_ABORTED, 4+2); data << uint32(mapid); data << uint8(reason); // transfer abort reason - switch(reason) + switch (reason) { case TRANSFER_ABORT_INSUF_EXPAN_LVL: case TRANSFER_ABORT_DIFFICULTY: @@ -20362,15 +20377,15 @@ void Player::SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg) GetSession()->SendPacket(&data); } -void Player::SendInstanceResetWarning( uint32 mapid, Difficulty difficulty, uint32 time ) +void Player::SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time) { // type of warning, based on the time remaining until reset uint32 type; - if(time > 3600) + if (time > 3600) type = RAID_INSTANCE_WELCOME; - else if(time > 900 && time <= 3600) + else if (time > 900 && time <= 3600) type = RAID_INSTANCE_WARNING_HOURS; - else if(time > 300 && time <= 900) + else if (time > 300 && time <= 900) type = RAID_INSTANCE_WARNING_MIN; else type = RAID_INSTANCE_WARNING_MIN_SOON; @@ -20380,7 +20395,7 @@ void Player::SendInstanceResetWarning( uint32 mapid, Difficulty difficulty, uint data << uint32(mapid); data << uint32(difficulty); // difficulty data << uint32(time); - if(type == RAID_INSTANCE_WELCOME) + if (type == RAID_INSTANCE_WELCOME) { data << uint8(0); // is your (1) data << uint8(0); // is extended (1), ignored if prev field is 0 @@ -20388,21 +20403,21 @@ void Player::SendInstanceResetWarning( uint32 mapid, Difficulty difficulty, uint GetSession()->SendPacket(&data); } -void Player::ApplyEquipCooldown( Item * pItem ) +void Player::ApplyEquipCooldown(Item* pItem) { if (pItem->GetProto()->Flags & ITEM_FLAG_NO_EQUIP_COOLDOWN) return; - for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) + for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { _Spell const& spellData = pItem->GetProto()->Spells[i]; // no spell - if( !spellData.SpellId ) + if (!spellData.SpellId) continue; // wrong triggering type (note: ITEM_SPELLTRIGGER_ON_NO_DELAY_USE not have cooldown) - if( spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_USE ) + if (spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) continue; AddSpellCooldown(spellData.SpellId, pItem->GetEntry(), time(NULL) + 30); @@ -20417,14 +20432,14 @@ void Player::ApplyEquipCooldown( Item * pItem ) void Player::resetSpells() { // not need after this call - if(HasAtLoginFlag(AT_LOGIN_RESET_SPELLS)) + if (HasAtLoginFlag(AT_LOGIN_RESET_SPELLS)) RemoveAtLoginFlag(AT_LOGIN_RESET_SPELLS,true); // make full copy of map (spells removed and marked as deleted at another spell remove // and we can't use original map for safe iterative with visit each spell at loop end PlayerSpellMap smap = GetSpellMap(); - for(PlayerSpellMap::const_iterator iter = smap.begin();iter != smap.end(); ++iter) + for (PlayerSpellMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter) removeSpell(iter->first,false,false); // only iter->first can be accessed, object by iter->second can be deleted already learnDefaultSpells(); @@ -20434,12 +20449,12 @@ void Player::resetSpells() void Player::learnDefaultSpells() { // learn default race/class spells - PlayerInfo const *info = sObjectMgr.GetPlayerInfo(getRace(),getClass()); + PlayerInfo const* info = sObjectMgr.GetPlayerInfo(getRace(),getClass()); for (PlayerCreateInfoSpells::const_iterator itr = info->spell.begin(); itr!=info->spell.end(); ++itr) { uint32 tspell = *itr; DEBUG_LOG("PLAYER (Class: %u Race: %u): Adding initial spell, id = %u",uint32(getClass()),uint32(getRace()), tspell); - if(!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add + if (!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add addSpell(tspell, true, true, true, false); else // but send in normal spell in game learn case learnSpell(tspell, true); @@ -20451,18 +20466,18 @@ void Player::learnQuestRewardedSpells(Quest const* quest) uint32 spell_id = quest->GetRewSpellCast(); // skip quests without rewarded spell - if( !spell_id ) + if (!spell_id) return; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); - if(!spellInfo) + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); + if (!spellInfo) return; // check learned spells state bool found = false; - for(int i=0; i < MAX_EFFECT_INDEX; ++i) + for (int i=0; i < MAX_EFFECT_INDEX; ++i) { - if(spellInfo->Effect[i] == SPELL_EFFECT_LEARN_SPELL && !HasSpell(spellInfo->EffectTriggerSpell[i])) + if (spellInfo->Effect[i] == SPELL_EFFECT_LEARN_SPELL && !HasSpell(spellInfo->EffectTriggerSpell[i])) { found = true; break; @@ -20470,33 +20485,33 @@ void Player::learnQuestRewardedSpells(Quest const* quest) } // skip quests with not teaching spell or already known spell - if(!found) + if (!found) return; // prevent learn non first rank unknown profession and second specialization for same profession) uint32 learned_0 = spellInfo->EffectTriggerSpell[EFFECT_INDEX_0]; - if( sSpellMgr.GetSpellRank(learned_0) > 1 && !HasSpell(learned_0) ) + if (sSpellMgr.GetSpellRank(learned_0) > 1 && !HasSpell(learned_0)) { // not have first rank learned (unlearned prof?) uint32 first_spell = sSpellMgr.GetFirstSpellInChain(learned_0); - if( !HasSpell(first_spell) ) + if (!HasSpell(first_spell)) return; - SpellEntry const *learnedInfo = sSpellStore.LookupEntry(learned_0); - if(!learnedInfo) + SpellEntry const* learnedInfo = sSpellStore.LookupEntry(learned_0); + if (!learnedInfo) return; // specialization if (learnedInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_TRADE_SKILL && learnedInfo->Effect[EFFECT_INDEX_1] == 0) { // search other specialization for same prof - for(PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) + for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) { - if(itr->second.state == PLAYERSPELL_REMOVED || itr->first==learned_0) + if (itr->second.state == PLAYERSPELL_REMOVED || itr->first==learned_0) continue; - SpellEntry const *itrInfo = sSpellStore.LookupEntry(itr->first); - if(!itrInfo) + SpellEntry const* itrInfo = sSpellStore.LookupEntry(itr->first); + if (!itrInfo) return; // compare only specializations @@ -20504,43 +20519,43 @@ void Player::learnQuestRewardedSpells(Quest const* quest) continue; // compare same chain spells - if(sSpellMgr.GetFirstSpellInChain(itr->first) != first_spell) + if (sSpellMgr.GetFirstSpellInChain(itr->first) != first_spell) continue; // now we have 2 specialization, learn possible only if found is lesser specialization rank - if(!sSpellMgr.IsHighRankOfSpell(learned_0,itr->first)) + if (!sSpellMgr.IsHighRankOfSpell(learned_0,itr->first)) return; } } } - CastSpell( this, spell_id, true); + CastSpell(this, spell_id, true); } void Player::learnQuestRewardedSpells() { // learn spells received from quest completing - for(QuestStatusMap::const_iterator itr = mQuestStatus.begin(); itr != mQuestStatus.end(); ++itr) + for (QuestStatusMap::const_iterator itr = mQuestStatus.begin(); itr != mQuestStatus.end(); ++itr) { // skip no rewarded quests - if(!itr->second.m_rewarded) + if (!itr->second.m_rewarded) continue; Quest const* quest = sObjectMgr.GetQuestTemplate(itr->first); - if( !quest ) + if (!quest) continue; learnQuestRewardedSpells(quest); } } -void Player::learnSkillRewardedSpells(uint32 skill_id, uint32 skill_value ) +void Player::learnSkillRewardedSpells(uint32 skill_id, uint32 skill_value) { uint32 raceMask = getRaceMask(); uint32 classMask = getClassMask(); for (uint32 j = 0; jskillId!=skill_id || pAbility->learnOnGetSkill != ABILITY_LEARNED_ON_GET_PROFESSION_SKILL) continue; // Check race if set @@ -20564,7 +20579,7 @@ void Player::learnSkillRewardedSpells(uint32 skill_id, uint32 skill_value ) } } -void Player::SendAurasForTarget(Unit *target) +void Player::SendAurasForTarget(Unit* target) { WorldPacket data(SMSG_AURA_UPDATE_ALL); data << target->GetPackGUID(); @@ -20580,11 +20595,11 @@ void Player::SendAurasForTarget(Unit *target) GetSession()->SendPacket(&data); } -void Player::SetDailyQuestStatus( uint32 quest_id ) +void Player::SetDailyQuestStatus(uint32 quest_id) { - for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) { - if(!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) + if (!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) { SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id); m_DailyQuestChanged = true; @@ -20593,7 +20608,7 @@ void Player::SetDailyQuestStatus( uint32 quest_id ) } } -void Player::SetWeeklyQuestStatus( uint32 quest_id ) +void Player::SetWeeklyQuestStatus(uint32 quest_id) { m_weeklyquests.insert(quest_id); m_WeeklyQuestChanged = true; @@ -20607,7 +20622,7 @@ void Player::SetMonthlyQuestStatus(uint32 quest_id) void Player::ResetDailyQuestStatus() { - for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0); // DB data deleted in caller @@ -20636,7 +20651,7 @@ void Player::ResetMonthlyQuestStatus() BattleGround* Player::GetBattleGround() const { - if(GetBattleGroundId()==0) + if (GetBattleGroundId()==0) return NULL; return sBattleGroundMgr.GetBattleGround(GetBattleGroundId(), m_bgData.bgTypeID); @@ -20644,8 +20659,8 @@ BattleGround* Player::GetBattleGround() const bool Player::InArena() const { - BattleGround *bg = GetBattleGround(); - if(!bg || !bg->isArena()) + BattleGround* bg = GetBattleGround(); + if (!bg || !bg->isArena()) return false; return true; @@ -20654,8 +20669,8 @@ bool Player::InArena() const bool Player::GetBGAccessByLevel(BattleGroundTypeId bgTypeId) const { // get a template bg instead of running one - BattleGround *bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); - if(!bg) + BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); + if (!bg) return false; // limit check leel to dbc compatible level range @@ -20663,20 +20678,20 @@ bool Player::GetBGAccessByLevel(BattleGroundTypeId bgTypeId) const if (level > DEFAULT_MAX_LEVEL) level = DEFAULT_MAX_LEVEL; - if(level < bg->GetMinLevel() || level > bg->GetMaxLevel()) + if (level < bg->GetMinLevel() || level > bg->GetMaxLevel()) return false; return true; } -float Player::GetReputationPriceDiscount( Creature const* pCreature ) const +float Player::GetReputationPriceDiscount(Creature const* pCreature) const { FactionTemplateEntry const* vendor_faction = pCreature->getFactionTemplateEntry(); - if(!vendor_faction || !vendor_faction->faction) + if (!vendor_faction || !vendor_faction->faction) return 1.0f; ReputationRank rank = GetReputationRank(vendor_faction->faction); - if(rank <= REP_NEUTRAL) + if (rank <= REP_NEUTRAL) return 1.0f; return 1.0f - 0.05f* (rank - REP_NEUTRAL); @@ -20744,14 +20759,14 @@ bool Player::IsSpellFitByClassAndRace(uint32 spell_id, uint32* pReqlevel /*= NUL bool Player::HasQuestForGO(int32 GOId) const { - for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i ) + for (int i = 0; i < MAX_QUEST_LOG_SIZE; ++i) { uint32 questid = GetQuestSlotQuestId(i); - if ( questid == 0 ) + if (questid == 0) continue; QuestStatusMap::const_iterator qs_itr = mQuestStatus.find(questid); - if(qs_itr == mQuestStatus.end()) + if (qs_itr == mQuestStatus.end()) continue; QuestStatusData const& qs = qs_itr->second; @@ -20759,10 +20774,10 @@ bool Player::HasQuestForGO(int32 GOId) const if (qs.m_status == QUEST_STATUS_INCOMPLETE) { Quest const* qinfo = sObjectMgr.GetQuestTemplate(questid); - if(!qinfo) + if (!qinfo) continue; - if(GetGroup() && GetGroup()->isRaidGroup() && !qinfo->IsAllowedInRaid()) + if (GetGroup() && GetGroup()->isRaidGroup() && !qinfo->IsAllowedInRaid()) continue; for (int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) @@ -20770,7 +20785,7 @@ bool Player::HasQuestForGO(int32 GOId) const if (qinfo->ReqCreatureOrGOId[j]>=0) //skip non GO case continue; - if((-1)*GOId == qinfo->ReqCreatureOrGOId[j] && qs.m_creatureOrGOcount[j] < qinfo->ReqCreatureOrGOCount[j]) + if ((-1)*GOId == qinfo->ReqCreatureOrGOId[j] && qs.m_creatureOrGOcount[j] < qinfo->ReqCreatureOrGOCount[j]) return true; } } @@ -20780,32 +20795,32 @@ bool Player::HasQuestForGO(int32 GOId) const void Player::UpdateForQuestWorldObjects() { - if(m_clientGUIDs.empty()) + if (m_clientGUIDs.empty()) return; UpdateData udata; WorldPacket packet; - for(GuidSet::const_iterator itr=m_clientGUIDs.begin(); itr!=m_clientGUIDs.end(); ++itr) + for (GuidSet::const_iterator itr=m_clientGUIDs.begin(); itr!=m_clientGUIDs.end(); ++itr) { if (itr->IsGameObject()) { - if (GameObject *obj = GetMap()->GetGameObject(*itr)) + if (GameObject* obj = GetMap()->GetGameObject(*itr)) obj->BuildValuesUpdateBlockForPlayer(&udata,this); } else if (itr->IsCreatureOrVehicle()) { - Creature *obj = GetMap()->GetAnyTypeCreature(*itr); - if(!obj) + Creature* obj = GetMap()->GetAnyTypeCreature(*itr); + if (!obj) continue; // check if this unit requires quest specific flags - if(!obj->HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_SPELLCLICK)) + if (!obj->HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_SPELLCLICK)) continue; SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(obj->GetEntry()); - for(SpellClickInfoMap::const_iterator _itr = clickPair.first; _itr != clickPair.second; ++_itr) + for (SpellClickInfoMap::const_iterator _itr = clickPair.first; _itr != clickPair.second; ++_itr) { - if(_itr->second.questStart || _itr->second.questEnd) + if (_itr->second.questStart || _itr->second.questEnd) { obj->BuildCreateUpdateBlockForPlayer(&udata,this); break; @@ -20819,18 +20834,18 @@ void Player::UpdateForQuestWorldObjects() void Player::SummonIfPossible(bool agree) { - if(!agree) + if (!agree) { m_summon_expire = 0; return; } // expire and auto declined - if(m_summon_expire < time(NULL)) + if (m_summon_expire < time(NULL)) return; // stop taxi flight at summon - if(IsTaxiFlying()) + if (IsTaxiFlying()) { GetMotionMaster()->MovementExpired(); m_taxi.ClearTaxiDestinations(); @@ -20838,7 +20853,7 @@ void Player::SummonIfPossible(bool agree) // drop flag at summon // this code can be reached only when GM is summoning player who carries flag, because player should be immune to summoning spells when he carries flag - if(BattleGround *bg = GetBattleGround()) + if (BattleGround* bg = GetBattleGround()) bg->EventPlayerDroppedFlag(this); m_summon_expire = 0; @@ -20848,11 +20863,11 @@ void Player::SummonIfPossible(bool agree) TeleportTo(m_summon_mapid, m_summon_x, m_summon_y, m_summon_z,GetOrientation()); } -void Player::RemoveItemDurations( Item *item ) +void Player::RemoveItemDurations(Item* item) { - for(ItemDurationList::iterator itr = m_itemDuration.begin();itr != m_itemDuration.end(); ++itr) + for (ItemDurationList::iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ++itr) { - if(*itr==item) + if (*itr==item) { m_itemDuration.erase(itr); break; @@ -20860,9 +20875,9 @@ void Player::RemoveItemDurations( Item *item ) } } -void Player::AddItemDurations( Item *item ) +void Player::AddItemDurations(Item* item) { - if(item->GetUInt32Value(ITEM_FIELD_DURATION)) + if (item->GetUInt32Value(ITEM_FIELD_DURATION)) { m_itemDuration.push_back(item); item->SendTimeUpdate(this); @@ -20871,21 +20886,21 @@ void Player::AddItemDurations( Item *item ) void Player::AutoUnequipOffhandIfNeed() { - Item *offItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND ); - if(!offItem) + Item* offItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + if (!offItem) return; // need unequip offhand for 2h-weapon without TitanGrip (in any from hands) if ((CanDualWield() || offItem->GetProto()->InventoryType == INVTYPE_SHIELD || offItem->GetProto()->InventoryType == INVTYPE_HOLDABLE) && - (CanTitanGrip() || (offItem->GetProto()->InventoryType != INVTYPE_2HWEAPON && !IsTwoHandUsed()))) + (CanTitanGrip() || (offItem->GetProto()->InventoryType != INVTYPE_2HWEAPON && !IsTwoHandUsed()))) return; ItemPosCountVec off_dest; - uint8 off_msg = CanStoreItem( NULL_BAG, NULL_SLOT, off_dest, offItem, false ); - if( off_msg == EQUIP_ERR_OK ) + uint8 off_msg = CanStoreItem(NULL_BAG, NULL_SLOT, off_dest, offItem, false); + if (off_msg == EQUIP_ERR_OK) { RemoveItem(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND, true); - StoreItem( off_dest, offItem, true ); + StoreItem(off_dest, offItem, true); } else { @@ -20902,37 +20917,37 @@ void Player::AutoUnequipOffhandIfNeed() bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem) { - if(spellInfo->EquippedItemClass < 0) + if (spellInfo->EquippedItemClass < 0) return true; // scan other equipped items for same requirements (mostly 2 daggers/etc) // for optimize check 2 used cases only - switch(spellInfo->EquippedItemClass) + switch (spellInfo->EquippedItemClass) { case ITEM_CLASS_WEAPON: { - for(int i= EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) - if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + for (int i= EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) + if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + if (item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; break; } case ITEM_CLASS_ARMOR: { // tabard not have dependent spells - for(int i= EQUIPMENT_SLOT_START; i< EQUIPMENT_SLOT_MAINHAND; ++i) - if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + for (int i= EQUIPMENT_SLOT_START; i< EQUIPMENT_SLOT_MAINHAND; ++i) + if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + if (item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; // shields can be equipped to offhand slot - if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) - if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) + if (item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; // ranged slot can have some armor subclasses - if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) - if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) + if (item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; break; @@ -20960,23 +20975,23 @@ bool Player::CanNoReagentCast(SpellEntry const* spellInfo) const return false; } -void Player::RemoveItemDependentAurasAndCasts( Item * pItem ) +void Player::RemoveItemDependentAurasAndCasts(Item* pItem) { SpellAuraHolderMap& auras = GetSpellAuraHolderMap(); - for(SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ) + for (SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end();) { SpellAuraHolder* holder = itr->second; // skip passive (passive item dependent spells work in another way) and not self applied auras SpellEntry const* spellInfo = holder->GetSpellProto(); - if(holder->IsPassive() || holder->GetCasterGuid() != GetObjectGuid()) + if (holder->IsPassive() || holder->GetCasterGuid() != GetObjectGuid()) { ++itr; continue; } // skip if not item dependent or have alternative item - if(HasItemFitToSpellReqirements(spellInfo,pItem)) + if (HasItemFitToSpellReqirements(spellInfo,pItem)) { ++itr; continue; @@ -20990,7 +21005,7 @@ void Player::RemoveItemDependentAurasAndCasts( Item * pItem ) // currently casted spells can be dependent from item for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i) if (Spell* spell = GetCurrentSpell(CurrentSpellTypes(i))) - if (spell->getState()!=SPELL_STATE_DELAYED && !HasItemFitToSpellReqirements(spell->m_spellInfo,pItem) ) + if (spell->getState()!=SPELL_STATE_DELAYED && !HasItemFitToSpellReqirements(spell->m_spellInfo,pItem)) InterruptSpell(CurrentSpellTypes(i)); } @@ -21000,12 +21015,12 @@ uint32 Player::GetResurrectionSpellId() uint32 prio = 0; uint32 spell_id = 0; AuraList const& dummyAuras = GetAurasByType(SPELL_AURA_DUMMY); - for(AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr) + for (AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr) { // Soulstone Resurrection // prio: 3 (max, non death persistent) - if( prio < 2 && (*itr)->GetSpellProto()->SpellVisual[0] == 99 && (*itr)->GetSpellProto()->SpellIconID == 92 ) + if (prio < 2 && (*itr)->GetSpellProto()->SpellVisual[0] == 99 && (*itr)->GetSpellProto()->SpellIconID == 92) { - switch((*itr)->GetId()) + switch ((*itr)->GetId()) { case 20707: spell_id = 3026; break; // rank 1 case 20762: spell_id = 20758; break; // rank 2 @@ -21022,7 +21037,7 @@ uint32 Player::GetResurrectionSpellId() prio = 3; } // Twisting Nether // prio: 2 (max) - else if((*itr)->GetId()==23701 && roll_chance_i(10)) + else if ((*itr)->GetId()==23701 && roll_chance_i(10)) { prio = 2; spell_id = 23700; @@ -21044,15 +21059,15 @@ bool Player::isHonorOrXPTarget(Unit* pVictim) const uint32 k_grey = MaNGOS::XP::GetGrayLevel(getLevel()); // Victim level less gray level - if(v_level<=k_grey) + if (v_level<=k_grey) return false; - if(pVictim->GetTypeId() == TYPEID_UNIT) + if (pVictim->GetTypeId() == TYPEID_UNIT) { if (((Creature*)pVictim)->IsTotem() || - ((Creature*)pVictim)->IsPet() || - ((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) - return false; + ((Creature*)pVictim)->IsPet() || + ((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) + return false; } return true; } @@ -21066,17 +21081,17 @@ void Player::RewardSinglePlayerAtKill(Unit* pVictim) RewardHonor(pVictim,1); // xp and reputation only in !PvP case - if(!PvP) + if (!PvP) { RewardReputation(pVictim,1); GiveXP(xp, pVictim); - if(Pet* pet = GetPet()) + if (Pet* pet = GetPet()) pet->GivePetXP(xp); // normal creature (not pet/etc) can be only in !PvP case - if(pVictim->GetTypeId()==TYPEID_UNIT) - if(CreatureInfo const* normalInfo = ObjectMgr::GetCreatureTemplate(pVictim->GetEntry())) + if (pVictim->GetTypeId()==TYPEID_UNIT) + if (CreatureInfo const* normalInfo = ObjectMgr::GetCreatureTemplate(pVictim->GetEntry())) KilledMonster(normalInfo, pVictim->GetObjectGuid()); } } @@ -21086,9 +21101,9 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar ObjectGuid creature_guid = pRewardSource && pRewardSource->GetTypeId() == TYPEID_UNIT ? pRewardSource->GetObjectGuid() : ObjectGuid(); // prepare data for near group iteration - if (Group *pGroup = GetGroup()) + if (Group* pGroup = GetGroup()) { - for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* pGroupGuy = itr->getSource(); if (!pGroupGuy) @@ -21109,19 +21124,19 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar void Player::RewardPlayerAndGroupAtCast(WorldObject* pRewardSource, uint32 spellid) { // prepare data for near group iteration - if(Group *pGroup = GetGroup()) + if (Group* pGroup = GetGroup()) { - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* pGroupGuy = itr->getSource(); - if(!pGroupGuy) + if (!pGroupGuy) continue; - if(!pGroupGuy->IsAtGroupRewardDistance(pRewardSource)) + if (!pGroupGuy->IsAtGroupRewardDistance(pRewardSource)) continue; // member (alive or dead) or his corpse at req. distance // quest objectives updated only for alive group member or dead but with not released body - if(pGroupGuy->isAlive()|| !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + if (pGroupGuy->isAlive()|| !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) pGroupGuy->CastedCreatureOrGO(pRewardSource->GetEntry(), pRewardSource->GetObjectGuid(), spellid, pGroupGuy == this); } } @@ -21144,12 +21159,12 @@ bool Player::IsAtGroupRewardDistance(WorldObject const* pRewardSource) const return pRewardSource->IsWithinDistInMap(corpse,sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE)); } -uint32 Player::GetBaseWeaponSkillValue (WeaponAttackType attType) const +uint32 Player::GetBaseWeaponSkillValue(WeaponAttackType attType) const { Item* item = GetWeaponForAttack(attType,true,true); // unarmed only with base attack - if(attType != BASE_ATTACK && !item) + if (attType != BASE_ATTACK && !item) return 0; // weapon skill or (unarmed for base attack) @@ -21165,7 +21180,7 @@ void Player::ResurectUsingRequestData() //we cannot resurrect player when we triggered far teleport //player will be resurrected upon teleportation - if(IsBeingTeleportedFar()) + if (IsBeingTeleportedFar()) { ScheduleDelayedOperation(DELAYED_RESURRECT_PLAYER); return; @@ -21173,19 +21188,19 @@ void Player::ResurectUsingRequestData() ResurrectPlayer(0.0f,false); - if(GetMaxHealth() > m_resurrectHealth) - SetHealth( m_resurrectHealth ); + if (GetMaxHealth() > m_resurrectHealth) + SetHealth(m_resurrectHealth); else - SetHealth( GetMaxHealth() ); + SetHealth(GetMaxHealth()); - if(GetMaxPower(POWER_MANA) > m_resurrectMana) - SetPower(POWER_MANA, m_resurrectMana ); + if (GetMaxPower(POWER_MANA) > m_resurrectMana) + SetPower(POWER_MANA, m_resurrectMana); else - SetPower(POWER_MANA, GetMaxPower(POWER_MANA) ); + SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); - SetPower(POWER_RAGE, 0 ); + SetPower(POWER_RAGE, 0); - SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY) ); + SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); SpawnCorpseBones(); } @@ -21202,8 +21217,8 @@ void Player::UpdateZoneDependentAuras() { // Some spells applied at enter into zone (with subzones), aura removed in UpdateAreaDependentAuras that called always at zone->area update SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAreaMapBounds(m_zoneUpdateId); - for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) - if(itr->second->autocast && itr->second->IsFitToRequirements(this, m_zoneUpdateId, 0)) + for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) + if (itr->second->autocast && itr->second->IsFitToRequirements(this, m_zoneUpdateId, 0)) if (!HasAura(itr->second->spellId, EFFECT_INDEX_0)) CastSpell(this,itr->second->spellId,true); } @@ -21211,10 +21226,10 @@ void Player::UpdateZoneDependentAuras() void Player::UpdateAreaDependentAuras() { // remove auras from spells with area limitations - for(SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();) + for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();) { // use m_zoneUpdateId for speed: UpdateArea called from UpdateZone or instead UpdateZone in both cases m_zoneUpdateId up-to-date - if(sSpellMgr.GetSpellAllowedInLocationError(iter->second->GetSpellProto(), GetMapId(), m_zoneUpdateId, m_areaUpdateId, this) != SPELL_CAST_OK) + if (sSpellMgr.GetSpellAllowedInLocationError(iter->second->GetSpellProto(), GetMapId(), m_zoneUpdateId, m_areaUpdateId, this) != SPELL_CAST_OK) { RemoveSpellAuraHolder(iter->second); iter = m_spellAuraHolders.begin(); @@ -21225,8 +21240,8 @@ void Player::UpdateAreaDependentAuras() // some auras applied at subzone enter SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAreaMapBounds(m_areaUpdateId); - for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) - if(itr->second->autocast && itr->second->IsFitToRequirements(this, m_zoneUpdateId, m_areaUpdateId)) + for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) + if (itr->second->autocast && itr->second->IsFitToRequirements(this, m_zoneUpdateId, m_areaUpdateId)) if (!HasAura(itr->second->spellId, EFFECT_INDEX_0)) CastSpell(this,itr->second->spellId,true); } @@ -21240,7 +21255,7 @@ struct UpdateZoneDependentPetsHelper if (uint32 spell_id = unit->GetUInt32Value(UNIT_CREATED_BY_SPELL)) if (SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell_id)) if (sSpellMgr.GetSpellAllowedInLocationError(spellEntry, owner->GetMapId(), zone_id, area_id, owner) != SPELL_CAST_OK) - ((Pet*)unit)->Unsummon(PET_SAVE_AS_DELETED, owner); + ((Pet*)unit)->Unsummon(PET_SAVE_AS_DELETED, owner); } Player* owner; uint32 zone_id; @@ -21256,7 +21271,7 @@ void Player::UpdateZoneDependentPets() uint32 Player::GetCorpseReclaimDelay(bool pvp) const { if ((pvp && !sWorld.getConfig(CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVP)) || - (!pvp && !sWorld.getConfig(CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVE) )) + (!pvp && !sWorld.getConfig(CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVE))) { return copseReclaimDelay[0]; } @@ -21272,15 +21287,15 @@ void Player::UpdateCorpseReclaimDelay() bool pvp = m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH; if ((pvp && !sWorld.getConfig(CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVP)) || - (!pvp && !sWorld.getConfig(CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVE) )) + (!pvp && !sWorld.getConfig(CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVE))) return; time_t now = time(NULL); - if(now < m_deathExpireTime) + if (now < m_deathExpireTime) { // full and partly periods 1..3 uint32 count = uint32((m_deathExpireTime - now)/DEATH_EXPIRE_STEP +1); - if(count < MAX_DEATH_COUNT) + if (count < MAX_DEATH_COUNT) m_deathExpireTime = now+(count+1)*DEATH_EXPIRE_STEP; else m_deathExpireTime = now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP; @@ -21305,7 +21320,7 @@ void Player::SendCorpseReclaimDelay(bool load) uint32 count; if ((pvp && sWorld.getConfig(CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVP)) || - (!pvp && sWorld.getConfig(CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVE))) + (!pvp && sWorld.getConfig(CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVE))) { count = uint32(m_deathExpireTime-corpse->GetGhostTime())/DEATH_EXPIRE_STEP; if (count>=MAX_DEATH_COUNT) @@ -21328,25 +21343,25 @@ void Player::SendCorpseReclaimDelay(bool load) //! corpse reclaim delay 30 * 1000ms or longer at often deaths WorldPacket data(SMSG_CORPSE_RECLAIM_DELAY, 4); data << uint32(delay*IN_MILLISECONDS); - GetSession()->SendPacket( &data ); + GetSession()->SendPacket(&data); } Player* Player::GetNextRandomRaidMember(float radius) { - Group *pGroup = GetGroup(); - if(!pGroup) + Group* pGroup = GetGroup(); + if (!pGroup) return NULL; std::vector nearMembers; nearMembers.reserve(pGroup->GetMembersCount()); - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* Target = itr->getSource(); // IsHostileTo check duel and controlled by enemy - if( Target && Target != this && IsWithinDistInMap(Target, radius) && - !Target->HasInvisibilityAura() && !IsHostileTo(Target) ) + if (Target && Target != this && IsWithinDistInMap(Target, radius) && + !Target->HasInvisibilityAura() && !IsHostileTo(Target)) nearMembers.push_back(Target); } @@ -21386,7 +21401,7 @@ void Player::RemoveFromBattleGroundRaid() { //remove existing reference m_group.unlink(); - if( Group* group = GetOriginalGroup() ) + if (Group* group = GetOriginalGroup()) { m_group.link(group, this); m_group.setSubGroup(GetOriginalSubGroup()); @@ -21394,9 +21409,9 @@ void Player::RemoveFromBattleGroundRaid() SetOriginalGroup(NULL); } -void Player::SetOriginalGroup(Group *group, int8 subgroup) +void Player::SetOriginalGroup(Group* group, int8 subgroup) { - if( group == NULL ) + if (group == NULL) m_originalGroup.unlink(); else { @@ -21407,7 +21422,7 @@ void Player::SetOriginalGroup(Group *group, int8 subgroup) } } -void Player::UpdateUnderwaterState( Map* m, float x, float y, float z ) +void Player::UpdateUnderwaterState(Map* m, float x, float y, float z) { GridMapLiquidData liquid_status; GridMapLiquidStatus res = m->GetTerrain()->getLiquidStatus(x, y, z, MAP_ALL_LIQUIDS, &liquid_status); @@ -21423,7 +21438,7 @@ void Player::UpdateUnderwaterState( Map* m, float x, float y, float z ) // All liquids type - check under water position if (liquid_status.type&(MAP_LIQUID_TYPE_WATER|MAP_LIQUID_TYPE_OCEAN|MAP_LIQUID_TYPE_MAGMA|MAP_LIQUID_TYPE_SLIME)) { - if ( res & LIQUID_MAP_UNDER_WATER) + if (res & LIQUID_MAP_UNDER_WATER) m_MirrorTimerFlags |= UNDERWATER_INWATER; else m_MirrorTimerFlags &= ~UNDERWATER_INWATER; @@ -21453,18 +21468,18 @@ void Player::UpdateUnderwaterState( Map* m, float x, float y, float z ) } } -void Player::SetCanParry( bool value ) +void Player::SetCanParry(bool value) { - if(m_canParry==value) + if (m_canParry==value) return; m_canParry = value; UpdateParryPercentage(); } -void Player::SetCanBlock( bool value ) +void Player::SetCanBlock(bool value) { - if(m_canBlock==value) + if (m_canBlock==value) return; m_canBlock = value; @@ -21473,8 +21488,8 @@ void Player::SetCanBlock( bool value ) bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const { - for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr) - if(itr->pos == pos) + for (ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end(); ++itr) + if (itr->pos == pos) return true; return false; @@ -21513,7 +21528,7 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n uint8 skintone = GetByteValue(PLAYER_BYTES, 0); if (hairstyle == newhairstyle && haircolor == newhaircolor && facialhair == newfacialhair && - (skintone == newskintone || newskintone == -1)) + (skintone == newskintone || newskintone == -1)) return 0; GtBarberShopCostBaseEntry const* bsc = sGtBarberShopCostBaseStore.LookupEntry(level - 1); @@ -21540,24 +21555,24 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n void Player::InitGlyphsForLevel() { - for(uint32 i = 0; i < sGlyphSlotStore.GetNumRows(); ++i) - if(GlyphSlotEntry const * gs = sGlyphSlotStore.LookupEntry(i)) - if(gs->Order) + for (uint32 i = 0; i < sGlyphSlotStore.GetNumRows(); ++i) + if (GlyphSlotEntry const* gs = sGlyphSlotStore.LookupEntry(i)) + if (gs->Order) SetGlyphSlot(gs->Order - 1, gs->Id); uint32 level = getLevel(); uint32 value = 0; // 0x3F = 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 for 80 level - if(level >= 15) + if (level >= 15) value |= (0x01 | 0x02); - if(level >= 30) + if (level >= 30) value |= 0x08; - if(level >= 50) + if (level >= 50) value |= 0x04; - if(level >= 70) + if (level >= 70) value |= 0x10; - if(level >= 80) + if (level >= 80) value |= 0x20; SetUInt32Value(PLAYER_GLYPHS_ENABLED, value); @@ -21567,9 +21582,9 @@ void Player::ApplyGlyph(uint8 slot, bool apply) { if (uint32 glyph = GetGlyph(slot)) { - if(GlyphPropertiesEntry const *gp = sGlyphPropertiesStore.LookupEntry(glyph)) + if (GlyphPropertiesEntry const* gp = sGlyphPropertiesStore.LookupEntry(glyph)) { - if(apply) + if (apply) { CastSpell(this, gp->SpellId, true); SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, glyph); @@ -21594,10 +21609,10 @@ bool Player::isTotalImmune() AuraList const& immune = GetAurasByType(SPELL_AURA_SCHOOL_IMMUNITY); uint32 immuneMask = 0; - for(AuraList::const_iterator itr = immune.begin(); itr != immune.end(); ++itr) + for (AuraList::const_iterator itr = immune.begin(); itr != immune.end(); ++itr) { immuneMask |= (*itr)->GetModifier()->m_miscvalue; - if( immuneMask & SPELL_SCHOOL_MASK_ALL ) // total immunity + if (immuneMask & SPELL_SCHOOL_MASK_ALL) // total immunity return true; } return false; @@ -21618,16 +21633,16 @@ void Player::SetTitle(CharTitlesEntry const* title, bool lost) uint32 fieldIndexOffset = title->bit_index / 32; uint32 flag = 1 << (title->bit_index % 32); - if(lost) + if (lost) { - if(!HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag)) + if (!HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag)) return; RemoveFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag); } else { - if(HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag)) + if (HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag)) return; SetFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag); @@ -21652,7 +21667,7 @@ void Player::ConvertRune(uint8 index, RuneType newType) bool Player::ActivateRunes(RuneType type, uint32 count) { bool modify = false; - for(uint32 j = 0; count > 0 && j < MAX_RUNES; ++j) + for (uint32 j = 0; count > 0 && j < MAX_RUNES; ++j) { if (GetRuneCooldown(j) && GetCurrentRune(j) == type) { @@ -21669,7 +21684,7 @@ void Player::ResyncRunes() { WorldPacket data(SMSG_RESYNC_RUNES, 4 + MAX_RUNES * 2); data << uint32(MAX_RUNES); - for(uint32 i = 0; i < MAX_RUNES; ++i) + for (uint32 i = 0; i < MAX_RUNES; ++i) { data << uint8(GetCurrentRune(i)); // rune type data << uint8(255 - ((GetRuneCooldown(i) / REGEN_TIME_FULL) * 51)); // passed cooldown time (0-255) @@ -21684,7 +21699,8 @@ void Player::AddRunePower(uint8 index) GetSession()->SendPacket(&data); } -static RuneType runeSlotTypes[MAX_RUNES] = { +static RuneType runeSlotTypes[MAX_RUNES] = +{ /*0*/ RUNE_BLOOD, /*1*/ RUNE_BLOOD, /*2*/ RUNE_UNHOLY, @@ -21695,14 +21711,14 @@ static RuneType runeSlotTypes[MAX_RUNES] = { void Player::InitRunes() { - if(getClass() != CLASS_DEATH_KNIGHT) + if (getClass() != CLASS_DEATH_KNIGHT) return; m_runes = new Runes; m_runes->runeState = 0; - for(uint32 i = 0; i < MAX_RUNES; ++i) + for (uint32 i = 0; i < MAX_RUNES; ++i) { SetBaseRune(i, runeSlotTypes[i]); // init base types SetCurrentRune(i, runeSlotTypes[i]); // init current types @@ -21710,14 +21726,14 @@ void Player::InitRunes() m_runes->SetRuneState(i); } - for(uint32 i = 0; i < NUM_RUNE_TYPES; ++i) + for (uint32 i = 0; i < NUM_RUNE_TYPES; ++i) SetFloatValue(PLAYER_RUNE_REGEN_1 + i, 0.1f); } -bool Player::IsBaseRuneSlotsOnCooldown( RuneType runeType ) const +bool Player::IsBaseRuneSlotsOnCooldown(RuneType runeType) const { - for(uint32 i = 0; i < MAX_RUNES; ++i) + for (uint32 i = 0; i < MAX_RUNES; ++i) if (GetBaseRune(i) == runeType && GetRuneCooldown(i) == 0) return false; @@ -21727,7 +21743,7 @@ bool Player::IsBaseRuneSlotsOnCooldown( RuneType runeType ) const void Player::AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast, uint8 bag, uint8 slot) { Loot loot; - loot.FillLoot (loot_id, store, this, true); + loot.FillLoot(loot_id, store, this, true); AutoStoreLoot(loot, broadcast, bag, slot); } @@ -21735,23 +21751,23 @@ void Player::AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcas void Player::AutoStoreLoot(Loot& loot, bool broadcast, uint8 bag, uint8 slot) { uint32 max_slot = loot.GetMaxSlotInLootFor(this); - for(uint32 i = 0; i < max_slot; ++i) + for (uint32 i = 0; i < max_slot; ++i) { LootItem* lootItem = loot.LootItemInSlot(i,this); ItemPosCountVec dest; InventoryResult msg = CanStoreNewItem(bag,slot,dest,lootItem->itemid,lootItem->count); - if(msg != EQUIP_ERR_OK && slot != NULL_SLOT) - msg = CanStoreNewItem( bag, NULL_SLOT,dest,lootItem->itemid,lootItem->count); - if( msg != EQUIP_ERR_OK && bag != NULL_BAG) - msg = CanStoreNewItem( NULL_BAG, NULL_SLOT,dest,lootItem->itemid,lootItem->count); - if(msg != EQUIP_ERR_OK) + if (msg != EQUIP_ERR_OK && slot != NULL_SLOT) + msg = CanStoreNewItem(bag, NULL_SLOT,dest,lootItem->itemid,lootItem->count); + if (msg != EQUIP_ERR_OK && bag != NULL_BAG) + msg = CanStoreNewItem(NULL_BAG, NULL_SLOT,dest,lootItem->itemid,lootItem->count); + if (msg != EQUIP_ERR_OK) { - SendEquipError( msg, NULL, NULL, lootItem->itemid ); + SendEquipError(msg, NULL, NULL, lootItem->itemid); continue; } - Item* pItem = StoreNewItem (dest,lootItem->itemid,true,lootItem->randomPropertyId); + Item* pItem = StoreNewItem(dest,lootItem->itemid,true,lootItem->randomPropertyId); SendNewItem(pItem, lootItem->count, false, false, broadcast); } } @@ -21760,7 +21776,7 @@ Item* Player::ConvertItem(Item* item, uint32 newItemId) { uint16 pos = item->GetPos(); - Item *pNewItem = Item::CreateItem(newItemId, 1, this); + Item* pNewItem = Item::CreateItem(newItemId, 1, this); if (!pNewItem) return NULL; @@ -21769,7 +21785,7 @@ Item* Player::ConvertItem(Item* item, uint32 newItemId) { if (item->GetEnchantmentId(EnchantmentSlot(j))) pNewItem->SetEnchantment(EnchantmentSlot(j), item->GetEnchantmentId(EnchantmentSlot(j)), - item->GetEnchantmentDuration(EnchantmentSlot(j)), item->GetEnchantmentCharges(EnchantmentSlot(j))); + item->GetEnchantmentDuration(EnchantmentSlot(j)), item->GetEnchantmentCharges(EnchantmentSlot(j))); } // copy durability @@ -21787,7 +21803,7 @@ Item* Player::ConvertItem(Item* item, uint32 newItemId) if (msg == EQUIP_ERR_OK) { DestroyItem(item->GetBagSlot(), item->GetSlot(), true); - return StoreItem( dest, pNewItem, true); + return StoreItem(dest, pNewItem, true); } } else if (IsBankPos(pos)) @@ -21801,7 +21817,7 @@ Item* Player::ConvertItem(Item* item, uint32 newItemId) return BankItem(dest, pNewItem, true); } } - else if (IsEquipmentPos (pos)) + else if (IsEquipmentPos(pos)) { uint16 dest; InventoryResult msg = CanEquipItem(item->GetSlot(), dest, pNewItem, true, false); @@ -21853,7 +21869,7 @@ bool Player::CanStartFlyInArea(uint32 mapid, uint32 zone, uint32 area) const struct DoPlayerLearnSpell { DoPlayerLearnSpell(Player& _player) : player(_player) {} - void operator() (uint32 spell_id) { player.learnSpell(spell_id, false); } + void operator()(uint32 spell_id) { player.learnSpell(spell_id, false); } Player& player; }; @@ -21865,7 +21881,7 @@ void Player::learnSpellHighRank(uint32 spellid) sSpellMgr.doForHighRanks(spellid, worker); } -void Player::_LoadSkills(QueryResult *result) +void Player::_LoadSkills(QueryResult* result) { // 0 1 2 // SetPQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = '%u'", GUID_LOPART(m_guid)); @@ -21875,21 +21891,21 @@ void Player::_LoadSkills(QueryResult *result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint16 skill = fields[0].GetUInt16(); uint16 value = fields[1].GetUInt16(); uint16 max = fields[2].GetUInt16(); - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(skill); - if(!pSkill) + SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(skill); + if (!pSkill) { sLog.outError("Character %u has skill %u that does not exist.", GetGUIDLow(), skill); continue; } // set fixed skill ranges - switch(GetSkillRangeType(pSkill,false)) + switch (GetSkillRangeType(pSkill,false)) { case SKILL_RANGE_LANGUAGE: // 300..300 value = max = 300; @@ -21901,10 +21917,10 @@ void Player::_LoadSkills(QueryResult *result) break; } - if(value == 0) + if (value == 0) { sLog.outError("Character %u has skill %u with value 0. Will be deleted.", GetGUIDLow(), skill); - CharacterDatabase.PExecute("DELETE FROM character_skills WHERE guid = '%u' AND skill = '%u' ", GetGUIDLow(), skill ); + CharacterDatabase.PExecute("DELETE FROM character_skills WHERE guid = '%u' AND skill = '%u' ", GetGUIDLow(), skill); continue; } @@ -21918,12 +21934,13 @@ void Player::_LoadSkills(QueryResult *result) ++count; - if(count >= PLAYER_MAX_SKILLS) // client limit + if (count >= PLAYER_MAX_SKILLS) // client limit { sLog.outError("Character %u has more than %u skills.", GetGUIDLow(), PLAYER_MAX_SKILLS); break; } - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } @@ -21935,30 +21952,30 @@ void Player::_LoadSkills(QueryResult *result) } // special settings - if(getClass()==CLASS_DEATH_KNIGHT) + if (getClass()==CLASS_DEATH_KNIGHT) { - uint32 base_level = std::min(getLevel(),sWorld.getConfig (CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL)); - if(base_level < 1) + uint32 base_level = std::min(getLevel(),sWorld.getConfig(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL)); + if (base_level < 1) base_level = 1; uint32 base_skill = (base_level-1)*5; // 270 at starting level 55 - if(base_skill < 1) + if (base_skill < 1) base_skill = 1; // skill mast be known and then > 0 in any case - if(GetPureSkillValue (SKILL_FIRST_AID) < base_skill) + if (GetPureSkillValue(SKILL_FIRST_AID) < base_skill) SetSkill(SKILL_FIRST_AID, base_skill, base_skill); - if(GetPureSkillValue (SKILL_AXES) < base_skill) + if (GetPureSkillValue(SKILL_AXES) < base_skill) SetSkill(SKILL_AXES, base_skill, base_skill); - if(GetPureSkillValue (SKILL_DEFENSE) < base_skill) + if (GetPureSkillValue(SKILL_DEFENSE) < base_skill) SetSkill(SKILL_DEFENSE, base_skill, base_skill); - if(GetPureSkillValue (SKILL_POLEARMS) < base_skill) + if (GetPureSkillValue(SKILL_POLEARMS) < base_skill) SetSkill(SKILL_POLEARMS, base_skill, base_skill); - if(GetPureSkillValue (SKILL_SWORDS) < base_skill) + if (GetPureSkillValue(SKILL_SWORDS) < base_skill) SetSkill(SKILL_SWORDS, base_skill, base_skill); - if(GetPureSkillValue (SKILL_2H_AXES) < base_skill) + if (GetPureSkillValue(SKILL_2H_AXES) < base_skill) SetSkill(SKILL_2H_AXES, base_skill, base_skill); - if(GetPureSkillValue (SKILL_2H_SWORDS) < base_skill) + if (GetPureSkillValue(SKILL_2H_SWORDS) < base_skill) SetSkill(SKILL_2H_SWORDS, base_skill, base_skill); - if(GetPureSkillValue (SKILL_UNARMED) < base_skill) + if (GetPureSkillValue(SKILL_UNARMED) < base_skill) SetSkill(SKILL_UNARMED, base_skill, base_skill); } } @@ -21966,17 +21983,17 @@ void Player::_LoadSkills(QueryResult *result) uint32 Player::GetPhaseMaskForSpawn() const { uint32 phase = PHASEMASK_NORMAL; - if(!isGameMaster()) + if (!isGameMaster()) phase = GetPhaseMask(); else { AuraList const& phases = GetAurasByType(SPELL_AURA_PHASE); - if(!phases.empty()) + if (!phases.empty()) phase = phases.front()->GetMiscValue(); } // some aura phases include 1 normal map in addition to phase itself - if(uint32 n_phase = phase & ~PHASEMASK_NORMAL) + if (uint32 n_phase = phase & ~PHASEMASK_NORMAL) return n_phase; return PHASEMASK_NORMAL; @@ -21987,41 +22004,41 @@ InventoryResult Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limi ItemPrototype const* pProto = pItem->GetProto(); // proto based limitations - if(InventoryResult res = CanEquipUniqueItem(pProto,eslot,limit_count)) + if (InventoryResult res = CanEquipUniqueItem(pProto,eslot,limit_count)) return res; // check unique-equipped on gems - for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) { uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); - if(!enchant_id) + if (!enchant_id) continue; SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!enchantEntry) + if (!enchantEntry) continue; ItemPrototype const* pGem = ObjectMgr::GetItemPrototype(enchantEntry->GemID); - if(!pGem) + if (!pGem) continue; // include for check equip another gems with same limit category for not equipped item (and then not counted) uint32 gem_limit_count = !pItem->IsEquipped() && pGem->ItemLimitCategory - ? pItem->GetGemCountWithLimitCategory(pGem->ItemLimitCategory) : 1; + ? pItem->GetGemCountWithLimitCategory(pGem->ItemLimitCategory) : 1; - if(InventoryResult res = CanEquipUniqueItem(pGem, eslot,gem_limit_count)) + if (InventoryResult res = CanEquipUniqueItem(pGem, eslot,gem_limit_count)) return res; } return EQUIP_ERR_OK; } -InventoryResult Player::CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_slot, uint32 limit_count) const +InventoryResult Player::CanEquipUniqueItem(ItemPrototype const* itemProto, uint8 except_slot, uint32 limit_count) const { // check unique-equipped on item if (itemProto->Flags & ITEM_FLAG_UNIQUE_EQUIPPED) { // there is an equip limit on this item - if(HasItemOrGemWithIdEquipped(itemProto->ItemId,1,except_slot)) + if (HasItemOrGemWithIdEquipped(itemProto->ItemId,1,except_slot)) return EQUIP_ERR_ITEM_UNIQUE_EQUIPABLE; } @@ -22029,16 +22046,16 @@ InventoryResult Player::CanEquipUniqueItem( ItemPrototype const* itemProto, uint if (itemProto->ItemLimitCategory) { ItemLimitCategoryEntry const* limitEntry = sItemLimitCategoryStore.LookupEntry(itemProto->ItemLimitCategory); - if(!limitEntry) + if (!limitEntry) return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; // NOTE: limitEntry->mode not checked because if item have have-limit then it applied and to equip case - if(limit_count > limitEntry->maxCount) + if (limit_count > limitEntry->maxCount) return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED_IS; // there is an equip limit on this item - if(HasItemOrGemWithLimitCategoryEquipped(itemProto->ItemLimitCategory,limitEntry->maxCount-limit_count+1,except_slot)) + if (HasItemOrGemWithLimitCategoryEquipped(itemProto->ItemLimitCategory,limitEntry->maxCount-limit_count+1,except_slot)) return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED_IS; } @@ -22054,15 +22071,15 @@ void Player::HandleFall(MovementInfo const& movementInfo) //Players with low fall distance, Feather Fall or physical immunity (charges used) are ignored // 14.57 can be calculated by resolving damageperc formula below to 0 if (z_diff >= 14.57f && !isDead() && !isGameMaster() && - !HasAuraType(SPELL_AURA_HOVER) && !HasAuraType(SPELL_AURA_FEATHER_FALL) && - !HasAuraType(SPELL_AURA_FLY) && !IsImmunedToDamage(SPELL_SCHOOL_MASK_NORMAL) ) + !HasAuraType(SPELL_AURA_HOVER) && !HasAuraType(SPELL_AURA_FEATHER_FALL) && + !HasAuraType(SPELL_AURA_FLY) && !IsImmunedToDamage(SPELL_SCHOOL_MASK_NORMAL)) { //Safe fall, fall height reduction int32 safe_fall = GetTotalAuraModifier(SPELL_AURA_SAFE_FALL); float damageperc = 0.018f*(z_diff-safe_fall)-0.2426f; - if(damageperc >0 ) + if (damageperc >0) { uint32 damage = (uint32)(damageperc * GetMaxHealth()*sWorld.getConfig(CONFIG_FLOAT_RATE_DAMAGE_FALL)); @@ -22093,7 +22110,7 @@ void Player::HandleFall(MovementInfo const& movementInfo) } } -void Player::UpdateAchievementCriteria( AchievementCriteriaTypes type, uint32 miscvalue1/*=0*/, uint32 miscvalue2/*=0*/, Unit *unit/*=NULL*/, uint32 time/*=0*/ ) +void Player::UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1/*=0*/, uint32 miscvalue2/*=0*/, Unit* unit/*=NULL*/, uint32 time/*=0*/) { GetAchievementMgr().UpdateAchievementCriteria(type, miscvalue1,miscvalue2,unit,time); } @@ -22124,7 +22141,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank) { uint32 CurTalentPoints = GetFreeTalentPoints(); - if(CurTalentPoints == 0) + if (CurTalentPoints == 0) return; if (talentRank >= MAX_TALENT_RANK) @@ -22132,16 +22149,16 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank) TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId); - if(!talentInfo) + if (!talentInfo) return; TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); - if(!talentTabInfo) + if (!talentTabInfo) return; // prevent learn talent for different class (cheating) - if( (getClassMask() & talentTabInfo->ClassMask) == 0 ) + if ((getClassMask() & talentTabInfo->ClassMask) == 0) return; // find current max talent rank @@ -22150,17 +22167,17 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank) curtalent_maxrank = talent->currentRank + 1; // we already have same or higher talent rank learned - if(curtalent_maxrank >= (talentRank + 1)) + if (curtalent_maxrank >= (talentRank + 1)) return; // check if we have enough talent points - if(CurTalentPoints < (talentRank - curtalent_maxrank + 1)) + if (CurTalentPoints < (talentRank - curtalent_maxrank + 1)) return; // Check if it requires another talent if (talentInfo->DependsOn > 0) { - if(TalentEntry const *depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn)) + if (TalentEntry const* depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn)) { bool hasEnoughRank = false; PlayerTalentMap::iterator dependsOnTalent = m_talents[m_activeSpec].find(depTalentInfo->TalentID); @@ -22188,19 +22205,19 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank) } // not have required min points spent in talent tree - if(spentPoints < (talentInfo->Row * MAX_TALENT_RANK)) + if (spentPoints < (talentInfo->Row * MAX_TALENT_RANK)) return; // spell not set in talent.dbc uint32 spellid = talentInfo->RankID[talentRank]; - if( spellid == 0 ) + if (spellid == 0) { sLog.outError("Talent.dbc have for talent: %u Rank: %u spell id = 0", talentId, talentRank); return; } // already known - if(HasSpell(spellid)) + if (HasSpell(spellid)) return; // learn! (other talent ranks will unlearned at learning) @@ -22210,7 +22227,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank) void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank) { - Pet *pet = GetPet(); + Pet* pet = GetPet(); if (!pet) return; @@ -22219,44 +22236,44 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa uint32 CurTalentPoints = pet->GetFreeTalentPoints(); - if(CurTalentPoints == 0) + if (CurTalentPoints == 0) return; if (talentRank >= MAX_PET_TALENT_RANK) return; - TalentEntry const *talentInfo = sTalentStore.LookupEntry(talentId); + TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId); - if(!talentInfo) + if (!talentInfo) return; - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); - if(!talentTabInfo) + if (!talentTabInfo) return; - CreatureInfo const *ci = pet->GetCreatureInfo(); + CreatureInfo const* ci = pet->GetCreatureInfo(); - if(!ci) + if (!ci) return; - CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family); + CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->family); - if(!pet_family) + if (!pet_family) return; - if(pet_family->petTalentType < 0) // not hunter pet + if (pet_family->petTalentType < 0) // not hunter pet return; // prevent learn talent for different family (cheating) - if(!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) + if (!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) return; // find current max talent rank int32 curtalent_maxrank = 0; - for(int32 k = MAX_TALENT_RANK-1; k > -1; --k) + for (int32 k = MAX_TALENT_RANK-1; k > -1; --k) { - if(talentInfo->RankID[k] && pet->HasSpell(talentInfo->RankID[k])) + if (talentInfo->RankID[k] && pet->HasSpell(talentInfo->RankID[k])) { curtalent_maxrank = k + 1; break; @@ -22264,17 +22281,17 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa } // we already have same or higher talent rank learned - if(curtalent_maxrank >= int32(talentRank + 1)) + if (curtalent_maxrank >= int32(talentRank + 1)) return; // check if we have enough talent points - if(CurTalentPoints < (talentRank - curtalent_maxrank + 1)) + if (CurTalentPoints < (talentRank - curtalent_maxrank + 1)) return; // Check if it requires another talent if (talentInfo->DependsOn > 0) { - if(TalentEntry const *depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn)) + if (TalentEntry const* depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn)) { bool hasEnoughRank = false; for (int i = talentInfo->DependsOnRank; i < MAX_TALENT_RANK; ++i) @@ -22298,7 +22315,7 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa for (unsigned int i = 0; i < numRows; ++i) // Loop through all talents. { // Someday, someone needs to revamp - const TalentEntry *tmpTalent = sTalentStore.LookupEntry(i); + const TalentEntry* tmpTalent = sTalentStore.LookupEntry(i); if (tmpTalent) // the way talents are tracked { if (tmpTalent->TalentTab == tTab) @@ -22319,19 +22336,19 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa } // not have required min points spent in talent tree - if(spentPoints < (talentInfo->Row * MAX_PET_TALENT_RANK)) + if (spentPoints < (talentInfo->Row * MAX_PET_TALENT_RANK)) return; // spell not set in talent.dbc uint32 spellid = talentInfo->RankID[talentRank]; - if( spellid == 0 ) + if (spellid == 0) { sLog.outError("Talent.dbc have for talent: %u Rank: %u spell id = 0", talentId, talentRank); return; } // already known - if(pet->HasSpell(spellid)) + if (pet->HasSpell(spellid)) return; // learn! (other talent ranks will unlearned at learning) @@ -22341,16 +22358,16 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa void Player::UpdateKnownCurrencies(uint32 itemId, bool apply) { - if(CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(itemId)) + if (CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(itemId)) { - if(apply) + if (apply) SetFlag64(PLAYER_FIELD_KNOWN_CURRENCIES, (UI64LIT(1) << (ctEntry->BitIndex - 1))); else RemoveFlag64(PLAYER_FIELD_KNOWN_CURRENCIES, (UI64LIT(1) << (ctEntry->BitIndex - 1))); } } -void Player::UpdateFallInformationIfNeed( MovementInfo const& minfo,uint16 opcode ) +void Player::UpdateFallInformationIfNeed(MovementInfo const& minfo,uint16 opcode) { if (m_lastFallTime >= minfo.GetFallTime() || m_lastFallZ <= minfo.GetPos()->z || opcode == MSG_MOVE_FALL_LAND) SetFallInformation(minfo.GetFallTime(), minfo.GetPos()->z); @@ -22359,10 +22376,10 @@ void Player::UpdateFallInformationIfNeed( MovementInfo const& minfo,uint16 opcod void Player::UnsummonPetTemporaryIfAny() { Pet* pet = GetPet(); - if(!pet) + if (!pet) return; - if(!m_temporaryUnsummonedPetNumber && pet->isControlled() && !pet->isTemporarySummoned() ) + if (!m_temporaryUnsummonedPetNumber && pet->isControlled() && !pet->isTemporarySummoned()) m_temporaryUnsummonedPetNumber = pet->GetCharmInfo()->GetPetNumber(); pet->Unsummon(PET_SAVE_AS_CURRENT, this); @@ -22381,35 +22398,35 @@ void Player::ResummonPetTemporaryUnSummonedIfAny() return; Pet* NewPet = new Pet; - if(!NewPet->LoadPetFromDB(this, 0, m_temporaryUnsummonedPetNumber, true)) + if (!NewPet->LoadPetFromDB(this, 0, m_temporaryUnsummonedPetNumber, true)) delete NewPet; m_temporaryUnsummonedPetNumber = 0; } -bool Player::canSeeSpellClickOn(Creature const *c) const +bool Player::canSeeSpellClickOn(Creature const* c) const { - if(!c->HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_SPELLCLICK)) + if (!c->HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_SPELLCLICK)) return false; SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(c->GetEntry()); - for(SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr) - if(itr->second.IsFitToRequirements(this)) + for (SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr) + if (itr->second.IsFitToRequirements(this)) return true; return false; } -void Player::BuildPlayerTalentsInfoData(WorldPacket *data) +void Player::BuildPlayerTalentsInfoData(WorldPacket* data) { *data << uint32(GetFreeTalentPoints()); // unspentTalentPoints *data << uint8(m_specsCount); // talent group count (0, 1 or 2) *data << uint8(m_activeSpec); // talent group index (0 or 1) - if(m_specsCount) + if (m_specsCount) { // loop through all specs (only 1 for now) - for(uint32 specIdx = 0; specIdx < m_specsCount; ++specIdx) + for (uint32 specIdx = 0; specIdx < m_specsCount; ++specIdx) { uint8 talentIdCount = 0; size_t pos = data->wpos(); @@ -22418,10 +22435,10 @@ void Player::BuildPlayerTalentsInfoData(WorldPacket *data) // find class talent tabs (all players have 3 talent tabs) uint32 const* talentTabIds = GetTalentTabPages(getClass()); - for(uint32 i = 0; i < 3; ++i) + for (uint32 i = 0; i < 3; ++i) { uint32 talentTabId = talentTabIds[i]; - for(PlayerTalentMap::iterator iter = m_talents[specIdx].begin(); iter != m_talents[specIdx].end(); ++iter) + for (PlayerTalentMap::iterator iter = m_talents[specIdx].begin(); iter != m_talents[specIdx].end(); ++iter) { PlayerTalent talent = (*iter).second; @@ -22444,13 +22461,13 @@ void Player::BuildPlayerTalentsInfoData(WorldPacket *data) *data << uint8(MAX_GLYPH_SLOT_INDEX); // glyphs count // GlyphProperties.dbc - for(uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i) + for (uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i) *data << uint16(m_glyphs[specIdx][i].GetId()); } } } -void Player::BuildPetTalentsInfoData(WorldPacket *data) +void Player::BuildPetTalentsInfoData(WorldPacket* data) { uint32 unspentTalentPoints = 0; size_t pointsPos = data->wpos(); @@ -22460,46 +22477,46 @@ void Player::BuildPetTalentsInfoData(WorldPacket *data) size_t countPos = data->wpos(); *data << uint8(talentIdCount); // [PH], talentIdCount - Pet *pet = GetPet(); - if(!pet) + Pet* pet = GetPet(); + if (!pet) return; unspentTalentPoints = pet->GetFreeTalentPoints(); data->put(pointsPos, unspentTalentPoints); // put real points - CreatureInfo const *ci = pet->GetCreatureInfo(); - if(!ci) + CreatureInfo const* ci = pet->GetCreatureInfo(); + if (!ci) return; - CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family); - if(!pet_family || pet_family->petTalentType < 0) + CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->family); + if (!pet_family || pet_family->petTalentType < 0) return; - for(uint32 talentTabId = 1; talentTabId < sTalentTabStore.GetNumRows(); ++talentTabId) + for (uint32 talentTabId = 1; talentTabId < sTalentTabStore.GetNumRows(); ++talentTabId) { - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentTabId ); - if(!talentTabInfo) + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentTabId); + if (!talentTabInfo) continue; - if(!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) + if (!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) continue; - for(uint32 talentId = 0; talentId < sTalentStore.GetNumRows(); ++talentId) + for (uint32 talentId = 0; talentId < sTalentStore.GetNumRows(); ++talentId) { TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId); - if(!talentInfo) + if (!talentInfo) continue; // skip another tab talents - if(talentInfo->TalentTab != talentTabId) + if (talentInfo->TalentTab != talentTabId) continue; // find max talent rank int32 curtalent_maxrank = -1; - for(int32 k = 4; k > -1; --k) + for (int32 k = 4; k > -1; --k) { - if(talentInfo->RankID[k] && pet->HasSpell(talentInfo->RankID[k])) + if (talentInfo->RankID[k] && pet->HasSpell(talentInfo->RankID[k])) { curtalent_maxrank = k; break; @@ -22507,7 +22524,7 @@ void Player::BuildPetTalentsInfoData(WorldPacket *data) } // not learned talent - if(curtalent_maxrank < 0) + if (curtalent_maxrank < 0) continue; *data << uint32(talentInfo->TalentID); // Talent.dbc @@ -22526,24 +22543,24 @@ void Player::SendTalentsInfoData(bool pet) { WorldPacket data(SMSG_TALENT_UPDATE, 50); data << uint8(pet ? 1 : 0); - if(pet) + if (pet) BuildPetTalentsInfoData(&data); else BuildPlayerTalentsInfoData(&data); GetSession()->SendPacket(&data); } -void Player::BuildEnchantmentsInfoData(WorldPacket *data) +void Player::BuildEnchantmentsInfoData(WorldPacket* data) { uint32 slotUsedMask = 0; size_t slotUsedMaskPos = data->wpos(); *data << uint32(slotUsedMask); // slotUsedMask < 0x80000 - for(uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) + for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) { - Item *item = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i); - if(!item) + if (!item) continue; slotUsedMask |= (1 << i); @@ -22554,11 +22571,11 @@ void Player::BuildEnchantmentsInfoData(WorldPacket *data) size_t enchantmentMaskPos = data->wpos(); *data << uint16(enchantmentMask); // enchantmentMask < 0x1000 - for(uint32 j = 0; j < MAX_ENCHANTMENT_SLOT; ++j) + for (uint32 j = 0; j < MAX_ENCHANTMENT_SLOT; ++j) { uint32 enchId = item->GetEnchantmentId(EnchantmentSlot(j)); - if(!enchId) + if (!enchId) continue; enchantmentMask |= (1 << j); @@ -22582,15 +22599,15 @@ void Player::SendEquipmentSetList() WorldPacket data(SMSG_LOAD_EQUIPMENT_SET, 4); size_t count_pos = data.wpos(); data << uint32(count); // count placeholder - for(EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end(); ++itr) + for (EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end(); ++itr) { - if(itr->second.state==EQUIPMENT_SET_DELETED) + if (itr->second.state==EQUIPMENT_SET_DELETED) continue; data.appendPackGUID(itr->second.Guid); data << uint32(itr->first); data << itr->second.Name; data << itr->second.IconName; - for(uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) + for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) { // ignored slots stored in IgnoreMask, client wants "1" as raw GUID, so no HIGHGUID_ITEM if (itr->second.IgnoreMask & (1 << i)) @@ -22607,20 +22624,20 @@ void Player::SendEquipmentSetList() void Player::SetEquipmentSet(uint32 index, EquipmentSet eqset) { - if(eqset.Guid != 0) + if (eqset.Guid != 0) { bool found = false; - for(EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end(); ++itr) + for (EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end(); ++itr) { - if((itr->second.Guid == eqset.Guid) && (itr->first == index)) + if ((itr->second.Guid == eqset.Guid) && (itr->first == index)) { found = true; break; } } - if(!found) // something wrong... + if (!found) // something wrong... { sLog.outError("Player %s tried to save equipment set "UI64FMTD" (index %u), but that equipment set not found!", GetName(), eqset.Guid, index); return; @@ -22633,7 +22650,7 @@ void Player::SetEquipmentSet(uint32 index, EquipmentSet eqset) eqslot = eqset; - if(eqset.Guid == 0) + if (eqset.Guid == 0) { eqslot.Guid = sObjectMgr.GenerateEquipmentSetGuid(); @@ -22652,11 +22669,11 @@ void Player::_SaveEquipmentSets() static SqlStatementID insSets ; static SqlStatementID delSets ; - for(EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end();) + for (EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end();) { uint32 index = itr->first; EquipmentSet& eqset = itr->second; - switch(eqset.state) + switch (eqset.state) { case EQUIPMENT_SET_UNCHANGED: ++itr; @@ -22664,8 +22681,8 @@ void Player::_SaveEquipmentSets() case EQUIPMENT_SET_CHANGED: { SqlStatement stmt = CharacterDatabase.CreateStatement(updSets, "UPDATE character_equipmentsets SET name=?, iconname=?, ignore_mask=?, item0=?, item1=?, item2=?, item3=?, item4=?, " - "item5=?, item6=?, item7=?, item8=?, item9=?, item10=?, item11=?, item12=?, item13=?, item14=?, " - "item15=?, item16=?, item17=?, item18=? WHERE guid=? AND setguid=? AND setindex=?"); + "item5=?, item6=?, item7=?, item8=?, item9=?, item10=?, item11=?, item12=?, item13=?, item14=?, " + "item15=?, item16=?, item17=?, item18=? WHERE guid=? AND setguid=? AND setindex=?"); stmt.addString(eqset.Name); stmt.addString(eqset.IconName); @@ -22751,11 +22768,11 @@ void Player::_SaveBGData() void Player::DeleteEquipmentSet(uint64 setGuid) { - for(EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end(); ++itr) + for (EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end(); ++itr) { - if(itr->second.Guid == setGuid) + if (itr->second.Guid == setGuid) { - if(itr->second.state == EQUIPMENT_SET_NEW) + if (itr->second.state == EQUIPMENT_SET_NEW) m_EquipmentSets.erase(itr); else itr->second.state = EQUIPMENT_SET_DELETED; @@ -22766,10 +22783,10 @@ void Player::DeleteEquipmentSet(uint64 setGuid) void Player::ActivateSpec(uint8 specNum) { - if(GetActiveSpec() == specNum) + if (GetActiveSpec() == specNum) return; - if(specNum >= GetSpecsCount()) + if (specNum >= GetSpecsCount()) return; UnsummonPetTemporaryIfAny(); @@ -22803,9 +22820,9 @@ void Player::ActivateSpec(uint8 specNum) // remove any talent rank if talent not listed in temp spec if (iterTempSpec == tempSpec.end() || iterTempSpec->second.state == PLAYERSPELL_REMOVED) { - TalentEntry const *talentInfo = talent.talentEntry; + TalentEntry const* talentInfo = talent.talentEntry; - for(int r = 0; r < MAX_TALENT_RANK; ++r) + for (int r = 0; r < MAX_TALENT_RANK; ++r) if (talentInfo->RankID[r]) removeSpell(talentInfo->RankID[r],!IsPassiveSpell(talentInfo->RankID[r]),false); @@ -22862,7 +22879,7 @@ void Player::ActivateSpec(uint8 specNum) // recheck action buttons (not checked at loading/spec copy) ActionButtonList const& currentActionButtonList = m_actionButtons[m_activeSpec]; - for(ActionButtonList::const_iterator itr = currentActionButtonList.begin(); itr != currentActionButtonList.end(); ) + for (ActionButtonList::const_iterator itr = currentActionButtonList.begin(); itr != currentActionButtonList.end();) { if (itr->second.uState != ACTIONBUTTON_DELETED) { @@ -22884,7 +22901,7 @@ void Player::ActivateSpec(uint8 specNum) SendInitialActionButtons(); Powers pw = getPowerType(); - if(pw != POWER_MANA) + if (pw != POWER_MANA) SetPower(POWER_MANA, 0); SetPower(pw, 0); @@ -22906,11 +22923,11 @@ void Player::UpdateSpecCount(uint8 count) // copy action buttons from active spec (more easy in this case iterate first by button) ActionButtonList const& currentActionButtonList = m_actionButtons[m_activeSpec]; - for(ActionButtonList::const_iterator itr = currentActionButtonList.begin(); itr != currentActionButtonList.end(); ++itr) + for (ActionButtonList::const_iterator itr = currentActionButtonList.begin(); itr != currentActionButtonList.end(); ++itr) { if (itr->second.uState != ACTIONBUTTON_DELETED) { - for(uint8 spec = curCount; spec < count; ++spec) + for (uint8 spec = curCount; spec < count; ++spec) addActionButton(spec,itr->first,itr->second.GetAction(),itr->second.GetType()); } } @@ -22919,10 +22936,10 @@ void Player::UpdateSpecCount(uint8 count) else if (count < curCount) { // delete action buttons for removed spec - for(uint8 spec = count; spec < curCount; ++spec) + for (uint8 spec = count; spec < curCount; ++spec) { // delete action buttons for removed spec - for(uint8 button = 0; button < MAX_ACTION_BUTTONS; ++button) + for (uint8 button = 0; button < MAX_ACTION_BUTTONS; ++button) removeActionButton(spec,button); } } @@ -22932,15 +22949,15 @@ void Player::UpdateSpecCount(uint8 count) SendTalentsInfoData(false); } -void Player::RemoveAtLoginFlag( AtLoginFlags f, bool in_db_also /*= false*/ ) +void Player::RemoveAtLoginFlag(AtLoginFlags f, bool in_db_also /*= false*/) { m_atLoginFlags &= ~f; - if(in_db_also) + if (in_db_also) CharacterDatabase.PExecute("UPDATE characters set at_login = at_login & ~ %u WHERE guid ='%u'", uint32(f), GetGUIDLow()); } -void Player::SendClearCooldown( uint32 spell_id, Unit* target ) +void Player::SendClearCooldown(uint32 spell_id, Unit* target) { WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8); data << uint32(spell_id); @@ -22959,7 +22976,7 @@ void Player::BuildTeleportAckMsg(WorldPacket& data, float x, float y, float z, f data << mi; } -bool Player::HasMovementFlag( MovementFlags f ) const +bool Player::HasMovementFlag(MovementFlags f) const { return m_movementInfo.HasMovementFlag(f); } @@ -22992,14 +23009,14 @@ void Player::SendDuelCountdown(uint32 counter) bool Player::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const { - switch(spellInfo->Effect[index]) + switch (spellInfo->Effect[index]) { case SPELL_EFFECT_ATTACK_ME: return true; default: break; } - switch(spellInfo->EffectApplyAuraName[index]) + switch (spellInfo->EffectApplyAuraName[index]) { case SPELL_AURA_MOD_TAUNT: return true; @@ -23019,12 +23036,12 @@ void Player::SetHomebindToLocation(WorldLocation const& loc, uint32 area_id) // update sql homebind CharacterDatabase.PExecute("UPDATE character_homebind SET map = '%u', zone = '%u', position_x = '%f', position_y = '%f', position_z = '%f' WHERE guid = '%u'", - m_homebindMapId, m_homebindAreaId, m_homebindX, m_homebindY, m_homebindZ, GetGUIDLow()); + m_homebindMapId, m_homebindAreaId, m_homebindX, m_homebindY, m_homebindZ, GetGUIDLow()); } Object* Player::GetObjectByTypeMask(ObjectGuid guid, TypeMask typemask) { - switch(guid.GetHigh()) + switch (guid.GetHigh()) { case HIGHGUID_ITEM: if (typemask & TYPEMASK_ITEM) @@ -23065,7 +23082,7 @@ Object* Player::GetObjectByTypeMask(ObjectGuid guid, TypeMask typemask) return NULL; } -void Player::SetRestType( RestType n_r_type, uint32 areaTriggerId /*= 0*/) +void Player::SetRestType(RestType n_r_type, uint32 areaTriggerId /*= 0*/) { rest_type = n_r_type; @@ -23074,7 +23091,7 @@ void Player::SetRestType( RestType n_r_type, uint32 areaTriggerId /*= 0*/) RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); // Set player to FFA PVP when not in rested environment. - if(sWorld.IsFFAPvPRealm()) + if (sWorld.IsFFAPvPRealm()) SetFFAPvP(true); } else @@ -23084,7 +23101,7 @@ void Player::SetRestType( RestType n_r_type, uint32 areaTriggerId /*= 0*/) inn_trigger_id = areaTriggerId; time_inn_enter = time(NULL); - if(sWorld.IsFFAPvPRealm()) + if (sWorld.IsFFAPvPRealm()) SetFFAPvP(false); } } @@ -23094,7 +23111,7 @@ uint32 Player::GetEquipGearScore(bool withBags, bool withBank) if (withBags && withBank && m_cachedGS > 0) return m_cachedGS; - GearScoreVec gearScore (EQUIPMENT_SLOT_END); + GearScoreVec gearScore(EQUIPMENT_SLOT_END); uint32 twoHandScore = 0; for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) @@ -23106,18 +23123,18 @@ uint32 Player::GetEquipGearScore(bool withBags, bool withBank) if (withBags) { // check inventory - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) + for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) { if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) _fillGearScoreData(item, &gearScore, twoHandScore); } // check bags - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { - if(Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) { - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { if (Item* item2 = pBag->GetItemByPos(j)) _fillGearScoreData(item2, &gearScore, twoHandScore); @@ -23164,7 +23181,7 @@ uint32 Player::GetEquipGearScore(bool withBags, bool withBank) for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) { - sum += gearScore[i]; + sum += gearScore[i]; } if (count) @@ -23242,8 +23259,8 @@ void Player::_fillGearScoreData(Item* item, GearScoreVec* gearScore, uint32& two case INVTYPE_HANDS: (*gearScore)[EQUIPMENT_SLOT_HEAD] = std::max((*gearScore)[EQUIPMENT_SLOT_HEAD], level); break; - // equipped gear score check uses both rings and trinkets for calculation, assume that for bags/banks it is the same - // with keeping second highest score at second slot + // equipped gear score check uses both rings and trinkets for calculation, assume that for bags/banks it is the same + // with keeping second highest score at second slot case INVTYPE_FINGER: { if ((*gearScore)[EQUIPMENT_SLOT_FINGER1] < level) diff --git a/src/game/Player.h b/src/game/Player.h index fc90e5205..447267e6f 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -105,7 +105,7 @@ struct PlayerSpell struct PlayerTalent { - TalentEntry const *talentEntry; + TalentEntry const* talentEntry; uint32 currentRank; PlayerSpellState state; }; @@ -153,7 +153,7 @@ enum ActionButtonType struct ActionButton { - ActionButton() : packedData(0), uState( ACTIONBUTTON_NEW ) {} + ActionButton() : packedData(0), uState(ACTIONBUTTON_NEW) {} uint32 packedData; ActionButtonUpdateState uState; @@ -202,16 +202,16 @@ struct Glyph void SetId(uint32 newId) { - if(newId == id) + if (newId == id) return; - if(id == 0 && uState == GLYPH_UNCHANGED) // not exist yet in db and already saved + if (id == 0 && uState == GLYPH_UNCHANGED) // not exist yet in db and already saved { uState = GLYPH_NEW; } else if (newId == 0) { - if(uState == GLYPH_NEW) // delete before add new -> no change + if (uState == GLYPH_NEW) // delete before add new -> no change uState = GLYPH_UNCHANGED; else // delete existing data uState = GLYPH_DELETED; @@ -251,7 +251,7 @@ struct PlayerClassInfo struct PlayerLevelInfo { - PlayerLevelInfo() { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; } + PlayerLevelInfo() { for (int i=0; i < MAX_STATS; ++i) stats[i] = 0; } uint8 stats[MAX_STATS]; }; @@ -272,7 +272,7 @@ typedef std::list PlayerCreateInfoActions; struct PlayerInfo { - // existence checked by displayId != 0 // existence checked by displayId != 0 + // existence checked by displayId != 0 // existence checked by displayId != 0 PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL) { } @@ -304,8 +304,8 @@ struct DuelInfo { DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0) {} - Player *initiator; - Player *opponent; + Player* initiator; + Player* opponent; time_t startTimer; time_t startTime; time_t outOfBound; @@ -347,7 +347,7 @@ struct Runes void SetRuneState(uint8 index, bool set = true) { - if(set) + if (set) runeState |= (1 << index); // usable else runeState &= ~(1 << index); // on cooldown @@ -357,9 +357,9 @@ struct Runes struct EnchantDuration { EnchantDuration() : item(NULL), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) {}; - EnchantDuration(Item * _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot), leftduration(_leftduration) { MANGOS_ASSERT(item); }; + EnchantDuration(Item* _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot), leftduration(_leftduration) { MANGOS_ASSERT(item); }; - Item * item; + Item* item; EnchantmentSlot slot; uint32 leftduration; }; @@ -685,7 +685,7 @@ struct EquipmentSet { EquipmentSet() : Guid(0), IgnoreMask(0), state(EQUIPMENT_SET_NEW) { - for(int i = 0; i < EQUIPMENT_SLOT_END; ++i) + for (int i = 0; i < EQUIPMENT_SLOT_END; ++i) Items[i] = 0; } @@ -871,7 +871,7 @@ enum ReputationSource struct InstancePlayerBind { - DungeonPersistentState *state; + DungeonPersistentState* state; bool perm; /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players that aren't already permanently bound when they are inside when a boss is killed @@ -905,7 +905,7 @@ class MANGOS_DLL_SPEC PlayerTaxi { uint8 field = uint8((nodeidx - 1) / 32); uint32 submask = 1<<((nodeidx-1)%32); - if ((m_taximask[field] & submask) != submask ) + if ((m_taximask[field] & submask) != submask) { m_taximask[field] |= submask; return true; @@ -946,7 +946,7 @@ struct BGData bgTeam(TEAM_NONE), mountSpell(0), m_needSave(false) { ClearTaxiPath(); } uint32 bgInstanceID; ///< This variable is set to bg->m_InstanceID, saved - /// when player is teleported to BG - (it is battleground's GUID) + /// when player is teleported to BG - (it is battleground's GUID) BattleGroundTypeId bgTypeID; std::set bgAfkReporter; @@ -1023,12 +1023,12 @@ class TradeData class MANGOS_DLL_SPEC Player : public Unit { - friend class WorldSession; - friend void Item::AddToUpdateQueueOf(Player *player); - friend void Item::RemoveFromUpdateQueueOf(Player *player); + friend class WorldSession; + friend void Item::AddToUpdateQueueOf(Player* player); + friend void Item::RemoveFromUpdateQueueOf(Player* player); public: - explicit Player (WorldSession *session); - ~Player ( ); + explicit Player(WorldSession* session); + ~Player(); void CleanupsBeforeDelete(); @@ -1040,7 +1040,7 @@ class MANGOS_DLL_SPEC Player : public Unit bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0); - bool TeleportTo(WorldLocation const &loc, uint32 options = 0) + bool TeleportTo(WorldLocation const& loc, uint32 options = 0) { return TeleportTo(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation, options); } @@ -1057,11 +1057,11 @@ class MANGOS_DLL_SPEC Player : public Unit } void SummonIfPossible(bool agree); - bool Create( uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId ); + bool Create(uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId); void Update(uint32 update_diff, uint32 time) override; - static bool BuildEnumData( QueryResult * result, WorldPacket * p_data ); + static bool BuildEnumData(QueryResult* result, WorldPacket* p_data); void SetInWater(bool apply); @@ -1085,37 +1085,37 @@ class MANGOS_DLL_SPEC Player : public Unit uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, uint32 newskintone); - PlayerSocial *GetSocial() { return m_social; } + PlayerSocial* GetSocial() { return m_social; } PlayerTaxi m_taxi; void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); } bool ActivateTaxiPathTo(std::vector const& nodes, Creature* npc = NULL, uint32 spellid = 0); bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0); - // mount_id can be used in scripting calls + // mount_id can be used in scripting calls void ContinueTaxiFlight(); bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER && (m_ExtraFlags & PLAYER_EXTRA_GM_ACCEPT_TICKETS); } - void SetAcceptTicket(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_ACCEPT_TICKETS; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS; } + void SetAcceptTicket(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_GM_ACCEPT_TICKETS; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS; } bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; } - void SetAcceptWhispers(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; } + void SetAcceptWhispers(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; } bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; } void SetGameMaster(bool on); bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR && (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT); } - void SetGMChat(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; } + void SetGMChat(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; } bool isTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; } - void SetTaxiCheater(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; } + void SetTaxiCheater(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; } bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); } void SetGMVisible(bool on); - void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; } + void SetPvPDeath(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; } // 0 = own auction, -1 = enemy auction, 1 = goblin auction int GetAuctionAccessMode() const { return m_ExtraFlags & PLAYER_EXTRA_AUCTION_ENEMY ? -1 : (m_ExtraFlags & PLAYER_EXTRA_AUCTION_NEUTRAL ? 1 : 0); } void SetAuctionAccessMode(int state) { - m_ExtraFlags &= ~ (PLAYER_EXTRA_AUCTION_ENEMY|PLAYER_EXTRA_AUCTION_NEUTRAL); + m_ExtraFlags &= ~(PLAYER_EXTRA_AUCTION_ENEMY|PLAYER_EXTRA_AUCTION_NEUTRAL); - if(state < 0) + if (state < 0) m_ExtraFlags |= PLAYER_EXTRA_AUCTION_ENEMY; - else if( state > 0) + else if (state > 0) m_ExtraFlags |= PLAYER_EXTRA_AUCTION_NEUTRAL; } @@ -1145,7 +1145,7 @@ class MANGOS_DLL_SPEC Player : public Unit void SetRestType(RestType n_r_type, uint32 areaTriggerId = 0); time_t GetTimeInnEnter() const { return time_inn_enter; } - void UpdateInnerTime (time_t time) { time_inn_enter = time; } + void UpdateInnerTime(time_t time) { time_inn_enter = time; } void RemovePet(PetSaveMode mode); @@ -1155,75 +1155,75 @@ class MANGOS_DLL_SPEC Player : public Unit void Yell(const std::string& text, const uint32 language); void TextEmote(const std::string& text); void Whisper(const std::string& text, const uint32 language, ObjectGuid receiver); - void BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const; + void BuildPlayerChat(WorldPacket* data, uint8 msgtype, const std::string& text, uint32 language) const; /*********************************************************/ /*** STORAGE SYSTEM ***/ /*********************************************************/ - void SetVirtualItemSlot( uint8 i, Item* item); - void SetSheath( SheathState sheathed ); // overwrite Unit version + void SetVirtualItemSlot(uint8 i, Item* item); + void SetSheath(SheathState sheathed); // overwrite Unit version uint8 FindEquipSlot(ItemPrototype const* proto, uint32 slot, bool swap) const; uint32 GetItemCount(uint32 item, bool inBankAlso = false, Item* skipItem = NULL) const; uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = NULL) const; Item* GetItemByGuid(ObjectGuid guid) const; Item* GetItemByEntry(uint32 item) const; // only for special cases Item* GetItemByLimitedCategory(uint32 limitedCategory) const; - Item* GetItemByPos( uint16 pos ) const; - Item* GetItemByPos( uint8 bag, uint8 slot ) const; + Item* GetItemByPos(uint16 pos) const; + Item* GetItemByPos(uint8 bag, uint8 slot) const; uint32 GetItemDisplayIdInSlot(uint8 bag, uint8 slot) const; Item* GetWeaponForAttack(WeaponAttackType attackType) const { return GetWeaponForAttack(attackType,false,false); } Item* GetWeaponForAttack(WeaponAttackType attackType, bool nonbroken, bool useable) const; Item* GetShield(bool useable = false) const; - static uint32 GetAttackBySlot( uint8 slot ); // MAX_ATTACK if not weapon slot - std::vector &GetItemUpdateQueue() { return m_itemUpdateQueue; } - static bool IsInventoryPos( uint16 pos ) { return IsInventoryPos(pos >> 8, pos & 255); } - static bool IsInventoryPos( uint8 bag, uint8 slot ); - static bool IsEquipmentPos( uint16 pos ) { return IsEquipmentPos(pos >> 8, pos & 255); } - static bool IsEquipmentPos( uint8 bag, uint8 slot ); - static bool IsBagPos( uint16 pos ); - static bool IsBankPos( uint16 pos ) { return IsBankPos(pos >> 8, pos & 255); } - static bool IsBankPos( uint8 bag, uint8 slot ); - bool IsValidPos( uint16 pos, bool explicit_pos ) const { return IsValidPos(pos >> 8, pos & 255, explicit_pos); } - bool IsValidPos( uint8 bag, uint8 slot, bool explicit_pos ) const; + static uint32 GetAttackBySlot(uint8 slot); // MAX_ATTACK if not weapon slot + std::vector& GetItemUpdateQueue() { return m_itemUpdateQueue; } + static bool IsInventoryPos(uint16 pos) { return IsInventoryPos(pos >> 8, pos & 255); } + static bool IsInventoryPos(uint8 bag, uint8 slot); + static bool IsEquipmentPos(uint16 pos) { return IsEquipmentPos(pos >> 8, pos & 255); } + static bool IsEquipmentPos(uint8 bag, uint8 slot); + static bool IsBagPos(uint16 pos); + static bool IsBankPos(uint16 pos) { return IsBankPos(pos >> 8, pos & 255); } + static bool IsBankPos(uint8 bag, uint8 slot); + bool IsValidPos(uint16 pos, bool explicit_pos) const { return IsValidPos(pos >> 8, pos & 255, explicit_pos); } + bool IsValidPos(uint8 bag, uint8 slot, bool explicit_pos) const; uint8 GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2, 2); } void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_2, 2, count); } - bool HasItemCount( uint32 item, uint32 count, bool inBankAlso = false) const; + bool HasItemCount(uint32 item, uint32 count, bool inBankAlso = false) const; bool HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem = NULL); bool CanNoReagentCast(SpellEntry const* spellInfo) const; - bool HasItemOrGemWithIdEquipped( uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const; - bool HasItemOrGemWithLimitCategoryEquipped( uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const; + bool HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const; + bool HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const; InventoryResult CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(), pItem->GetCount(), pItem); } InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return _CanTakeMoreSimilarItems(entry, count, NULL); } - InventoryResult CanStoreNewItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL ) const + InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL) const { - return _CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count ); + return _CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count); } - InventoryResult CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap = false ) const + InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap = false) const { - if(!pItem) + if (!pItem) return EQUIP_ERR_ITEM_NOT_FOUND; uint32 count = pItem->GetCount(); - return _CanStoreItem( bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL ); + return _CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL); } - InventoryResult CanStoreItems(Item **pItem,int count) const; - InventoryResult CanEquipNewItem(uint8 slot, uint16 &dest, uint32 item, bool swap) const; - InventoryResult CanEquipItem(uint8 slot, uint16 &dest, Item *pItem, bool swap, bool direct_action = true) const; + InventoryResult CanStoreItems(Item** pItem,int count) const; + InventoryResult CanEquipNewItem(uint8 slot, uint16& dest, uint32 item, bool swap) const; + InventoryResult CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool swap, bool direct_action = true) const; - InventoryResult CanEquipUniqueItem( Item * pItem, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const; - InventoryResult CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const; - InventoryResult CanUnequipItems( uint32 item, uint32 count ) const; - InventoryResult CanUnequipItem( uint16 src, bool swap ) const; - InventoryResult CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const; - InventoryResult CanUseItem(Item *pItem, bool direct_action = true) const; + InventoryResult CanEquipUniqueItem(Item* pItem, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1) const; + InventoryResult CanEquipUniqueItem(ItemPrototype const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1) const; + InventoryResult CanUnequipItems(uint32 item, uint32 count) const; + InventoryResult CanUnequipItem(uint16 src, bool swap) const; + InventoryResult CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap, bool not_loading = true) const; + InventoryResult CanUseItem(Item* pItem, bool direct_action = true) const; bool HasItemTotemCategory(uint32 TotemCategory) const; - InventoryResult CanUseItem(ItemPrototype const *pItem) const; - InventoryResult CanUseAmmo( uint32 item ) const; - Item* StoreNewItem( ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0 ); - Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update ); - Item* EquipNewItem( uint16 pos, uint32 item, bool update ); - Item* EquipItem( uint16 pos, Item *pItem, bool update ); + InventoryResult CanUseItem(ItemPrototype const* pItem) const; + InventoryResult CanUseAmmo(uint32 item) const; + Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0); + Item* StoreItem(ItemPosCountVec const& pos, Item* pItem, bool update); + Item* EquipNewItem(uint16 pos, uint32 item, bool update); + Item* EquipItem(uint16 pos, Item* pItem, bool update); void AutoUnequipOffhandIfNeed(); bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count); Item* StoreNewItemInInventorySlot(uint32 itemEntry, uint32 amount); @@ -1234,44 +1234,44 @@ class MANGOS_DLL_SPEC Player : public Unit Item* ConvertItem(Item* item, uint32 newItemId); InventoryResult _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const; - InventoryResult _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const; + InventoryResult _CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem = NULL, bool swap = false, uint32* no_space_count = NULL) const; - void ApplyEquipCooldown( Item * pItem ); - void SetAmmo( uint32 item ); + void ApplyEquipCooldown(Item* pItem); + void SetAmmo(uint32 item); void RemoveAmmo(); float GetAmmoDPS() const { return m_ammoDPS; } - bool CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const; - void QuickEquipItem( uint16 pos, Item *pItem); - void VisualizeItem( uint8 slot, Item *pItem); - void SetVisibleItemSlot(uint8 slot, Item *pItem); - Item* BankItem( ItemPosCountVec const& dest, Item *pItem, bool update ) + bool CheckAmmoCompatibility(const ItemPrototype* ammo_proto) const; + void QuickEquipItem(uint16 pos, Item* pItem); + void VisualizeItem(uint8 slot, Item* pItem); + void SetVisibleItemSlot(uint8 slot, Item* pItem); + Item* BankItem(ItemPosCountVec const& dest, Item* pItem, bool update) { - return StoreItem( dest, pItem, update); + return StoreItem(dest, pItem, update); } - Item* BankItem(uint16 pos, Item *pItem, bool update); + Item* BankItem(uint16 pos, Item* pItem, bool update); void RemoveItem(uint8 bag, uint8 slot, bool update);// see ApplyItemOnStoreSpell notes void MoveItemFromInventory(uint8 bag, uint8 slot, bool update); - // in trade, auction, guild bank, mail.... + // in trade, auction, guild bank, mail.... void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false); - // in trade, guild bank, mail.... - void RemoveItemDependentAurasAndCasts( Item * pItem ); - void DestroyItem( uint8 bag, uint8 slot, bool update ); + // in trade, guild bank, mail.... + void RemoveItemDependentAurasAndCasts(Item* pItem); + void DestroyItem(uint8 bag, uint8 slot, bool update); void DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check = false, bool inBankAlso = false); - void DestroyItemCount( Item* item, uint32& count, bool update ); - void DestroyConjuredItems( bool update ); - void DestroyZoneLimitedItem( bool update, uint32 new_zone ); - void SplitItem( uint16 src, uint16 dst, uint32 count ); - void SwapItem( uint16 src, uint16 dst ); - void AddItemToBuyBackSlot( Item *pItem ); - Item* GetItemFromBuyBackSlot( uint32 slot ); - void RemoveItemFromBuyBackSlot( uint32 slot, bool del ); + void DestroyItemCount(Item* item, uint32& count, bool update); + void DestroyConjuredItems(bool update); + void DestroyZoneLimitedItem(bool update, uint32 new_zone); + void SplitItem(uint16 src, uint16 dst, uint32 count); + void SwapItem(uint16 src, uint16 dst); + void AddItemToBuyBackSlot(Item* pItem); + Item* GetItemFromBuyBackSlot(uint32 slot); + void RemoveItemFromBuyBackSlot(uint32 slot, bool del); void TakeExtendedCost(uint32 extendedCostId, uint32 count); uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; } - void SendEquipError( InventoryResult msg, Item* pItem, Item *pItem2 = NULL, uint32 itemid = 0 ) const; - void SendBuyError( BuyResult msg, Creature* pCreature, uint32 item, uint32 param ); - void SendSellError( SellResult msg, Creature* pCreature, ObjectGuid itemGuid, uint32 param ); + void SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2 = NULL, uint32 itemid = 0) const; + void SendBuyError(BuyResult msg, Creature* pCreature, uint32 item, uint32 param); + void SendSellError(SellResult msg, Creature* pCreature, ObjectGuid itemGuid, uint32 param); void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; } void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; } uint32 GetWeaponProficiency() const { return m_WeaponProficiency; } @@ -1287,10 +1287,10 @@ class MANGOS_DLL_SPEC Player : public Unit Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); return offItem && ((mainItem && mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON) || offItem->GetProto()->InventoryType == INVTYPE_2HWEAPON); } - void SendNewItem( Item *item, uint32 count, bool received, bool created, bool broadcast = false ); + void SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast = false); bool BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot); - float GetReputationPriceDiscount( Creature const* pCreature ) const; + float GetReputationPriceDiscount(Creature const* pCreature) const; Player* GetTrader() const { return m_trade ? m_trade->GetTrader() : NULL; } TradeData* GetTradeData() const { return m_trade; } @@ -1298,16 +1298,16 @@ class MANGOS_DLL_SPEC Player : public Unit void UpdateEnchantTime(uint32 time); void UpdateItemDuration(uint32 time, bool realtimeonly=false); - void AddEnchantmentDurations(Item *item); - void RemoveEnchantmentDurations(Item *item); + void AddEnchantmentDurations(Item* item); + void RemoveEnchantmentDurations(Item* item); void RemoveAllEnchantments(EnchantmentSlot slot); - void AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration); - void ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur = true, bool ignore_condition = false); - void ApplyEnchantment(Item *item,bool apply); + void AddEnchantmentDuration(Item* item,EnchantmentSlot slot,uint32 duration); + void ApplyEnchantment(Item* item,EnchantmentSlot slot,bool apply, bool apply_dur = true, bool ignore_condition = false); + void ApplyEnchantment(Item* item,bool apply); void SendEnchantmentDurations(); - void BuildEnchantmentsInfoData(WorldPacket *data); - void AddItemDurations(Item *item); - void RemoveItemDurations(Item *item); + void BuildEnchantmentsInfoData(WorldPacket* data); + void AddItemDurations(Item* item); + void RemoveItemDurations(Item* item); void SendItemDurations(); void LoadCorpse(); void LoadPet(); @@ -1322,13 +1322,13 @@ class MANGOS_DLL_SPEC Player : public Unit /*** GOSSIP SYSTEM ***/ /*********************************************************/ - void PrepareGossipMenu(WorldObject *pSource, uint32 menuId = 0); - void SendPreparedGossip(WorldObject *pSource); - void OnGossipSelect(WorldObject *pSource, uint32 gossipListId, uint32 menuId); + void PrepareGossipMenu(WorldObject* pSource, uint32 menuId = 0); + void SendPreparedGossip(WorldObject* pSource); + void OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 menuId); uint32 GetGossipTextId(uint32 menuId, WorldObject* pSource); - uint32 GetGossipTextId(WorldObject *pSource); - uint32 GetDefaultGossipMenuForSource(WorldObject *pSource); + uint32 GetGossipTextId(WorldObject* pSource); + uint32 GetDefaultGossipMenuForSource(WorldObject* pSource); /*********************************************************/ /*** QUEST SYSTEM ***/ @@ -1337,9 +1337,9 @@ class MANGOS_DLL_SPEC Player : public Unit // Return player level when QuestLevel is dynamic (-1) uint32 GetQuestLevelForPlayer(Quest const* pQuest) const { return pQuest && (pQuest->GetQuestLevel() > 0) ? (uint32)pQuest->GetQuestLevel() : getLevel(); } - void PrepareQuestMenu(ObjectGuid guid ); + void PrepareQuestMenu(ObjectGuid guid); void SendPreparedQuest(ObjectGuid guid); - bool IsActiveQuest( uint32 quest_id ) const; // can be taken or taken + bool IsActiveQuest(uint32 quest_id) const; // can be taken or taken // Quest is taken and not yet rewarded // if completed_or_not = 0 (or any other value except 1 or 2) - returns true, if quest is taken and doesn't depend if quest is completed or not @@ -1347,50 +1347,50 @@ class MANGOS_DLL_SPEC Player : public Unit // if completed_or_not = 2 - returns true, if quest is taken and already completed bool IsCurrentQuest(uint32 quest_id, uint8 completed_or_not = 0) const; // taken and not yet rewarded - Quest const *GetNextQuest(ObjectGuid guid, Quest const *pQuest ); - bool CanSeeStartQuest( Quest const *pQuest ) const; - bool CanTakeQuest( Quest const *pQuest, bool msg ) const; - bool CanAddQuest( Quest const *pQuest, bool msg ) const; - bool CanCompleteQuest( uint32 quest_id ) const; - bool CanCompleteRepeatableQuest(Quest const *pQuest) const; - bool CanRewardQuest( Quest const *pQuest, bool msg ) const; - bool CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg ) const; - void AddQuest( Quest const *pQuest, Object *questGiver ); - void CompleteQuest( uint32 quest_id ); - void IncompleteQuest( uint32 quest_id ); - void RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true); + Quest const* GetNextQuest(ObjectGuid guid, Quest const* pQuest); + bool CanSeeStartQuest(Quest const* pQuest) const; + bool CanTakeQuest(Quest const* pQuest, bool msg) const; + bool CanAddQuest(Quest const* pQuest, bool msg) const; + bool CanCompleteQuest(uint32 quest_id) const; + bool CanCompleteRepeatableQuest(Quest const* pQuest) const; + bool CanRewardQuest(Quest const* pQuest, bool msg) const; + bool CanRewardQuest(Quest const* pQuest, uint32 reward, bool msg) const; + void AddQuest(Quest const* pQuest, Object* questGiver); + void CompleteQuest(uint32 quest_id); + void IncompleteQuest(uint32 quest_id); + void RewardQuest(Quest const* pQuest, uint32 reward, Object* questGiver, bool announce = true); - void FailQuest( uint32 quest_id ); + void FailQuest(uint32 quest_id); bool SatisfyQuestSkill(Quest const* qInfo, bool msg) const; - bool SatisfyQuestLevel( Quest const* qInfo, bool msg ) const; - bool SatisfyQuestLog( bool msg ) const; - bool SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) const; + bool SatisfyQuestLevel(Quest const* qInfo, bool msg) const; + bool SatisfyQuestLog(bool msg) const; + bool SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) const; bool SatisfyQuestClass(Quest const* qInfo, bool msg) const; - bool SatisfyQuestRace( Quest const* qInfo, bool msg ) const; - bool SatisfyQuestReputation( Quest const* qInfo, bool msg ) const; - bool SatisfyQuestStatus( Quest const* qInfo, bool msg ) const; - bool SatisfyQuestTimed( Quest const* qInfo, bool msg ) const; - bool SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg ) const; - bool SatisfyQuestNextChain( Quest const* qInfo, bool msg ) const; - bool SatisfyQuestPrevChain( Quest const* qInfo, bool msg ) const; - bool SatisfyQuestDay( Quest const* qInfo, bool msg ) const; - bool SatisfyQuestWeek( Quest const* qInfo, bool msg ) const; + bool SatisfyQuestRace(Quest const* qInfo, bool msg) const; + bool SatisfyQuestReputation(Quest const* qInfo, bool msg) const; + bool SatisfyQuestStatus(Quest const* qInfo, bool msg) const; + bool SatisfyQuestTimed(Quest const* qInfo, bool msg) const; + bool SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const; + bool SatisfyQuestNextChain(Quest const* qInfo, bool msg) const; + bool SatisfyQuestPrevChain(Quest const* qInfo, bool msg) const; + bool SatisfyQuestDay(Quest const* qInfo, bool msg) const; + bool SatisfyQuestWeek(Quest const* qInfo, bool msg) const; bool SatisfyQuestMonth(Quest const* qInfo, bool msg) const; - bool CanGiveQuestSourceItemIfNeed( Quest const *pQuest, ItemPosCountVec* dest = NULL) const; - void GiveQuestSourceItemIfNeed(Quest const *pQuest); - bool TakeQuestSourceItem( uint32 quest_id, bool msg ); - bool GetQuestRewardStatus( uint32 quest_id ) const; - QuestStatus GetQuestStatus( uint32 quest_id ) const; - void SetQuestStatus( uint32 quest_id, QuestStatus status ); + bool CanGiveQuestSourceItemIfNeed(Quest const* pQuest, ItemPosCountVec* dest = NULL) const; + void GiveQuestSourceItemIfNeed(Quest const* pQuest); + bool TakeQuestSourceItem(uint32 quest_id, bool msg); + bool GetQuestRewardStatus(uint32 quest_id) const; + QuestStatus GetQuestStatus(uint32 quest_id) const; + void SetQuestStatus(uint32 quest_id, QuestStatus status); - void SetDailyQuestStatus( uint32 quest_id ); - void SetWeeklyQuestStatus( uint32 quest_id ); + void SetDailyQuestStatus(uint32 quest_id); + void SetWeeklyQuestStatus(uint32 quest_id); void SetMonthlyQuestStatus(uint32 quest_id); void ResetDailyQuestStatus(); void ResetWeeklyQuestStatus(); void ResetMonthlyQuestStatus(); - uint16 FindQuestSlot( uint32 quest_id ) const; + uint16 FindQuestSlot(uint32 quest_id) const; uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET); } void SetQuestSlot(uint16 slot, uint32 quest_id, uint32 timer = 0) { @@ -1422,28 +1422,28 @@ class MANGOS_DLL_SPEC Player : public Unit } } uint32 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry); - void AreaExploredOrEventHappens( uint32 questId ); - void GroupEventHappens( uint32 questId, WorldObject const* pEventObject ); - void ItemAddedQuestCheck( uint32 entry, uint32 count ); - void ItemRemovedQuestCheck( uint32 entry, uint32 count ); - void KilledMonster( CreatureInfo const* cInfo, ObjectGuid guid ); - void KilledMonsterCredit( uint32 entry, ObjectGuid guid = ObjectGuid()); - void CastedCreatureOrGO( uint32 entry, ObjectGuid guid, uint32 spell_id, bool original_caster = true ); - void TalkedToCreature( uint32 entry, ObjectGuid guid ); - void MoneyChanged( uint32 value ); - void ReputationChanged(FactionEntry const* factionEntry ); - bool HasQuestForItem( uint32 itemid ) const; + void AreaExploredOrEventHappens(uint32 questId); + void GroupEventHappens(uint32 questId, WorldObject const* pEventObject); + void ItemAddedQuestCheck(uint32 entry, uint32 count); + void ItemRemovedQuestCheck(uint32 entry, uint32 count); + void KilledMonster(CreatureInfo const* cInfo, ObjectGuid guid); + void KilledMonsterCredit(uint32 entry, ObjectGuid guid = ObjectGuid()); + void CastedCreatureOrGO(uint32 entry, ObjectGuid guid, uint32 spell_id, bool original_caster = true); + void TalkedToCreature(uint32 entry, ObjectGuid guid); + void MoneyChanged(uint32 value); + void ReputationChanged(FactionEntry const* factionEntry); + bool HasQuestForItem(uint32 itemid) const; bool HasQuestForGO(int32 GOId) const; void UpdateForQuestWorldObjects(); bool CanShareQuest(uint32 quest_id) const; void SendQuestCompleteEvent(uint32 quest_id); - void SendQuestReward( Quest const *pQuest, uint32 XP, Object* questGiver ); - void SendQuestFailed( uint32 quest_id, InventoryResult reason = EQUIP_ERR_OK); - void SendQuestTimerFailed( uint32 quest_id ); - void SendCanTakeQuestResponse( uint32 msg ) const; + void SendQuestReward(Quest const* pQuest, uint32 XP, Object* questGiver); + void SendQuestFailed(uint32 quest_id, InventoryResult reason = EQUIP_ERR_OK); + void SendQuestTimerFailed(uint32 quest_id); + void SendCanTakeQuestResponse(uint32 msg) const; void SendQuestConfirmAccept(Quest const* pQuest, Player* pReceiver); - void SendPushToPartyResponse( Player *pPlayer, uint32 msg ); + void SendPushToPartyResponse(Player* pPlayer, uint32 msg); void SendQuestUpdateAddCreatureOrGo(Quest const* pQuest, ObjectGuid guid, uint32 creatureOrGO_idx, uint32 count); ObjectGuid GetDividerGuid() const { return m_dividerGuid; } @@ -1452,16 +1452,16 @@ class MANGOS_DLL_SPEC Player : public Unit uint32 GetInGameTime() { return m_ingametime; } - void SetInGameTime( uint32 time ) { m_ingametime = time; } + void SetInGameTime(uint32 time) { m_ingametime = time; } - void AddTimedQuest( uint32 quest_id ) { m_timedquests.insert(quest_id); } - void RemoveTimedQuest( uint32 quest_id ) { m_timedquests.erase(quest_id); } + void AddTimedQuest(uint32 quest_id) { m_timedquests.insert(quest_id); } + void RemoveTimedQuest(uint32 quest_id) { m_timedquests.erase(quest_id); } /*********************************************************/ /*** LOAD SYSTEM ***/ /*********************************************************/ - bool LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder); + bool LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder); static uint32 GetZoneIdFromDB(ObjectGuid guid); static uint32 GetLevelFromDB(ObjectGuid guid); @@ -1489,37 +1489,37 @@ class MANGOS_DLL_SPEC Player : public Unit void SetBindPoint(ObjectGuid guid); void SendTalentWipeConfirm(ObjectGuid guid); - void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker ); + void RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacker); void SendPetSkillWipeConfirm(); - void CalcRage( uint32 damage,bool attacker ); + void CalcRage(uint32 damage,bool attacker); void RegenerateAll(uint32 diff = REGEN_TIME_FULL); void Regenerate(Powers power, uint32 diff); void RegenerateHealth(uint32 diff); void setRegenTimer(uint32 time) {m_regenTimer = time;} void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;} - uint32 GetMoney() const { return GetUInt32Value (PLAYER_FIELD_COINAGE); } - void ModifyMoney( int32 d ) + uint32 GetMoney() const { return GetUInt32Value(PLAYER_FIELD_COINAGE); } + void ModifyMoney(int32 d) { - if(d < 0) - SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0); + if (d < 0) + SetMoney(GetMoney() > uint32(-d) ? GetMoney() + d : 0); else - SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT); + SetMoney(GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT); // "At Gold Limit" - if(GetMoney() >= MAX_MONEY_AMOUNT) + if (GetMoney() >= MAX_MONEY_AMOUNT) SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD,NULL,NULL); } - void SetMoney( uint32 value ) + void SetMoney(uint32 value) { - SetUInt32Value (PLAYER_FIELD_COINAGE, value); - MoneyChanged( value ); + SetUInt32Value(PLAYER_FIELD_COINAGE, value); + MoneyChanged(value); UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED); } QuestStatusMap& getQuestStatusMap() { return mQuestStatus; }; - ObjectGuid const& GetSelectionGuid( ) const { return m_curSelectionGuid; } + ObjectGuid const& GetSelectionGuid() const { return m_curSelectionGuid; } void SetSelectionGuid(ObjectGuid guid) { m_curSelectionGuid = guid; SetTargetGuid(guid); } uint8 GetComboPoints() const { return m_comboPoints; } @@ -1562,7 +1562,7 @@ class MANGOS_DLL_SPEC Player : public Unit void AddMItem(Item* it) { - MANGOS_ASSERT( it ); + MANGOS_ASSERT(it); //ASSERT deleted, because items can be added before loading mMitems[it->GetGUIDLow()] = it; } @@ -1602,8 +1602,8 @@ class MANGOS_DLL_SPEC Player : public Unit bool resetTalents(bool no_cost = false, bool all_specs = false); uint32 resetTalentsCost() const; void InitTalentForLevel(); - void BuildPlayerTalentsInfoData(WorldPacket *data); - void BuildPetTalentsInfoData(WorldPacket *data); + void BuildPlayerTalentsInfoData(WorldPacket* data); + void BuildPetTalentsInfoData(WorldPacket* data); void SendTalentsInfoData(bool pet); void LearnTalent(uint32 talentId, uint32 talentRank); void LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank); @@ -1631,7 +1631,7 @@ class MANGOS_DLL_SPEC Player : public Unit void InitPrimaryProfessions(); PlayerSpellMap const& GetSpellMap() const { return m_spells; } - PlayerSpellMap & GetSpellMap() { return m_spells; } + PlayerSpellMap& GetSpellMap() { return m_spells; } SpellCooldowns const& GetSpellCooldownMap() const { return m_spellCooldowns; } @@ -1639,7 +1639,7 @@ class MANGOS_DLL_SPEC Player : public Unit SpellEntry const* GetKnownTalentRankById(int32 talentId) const; void AddSpellMod(Aura* aura, bool apply); - template T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell = NULL); + template T ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell const* spell = NULL); static uint32 const infinityCooldownDelay = MONTH; // used for set "infinity cooldowns" for spells and check static uint32 const infinityCooldownDelayCheck = MONTH/2; @@ -1654,19 +1654,19 @@ class MANGOS_DLL_SPEC Player : public Unit time_t t = time(NULL); return itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0; } - void AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false ); + void AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false); void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time); - void SendCooldownEvent(SpellEntry const *spellInfo, uint32 itemId = 0, Spell* spell = NULL); - void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs ); + void SendCooldownEvent(SpellEntry const* spellInfo, uint32 itemId = 0, Spell* spell = NULL); + void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); void RemoveSpellCooldown(uint32 spell_id, bool update = false); void RemoveSpellCategoryCooldown(uint32 cat, bool update = false); - void SendClearCooldown( uint32 spell_id, Unit* target ); + void SendClearCooldown(uint32 spell_id, Unit* target); GlobalCooldownMgr& GetGlobalCooldownMgr() { return m_GlobalCooldownMgr; } void RemoveArenaSpellCooldowns(); void RemoveAllSpellCooldown(); - void _LoadSpellCooldowns(QueryResult *result); + void _LoadSpellCooldowns(QueryResult* result); void _SaveSpellCooldowns(); void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; } uint32 GetLastPotionId() { return m_lastPotionId; } @@ -1719,7 +1719,7 @@ class MANGOS_DLL_SPEC Player : public Unit } /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/ - DuelInfo *duel; + DuelInfo* duel; bool IsInDuelWith(Player const* player) const { return duel && duel->opponent == player && duel->startTime != 0; } void UpdateDuelFlag(time_t currTime); void CheckDuelDistance(time_t currTime); @@ -1737,11 +1737,11 @@ class MANGOS_DLL_SPEC Player : public Unit bool GetAllowLowLevelRaid() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_ENABLE_LOW_LEVEL_RAID); } void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); } - void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); } + void SetRank(uint32 rankId) { SetUInt32Value(PLAYER_GUILDRANK, rankId); } void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); } static uint32 GetGuildIdFromDB(ObjectGuid guid); - uint32 GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK); } + uint32 GetRank() { return GetUInt32Value(PLAYER_GUILDRANK); } static uint32 GetRankFromDB(ObjectGuid guid); int GetGuildIdInvited() { return m_GuildIdInvited; } static void RemovePetitionsAndSigns(ObjectGuid guid, uint32 type); @@ -1779,7 +1779,7 @@ class MANGOS_DLL_SPEC Player : public Unit uint32 GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE); } uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const; - uint32 GetSpellByProto(ItemPrototype *proto); + uint32 GetSpellByProto(ItemPrototype* proto); float GetHealthBonusFromStamina(); float GetManaBonusFromIntellect(); @@ -1804,7 +1804,7 @@ class MANGOS_DLL_SPEC Player : public Unit void UpdateDefenseBonusesMod(); float GetMeleeCritFromAgility(); - void GetDodgeFromAgility(float &diminishing, float &nondiminishing); + void GetDodgeFromAgility(float& diminishing, float& nondiminishing); float GetSpellCritFromIntellect(); float OCTRegenHPPerSpirit(); float OCTRegenMPPerSpirit(); @@ -1835,10 +1835,10 @@ class MANGOS_DLL_SPEC Player : public Unit void RemovedInsignia(Player* looterPlr); WorldSession* GetSession() const { return m_session; } - void SetSession(WorldSession *s) { m_session = s; } + void SetSession(WorldSession* s) { m_session = s; } - void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const; - void DestroyForPlayer( Player *target, bool anim = false ) const; + void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const; + void DestroyForPlayer(Player* target, bool anim = false) const; void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP); uint8 LastSwingErrorMsg() const { return m_swingErrorMsg; } @@ -1850,7 +1850,7 @@ class MANGOS_DLL_SPEC Player : public Unit void SendAttackSwingDeadTarget(); void SendAttackSwingNotInRange(); void SendAttackSwingBadFacingAttack(); - void SendAutoRepeatCancel(Unit *target); + void SendAutoRepeatCancel(Unit* target); void SendExplorationExperience(uint32 Area, uint32 Experience); void SendDungeonDifficulty(bool IsInGroup); @@ -1861,14 +1861,14 @@ class MANGOS_DLL_SPEC Player : public Unit void SendResetFailedNotify(uint32 mapid); bool SetPosition(float x, float y, float z, float orientation, bool teleport = false); - void UpdateUnderwaterState( Map * m, float x, float y, float z ); + void UpdateUnderwaterState(Map* m, float x, float y, float z); - void SendMessageToSet(WorldPacket *data, bool self);// overwrite Object::SendMessageToSet - void SendMessageToSetInRange(WorldPacket *data, float fist, bool self); - // overwrite Object::SendMessageToSetInRange - void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only); + void SendMessageToSet(WorldPacket* data, bool self);// overwrite Object::SendMessageToSet + void SendMessageToSetInRange(WorldPacket* data, float fist, bool self); + // overwrite Object::SendMessageToSetInRange + void SendMessageToSetInRange(WorldPacket* data, float dist, bool self, bool own_team_only); - Corpse *GetCorpse() const; + Corpse* GetCorpse() const; void SpawnCorpseBones(); Corpse* CreateCorpse(); void KillPlayer(); @@ -1895,15 +1895,15 @@ class MANGOS_DLL_SPEC Player : public Unit void SetMovement(PlayerMovementType pType); - void JoinedChannel(Channel *c); - void LeftChannel(Channel *c); + void JoinedChannel(Channel* c); + void LeftChannel(Channel* c); void CleanupChannels(); - void UpdateLocalChannels( uint32 newZone ); + void UpdateLocalChannels(uint32 newZone); void LeaveLFGChannel(); void UpdateDefense(); - void UpdateWeaponSkill (WeaponAttackType attType); - void UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool defence); + void UpdateWeaponSkill(WeaponAttackType attType); + void UpdateCombatSkills(Unit* pVictim, WeaponAttackType attType, bool defence); void SetSkill(uint16 id, uint16 currVal, uint16 maxVal, uint16 step = 0); uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus @@ -1942,8 +1942,8 @@ class MANGOS_DLL_SPEC Player : public Unit ReputationMgr& GetReputationMgr() { return m_reputationMgr; } ReputationMgr const& GetReputationMgr() const { return m_reputationMgr; } ReputationRank GetReputationRank(uint32 faction_id) const; - void RewardReputation(Unit *pVictim, float rate); - void RewardReputation(Quest const *pQuest); + void RewardReputation(Unit* pVictim, float rate); + void RewardReputation(Quest const* pQuest); int32 CalculateReputationGain(ReputationSource source, int32 rep, int32 faction, uint32 creatureOrQuestLevel = 0, bool noAuraBonus = false); void UpdateSkillsForLevel(); @@ -1955,7 +1955,7 @@ class MANGOS_DLL_SPEC Player : public Unit /*********************************************************/ void UpdateArenaFields(); void UpdateHonorFields(); - bool RewardHonor(Unit *pVictim, uint32 groupsize, float honor = -1); + bool RewardHonor(Unit* pVictim, uint32 groupsize, float honor = -1); uint32 GetHonorPoints() const { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); } uint32 GetArenaPoints() const { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); } void SetHonorPoints(uint32 value); @@ -1998,28 +1998,28 @@ class MANGOS_DLL_SPEC Player : public Unit float GetArmorPenetrationPct() const { return m_armorPenetrationPct; } int32 GetSpellPenetrationItemMod() const { return m_spellPenetrationItemMod; } - void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply); - void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); - void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); + void _ApplyWeaponDependentAuraMods(Item* item, WeaponAttackType attackType, bool apply); + void _ApplyWeaponDependentAuraCritMod(Item* item, WeaponAttackType attackType, Aura* aura, bool apply); + void _ApplyWeaponDependentAuraDamageMod(Item* item, WeaponAttackType attackType, Aura* aura, bool apply); - void _ApplyItemMods(Item *item,uint8 slot,bool apply); + void _ApplyItemMods(Item* item,uint8 slot,bool apply); void _RemoveAllItemMods(); void _ApplyAllItemMods(); void _ApplyAllLevelScaleItemMods(bool apply); - void _ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply, bool only_level_scale = false); + void _ApplyItemBonuses(ItemPrototype const* proto,uint8 slot,bool apply, bool only_level_scale = false); void _ApplyAmmoBonuses(); bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot); void ToggleMetaGemsActive(uint8 exceptslot, bool apply); void CorrectMetaGemEnchants(uint8 slot, bool apply); void InitDataForForm(bool reapplyMods = false); - void ApplyItemEquipSpell(Item *item, bool apply, bool form_change = false); + void ApplyItemEquipSpell(Item* item, bool apply, bool form_change = false); void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false); void UpdateEquipSpellsAtFormChange(); void CastItemCombatSpell(Unit* Target, WeaponAttackType attType); - void CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex); + void CastItemUseSpell(Item* item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex); - void ApplyItemOnStoreSpell(Item *item, bool apply); + void ApplyItemOnStoreSpell(Item* item, bool apply); void DestroyItemWithOnStoreSpell(Item* item, uint32 spellId); void SendEquipmentSetList(); @@ -2028,16 +2028,16 @@ class MANGOS_DLL_SPEC Player : public Unit void SendInitWorldStates(uint32 zone, uint32 area); void SendUpdateWorldState(uint32 Field, uint32 Value); - void SendDirectMessage(WorldPacket *data); + void SendDirectMessage(WorldPacket* data); void FillBGWeekendWorldStates(WorldPacket& data, uint32& count); - void SendAurasForTarget(Unit *target); + void SendAurasForTarget(Unit* target); PlayerMenu* PlayerTalkClass; - std::vector ItemSetEff; + std::vector ItemSetEff; void SendLoot(ObjectGuid guid, LootType loot_type); - void SendLootRelease(ObjectGuid guid ); + void SendLootRelease(ObjectGuid guid); void SendNotifyLootItemRemoved(uint8 lootSlot); void SendNotifyLootMoneyRemoved(); @@ -2207,8 +2207,8 @@ class MANGOS_DLL_SPEC Player : public Unit ObjectGuid const& GetFarSightGuid() const { return GetGuidValue(PLAYER_FARSIGHT); } // Transports - Transport * GetTransport() const { return m_transport; } - void SetTransport(Transport * t) { m_transport = t; } + Transport* GetTransport() const { return m_transport; } + void SetTransport(Transport* t) { m_transport = t; } float GetTransOffsetX() const { return m_movementInfo.GetTransportPos()->x; } float GetTransOffsetY() const { return m_movementInfo.GetTransportPos()->y; } @@ -2245,7 +2245,7 @@ class MANGOS_DLL_SPEC Player : public Unit void UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* target); template - void UpdateVisibilityOf(WorldObject const* viewPoint,T* target, UpdateData& data, std::set& visibleNow); + void UpdateVisibilityOf(WorldObject const* viewPoint,T* target, UpdateData& data, std::set& visibleNow); // Stealth detection system void HandleStealthedUnitsDetection(); @@ -2285,23 +2285,23 @@ class MANGOS_DLL_SPEC Player : public Unit InstancePlayerBind* GetBoundInstance(uint32 mapid, Difficulty difficulty); BoundInstancesMap& GetBoundInstances(Difficulty difficulty) { return m_boundInstances[difficulty]; } void UnbindInstance(uint32 mapid, Difficulty difficulty, bool unload = false); - void UnbindInstance(BoundInstancesMap::iterator &itr, Difficulty difficulty, bool unload = false); - InstancePlayerBind* BindToInstance(DungeonPersistentState *save, bool permanent, bool load = false); + void UnbindInstance(BoundInstancesMap::iterator& itr, Difficulty difficulty, bool unload = false); + InstancePlayerBind* BindToInstance(DungeonPersistentState* save, bool permanent, bool load = false); void SendRaidInfo(); void SendSavedInstances(); - static void ConvertInstancesToGroup(Player *player, Group *group = NULL, ObjectGuid player_guid = ObjectGuid()); + static void ConvertInstancesToGroup(Player* player, Group* group = NULL, ObjectGuid player_guid = ObjectGuid()); DungeonPersistentState* GetBoundInstanceSaveForSelfOrGroup(uint32 mapid); /*********************************************************/ /*** GROUP SYSTEM ***/ /*********************************************************/ - Group * GetGroupInvite() { return m_groupInvite; } - void SetGroupInvite(Group *group) { m_groupInvite = group; } - Group * GetGroup() { return m_group.getTarget(); } - const Group * GetGroup() const { return (const Group*)m_group.getTarget(); } + Group* GetGroupInvite() { return m_groupInvite; } + void SetGroupInvite(Group* group) { m_groupInvite = group; } + Group* GetGroup() { return m_group.getTarget(); } + const Group* GetGroup() const { return (const Group*)m_group.getTarget(); } GroupReference& GetGroupRef() { return m_group; } - void SetGroup(Group *group, int8 subgroup = -1); + void SetGroup(Group* group, int8 subgroup = -1); uint8 GetSubGroup() const { return m_group.getSubGroup(); } uint32 GetGroupUpdateFlag() const { return m_groupUpdateMask; } void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; } @@ -2310,15 +2310,15 @@ class MANGOS_DLL_SPEC Player : public Unit Player* GetNextRandomRaidMember(float radius); PartyResult CanUninviteFromGroup() const; // BattleGround Group System - void SetBattleGroundRaid(Group *group, int8 subgroup = -1); + void SetBattleGroundRaid(Group* group, int8 subgroup = -1); void RemoveFromBattleGroundRaid(); - Group * GetOriginalGroup() { return m_originalGroup.getTarget(); } + Group* GetOriginalGroup() { return m_originalGroup.getTarget(); } GroupReference& GetOriginalGroupRef() { return m_originalGroup; } uint8 GetOriginalSubGroup() const { return m_originalGroup.getSubGroup(); } - void SetOriginalGroup(Group *group, int8 subgroup = -1); + void SetOriginalGroup(Group* group, int8 subgroup = -1); - GridReference &GetGridRef() { return m_gridRef; } - MapReference &GetMapRef() { return m_mapRef; } + GridReference& GetGridRef() { return m_gridRef; } + MapReference& GetMapRef() { return m_mapRef; } bool isAllowedToLoot(Creature* creature); @@ -2341,7 +2341,7 @@ class MANGOS_DLL_SPEC Player : public Unit AchievementMgr const& GetAchievementMgr() const { return m_achievementMgr; } AchievementMgr& GetAchievementMgr() { return m_achievementMgr; } - void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit *unit=NULL, uint32 time=0); + void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit* unit=NULL, uint32 time=0); void StartTimedAchievementCriteria(AchievementCriteriaTypes type, uint32 timedRequirementId, time_t startTime = 0); @@ -2387,28 +2387,28 @@ class MANGOS_DLL_SPEC Player : public Unit /*** LOAD SYSTEM ***/ /*********************************************************/ - void _LoadActions(QueryResult *result); - void _LoadAuras(QueryResult *result, uint32 timediff); - void _LoadBoundInstances(QueryResult *result); - void _LoadInventory(QueryResult *result, uint32 timediff); - void _LoadItemLoot(QueryResult *result); - void _LoadMails(QueryResult *result); - void _LoadMailedItems(QueryResult *result); - void _LoadQuestStatus(QueryResult *result); - void _LoadDailyQuestStatus(QueryResult *result); - void _LoadWeeklyQuestStatus(QueryResult *result); - void _LoadMonthlyQuestStatus(QueryResult *result); - void _LoadGroup(QueryResult *result); - void _LoadSkills(QueryResult *result); - void _LoadSpells(QueryResult *result); - void _LoadTalents(QueryResult *result); - void _LoadFriendList(QueryResult *result); - bool _LoadHomeBind(QueryResult *result); - void _LoadDeclinedNames(QueryResult *result); - void _LoadArenaTeamInfo(QueryResult *result); - void _LoadEquipmentSets(QueryResult *result); + void _LoadActions(QueryResult* result); + void _LoadAuras(QueryResult* result, uint32 timediff); + void _LoadBoundInstances(QueryResult* result); + void _LoadInventory(QueryResult* result, uint32 timediff); + void _LoadItemLoot(QueryResult* result); + void _LoadMails(QueryResult* result); + void _LoadMailedItems(QueryResult* result); + void _LoadQuestStatus(QueryResult* result); + void _LoadDailyQuestStatus(QueryResult* result); + void _LoadWeeklyQuestStatus(QueryResult* result); + void _LoadMonthlyQuestStatus(QueryResult* result); + void _LoadGroup(QueryResult* result); + void _LoadSkills(QueryResult* result); + void _LoadSpells(QueryResult* result); + void _LoadTalents(QueryResult* result); + void _LoadFriendList(QueryResult* result); + bool _LoadHomeBind(QueryResult* result); + void _LoadDeclinedNames(QueryResult* result); + void _LoadArenaTeamInfo(QueryResult* result); + void _LoadEquipmentSets(QueryResult* result); void _LoadBGData(QueryResult* result); - void _LoadGlyphs(QueryResult *result); + void _LoadGlyphs(QueryResult* result); void _LoadIntoDataField(const char* data, uint32 startOffset, uint32 count); /*********************************************************/ @@ -2431,8 +2431,8 @@ class MANGOS_DLL_SPEC Player : public Unit void _SaveTalents(); void _SaveStats(); - void _SetCreateBits(UpdateMask *updateMask, Player *target) const; - void _SetUpdateBits(UpdateMask *updateMask, Player *target) const; + void _SetCreateBits(UpdateMask* updateMask, Player* target) const; + void _SetUpdateBits(UpdateMask* updateMask, Player* target) const; /*********************************************************/ /*** ENVIRONMENTAL SYSTEM ***/ @@ -2511,7 +2511,7 @@ class MANGOS_DLL_SPEC Player : public Unit float m_resurrectX, m_resurrectY, m_resurrectZ; uint32 m_resurrectHealth, m_resurrectMana; - WorldSession *m_session; + WorldSession* m_session; typedef std::list JoinedChannelsList; JoinedChannelsList m_channels; @@ -2554,7 +2554,7 @@ class MANGOS_DLL_SPEC Player : public Unit ////////////////////Rest System///////////////////// // Transports - Transport * m_transport; + Transport* m_transport; uint32 m_resetTalentsCost; time_t m_resetTalentsTime; @@ -2562,12 +2562,12 @@ class MANGOS_DLL_SPEC Player : public Unit uint32 m_questRewardTalentCount; // Social - PlayerSocial *m_social; + PlayerSocial* m_social; // Groups GroupReference m_group; GroupReference m_originalGroup; - Group *m_groupInvite; + Group* m_groupInvite; uint32 m_groupUpdateMask; uint64 m_auraUpdateMask; @@ -2578,23 +2578,23 @@ class MANGOS_DLL_SPEC Player : public Unit float m_summon_y; float m_summon_z; - DeclinedName *m_declinedname; - Runes *m_runes; + DeclinedName* m_declinedname; + Runes* m_runes; EquipmentSets m_EquipmentSets; /// class dependent melee diminishing constant for dodge/parry/missed chances static const float m_diminishing_k[MAX_CLASSES]; private: - void _HandleDeadlyPoison(Unit* Target, WeaponAttackType attType, SpellEntry const *spellInfo); + void _HandleDeadlyPoison(Unit* Target, WeaponAttackType attType, SpellEntry const* spellInfo); // internal common parts for CanStore/StoreItem functions - InventoryResult _CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem ) const; - InventoryResult _CanStoreItem_InBag( uint8 bag, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot ) const; - InventoryResult _CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot ) const; - Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update ); + InventoryResult _CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const* pProto, uint32& count, bool swap, Item* pSrcItem) const; + InventoryResult _CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, ItemPrototype const* pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const; + InventoryResult _CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemPrototype const* pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const; + Item* _StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool update); void UpdateKnownCurrencies(uint32 itemId, bool apply); - void AdjustQuestReqItemCount( Quest const* pQuest, QuestStatusData& questStatusData ); + void AdjustQuestReqItemCount(Quest const* pQuest, QuestStatusData& questStatusData); void SetCanDelayTeleport(bool setting) { m_bCanDelayTeleport = setting; } bool IsHasDelayedTeleport() const @@ -2619,7 +2619,7 @@ class MANGOS_DLL_SPEC Player : public Unit void _fillGearScoreData(Item* item, GearScoreVec* gearScore, uint32& twoHandScore); - Unit *m_mover; + Unit* m_mover; Camera m_camera; GridReference m_gridRef; @@ -2667,7 +2667,7 @@ class MANGOS_DLL_SPEC Player : public Unit uint32 m_cachedGS; }; -void AddItemsSetItem(Player*player,Item *item); -void RemoveItemsSetItem(Player*player,ItemPrototype const *proto); +void AddItemsSetItem(Player* player,Item* item); +void RemoveItemsSetItem(Player* player,ItemPrototype const* proto); #endif diff --git a/src/game/PlayerDump.cpp b/src/game/PlayerDump.cpp index c11c7ed78..44b1076da 100644 --- a/src/game/PlayerDump.cpp +++ b/src/game/PlayerDump.cpp @@ -68,11 +68,11 @@ static DumpTable dumpTables[] = }; // 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; 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) 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; } -std::string gettoknth(std::string &str, int n) +std::string gettoknth(std::string& str, int n) { std::string::size_type s = 0, e = 0; if (!findtoknth(str, n, s, e)) @@ -90,7 +90,7 @@ std::string gettoknth(std::string &str, int n) 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; 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); if (e == std::string::npos) 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 { @@ -111,12 +112,13 @@ bool findnth(std::string &str, int n, std::string::size_type &s, std::string::si e = str.find("'",s); if (e == std::string::npos) return false; - } while (str[e-1] == '\\'); + } + while (str[e-1] == '\\'); } return true; } -std::string gettablename(std::string &str) +std::string gettablename(std::string& str) { std::string::size_type s = 13; 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); } -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; 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; } -std::string getnth(std::string &str, int n) +std::string getnth(std::string& str, int n) { std::string::size_type 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); } -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; 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; } -uint32 registerNewGuid(uint32 oldGuid, std::map &guidMap, uint32 hiGuid) +uint32 registerNewGuid(uint32 oldGuid, std::map& guidMap, uint32 hiGuid) { std::map::const_iterator itr = guidMap.find(oldGuid); if (itr != guidMap.end()) @@ -177,7 +179,7 @@ uint32 registerNewGuid(uint32 oldGuid, std::map &guidMap, uint32 return newguid; } -bool changeGuid(std::string &str, int n, std::map &guidMap, uint32 hiGuid, bool nonzero = false) +bool changeGuid(std::string& str, int n, std::map& guidMap, uint32 hiGuid, bool nonzero = false) { char chritem[20]; uint32 oldGuid = atoi(getnth(str, n).c_str()); @@ -190,7 +192,7 @@ bool changeGuid(std::string &str, int n, std::map &guidMap, uint return changenth(str, n, chritem, false, nonzero); } -bool changetokGuid(std::string &str, int n, std::map &guidMap, uint32 hiGuid, bool nonzero = false) +bool changetokGuid(std::string& str, int n, std::map& guidMap, uint32 hiGuid, bool nonzero = false) { char chritem[20]; uint32 oldGuid = atoi(gettoknth(str, n).c_str()); @@ -203,15 +205,15 @@ bool changetokGuid(std::string &str, int n, std::map &guidMap, u 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) return ""; std::ostringstream ss; ss << "INSERT INTO "<< _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES ("; - Field *fields = result->Fetch(); - for(uint32 i = 0; i < result->GetFieldCount(); ++i) + Field* fields = result->Fetch(); + for (uint32 i = 0; i < result->GetFieldCount(); ++i) { if (i != 0) ss << ", "; @@ -241,7 +243,7 @@ std::string PlayerDumpWriter::GenerateWhereStr(char const* field, GUIDs const& g { std::ostringstream wherestr; wherestr << field << " IN ('"; - for(; itr != guids.end(); ++itr) + for (; itr != guids.end(); ++itr) { wherestr << *itr; @@ -259,7 +261,7 @@ std::string PlayerDumpWriter::GenerateWhereStr(char const* field, GUIDs const& g return wherestr.str(); } -void StoreGUID(QueryResult *result,uint32 field,std::set& guids) +void StoreGUID(QueryResult* result,uint32 field,std::set& guids) { Field* fields = result->Fetch(); uint32 guid = fields[field].GetUInt32(); @@ -267,7 +269,7 @@ void StoreGUID(QueryResult *result,uint32 field,std::set& guids) guids.insert(guid); } -void StoreGUID(QueryResult *result,uint32 data,uint32 field, std::set& guids) +void StoreGUID(QueryResult* result,uint32 data,uint32 field, std::set& guids) { Field* fields = result->Fetch(); std::string dataStr = fields[data].GetCppString(); @@ -277,12 +279,12 @@ void StoreGUID(QueryResult *result,uint32 data,uint32 field, std::set& g } // 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; char const* fieldname = NULL; - switch ( type ) + switch (type) { case DTT_ITEM: fieldname = "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 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) return; do { // collect guids - switch ( type ) + switch (type) { case DTT_INVENTORY: 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; } - 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) @@ -356,7 +358,7 @@ std::string PlayerDumpWriter::GetDump(uint32 guid) { QueryFieldNames const& namesMap = result->GetFieldNames(); 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_") { @@ -378,7 +380,7 @@ std::string PlayerDumpWriter::GetDump(uint32 guid) else 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); // TODO: Add instance/group.. @@ -389,7 +391,7 @@ std::string PlayerDumpWriter::GetDump(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) return DUMP_FILE_OPEN_ERROR; @@ -412,11 +414,11 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s if (charcount >= 10) return DUMP_TOO_MANY_CHARS; - FILE *fin = fopen(file.c_str(), "r"); + FILE* fin = fopen(file.c_str(), "r"); if (!fin) return DUMP_FILE_OPEN_ERROR; - QueryResult * result = NULL; + QueryResult* result = NULL; 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 @@ -468,11 +470,11 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s PetIds petids; CharacterDatabase.BeginTransaction(); - while(!feof(fin)) + while (!feof(fin)) { if (!fgets(buf, 32000, fin)) { - if(feof(fin)) break; + if (feof(fin)) break; 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' DumpTable* dTable = &dumpTables[0]; - for(; dTable->isValid(); ++dTable) + for (; dTable->isValid(); ++dTable) { 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 // change the data to server values - switch(type) + switch (type) { case DTT_CHAR_TABLE: 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); if (!changeGuid(line, 2, eqsets, sObjectMgr.m_EquipmentSetIds.GetNextAfterMaxUsed())) ROLLBACK(DUMP_FILE_BROKEN); // character_equipmentsets.setguid - for(int i = 0; i < 19; ++i) // character_equipmentsets.item0..item18 - if(!changeGuid(line, 6+i, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) + for (int i = 0; i < 19; ++i) // character_equipmentsets.item0..item18 + if (!changeGuid(line, 6+i, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) ROLLBACK(DUMP_FILE_BROKEN); break; } diff --git a/src/game/PlayerDump.h b/src/game/PlayerDump.h index f9ff21d3a..af867876c 100644 --- a/src/game/PlayerDump.h +++ b/src/game/PlayerDump.h @@ -28,11 +28,11 @@ enum DumpTableType DTT_CHARACTER, // -> guid, name // characters DTT_CHAR_TABLE, // // character_account_data, character_achievement, - // character_achievement_progress, character_action, - // character_aura, character_glyphs, - // character_homebind, character_queststatus, - // character_reputation, character_skills, character_spell, - // character_spell_cooldown, character_talent, character_ticket + // character_achievement_progress, character_action, + // character_aura, character_glyphs, + // character_homebind, character_queststatus, + // character_reputation, character_skills, character_spell, + // character_spell_cooldown, character_talent, character_ticket DTT_CHAR_NAME_TABLE,// <- guid, name // character_declinedname @@ -41,10 +41,10 @@ enum DumpTableType DTT_INVENTORY, // -> item guids collection // character_inventory DTT_MAIL, // -> mail ids collection // mail - // -> item_text + // -> item_text DTT_MAIL_ITEM, // <- mail ids // mail_items - // -> item guids collection + // -> item guids collection DTT_ITEM, // <- item guids // item_instance @@ -82,7 +82,7 @@ class PlayerDumpWriter : public PlayerDump private: typedef std::set 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, uint32 guid); diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp index 2abe26750..e6bbeb314 100644 --- a/src/game/PointMovementGenerator.cpp +++ b/src/game/PointMovementGenerator.cpp @@ -27,7 +27,7 @@ //----- Point Movement Generator template -void PointMovementGenerator::Initialize(T &unit) +void PointMovementGenerator::Initialize(T& unit) { if (!unit.IsStopped()) unit.StopMoving(); @@ -39,7 +39,7 @@ void PointMovementGenerator::Initialize(T &unit) } template -void PointMovementGenerator::Finalize(T &unit) +void PointMovementGenerator::Finalize(T& unit) { unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); @@ -48,13 +48,13 @@ void PointMovementGenerator::Finalize(T &unit) } template -void PointMovementGenerator::Interrupt(T &unit) +void PointMovementGenerator::Interrupt(T& unit) { unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); } template -void PointMovementGenerator::Reset(T &unit) +void PointMovementGenerator::Reset(T& unit) { if (!unit.IsStopped()) unit.StopMoving(); @@ -63,12 +63,12 @@ void PointMovementGenerator::Reset(T &unit) } template -bool PointMovementGenerator::Update(T &unit, const uint32 &diff) +bool PointMovementGenerator::Update(T& unit, const uint32& diff) { - if(!&unit) + if (!&unit) return false; - if(unit.hasUnitState(UNIT_STAT_CAN_NOT_MOVE)) + if (unit.hasUnitState(UNIT_STAT_CAN_NOT_MOVE)) { unit.clearUnitState(UNIT_STAT_ROAMING_MOVE); return true; @@ -84,7 +84,7 @@ void PointMovementGenerator::MovementInform(Player&) } template <> -void PointMovementGenerator::MovementInform(Creature &unit) +void PointMovementGenerator::MovementInform(Creature& unit) { if (unit.AI()) unit.AI()->MovementInform(POINT_MOTION_TYPE, id); @@ -93,7 +93,7 @@ void PointMovementGenerator::MovementInform(Creature &unit) { TemporarySummon* pSummon = (TemporarySummon*)(&unit); if (pSummon->GetSummonerGuid().IsCreatureOrVehicle()) - if(Creature* pSummoner = unit.GetMap()->GetCreature(pSummon->GetSummonerGuid())) + if (Creature* pSummoner = unit.GetMap()->GetCreature(pSummon->GetSummonerGuid())) if (pSummoner->AI()) pSummoner->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id); } @@ -107,10 +107,10 @@ template void PointMovementGenerator::Interrupt(Player&); template void PointMovementGenerator::Interrupt(Creature&); template void PointMovementGenerator::Reset(Player&); template void PointMovementGenerator::Reset(Creature&); -template bool PointMovementGenerator::Update(Player &, const uint32 &diff); -template bool PointMovementGenerator::Update(Creature&, const uint32 &diff); +template bool PointMovementGenerator::Update(Player&, const uint32& diff); +template bool PointMovementGenerator::Update(Creature&, const uint32& diff); -void AssistanceMovementGenerator::Finalize(Unit &unit) +void AssistanceMovementGenerator::Finalize(Unit& unit) { 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)); } -bool EffectMovementGenerator::Update(Unit &unit, const uint32 &) +bool EffectMovementGenerator::Update(Unit& unit, const uint32&) { return !unit.movespline->Finalized(); } -void EffectMovementGenerator::Finalize(Unit &unit) +void EffectMovementGenerator::Finalize(Unit& unit) { if (unit.GetTypeId() != TYPEID_UNIT) return; @@ -135,7 +135,7 @@ void EffectMovementGenerator::Finalize(Unit &unit) // Need restore previous movement since we have no proper states system 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); else unit.GetMotionMaster()->Initialize(); diff --git a/src/game/PointMovementGenerator.h b/src/game/PointMovementGenerator.h index 6e972b0f8..d56dff6ba 100644 --- a/src/game/PointMovementGenerator.h +++ b/src/game/PointMovementGenerator.h @@ -25,19 +25,19 @@ template class MANGOS_DLL_SPEC PointMovementGenerator -: public MovementGeneratorMedium< T, PointMovementGenerator > + : public MovementGeneratorMedium< T, PointMovementGenerator > { public: 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 Finalize(T &); - void Interrupt(T &); - void Reset(T &unit); - bool Update(T &, const uint32 &diff); + void Initialize(T&); + void Finalize(T&); + void Interrupt(T&); + void Reset(T& unit); + bool Update(T&, const uint32& diff); - void MovementInform(T &); + void MovementInform(T&); MovementGeneratorType GetMovementGeneratorType() const { return POINT_MOTION_TYPE; } @@ -49,14 +49,14 @@ class MANGOS_DLL_SPEC PointMovementGenerator }; class MANGOS_DLL_SPEC AssistanceMovementGenerator -: public PointMovementGenerator + : public PointMovementGenerator { public: AssistanceMovementGenerator(float _x, float _y, float _z) : PointMovementGenerator(0, _x, _y, _z, true) {} 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 @@ -64,11 +64,11 @@ class EffectMovementGenerator : public MovementGenerator { public: explicit EffectMovementGenerator(uint32 Id) : m_Id(Id) {} - void Initialize(Unit &) {} - void Finalize(Unit &unit); - void Interrupt(Unit &) {} - void Reset(Unit &) {} - bool Update(Unit &u, const uint32 &); + void Initialize(Unit&) {} + void Finalize(Unit& unit); + void Interrupt(Unit&) {} + void Reset(Unit&) {} + bool Update(Unit& u, const uint32&); MovementGeneratorType GetMovementGeneratorType() const { return EFFECT_MOTION_TYPE; } private: uint32 m_Id; diff --git a/src/game/PoolManager.cpp b/src/game/PoolManager.cpp index cd406cd34..187b20195 100644 --- a/src/game/PoolManager.cpp +++ b/src/game/PoolManager.cpp @@ -306,7 +306,7 @@ void PoolGroup::RemoveOneRelation(uint16 child_pool_id) { 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); break; @@ -314,7 +314,7 @@ void PoolGroup::RemoveOneRelation(uint16 child_pool_id) } 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); break; @@ -398,9 +398,9 @@ void PoolGroup::Spawn1Object(MapPersistentState& mapState, PoolObject* else { // 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()) pCreature->SaveRespawnTime(); } @@ -408,7 +408,7 @@ void PoolGroup::Spawn1Object(MapPersistentState& mapState, PoolObject* } } // 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); } @@ -444,9 +444,9 @@ void PoolGroup::Spawn1Object(MapPersistentState& mapState, PoolObjec if (pGameobject->isSpawnedByDefault()) { // 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)) pGameobject->SaveRespawnTime(); } @@ -455,7 +455,7 @@ void PoolGroup::Spawn1Object(MapPersistentState& mapState, PoolObjec } } // 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 if (data->spawntimesecs >= 0) @@ -545,7 +545,7 @@ struct PoolMapChecker 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.", - tableName, elementName, mapid, poolMapEntry->MapID, pool_id); + tableName, elementName, mapid, poolMapEntry->MapID, pool_id); return false; } @@ -553,7 +553,7 @@ struct PoolMapChecker 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.", - tableName, elementName, mapid, poolMapEntry->MapID, pool_id); + tableName, elementName, mapid, poolMapEntry->MapID, pool_id); return false; } @@ -564,7 +564,7 @@ struct PoolMapChecker 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) { sLog.outString(">> Table pool_template is empty."); @@ -573,7 +573,7 @@ void PoolManager::LoadFromDB() } else { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); max_pool_id = fields[0].GetUInt16(); delete result; } @@ -595,7 +595,7 @@ void PoolManager::LoadFromDB() do { ++count; - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); @@ -606,10 +606,11 @@ void PoolManager::LoadFromDB() pPoolTemplate.description = fields[2].GetCppString(); pPoolTemplate.AutoSpawn = true; // will update and later data loading - } while (result->NextRow()); + } + while (result->NextRow()); sLog.outString(); - sLog.outString( ">> Loaded %u objects pools", count ); + sLog.outString(">> Loaded %u objects pools", count); delete result; PoolMapChecker mapChecker(mPoolTemplate); @@ -628,7 +629,7 @@ void PoolManager::LoadFromDB() bar2.step(); 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 { @@ -636,7 +637,7 @@ void PoolManager::LoadFromDB() BarGoLink bar2(result->GetRowCount()); do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar2.step(); @@ -647,7 +648,7 @@ void PoolManager::LoadFromDB() CreatureData const* data = sObjectMgr.GetCreatureData(guid); 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; } if (pool_id > max_pool_id) @@ -664,7 +665,7 @@ void PoolManager::LoadFromDB() if (!mapChecker.CheckAndRemember(data->mapid, pool_id, "pool_creature", "creature guid")) continue; - PoolTemplateData *pPoolTemplate = &mPoolTemplate[pool_id]; + PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id]; ++count; @@ -675,9 +676,10 @@ void PoolManager::LoadFromDB() SearchPair p(guid, pool_id); mCreatureSearchMap.insert(p); - } while (result->NextRow()); + } + while (result->NextRow()); 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; } @@ -690,14 +692,14 @@ void PoolManager::LoadFromDB() bar2.step(); 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 { BarGoLink bar2(result->GetRowCount()); do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar2.step(); @@ -709,7 +711,7 @@ void PoolManager::LoadFromDB() CreatureData const* data = sObjectMgr.GetCreatureData(guid); 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; } if (pool_id > max_pool_id) @@ -729,14 +731,14 @@ void PoolManager::LoadFromDB() if (uint16 alt_pool_id = IsPartOfAPool(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.", - guid, pool_id, alt_pool_id, entry_id); + guid, pool_id, alt_pool_id, entry_id); continue; } if (!mapChecker.CheckAndRemember(data->mapid, pool_id, "pool_creature_template", "creature guid")) continue; - PoolTemplateData *pPoolTemplate = &mPoolTemplate[pool_id]; + PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id]; ++count; @@ -747,9 +749,10 @@ void PoolManager::LoadFromDB() SearchPair p(guid, pool_id); mCreatureSearchMap.insert(p); - } while (result->NextRow()); + } + while (result->NextRow()); 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; } @@ -767,7 +770,7 @@ void PoolManager::LoadFromDB() bar2.step(); 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 { @@ -775,7 +778,7 @@ void PoolManager::LoadFromDB() BarGoLink bar2(result->GetRowCount()); do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar2.step(); @@ -786,15 +789,15 @@ void PoolManager::LoadFromDB() GameObjectData const* data = sObjectMgr.GetGOData(guid); 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; } GameObjectInfo const* goinfo = ObjectMgr::GetGameObjectInfo(data->id); if (goinfo->type != GAMEOBJECT_TYPE_CHEST && - goinfo->type != GAMEOBJECT_TYPE_GOOBER && - goinfo->type != GAMEOBJECT_TYPE_FISHINGHOLE) + goinfo->type != GAMEOBJECT_TYPE_GOOBER && + 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; } if (pool_id > max_pool_id) @@ -811,7 +814,7 @@ void PoolManager::LoadFromDB() if (!mapChecker.CheckAndRemember(data->mapid, pool_id, "pool_gameobject", "gameobject guid")) continue; - PoolTemplateData *pPoolTemplate = &mPoolTemplate[pool_id]; + PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id]; ++count; @@ -822,9 +825,10 @@ void PoolManager::LoadFromDB() SearchPair p(guid, pool_id); mGameobjectSearchMap.insert(p); - } while( result->NextRow() ); + } + while (result->NextRow()); 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; } @@ -838,7 +842,7 @@ void PoolManager::LoadFromDB() bar2.step(); 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 { @@ -846,7 +850,7 @@ void PoolManager::LoadFromDB() BarGoLink bar2(result->GetRowCount()); do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar2.step(); @@ -863,8 +867,8 @@ void PoolManager::LoadFromDB() } GameObjectInfo const* goinfo = ObjectMgr::GetGameObjectInfo(data->id); if (goinfo->type != GAMEOBJECT_TYPE_CHEST && - goinfo->type != GAMEOBJECT_TYPE_GOOBER && - goinfo->type != GAMEOBJECT_TYPE_FISHINGHOLE) + goinfo->type != GAMEOBJECT_TYPE_GOOBER && + 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); continue; @@ -886,14 +890,14 @@ void PoolManager::LoadFromDB() if (uint16 alt_pool_id = IsPartOfAPool(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.", - guid, pool_id, alt_pool_id, entry_id); + guid, pool_id, alt_pool_id, entry_id); continue; } if (!mapChecker.CheckAndRemember(data->mapid, pool_id, "pool_gameobject_template", "gameobject guid")) continue; - PoolTemplateData *pPoolTemplate = &mPoolTemplate[pool_id]; + PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id]; ++count; @@ -904,9 +908,10 @@ void PoolManager::LoadFromDB() SearchPair p(guid, pool_id); mGameobjectSearchMap.insert(p); - } while( result->NextRow() ); + } + while (result->NextRow()); 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; } @@ -916,13 +921,13 @@ void PoolManager::LoadFromDB() result = WorldDatabase.Query("SELECT pool_id, mother_pool, chance FROM pool_pool"); count = 0; - if( !result ) + if (!result) { BarGoLink bar2(1); bar2.step(); sLog.outString(); - sLog.outString(">> Loaded %u pools in pools", count ); + sLog.outString(">> Loaded %u pools in pools", count); } else { @@ -930,7 +935,7 @@ void PoolManager::LoadFromDB() BarGoLink bar2(result->GetRowCount()); do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar2.step(); @@ -959,7 +964,7 @@ void PoolManager::LoadFromDB() continue; } - PoolTemplateData *pPoolTemplateMother = &mPoolTemplate[mother_pool_id]; + PoolTemplateData* pPoolTemplateMother = &mPoolTemplate[mother_pool_id]; ++count; @@ -973,13 +978,14 @@ void PoolManager::LoadFromDB() // update top independent pool flag mPoolTemplate[child_pool_id].AutoSpawn = false; - } while( result->NextRow() ); + } + while (result->NextRow()); // Now check for circular reference - for(uint16 i=0; i 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 (MapEntry const* childMapEntry = mPoolTemplate[poolItr->first].mapEntry) @@ -994,14 +1000,14 @@ void PoolManager::LoadFromDB() } checkedPools.insert(poolItr->first); - if(checkedPools.find(poolItr->second) != checkedPools.end()) + if (checkedPools.find(poolItr->second) != checkedPools.end()) { std::ostringstream ss; ss<< "The pool(s) "; for (std::set::const_iterator itr=checkedPools.begin(); itr!=checkedPools.end(); ++itr) ss << *itr << " "; 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()); mPoolPoolGroups[poolItr->second].RemoveOneRelation(poolItr->first); mPoolSearchMap.erase(poolItr); @@ -1012,12 +1018,12 @@ void PoolManager::LoadFromDB() } sLog.outString(); - sLog.outString( ">> Loaded %u pools in mother pools", count ); + sLog.outString(">> Loaded %u pools in mother pools", count); delete result; } // 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) { @@ -1034,7 +1040,7 @@ void PoolManager::LoadFromDB() void PoolManager::Initialize(MapPersistentState* state) { // 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) InitSpawnPool(*state, pool_entry); } @@ -1092,9 +1098,9 @@ void PoolManager::DespawnPool(MapPersistentState& mapState, uint16 pool_id) bool PoolManager::CheckPool(uint16 pool_id) const { return pool_id <= max_pool_id && - mPoolGameobjectGroups[pool_id].CheckPool() && - mPoolCreatureGroups[pool_id].CheckPool() && - mPoolPoolGroups[pool_id].CheckPool(); + mPoolGameobjectGroups[pool_id].CheckPool() && + mPoolCreatureGroups[pool_id].CheckPool() && + mPoolPoolGroups[pool_id].CheckPool(); } // Method that check linking all elements to event @@ -1139,7 +1145,7 @@ struct SpawnPoolInMapsWorker explicit SpawnPoolInMapsWorker(PoolManager& mgr, uint32 pool_id, bool 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); } @@ -1167,7 +1173,7 @@ struct DespawnPoolInMapsWorker explicit DespawnPoolInMapsWorker(PoolManager& mgr, uint32 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); } @@ -1202,7 +1208,7 @@ struct UpdatePoolInMapsWorker 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) {} - void operator() (MapPersistentState* state) + void operator()(MapPersistentState* state) { i_mgr.UpdatePool(*state, i_pool_id, i_db_guid_or_pool_id); } diff --git a/src/game/PoolManager.h b/src/game/PoolManager.h index 965464202..e705e143f 100644 --- a/src/game/PoolManager.h +++ b/src/game/PoolManager.h @@ -33,8 +33,8 @@ struct PoolTemplateData PoolTemplateData() : mapEntry(NULL), MaxLimit(0), AutoSpawn(false) {} 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. - // NULL is no spawns by some reason + // 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 uint32 MaxLimit; bool AutoSpawn; // spawn at pool system start (not part of another pool and not part of event spawn) std::string description;