From 6379a746d7f08156b33c6063765d49b7549eb103 Mon Sep 17 00:00:00 2001 From: Schmoozerd Date: Thu, 19 Jul 2012 21:52:26 +0200 Subject: [PATCH] Various Cleanups (game T-Z) --- src/game/TargetedMovementGenerator.cpp | 82 +- src/game/TargetedMovementGenerator.h | 54 +- src/game/TaxiHandler.cpp | 88 +- src/game/TemporarySummon.cpp | 14 +- src/game/TemporarySummon.h | 2 +- src/game/ThreatManager.cpp | 95 +- src/game/ThreatManager.h | 22 +- src/game/Totem.cpp | 30 +- src/game/Totem.h | 8 +- src/game/TotemAI.cpp | 20 +- src/game/TotemAI.h | 10 +- src/game/TradeHandler.cpp | 96 +- src/game/Transports.cpp | 71 +- src/game/Transports.h | 4 +- src/game/Unit.cpp | 2037 ++++++++++++------------ src/game/Unit.h | 352 ++-- src/game/UnitAuraProcHandler.cpp | 660 ++++---- src/game/UpdateData.cpp | 26 +- src/game/UpdateData.h | 8 +- src/game/UpdateMask.h | 36 +- src/game/VoiceChatHandler.cpp | 6 +- src/game/WaypointManager.cpp | 140 +- src/game/WaypointManager.h | 16 +- src/game/WaypointMovementGenerator.cpp | 45 +- src/game/WaypointMovementGenerator.h | 36 +- src/game/Weather.cpp | 54 +- src/game/Weather.h | 4 +- src/game/World.cpp | 486 +++--- src/game/World.h | 14 +- src/game/WorldSession.cpp | 284 ++-- src/game/WorldSession.h | 244 +-- src/game/WorldSocket.cpp | 548 +++---- src/game/WorldSocket.h | 50 +- src/game/WorldSocketMgr.cpp | 68 +- 34 files changed, 2858 insertions(+), 2852 deletions(-) diff --git a/src/game/TargetedMovementGenerator.cpp b/src/game/TargetedMovementGenerator.cpp index 0f8271acf..0438d4131 100644 --- a/src/game/TargetedMovementGenerator.cpp +++ b/src/game/TargetedMovementGenerator.cpp @@ -27,7 +27,7 @@ //-----------------------------------------------// template -void TargetedMovementGeneratorMedium::_setTargetLocation(T &owner) +void TargetedMovementGeneratorMedium::_setTargetLocation(T& owner) { if (!i_target.isValid() || !i_target->IsInWorld()) return; @@ -48,7 +48,7 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T &owner) else if (!i_offset) { // to nearest contact position - i_target->GetContactPoint( &owner, x, y, z ); + i_target->GetContactPoint(&owner, x, y, z); } else { @@ -73,14 +73,14 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T &owner) return; */ - if(!i_path) + if (!i_path) i_path = new PathFinder(&owner); // allow pets following their master to cheat while generating paths bool forceDest = (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->IsPet() - && owner.hasUnitState(UNIT_STAT_FOLLOW)); + && owner.hasUnitState(UNIT_STAT_FOLLOW)); i_path->calculate(x, y, z, forceDest); - if(i_path->getPathType() & PATHFIND_NOPATH) + if (i_path->getPathType() & PATHFIND_NOPATH) return; D::_addUnitStateMove(owner); @@ -120,7 +120,7 @@ void TargetedMovementGeneratorMedium } template -bool TargetedMovementGeneratorMedium::Update(T &owner, const uint32 & time_diff) +bool TargetedMovementGeneratorMedium::Update(T& owner, const uint32& time_diff) { if (!i_target.isValid() || !i_target->IsInWorld()) return false; @@ -189,21 +189,21 @@ bool TargetedMovementGeneratorMedium::Update(T &owner, const uint32 & time_ //-----------------------------------------------// template -void ChaseMovementGenerator::_reachTarget(T &owner) +void ChaseMovementGenerator::_reachTarget(T& owner) { if (owner.CanReachWithMeleeAttack(this->i_target.getTarget())) owner.Attack(this->i_target.getTarget(),true); } template<> -void ChaseMovementGenerator::Initialize(Player &owner) +void ChaseMovementGenerator::Initialize(Player& owner) { owner.addUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE); _setTargetLocation(owner); } template<> -void ChaseMovementGenerator::Initialize(Creature &owner) +void ChaseMovementGenerator::Initialize(Creature& owner) { owner.SetWalk(false); owner.addUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE); @@ -211,19 +211,19 @@ void ChaseMovementGenerator::Initialize(Creature &owner) } template -void ChaseMovementGenerator::Finalize(T &owner) +void ChaseMovementGenerator::Finalize(T& owner) { owner.clearUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE); } template -void ChaseMovementGenerator::Interrupt(T &owner) +void ChaseMovementGenerator::Interrupt(T& owner) { owner.clearUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE); } template -void ChaseMovementGenerator::Reset(T &owner) +void ChaseMovementGenerator::Reset(T& owner) { Initialize(owner); } @@ -242,13 +242,13 @@ bool FollowMovementGenerator::EnableWalking() const } template<> -void FollowMovementGenerator::_updateSpeed(Player &/*u*/) +void FollowMovementGenerator::_updateSpeed(Player& /*u*/) { // nothing to do for Player } template<> -void FollowMovementGenerator::_updateSpeed(Creature &u) +void FollowMovementGenerator::_updateSpeed(Creature& u) { // pet only sync speed with owner if (!((Creature&)u).IsPet() || !i_target.isValid() || i_target->GetObjectGuid() != u.GetOwnerGuid()) @@ -260,7 +260,7 @@ void FollowMovementGenerator::_updateSpeed(Creature &u) } template<> -void FollowMovementGenerator::Initialize(Player &owner) +void FollowMovementGenerator::Initialize(Player& owner) { owner.addUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE); _updateSpeed(owner); @@ -268,7 +268,7 @@ void FollowMovementGenerator::Initialize(Player &owner) } template<> -void FollowMovementGenerator::Initialize(Creature &owner) +void FollowMovementGenerator::Initialize(Creature& owner) { owner.addUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE); _updateSpeed(owner); @@ -276,47 +276,47 @@ void FollowMovementGenerator::Initialize(Creature &owner) } template -void FollowMovementGenerator::Finalize(T &owner) +void FollowMovementGenerator::Finalize(T& owner) { owner.clearUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE); _updateSpeed(owner); } template -void FollowMovementGenerator::Interrupt(T &owner) +void FollowMovementGenerator::Interrupt(T& owner) { owner.clearUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE); _updateSpeed(owner); } template -void FollowMovementGenerator::Reset(T &owner) +void FollowMovementGenerator::Reset(T& owner) { Initialize(owner); } //-----------------------------------------------// -template void TargetedMovementGeneratorMedium >::_setTargetLocation(Player &); -template void TargetedMovementGeneratorMedium >::_setTargetLocation(Player &); -template void TargetedMovementGeneratorMedium >::_setTargetLocation(Creature &); -template void TargetedMovementGeneratorMedium >::_setTargetLocation(Creature &); -template bool TargetedMovementGeneratorMedium >::Update(Player &, const uint32 &); -template bool TargetedMovementGeneratorMedium >::Update(Player &, const uint32 &); -template bool TargetedMovementGeneratorMedium >::Update(Creature &, const uint32 &); -template bool TargetedMovementGeneratorMedium >::Update(Creature &, const uint32 &); +template void TargetedMovementGeneratorMedium >::_setTargetLocation(Player&); +template void TargetedMovementGeneratorMedium >::_setTargetLocation(Player&); +template void TargetedMovementGeneratorMedium >::_setTargetLocation(Creature&); +template void TargetedMovementGeneratorMedium >::_setTargetLocation(Creature&); +template bool TargetedMovementGeneratorMedium >::Update(Player&, const uint32&); +template bool TargetedMovementGeneratorMedium >::Update(Player&, const uint32&); +template bool TargetedMovementGeneratorMedium >::Update(Creature&, const uint32&); +template bool TargetedMovementGeneratorMedium >::Update(Creature&, const uint32&); -template void ChaseMovementGenerator::_reachTarget(Player &); -template void ChaseMovementGenerator::_reachTarget(Creature &); -template void ChaseMovementGenerator::Finalize(Player &); -template void ChaseMovementGenerator::Finalize(Creature &); -template void ChaseMovementGenerator::Interrupt(Player &); -template void ChaseMovementGenerator::Interrupt(Creature &); -template void ChaseMovementGenerator::Reset(Player &); -template void ChaseMovementGenerator::Reset(Creature &); +template void ChaseMovementGenerator::_reachTarget(Player&); +template void ChaseMovementGenerator::_reachTarget(Creature&); +template void ChaseMovementGenerator::Finalize(Player&); +template void ChaseMovementGenerator::Finalize(Creature&); +template void ChaseMovementGenerator::Interrupt(Player&); +template void ChaseMovementGenerator::Interrupt(Creature&); +template void ChaseMovementGenerator::Reset(Player&); +template void ChaseMovementGenerator::Reset(Creature&); -template void FollowMovementGenerator::Finalize(Player &); -template void FollowMovementGenerator::Finalize(Creature &); -template void FollowMovementGenerator::Interrupt(Player &); -template void FollowMovementGenerator::Interrupt(Creature &); -template void FollowMovementGenerator::Reset(Player &); -template void FollowMovementGenerator::Reset(Creature &); +template void FollowMovementGenerator::Finalize(Player&); +template void FollowMovementGenerator::Finalize(Creature&); +template void FollowMovementGenerator::Interrupt(Player&); +template void FollowMovementGenerator::Interrupt(Creature&); +template void FollowMovementGenerator::Reset(Player&); +template void FollowMovementGenerator::Reset(Creature&); diff --git a/src/game/TargetedMovementGenerator.h b/src/game/TargetedMovementGenerator.h index d05e0d471..7e6cf263a 100644 --- a/src/game/TargetedMovementGenerator.h +++ b/src/game/TargetedMovementGenerator.h @@ -27,7 +27,7 @@ class MANGOS_DLL_SPEC TargetedMovementGeneratorBase { public: - TargetedMovementGeneratorBase(Unit &target) { i_target.link(&target, this); } + TargetedMovementGeneratorBase(Unit& target) { i_target.link(&target, this); } void stopFollowing() { } protected: FollowerReference i_target; @@ -35,10 +35,10 @@ class MANGOS_DLL_SPEC TargetedMovementGeneratorBase template class MANGOS_DLL_SPEC TargetedMovementGeneratorMedium -: public MovementGeneratorMedium< T, D >, public TargetedMovementGeneratorBase + : public MovementGeneratorMedium< T, D >, public TargetedMovementGeneratorBase { protected: - TargetedMovementGeneratorMedium(Unit &target, float offset, float angle) : + TargetedMovementGeneratorMedium(Unit& target, float offset, float angle) : TargetedMovementGeneratorBase(target), i_offset(offset), i_angle(angle), i_recalculateTravel(false), i_targetReached(false), i_recheckDistance(0), i_path(NULL) @@ -47,7 +47,7 @@ class MANGOS_DLL_SPEC TargetedMovementGeneratorMedium ~TargetedMovementGeneratorMedium() { delete i_path; } public: - bool Update(T &, const uint32 &); + bool Update(T&, const uint32&); bool IsReachable() const { @@ -60,7 +60,7 @@ class MANGOS_DLL_SPEC TargetedMovementGeneratorMedium void UpdateFinalDistance(float fDistance); protected: - void _setTargetLocation(T &); + void _setTargetLocation(T&); ShortTimeTracker i_recheckDistance; float i_offset; @@ -75,50 +75,50 @@ template class MANGOS_DLL_SPEC ChaseMovementGenerator : public TargetedMovementGeneratorMedium > { public: - ChaseMovementGenerator(Unit &target) + ChaseMovementGenerator(Unit& target) : TargetedMovementGeneratorMedium >(target) {} - ChaseMovementGenerator(Unit &target, float offset, float angle) + ChaseMovementGenerator(Unit& target, float offset, float angle) : TargetedMovementGeneratorMedium >(target, offset, angle) {} ~ChaseMovementGenerator() {} MovementGeneratorType GetMovementGeneratorType() const { return CHASE_MOTION_TYPE; } - void Initialize(T &); - void Finalize(T &); - void Interrupt(T &); - void Reset(T &); + void Initialize(T&); + void Finalize(T&); + void Interrupt(T&); + void Reset(T&); - static void _clearUnitStateMove(T &u) { u.clearUnitState(UNIT_STAT_CHASE_MOVE); } - static void _addUnitStateMove(T &u) { u.addUnitState(UNIT_STAT_CHASE_MOVE); } + static void _clearUnitStateMove(T& u) { u.clearUnitState(UNIT_STAT_CHASE_MOVE); } + static void _addUnitStateMove(T& u) { u.addUnitState(UNIT_STAT_CHASE_MOVE); } bool EnableWalking() const { return false;} - bool _lostTarget(T &u) const { return u.getVictim() != this->GetTarget(); } - void _reachTarget(T &); + bool _lostTarget(T& u) const { return u.getVictim() != this->GetTarget(); } + void _reachTarget(T&); }; template class MANGOS_DLL_SPEC FollowMovementGenerator : public TargetedMovementGeneratorMedium > { public: - FollowMovementGenerator(Unit &target) - : TargetedMovementGeneratorMedium >(target){} - FollowMovementGenerator(Unit &target, float offset, float angle) + FollowMovementGenerator(Unit& target) + : TargetedMovementGeneratorMedium >(target) {} + FollowMovementGenerator(Unit& target, float offset, float angle) : TargetedMovementGeneratorMedium >(target, offset, angle) {} ~FollowMovementGenerator() {} MovementGeneratorType GetMovementGeneratorType() const { return FOLLOW_MOTION_TYPE; } - void Initialize(T &); - void Finalize(T &); - void Interrupt(T &); - void Reset(T &); + void Initialize(T&); + void Finalize(T&); + void Interrupt(T&); + void Reset(T&); - static void _clearUnitStateMove(T &u) { u.clearUnitState(UNIT_STAT_FOLLOW_MOVE); } - static void _addUnitStateMove(T &u) { u.addUnitState(UNIT_STAT_FOLLOW_MOVE); } + static void _clearUnitStateMove(T& u) { u.clearUnitState(UNIT_STAT_FOLLOW_MOVE); } + static void _addUnitStateMove(T& u) { u.addUnitState(UNIT_STAT_FOLLOW_MOVE); } bool EnableWalking() const; - bool _lostTarget(T &) const { return false; } - void _reachTarget(T &) {} + bool _lostTarget(T&) const { return false; } + void _reachTarget(T&) {} private: - void _updateSpeed(T &u); + void _updateSpeed(T& u); }; #endif diff --git a/src/game/TaxiHandler.cpp b/src/game/TaxiHandler.cpp index 40deee137..ac45e14b1 100644 --- a/src/game/TaxiHandler.cpp +++ b/src/game/TaxiHandler.cpp @@ -28,27 +28,27 @@ #include "Path.h" #include "WaypointMovementGenerator.h" -void WorldSession::HandleTaxiNodeStatusQueryOpcode( WorldPacket & recv_data ) +void WorldSession::HandleTaxiNodeStatusQueryOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Received CMSG_TAXINODE_STATUS_QUERY"); ObjectGuid guid; recv_data >> guid; - SendTaxiStatus( guid ); + SendTaxiStatus(guid); } void WorldSession::SendTaxiStatus(ObjectGuid guid) { // cheating checks - Creature *unit = GetPlayer()->GetMap()->GetCreature(guid); + Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) { DEBUG_LOG("WorldSession::SendTaxiStatus - %s not found or you can't interact with it.", guid.GetString().c_str()); return; } - uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer( )->GetTeam()); + uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer()->GetTeam()); // not found nearest if (curloc == 0) @@ -64,15 +64,15 @@ void WorldSession::SendTaxiStatus(ObjectGuid guid) DEBUG_LOG("WORLD: Sent SMSG_TAXINODE_STATUS"); } -void WorldSession::HandleTaxiQueryAvailableNodes( WorldPacket & recv_data ) +void WorldSession::HandleTaxiQueryAvailableNodes(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Received CMSG_TAXIQUERYAVAILABLENODES" ); + DEBUG_LOG("WORLD: Received CMSG_TAXIQUERYAVAILABLENODES"); ObjectGuid guid; recv_data >> guid; // cheating checks - Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); + Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); if (!unit) { DEBUG_LOG("WORLD: HandleTaxiQueryAvailableNodes - %s not found or you can't interact with him.", guid.GetString().c_str()); @@ -80,56 +80,56 @@ void WorldSession::HandleTaxiQueryAvailableNodes( WorldPacket & recv_data ) } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); // unknown taxi node case - if( SendLearnNewTaxiNode(unit) ) + if (SendLearnNewTaxiNode(unit)) return; // known taxi node case - SendTaxiMenu( unit ); + SendTaxiMenu(unit); } -void WorldSession::SendTaxiMenu( Creature* unit ) +void WorldSession::SendTaxiMenu(Creature* unit) { // find current node - uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer( )->GetTeam()); + uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer()->GetTeam()); - if ( curloc == 0 ) + if (curloc == 0) return; - DEBUG_LOG( "WORLD: CMSG_TAXINODE_STATUS_QUERY %u ",curloc); + DEBUG_LOG("WORLD: CMSG_TAXINODE_STATUS_QUERY %u ",curloc); - WorldPacket data( SMSG_SHOWTAXINODES, (4+8+4+8*4) ); - data << uint32( 1 ); + WorldPacket data(SMSG_SHOWTAXINODES, (4+8+4+8*4)); + data << uint32(1); data << unit->GetObjectGuid(); - data << uint32( curloc ); + data << uint32(curloc); GetPlayer()->m_taxi.AppendTaximaskTo(data,GetPlayer()->isTaxiCheater()); - SendPacket( &data ); + SendPacket(&data); - DEBUG_LOG( "WORLD: Sent SMSG_SHOWTAXINODES" ); + DEBUG_LOG("WORLD: Sent SMSG_SHOWTAXINODES"); } -void WorldSession::SendDoFlight( uint32 mountDisplayId, uint32 path, uint32 pathNode ) +void WorldSession::SendDoFlight(uint32 mountDisplayId, uint32 path, uint32 pathNode) { // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - while(GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType()==FLIGHT_MOTION_TYPE) + while (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType()==FLIGHT_MOTION_TYPE) GetPlayer()->GetMotionMaster()->MovementExpired(false); if (mountDisplayId) - GetPlayer()->Mount( mountDisplayId ); + GetPlayer()->Mount(mountDisplayId); GetPlayer()->GetMotionMaster()->MoveTaxiFlight(path,pathNode); } -bool WorldSession::SendLearnNewTaxiNode( Creature* unit ) +bool WorldSession::SendLearnNewTaxiNode(Creature* unit) { // find current node - uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer( )->GetTeam()); + uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer()->GetTeam()); if (curloc == 0) return true; // `true` send to avoid WorldSession::SendTaxiMenu call with one more curlock seartch with same false result. @@ -150,41 +150,41 @@ bool WorldSession::SendLearnNewTaxiNode( Creature* unit ) return false; } -void WorldSession::HandleActivateTaxiExpressOpcode ( WorldPacket & recv_data ) +void WorldSession::HandleActivateTaxiExpressOpcode(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Received CMSG_ACTIVATETAXIEXPRESS" ); + DEBUG_LOG("WORLD: Received CMSG_ACTIVATETAXIEXPRESS"); ObjectGuid guid; uint32 node_count; recv_data >> guid >> node_count; - Creature *npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); + Creature* npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); if (!npc) { - DEBUG_LOG( "WORLD: HandleActivateTaxiExpressOpcode - %s not found or you can't interact with it.", guid.GetString().c_str()); + DEBUG_LOG("WORLD: HandleActivateTaxiExpressOpcode - %s not found or you can't interact with it.", guid.GetString().c_str()); return; } std::vector nodes; - for(uint32 i = 0; i < node_count; ++i) + for (uint32 i = 0; i < node_count; ++i) { uint32 node; recv_data >> node; nodes.push_back(node); } - if(nodes.empty()) + if (nodes.empty()) return; - DEBUG_LOG( "WORLD: Received CMSG_ACTIVATETAXIEXPRESS from %d to %d" ,nodes.front(),nodes.back()); + DEBUG_LOG("WORLD: Received CMSG_ACTIVATETAXIEXPRESS from %d to %d" ,nodes.front(),nodes.back()); GetPlayer()->ActivateTaxiPathTo(nodes, npc); } void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Received CMSG_MOVE_SPLINE_DONE" ); + DEBUG_LOG("WORLD: Received CMSG_MOVE_SPLINE_DONE"); ObjectGuid guid; // used only for proper packet read MovementInfo movementInfo; // used only for proper packet read @@ -199,15 +199,15 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data) // 2) switch from one map to other in case multi-map taxi path // we need process only (1) uint32 curDest = GetPlayer()->m_taxi.GetTaxiDestination(); - if(!curDest) + if (!curDest) return; TaxiNodesEntry const* curDestNode = sTaxiNodesStore.LookupEntry(curDest); // far teleport case - if(curDestNode && curDestNode->map_id != GetPlayer()->GetMapId()) + if (curDestNode && curDestNode->map_id != GetPlayer()->GetMapId()) { - if(GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType()==FLIGHT_MOTION_TYPE) + if (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType()==FLIGHT_MOTION_TYPE) { // short preparations to continue flight FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top()); @@ -224,7 +224,7 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data) } uint32 destinationnode = GetPlayer()->m_taxi.NextTaxiDestination(); - if ( destinationnode > 0 ) // if more destinations to go + if (destinationnode > 0) // if more destinations to go { // current source node for next destination uint32 sourcenode = GetPlayer()->m_taxi.GetTaxiSource(); @@ -232,22 +232,22 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data) // Add to taximask middle hubs in taxicheat mode (to prevent having player with disabled taxicheat and not having back flight path) if (GetPlayer()->isTaxiCheater()) { - if(GetPlayer()->m_taxi.SetTaximaskNode(sourcenode)) + if (GetPlayer()->m_taxi.SetTaximaskNode(sourcenode)) { WorldPacket data(SMSG_NEW_TAXI_PATH, 0); - _player->GetSession()->SendPacket( &data ); + _player->GetSession()->SendPacket(&data); } } - DEBUG_LOG( "WORLD: Taxi has to go from %u to %u", sourcenode, destinationnode ); + DEBUG_LOG("WORLD: Taxi has to go from %u to %u", sourcenode, destinationnode); uint32 mountDisplayId = sObjectMgr.GetTaxiMountDisplayId(sourcenode, GetPlayer()->GetTeam()); uint32 path, cost; - sObjectMgr.GetTaxiPath( sourcenode, destinationnode, path, cost); + sObjectMgr.GetTaxiPath(sourcenode, destinationnode, path, cost); - if(path && mountDisplayId) - SendDoFlight( mountDisplayId, path, 1 ); // skip start fly node + if (path && mountDisplayId) + SendDoFlight(mountDisplayId, path, 1); // skip start fly node else GetPlayer()->m_taxi.ClearTaxiDestinations(); // clear problematic path and next } @@ -255,7 +255,7 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data) GetPlayer()->m_taxi.ClearTaxiDestinations(); // not destinations, clear source node } -void WorldSession::HandleActivateTaxiOpcode( WorldPacket & recv_data ) +void WorldSession::HandleActivateTaxiOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Received CMSG_ACTIVATETAXI"); @@ -265,7 +265,7 @@ void WorldSession::HandleActivateTaxiOpcode( WorldPacket & recv_data ) recv_data >> guid >> nodes[0] >> nodes[1]; DEBUG_LOG("WORLD: Received CMSG_ACTIVATETAXI from %d to %d" ,nodes[0],nodes[1]); - Creature *npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); + Creature* npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); if (!npc) { DEBUG_LOG("WORLD: HandleActivateTaxiOpcode - %s not found or you can't interact with it.", guid.GetString().c_str()); diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index 80aeaa92d..0f49442b8 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -20,14 +20,14 @@ #include "Log.h" #include "CreatureAI.h" -TemporarySummon::TemporarySummon( ObjectGuid summoner ) : -Creature(CREATURE_SUBTYPE_TEMPORARY_SUMMON), m_type(TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN), m_timer(0), m_lifetime(0), m_summoner(summoner) +TemporarySummon::TemporarySummon(ObjectGuid summoner) : + Creature(CREATURE_SUBTYPE_TEMPORARY_SUMMON), m_type(TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN), m_timer(0), m_lifetime(0), m_summoner(summoner) { } -void TemporarySummon::Update( uint32 update_diff, uint32 diff ) +void TemporarySummon::Update(uint32 update_diff, uint32 diff) { - switch(m_type) + switch (m_type) { case TEMPSUMMON_MANUAL_DESPAWN: break; @@ -126,7 +126,7 @@ void TemporarySummon::Update( uint32 update_diff, uint32 diff ) return; } - if (!isInCombat() && isAlive() ) + if (!isInCombat() && isAlive()) { if (m_timer <= update_diff) { @@ -146,7 +146,7 @@ void TemporarySummon::Update( uint32 update_diff, uint32 diff ) break; } - Creature::Update( update_diff, diff ); + Creature::Update(update_diff, diff); } void TemporarySummon::Summon(TempSummonType type, uint32 lifetime) @@ -164,7 +164,7 @@ void TemporarySummon::UnSummon() CombatStop(); if (GetSummonerGuid().IsCreatureOrVehicle()) - if(Creature* sum = GetMap()->GetCreature(GetSummonerGuid())) + if (Creature* sum = GetMap()->GetCreature(GetSummonerGuid())) if (sum->AI()) sum->AI()->SummonedCreatureDespawn(this); diff --git a/src/game/TemporarySummon.h b/src/game/TemporarySummon.h index 78488b08a..501226fd1 100644 --- a/src/game/TemporarySummon.h +++ b/src/game/TemporarySummon.h @@ -26,7 +26,7 @@ class TemporarySummon : public Creature { public: explicit TemporarySummon(ObjectGuid summoner = ObjectGuid()); - virtual ~TemporarySummon(){}; + virtual ~TemporarySummon() {}; void Update(uint32 update_diff, uint32 time) override; void Summon(TempSummonType type, uint32 lifetime); diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp index b2516913f..bbfc91ac3 100644 --- a/src/game/ThreatManager.cpp +++ b/src/game/ThreatManager.cpp @@ -30,7 +30,7 @@ //============================================================== // The pHatingUnit is not used yet -float ThreatCalcHelper::CalcThreat(Unit* pHatedUnit, Unit* /*pHatingUnit*/, float threat, bool crit, SpellSchoolMask schoolMask, SpellEntry const *pThreatSpell) +float ThreatCalcHelper::CalcThreat(Unit* pHatedUnit, Unit* /*pHatingUnit*/, float threat, bool crit, SpellSchoolMask schoolMask, SpellEntry const* pThreatSpell) { // all flat mods applied early if (!threat) @@ -56,7 +56,7 @@ float ThreatCalcHelper::CalcThreat(Unit* pHatedUnit, Unit* /*pHatingUnit*/, floa //================= HostileReference ========================== //============================================================ -HostileReference::HostileReference(Unit* pUnit, ThreatManager *pThreatManager, float pThreat) +HostileReference::HostileReference(Unit* pUnit, ThreatManager* pThreatManager, float pThreat) { iThreat = pThreat; iTempThreatModifyer = 0.0f; @@ -93,7 +93,7 @@ void HostileReference::sourceObjectDestroyLink() void HostileReference::fireStatusChanged(ThreatRefStatusChangeEvent& pThreatRefStatusChangeEvent) { - if(getSource()) + if (getSource()) getSource()->processThreatEvent(&pThreatRefStatusChangeEvent); } @@ -104,18 +104,18 @@ void HostileReference::addThreat(float pMod) iThreat += pMod; // the threat is changed. Source and target unit have to be availabe // if the link was cut before relink it again - if(!isOnline()) + if (!isOnline()) updateOnlineStatus(); - if(pMod != 0.0f) + if (pMod != 0.0f) { ThreatRefStatusChangeEvent event(UEV_THREAT_REF_THREAT_CHANGE, this, pMod); fireStatusChanged(event); } - if(isValid() && pMod >= 0) + if (isValid() && pMod >= 0) { Unit* victim_owner = getTarget()->GetOwner(); - if(victim_owner && victim_owner->isAlive()) + if (victim_owner && victim_owner->isAlive()) getSource()->addThreat(victim_owner, 0.0f); // create a threat to the owner of a pet, if the pet attacks } } @@ -137,15 +137,15 @@ void HostileReference::updateOnlineStatus() // ref is valid // target is no player or not gamemaster // target is not in flight - if(isValid() && - ((getTarget()->GetTypeId() != TYPEID_PLAYER || !((Player*)getTarget())->isGameMaster()) || - !getTarget()->IsTaxiFlying())) + if (isValid() && + ((getTarget()->GetTypeId() != TYPEID_PLAYER || !((Player*)getTarget())->isGameMaster()) || + !getTarget()->IsTaxiFlying())) { - Creature* creature = (Creature* ) getSourceUnit(); + Creature* creature = (Creature*) getSourceUnit(); online = getTarget()->isInAccessablePlaceFor(creature); - if(!online) + if (!online) { - if(creature->AI()->canReachByRangeAttack(getTarget())) + if (creature->AI()->canReachByRangeAttack(getTarget())) online = true; // not accessable but stays online } else @@ -161,10 +161,10 @@ void HostileReference::updateOnlineStatus() void HostileReference::setOnlineOfflineState(bool pIsOnline) { - if(iOnline != pIsOnline) + if (iOnline != pIsOnline) { iOnline = pIsOnline; - if(!iOnline) + if (!iOnline) setAccessibleState(false); // if not online that not accessable as well ThreatRefStatusChangeEvent event(UEV_THREAT_REF_ONLINE_STATUS, this); @@ -176,7 +176,7 @@ void HostileReference::setOnlineOfflineState(bool pIsOnline) void HostileReference::setAccessibleState(bool pIsAccessible) { - if(iAccessible != pIsAccessible) + if (iAccessible != pIsAccessible) { iAccessible = pIsAccessible; @@ -210,10 +210,10 @@ Unit* HostileReference::getSourceUnit() void ThreatContainer::clearReferences() { - for(ThreatList::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) + for (ThreatList::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) { (*i)->unlink(); - delete (*i); + delete(*i); } iThreatList.clear(); } @@ -224,7 +224,7 @@ HostileReference* ThreatContainer::getReferenceByTarget(Unit* pVictim) { HostileReference* result = NULL; ObjectGuid guid = pVictim->GetObjectGuid(); - for(ThreatList::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) + for (ThreatList::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) { if ((*i)->getUnitGuid() == guid) { @@ -242,18 +242,18 @@ HostileReference* ThreatContainer::getReferenceByTarget(Unit* pVictim) HostileReference* ThreatContainer::addThreat(Unit* pVictim, float pThreat) { HostileReference* ref = getReferenceByTarget(pVictim); - if(ref) + if (ref) ref->addThreat(pThreat); return ref; } //============================================================ -void ThreatContainer::modifyThreatPercent(Unit *pVictim, int32 pPercent) +void ThreatContainer::modifyThreatPercent(Unit* pVictim, int32 pPercent) { - if(HostileReference* ref = getReferenceByTarget(pVictim)) + if (HostileReference* ref = getReferenceByTarget(pVictim)) { - if(pPercent < -100) + if (pPercent < -100) { ref->removeReference(); delete ref; @@ -276,7 +276,7 @@ bool HostileReferenceSortPredicate(const HostileReference* lhs, const HostileRef void ThreatContainer::update() { - if(iDirty && iThreatList.size() >1) + if (iDirty && iThreatList.size() >1) { iThreatList.sort(HostileReferenceSortPredicate); } @@ -361,8 +361,9 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* pAttacker, Hostile } if (pCurrentRef->getThreat() > 1.3f * pCurrentVictim->getThreat() || - (pCurrentRef->getThreat() > 1.1f * pCurrentVictim->getThreat() && pAttacker->CanReachWithMeleeAttack(pTarget))) - { // implement 110% threat rule for targets in melee range + (pCurrentRef->getThreat() > 1.1f * pCurrentVictim->getThreat() && pAttacker->CanReachWithMeleeAttack(pTarget))) + { + // implement 110% threat rule for targets in melee range found = true; // and 130% rule for targets in ranged distances break; // for selecting alive targets } @@ -386,7 +387,7 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* pAttacker, Hostile //============================================================ ThreatManager::ThreatManager(Unit* owner) -: iCurrentVictim(NULL), iOwner(owner), iUpdateTimer(THREAT_UPDATE_INTERVAL), iUpdateNeed(false) + : iCurrentVictim(NULL), iOwner(owner), iUpdateTimer(THREAT_UPDATE_INTERVAL), iUpdateNeed(false) { } @@ -403,7 +404,7 @@ void ThreatManager::clearReferences() //============================================================ -void ThreatManager::addThreat(Unit* pVictim, float pThreat, bool crit, SpellSchoolMask schoolMask, SpellEntry const *pThreatSpell) +void ThreatManager::addThreat(Unit* pVictim, float pThreat, bool crit, SpellSchoolMask schoolMask, SpellEntry const* pThreatSpell) { //function deals with adding threat and adding players and pets into ThreatList //mobs, NPCs, guards have ThreatList and HateOfflineList @@ -415,11 +416,11 @@ void ThreatManager::addThreat(Unit* pVictim, float pThreat, bool crit, SpellScho return; // not to GM - if (!pVictim || (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster()) ) + if (!pVictim || (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster())) return; // not to dead and not for dead - if(!pVictim->isAlive() || !getOwner()->isAlive() ) + if (!pVictim->isAlive() || !getOwner()->isAlive()) return; MANGOS_ASSERT(getOwner()->GetTypeId()== TYPEID_UNIT); @@ -455,21 +456,21 @@ void ThreatManager::addThreatDirectly(Unit* pVictim, float threat) else ref = iThreatOfflineContainer.addThreat(pVictim, threat); - if(!ref) // there was no ref => create a new one + if (!ref) // there was no ref => create a new one { // threat has to be 0 here HostileReference* hostileReference = new HostileReference(pVictim, this, 0); iThreatContainer.addReference(hostileReference); hostileReference->addThreat(threat); // now we add the real threat iUpdateNeed = true; - if(pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster()) + if (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster()) hostileReference->setOnlineOfflineState(false); // GM is always offline } } //============================================================ -void ThreatManager::modifyThreatPercent(Unit *pVictim, int32 pPercent) +void ThreatManager::modifyThreatPercent(Unit* pVictim, int32 pPercent) { iThreatContainer.modifyThreatPercent(pVictim, pPercent); iUpdateNeed = true; @@ -487,13 +488,13 @@ Unit* ThreatManager::getHostileTarget() //============================================================ -float ThreatManager::getThreat(Unit *pVictim, bool pAlsoSearchOfflineList) +float ThreatManager::getThreat(Unit* pVictim, bool pAlsoSearchOfflineList) { float threat = 0.0f; HostileReference* ref = iThreatContainer.getReferenceByTarget(pVictim); - if(!ref && pAlsoSearchOfflineList) + if (!ref && pAlsoSearchOfflineList) ref = iThreatOfflineContainer.getReferenceByTarget(pVictim); - if(ref) + if (ref) threat = ref->getThreat(); return threat; } @@ -502,12 +503,12 @@ float ThreatManager::getThreat(Unit *pVictim, bool pAlsoSearchOfflineList) void ThreatManager::tauntApply(Unit* pTaunter) { - if(HostileReference* ref = iThreatContainer.getReferenceByTarget(pTaunter)) + if (HostileReference* ref = iThreatContainer.getReferenceByTarget(pTaunter)) { - if(getCurrentVictim() && (ref->getThreat() < getCurrentVictim()->getThreat())) + if (getCurrentVictim() && (ref->getThreat() < getCurrentVictim()->getThreat())) { // Ok, temp threat is unused - if(ref->getTempThreatModifyer() == 0.0f) + if (ref->getTempThreatModifyer() == 0.0f) { ref->setTempThreat(getCurrentVictim()->getThreat()); iUpdateNeed = true; @@ -518,9 +519,9 @@ void ThreatManager::tauntApply(Unit* pTaunter) //============================================================ -void ThreatManager::tauntFadeOut(Unit *pTaunter) +void ThreatManager::tauntFadeOut(Unit* pTaunter) { - if(HostileReference* ref = iThreatContainer.getReferenceByTarget(pTaunter)) + if (HostileReference* ref = iThreatContainer.getReferenceByTarget(pTaunter)) { ref->resetTempThreat(); iUpdateNeed = true; @@ -552,15 +553,15 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat HostileReference* hostileReference = threatRefStatusChangeEvent->getReference(); - switch(threatRefStatusChangeEvent->getType()) + switch (threatRefStatusChangeEvent->getType()) { case UEV_THREAT_REF_THREAT_CHANGE: - if((getCurrentVictim() == hostileReference && threatRefStatusChangeEvent->getFValue()<0.0f) || - (getCurrentVictim() != hostileReference && threatRefStatusChangeEvent->getFValue()>0.0f)) + if ((getCurrentVictim() == hostileReference && threatRefStatusChangeEvent->getFValue()<0.0f) || + (getCurrentVictim() != hostileReference && threatRefStatusChangeEvent->getFValue()>0.0f)) setDirty(true); // the order in the threat list might have changed break; case UEV_THREAT_REF_ONLINE_STATUS: - if(!hostileReference->isOnline()) + if (!hostileReference->isOnline()) { if (hostileReference == getCurrentVictim()) { @@ -574,7 +575,7 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat } else { - if(getCurrentVictim() && hostileReference->getThreat() > (1.1f * getCurrentVictim()->getThreat())) + if (getCurrentVictim() && hostileReference->getThreat() > (1.1f * getCurrentVictim()->getThreat())) setDirty(true); iThreatContainer.addReference(hostileReference); iUpdateNeed = true; @@ -587,7 +588,7 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat setCurrentVictim(NULL); setDirty(true); } - if(hostileReference->isOnline()) + if (hostileReference->isOnline()) { iOwner->SendThreatRemove(hostileReference); iThreatContainer.remove(hostileReference); diff --git a/src/game/ThreatManager.h b/src/game/ThreatManager.h index cdf7e25a4..1f8cdd770 100644 --- a/src/game/ThreatManager.h +++ b/src/game/ThreatManager.h @@ -42,14 +42,14 @@ struct SpellEntry; class ThreatCalcHelper { public: - static float CalcThreat(Unit* pHatedUnit, Unit* pHatingUnit, float threat, bool crit, SpellSchoolMask schoolMask, SpellEntry const *threatSpell); + static float CalcThreat(Unit* pHatedUnit, Unit* pHatingUnit, float threat, bool crit, SpellSchoolMask schoolMask, SpellEntry const* threatSpell); }; //============================================================== class MANGOS_DLL_SPEC HostileReference : public Reference { public: - HostileReference(Unit* pUnit, ThreatManager *pThreatManager, float pThreat); + HostileReference(Unit* pUnit, ThreatManager* pThreatManager, float pThreat); //================================================= void addThreat(float pMod); @@ -72,11 +72,11 @@ class MANGOS_DLL_SPEC HostileReference : public Reference // used for temporary setting a threat and reducting it later again. // the threat modification is stored - void setTempThreat(float pThreat) { iTempThreatModifyer = pThreat - getThreat(); if(iTempThreatModifyer != 0.0f) addThreat(iTempThreatModifyer); } + void setTempThreat(float pThreat) { iTempThreatModifyer = pThreat - getThreat(); if (iTempThreatModifyer != 0.0f) addThreat(iTempThreatModifyer); } void resetTempThreat() { - if(iTempThreatModifyer != 0.0f) + if (iTempThreatModifyer != 0.0f) { addThreat(-iTempThreatModifyer); iTempThreatModifyer = 0.0f; } @@ -106,7 +106,7 @@ class MANGOS_DLL_SPEC HostileReference : public Reference //================================================= - HostileReference* next() { return ((HostileReference* ) Reference::next()); } + HostileReference* next() { return ((HostileReference*) Reference::next()); } //================================================= @@ -156,7 +156,7 @@ class MANGOS_DLL_SPEC ThreatContainer HostileReference* addThreat(Unit* pVictim, float pThreat); - void modifyThreatPercent(Unit *pVictim, int32 percent); + void modifyThreatPercent(Unit* pVictim, int32 percent); HostileReference* selectNextVictim(Creature* pAttacker, HostileReference* pCurrentVictim); @@ -180,21 +180,21 @@ class MANGOS_DLL_SPEC ThreatManager public: friend class HostileReference; - explicit ThreatManager(Unit *pOwner); + explicit ThreatManager(Unit* pOwner); ~ThreatManager() { clearReferences(); } void clearReferences(); - void addThreat(Unit* pVictim, float threat, bool crit, SpellSchoolMask schoolMask, SpellEntry const *threatSpell); + void addThreat(Unit* pVictim, float threat, bool crit, SpellSchoolMask schoolMask, SpellEntry const* threatSpell); void addThreat(Unit* pVictim, float threat) { addThreat(pVictim,threat,false,SPELL_SCHOOL_MASK_NONE,NULL); } // add threat as raw value (ignore redirections and expection all mods applied already to it void addThreatDirectly(Unit* pVictim, float threat); - void modifyThreatPercent(Unit *pVictim, int32 pPercent); + void modifyThreatPercent(Unit* pVictim, int32 pPercent); - float getThreat(Unit *pVictim, bool pAlsoSearchOfflineList = false); + float getThreat(Unit* pVictim, bool pAlsoSearchOfflineList = false); bool isThreatListEmpty() const { return iThreatContainer.empty(); } @@ -209,7 +209,7 @@ class MANGOS_DLL_SPEC ThreatManager Unit* getHostileTarget(); void tauntApply(Unit* pTaunter); - void tauntFadeOut(Unit *pTaunter); + void tauntFadeOut(Unit* pTaunter); void setCurrentVictim(HostileReference* pHostileReference); diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp index f68266eb9..9734d267f 100644 --- a/src/game/Totem.cpp +++ b/src/game/Totem.cpp @@ -52,7 +52,7 @@ bool Totem::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cPos.SelectFinalPoint(this); // totem must be at same Z in case swimming caster and etc. - if (fabs(cPos.m_pos.z - owner->GetPositionZ() ) > 5.0f) + if (fabs(cPos.m_pos.z - owner->GetPositionZ()) > 5.0f) cPos.m_pos.z = owner->GetPositionZ(); if (!cPos.Relocate(this)) @@ -69,9 +69,9 @@ bool Totem::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* return true; } -void Totem::Update(uint32 update_diff, uint32 time ) +void Totem::Update(uint32 update_diff, uint32 time) { - Unit *owner = GetOwner(); + Unit* owner = GetOwner(); if (!owner || !owner->isAlive() || !isAlive()) { UnSummon(); // remove self @@ -86,7 +86,7 @@ void Totem::Update(uint32 update_diff, uint32 time ) else m_duration -= update_diff; - Creature::Update( update_diff, time ); + Creature::Update(update_diff, time); } void Totem::Summon(Unit* owner) @@ -101,7 +101,7 @@ void Totem::Summon(Unit* owner) if (!GetSpell()) return; - switch(m_type) + switch (m_type) { case TOTEM_PASSIVE: CastSpell(this, GetSpell(), true); @@ -118,7 +118,7 @@ void Totem::UnSummon() CombatStop(); RemoveAurasDueToSpell(GetSpell()); - if (Unit *owner = GetOwner()) + if (Unit* owner = GetOwner()) { owner->_RemoveTotem(this); owner->RemoveAurasDueToSpell(GetSpell()); @@ -129,12 +129,12 @@ void Totem::UnSummon() ((Player*)owner)->SendAutoRepeatCancel(this); // Not only the player can summon the totem (scripted AI) - if (Group *pGroup = ((Player*)owner)->GetGroup()) + if (Group* pGroup = ((Player*)owner)->GetGroup()) { - 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)) + if (Target && pGroup->SameSubGroup((Player*)owner, Target)) Target->RemoveAurasDueToSpell(GetSpell()); } } @@ -159,7 +159,7 @@ void Totem::SetOwner(Unit* owner) SetLevel(owner->getLevel()); } -Unit *Totem::GetOwner() +Unit* Totem::GetOwner() { if (ObjectGuid ownerGuid = GetOwnerGuid()) return ObjectAccessor::GetUnit(*this, ownerGuid); @@ -167,26 +167,26 @@ Unit *Totem::GetOwner() return NULL; } -void Totem::SetTypeBySummonSpell(SpellEntry const * spellProto) +void Totem::SetTypeBySummonSpell(SpellEntry const* spellProto) { // Get spell casted by totem - SpellEntry const * totemSpell = sSpellStore.LookupEntry(GetSpell()); + SpellEntry const* totemSpell = sSpellStore.LookupEntry(GetSpell()); if (totemSpell) { // If spell have cast time -> so its active totem if (GetSpellCastTime(totemSpell)) m_type = TOTEM_ACTIVE; } - if(spellProto->SpellIconID == 2056) + if (spellProto->SpellIconID == 2056) m_type = TOTEM_STATUE; //Jewelery statue } bool Totem::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const { - switch(spellInfo->Effect[index]) + switch (spellInfo->Effect[index]) { case SPELL_EFFECT_ATTACK_ME: - // immune to any type of regeneration effects hp/mana etc. + // immune to any type of regeneration effects hp/mana etc. case SPELL_EFFECT_HEAL: case SPELL_EFFECT_HEAL_MAX_HEALTH: case SPELL_EFFECT_HEAL_MECHANICAL: diff --git a/src/game/Totem.h b/src/game/Totem.h index 6ef031393..cb946d5b1 100644 --- a/src/game/Totem.h +++ b/src/game/Totem.h @@ -32,16 +32,16 @@ class Totem : public Creature { public: explicit Totem(); - virtual ~Totem(){}; + virtual ~Totem() {}; bool Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, Unit* owner); void Update(uint32 update_diff, uint32 time) override; void Summon(Unit* owner); void UnSummon(); uint32 GetSpell() const { return m_spells[0]; } uint32 GetTotemDuration() const { return m_duration; } - Unit *GetOwner(); + Unit* GetOwner(); TotemType GetTotemType() const { return m_type; } - void SetTypeBySummonSpell(SpellEntry const * spellProto); + void SetTypeBySummonSpell(SpellEntry const* spellProto); void SetDuration(uint32 dur) { m_duration = dur; } void SetOwner(Unit* owner); @@ -51,7 +51,7 @@ class Totem : public Creature void UpdateArmor() {} void UpdateMaxHealth() {} void UpdateMaxPower(Powers /*power*/) {} - void UpdateAttackPowerAndDamage(bool /*ranged*/ ) {} + void UpdateAttackPowerAndDamage(bool /*ranged*/) {} void UpdateDamagePhysical(WeaponAttackType /*attType*/) {} bool IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const; diff --git a/src/game/TotemAI.cpp b/src/game/TotemAI.cpp index 951f87d56..78f412573 100644 --- a/src/game/TotemAI.cpp +++ b/src/game/TotemAI.cpp @@ -27,20 +27,20 @@ #include "CellImpl.h" int -TotemAI::Permissible(const Creature *creature) +TotemAI::Permissible(const Creature* creature) { - if( creature->IsTotem() ) + if (creature->IsTotem()) return PERMIT_BASE_PROACTIVE; return PERMIT_BASE_NO; } -TotemAI::TotemAI(Creature *c) : CreatureAI(c) +TotemAI::TotemAI(Creature* c) : CreatureAI(c) { } void -TotemAI::MoveInLineOfSight(Unit *) +TotemAI::MoveInLineOfSight(Unit*) { } @@ -59,7 +59,7 @@ TotemAI::UpdateAI(const uint32 /*diff*/) return; // Search spell - SpellEntry const *spellInfo = sSpellStore.LookupEntry(getTotem().GetSpell()); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(getTotem().GetSpell()); if (!spellInfo) return; @@ -73,9 +73,9 @@ TotemAI::UpdateAI(const uint32 /*diff*/) Unit* victim = m_creature->GetMap()->GetUnit(i_victimGuid); // Search victim if no, not attackable, or out of range, or friendly (possible in case duel end) - if( !victim || - !victim->isTargetableForAttack() || !m_creature->IsWithinDistInMap(victim, max_range) || - m_creature->IsFriendlyTo(victim) || !victim->isVisibleForOrDetect(m_creature,m_creature,false) ) + if (!victim || + !victim->isTargetableForAttack() || !m_creature->IsWithinDistInMap(victim, max_range) || + m_creature->IsFriendlyTo(victim) || !victim->isVisibleForOrDetect(m_creature,m_creature,false)) { victim = NULL; @@ -99,13 +99,13 @@ TotemAI::UpdateAI(const uint32 /*diff*/) } bool -TotemAI::IsVisible(Unit *) const +TotemAI::IsVisible(Unit*) const { return false; } void -TotemAI::AttackStart(Unit *) +TotemAI::AttackStart(Unit*) { } diff --git a/src/game/TotemAI.h b/src/game/TotemAI.h index 8a95cb6c3..dc5eb6b40 100644 --- a/src/game/TotemAI.h +++ b/src/game/TotemAI.h @@ -30,15 +30,15 @@ class MANGOS_DLL_DECL TotemAI : public CreatureAI { public: - explicit TotemAI(Creature *c); + explicit TotemAI(Creature* c); - void MoveInLineOfSight(Unit *); - void AttackStart(Unit *); + void MoveInLineOfSight(Unit*); + void AttackStart(Unit*); void EnterEvadeMode(); - bool IsVisible(Unit *) const; + bool IsVisible(Unit*) const; void UpdateAI(const uint32); - static int Permissible(const Creature *); + static int Permissible(const Creature*); protected: Totem& getTotem(); diff --git a/src/game/TradeHandler.cpp b/src/game/TradeHandler.cpp index 336a8e432..23266833e 100644 --- a/src/game/TradeHandler.cpp +++ b/src/game/TradeHandler.cpp @@ -34,7 +34,7 @@ void WorldSession::SendTradeStatus(TradeStatus status) { WorldPacket data; - switch(status) + switch (status) { case TRADE_STATUS_BEGIN_TRADE: data.Initialize(SMSG_TRADE_STATUS, 4+8); @@ -69,13 +69,13 @@ void WorldSession::SendTradeStatus(TradeStatus status) void WorldSession::HandleIgnoreTradeOpcode(WorldPacket& /*recvPacket*/) { - DEBUG_LOG( "WORLD: Ignore Trade %u",_player->GetGUIDLow()); + DEBUG_LOG("WORLD: Ignore Trade %u",_player->GetGUIDLow()); // recvPacket.print_storage(); } void WorldSession::HandleBusyTradeOpcode(WorldPacket& /*recvPacket*/) { - DEBUG_LOG( "WORLD: Busy Trade %u",_player->GetGUIDLow()); + DEBUG_LOG("WORLD: Busy Trade %u",_player->GetGUIDLow()); // recvPacket.print_storage(); } @@ -91,7 +91,7 @@ void WorldSession::SendUpdateTrade(bool trader_state /*= true*/) data << uint32(view_trade->GetMoney()); // trader gold data << uint32(view_trade->GetSpell()); // spell casted on lowest slot item - for(uint8 i = 0; i < TRADE_SLOT_COUNT; ++i) + for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i) { data << uint8(i); // trade slot number, if not specified, then end of packet @@ -100,27 +100,27 @@ void WorldSession::SendUpdateTrade(bool trader_state /*= true*/) data << uint32(item->GetProto()->ItemId); // entry data << uint32(item->GetProto()->DisplayInfoID);// display id data << uint32(item->GetCount()); // stack count - // wrapped: hide stats but show giftcreator name + // wrapped: hide stats but show giftcreator name data << uint32(item->HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED) ? 1 : 0); data << item->GetGuidValue(ITEM_FIELD_GIFTCREATOR); data << uint32(item->GetEnchantmentId(PERM_ENCHANTMENT_SLOT)); - for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot) data << uint32(item->GetEnchantmentId(EnchantmentSlot(enchant_slot))); - // creator + // creator data << item->GetGuidValue(ITEM_FIELD_CREATOR); data << uint32(item->GetSpellCharges()); // charges data << uint32(item->GetItemSuffixFactor()); // SuffixFactor data << uint32(item->GetItemRandomPropertyId());// random properties id data << uint32(item->GetProto()->LockID); // lock id - // max durability + // max durability data << uint32(item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)); - // durability + // durability data << uint32(item->GetUInt32Value(ITEM_FIELD_DURABILITY)); } else { - for(uint8 j = 0; j < 18; ++j) + for (uint8 j = 0; j < 18; ++j) data << uint32(0); } } @@ -136,13 +136,13 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) if (!trader) return; - for(int i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i) + for (int i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i) { ItemPosCountVec traderDst; ItemPosCountVec playerDst; - bool traderCanTrade = (myItems[i]==NULL || trader->CanStoreItem( NULL_BAG, NULL_SLOT, traderDst, myItems[i], false ) == EQUIP_ERR_OK); - bool playerCanTrade = (hisItems[i]==NULL || _player->CanStoreItem( NULL_BAG, NULL_SLOT, playerDst, hisItems[i], false ) == EQUIP_ERR_OK); - if (traderCanTrade && playerCanTrade ) + bool traderCanTrade = (myItems[i]==NULL || trader->CanStoreItem(NULL_BAG, NULL_SLOT, traderDst, myItems[i], false) == EQUIP_ERR_OK); + bool playerCanTrade = (hisItems[i]==NULL || _player->CanStoreItem(NULL_BAG, NULL_SLOT, playerDst, hisItems[i], false) == EQUIP_ERR_OK); + if (traderCanTrade && playerCanTrade) { // Ok, if trade item exists and can be stored // If we trade in both directions we had to check, if the trade will work before we actually do it @@ -154,13 +154,13 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) if (_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", - _player->GetName(), _player->GetSession()->GetAccountId(), - myItems[i]->GetProto()->Name1, myItems[i]->GetEntry(), myItems[i]->GetCount(), - trader->GetName(), trader->GetSession()->GetAccountId()); + _player->GetName(), _player->GetSession()->GetAccountId(), + myItems[i]->GetProto()->Name1, myItems[i]->GetEntry(), myItems[i]->GetCount(), + trader->GetName(), trader->GetSession()->GetAccountId()); } // store - trader->MoveItemToInventory( traderDst, myItems[i], true, true); + trader->MoveItemToInventory(traderDst, myItems[i], true, true); } if (hisItems[i]) @@ -170,13 +170,13 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) if (trader->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { sLog.outCommand(trader->GetSession()->GetAccountId(),"GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", - trader->GetName(), trader->GetSession()->GetAccountId(), - hisItems[i]->GetProto()->Name1, hisItems[i]->GetEntry(), hisItems[i]->GetCount(), - _player->GetName(), _player->GetSession()->GetAccountId()); + trader->GetName(), trader->GetSession()->GetAccountId(), + hisItems[i]->GetProto()->Name1, hisItems[i]->GetEntry(), hisItems[i]->GetCount(), + _player->GetName(), _player->GetSession()->GetAccountId()); } // store - _player->MoveItemToInventory( playerDst, hisItems[i], true, true); + _player->MoveItemToInventory(playerDst, hisItems[i], true, true); } } else @@ -187,7 +187,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) { if (!traderCanTrade) sLog.outError("trader can't store item: %s", myItems[i]->GetGuidStr().c_str()); - if (_player->CanStoreItem( NULL_BAG, NULL_SLOT, playerDst, myItems[i], false ) == EQUIP_ERR_OK) + if (_player->CanStoreItem(NULL_BAG, NULL_SLOT, playerDst, myItems[i], false) == EQUIP_ERR_OK) _player->MoveItemToInventory(playerDst, myItems[i], true, true); else sLog.outError("player can't take item back: %s", myItems[i]->GetGuidStr().c_str()); @@ -197,7 +197,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) { if (!playerCanTrade) sLog.outError("player can't store item: %s", hisItems[i]->GetGuidStr().c_str()); - if (trader->CanStoreItem( NULL_BAG, NULL_SLOT, traderDst, hisItems[i], false ) == EQUIP_ERR_OK) + if (trader->CanStoreItem(NULL_BAG, NULL_SLOT, traderDst, hisItems[i], false) == EQUIP_ERR_OK) trader->MoveItemToInventory(traderDst, hisItems[i], true, true); else sLog.outError("trader can't take item back: %s", hisItems[i]->GetGuidStr().c_str()); @@ -207,13 +207,13 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) } //============================================================== -static void setAcceptTradeMode(TradeData* myTrade, TradeData* hisTrade, Item **myItems, Item **hisItems) +static void setAcceptTradeMode(TradeData* myTrade, TradeData* hisTrade, Item** myItems, Item** hisItems) { myTrade->SetInAcceptProcess(true); hisTrade->SetInAcceptProcess(true); // store items in local list and set 'in-trade' flag - for(int i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i) + for (int i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i) { if (Item* item = myTrade->GetItem(TradeSlots(i))) { @@ -238,7 +238,7 @@ static void clearAcceptTradeMode(TradeData* myTrade, TradeData* hisTrade) hisTrade->SetInAcceptProcess(false); } -static void clearAcceptTradeMode(Item **myItems, Item **hisItems) +static void clearAcceptTradeMode(Item** myItems, Item** hisItems) { // clear 'in-trade' flag for (int i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i) @@ -264,8 +264,8 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& recvPacket) if (!his_trade) return; - Item *myItems[TRADE_SLOT_TRADED_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL }; - Item *hisItems[TRADE_SLOT_TRADED_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL }; + Item* myItems[TRADE_SLOT_TRADED_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL }; + Item* hisItems[TRADE_SLOT_TRADED_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL }; bool myCanCompleteTrade=true,hisCanCompleteTrade=true; // set before checks to properly undo at problems (it already set in to client) @@ -282,13 +282,13 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& recvPacket) // not accept case incorrect money amount if (his_trade->GetMoney() > trader->GetMoney()) { - trader->GetSession( )->SendNotification(LANG_NOT_ENOUGH_GOLD); + trader->GetSession()->SendNotification(LANG_NOT_ENOUGH_GOLD); his_trade->SetAccepted(false, true); return; } // not accept if some items now can't be trade (cheating) - for(int i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i) + for (int i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i) { if (Item* item = my_trade->GetItem(TradeSlots(i))) { @@ -326,7 +326,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& recvPacket) Item* castItem = my_trade->GetSpellCastItem(); if (!spellEntry || !his_trade->GetItem(TRADE_SLOT_NONTRADED) || - (my_trade->HasSpellCastItem() && !castItem)) + (my_trade->HasSpellCastItem() && !castItem)) { clearAcceptTradeMode(my_trade, his_trade); clearAcceptTradeMode(myItems, hisItems); @@ -361,7 +361,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& recvPacket) Item* castItem = his_trade->GetSpellCastItem(); if (!spellEntry || !my_trade->GetItem(TRADE_SLOT_NONTRADED) || - (his_trade->HasSpellCastItem() && !castItem)) + (his_trade->HasSpellCastItem() && !castItem)) { delete my_spell; his_trade->SetSpell(0); @@ -396,18 +396,18 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& recvPacket) trader->GetSession()->SendTradeStatus(TRADE_STATUS_TRADE_ACCEPT); // test if item will fit in each inventory - hisCanCompleteTrade = (trader->CanStoreItems( myItems,TRADE_SLOT_TRADED_COUNT )== EQUIP_ERR_OK); - myCanCompleteTrade = (_player->CanStoreItems( hisItems,TRADE_SLOT_TRADED_COUNT ) == EQUIP_ERR_OK); + hisCanCompleteTrade = (trader->CanStoreItems(myItems,TRADE_SLOT_TRADED_COUNT)== EQUIP_ERR_OK); + myCanCompleteTrade = (_player->CanStoreItems(hisItems,TRADE_SLOT_TRADED_COUNT) == EQUIP_ERR_OK); clearAcceptTradeMode(myItems, hisItems); // in case of missing space report error - if(!myCanCompleteTrade) + if (!myCanCompleteTrade) { clearAcceptTradeMode(my_trade, his_trade); SendNotification(LANG_NOT_FREE_TRADE_SLOTS); - trader->GetSession( )->SendNotification(LANG_NOT_PARTNER_FREE_TRADE_SLOTS); + trader->GetSession()->SendNotification(LANG_NOT_PARTNER_FREE_TRADE_SLOTS); my_trade->SetAccepted(false); his_trade->SetAccepted(false); return; @@ -424,7 +424,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& recvPacket) } // execute trade: 1. remove - for(int i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i) + for (int i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i) { if (Item* item = myItems[i]) { @@ -447,23 +447,23 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& recvPacket) if (_player->GetSession()->GetSecurity() > SEC_PLAYER && my_trade->GetMoney() > 0) { sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", - _player->GetName(),_player->GetSession()->GetAccountId(), - my_trade->GetMoney(), - trader->GetName(), trader->GetSession()->GetAccountId()); + _player->GetName(),_player->GetSession()->GetAccountId(), + my_trade->GetMoney(), + trader->GetName(), trader->GetSession()->GetAccountId()); } if (trader->GetSession()->GetSecurity() > SEC_PLAYER && his_trade->GetMoney() > 0) { sLog.outCommand(trader->GetSession()->GetAccountId(),"GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", - trader->GetName(), trader->GetSession()->GetAccountId(), - his_trade->GetMoney(), - _player->GetName(),_player->GetSession()->GetAccountId()); + trader->GetName(), trader->GetSession()->GetAccountId(), + his_trade->GetMoney(), + _player->GetName(),_player->GetSession()->GetAccountId()); } } // update money - _player->ModifyMoney( -int32(my_trade->GetMoney()) ); + _player->ModifyMoney(-int32(my_trade->GetMoney())); _player->ModifyMoney(his_trade->GetMoney()); - trader->ModifyMoney( -int32(his_trade->GetMoney()) ); + trader->ModifyMoney(-int32(his_trade->GetMoney())); trader->ModifyMoney(my_trade->GetMoney()); if (my_spell) @@ -560,7 +560,7 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) return; } - Player* pOther = ObjectAccessor::FindPlayer( otherGuid ); + Player* pOther = ObjectAccessor::FindPlayer(otherGuid); if (!pOther) { @@ -604,7 +604,7 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) return; } - if (pOther->GetTeam() !=_player->GetTeam() ) + if (pOther->GetTeam() !=_player->GetTeam()) { SendTradeStatus(TRADE_STATUS_WRONG_FACTION); return; diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 2b517428e..c497e2bf3 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -31,17 +31,17 @@ void MapManager::LoadTransports() { - QueryResult *result = WorldDatabase.Query("SELECT entry, name, period FROM transports"); + QueryResult* result = WorldDatabase.Query("SELECT entry, name, period FROM transports"); uint32 count = 0; - if( !result ) + if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); - sLog.outString( ">> Loaded %u transports", count ); + sLog.outString(">> Loaded %u transports", count); return; } @@ -51,24 +51,24 @@ void MapManager::LoadTransports() { bar.step(); - Transport *t = new Transport; + Transport* t = new Transport; - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 entry = fields[0].GetUInt32(); std::string name = fields[1].GetCppString(); t->m_period = fields[2].GetUInt32(); - const GameObjectInfo *goinfo = ObjectMgr::GetGameObjectInfo(entry); + const GameObjectInfo* goinfo = ObjectMgr::GetGameObjectInfo(entry); - if(!goinfo) + if (!goinfo) { sLog.outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template missing", entry, name.c_str()); delete t; continue; } - if(goinfo->type != GAMEOBJECT_TYPE_MO_TRANSPORT) + if (goinfo->type != GAMEOBJECT_TYPE_MO_TRANSPORT) { sLog.outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template type wrong", entry, name.c_str()); delete t; @@ -79,7 +79,7 @@ void MapManager::LoadTransports() std::set mapsUsed; - if(!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed)) + if (!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed)) // skip transports with empty waypoints list { sLog.outErrorDb("Transport (path id %u) path size = 0. Transport ignored, check DBC files or transport GO data0 field.",goinfo->moTransport.taxiPathId); @@ -93,7 +93,7 @@ void MapManager::LoadTransports() //current code does not support transports in dungeon! const MapEntry* pMapInfo = sMapStore.LookupEntry(mapid); - if(!pMapInfo || pMapInfo->Instanceable()) + if (!pMapInfo || pMapInfo->Instanceable()) { delete t; continue; @@ -116,26 +116,27 @@ void MapManager::LoadTransports() //t->GetMap()->Add((GameObject *)t); ++count; - } while(result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u transports", count ); + sLog.outString(">> Loaded %u transports", count); // check transport data DB integrity result = WorldDatabase.Query("SELECT gameobject.guid,gameobject.id,transports.name FROM gameobject,transports WHERE gameobject.id = transports.entry"); - if(result) // wrong data found + if (result) // wrong data found { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); std::string name = fields[2].GetCppString(); sLog.outErrorDb("Transport %u '%s' have record (GUID: %u) in `gameobject`. Transports DON'T must have any records in `gameobject` or its behavior will be unpredictable/bugged.",entry,name.c_str(),guid); } - while(result->NextRow()); + while (result->NextRow()); delete result; } @@ -151,10 +152,10 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, Relocate(x,y,z,ang); // instance id and phaseMask isn't set to values different from std. - if(!IsPositionValid()) + if (!IsPositionValid()) { sLog.outError("Transport (GUID: %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", - guidlow,x,y); + guidlow,x,y); return false; } @@ -209,7 +210,7 @@ struct keyFrame float tFrom, tTo; }; -bool Transport::GenerateWaypoints(uint32 pathid, std::set &mapids) +bool Transport::GenerateWaypoints(uint32 pathid, std::set& mapids) { if (pathid >= sTaxiPathNodesByPath.size()) return false; @@ -262,13 +263,13 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set &mapids) { keyFrames[i].distFromPrev = sqrt(pow(keyFrames[i].node->x - keyFrames[i - 1].node->x, 2) + - pow(keyFrames[i].node->y - keyFrames[i - 1].node->y, 2) + - pow(keyFrames[i].node->z - keyFrames[i - 1].node->z, 2)); + pow(keyFrames[i].node->y - keyFrames[i - 1].node->y, 2) + + pow(keyFrames[i].node->z - keyFrames[i - 1].node->z, 2)); } if (keyFrames[i].node->actionFlag == 2) { // remember first stop frame - if(firstStop == -1) + if (firstStop == -1) firstStop = i; lastStop = i; } @@ -322,7 +323,7 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set &mapids) teleport = true; WayPoint pos(keyFrames[0].node->mapid, keyFrames[0].node->x, keyFrames[0].node->y, keyFrames[0].node->z, teleport, - keyFrames[0].node->arrivalEventID, keyFrames[0].node->departureEventID); + keyFrames[0].node->arrivalEventID, keyFrames[0].node->departureEventID); m_WayPoints[0] = pos; t += keyFrames[0].node->delay * 1000; @@ -403,7 +404,7 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set &mapids) } WayPoint pos(keyFrames[i + 1].node->mapid, keyFrames[i + 1].node->x, keyFrames[i + 1].node->y, keyFrames[i + 1].node->z, teleport, - keyFrames[i + 1].node->arrivalEventID, keyFrames[i + 1].node->departureEventID); + keyFrames[i + 1].node->arrivalEventID, keyFrames[i + 1].node->departureEventID); // sLog.outString("T: %d, x: %f, y: %f, z: %f, t:%d", t, pos.x, pos.y, pos.z, teleport); @@ -443,13 +444,13 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z) Map const* oldMap = GetMap(); Relocate(x, y, z); - for(PlayerSet::iterator itr = m_passengers.begin(); itr != m_passengers.end();) + for (PlayerSet::iterator itr = m_passengers.begin(); itr != m_passengers.end();) { PlayerSet::iterator it2 = itr; ++itr; - Player *plr = *it2; - if(!plr) + Player* plr = *it2; + if (!plr) { m_passengers.erase(it2); continue; @@ -469,10 +470,10 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z) //we need to create and save new Map object with 'newMapid' because if not done -> lead to invalid Map object reference... //player far teleport would try to create same instance, but we need it NOW for transport... //correct me if I'm wrong O.o - Map * newMap = sMapMgr.CreateMap(newMapid, this); + Map* newMap = sMapMgr.CreateMap(newMapid, this); SetMap(newMap); - if(oldMap != newMap) + if (oldMap != newMap) { UpdateForMap(oldMap); UpdateForMap(newMap); @@ -496,7 +497,7 @@ bool Transport::RemovePassenger(Player* passenger) return true; } -void Transport::Update( uint32 update_diff, uint32 /*p_time*/) +void Transport::Update(uint32 update_diff, uint32 /*p_time*/) { if (m_WayPoints.size() <= 1) return; @@ -542,14 +543,14 @@ void Transport::Update( uint32 update_diff, uint32 /*p_time*/) void Transport::UpdateForMap(Map const* targetMap) { Map::PlayerList const& pl = targetMap->GetPlayers(); - if(pl.isEmpty()) + if (pl.isEmpty()) return; - if(GetMapId()==targetMap->GetId()) + if (GetMapId()==targetMap->GetId()) { - for(Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr) + for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr) { - if(this != itr->getSource()->GetTransport()) + if (this != itr->getSource()->GetTransport()) { UpdateData transData; BuildCreateUpdateBlockForPlayer(&transData, itr->getSource()); @@ -566,8 +567,8 @@ void Transport::UpdateForMap(Map const* targetMap) WorldPacket out_packet; transData.BuildPacket(&out_packet); - for(Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr) - if(this != itr->getSource()->GetTransport()) + for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr) + if (this != itr->getSource()->GetTransport()) itr->getSource()->SendDirectMessage(&out_packet); } } diff --git a/src/game/Transports.h b/src/game/Transports.h index a3b74812a..b8b78ae7a 100644 --- a/src/game/Transports.h +++ b/src/game/Transports.h @@ -31,7 +31,7 @@ class Transport : public GameObject explicit Transport(); bool Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint8 animprogress, uint16 dynamicHighValue); - bool GenerateWaypoints(uint32 pathid, std::set &mapids); + bool GenerateWaypoints(uint32 pathid, std::set& mapids); void Update(uint32 update_diff, uint32 p_time) override; bool AddPassenger(Player* passenger); bool RemovePassenger(Player* passenger); @@ -45,7 +45,7 @@ class Transport : public GameObject WayPoint() : mapid(0), x(0), y(0), z(0), teleport(false) {} WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport, uint32 _arrivalEventID = 0, uint32 _departureEventID = 0) : mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport), - arrivalEventID(_arrivalEventID), departureEventID(_departureEventID) + arrivalEventID(_arrivalEventID), departureEventID(_departureEventID) { } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 28b9c4283..55d916151 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -70,7 +70,7 @@ float baseMoveSpeed[MAX_MOVE_TYPE] = //////////////////////////////////////////////////////////// // Methods of class MovementInfo -void MovementInfo::Read(ByteBuffer &data) +void MovementInfo::Read(ByteBuffer& data) { data >> moveFlags; data >> moveFlags2; @@ -80,7 +80,7 @@ void MovementInfo::Read(ByteBuffer &data) data >> pos.z; data >> pos.o; - if(HasMovementFlag(MOVEFLAG_ONTRANSPORT)) + if (HasMovementFlag(MOVEFLAG_ONTRANSPORT)) { data >> t_guid.ReadAsPacked(); data >> t_pos.x; @@ -90,18 +90,18 @@ void MovementInfo::Read(ByteBuffer &data) data >> t_time; data >> t_seat; - if(moveFlags2 & MOVEFLAG2_INTERP_MOVEMENT) + if (moveFlags2 & MOVEFLAG2_INTERP_MOVEMENT) data >> t_time2; } - if((HasMovementFlag(MovementFlags(MOVEFLAG_SWIMMING | MOVEFLAG_FLYING))) || (moveFlags2 & MOVEFLAG2_ALLOW_PITCHING)) + if ((HasMovementFlag(MovementFlags(MOVEFLAG_SWIMMING | MOVEFLAG_FLYING))) || (moveFlags2 & MOVEFLAG2_ALLOW_PITCHING)) { data >> s_pitch; } data >> fallTime; - if(HasMovementFlag(MOVEFLAG_FALLING)) + if (HasMovementFlag(MOVEFLAG_FALLING)) { data >> jump.velocity; data >> jump.sinAngle; @@ -109,13 +109,13 @@ void MovementInfo::Read(ByteBuffer &data) data >> jump.xyspeed; } - if(HasMovementFlag(MOVEFLAG_SPLINE_ELEVATION)) + if (HasMovementFlag(MOVEFLAG_SPLINE_ELEVATION)) { data >> u_unk1; } } -void MovementInfo::Write(ByteBuffer &data) const +void MovementInfo::Write(ByteBuffer& data) const { data << moveFlags; data << moveFlags2; @@ -125,7 +125,7 @@ void MovementInfo::Write(ByteBuffer &data) const data << pos.z; data << pos.o; - if(HasMovementFlag(MOVEFLAG_ONTRANSPORT)) + if (HasMovementFlag(MOVEFLAG_ONTRANSPORT)) { data << t_guid.WriteAsPacked(); data << t_pos.x; @@ -135,18 +135,18 @@ void MovementInfo::Write(ByteBuffer &data) const data << t_time; data << t_seat; - if(moveFlags2 & MOVEFLAG2_INTERP_MOVEMENT) + if (moveFlags2 & MOVEFLAG2_INTERP_MOVEMENT) data << t_time2; } - if((HasMovementFlag(MovementFlags(MOVEFLAG_SWIMMING | MOVEFLAG_FLYING))) || (moveFlags2 & MOVEFLAG2_ALLOW_PITCHING)) + if ((HasMovementFlag(MovementFlags(MOVEFLAG_SWIMMING | MOVEFLAG_FLYING))) || (moveFlags2 & MOVEFLAG2_ALLOW_PITCHING)) { data << s_pitch; } data << fallTime; - if(HasMovementFlag(MOVEFLAG_FALLING)) + if (HasMovementFlag(MOVEFLAG_FALLING)) { data << jump.velocity; data << jump.sinAngle; @@ -154,7 +154,7 @@ void MovementInfo::Write(ByteBuffer &data) const data << jump.xyspeed; } - if(HasMovementFlag(MOVEFLAG_SPLINE_ELEVATION)) + if (HasMovementFlag(MOVEFLAG_SPLINE_ELEVATION)) { data << u_unk1; } @@ -262,7 +262,7 @@ Unit::Unit() : m_speed_rate[i] = 1.0f; // remove aurastates allowing special moves - for(int i=0; i < MAX_REACTIVE; ++i) + for (int i=0; i < MAX_REACTIVE; ++i) m_reactiveTimer[i] = 0; m_isCreatureLinkingTrigger = false; @@ -292,9 +292,9 @@ Unit::~Unit() MANGOS_ASSERT(m_deletedHolders.size() == 0); } -void Unit::Update( uint32 update_diff, uint32 p_time ) +void Unit::Update(uint32 update_diff, uint32 p_time) { - if(!IsInWorld()) + if (!IsInWorld()) return; /*if(p_time > m_AurasCheck) @@ -307,8 +307,8 @@ void Unit::Update( uint32 update_diff, uint32 p_time ) // WARNING! Order of execution here is important, do not change. // Spells must be processed with event system BEFORE they go to _UpdateSpells. // Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad. - m_Events.Update( update_diff ); - _UpdateSpells( update_diff ); + m_Events.Update(update_diff); + _UpdateSpells(update_diff); CleanupDeletedAuras(); @@ -341,16 +341,16 @@ void Unit::Update( uint32 update_diff, uint32 p_time ) if (uint32 base_att = getAttackTimer(BASE_ATTACK)) { - setAttackTimer(BASE_ATTACK, (update_diff >= base_att ? 0 : base_att - update_diff) ); + setAttackTimer(BASE_ATTACK, (update_diff >= base_att ? 0 : base_att - update_diff)); } if (uint32 base_att = getAttackTimer(OFF_ATTACK)) { - setAttackTimer(OFF_ATTACK, (update_diff >= base_att ? 0 : base_att - update_diff) ); + setAttackTimer(OFF_ATTACK, (update_diff >= base_att ? 0 : base_att - update_diff)); } // update abilities available only for fraction of time - UpdateReactives( update_diff ); + UpdateReactives(update_diff); ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, GetHealth() < GetMaxHealth()*0.20f); ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, GetHealth() < GetMaxHealth()*0.35f); @@ -361,7 +361,7 @@ void Unit::Update( uint32 update_diff, uint32 p_time ) bool Unit::UpdateMeleeAttackingState() { - Unit *victim = getVictim(); + Unit* victim = getVictim(); if (!victim || IsNonMeleeSpellCasted(false)) return false; @@ -425,7 +425,7 @@ bool Unit::haveOffhandWeapon() const if (!CanUseEquippedWeapon(OFF_ATTACK)) return false; - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) return ((Player*)this)->GetWeaponForAttack(OFF_ATTACK,true,true); else { @@ -459,7 +459,7 @@ bool Unit::CanReachWithMeleeAttack(Unit* pVictim, float flat_mod /*= 0.0f*/) con // The measured values show BASE_MELEE_OFFSET in (1.3224, 1.342) float reach = GetFloatValue(UNIT_FIELD_COMBATREACH) + pVictim->GetFloatValue(UNIT_FIELD_COMBATREACH) + - BASE_MELEERANGE_OFFSET + flat_mod; + BASE_MELEERANGE_OFFSET + flat_mod; if (reach < ATTACK_DISTANCE) reach = ATTACK_DISTANCE; @@ -497,7 +497,7 @@ void Unit::RemoveSpellsCausingAura(AuraType auraType, SpellAuraHolder* except) } } -void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb) +void Unit::DealDamageMods(Unit* pVictim, uint32& damage, uint32* absorb) { if (!pVictim->isAlive() || pVictim->IsTaxiFlying() || (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode())) { @@ -511,7 +511,7 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb) //You still see it in the combat log though if (!IsAllowedDamageInArea(pVictim)) { - if(absorb) + if (absorb) *absorb += damage; damage = 0; } @@ -519,35 +519,35 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb) uint32 originalDamage = damage; //Script Event damage Deal - if( GetTypeId()== TYPEID_UNIT && ((Creature *)this)->AI()) - ((Creature *)this)->AI()->DamageDeal(pVictim, damage); + if (GetTypeId()== TYPEID_UNIT && ((Creature*)this)->AI()) + ((Creature*)this)->AI()->DamageDeal(pVictim, damage); //Script Event damage taken - if( pVictim->GetTypeId()== TYPEID_UNIT && ((Creature *)pVictim)->AI() ) - ((Creature *)pVictim)->AI()->DamageTaken(this, damage); + if (pVictim->GetTypeId()== TYPEID_UNIT && ((Creature*)pVictim)->AI()) + ((Creature*)pVictim)->AI()->DamageTaken(this, damage); - if(absorb && originalDamage > damage) + if (absorb && originalDamage > damage) *absorb += (originalDamage - damage); } -uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss) +uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const* spellProto, bool durabilityLoss) { // remove affects from attacker at any non-DoT damage (including 0 damage) - if( damagetype != DOT) + if (damagetype != DOT) { RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - if(pVictim != this) + if (pVictim != this) RemoveSpellsCausingAura(SPELL_AURA_MOD_INVISIBILITY); - if(pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNNED)) + if (pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNNED)) pVictim->SetStandState(UNIT_STAND_STATE_STAND); } - if(!damage) + if (!damage) { // Rage from physical damage received . - if(cleanDamage && cleanDamage->damage && (damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL) && pVictim->GetTypeId() == TYPEID_PLAYER && (pVictim->getPowerType() == POWER_RAGE)) + if (cleanDamage && cleanDamage->damage && (damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL) && pVictim->GetTypeId() == TYPEID_PLAYER && (pVictim->getPowerType() == POWER_RAGE)) ((Player*)pVictim)->RewardRage(cleanDamage->damage, 0, false); return 0; @@ -583,31 +583,31 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa if (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->duel && damage >= (health-1)) { // prevent kill only if killed in duel and killed by opponent or opponent controlled creature - if(((Player*)pVictim)->duel->opponent==this || ((Player*)pVictim)->duel->opponent->GetObjectGuid() == GetOwnerGuid()) + if (((Player*)pVictim)->duel->opponent==this || ((Player*)pVictim)->duel->opponent->GetObjectGuid() == GetOwnerGuid()) damage = health-1; duel_hasEnded = true; } //Get in CombatState - if(pVictim != this && damagetype != DOT) + if (pVictim != this && damagetype != DOT) { SetInCombatWith(pVictim); pVictim->SetInCombatWith(this); - if(Player* attackedPlayer = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself()) + if (Player* attackedPlayer = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself()) SetContestedPvP(attackedPlayer); } // Rage from Damage made (only from direct weapon damage) - if( cleanDamage && damagetype==DIRECT_DAMAGE && this != pVictim && GetTypeId() == TYPEID_PLAYER && (getPowerType() == POWER_RAGE)) + if (cleanDamage && damagetype==DIRECT_DAMAGE && this != pVictim && GetTypeId() == TYPEID_PLAYER && (getPowerType() == POWER_RAGE)) { uint32 weaponSpeedHitFactor; - switch(cleanDamage->attackType) + switch (cleanDamage->attackType) { case BASE_ATTACK: { - if(cleanDamage->hitOutCome == MELEE_HIT_CRIT) + if (cleanDamage->hitOutCome == MELEE_HIT_CRIT) weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 7); else weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f); @@ -618,7 +618,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } case OFF_ATTACK: { - if(cleanDamage->hitOutCome == MELEE_HIT_CRIT) + if (cleanDamage->hitOutCome == MELEE_HIT_CRIT) weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f); else weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 1.75f); @@ -634,12 +634,12 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa if (GetTypeId() == TYPEID_PLAYER && this != pVictim) { - Player *killer = ((Player*)this); + Player* killer = ((Player*)this); // in bg, count dmg if victim is also a player if (pVictim->GetTypeId()==TYPEID_PLAYER) { - if (BattleGround *bg = killer->GetBattleGround()) + if (BattleGround* bg = killer->GetBattleGround()) { // FIXME: kept by compatibility. don't know in BG if the restriction apply. bg->UpdatePlayerScore(killer, SCORE_DAMAGE_DONE, damage); @@ -662,8 +662,8 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa // find player: owner of controlled `this` or `this` itself maybe // for loot will be sued only if group_tap==NULL - Player *player_tap = GetCharmerOrOwnerPlayerOrPlayerItself(); - Group *group_tap = NULL; + Player* player_tap = GetCharmerOrOwnerPlayerOrPlayerItself(); + Group* group_tap = NULL; // in creature kill case group/player tap stored for creature if (pVictim->GetTypeId() == TYPEID_UNIT) @@ -688,7 +688,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } // call kill spell proc event (before real die and combat stop to triggering auras removed at death/combat stop) - if(player_tap && player_tap != pVictim) + if (player_tap && player_tap != pVictim) { player_tap->ProcDamageAndSpell(pVictim, PROC_FLAG_KILL, PROC_FLAG_KILLED, PROC_EX_NONE, 0); @@ -721,13 +721,13 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa // if talent known but not triggered (check priest class for speedup check) Aura* spiritOfRedemtionTalentReady = NULL; - if( !damageFromSpiritOfRedemtionTalent && // not called from SPELL_AURA_SPIRIT_OF_REDEMPTION - pVictim->GetTypeId()==TYPEID_PLAYER && pVictim->getClass()==CLASS_PRIEST ) + if (!damageFromSpiritOfRedemtionTalent && // not called from SPELL_AURA_SPIRIT_OF_REDEMPTION + pVictim->GetTypeId()==TYPEID_PLAYER && pVictim->getClass()==CLASS_PRIEST) { AuraList const& vDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); - for(AuraList::const_iterator itr = vDummyAuras.begin(); itr != vDummyAuras.end(); ++itr) + for (AuraList::const_iterator itr = vDummyAuras.begin(); itr != vDummyAuras.end(); ++itr) { - if((*itr)->GetSpellProto()->SpellIconID==1654) + if ((*itr)->GetSpellProto()->SpellIconID==1654) { spiritOfRedemtionTalentReady = *itr; break; @@ -743,11 +743,11 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE,"DealDamageHealth1"); - if(spiritOfRedemtionTalentReady) + if (spiritOfRedemtionTalentReady) { // save value before aura remove uint32 ressSpellId = pVictim->GetUInt32Value(PLAYER_SELF_RES_SPELL); - if(!ressSpellId) + if (!ressSpellId) ressSpellId = ((Player*)pVictim)->GetResurrectionSpellId(); //Remove all expected to remove at death auras (most important negative case like DoT or periodic triggers) @@ -764,7 +764,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa // remember victim PvP death for corpse type and corpse reclaim delay // at original death (not at SpiritOfRedemtionTalent timeout) - if( pVictim->GetTypeId()==TYPEID_PLAYER && !damageFromSpiritOfRedemtionTalent ) + if (pVictim->GetTypeId()==TYPEID_PLAYER && !damageFromSpiritOfRedemtionTalent) ((Player*)pVictim)->SetPvPDeath(player_tap != NULL); // Call KilledUnit for creatures @@ -779,7 +779,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa { if (GetTypeId() == TYPEID_UNIT) ((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE, GetEntry()); - else if(GetTypeId() == TYPEID_PLAYER && pVictim != this) + else if (GetTypeId() == TYPEID_PLAYER && pVictim != this) ((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, 1, ((Player*)this)->GetTeam()); } @@ -804,10 +804,10 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } // last damage from non duel opponent or opponent controlled creature - if(duel_hasEnded) + if (duel_hasEnded) { MANGOS_ASSERT(pVictim->GetTypeId()==TYPEID_PLAYER); - Player *he = (Player*)pVictim; + Player* he = (Player*)pVictim; MANGOS_ASSERT(he->duel); @@ -818,17 +818,17 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } // battleground things (do this at the end, so the death state flag will be properly set to handle in the bg->handlekill) - if(pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->InBattleGround()) + if (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->InBattleGround()) { - Player *killed = ((Player*)pVictim); - if(BattleGround *bg = killed->GetBattleGround()) - if(player_tap) + Player* killed = ((Player*)pVictim); + if (BattleGround* bg = killed->GetBattleGround()) + if (player_tap) bg->HandleKillPlayer(killed, player_tap); } - else if(pVictim->GetTypeId() == TYPEID_UNIT) + else if (pVictim->GetTypeId() == TYPEID_UNIT) { if (player_tap) - if (BattleGround *bg = player_tap->GetBattleGround()) + if (BattleGround* bg = player_tap->GetBattleGround()) bg->HandleKillUnit((Creature*)pVictim, player_tap); } } @@ -841,9 +841,9 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa pVictim->ModifyHealth(- (int32)damage); - if(damagetype != DOT) + if (damagetype != DOT) { - if(!getVictim()) + if (!getVictim()) { // if not have main target then attack state with target (including AI call) //start melee attacks only after melee hit @@ -854,7 +854,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa pVictim->AttackedBy(this); } - if(damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE) + if (damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE) { if (!spellProto || !(spellProto->AuraInterruptFlags&AURA_INTERRUPT_FLAG_DIRECT_DAMAGE)) pVictim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_DIRECT_DAMAGE); @@ -867,7 +867,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa else // victim is a player { // Rage from damage received - if(this != pVictim && pVictim->getPowerType() == POWER_RAGE) + if (this != pVictim && pVictim->getPowerType() == POWER_RAGE) { uint32 rage_damage = damage + (cleanDamage ? cleanDamage->damage : 0); ((Player*)pVictim)->RewardRage(rage_damage, 0, false); @@ -881,7 +881,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } } - if(GetTypeId()==TYPEID_PLAYER) + if (GetTypeId()==TYPEID_PLAYER) { // random durability for items (HIT DONE) if (roll_chance_f(sWorld.getConfig(CONFIG_FLOAT_RATE_DURABILITY_LOSS_DAMAGE))) @@ -895,7 +895,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa SpellAuraHolderMap& vAuras = pVictim->GetSpellAuraHolderMap(); for (SpellAuraHolderMap::const_iterator i = vAuras.begin(), next; i != vAuras.end(); i = next) { - const SpellEntry *se = i->second->GetSpellProto(); + const SpellEntry* se = i->second->GetSpellProto(); next = i; ++next; if (spellProto && spellProto->Id == se->Id) // Not drop auras added by self continue; @@ -908,7 +908,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa if (damagetype != NODAMAGE && damage && pVictim->GetTypeId() == TYPEID_PLAYER) { - if( damagetype != DOT ) + if (damagetype != DOT) { for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i) { @@ -916,11 +916,11 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa if (i == CURRENT_CHANNELED_SPELL) continue; - if(Spell* spell = pVictim->GetCurrentSpell(CurrentSpellTypes(i))) + if (Spell* spell = pVictim->GetCurrentSpell(CurrentSpellTypes(i))) { - if(spell->getState() == SPELL_STATE_PREPARING) + if (spell->getState() == SPELL_STATE_PREPARING) { - if(spell->m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_ABORT_ON_DMG) + if (spell->m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_ABORT_ON_DMG) pVictim->InterruptSpell(CurrentSpellTypes(i)); else spell->Delayed(); @@ -929,17 +929,17 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } } - if(Spell* spell = pVictim->m_currentSpells[CURRENT_CHANNELED_SPELL]) + if (Spell* spell = pVictim->m_currentSpells[CURRENT_CHANNELED_SPELL]) { if (spell->getState() == SPELL_STATE_CASTING) { uint32 channelInterruptFlags = spell->m_spellInfo->ChannelInterruptFlags; - if( channelInterruptFlags & CHANNEL_FLAG_DELAY ) + if (channelInterruptFlags & CHANNEL_FLAG_DELAY) { - if(pVictim!=this) //don't shorten the duration of channeling if you damage yourself + if (pVictim!=this) //don't shorten the duration of channeling if you damage yourself spell->DelayedChannel(); } - else if( (channelInterruptFlags & (CHANNEL_FLAG_DAMAGE | CHANNEL_FLAG_DAMAGE2)) ) + else if ((channelInterruptFlags & (CHANNEL_FLAG_DAMAGE | CHANNEL_FLAG_DAMAGE2))) { DETAIL_LOG("Spell %u canceled at damage!",spell->m_spellInfo->Id); pVictim->InterruptSpell(CURRENT_CHANNELED_SPELL); @@ -955,10 +955,10 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } // last damage from duel opponent - if(duel_hasEnded) + if (duel_hasEnded) { MANGOS_ASSERT(pVictim->GetTypeId()==TYPEID_PLAYER); - Player *he = (Player*)pVictim; + Player* he = (Player*)pVictim; MANGOS_ASSERT(he->duel); @@ -1022,7 +1022,7 @@ void Unit::JustKilledCreature(Creature* victim) creator->InterruptNonMeleeSpells(false); } } - + /* ******************************* Inform various hooks ************************************ */ // Inform victim's AI if (victim->AI()) @@ -1034,7 +1034,7 @@ void Unit::JustKilledCreature(Creature* victim) { TemporarySummon* pSummon = (TemporarySummon*)victim; if (pSummon->GetSummonerGuid().IsCreatureOrVehicle()) - if(Creature* pSummoner = victim->GetMap()->GetCreature(pSummon->GetSummonerGuid())) + if (Creature* pSummoner = victim->GetMap()->GetCreature(pSummon->GetSummonerGuid())) if (pSummoner->AI()) pSummoner->AI()->SummonedCreatureJustDied(victim); } @@ -1094,11 +1094,11 @@ void Unit::CastStop(uint32 except_spellid) InterruptSpell(CurrentSpellTypes(i),false); } -void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) +void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item* castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); - if(!spellInfo) + if (!spellInfo) { if (triggeredByAura) sLog.outError("CastSpell: unknown spell id %i by caster: %s triggered by aura %u (eff %u)", spellId, GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex()); @@ -1110,9 +1110,9 @@ void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castIte CastSpell(Victim, spellInfo, triggered, castItem, triggeredByAura, originalCaster, triggeredBy); } -void Unit::CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) +void Unit::CastSpell(Unit* Victim, SpellEntry const* spellInfo, bool triggered, Item* castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) { - if(!spellInfo) + if (!spellInfo) { if (triggeredByAura) sLog.outError("CastSpell: unknown spell by caster: %s triggered by aura %u (eff %u)", GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex()); @@ -1132,10 +1132,10 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered, triggeredBy = triggeredByAura->GetSpellProto(); } - Spell *spell = new Spell(this, spellInfo, triggered, originalCaster, triggeredBy); + Spell* spell = new Spell(this, spellInfo, triggered, originalCaster, triggeredBy); SpellCastTargets targets; - targets.setUnitTarget( Victim ); + targets.setUnitTarget(Victim); if (spellInfo->Targets & TARGET_FLAG_DEST_LOCATION) targets.setDestination(Victim->GetPositionX(), Victim->GetPositionY(), Victim->GetPositionZ()); @@ -1147,11 +1147,11 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered, spell->prepare(&targets, triggeredByAura); } -void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) +void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); - if(!spellInfo) + if (!spellInfo) { if (triggeredByAura) sLog.outError("CastCustomSpell: unknown spell id %i by caster: %s triggered by aura %u (eff %u)", spellId, GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex()); @@ -1163,9 +1163,9 @@ void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 CastCustomSpell(Victim, spellInfo, bp0, bp1, bp2, triggered, castItem, triggeredByAura, originalCaster, triggeredBy); } -void Unit::CastCustomSpell(Unit* Victim, SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) +void Unit::CastCustomSpell(Unit* Victim, SpellEntry const* spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) { - if(!spellInfo) + if (!spellInfo) { if (triggeredByAura) sLog.outError("CastCustomSpell: unknown spell by caster: %s triggered by aura %u (eff %u)", GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex()); @@ -1185,19 +1185,19 @@ void Unit::CastCustomSpell(Unit* Victim, SpellEntry const *spellInfo, int32 cons triggeredBy = triggeredByAura->GetSpellProto(); } - Spell *spell = new Spell(this, spellInfo, triggered, originalCaster, triggeredBy); + Spell* spell = new Spell(this, spellInfo, triggered, originalCaster, triggeredBy); - if(bp0) + if (bp0) spell->m_currentBasePoints[EFFECT_INDEX_0] = *bp0; - if(bp1) + if (bp1) spell->m_currentBasePoints[EFFECT_INDEX_1] = *bp1; - if(bp2) + if (bp2) spell->m_currentBasePoints[EFFECT_INDEX_2] = *bp2; SpellCastTargets targets; - targets.setUnitTarget( Victim ); + targets.setUnitTarget(Victim); spell->m_CastItem = castItem; if (spellInfo->Targets & TARGET_FLAG_DEST_LOCATION) @@ -1210,11 +1210,11 @@ void Unit::CastCustomSpell(Unit* Victim, SpellEntry const *spellInfo, int32 cons } // used for scripting -void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) +void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); - if(!spellInfo) + if (!spellInfo) { if (triggeredByAura) sLog.outError("CastSpell(x,y,z): unknown spell id %i by caster: %s triggered by aura %u (eff %u)", spellId, GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex()); @@ -1227,9 +1227,9 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, } // used for scripting -void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) +void Unit::CastSpell(float x, float y, float z, SpellEntry const* spellInfo, bool triggered, Item* castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) { - if(!spellInfo) + if (!spellInfo) { if (triggeredByAura) sLog.outError("CastSpell(x,y,z): unknown spell by caster: %s triggered by aura %u (eff %u)", GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex()); @@ -1249,7 +1249,7 @@ void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, boo triggeredBy = triggeredByAura->GetSpellProto(); } - Spell *spell = new Spell(this, spellInfo, triggered, originalCaster, triggeredBy); + Spell* spell = new Spell(this, spellInfo, triggered, originalCaster, triggeredBy); SpellCastTargets targets; @@ -1267,9 +1267,9 @@ void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, boo } // Obsolete func need remove, here only for comotability vs another patches -uint32 Unit::SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage) +uint32 Unit::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellID); SpellNonMeleeDamage damageInfo(this, pVictim, spellInfo->Id, SpellSchoolMask(spellInfo->SchoolMask)); CalculateSpellDamage(&damageInfo, damage, spellInfo); damageInfo.target->CalculateAbsorbResistBlock(this, &damageInfo, spellInfo); @@ -1279,17 +1279,17 @@ uint32 Unit::SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage return damageInfo.damage; } -void Unit::CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType) +void Unit::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 damage, SpellEntry const* spellInfo, WeaponAttackType attackType) { SpellSchoolMask damageSchoolMask = damageInfo->schoolMask; - Unit *pVictim = damageInfo->target; + Unit* pVictim = damageInfo->target; if (damage < 0) return; - if(!this || !pVictim) + if (!this || !pVictim) return; - if(!this->isAlive() || !pVictim->isAlive()) + if (!this->isAlive() || !pVictim->isAlive()) return; // Check spell crit chance @@ -1298,7 +1298,7 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, S // damage bonus (per damage class) switch (spellInfo->DmgClass) { - // Melee and Ranged Spells + // Melee and Ranged Spells case SPELL_DAMAGE_CLASS_RANGED: case SPELL_DAMAGE_CLASS_MELEE: { @@ -1363,20 +1363,20 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, S damageInfo->damage = damage; } -void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss) +void Unit::DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss) { if (!damageInfo) return; - Unit *pVictim = damageInfo->target; + Unit* pVictim = damageInfo->target; - if(!this || !pVictim) + if (!this || !pVictim) return; if (!pVictim->isAlive() || pVictim->IsTaxiFlying() || (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode())) return; - SpellEntry const *spellProto = sSpellStore.LookupEntry(damageInfo->SpellID); + SpellEntry const* spellProto = sSpellStore.LookupEntry(damageInfo->SpellID); if (spellProto == NULL) { sLog.outError("Unit::DealSpellDamage have wrong damageInfo->SpellID: %u", damageInfo->SpellID); @@ -1394,7 +1394,7 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss) } //TODO for melee need create structure as in -void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType) +void Unit::CalculateMeleeDamage(Unit* pVictim, uint32 damage, CalcDamageInfo* damageInfo, WeaponAttackType attackType) { damageInfo->attacker = this; damageInfo->target = pVictim; @@ -1413,9 +1413,9 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da damageInfo->procEx = PROC_EX_NONE; damageInfo->hitOutCome = MELEE_HIT_EVADE; - if(!this || !pVictim) + if (!this || !pVictim) return; - if(!this->isAlive() || !pVictim->isAlive()) + if (!this->isAlive() || !pVictim->isAlive()) return; // Select HitInfo/procAttacker/procVictim flag based on attack type @@ -1451,7 +1451,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da damageInfo->cleanDamage = 0; return; } - damage += CalculateDamage (damageInfo->attackType, false); + damage += CalculateDamage(damageInfo->attackType, false); // Add melee damage bonus damage = MeleeDamageBonusDone(damageInfo->target, damage, damageInfo->attackType); damage = damageInfo->target->MeleeDamageBonusTaken(this, damage, damageInfo->attackType); @@ -1470,7 +1470,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da if (damageInfo->hitOutCome == MELEE_HIT_DODGE) damageInfo->hitOutCome = MELEE_HIT_MISS; } - switch(damageInfo->hitOutCome) + switch (damageInfo->hitOutCome) { case MELEE_HIT_EVADE: { @@ -1506,7 +1506,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da damageInfo->damage += damageInfo->damage; int32 mod=0; // Apply SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE or SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE - if(damageInfo->attackType == RANGED_ATTACK) + if (damageInfo->attackType == RANGED_ATTACK) mod += damageInfo->target->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE); else mod += damageInfo->target->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE); @@ -1578,7 +1578,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da // calculate base values and mods float baseLowEnd = 1.3f; float baseHighEnd = 1.2f; - switch(getClass()) // lowering base values for casters + switch (getClass()) // lowering base values for casters { case CLASS_SHAMAN: case CLASS_PRIEST: @@ -1591,7 +1591,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da } float maxLowEnd = 0.6f; - switch(getClass()) // upper for melee classes + switch (getClass()) // upper for melee classes { case CLASS_WARRIOR: case CLASS_ROGUE: @@ -1600,24 +1600,24 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da // calculate values int32 diff = damageInfo->target->GetDefenseSkillValue() - GetWeaponSkillValue(damageInfo->attackType); - float lowEnd = baseLowEnd - ( 0.05f * diff ); - float highEnd = baseHighEnd - ( 0.03f * diff ); + float lowEnd = baseLowEnd - (0.05f * diff); + float highEnd = baseHighEnd - (0.03f * diff); // apply max/min bounds - if ( lowEnd < 0.01f ) //the low end must not go bellow 0.01f + if (lowEnd < 0.01f) //the low end must not go bellow 0.01f lowEnd = 0.01f; - else if ( lowEnd > maxLowEnd ) //the smaller value of this and 0.6 is kept as the low end + else if (lowEnd > maxLowEnd) //the smaller value of this and 0.6 is kept as the low end lowEnd = maxLowEnd; - if ( highEnd < 0.2f ) //high end limits + if (highEnd < 0.2f) //high end limits highEnd = 0.2f; - if ( highEnd > 0.99f ) + if (highEnd > 0.99f) highEnd = 0.99f; - if(lowEnd > highEnd) // prevent negative range size + if (lowEnd > highEnd) // prevent negative range size lowEnd = highEnd; - reducePercent = lowEnd + rand_norm_f() * ( highEnd - lowEnd ); + reducePercent = lowEnd + rand_norm_f() * (highEnd - lowEnd); damageInfo->cleanDamage += damageInfo->damage-uint32(reducePercent * damageInfo->damage); damageInfo->damage = uint32(reducePercent * damageInfo->damage); @@ -1651,7 +1651,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da } // Calculate absorb resist - if(int32(damageInfo->damage) > 0) + if (int32(damageInfo->damage) > 0) { damageInfo->procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; @@ -1672,12 +1672,12 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da damageInfo->damage = 0; } -void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) +void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) { if (damageInfo==0) return; - Unit *pVictim = damageInfo->target; + Unit* pVictim = damageInfo->target; - if(!this || !pVictim) + if (!this || !pVictim) return; if (!pVictim->isAlive() || pVictim->IsTaxiFlying() || (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode())) @@ -1694,7 +1694,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) if (damageInfo->blocked_amount && damageInfo->TargetState!=VICTIMSTATE_BLOCKS) pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD); - if(damageInfo->TargetState == VICTIMSTATE_PARRY) + if (damageInfo->TargetState == VICTIMSTATE_PARRY) { // Get attack timers float offtime = float(pVictim->getAttackTimer(OFF_ATTACK)); @@ -1704,11 +1704,11 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) { float percent20 = pVictim->GetAttackTime(OFF_ATTACK) * 0.20f; float percent60 = 3.0f * percent20; - if(offtime > percent20 && offtime <= percent60) + if (offtime > percent20 && offtime <= percent60) { pVictim->setAttackTimer(OFF_ATTACK, uint32(percent20)); } - else if(offtime > percent60) + else if (offtime > percent60) { offtime -= 2.0f * percent20; pVictim->setAttackTimer(OFF_ATTACK, uint32(offtime)); @@ -1718,11 +1718,11 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) { float percent20 = pVictim->GetAttackTime(BASE_ATTACK) * 0.20f; float percent60 = 3.0f * percent20; - if(basetime > percent20 && basetime <= percent60) + if (basetime > percent20 && basetime <= percent60) { pVictim->setAttackTimer(BASE_ATTACK, uint32(percent20)); } - else if(basetime > percent60) + else if (basetime > percent60) { basetime -= 2.0f * percent20; pVictim->setAttackTimer(BASE_ATTACK, uint32(basetime)); @@ -1735,15 +1735,15 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) DealDamage(pVictim, damageInfo->damage, &cleanDamage, DIRECT_DAMAGE, damageInfo->damageSchoolMask, NULL, durabilityLoss); // If this is a creature and it attacks from behind it has a probability to daze it's victim - if( (damageInfo->hitOutCome==MELEE_HIT_CRIT || damageInfo->hitOutCome==MELEE_HIT_CRUSHING || damageInfo->hitOutCome==MELEE_HIT_NORMAL || damageInfo->hitOutCome==MELEE_HIT_GLANCING) && - GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->GetCharmerOrOwnerGuid() && !pVictim->HasInArc(M_PI_F, this) ) + if ((damageInfo->hitOutCome==MELEE_HIT_CRIT || damageInfo->hitOutCome==MELEE_HIT_CRUSHING || damageInfo->hitOutCome==MELEE_HIT_NORMAL || damageInfo->hitOutCome==MELEE_HIT_GLANCING) && + GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->GetCharmerOrOwnerGuid() && !pVictim->HasInArc(M_PI_F, this)) { // -probability is between 0% and 40% // 20% base chance float Probability = 20.0f; //there is a newbie protection, at level 10 just 7% base chance; assuming linear function - if( pVictim->getLevel() < 30 ) + if (pVictim->getLevel() < 30) Probability = 0.65f*pVictim->getLevel()+0.5f; uint32 VictimDefense=pVictim->GetDefenseSkillValue(); @@ -1751,10 +1751,10 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) Probability *= AttackerMeleeSkill/(float)VictimDefense; - if(Probability > 40.0f) + if (Probability > 40.0f) Probability = 40.0f; - if(roll_chance_f(Probability)) + if (roll_chance_f(Probability)) CastSpell(pVictim, 1604, true); } @@ -1762,19 +1762,19 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) if (!(damageInfo->HitInfo & HITINFO_MISS)) { // on weapon hit casts - if(GetTypeId() == TYPEID_PLAYER && pVictim->isAlive()) + if (GetTypeId() == TYPEID_PLAYER && pVictim->isAlive()) ((Player*)this)->CastItemCombatSpell(pVictim, damageInfo->attackType); // victim's damage shield std::set alreadyDone; AuraList const& vDamageShields = pVictim->GetAurasByType(SPELL_AURA_DAMAGE_SHIELD); - for(AuraList::const_iterator i = vDamageShields.begin(); i != vDamageShields.end();) + for (AuraList::const_iterator i = vDamageShields.begin(); i != vDamageShields.end();) { if (alreadyDone.find(*i) == alreadyDone.end()) { alreadyDone.insert(*i); uint32 damage=(*i)->GetModifier()->m_amount; - SpellEntry const *i_spellProto = (*i)->GetSpellProto(); + SpellEntry const* i_spellProto = (*i)->GetSpellProto(); //Calculate absorb resist ??? no data in opcode for this possibly unable to absorb or resist? //uint32 absorb; //uint32 resist; @@ -1793,7 +1793,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) data << uint32(damage); // Damage data << uint32(overkill); // Overkill data << uint32(i_spellProto->SchoolMask); - pVictim->SendMessageToSet(&data, true ); + pVictim->SendMessageToSet(&data, true); pVictim->DealDamage(this, damage, 0, SPELL_DIRECT_DAMAGE, GetSpellSchoolMask(i_spellProto), i_spellProto, true); @@ -1808,7 +1808,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) void Unit::HandleEmoteCommand(uint32 emote_id) { - WorldPacket data( SMSG_EMOTE, 4 + 8 ); + WorldPacket data(SMSG_EMOTE, 4 + 8); data << uint32(emote_id); data << GetObjectGuid(); SendMessageToSet(&data, true); @@ -1832,18 +1832,18 @@ void Unit::HandleEmote(uint32 emote_id) } } -uint32 Unit::CalcNotIgnoreAbsorbDamage( uint32 damage, SpellSchoolMask damageSchoolMask, SpellEntry const* spellInfo /*= NULL*/) +uint32 Unit::CalcNotIgnoreAbsorbDamage(uint32 damage, SpellSchoolMask damageSchoolMask, SpellEntry const* spellInfo /*= NULL*/) { float absorb_affected_rate = 1.0f; Unit::AuraList const& ignoreAbsorbSchool = GetAurasByType(SPELL_AURA_MOD_IGNORE_ABSORB_SCHOOL); - for(Unit::AuraList::const_iterator i = ignoreAbsorbSchool.begin(); i != ignoreAbsorbSchool.end(); ++i) + for (Unit::AuraList::const_iterator i = ignoreAbsorbSchool.begin(); i != ignoreAbsorbSchool.end(); ++i) if ((*i)->GetMiscValue() & damageSchoolMask) absorb_affected_rate *= (100.0f - (*i)->GetModifier()->m_amount)/100.0f; - if(spellInfo) + if (spellInfo) { Unit::AuraList const& ignoreAbsorbForSpell = GetAurasByType(SPELL_AURA_MOD_IGNORE_ABSORB_FOR_SPELL); - for(Unit::AuraList::const_iterator citr = ignoreAbsorbForSpell.begin(); citr != ignoreAbsorbForSpell.end(); ++citr) + for (Unit::AuraList::const_iterator citr = ignoreAbsorbForSpell.begin(); citr != ignoreAbsorbForSpell.end(); ++citr) if ((*citr)->isAffectedOnSpell(spellInfo)) absorb_affected_rate *= (100.0f - (*citr)->GetModifier()->m_amount)/100.0f; } @@ -1855,7 +1855,7 @@ uint32 Unit::CalcNotIgnoreDamageReduction(uint32 damage, SpellSchoolMask damageS { float absorb_affected_rate = 1.0f; Unit::AuraList const& ignoreAbsorb = GetAurasByType(SPELL_AURA_MOD_IGNORE_DAMAGE_REDUCTION_SCHOOL); - for(Unit::AuraList::const_iterator i = ignoreAbsorb.begin(); i != ignoreAbsorb.end(); ++i) + for (Unit::AuraList::const_iterator i = ignoreAbsorb.begin(); i != ignoreAbsorb.end(); ++i) if ((*i)->GetMiscValue() & damageSchoolMask) absorb_affected_rate *= (100.0f - (*i)->GetModifier()->m_amount)/100.0f; @@ -1904,9 +1904,9 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage) return (newdamage > 1) ? newdamage : 1; } -void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist, bool canReflect) +void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32* absorb, uint32* resist, bool canReflect) { - if(!pCaster || !isAlive() || !damage) + if (!pCaster || !isAlive() || !damage) return; // Magic damage, check for resists @@ -1931,8 +1931,8 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM float Binom = 0.0f; for (uint8 i = 0; i < 4; ++i) { - Binom += 2400 *( powf(tmpvalue2, float(i)) * powf( (1-tmpvalue2), float(4-i)))/faq[i]; - if (ran > Binom ) + Binom += 2400 *(powf(tmpvalue2, float(i)) * powf((1-tmpvalue2), float(4-i)))/faq[i]; + if (ran > Binom) ++m; else break; @@ -1941,7 +1941,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM *resist += uint32(damage - 1); else *resist += uint32(damage * m / 4); - if(*resist > damage) + if (*resist > damage) *resist = damage; } else @@ -1961,7 +1961,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM // full absorb cases (by chance) AuraList const& vAbsorb = GetAurasByType(SPELL_AURA_SCHOOL_ABSORB); - for(AuraList::const_iterator i = vAbsorb.begin(); i != vAbsorb.end() && RemainingDamage > 0; ++i) + for (AuraList::const_iterator i = vAbsorb.begin(); i != vAbsorb.end() && RemainingDamage > 0; ++i) { // only work with proper school mask damage Modifier* i_mod = (*i)->GetModifier(); @@ -1970,7 +1970,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM SpellEntry const* i_spellProto = (*i)->GetSpellProto(); // Fire Ward or Frost Ward - if(i_spellProto->SpellFamilyName == SPELLFAMILY_MAGE && i_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000108)) + if (i_spellProto->SpellFamilyName == SPELLFAMILY_MAGE && i_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000108)) { int chance = 0; Unit::AuraList const& auras = GetAurasByType(SPELL_AURA_ADD_PCT_MODIFIER); @@ -1985,7 +1985,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM break; } } - if(roll_chance_i(chance)) + if (roll_chance_i(chance)) { int32 amount = RemainingDamage; RemainingDamage = 0; @@ -2005,7 +2005,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM // absorb without mana cost AuraList const& vSchoolAbsorb = GetAurasByType(SPELL_AURA_SCHOOL_ABSORB); - for(AuraList::const_iterator i = vSchoolAbsorb.begin(); i != vSchoolAbsorb.end() && RemainingDamage > 0; ++i) + for (AuraList::const_iterator i = vSchoolAbsorb.begin(); i != vSchoolAbsorb.end() && RemainingDamage > 0; ++i) { Modifier* mod = (*i)->GetModifier(); if (!(mod->m_miscvalue & schoolMask)) @@ -2026,7 +2026,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM // Handle custom absorb auras // TODO: try find better way - switch(spellProto->SpellFamilyName) + switch (spellProto->SpellFamilyName) { case SPELLFAMILY_GENERIC: { @@ -2051,14 +2051,14 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM { // You have a chance equal to your Parry chance if (damagetype == SPELL_DIRECT_DAMAGE && // Only for direct spell damage - roll_chance_f(GetUnitParryChance())) // Roll chance + roll_chance_f(GetUnitParryChance())) // Roll chance RemainingDamage -= RemainingDamage * currentAbsorb / 100; continue; } // Reflective Shield (Lady Malande boss) if (spellProto->Id == 41475 && canReflect) { - if(RemainingDamage < currentAbsorb) + if (RemainingDamage < currentAbsorb) reflectDamage = RemainingDamage / 2; else reflectDamage = currentAbsorb / 2; @@ -2068,7 +2068,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM break; } if (spellProto->Id == 39228 || // Argussian Compass - spellProto->Id == 60218) // Essence of Gossamer + spellProto->Id == 60218) // Essence of Gossamer { // Max absorb stored in 1 dummy effect int32 max_absorb = spellProto->CalculateSimpleValue(EFFECT_INDEX_1); @@ -2104,11 +2104,11 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM if (spellProto->SpellIconID == 2109) { if (!preventDeathSpell && - GetTypeId()==TYPEID_PLAYER && // Only players - !((Player*)this)->HasSpellCooldown(31231) && - // Only if no cooldown - roll_chance_i((*i)->GetModifier()->m_amount)) - // Only if roll + GetTypeId()==TYPEID_PLAYER && // Only players + !((Player*)this)->HasSpellCooldown(31231) && + // Only if no cooldown + roll_chance_i((*i)->GetModifier()->m_amount)) + // Only if roll { preventDeathSpell = (*i)->GetSpellProto(); } @@ -2135,14 +2135,14 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM if (!caster) break; AuraList const& vOverRideCS = caster->GetAurasByType(SPELL_AURA_DUMMY); - for(AuraList::const_iterator k = vOverRideCS.begin(); k != vOverRideCS.end(); ++k) + for (AuraList::const_iterator k = vOverRideCS.begin(); k != vOverRideCS.end(); ++k) { - switch((*k)->GetModifier()->m_miscvalue) + switch ((*k)->GetModifier()->m_miscvalue) { case 5065: // Rank 1 case 5064: // Rank 2 { - if(RemainingDamage >= currentAbsorb) + if (RemainingDamage >= currentAbsorb) reflectDamage = (*k)->GetModifier()->m_amount * currentAbsorb/100; else reflectDamage = (*k)->GetModifier()->m_amount * RemainingDamage/100; @@ -2232,7 +2232,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM // Reduce shield amount mod->m_amount-=currentAbsorb; - if((*i)->GetHolder()->DropAuraCharge()) + if ((*i)->GetHolder()->DropAuraCharge()) mod->m_amount = 0; // Need remove it later if (mod->m_amount<=0) @@ -2242,7 +2242,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM // Remove all expired absorb auras if (existExpired) { - for(AuraList::const_iterator i = vSchoolAbsorb.begin(); i != vSchoolAbsorb.end();) + for (AuraList::const_iterator i = vSchoolAbsorb.begin(); i != vSchoolAbsorb.end();) { if ((*i)->GetModifier()->m_amount<=0) { @@ -2263,12 +2263,12 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM // absorb by mana cost AuraList const& vManaShield = GetAurasByType(SPELL_AURA_MANA_SHIELD); - for(AuraList::const_iterator i = vManaShield.begin(), next; i != vManaShield.end() && RemainingDamage > 0; i = next) + for (AuraList::const_iterator i = vManaShield.begin(), next; i != vManaShield.end() && RemainingDamage > 0; i = next) { next = i; ++next; // check damage school mask - if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0) + if (((*i)->GetModifier()->m_miscvalue & schoolMask)==0) continue; int32 currentAbsorb; @@ -2279,7 +2279,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM if (float manaMultiplier = (*i)->GetSpellProto()->EffectMultipleValue[(*i)->GetEffIndex()]) { - if(Player *modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod((*i)->GetId(), SPELLMOD_MULTIPLE_VALUE, manaMultiplier); int32 maxAbsorb = int32(GetPower(POWER_MANA) / manaMultiplier); @@ -2296,7 +2296,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM incanterAbsorption += currentAbsorb; (*i)->GetModifier()->m_amount -= currentAbsorb; - if((*i)->GetModifier()->m_amount <= 0) + if ((*i)->GetModifier()->m_amount <= 0) { RemoveAurasDueToSpell((*i)->GetId()); next = vManaShield.begin(); @@ -2316,7 +2316,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM // Incanter's Absorption if (itr_spellProto->SpellFamilyName == SPELLFAMILY_GENERIC && - itr_spellProto->SpellIconID == 2941) + itr_spellProto->SpellIconID == 2941) { int32 amount = int32(incanterAbsorption * (*itr)->GetModifier()->m_amount / 100); @@ -2332,20 +2332,20 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM } // only split damage if not damaging yourself - if(pCaster != this) + if (pCaster != this) { AuraList const& vSplitDamageFlat = GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_FLAT); - for(AuraList::const_iterator i = vSplitDamageFlat.begin(), next; i != vSplitDamageFlat.end() && RemainingDamage >= 0; i = next) + for (AuraList::const_iterator i = vSplitDamageFlat.begin(), next; i != vSplitDamageFlat.end() && RemainingDamage >= 0; i = next) { next = i; ++next; // check damage school mask - if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0) + if (((*i)->GetModifier()->m_miscvalue & schoolMask)==0) continue; // Damage can be splitted only if aura has an alive caster - Unit *caster = (*i)->GetCaster(); - if(!caster || caster == this || !caster->IsInWorld() || !caster->isAlive()) + Unit* caster = (*i)->GetCaster(); + if (!caster || caster == this || !caster->IsInWorld() || !caster->isAlive()) continue; int32 currentAbsorb; @@ -2368,17 +2368,17 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM } AuraList const& vSplitDamagePct = GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_PCT); - for(AuraList::const_iterator i = vSplitDamagePct.begin(), next; i != vSplitDamagePct.end() && RemainingDamage >= 0; i = next) + for (AuraList::const_iterator i = vSplitDamagePct.begin(), next; i != vSplitDamagePct.end() && RemainingDamage >= 0; i = next) { next = i; ++next; // check damage school mask - if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0) + if (((*i)->GetModifier()->m_miscvalue & schoolMask)==0) continue; // Damage can be splitted only if aura has an alive caster - Unit *caster = (*i)->GetCaster(); - if(!caster || caster == this || !caster->IsInWorld() || !caster->isAlive()) + Unit* caster = (*i)->GetCaster(); + if (!caster || caster == this || !caster->IsInWorld() || !caster->isAlive()) continue; uint32 splitted = uint32(RemainingDamage * (*i)->GetModifier()->m_amount / 100.0f); @@ -2398,9 +2398,9 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM // Apply death prevention spells effects if (preventDeathSpell && RemainingDamage >= (int32)GetHealth()) { - switch(preventDeathSpell->SpellFamilyName) + switch (preventDeathSpell->SpellFamilyName) { - // Cheat Death + // Cheat Death case SPELLFAMILY_ROGUE: { // Cheat Death @@ -2433,13 +2433,13 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM *absorb = damage - RemainingDamage - *resist; } -void Unit::CalculateAbsorbResistBlock(Unit *pCaster, SpellNonMeleeDamage *damageInfo, SpellEntry const* spellProto, WeaponAttackType attType) +void Unit::CalculateAbsorbResistBlock(Unit* pCaster, SpellNonMeleeDamage* damageInfo, SpellEntry const* spellProto, WeaponAttackType attType) { bool blocked = false; // Get blocked status switch (spellProto->DmgClass) { - // Melee and Ranged Spells + // Melee and Ranged Spells case SPELL_DAMAGE_CLASS_RANGED: case SPELL_DAMAGE_CLASS_MELEE: blocked = IsSpellBlocked(pCaster, spellProto, attType); @@ -2461,7 +2461,7 @@ void Unit::CalculateAbsorbResistBlock(Unit *pCaster, SpellNonMeleeDamage *damage damageInfo->damage-= damageInfo->absorb + damageInfo->resist; } -void Unit::CalculateHealAbsorb(const uint32 heal, uint32 *absorb) +void Unit::CalculateHealAbsorb(const uint32 heal, uint32* absorb) { if (!isAlive() || !heal) return; @@ -2473,7 +2473,7 @@ void Unit::CalculateHealAbsorb(const uint32 heal, uint32 *absorb) // absorb AuraList const& vHealAbsorb = GetAurasByType(SPELL_AURA_HEAL_ABSORB); - for(AuraList::const_iterator i = vHealAbsorb.begin(); i != vHealAbsorb.end() && RemainingHeal > 0; ++i) + for (AuraList::const_iterator i = vHealAbsorb.begin(); i != vHealAbsorb.end() && RemainingHeal > 0; ++i) { Modifier* mod = (*i)->GetModifier(); @@ -2506,7 +2506,7 @@ void Unit::CalculateHealAbsorb(const uint32 heal, uint32 *absorb) // Remove all expired absorb auras if (existExpired) { - for(AuraList::const_iterator i = vHealAbsorb.begin(); i != vHealAbsorb.end();) + for (AuraList::const_iterator i = vHealAbsorb.begin(); i != vHealAbsorb.end();) { if ((*i)->GetModifier()->m_amount<=0) { @@ -2521,15 +2521,15 @@ void Unit::CalculateHealAbsorb(const uint32 heal, uint32 *absorb) *absorb = heal - RemainingHeal; } -void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool extra ) +void Unit::AttackerStateUpdate(Unit* pVictim, WeaponAttackType attType, bool extra) { - if(hasUnitState(UNIT_STAT_CAN_NOT_REACT) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) ) + if (hasUnitState(UNIT_STAT_CAN_NOT_REACT) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)) return; if (!pVictim->isAlive()) return; - if(IsNonMeleeSpellCasted(false)) + if (IsNonMeleeSpellCasted(false)) return; uint32 hitInfo; @@ -2548,12 +2548,12 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex m_currentSpells[CURRENT_MELEE_SPELL]->cast(); // not recent extra attack only at any non extra attack (melee spell case) - if(!extra && extraAttacks) + if (!extra && extraAttacks) { - while(m_extraAttacks) + while (m_extraAttacks) { AttackerStateUpdate(pVictim, BASE_ATTACK, true); - if(m_extraAttacks > 0) + if (m_extraAttacks > 0) --m_extraAttacks; } } @@ -2573,27 +2573,27 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex if (GetTypeId() == TYPEID_PLAYER) DEBUG_FILTER_LOG(LOG_FILTER_COMBAT,"AttackerStateUpdate: (Player) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", - GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); + GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); else DEBUG_FILTER_LOG(LOG_FILTER_COMBAT,"AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", - GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); + GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); // if damage pVictim call AI reaction pVictim->AttackedBy(this); // extra attack only at any non extra attack (normal case) - if(!extra && extraAttacks) + if (!extra && extraAttacks) { - while(m_extraAttacks) + while (m_extraAttacks) { AttackerStateUpdate(pVictim, BASE_ATTACK, true); - if(m_extraAttacks > 0) + if (m_extraAttacks > 0) --m_extraAttacks; } } } -MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit *pVictim, WeaponAttackType attType) const +MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackType attType) const { // This is only wrapper @@ -2614,9 +2614,9 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit *pVictim, WeaponAttackT return RollMeleeOutcomeAgainst(pVictim, attType, int32(crit_chance*100), int32(miss_chance*100), int32(dodge_chance*100),int32(parry_chance*100),int32(block_chance*100)); } -MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance) const +MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance) const { - if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) + if (pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) return MELEE_HIT_EVADE; int32 attackerMaxSkillValueForLevel = GetMaxSkillValueForLevel(pVictim); @@ -2626,24 +2626,24 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack int32 victimDefenseSkill = pVictim->GetDefenseSkillValue(this); // bonus from skills is 0.04% - int32 skillBonus = 4 * ( attackerWeaponSkill - victimMaxSkillValueForLevel ); + int32 skillBonus = 4 * (attackerWeaponSkill - victimMaxSkillValueForLevel); int32 sum = 0, tmp = 0; - int32 roll = urand (0, 10000); + int32 roll = urand(0, 10000); DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: skill bonus of %d for attacker", skillBonus); DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: rolled %d, miss %d, dodge %d, parry %d, block %d, crit %d", - roll, miss_chance, dodge_chance, parry_chance, block_chance, crit_chance); + roll, miss_chance, dodge_chance, parry_chance, block_chance, crit_chance); tmp = miss_chance; - if (tmp > 0 && roll < (sum += tmp )) + if (tmp > 0 && roll < (sum += tmp)) { DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: MISS"); return MELEE_HIT_MISS; } // always crit against a sitting target (except 0 crit chance) - if( pVictim->GetTypeId() == TYPEID_PLAYER && crit_chance > 0 && !pVictim->IsStandState() ) + if (pVictim->GetTypeId() == TYPEID_PLAYER && crit_chance > 0 && !pVictim->IsStandState()) { DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: CRIT (sitting victim)"); return MELEE_HIT_CRIT; @@ -2669,9 +2669,9 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack dodge_chance+= GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE)*100; tmp = dodge_chance; - if ( (tmp > 0) // check if unit _can_ dodge - && ((tmp -= skillBonus) > 0) - && roll < (sum += tmp)) + if ((tmp > 0) // check if unit _can_ dodge + && ((tmp -= skillBonus) > 0) + && roll < (sum += tmp)) { DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: DODGE <%d, %d)", sum-tmp, sum); return MELEE_HIT_DODGE; @@ -2696,7 +2696,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack // parry_chance = int32(parry_chance * (pVictim->GetTotalAuraMultiplier(SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT) - 1); if (parry_chance > 0 && // check if unit _can_ parry - (roll < (sum += parry_chance))) + (roll < (sum += parry_chance))) { DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum - parry_chance, sum); return MELEE_HIT_PARRY; @@ -2705,10 +2705,10 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack } // Max 40% chance to score a glancing blow against mobs that are higher level (can do only players and pets and not with ranged weapon) - if( attType != RANGED_ATTACK && - (GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->IsPet()) && - pVictim->GetTypeId() != TYPEID_PLAYER && !((Creature*)pVictim)->IsPet() && - getLevel() < pVictim->GetLevelForTarget(this) ) + if (attType != RANGED_ATTACK && + (GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->IsPet()) && + pVictim->GetTypeId() != TYPEID_PLAYER && !((Creature*)pVictim)->IsPet() && + getLevel() < pVictim->GetLevelForTarget(this)) { // cap possible value (with bonuses > max skill) int32 skill = attackerWeaponSkill; @@ -2728,12 +2728,12 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack // check if attack comes from behind, nobody can parry or block if attacker is behind if (!from_behind) { - if(pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK) ) + if (pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK)) { tmp = block_chance; - if ( (tmp > 0) // check if unit _can_ block - && ((tmp -= skillBonus) > 0) - && (roll < (sum += tmp))) + if ((tmp > 0) // check if unit _can_ block + && ((tmp -= skillBonus) > 0) + && (roll < (sum += tmp))) { DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: BLOCK <%d, %d)", sum-tmp, sum); return MELEE_HIT_BLOCK; @@ -2752,10 +2752,10 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack // mobs can score crushing blows if they're 4 or more levels above victim if (GetLevelForTarget(pVictim) >= pVictim->GetLevelForTarget(this) + 4 && - // can be from by creature (if can) or from controlled player that considered as creature - ((GetTypeId()!=TYPEID_PLAYER && !((Creature*)this)->IsPet() && - !(((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH)) || - GetTypeId()==TYPEID_PLAYER && GetCharmerOrOwnerGuid())) + // can be from by creature (if can) or from controlled player that considered as creature + ((GetTypeId()!=TYPEID_PLAYER && !((Creature*)this)->IsPet() && + !(((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH)) || + GetTypeId()==TYPEID_PLAYER && GetCharmerOrOwnerGuid())) { // when their weapon skill is 15 or more above victim's defense skill tmp = victimDefenseSkill; @@ -2764,7 +2764,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack tmp = tmp > tmpmax ? tmpmax : tmp; // tmp = mob's level * 5 - player's current defense skill tmp = attackerMaxSkillValueForLevel - tmp; - if(tmp >= 15) + if (tmp >= 15) { // add 2% chance per lacking skill point, min. is 15% tmp = tmp * 200 - 1500; @@ -2780,7 +2780,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack return MELEE_HIT_NORMAL; } -uint32 Unit::CalculateDamage (WeaponAttackType attType, bool normalized) +uint32 Unit::CalculateDamage(WeaponAttackType attType, bool normalized) { float min_damage, max_damage; @@ -2815,7 +2815,7 @@ uint32 Unit::CalculateDamage (WeaponAttackType attType, bool normalized) std::swap(min_damage,max_damage); } - if(max_damage == 0.0f) + if (max_damage == 0.0f) max_damage = 5.0f; return urand((uint32)min_damage, (uint32)max_damage); @@ -2824,15 +2824,15 @@ uint32 Unit::CalculateDamage (WeaponAttackType attType, bool normalized) float Unit::CalculateLevelPenalty(SpellEntry const* spellProto) const { uint32 spellLevel = spellProto->spellLevel; - if(spellLevel <= 0) + if (spellLevel <= 0) return 1.0f; float LvlPenalty = 0.0f; - if(spellLevel < 20) + if (spellLevel < 20) LvlPenalty = 20.0f - spellLevel * 3.75f; float LvlFactor = (float(spellLevel) + 6.0f) / float(getLevel()); - if(LvlFactor > 1.0f) + if (LvlFactor > 1.0f) LvlFactor = 1.0f; return (100.0f - LvlPenalty) * LvlFactor / 100.0f; @@ -2840,20 +2840,20 @@ float Unit::CalculateLevelPenalty(SpellEntry const* spellProto) const void Unit::SendMeleeAttackStart(Unit* pVictim) { - WorldPacket data( SMSG_ATTACKSTART, 8 + 8 ); + WorldPacket data(SMSG_ATTACKSTART, 8 + 8); data << GetObjectGuid(); data << pVictim->GetObjectGuid(); SendMessageToSet(&data, true); - DEBUG_LOG( "WORLD: Sent SMSG_ATTACKSTART" ); + DEBUG_LOG("WORLD: Sent SMSG_ATTACKSTART"); } void Unit::SendMeleeAttackStop(Unit* victim) { - if(!victim) + if (!victim) return; - WorldPacket data( SMSG_ATTACKSTOP, (4+16) ); // we guess size + WorldPacket data(SMSG_ATTACKSTOP, (4+16)); // we guess size data << GetPackGUID(); data << victim->GetPackGUID(); // can be 0x00... data << uint32(0); // can be 0x1 @@ -2864,7 +2864,7 @@ void Unit::SendMeleeAttackStop(Unit* victim) ((Creature*)victim)->AI().EnterEvadeMode(this);*/ } -bool Unit::IsSpellBlocked(Unit *pCaster, SpellEntry const *spellEntry, WeaponAttackType attackType) +bool Unit::IsSpellBlocked(Unit* pCaster, SpellEntry const* spellEntry, WeaponAttackType attackType) { if (!HasInArc(M_PI_F, pCaster)) return false; @@ -2903,7 +2903,7 @@ bool Unit::IsSpellBlocked(Unit *pCaster, SpellEntry const *spellEntry, WeaponAtt // Melee based spells can be miss, parry or dodge on this step // Crit or block - determined on damage calculation phase! (and can be both in some time) -float Unit::MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32 skillDiff, SpellEntry const *spell) +float Unit::MeleeSpellMissChance(Unit* pVictim, WeaponAttackType attType, int32 skillDiff, SpellEntry const* spell) { // Calculate hit chance (more correct for chance mod) float hitChance = 0.0f; @@ -2925,7 +2925,7 @@ float Unit::MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32 hitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE); // Spellmod from SPELLMOD_RESIST_MISS_CHANCE - if (Player *modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, hitChance); // Miss = 100 - hit @@ -2946,7 +2946,7 @@ float Unit::MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32 } // Melee based spells hit result calculations -SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) +SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell) { WeaponAttackType attType = BASE_ATTACK; @@ -2958,7 +2958,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) int32 skillDiff = attackerWeaponSkill - int32(pVictim->GetMaxSkillValueForLevel(this)); int32 fullSkillDiff = attackerWeaponSkill - int32(pVictim->GetDefenseSkillValue(this)); - uint32 roll = urand (0, 10000); + uint32 roll = urand(0, 10000); uint32 missChance = uint32(MeleeSpellMissChance(pVictim, attType, fullSkillDiff, spell)*100.0f); // Roll miss @@ -2969,7 +2969,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) // Chance resist mechanic (select max value from every mechanic spell effect) int32 resist_mech = 0; // Get effects mechanic and chance - for(int eff = 0; eff < MAX_EFFECT_INDEX; ++eff) + for (int eff = 0; eff < MAX_EFFECT_INDEX; ++eff) { int32 effect_mech = GetEffectMechanic(spell, SpellEffectIndex(eff)); if (effect_mech) @@ -3022,19 +3022,19 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) canParry = false; } // Check creatures flags_extra for disable parry - if(pVictim->GetTypeId()==TYPEID_UNIT) + if (pVictim->GetTypeId()==TYPEID_UNIT) { uint32 flagEx = ((Creature*)pVictim)->GetCreatureInfo()->flags_extra; - if( flagEx & CREATURE_FLAG_EXTRA_NO_PARRY ) + if (flagEx & CREATURE_FLAG_EXTRA_NO_PARRY) canParry = false; } // Ignore combat result aura AuraList const& ignore = GetAurasByType(SPELL_AURA_IGNORE_COMBAT_RESULT); - for(AuraList::const_iterator i = ignore.begin(); i != ignore.end(); ++i) + for (AuraList::const_iterator i = ignore.begin(); i != ignore.end(); ++i) { if (!(*i)->isAffectedOnSpell(spell)) continue; - switch((*i)->GetModifier()->m_miscvalue) + switch ((*i)->GetModifier()->m_miscvalue) { case MELEE_HIT_DODGE: canDodge = false; break; case MELEE_HIT_BLOCK: break; // Block check in hit step @@ -3088,7 +3088,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) } // TODO need use unit spell resistances in calculations -SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) +SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spell) { // Can`t miss on dead target (on skinning for example) if (!pVictim->isAlive()) @@ -3101,13 +3101,13 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) // Base hit chance from attacker and victim levels int32 modHitChance; - if(leveldif < 3) + if (leveldif < 3) modHitChance = 96 - leveldif; else modHitChance = 94 - (leveldif - 2) * lchance; // Spellmod from SPELLMOD_RESIST_MISS_CHANCE - if(Player *modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, modHitChance); // Increase from attacker SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT auras modHitChance+=GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT, schoolMask); @@ -3122,7 +3122,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) // Chance resist mechanic (select max value from every mechanic spell effect) int32 resist_mech = 0; // Get effects mechanic and chance - for(int eff = 0; eff < MAX_EFFECT_INDEX; ++eff) + for (int eff = 0; eff < MAX_EFFECT_INDEX; ++eff) { int32 effect_mech = GetEffectMechanic(spell, SpellEffectIndex(eff)); if (effect_mech) @@ -3182,7 +3182,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) // Parry // For spells // Resist -SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool CanReflect) +SpellMissInfo Unit::SpellHitResult(Unit* pVictim, SpellEntry const* spell, bool CanReflect) { // Return evade for units in evade mode if (pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) @@ -3206,8 +3206,8 @@ SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool { int32 reflectchance = pVictim->GetTotalAuraModifier(SPELL_AURA_REFLECT_SPELLS); Unit::AuraList const& mReflectSpellsSchool = pVictim->GetAurasByType(SPELL_AURA_REFLECT_SPELLS_SCHOOL); - for(Unit::AuraList::const_iterator i = mReflectSpellsSchool.begin(); i != mReflectSpellsSchool.end(); ++i) - if((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spell)) + for (Unit::AuraList::const_iterator i = mReflectSpellsSchool.begin(); i != mReflectSpellsSchool.end(); ++i) + if ((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spell)) reflectchance += (*i)->GetModifier()->m_amount; if (reflectchance > 0 && roll_chance_i(reflectchance)) { @@ -3230,9 +3230,9 @@ SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool return SPELL_MISS_NONE; } -float Unit::MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const +float Unit::MeleeMissChanceCalc(const Unit* pVictim, WeaponAttackType attType) const { - if(!pVictim) + if (!pVictim) return 0.0f; // Base misschance 5% @@ -3259,9 +3259,9 @@ float Unit::MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) c // PvP - PvE melee chances // TODO: implement diminishing returns for defense from player's defense rating // pure skill diff is not sufficient since 3.x anymore, but exact formulas hard to research - if ( pVictim->GetTypeId() == TYPEID_PLAYER ) + if (pVictim->GetTypeId() == TYPEID_PLAYER) missChance -= skillDiff * 0.04f; - else if ( skillDiff < -10 ) + else if (skillDiff < -10) missChance -= (skillDiff + 10) * 0.4f - 1.0f; else missChance -= skillDiff * 0.1f; @@ -3282,7 +3282,7 @@ float Unit::MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) c } // Modify miss chance by victim auras - if(attType == RANGED_ATTACK) + if (attType == RANGED_ATTACK) missChance -= pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE); else missChance -= pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE); @@ -3298,12 +3298,12 @@ float Unit::MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) c uint32 Unit::GetDefenseSkillValue(Unit const* target) const { - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { // in PvP use full skill instead current skill value uint32 value = (target && target->GetTypeId() == TYPEID_PLAYER) - ? ((Player*)this)->GetMaxSkillValue(SKILL_DEFENSE) - : ((Player*)this)->GetSkillValue(SKILL_DEFENSE); + ? ((Player*)this)->GetMaxSkillValue(SKILL_DEFENSE) + : ((Player*)this)->GetSkillValue(SKILL_DEFENSE); value += uint32(((Player*)this)->GetRatingBonusValue(CR_DEFENSE_SKILL)); return value; } @@ -3313,13 +3313,13 @@ uint32 Unit::GetDefenseSkillValue(Unit const* target) const float Unit::GetUnitDodgeChance() const { - if(hasUnitState(UNIT_STAT_STUNNED)) + if (hasUnitState(UNIT_STAT_STUNNED)) return 0.0f; - if( GetTypeId() == TYPEID_PLAYER ) + if (GetTypeId() == TYPEID_PLAYER) return GetFloatValue(PLAYER_DODGE_PERCENTAGE); else { - if(((Creature const*)this)->IsTotem()) + if (((Creature const*)this)->IsTotem()) return 0.0f; else { @@ -3332,27 +3332,27 @@ float Unit::GetUnitDodgeChance() const float Unit::GetUnitParryChance() const { - if ( IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNNED)) + if (IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNNED)) return 0.0f; float chance = 0.0f; - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { Player const* player = (Player const*)this; - if(player->CanParry() ) + if (player->CanParry()) { - Item *tmpitem = player->GetWeaponForAttack(BASE_ATTACK,true,true); - if(!tmpitem) + Item* tmpitem = player->GetWeaponForAttack(BASE_ATTACK,true,true); + if (!tmpitem) tmpitem = player->GetWeaponForAttack(OFF_ATTACK,true,true); - if(tmpitem) + if (tmpitem) chance = GetFloatValue(PLAYER_PARRY_PERCENTAGE); } } - else if(GetTypeId() == TYPEID_UNIT) + else if (GetTypeId() == TYPEID_UNIT) { - if(GetCreatureType() == CREATURE_TYPE_HUMANOID) + if (GetCreatureType() == CREATURE_TYPE_HUMANOID) { chance = 5.0f; chance += GetTotalAuraModifier(SPELL_AURA_MOD_PARRY_PERCENT); @@ -3364,16 +3364,16 @@ float Unit::GetUnitParryChance() const float Unit::GetUnitBlockChance() const { - if ( IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNNED)) + if (IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNNED)) return 0.0f; - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { Player const* player = (Player const*)this; - if(player->CanBlock() && player->CanUseEquippedWeapon(OFF_ATTACK)) + if (player->CanBlock() && player->CanUseEquippedWeapon(OFF_ATTACK)) { - Item *tmpitem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - if(tmpitem && !tmpitem->IsBroken() && tmpitem->GetProto()->Block) + Item* tmpitem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + if (tmpitem && !tmpitem->IsBroken() && tmpitem->GetProto()->Block) return GetFloatValue(PLAYER_BLOCK_PERCENTAGE); } // is player but has no block ability or no not broken shield equipped @@ -3381,7 +3381,7 @@ float Unit::GetUnitBlockChance() const } else { - if(((Creature const*)this)->IsTotem()) + if (((Creature const*)this)->IsTotem()) return 0.0f; else { @@ -3392,22 +3392,22 @@ float Unit::GetUnitBlockChance() const } } -float Unit::GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVictim) const +float Unit::GetUnitCriticalChance(WeaponAttackType attackType, const Unit* pVictim) const { float crit; - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { - switch(attackType) + switch (attackType) { case BASE_ATTACK: - crit = GetFloatValue( PLAYER_CRIT_PERCENTAGE ); + crit = GetFloatValue(PLAYER_CRIT_PERCENTAGE); break; case OFF_ATTACK: - crit = GetFloatValue( PLAYER_OFFHAND_CRIT_PERCENTAGE ); + crit = GetFloatValue(PLAYER_OFFHAND_CRIT_PERCENTAGE); break; case RANGED_ATTACK: - crit = GetFloatValue( PLAYER_RANGED_CRIT_PERCENTAGE ); + crit = GetFloatValue(PLAYER_RANGED_CRIT_PERCENTAGE); break; // Just for good manner default: @@ -3422,7 +3422,7 @@ float Unit::GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVict } // flat aura mods - if(attackType == RANGED_ATTACK) + if (attackType == RANGED_ATTACK) crit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE); else crit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE); @@ -3443,18 +3443,18 @@ float Unit::GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVict return crit; } -uint32 Unit::GetWeaponSkillValue (WeaponAttackType attType, Unit const* target) const +uint32 Unit::GetWeaponSkillValue(WeaponAttackType attType, Unit const* target) const { uint32 value = 0; - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { Item* item = ((Player*)this)->GetWeaponForAttack(attType,true,true); // feral or unarmed skill only for base attack - if(attType != BASE_ATTACK && !item ) + if (attType != BASE_ATTACK && !item) return 0; - if(IsInFeralForm()) + if (IsInFeralForm()) return GetMaxSkillValueForLevel(); // always maximized SKILL_FERAL_COMBAT in fact // weapon skill or (unarmed for base attack) @@ -3462,25 +3462,25 @@ uint32 Unit::GetWeaponSkillValue (WeaponAttackType attType, Unit const* target) // in PvP use full skill instead current skill value value = (target && target->GetTypeId() == TYPEID_PLAYER) - ? ((Player*)this)->GetMaxSkillValue(skill) - : ((Player*)this)->GetSkillValue(skill); + ? ((Player*)this)->GetMaxSkillValue(skill) + : ((Player*)this)->GetSkillValue(skill); // Modify value from ratings value += uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL)); switch (attType) { - case BASE_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_MAINHAND));break; - case OFF_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_OFFHAND));break; - case RANGED_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_RANGED));break; + case BASE_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_MAINHAND)); break; + case OFF_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_OFFHAND)); break; + case RANGED_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_RANGED)); break; } } else value = GetUnitMeleeSkill(target); - return value; + return value; } -void Unit::_UpdateSpells( uint32 time ) +void Unit::_UpdateSpells(uint32 time) { - if(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]) + if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]) _UpdateAutoRepeatSpell(); // remove finished spells from current pointers @@ -3505,7 +3505,7 @@ void Unit::_UpdateSpells( uint32 time ) // remove expired auras for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();) { - SpellAuraHolder *holder = iter->second; + SpellAuraHolder* holder = iter->second; if (!(holder->IsPermanent() || holder->IsPassive()) && holder->GetAuraDuration() == 0) { @@ -3516,14 +3516,14 @@ void Unit::_UpdateSpells( uint32 time ) ++iter; } - if(!m_gameObj.empty()) + if (!m_gameObj.empty()) { GameObjectList::iterator ite1, dnext1; for (ite1 = m_gameObj.begin(); ite1 != m_gameObj.end(); ite1 = dnext1) { dnext1 = ite1; //(*i)->Update( difftime ); - if( !(*ite1)->isSpawned() ) + if (!(*ite1)->isSpawned()) { (*ite1)->SetOwnerGuid(ObjectGuid()); (*ite1)->SetRespawnTime(0); @@ -3544,7 +3544,7 @@ void Unit::_UpdateAutoRepeatSpell() if (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->isMoving()) { // cancel wand shoot - if(!isAutoShot) + if (!isAutoShot) InterruptSpell(CURRENT_AUTOREPEAT_SPELL); // auto shot just waits return; @@ -3554,7 +3554,7 @@ void Unit::_UpdateAutoRepeatSpell() if (IsNonMeleeSpellCasted(false, false, true)) { // cancel wand shoot - if(!isAutoShot) + if (!isAutoShot) { InterruptSpell(CURRENT_AUTOREPEAT_SPELL); return; @@ -3568,7 +3568,7 @@ void Unit::_UpdateAutoRepeatSpell() if (isAttackReady(RANGED_ATTACK)) { // Check if able to cast - if(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->CheckCast(true) != SPELL_CAST_OK) + if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->CheckCast(true) != SPELL_CAST_OK) { InterruptSpell(CURRENT_AUTOREPEAT_SPELL); return; @@ -3583,7 +3583,7 @@ void Unit::_UpdateAutoRepeatSpell() } } -void Unit::SetCurrentCastedSpell( Spell * pSpell ) +void Unit::SetCurrentCastedSpell(Spell* pSpell) { MANGOS_ASSERT(pSpell); // NULL may be never passed here, use InterruptSpell or InterruptNonMeleeSpells @@ -3603,7 +3603,7 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell ) InterruptSpell(CURRENT_CHANNELED_SPELL,false); // autorepeat breaking - if ( m_currentSpells[CURRENT_AUTOREPEAT_SPELL] ) + if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]) { // break autorepeat if not Auto Shot if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id != SPELL_ID_AUTOSHOT) @@ -3618,8 +3618,8 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell ) InterruptSpell(CURRENT_CHANNELED_SPELL); // it also does break autorepeat if not Auto Shot - if ( m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && - m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id != SPELL_ID_AUTOSHOT ) + if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && + m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id != SPELL_ID_AUTOSHOT) InterruptSpell(CURRENT_AUTOREPEAT_SPELL); } break; @@ -3632,7 +3632,7 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell ) InterruptSpell(CURRENT_GENERIC_SPELL,false); InterruptSpell(CURRENT_CHANNELED_SPELL,false); // special action: first cast delay - if ( getAttackTimer(RANGED_ATTACK) < 500 ) + if (getAttackTimer(RANGED_ATTACK) < 500) setAttackTimer(RANGED_ATTACK,500); } } break; @@ -3658,12 +3658,12 @@ void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool se { MANGOS_ASSERT(spellType < CURRENT_MAX_SPELL); - if (m_currentSpells[spellType] && (withDelayed || m_currentSpells[spellType]->getState() != SPELL_STATE_DELAYED) ) + if (m_currentSpells[spellType] && (withDelayed || m_currentSpells[spellType]->getState() != SPELL_STATE_DELAYED)) { // send autorepeat cancel message for autorepeat spells if (spellType == CURRENT_AUTOREPEAT_SPELL && sendAutoRepeatCancelToClient) { - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) ((Player*)this)->SendAutoRepeatCancel(this); } @@ -3698,13 +3698,13 @@ bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skip // generic spells are casted when they are not finished and not delayed if (m_currentSpells[CURRENT_GENERIC_SPELL] && - (m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) && - (withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED)) + (m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) && + (withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED)) return true; // channeled spells may be delayed, but they are still considered casted else if (!skipChanneled && m_currentSpells[CURRENT_CHANNELED_SPELL] && - (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED)) + (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED)) return true; // autorepeat spells may be finished or delayed, but they are still considered casted @@ -3761,7 +3761,7 @@ void Unit::SetFacingToObject(WorldObject* pObject) bool Unit::isInAccessablePlaceFor(Creature const* c) const { - if(IsInWater()) + if (IsInWater()) return c->CanSwim(); else return c->CanWalk() || c->CanFly(); @@ -3787,7 +3787,7 @@ int32 Unit::GetTotalAuraModifier(AuraType auratype) const int32 modifier = 0; AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) modifier += (*i)->GetModifier()->m_amount; return modifier; @@ -3798,7 +3798,7 @@ float Unit::GetTotalAuraMultiplier(AuraType auratype) const float multiplier = 1.0f; AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) multiplier *= (100.0f + (*i)->GetModifier()->m_amount)/100.0f; return multiplier; @@ -3809,7 +3809,7 @@ int32 Unit::GetMaxPositiveAuraModifier(AuraType auratype) const int32 modifier = 0; AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) if ((*i)->GetModifier()->m_amount > modifier) modifier = (*i)->GetModifier()->m_amount; @@ -3821,7 +3821,7 @@ int32 Unit::GetMaxNegativeAuraModifier(AuraType auratype) const int32 modifier = 0; AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) if ((*i)->GetModifier()->m_amount < modifier) modifier = (*i)->GetModifier()->m_amount; @@ -3830,13 +3830,13 @@ int32 Unit::GetMaxNegativeAuraModifier(AuraType auratype) const int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const { - if(!misc_mask) + if (!misc_mask) return 0; int32 modifier = 0; AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { Modifier* mod = (*i)->GetModifier(); if (mod->m_miscvalue & misc_mask) @@ -3847,13 +3847,13 @@ int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const { - if(!misc_mask) + if (!misc_mask) return 1.0f; float multiplier = 1.0f; AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { Modifier* mod = (*i)->GetModifier(); if (mod->m_miscvalue & misc_mask) @@ -3864,13 +3864,13 @@ float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const { - if(!misc_mask) + if (!misc_mask) return 0; int32 modifier = 0; AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { Modifier* mod = (*i)->GetModifier(); if (mod->m_miscvalue & misc_mask && mod->m_amount > modifier) @@ -3882,13 +3882,13 @@ int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_ int32 Unit::GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const { - if(!misc_mask) + if (!misc_mask) return 0; int32 modifier = 0; AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { Modifier* mod = (*i)->GetModifier(); if (mod->m_miscvalue & misc_mask && mod->m_amount < modifier) @@ -3903,7 +3903,7 @@ int32 Unit::GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) int32 modifier = 0; AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { Modifier* mod = (*i)->GetModifier(); if (mod->m_miscvalue == misc_value) @@ -3917,7 +3917,7 @@ float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_valu float multiplier = 1.0f; AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { Modifier* mod = (*i)->GetModifier(); if (mod->m_miscvalue == misc_value) @@ -3931,7 +3931,7 @@ int32 Unit::GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 misc_ int32 modifier = 0; AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { Modifier* mod = (*i)->GetModifier(); if (mod->m_miscvalue == misc_value && mod->m_amount > modifier) @@ -3946,7 +3946,7 @@ int32 Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_ int32 modifier = 0; AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { Modifier* mod = (*i)->GetModifier(); if (mod->m_miscvalue == misc_value && mod->m_amount < modifier) @@ -3958,13 +3958,13 @@ int32 Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_ float Unit::GetTotalAuraMultiplierByMiscValueForMask(AuraType auratype, uint32 mask) const { - if(!mask) + if (!mask) return 1.0f; float multiplier = 1.0f; AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { Modifier* mod = (*i)->GetModifier(); if (mask & (1 << (mod->m_miscvalue -1))) @@ -3973,24 +3973,24 @@ float Unit::GetTotalAuraMultiplierByMiscValueForMask(AuraType auratype, uint32 m return multiplier; } -bool Unit::AddSpellAuraHolder(SpellAuraHolder *holder) +bool Unit::AddSpellAuraHolder(SpellAuraHolder* holder) { SpellEntry const* aurSpellInfo = holder->GetSpellProto(); // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load) - if( !isAlive() && !IsDeathPersistentSpell(aurSpellInfo) && - !IsDeathOnlySpell(aurSpellInfo) && - (GetTypeId()!=TYPEID_PLAYER || !((Player*)this)->GetSession()->PlayerLoading()) ) + if (!isAlive() && !IsDeathPersistentSpell(aurSpellInfo) && + !IsDeathOnlySpell(aurSpellInfo) && + (GetTypeId()!=TYPEID_PLAYER || !((Player*)this)->GetSession()->PlayerLoading())) { delete holder; return false; } - if(holder->GetTarget() != this) + if (holder->GetTarget() != this) { sLog.outError("Holder (spell %u) add to spell aura holder list of %s (lowguid: %u) but spell aura holder target is %s (lowguid: %u)", - holder->GetId(),(GetTypeId()==TYPEID_PLAYER?"player":"creature"),GetGUIDLow(), - (holder->GetTarget()->GetTypeId()==TYPEID_PLAYER?"player":"creature"),holder->GetTarget()->GetGUIDLow()); + holder->GetId(),(GetTypeId()==TYPEID_PLAYER?"player":"creature"),GetGUIDLow(), + (holder->GetTarget()->GetTypeId()==TYPEID_PLAYER?"player":"creature"),holder->GetTarget()->GetGUIDLow()); delete holder; return false; } @@ -4003,7 +4003,7 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder *holder) // take out same spell for (SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second; ++iter) { - SpellAuraHolder *foundHolder = iter->second; + SpellAuraHolder* foundHolder = iter->second; if (foundHolder->GetCasterGuid() == holder->GetCasterGuid()) { // Aura can stack on self -> Stack it; @@ -4024,14 +4024,14 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder *holder) { for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { - if (Aura *aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) + if (Aura* aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) { // m_auraname can be modified to SPELL_AURA_NONE for area auras, use original AuraType aurNameReal = AuraType(aurSpellInfo->EffectApplyAuraName[i]); if (aurNameReal == SPELL_AURA_PERIODIC_DAMAGE && aur->GetAuraDuration() > 0) { - if (Aura *existing = foundHolder->GetAuraByEffectIndex(SpellEffectIndex(i))) + if (Aura* existing = foundHolder->GetAuraByEffectIndex(SpellEffectIndex(i))) { int32 remainingTicks = existing->GetAuraMaxTicks() - existing->GetAuraTicks(); int32 remainingDamage = existing->GetModifier()->m_amount * remainingTicks; @@ -4061,9 +4061,9 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder *holder) // m_auraname can be modified to SPELL_AURA_NONE for area auras, use original AuraType aurNameReal = AuraType(aurSpellInfo->EffectApplyAuraName[i]); - switch(aurNameReal) + switch (aurNameReal) { - // DoT/HoT/etc + // DoT/HoT/etc case SPELL_AURA_DUMMY: // allow stack case SPELL_AURA_PERIODIC_DAMAGE: case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: @@ -4083,7 +4083,7 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder *holder) } } - if(stop) + if (stop) break; } } @@ -4104,13 +4104,13 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder *holder) if (Unit* caster = holder->GetCaster()) // caster not in world { SingleCastSpellTargetMap& scTargets = caster->GetSingleCastSpellTargets(); - for(SingleCastSpellTargetMap::iterator itr = scTargets.begin(); itr != scTargets.end();) + for (SingleCastSpellTargetMap::iterator itr = scTargets.begin(); itr != scTargets.end();) { SpellEntry const* itr_spellEntry = itr->first; ObjectGuid itr_targetGuid = itr->second; if (itr_targetGuid != GetObjectGuid() && - IsSingleTargetSpells(itr_spellEntry, aurSpellInfo)) + IsSingleTargetSpells(itr_spellEntry, aurSpellInfo)) { scTargets.erase(itr); // remove for caster in any case @@ -4135,7 +4135,7 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder *holder) m_spellAuraHolders.insert(SpellAuraHolderMap::value_type(holder->GetId(), holder)); for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) - if (Aura *aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) + if (Aura* aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) AddAuraToModList(aur); holder->ApplyAuraModifiers(true, true); @@ -4151,7 +4151,7 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder *holder) return true; } -void Unit::AddAuraToModList(Aura *aura) +void Unit::AddAuraToModList(Aura* aura) { if (aura->GetModifier()->m_auraname < TOTAL_AURAS) m_modAuras[aura->GetModifier()->m_auraname].push_back(aura); @@ -4159,8 +4159,8 @@ void Unit::AddAuraToModList(Aura *aura) void Unit::RemoveRankAurasDueToSpell(uint32 spellId) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); - if(!spellInfo) + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); + if (!spellInfo) return; SpellAuraHolderMap::const_iterator i,next; for (i = m_spellAuraHolders.begin(); i != m_spellAuraHolders.end(); i = next) @@ -4168,13 +4168,13 @@ void Unit::RemoveRankAurasDueToSpell(uint32 spellId) next = i; ++next; uint32 i_spellId = (*i).second->GetId(); - if((*i).second && i_spellId && i_spellId != spellId) + if ((*i).second && i_spellId && i_spellId != spellId) { - if(sSpellMgr.IsRankSpellDueToSpell(spellInfo,i_spellId)) + if (sSpellMgr.IsRankSpellDueToSpell(spellInfo,i_spellId)) { RemoveAurasDueToSpell(i_spellId); - if( m_spellAuraHolders.empty() ) + if (m_spellAuraHolders.empty()) break; else next = m_spellAuraHolders.begin(); @@ -4183,7 +4183,7 @@ void Unit::RemoveRankAurasDueToSpell(uint32 spellId) } } -bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) +bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder* holder) { if (!holder) return false; @@ -4195,9 +4195,9 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) uint32 spellId = holder->GetId(); // passive spell special case (only non stackable with ranks) - if(IsPassiveSpell(spellProto)) + if (IsPassiveSpell(spellProto)) { - if(IsPassiveSpellStackableWithRanks(spellProto)) + if (IsPassiveSpellStackableWithRanks(spellProto)) return true; } @@ -4229,16 +4229,16 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) continue; } - if(i_spellId == spellId) continue; + if (i_spellId == spellId) continue; bool is_triggered_by_spell = false; // prevent triggering aura of removing aura that triggered it - for(int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (int j = 0; j < MAX_EFFECT_INDEX; ++j) if (i_spellProto->EffectTriggerSpell[j] == spellId) is_triggered_by_spell = true; // prevent triggered aura of removing aura that triggering it (triggered effect early some aura of parent spell - for(int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (int j = 0; j < MAX_EFFECT_INDEX; ++j) if (spellProto->EffectTriggerSpell[j] == i_spellId) is_triggered_by_spell = true; @@ -4254,7 +4254,7 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) { // cannot remove higher rank if (sSpellMgr.IsRankSpellDueToSpell(spellProto, i_spellId)) - if(CompareAuraRanks(spellId, i_spellId) < 0) + if (CompareAuraRanks(spellId, i_spellId) < 0) return false; // Its a parent aura (create this aura in ApplyModifier) @@ -4265,7 +4265,7 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) } RemoveAurasDueToSpell(i_spellId); - if( m_spellAuraHolders.empty() ) + if (m_spellAuraHolders.empty()) break; else next = m_spellAuraHolders.begin(); @@ -4276,10 +4276,10 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) // spell with spell specific that allow single ranks for spell from diff caster // same caster case processed or early or later bool is_spellPerTarget = IsSingleFromSpellSpecificSpellRanksPerTarget(spellId_spec,i_spellId_spec); - if ( is_spellPerTarget && holder->GetCasterGuid() != (*i).second->GetCasterGuid() && sSpellMgr.IsRankSpellDueToSpell(spellProto, i_spellId)) + if (is_spellPerTarget && holder->GetCasterGuid() != (*i).second->GetCasterGuid() && sSpellMgr.IsRankSpellDueToSpell(spellProto, i_spellId)) { // cannot remove higher rank - if(CompareAuraRanks(spellId, i_spellId) < 0) + if (CompareAuraRanks(spellId, i_spellId) < 0) return false; // Its a parent aura (create this aura in ApplyModifier) @@ -4290,7 +4290,7 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) } RemoveAurasDueToSpell(i_spellId); - if( m_spellAuraHolders.empty() ) + if (m_spellAuraHolders.empty()) break; else next = m_spellAuraHolders.begin(); @@ -4299,7 +4299,7 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) } // non single (per caster) per target spell specific (possible single spell per target at caster) - if( !is_spellSpecPerTargetPerCaster && !is_spellSpecPerTarget && sSpellMgr.IsNoStackSpellDueToSpell(spellId, i_spellId) ) + if (!is_spellSpecPerTargetPerCaster && !is_spellSpecPerTarget && sSpellMgr.IsNoStackSpellDueToSpell(spellId, i_spellId)) { // Its a parent aura (create this aura in ApplyModifier) if ((*i).second->IsInUse()) @@ -4309,7 +4309,7 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) } RemoveAurasDueToSpell(i_spellId); - if( m_spellAuraHolders.empty() ) + if (m_spellAuraHolders.empty()) break; else next = m_spellAuraHolders.begin(); @@ -4318,11 +4318,11 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) } // Potions stack aura by aura (elixirs/flask already checked) - if( spellProto->SpellFamilyName == SPELLFAMILY_POTION && i_spellProto->SpellFamilyName == SPELLFAMILY_POTION ) + if (spellProto->SpellFamilyName == SPELLFAMILY_POTION && i_spellProto->SpellFamilyName == SPELLFAMILY_POTION) { if (IsNoStackAuraDueToAura(spellId, i_spellId)) { - if(CompareAuraRanks(spellId, i_spellId) < 0) + if (CompareAuraRanks(spellId, i_spellId) < 0) return false; // cannot remove higher rank // Its a parent aura (create this aura in ApplyModifier) @@ -4333,7 +4333,7 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) } RemoveAurasDueToSpell(i_spellId); - if( m_spellAuraHolders.empty() ) + if (m_spellAuraHolders.empty()) break; else next = m_spellAuraHolders.begin(); @@ -4346,9 +4346,9 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) void Unit::RemoveAura(uint32 spellId, SpellEffectIndex effindex, Aura* except) { SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellId); - for(SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second; ) + for (SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second;) { - Aura *aur = iter->second->m_auras[effindex]; + Aura* aur = iter->second->m_auras[effindex]; if (aur && aur != except) { RemoveSingleAuraFromSpellAuraHolder(iter->second, effindex); @@ -4363,7 +4363,7 @@ void Unit::RemoveAura(uint32 spellId, SpellEffectIndex effindex, Aura* except) void Unit::RemoveAurasByCasterSpell(uint32 spellId, ObjectGuid casterGuid) { SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellId); - for(SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second; ) + for (SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second;) { if (iter->second->GetCasterGuid() == casterGuid) { @@ -4379,9 +4379,9 @@ void Unit::RemoveAurasByCasterSpell(uint32 spellId, ObjectGuid casterGuid) void Unit::RemoveSingleAuraFromSpellAuraHolder(uint32 spellId, SpellEffectIndex effindex, ObjectGuid casterGuid, AuraRemoveMode mode) { SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellId); - for(SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second; ) + for (SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second;) { - Aura *aur = iter->second->m_auras[effindex]; + Aura* aur = iter->second->m_auras[effindex]; if (aur && aur->GetCasterGuid() == casterGuid) { RemoveSingleAuraFromSpellAuraHolder(iter->second, effindex, mode); @@ -4393,13 +4393,13 @@ void Unit::RemoveSingleAuraFromSpellAuraHolder(uint32 spellId, SpellEffectIndex } } -void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount, ObjectGuid casterGuid, Unit *dispeller) +void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount, ObjectGuid casterGuid, Unit* dispeller) { SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellId); // Custom dispel case // Unstable Affliction - if(spellEntry->SpellFamilyName == SPELLFAMILY_WARLOCK && (spellEntry->SpellFamilyFlags & UI64LIT(0x010000000000))) + if (spellEntry->SpellFamilyName == SPELLFAMILY_WARLOCK && (spellEntry->SpellFamilyFlags & UI64LIT(0x010000000000))) { if (Aura* dotAura = GetAura(SPELL_AURA_PERIODIC_DAMAGE,SPELLFAMILY_WARLOCK,UI64LIT(0x010000000000), 0x00000000, casterGuid)) { @@ -4420,7 +4420,7 @@ void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount { if (Aura* dotAura = GetAura(SPELL_AURA_DUMMY, SPELLFAMILY_DRUID, UI64LIT(0x0000001000000000), 0x00000000, casterGuid)) { - int32 amount = ( dotAura->GetModifier()->m_amount / dotAura->GetStackAmount() ) * stackAmount; + int32 amount = (dotAura->GetModifier()->m_amount / dotAura->GetStackAmount()) * stackAmount; CastCustomSpell(this, 33778, &amount, NULL, NULL, true, NULL, dotAura, casterGuid); if (Unit* caster = dotAura->GetCaster()) @@ -4444,7 +4444,7 @@ void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount Unit::AuraList const& auras = caster->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i) { - switch((*i)->GetId()) + switch ((*i)->GetId()) { case 51480: triggeredSpell=64694; break;// Lava Flows, Rank 1 case 51481: triggeredSpell=65263; break;// Lava Flows, Rank 2 @@ -4466,7 +4466,7 @@ void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount // Vampiric touch (first dummy aura) else if (spellEntry->SpellFamilyName == SPELLFAMILY_PRIEST && spellEntry->SpellFamilyFlags & UI64LIT(0x0000040000000000)) { - if (Aura *dot = GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, UI64LIT(0x0000040000000000), 0x00000000, casterGuid)) + if (Aura* dot = GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, UI64LIT(0x0000040000000000), 0x00000000, casterGuid)) { if (dot->GetCaster()) { @@ -4486,11 +4486,11 @@ void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount RemoveAuraHolderFromStack(spellId, stackAmount, casterGuid, AURA_REMOVE_BY_DISPEL); } -void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, Unit *stealer) +void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, Unit* stealer) { - SpellAuraHolder *holder = GetSpellAuraHolder(spellId, casterGuid); + SpellAuraHolder* holder = GetSpellAuraHolder(spellId, casterGuid); SpellEntry const* spellProto = sSpellStore.LookupEntry(spellId); - SpellAuraHolder *new_holder = CreateSpellAuraHolder(spellProto, stealer, this); + SpellAuraHolder* new_holder = CreateSpellAuraHolder(spellProto, stealer, this); // set its duration and maximum duration // max duration 2 minutes (in msecs) @@ -4502,7 +4502,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, U for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { - Aura *aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i)); + Aura* aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i)); if (!aur) continue; @@ -4510,7 +4510,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, U int32 basePoints = aur->GetBasePoints(); // construct the new aura for the attacker - will never return NULL, it's just a wrapper for // some different constructors - Aura * new_aur = CreateAura(spellProto, aur->GetEffIndex(), &basePoints, new_holder, stealer, this); + Aura* new_aur = CreateAura(spellProto, aur->GetEffIndex(), &basePoints, new_holder, stealer, this); // set periodic to do at least one tick (for case when original aura has been at last tick preparing) int32 periodic = aur->GetModifier()->periodictime; @@ -4533,7 +4533,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, U void Unit::RemoveAurasDueToSpellByCancel(uint32 spellId) { SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellId); - for(SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second;) + for (SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second;) { RemoveSpellAuraHolder(iter->second, AURA_REMOVE_BY_CANCEL); spair = GetSpellAuraHolderBounds(spellId); @@ -4547,7 +4547,7 @@ void Unit::RemoveAurasWithDispelType(DispelType type, ObjectGuid casterGuid) uint32 dispelMask = GetDispellMask(type); // Dispel all existing auras vs current dispel type SpellAuraHolderMap& auras = GetSpellAuraHolderMap(); - for (SpellAuraHolderMap::iterator itr = auras.begin(); itr != auras.end(); ) + for (SpellAuraHolderMap::iterator itr = auras.begin(); itr != auras.end();) { SpellEntry const* spell = itr->second->GetSpellProto(); if (((1<Dispel) & dispelMask) && (!casterGuid || casterGuid == itr->second->GetCasterGuid())) @@ -4585,7 +4585,7 @@ void Unit::RemoveAurasDueToSpell(uint32 spellId, SpellAuraHolder* except, AuraRe spellId = spellDiffEntry->Id; SpellAuraHolderBounds bounds = GetSpellAuraHolderBounds(spellId); - for (SpellAuraHolderMap::iterator iter = bounds.first; iter != bounds.second; ) + for (SpellAuraHolderMap::iterator iter = bounds.first; iter != bounds.second;) { if (iter->second != except) { @@ -4601,7 +4601,7 @@ void Unit::RemoveAurasDueToSpell(uint32 spellId, SpellAuraHolder* except, AuraRe void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId) { SpellAuraHolderBounds bounds = GetSpellAuraHolderBounds(spellId); - for (SpellAuraHolderMap::iterator iter = bounds.first; iter != bounds.second; ) + for (SpellAuraHolderMap::iterator iter = bounds.first; iter != bounds.second;) { if (iter->second->GetCastItemGuid() == castItem->GetObjectGuid()) { @@ -4616,7 +4616,7 @@ void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId) void Unit::RemoveAurasWithInterruptFlags(uint32 flags) { - for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end(); ) + for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();) { if (iter->second->GetSpellProto()->AuraInterruptFlags & flags) { @@ -4630,7 +4630,7 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flags) void Unit::RemoveAurasWithAttribute(uint32 flags) { - for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end(); ) + for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();) { if (iter->second->GetSpellProto()->HasAttribute((SpellAttributes)flags)) { @@ -4645,7 +4645,7 @@ void Unit::RemoveAurasWithAttribute(uint32 flags) void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase) { // single target auras from other casters - for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end(); ) + for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();) { if (iter->second->GetCasterGuid() != GetObjectGuid() && iter->second->IsSingleTarget()) { @@ -4672,14 +4672,14 @@ void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase) // single target auras at other targets SingleCastSpellTargetMap& scTargets = GetSingleCastSpellTargets(); - for (SingleCastSpellTargetMap::iterator itr = scTargets.begin(); itr != scTargets.end(); ) + for (SingleCastSpellTargetMap::iterator itr = scTargets.begin(); itr != scTargets.end();) { SpellEntry const* itr_spellEntry = itr->first; ObjectGuid itr_targetGuid = itr->second; if (itr_targetGuid != GetObjectGuid()) { - if(!newPhase) + if (!newPhase) { scTargets.erase(itr); // remove for caster in any case @@ -4693,7 +4693,7 @@ void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase) else { Unit* itr_target = GetMap()->GetUnit(itr_targetGuid); - if(!itr_target || !itr_target->InSamePhase(newPhase)) + if (!itr_target || !itr_target->InSamePhase(newPhase)) { scTargets.erase(itr); // remove for caster in any case @@ -4712,14 +4712,14 @@ void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase) } -void Unit::RemoveSpellAuraHolder(SpellAuraHolder *holder, AuraRemoveMode mode) +void Unit::RemoveSpellAuraHolder(SpellAuraHolder* holder, AuraRemoveMode mode) { // Statue unsummoned at holder remove SpellEntry const* AurSpellInfo = holder->GetSpellProto(); Totem* statue = NULL; Unit* caster = holder->GetCaster(); - if(IsChanneledSpell(AurSpellInfo) && caster) - if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->IsTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE) + if (IsChanneledSpell(AurSpellInfo) && caster) + if (caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->IsTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE) statue = ((Totem*)caster); if (m_spellAuraHoldersUpdateIterator != m_spellAuraHolders.end() && m_spellAuraHoldersUpdateIterator->second == holder) @@ -4740,7 +4740,7 @@ void Unit::RemoveSpellAuraHolder(SpellAuraHolder *holder, AuraRemoveMode mode) for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { - if (Aura *aura = holder->m_auras[i]) + if (Aura* aura = holder->m_auras[i]) RemoveAura(aura, mode); } @@ -4749,7 +4749,7 @@ void Unit::RemoveSpellAuraHolder(SpellAuraHolder *holder, AuraRemoveMode mode) if (mode != AURA_REMOVE_BY_DELETE) holder->HandleSpellSpecificBoosts(false); - if(statue) + if (statue) statue->UnSummon(); // If holder in use (removed from code that plan access to it data after return) @@ -4763,15 +4763,15 @@ void Unit::RemoveSpellAuraHolder(SpellAuraHolder *holder, AuraRemoveMode mode) delete holder; if (mode != AURA_REMOVE_BY_EXPIRE && IsChanneledSpell(AurSpellInfo) && !IsAreaOfEffectSpell(AurSpellInfo) && - caster && caster->GetObjectGuid() != GetObjectGuid()) + caster && caster->GetObjectGuid() != GetObjectGuid()) { caster->InterruptSpell(CURRENT_CHANNELED_SPELL); } } -void Unit::RemoveSingleAuraFromSpellAuraHolder(SpellAuraHolder *holder, SpellEffectIndex index, AuraRemoveMode mode) +void Unit::RemoveSingleAuraFromSpellAuraHolder(SpellAuraHolder* holder, SpellEffectIndex index, AuraRemoveMode mode) { - Aura *aura = holder->GetAuraByEffectIndex(index); + Aura* aura = holder->GetAuraByEffectIndex(index); if (!aura) return; @@ -4781,7 +4781,7 @@ void Unit::RemoveSingleAuraFromSpellAuraHolder(SpellAuraHolder *holder, SpellEff RemoveAura(aura, mode); } -void Unit::RemoveAura(Aura *Aur, AuraRemoveMode mode) +void Unit::RemoveAura(Aura* Aur, AuraRemoveMode mode) { // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order) if (Aur->GetModifier()->m_auraname < TOTAL_AURAS) @@ -4808,7 +4808,7 @@ void Unit::RemoveAura(Aura *Aur, AuraRemoveMode mode) { switch (Aur->GetModifier()->m_auraname) { - // need properly undo any auras with player-caster mover set (or will crash at next caster move packet) + // need properly undo any auras with player-caster mover set (or will crash at next caster move packet) case SPELL_AURA_MOD_POSSESS: case SPELL_AURA_MOD_POSSESS_PET: case SPELL_AURA_CONTROL_VEHICLE: @@ -4841,15 +4841,15 @@ void Unit::RemoveArenaAuras(bool onleave) { // in join, remove positive buffs, on end, remove negative // used to remove positive visible auras in arenas - for(SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();) + for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();) { if (!iter->second->GetSpellProto()->HasAttribute(SPELL_ATTR_EX4_UNK21) && - // don't remove stances, shadowform, pally/hunter auras - !iter->second->IsPassive() && // don't remove passive auras - (!iter->second->GetSpellProto()->HasAttribute(SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) || - !iter->second->GetSpellProto()->HasAttribute(SPELL_ATTR_UNK8)) && - // not unaffected by invulnerability auras or not having that unknown flag (that seemed the most probable) - (iter->second->IsPositive() != onleave)) // remove positive buffs on enter, negative buffs on leave + // don't remove stances, shadowform, pally/hunter auras + !iter->second->IsPassive() && // don't remove passive auras + (!iter->second->GetSpellProto()->HasAttribute(SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) || + !iter->second->GetSpellProto()->HasAttribute(SPELL_ATTR_UNK8)) && + // not unaffected by invulnerability auras or not having that unknown flag (that seemed the most probable) + (iter->second->IsPositive() != onleave)) // remove positive buffs on enter, negative buffs on leave { RemoveSpellAuraHolder(iter->second); iter = m_spellAuraHolders.begin(); @@ -4863,7 +4863,7 @@ void Unit::RemoveAllAurasOnDeath() { // used just after dieing to remove all visible auras // and disable the mods for the passive ones - for(SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();) + for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();) { if (!iter->second->IsPassive() && !iter->second->IsDeathPersistent()) { @@ -4941,9 +4941,9 @@ Aura* Unit::GetAura(uint32 spellId, SpellEffectIndex effindex) Aura* Unit::GetAura(AuraType type, SpellFamily family, uint64 familyFlag, uint32 familyFlag2, ObjectGuid casterGuid) { AuraList const& auras = GetAurasByType(type); - for(AuraList::const_iterator i = auras.begin();i != auras.end(); ++i) + for (AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i) if ((*i)->GetSpellProto()->IsFitToFamily(family, familyFlag, familyFlag2) && - (!casterGuid || (*i)->GetCasterGuid() == casterGuid)) + (!casterGuid || (*i)->GetCasterGuid() == casterGuid)) return *i; return NULL; @@ -4952,7 +4952,7 @@ Aura* Unit::GetAura(AuraType type, SpellFamily family, uint64 familyFlag, uint32 bool Unit::HasAura(uint32 spellId, SpellEffectIndex effIndex) const { SpellAuraHolderConstBounds spair = GetSpellAuraHolderBounds(spellId); - for(SpellAuraHolderMap::const_iterator i_holder = spair.first; i_holder != spair.second; ++i_holder) + for (SpellAuraHolderMap::const_iterator i_holder = spair.first; i_holder != spair.second; ++i_holder) if (i_holder->second->GetAuraByEffectIndex(effIndex)) return true; @@ -4976,16 +4976,16 @@ void Unit::AddDynObject(DynamicObject* dynObj) void Unit::RemoveDynObject(uint32 spellid) { - if(m_dynObjGUIDs.empty()) + if (m_dynObjGUIDs.empty()) return; for (GuidList::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();) { DynamicObject* dynObj = GetMap()->GetDynamicObject(*i); - if(!dynObj) + if (!dynObj) { i = m_dynObjGUIDs.erase(i); } - else if(spellid == 0 || dynObj->GetSpellId() == spellid) + else if (spellid == 0 || dynObj->GetSpellId() == spellid) { dynObj->Delete(); i = m_dynObjGUIDs.erase(i); @@ -4997,7 +4997,7 @@ void Unit::RemoveDynObject(uint32 spellid) void Unit::RemoveAllDynObjects() { - while(!m_dynObjGUIDs.empty()) + while (!m_dynObjGUIDs.empty()) { if (DynamicObject* dynObj = GetMap()->GetDynamicObject(*m_dynObjGUIDs.begin())) dynObj->Delete(); @@ -5005,12 +5005,12 @@ void Unit::RemoveAllDynObjects() } } -DynamicObject * Unit::GetDynObject(uint32 spellId, SpellEffectIndex effIndex) +DynamicObject* Unit::GetDynObject(uint32 spellId, SpellEffectIndex effIndex) { for (GuidList::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();) { DynamicObject* dynObj = GetMap()->GetDynamicObject(*i); - if(!dynObj) + if (!dynObj) { i = m_dynObjGUIDs.erase(i); continue; @@ -5023,12 +5023,12 @@ DynamicObject * Unit::GetDynObject(uint32 spellId, SpellEffectIndex effIndex) return NULL; } -DynamicObject * Unit::GetDynObject(uint32 spellId) +DynamicObject* Unit::GetDynObject(uint32 spellId) { for (GuidList::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();) { DynamicObject* dynObj = GetMap()->GetDynamicObject(*i); - if(!dynObj) + if (!dynObj) { i = m_dynObjGUIDs.erase(i); continue; @@ -5101,7 +5101,7 @@ void Unit::RemoveGameObject(GameObject* gameObj, bool del) if (GetTypeId()==TYPEID_PLAYER) { - SpellEntry const* createBySpell = sSpellStore.LookupEntry(spellid ); + SpellEntry const* createBySpell = sSpellStore.LookupEntry(spellid); // Need activate spell use for owner if (createBySpell && createBySpell->HasAttribute(SPELL_ATTR_DISABLED_WHILE_ACTIVE)) // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existing cases) @@ -5158,7 +5158,7 @@ void Unit::RemoveAllGameObjects() m_wildGameObjs.clear(); } -void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage *log) +void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log) { uint32 targetHealth = log->target->GetHealth(); uint32 overkill = log->damage > targetHealth ? log->damage - targetHealth : 0; @@ -5169,18 +5169,18 @@ void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage *log) data << uint32(log->SpellID); data << uint32(log->damage); // damage amount data << uint32(overkill); // overkill - data << uint8 (log->schoolMask); // damage school + data << uint8(log->schoolMask); // damage school data << uint32(log->absorb); // AbsorbedDamage data << uint32(log->resist); // resist - data << uint8 (log->physicalLog); // if 1, then client show spell name (example: %s's ranged shot hit %s for %u school or %s suffers %u school damage from %s's spell_name - data << uint8 (log->unused); // unused + data << uint8(log->physicalLog); // if 1, then client show spell name (example: %s's ranged shot hit %s for %u school or %s suffers %u school damage from %s's spell_name + data << uint8(log->unused); // unused data << uint32(log->blocked); // blocked data << uint32(log->HitInfo); - data << uint8 (0); // flag to use extend data - SendMessageToSet( &data, true ); + data << uint8(0); // flag to use extend data + SendMessageToSet(&data, true); } -void Unit::SendSpellNonMeleeDamageLog(Unit *target, uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit) +void Unit::SendSpellNonMeleeDamageLog(Unit* target, uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit) { SpellNonMeleeDamage log(this, target, SpellID, damageSchoolMask); log.damage = Damage - AbsorbedDamage - Resist - Blocked; @@ -5189,15 +5189,15 @@ void Unit::SendSpellNonMeleeDamageLog(Unit *target, uint32 SpellID, uint32 Damag log.physicalLog = PhysicalDamage; log.blocked = Blocked; log.HitInfo = SPELL_HIT_TYPE_UNK1 | SPELL_HIT_TYPE_UNK3 | SPELL_HIT_TYPE_UNK6; - if(CriticalHit) + if (CriticalHit) log.HitInfo |= SPELL_HIT_TYPE_CRIT; SendSpellNonMeleeDamageLog(&log); } -void Unit::SendPeriodicAuraLog(SpellPeriodicAuraLogInfo *pInfo) +void Unit::SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* pInfo) { - Aura *aura = pInfo->aura; - Modifier *mod = aura->GetModifier(); + Aura* aura = pInfo->aura; + Modifier* mod = aura->GetModifier(); WorldPacket data(SMSG_PERIODICAURALOG, 30); data << aura->GetTarget()->GetPackGUID(); @@ -5205,7 +5205,7 @@ void Unit::SendPeriodicAuraLog(SpellPeriodicAuraLogInfo *pInfo) data << uint32(aura->GetId()); // spellId data << uint32(1); // count data << uint32(mod->m_auraname); // auraId - switch(mod->m_auraname) + switch (mod->m_auraname) { case SPELL_AURA_PERIODIC_DAMAGE: case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: @@ -5241,18 +5241,18 @@ void Unit::SendPeriodicAuraLog(SpellPeriodicAuraLogInfo *pInfo) aura->GetTarget()->SendMessageToSet(&data, true); } -void Unit::ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 procExtra, uint32 amount, WeaponAttackType attType, SpellEntry const *procSpell) +void Unit::ProcDamageAndSpell(Unit* pVictim, uint32 procAttacker, uint32 procVictim, uint32 procExtra, uint32 amount, WeaponAttackType attType, SpellEntry const* procSpell) { - // Not much to do if no flags are set. + // Not much to do if no flags are set. if (procAttacker) ProcDamageAndSpellFor(false,pVictim,procAttacker, procExtra,attType, procSpell, amount); // Now go on with a victim's events'n'auras // Not much to do if no flags are set or there is no victim - if(pVictim && pVictim->isAlive() && procVictim) + if (pVictim && pVictim->isAlive() && procVictim) pVictim->ProcDamageAndSpellFor(true,this,procVictim, procExtra, attType, procSpell, amount); } -void Unit::SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo) +void Unit::SendSpellMiss(Unit* target, uint32 spellID, SpellMissInfo missInfo) { WorldPacket data(SMSG_SPELLLOGMISS, (4+8+1+4+8+1)); data << uint32(spellID); @@ -5266,7 +5266,7 @@ void Unit::SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo) SendMessageToSet(&data, true); } -void Unit::SendAttackStateUpdate(CalcDamageInfo *damageInfo) +void Unit::SendAttackStateUpdate(CalcDamageInfo* damageInfo) { DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "WORLD: Sending SMSG_ATTACKERSTATEUPDATE"); @@ -5282,37 +5282,37 @@ void Unit::SendAttackStateUpdate(CalcDamageInfo *damageInfo) data << uint32(overkill); // overkill value data << uint8(count); // Sub damage count - for(uint32 i = 0; i < count; ++i) + for (uint32 i = 0; i < count; ++i) { data << uint32(damageInfo->damageSchoolMask); // School of sub damage data << float(damageInfo->damage); // sub damage data << uint32(damageInfo->damage); // Sub Damage } - if(damageInfo->HitInfo & (HITINFO_ABSORB | HITINFO_ABSORB2)) + if (damageInfo->HitInfo & (HITINFO_ABSORB | HITINFO_ABSORB2)) { - for(uint32 i = 0; i < count; ++i) + for (uint32 i = 0; i < count; ++i) data << uint32(damageInfo->absorb); // Absorb } - if(damageInfo->HitInfo & (HITINFO_RESIST | HITINFO_RESIST2)) + if (damageInfo->HitInfo & (HITINFO_RESIST | HITINFO_RESIST2)) { - for(uint32 i = 0; i < count; ++i) + for (uint32 i = 0; i < count; ++i) data << uint32(damageInfo->resist); // Resist } data << uint8(damageInfo->TargetState); data << uint32(0); // unknown, usually seen with -1, 0 and 1000 data << uint32(0); // spell id, seen with heroic strike and disarm as examples. - // HITINFO_NOACTION normally set if spell + // HITINFO_NOACTION normally set if spell - if(damageInfo->HitInfo & HITINFO_BLOCK) + if (damageInfo->HitInfo & HITINFO_BLOCK) data << uint32(damageInfo->blocked_amount); - if(damageInfo->HitInfo & HITINFO_UNK22) + if (damageInfo->HitInfo & HITINFO_UNK22) data << uint32(0); // count of some sort? - if(damageInfo->HitInfo & HITINFO_UNK0) + if (damageInfo->HitInfo & HITINFO_UNK0) { data << uint32(0); data << float(0); @@ -5323,7 +5323,7 @@ void Unit::SendAttackStateUpdate(CalcDamageInfo *damageInfo) data << float(0); data << float(0); data << float(0); - for(uint8 i = 0; i < 5; ++i) + for (uint8 i = 0; i < 5; ++i) { data << float(0); data << float(0); @@ -5331,10 +5331,10 @@ void Unit::SendAttackStateUpdate(CalcDamageInfo *damageInfo) data << uint32(0); } - SendMessageToSet( &data, true ); + SendMessageToSet(&data, true); } -void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit *target, uint8 /*SwingType*/, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount) +void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 /*SwingType*/, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount) { CalcDamageInfo dmgInfo; dmgInfo.HitInfo = HitInfo; @@ -5353,34 +5353,34 @@ void Unit::setPowerType(Powers new_powertype) { SetByteValue(UNIT_FIELD_BYTES_0, 3, new_powertype); - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { - if(((Player*)this)->GetGroup()) + if (((Player*)this)->GetGroup()) ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POWER_TYPE); } - else if(((Creature*)this)->IsPet()) + else if (((Creature*)this)->IsPet()) { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) + Pet* pet = ((Pet*)this); + if (pet->isControlled()) { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + Unit* owner = GetOwner(); + if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_POWER_TYPE); } } - switch(new_powertype) + switch (new_powertype) { default: case POWER_MANA: break; case POWER_RAGE: SetMaxPower(POWER_RAGE,GetCreatePowers(POWER_RAGE)); - SetPower( POWER_RAGE,0); + SetPower(POWER_RAGE,0); break; case POWER_FOCUS: SetMaxPower(POWER_FOCUS,GetCreatePowers(POWER_FOCUS)); - SetPower( POWER_FOCUS,GetCreatePowers(POWER_FOCUS)); + SetPower(POWER_FOCUS,GetCreatePowers(POWER_FOCUS)); break; case POWER_ENERGY: SetMaxPower(POWER_ENERGY,GetCreatePowers(POWER_ENERGY)); @@ -5395,7 +5395,7 @@ void Unit::setPowerType(Powers new_powertype) FactionTemplateEntry const* Unit::getFactionTemplateEntry() const { FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(getFaction()); - if(!entry) + if (!entry) { static ObjectGuid guid; // prevent repeating spam same faction problem @@ -5589,8 +5589,8 @@ bool Unit::IsFriendlyTo(Unit const* unit) const } // faction base cases - FactionTemplateEntry const*tester_faction = tester->getFactionTemplateEntry(); - FactionTemplateEntry const*target_faction = target->getFactionTemplateEntry(); + FactionTemplateEntry const* tester_faction = tester->getFactionTemplateEntry(); + FactionTemplateEntry const* target_faction = target->getFactionTemplateEntry(); if (!tester_faction || !target_faction) return false; @@ -5623,7 +5623,7 @@ bool Unit::IsFriendlyTo(Unit const* unit) const // apply reputation state if (FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction)) - if (raw_tester_faction->reputationListID >=0 ) + if (raw_tester_faction->reputationListID >=0) return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY; } } @@ -5635,11 +5635,11 @@ bool Unit::IsFriendlyTo(Unit const* unit) const bool Unit::IsHostileToPlayers() const { FactionTemplateEntry const* my_faction = getFactionTemplateEntry(); - if(!my_faction || !my_faction->faction) + if (!my_faction || !my_faction->faction) return false; FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction); - if(raw_faction && raw_faction->reputationListID >=0 ) + if (raw_faction && raw_faction->reputationListID >=0) return false; return my_faction->IsHostileToPlayers(); @@ -5648,43 +5648,43 @@ bool Unit::IsHostileToPlayers() const bool Unit::IsNeutralToAll() const { FactionTemplateEntry const* my_faction = getFactionTemplateEntry(); - if(!my_faction || !my_faction->faction) + if (!my_faction || !my_faction->faction) return true; FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction); - if(raw_faction && raw_faction->reputationListID >=0 ) + if (raw_faction && raw_faction->reputationListID >=0) return false; return my_faction->IsNeutralToAll(); } -bool Unit::Attack(Unit *victim, bool meleeAttack) +bool Unit::Attack(Unit* victim, bool meleeAttack) { - if(!victim || victim == this) + if (!victim || victim == this) return false; // dead units can neither attack nor be attacked - if(!isAlive() || !victim->IsInWorld() || !victim->isAlive()) + if (!isAlive() || !victim->IsInWorld() || !victim->isAlive()) return false; // player cannot attack in mount state - if(GetTypeId()==TYPEID_PLAYER && IsMounted()) + if (GetTypeId()==TYPEID_PLAYER && IsMounted()) return false; // nobody can attack GM in GM-mode - if(victim->GetTypeId()==TYPEID_PLAYER) + if (victim->GetTypeId()==TYPEID_PLAYER) { - if(((Player*)victim)->isGameMaster()) + if (((Player*)victim)->isGameMaster()) return false; } else { - if(((Creature*)victim)->IsInEvadeMode()) + if (((Creature*)victim)->IsInEvadeMode()) return false; } // remove SPELL_AURA_MOD_UNATTACKABLE at attack (in case non-interruptible spells stun aura applied also that not let attack) - if(HasAuraType(SPELL_AURA_MOD_UNATTACKABLE)) + if (HasAuraType(SPELL_AURA_MOD_UNATTACKABLE)) RemoveSpellsCausingAura(SPELL_AURA_MOD_UNATTACKABLE); // in fighting already @@ -5693,7 +5693,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) if (m_attacking == victim) { // switch to melee attack from ranged/magic - if( meleeAttack && !hasUnitState(UNIT_STAT_MELEE_ATTACKING) ) + if (meleeAttack && !hasUnitState(UNIT_STAT_MELEE_ATTACKING)) { addUnitState(UNIT_STAT_MELEE_ATTACKING); SendMeleeAttackStart(victim); @@ -5709,14 +5709,14 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) else { // set position before any AI calls/assistance - if(GetTypeId()==TYPEID_UNIT) + if (GetTypeId()==TYPEID_UNIT) ((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); } // Set our target SetTargetGuid(victim->GetObjectGuid()); - if(meleeAttack) + if (meleeAttack) addUnitState(UNIT_STAT_MELEE_ATTACKING); m_attacking = victim; @@ -5729,10 +5729,10 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) } // delay offhand weapon attack to next attack time - if(haveOffhandWeapon()) + if (haveOffhandWeapon()) resetAttackTimer(OFF_ATTACK); - if(meleeAttack) + if (meleeAttack) SendMeleeAttackStart(victim); return true; @@ -5771,7 +5771,7 @@ bool Unit::AttackStop(bool targetSwitch /*=false*/) InterruptSpell(CURRENT_MELEE_SPELL); // reset only at real combat stop - if(!targetSwitch && GetTypeId()==TYPEID_UNIT ) + if (!targetSwitch && GetTypeId()==TYPEID_UNIT) { ((Creature*)this)->SetNoCallAssistance(false); @@ -5795,7 +5795,7 @@ void Unit::CombatStop(bool includingCast) AttackStop(); RemoveAllAttackers(); - if( GetTypeId()==TYPEID_PLAYER ) + if (GetTypeId()==TYPEID_PLAYER) ((Player*)this)->SendAttackSwingCancelAttack(); // melee and ranged forced attack cancel else if (GetTypeId() == TYPEID_UNIT) { @@ -5827,7 +5827,7 @@ struct IsAttackingPlayerHelper bool Unit::isAttackingPlayer() const { - if(hasUnitState(UNIT_STAT_ATTACK_PLAYER)) + if (hasUnitState(UNIT_STAT_ATTACK_PLAYER)) return true; return CheckAllControlledUnits(IsAttackingPlayerHelper(), CONTROLLED_PET|CONTROLLED_TOTEMS|CONTROLLED_GUARDIANS|CONTROLLED_CHARM); @@ -5838,7 +5838,7 @@ void Unit::RemoveAllAttackers() while (!m_attackers.empty()) { AttackerSet::iterator iter = m_attackers.begin(); - if(!(*iter)->AttackStop()) + if (!(*iter)->AttackStop()) { sLog.outError("WORLD: Unit has an attacker that isn't attacking it!"); m_attackers.erase(iter); @@ -5858,8 +5858,8 @@ bool Unit::HasAuraStateForCaster(AuraState flag, ObjectGuid casterGuid) const for (Unit::AuraList::const_iterator i = dotList.begin(); i != dotList.end(); ++i) { if ((*i)->GetCasterGuid() == casterGuid && - // Immolate or Shadowflame - (*i)->GetSpellProto()->IsFitToFamily(SPELLFAMILY_WARLOCK, UI64LIT(0x0000000000000004), 0x00000002)) + // Immolate or Shadowflame + (*i)->GetSpellProto()->IsFitToFamily(SPELLFAMILY_WARLOCK, UI64LIT(0x0000000000000004), 0x00000002)) { return true; } @@ -5878,13 +5878,13 @@ void Unit::ModifyAuraState(AuraState flag, bool apply) if (!HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1))) { SetFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { const PlayerSpellMap& sp_list = ((Player*)this)->GetSpellMap(); for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) { - if(itr->second.state == PLAYERSPELL_REMOVED) continue; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); + if (itr->second.state == PLAYERSPELL_REMOVED) continue; + SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first); if (!spellInfo || !IsPassiveSpell(spellInfo)) continue; if (AuraState(spellInfo->CasterAuraState) == flag) CastSpell(this, itr->first, true, NULL); @@ -5917,14 +5917,14 @@ void Unit::ModifyAuraState(AuraState flag, bool apply) } } -Unit *Unit::GetOwner() const +Unit* Unit::GetOwner() const { if (ObjectGuid ownerid = GetOwnerGuid()) return ObjectAccessor::GetUnit(*this, ownerid); return NULL; } -Unit *Unit::GetCharmer() const +Unit* Unit::GetCharmer() const { if (ObjectGuid charmerid = GetCharmerGuid()) return ObjectAccessor::GetUnit(*this, charmerid); @@ -5961,7 +5961,7 @@ Pet* Unit::GetPet() const { if (ObjectGuid pet_guid = GetPetGuid()) { - if(Pet* pet = GetMap()->GetPet(pet_guid)) + if (Pet* pet = GetMap()->GetPet(pet_guid)) return pet; sLog.outError("Unit::GetPet: %s not exist.", pet_guid.GetString().c_str()); @@ -6016,21 +6016,21 @@ void Unit::Uncharm() } } -float Unit::GetCombatDistance( const Unit* target ) const +float Unit::GetCombatDistance(const Unit* target) const { float radius = target->GetFloatValue(UNIT_FIELD_COMBATREACH) + GetFloatValue(UNIT_FIELD_COMBATREACH); float dx = GetPositionX() - target->GetPositionX(); float dy = GetPositionY() - target->GetPositionY(); float dz = GetPositionZ() - target->GetPositionZ(); float dist = sqrt((dx*dx) + (dy*dy) + (dz*dz)) - radius; - return ( dist > 0 ? dist : 0); + return (dist > 0 ? dist : 0); } void Unit::SetPet(Pet* pet) { SetPetGuid(pet ? pet->GetObjectGuid() : ObjectGuid()); - if(pet && GetTypeId() == TYPEID_PLAYER) + if (pet && GetTypeId() == TYPEID_PLAYER) ((Player*)this)->SendPetGUIDs(); } @@ -6039,12 +6039,12 @@ void Unit::SetCharm(Unit* pet) SetCharmGuid(pet ? pet->GetObjectGuid() : ObjectGuid()); } -void Unit::AddGuardian( Pet* pet ) +void Unit::AddGuardian(Pet* pet) { m_guardianPets.insert(pet->GetObjectGuid()); } -void Unit::RemoveGuardian( Pet* pet ) +void Unit::RemoveGuardian(Pet* pet) { m_guardianPets.erase(pet->GetObjectGuid()); } @@ -6087,12 +6087,12 @@ Unit* Unit::_GetTotem(TotemSlot slot) const return GetTotem(slot); } -Totem* Unit::GetTotem(TotemSlot slot ) const +Totem* Unit::GetTotem(TotemSlot slot) const { if (slot >= MAX_TOTEM_SLOT || !IsInWorld() || !m_TotemSlot[slot]) return NULL; - Creature *totem = GetMap()->GetCreature(m_TotemSlot[slot]); + Creature* totem = GetMap()->GetCreature(m_TotemSlot[slot]); return totem && totem->IsTotem() ? (Totem*)totem : NULL; } @@ -6111,7 +6111,7 @@ void Unit::_AddTotem(TotemSlot slot, Totem* totem) void Unit::_RemoveTotem(Totem* totem) { - for(int i = 0; i < MAX_TOTEM_SLOT; ++i) + for (int i = 0; i < MAX_TOTEM_SLOT; ++i) { if (m_TotemSlot[i] == totem->GetObjectGuid()) { @@ -6161,16 +6161,16 @@ int32 Unit::DealHeal(Unit* pVictim, uint32 addhealth, SpellEntry const* spellPro return gain; } -Unit* Unit::SelectMagnetTarget(Unit *victim, Spell* spell, SpellEffectIndex eff) +Unit* Unit::SelectMagnetTarget(Unit* victim, Spell* spell, SpellEffectIndex eff) { - if(!victim) + if (!victim) return NULL; // Magic case if (spell && spell->m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC) { Unit::AuraList const& magnetAuras = victim->GetAurasByType(SPELL_AURA_SPELL_MAGNET); - for(Unit::AuraList::const_iterator itr = magnetAuras.begin(); itr != magnetAuras.end(); ++itr) + for (Unit::AuraList::const_iterator itr = magnetAuras.begin(); itr != magnetAuras.end(); ++itr) { if (Unit* magnet = (*itr)->GetCaster()) { @@ -6183,7 +6183,7 @@ Unit* Unit::SelectMagnetTarget(Unit *victim, Spell* spell, SpellEffectIndex eff) else { AuraList const& hitTriggerAuras = victim->GetAurasByType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER); - for(AuraList::const_iterator i = hitTriggerAuras.begin(); i != hitTriggerAuras.end(); ++i) + for (AuraList::const_iterator i = hitTriggerAuras.begin(); i != hitTriggerAuras.end(); ++i) { if (Unit* magnet = (*i)->GetCaster()) { @@ -6199,7 +6199,7 @@ Unit* Unit::SelectMagnetTarget(Unit *victim, Spell* spell, SpellEffectIndex eff) return victim; } -void Unit::SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, uint32 OverHeal, bool critical, uint32 absorb) +void Unit::SendHealSpellLog(Unit* pVictim, uint32 SpellID, uint32 Damage, uint32 OverHeal, bool critical, uint32 absorb) { // we guess size WorldPacket data(SMSG_SPELLHEALLOG, (8+8+4+4+1)); @@ -6214,7 +6214,7 @@ void Unit::SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, uint32 SendMessageToSet(&data, true); } -void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype) +void Unit::SendEnergizeSpellLog(Unit* pVictim, uint32 SpellID, uint32 Damage, Powers powertype) { WorldPacket data(SMSG_SPELLENERGIZELOG, (8+8+4+4+4+1)); data << pVictim->GetPackGUID(); @@ -6225,14 +6225,14 @@ void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Po SendMessageToSet(&data, true); } -void Unit::EnergizeBySpell(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype) +void Unit::EnergizeBySpell(Unit* pVictim, uint32 SpellID, uint32 Damage, Powers powertype) { SendEnergizeSpellLog(pVictim, SpellID, Damage, powertype); // needs to be called after sending spell log pVictim->ModifyPower(powertype, Damage); } -int32 Unit::SpellBonusWithCoeffs(SpellEntry const *spellProto, int32 total, int32 benefit, int32 ap_benefit, DamageEffectType damagetype, bool donePart, float defCoeffMod) +int32 Unit::SpellBonusWithCoeffs(SpellEntry const* spellProto, int32 total, int32 benefit, int32 ap_benefit, DamageEffectType damagetype, bool donePart, float defCoeffMod) { // Distribute Damage over multiple effects, reduce by AoE float coeff = 1.0f; @@ -6269,7 +6269,7 @@ int32 Unit::SpellBonusWithCoeffs(SpellEntry const *spellProto, int32 total, int3 float LvlPenalty = CalculateLevelPenalty(spellProto); // Spellmod SpellDamage - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) { coeff *= 100.0f; modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_SPELL_BONUS_DAMAGE, coeff); @@ -6286,15 +6286,15 @@ int32 Unit::SpellBonusWithCoeffs(SpellEntry const *spellProto, int32 total, int3 * Calculates caster part of spell damage bonuses, * also includes different bonuses dependent from target auras */ -uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) { if (!spellProto || !pVictim || damagetype == DIRECT_DAMAGE || spellProto->HasAttribute(SPELL_ATTR_EX6_NO_DMG_MODS)) return pdamage; // For totems get damage bonus from owner (statue isn't totem in fact) - if( GetTypeId()==TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType()!=TOTEM_STATUE) + if (GetTypeId()==TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType()!=TOTEM_STATUE) { - if(Unit* owner = GetOwner()) + if (Unit* owner = GetOwner()) return owner->SpellDamageBonusDone(pVictim, spellProto, pdamage, damagetype); } @@ -6302,17 +6302,17 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u int32 DoneTotal = 0; // Creature damage - if( GetTypeId() == TYPEID_UNIT && !((Creature*)this)->IsPet() ) + if (GetTypeId() == TYPEID_UNIT && !((Creature*)this)->IsPet()) DoneTotalMod *= ((Creature*)this)->GetSpellDamageMod(((Creature*)this)->GetCreatureInfo()->rank); AuraList const& mModDamagePercentDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); - for(AuraList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i) + for (AuraList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i) { if (((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto)) && - (*i)->GetSpellProto()->EquippedItemClass == -1 && - // -1 == any item class (not wand then) - (*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0) - // 0 == any inventory type (not wand then) + (*i)->GetSpellProto()->EquippedItemClass == -1 && + // -1 == any item class (not wand then) + (*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0) + // 0 == any inventory type (not wand then) { DoneTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; } @@ -6322,26 +6322,26 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u // Add flat bonus from spell damage versus DoneTotal += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS, creatureTypeMask); AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); - for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) + for (AuraList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i) + if (creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; AuraList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); - for(AuraList::const_iterator i = mDamageDoneCreature.begin();i != mDamageDoneCreature.end(); ++i) + for (AuraList::const_iterator i = mDamageDoneCreature.begin(); i != mDamageDoneCreature.end(); ++i) { - if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) + if (creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) DoneTotalMod += ((*i)->GetModifier()->m_amount+100.0f)/100.0f; } // done scripted mod (take it from owner) - Unit *owner = GetOwner(); + Unit* owner = GetOwner(); if (!owner) owner = this; AuraList const& mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) + for (AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { if (!(*i)->isAffectedOnSpell(spellProto)) continue; - switch((*i)->GetModifier()->m_miscvalue) + switch ((*i)->GetModifier()->m_miscvalue) { case 4920: // Molten Fury case 4919: @@ -6349,7 +6349,7 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u case 6926: case 6928: { - if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) + if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) DoneTotalMod *= (100.0f+(*i)->GetModifier()->m_amount)/100.0f; break; } @@ -6410,7 +6410,7 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u // Merciless Combat if ((*i)->GetSpellProto()->SpellIconID == 2656) { - if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) + if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) DoneTotalMod *= (100.0f+(*i)->GetModifier()->m_amount)/100.0f; } else // Tundra Stalker @@ -6449,8 +6449,8 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u } } - // Custom scripted damage - switch(spellProto->SpellFamilyName) + // Custom scripted damage + switch (spellProto->SpellFamilyName) { case SPELLFAMILY_MAGE: { @@ -6472,11 +6472,11 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u } // Torment the weak affected (Arcane Barrage, Arcane Blast, Frostfire Bolt, Arcane Missiles, Fireball) if ((spellProto->SpellFamilyFlags & UI64LIT(0x0000900020200021)) && - (pVictim->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED) || pVictim->HasAuraType(SPELL_AURA_HASTE_ALL))) + (pVictim->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED) || pVictim->HasAuraType(SPELL_AURA_HASTE_ALL))) { //Search for Torment the weak dummy aura Unit::AuraList const& ttw = GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator i = ttw.begin(); i != ttw.end(); ++i) + for (Unit::AuraList::const_iterator i = ttw.begin(); i != ttw.end(); ++i) { if ((*i)->GetSpellProto()->SpellIconID == 3263) { @@ -6505,7 +6505,7 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u // Holy Fire if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, UI64LIT(0x00100000))) // Glyph of Smite - if (Aura *aur = GetAura(55692, EFFECT_INDEX_0)) + if (Aura* aur = GetAura(55692, EFFECT_INDEX_0)) DoneTotalMod *= (aur->GetModifier()->m_amount+100.0f) / 100.0f; } // Shadow word: Death @@ -6531,7 +6531,7 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, UI64LIT(0x000000000200000), 0, GetObjectGuid())) { Unit::AuraList const& improvedSwarm = GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator iter = improvedSwarm.begin(); iter != improvedSwarm.end(); ++iter) + for (Unit::AuraList::const_iterator iter = improvedSwarm.begin(); iter != improvedSwarm.end(); ++iter) { if ((*iter)->GetSpellProto()->SpellIconID == 1771) { @@ -6551,20 +6551,20 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u // search disease bool found = false; Unit::SpellAuraHolderMap const& auras = pVictim->GetSpellAuraHolderMap(); - for(Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) { - if(itr->second->GetSpellProto()->Dispel == DISPEL_DISEASE) + if (itr->second->GetSpellProto()->Dispel == DISPEL_DISEASE) { found = true; break; } } - if(!found) + if (!found) break; // search for Glacier Rot dummy aura Unit::AuraList const& dummyAuras = GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator i = dummyAuras.begin(); i != dummyAuras.end(); ++i) + for (Unit::AuraList::const_iterator i = dummyAuras.begin(); i != dummyAuras.end(); ++i) { if ((*i)->GetSpellProto()->EffectMiscValue[(*i)->GetEffIndex()] == 7244) { @@ -6576,7 +6576,7 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u // Death Coil (bonus from Item - Death Knight T8 DPS Relic) else if (spellProto->SpellFamilyFlags & UI64LIT(0x00002000)) { - if (Aura* sigil = GetDummyAura(64962)) + if (Aura* sigil = GetDummyAura(64962)) DoneTotal += sigil->GetModifier()->m_amount; } break; @@ -6598,7 +6598,7 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u float tmpDamage = (int32(pdamage) + DoneTotal * int32(stack)) * DoneTotalMod; // apply spellmod to Done damage (flat and pct) - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage); return tmpDamage > 0 ? uint32(tmpDamage) : 0; @@ -6608,9 +6608,9 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u * Calculates target part of spell damage bonuses, * will be called on each tick for periodic damage over time auras */ -uint32 Unit::SpellDamageBonusTaken(Unit *pCaster, SpellEntry const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellDamageBonusTaken(Unit* pCaster, SpellEntry const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) { - if(!spellProto || !pCaster || damagetype==DIRECT_DAMAGE ) + if (!spellProto || !pCaster || damagetype==DIRECT_DAMAGE) return pdamage; uint32 schoolMask = spellProto->SchoolMask; @@ -6624,14 +6624,14 @@ uint32 Unit::SpellDamageBonusTaken(Unit *pCaster, SpellEntry const *spellProto, // .. taken pct: dummy auras AuraList const& mDummyAuras = GetAurasByType(SPELL_AURA_DUMMY); - for(AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) + for (AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) { - switch((*i)->GetId()) + switch ((*i)->GetId()) { case 45182: // Cheating Death - if((*i)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) + if ((*i)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) { - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) continue; float mod = ((Player*)this)->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*(-8.0f); @@ -6657,7 +6657,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit *pCaster, SpellEntry const *spellProto, // From caster spells AuraList const& mOwnerTaken = GetAurasByType(SPELL_AURA_MOD_DAMAGE_FROM_CASTER); - for(AuraList::const_iterator i = mOwnerTaken.begin(); i != mOwnerTaken.end(); ++i) + for (AuraList::const_iterator i = mOwnerTaken.begin(); i != mOwnerTaken.end(); ++i) { if ((*i)->GetCasterGuid() == pCaster->GetObjectGuid() && (*i)->isAffectedOnSpell(spellProto)) TakenTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; @@ -6667,7 +6667,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit *pCaster, SpellEntry const *spellProto, TakenTotalMod *= GetTotalAuraMultiplierByMiscValueForMask(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT,GetAllSpellMechanicMask(spellProto)); // Mod damage taken from AoE spells - if(IsAreaOfEffectSpell(spellProto)) + if (IsAreaOfEffectSpell(spellProto)) { TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, schoolMask); if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsPet()) @@ -6691,12 +6691,12 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) // ..done AuraList const& mDamageDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE); - for(AuraList::const_iterator i = mDamageDone.begin();i != mDamageDone.end(); ++i) + for (AuraList::const_iterator i = mDamageDone.begin(); i != mDamageDone.end(); ++i) { if (((*i)->GetModifier()->m_miscvalue & schoolMask) != 0 && - (*i)->GetSpellProto()->EquippedItemClass == -1 && // -1 == any item class (not wand then) - (*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0) // 0 == any inventory type (not wand then) - DoneAdvertisedBenefit += (*i)->GetModifier()->m_amount; + (*i)->GetSpellProto()->EquippedItemClass == -1 && // -1 == any item class (not wand then) + (*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0) // 0 == any inventory type (not wand then) + DoneAdvertisedBenefit += (*i)->GetModifier()->m_amount; } if (GetTypeId() == TYPEID_PLAYER) @@ -6706,9 +6706,9 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) // Damage bonus from stats AuraList const& mDamageDoneOfStatPercent = GetAurasByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT); - for(AuraList::const_iterator i = mDamageDoneOfStatPercent.begin();i != mDamageDoneOfStatPercent.end(); ++i) + for (AuraList::const_iterator i = mDamageDoneOfStatPercent.begin(); i != mDamageDoneOfStatPercent.end(); ++i) { - if((*i)->GetModifier()->m_miscvalue & schoolMask) + if ((*i)->GetModifier()->m_miscvalue & schoolMask) { // stat used stored in miscValueB for this aura Stats usedStat = Stats((*i)->GetMiscBValue()); @@ -6717,7 +6717,7 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) } // ... and attack power AuraList const& mDamageDonebyAP = GetAurasByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER); - for(AuraList::const_iterator i =mDamageDonebyAP.begin();i != mDamageDonebyAP.end(); ++i) + for (AuraList::const_iterator i =mDamageDonebyAP.begin(); i != mDamageDonebyAP.end(); ++i) { if ((*i)->GetModifier()->m_miscvalue & schoolMask) DoneAdvertisedBenefit += int32(GetTotalAttackPowerValue(BASE_ATTACK) * (*i)->GetModifier()->m_amount / 100.0f); @@ -6733,23 +6733,23 @@ int32 Unit::SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask) // ..taken AuraList const& mDamageTaken = GetAurasByType(SPELL_AURA_MOD_DAMAGE_TAKEN); - for(AuraList::const_iterator i = mDamageTaken.begin();i != mDamageTaken.end(); ++i) + for (AuraList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i) { - if(((*i)->GetModifier()->m_miscvalue & schoolMask) != 0) + if (((*i)->GetModifier()->m_miscvalue & schoolMask) != 0) TakenAdvertisedBenefit += (*i)->GetModifier()->m_amount; } return TakenAdvertisedBenefit; } -bool Unit::IsSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType) +bool Unit::IsSpellCrit(Unit* pVictim, SpellEntry const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType) { // not critting spell if (spellProto->HasAttribute(SPELL_ATTR_EX2_CANT_CRIT)) return false; float crit_chance = 0.0f; - switch(spellProto->DmgClass) + switch (spellProto->DmgClass) { case SPELL_DAMAGE_CLASS_NONE: return false; @@ -6759,7 +6759,7 @@ bool Unit::IsSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM crit_chance = 0.0f; // For other schools else if (GetTypeId() == TYPEID_PLAYER) - crit_chance = GetFloatValue( PLAYER_SPELL_CRIT_PERCENTAGE1 + GetFirstSchoolInMask(schoolMask)); + crit_chance = GetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1 + GetFirstSchoolInMask(schoolMask)); else { crit_chance = float(m_baseSpellCritChance); @@ -6781,11 +6781,11 @@ bool Unit::IsSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM // scripted (increase crit chance ... against ... target by x%) // scripted (Increases the critical effect chance of your .... by x% on targets ...) AuraList const& mOverrideClassScript = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) + for (AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { if (!((*i)->isAffectedOnSpell(spellProto))) continue; - switch((*i)->GetModifier()->m_miscvalue) + switch ((*i)->GetModifier()->m_miscvalue) { case 849: //Shatter Rank 1 if (pVictim->isFrozen() || IsIgnoreUnitState(spellProto, IGNORE_UNIT_TARGET_NON_FROZEN)) @@ -6814,7 +6814,7 @@ bool Unit::IsSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM } // Custom crit by class - switch(spellProto->SpellFamilyName) + switch (spellProto->SpellFamilyName) { case SPELLFAMILY_MAGE: { @@ -6835,11 +6835,11 @@ bool Unit::IsSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM if (pVictim->GetHealth() > pVictim->GetMaxHealth()/2) break; AuraList const& mDummyAuras = GetAurasByType(SPELL_AURA_DUMMY); - for(AuraList::const_iterator i = mDummyAuras.begin(); i!= mDummyAuras.end(); ++i) + for (AuraList::const_iterator i = mDummyAuras.begin(); i!= mDummyAuras.end(); ++i) { // Improved Flash Heal if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_PRIEST && - (*i)->GetSpellProto()->SpellIconID == 2542) + (*i)->GetSpellProto()->SpellIconID == 2542) { crit_chance+=(*i)->GetModifier()->m_amount; break; @@ -6855,7 +6855,7 @@ bool Unit::IsSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, UI64LIT(0x000000000000002), 0, GetObjectGuid())) { Unit::AuraList const& improvedSwarm = GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator iter = improvedSwarm.begin(); iter != improvedSwarm.end(); ++iter) + for (Unit::AuraList::const_iterator iter = improvedSwarm.begin(); iter != improvedSwarm.end(); ++iter) { if ((*iter)->GetSpellProto()->SpellIconID == 1771) { @@ -6870,7 +6870,7 @@ bool Unit::IsSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM // Sacred Shield if (spellProto->SpellFamilyFlags & UI64LIT(0x0000000040000000)) { - Aura *aura = pVictim->GetDummyAura(58597); + Aura* aura = pVictim->GetDummyAura(58597); if (aura && aura->GetCasterGuid() == GetObjectGuid()) crit_chance+=aura->GetModifier()->m_amount; } @@ -6908,7 +6908,7 @@ bool Unit::IsSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM } // percent done // only players use intelligence for critical chance computations - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRITICAL_CHANCE, crit_chance); crit_chance = crit_chance > 0.0f ? crit_chance : 0.0f; @@ -6917,11 +6917,11 @@ bool Unit::IsSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM return false; } -uint32 Unit::SpellCriticalDamageBonus(SpellEntry const *spellProto, uint32 damage, Unit *pVictim) +uint32 Unit::SpellCriticalDamageBonus(SpellEntry const* spellProto, uint32 damage, Unit* pVictim) { // Calculate critical bonus int32 crit_bonus; - switch(spellProto->DmgClass) + switch (spellProto->DmgClass) { case SPELL_DAMAGE_CLASS_MELEE: // for melee based spells is 100% case SPELL_DAMAGE_CLASS_RANGED: @@ -6933,16 +6933,16 @@ uint32 Unit::SpellCriticalDamageBonus(SpellEntry const *spellProto, uint32 damag } // adds additional damage to crit_bonus (from talents) - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); - if(!pVictim) + if (!pVictim) return damage += crit_bonus; int32 critPctDamageMod = 0; - if(spellProto->DmgClass >= SPELL_DAMAGE_CLASS_MELEE) + if (spellProto->DmgClass >= SPELL_DAMAGE_CLASS_MELEE) { - if(GetWeaponAttackType(spellProto) == RANGED_ATTACK) + if (GetWeaponAttackType(spellProto) == RANGED_ATTACK) critPctDamageMod += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE); else critPctDamageMod += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE); @@ -6955,20 +6955,20 @@ uint32 Unit::SpellCriticalDamageBonus(SpellEntry const *spellProto, uint32 damag uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); critPctDamageMod += GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, creatureTypeMask); - if(critPctDamageMod!=0) + if (critPctDamageMod!=0) crit_bonus = int32(crit_bonus * float((100.0f + critPctDamageMod)/100.0f)); - if(crit_bonus > 0) + if (crit_bonus > 0) damage += crit_bonus; return damage; } -uint32 Unit::SpellCriticalHealingBonus(SpellEntry const *spellProto, uint32 damage, Unit *pVictim) +uint32 Unit::SpellCriticalHealingBonus(SpellEntry const* spellProto, uint32 damage, Unit* pVictim) { // Calculate critical bonus int32 crit_bonus; - switch(spellProto->DmgClass) + switch (spellProto->DmgClass) { case SPELL_DAMAGE_CLASS_MELEE: // for melee based spells is 100% case SPELL_DAMAGE_CLASS_RANGED: @@ -6980,13 +6980,13 @@ uint32 Unit::SpellCriticalHealingBonus(SpellEntry const *spellProto, uint32 dama break; } - if(pVictim) + if (pVictim) { uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); crit_bonus = int32(crit_bonus * GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, creatureTypeMask)); } - if(crit_bonus > 0) + if (crit_bonus > 0) damage += crit_bonus; damage = int32(damage * GetTotalAuraMultiplier(SPELL_AURA_MOD_CRITICAL_HEALING_AMOUNT)); @@ -6998,11 +6998,11 @@ uint32 Unit::SpellCriticalHealingBonus(SpellEntry const *spellProto, uint32 dama * Calculates caster part of healing spell bonuses, * also includes different bonuses dependent from target auras */ -uint32 Unit::SpellHealingBonusDone(Unit *pVictim, SpellEntry const *spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellHealingBonusDone(Unit* pVictim, SpellEntry const* spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack) { // For totems get healing bonus from owner (statue isn't totem in fact) - if( GetTypeId()==TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType()!=TOTEM_STATUE) - if(Unit* owner = GetOwner()) + if (GetTypeId()==TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType()!=TOTEM_STATUE) + if (Unit* owner = GetOwner()) return owner->SpellHealingBonusDone(pVictim, spellProto, healamount, damagetype, stack); // No heal amount for this class spells @@ -7016,18 +7016,18 @@ uint32 Unit::SpellHealingBonusDone(Unit *pVictim, SpellEntry const *spellProto, // Healing done percent AuraList const& mHealingDonePct = GetAurasByType(SPELL_AURA_MOD_HEALING_DONE_PERCENT); - for(AuraList::const_iterator i = mHealingDonePct.begin();i != mHealingDonePct.end(); ++i) + for (AuraList::const_iterator i = mHealingDonePct.begin(); i != mHealingDonePct.end(); ++i) DoneTotalMod *= (100.0f + (*i)->GetModifier()->m_amount) / 100.0f; // done scripted mod (take it from owner) - Unit *owner = GetOwner(); + Unit* owner = GetOwner(); if (!owner) owner = this; AuraList const& mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) + for (AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { if (!(*i)->isAffectedOnSpell(spellProto)) continue; - switch((*i)->GetModifier()->m_miscvalue) + switch ((*i)->GetModifier()->m_miscvalue) { case 4415: // Increased Rejuvenation Healing case 4953: @@ -7058,9 +7058,9 @@ uint32 Unit::SpellHealingBonusDone(Unit *pVictim, SpellEntry const *spellProto, int ownHotCount = 0; // counted HoT types amount, not stacks Unit::AuraList const& RejorRegr = pVictim->GetAurasByType(SPELL_AURA_PERIODIC_HEAL); - for(Unit::AuraList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i) + for (Unit::AuraList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i) if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID && - (*i)->GetCasterGuid() == GetObjectGuid()) + (*i)->GetCasterGuid() == GetObjectGuid()) ++ownHotCount; if (ownHotCount) @@ -7085,9 +7085,9 @@ uint32 Unit::SpellHealingBonusDone(Unit *pVictim, SpellEntry const *spellProto, { int ownHotCount = 0; // counted HoT types amount, not stacks Unit::AuraList const& RejorRegr = pVictim->GetAurasByType(SPELL_AURA_PERIODIC_HEAL); - for(Unit::AuraList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i) + for (Unit::AuraList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i) if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID && - (*i)->GetCasterGuid() == GetObjectGuid()) + (*i)->GetCasterGuid() == GetObjectGuid()) ++ownHotCount; if (ownHotCount) @@ -7102,9 +7102,9 @@ uint32 Unit::SpellHealingBonusDone(Unit *pVictim, SpellEntry const *spellProto, else if (spellProto->IsFitToFamilyMask(UI64LIT(0x0000001000000000))) { AuraList const& dummyList = owner->GetAurasByType(SPELL_AURA_DUMMY); - for(AuraList::const_iterator i = dummyList.begin(); i != dummyList.end(); ++i) + for (AuraList::const_iterator i = dummyList.begin(); i != dummyList.end(); ++i) { - switch((*i)->GetId()) + switch ((*i)->GetId()) { case 34246: // Idol of the Emerald Queen TODO: can be flat modifier aura case 60779: // Idol of Lush Moss @@ -7124,7 +7124,7 @@ uint32 Unit::SpellHealingBonusDone(Unit *pVictim, SpellEntry const *spellProto, // use float as more appropriate for negative values and percent applying float heal = (healamount + DoneTotal * int32(stack))*DoneTotalMod; // apply spellmod to Done amount - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal); return heal < 0 ? 0 : uint32(heal); @@ -7134,7 +7134,7 @@ uint32 Unit::SpellHealingBonusDone(Unit *pVictim, SpellEntry const *spellProto, * Calculates target part of healing spell bonuses, * will be called on each tick for periodic damage over time auras */ -uint32 Unit::SpellHealingBonusTaken(Unit *pCaster, SpellEntry const *spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellHealingBonusTaken(Unit* pCaster, SpellEntry const* spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack) { float TakenTotalMod = 1.0f; @@ -7172,7 +7172,7 @@ uint32 Unit::SpellHealingBonusTaken(Unit *pCaster, SpellEntry const *spellProto, TakenTotal = SpellBonusWithCoeffs(spellProto, TakenTotal, TakenAdvertisedBenefit, 0, damagetype, false, 1.88f); AuraList const& mHealingGet= GetAurasByType(SPELL_AURA_MOD_HEALING_RECEIVED); - for(AuraList::const_iterator i = mHealingGet.begin(); i != mHealingGet.end(); ++i) + for (AuraList::const_iterator i = mHealingGet.begin(); i != mHealingGet.end(); ++i) if ((*i)->isAffectedOnSpell(spellProto)) TakenTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; @@ -7187,8 +7187,8 @@ int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) int32 AdvertisedBenefit = 0; AuraList const& mHealingDone = GetAurasByType(SPELL_AURA_MOD_HEALING_DONE); - for(AuraList::const_iterator i = mHealingDone.begin();i != mHealingDone.end(); ++i) - if(!(*i)->GetModifier()->m_miscvalue || ((*i)->GetModifier()->m_miscvalue & schoolMask) != 0) + for (AuraList::const_iterator i = mHealingDone.begin(); i != mHealingDone.end(); ++i) + if (!(*i)->GetModifier()->m_miscvalue || ((*i)->GetModifier()->m_miscvalue & schoolMask) != 0) AdvertisedBenefit += (*i)->GetModifier()->m_amount; // Healing bonus of spirit, intellect and strength @@ -7199,7 +7199,7 @@ int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) // Healing bonus from stats AuraList const& mHealingDoneOfStatPercent = GetAurasByType(SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT); - for(AuraList::const_iterator i = mHealingDoneOfStatPercent.begin();i != mHealingDoneOfStatPercent.end(); ++i) + for (AuraList::const_iterator i = mHealingDoneOfStatPercent.begin(); i != mHealingDoneOfStatPercent.end(); ++i) { // stat used dependent from misc value (stat index) Stats usedStat = Stats((*i)->GetSpellProto()->EffectMiscValue[(*i)->GetEffIndex()]); @@ -7208,7 +7208,7 @@ int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) // ... and attack power AuraList const& mHealingDonebyAP = GetAurasByType(SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER); - for(AuraList::const_iterator i = mHealingDonebyAP.begin();i != mHealingDonebyAP.end(); ++i) + for (AuraList::const_iterator i = mHealingDonebyAP.begin(); i != mHealingDonebyAP.end(); ++i) if ((*i)->GetModifier()->m_miscvalue & schoolMask) AdvertisedBenefit += int32(GetTotalAttackPowerValue(BASE_ATTACK) * (*i)->GetModifier()->m_amount / 100.0f); } @@ -7219,7 +7219,7 @@ int32 Unit::SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) { int32 AdvertisedBenefit = 0; AuraList const& mDamageTaken = GetAurasByType(SPELL_AURA_MOD_HEALING); - for(AuraList::const_iterator i = mDamageTaken.begin();i != mDamageTaken.end(); ++i) + for (AuraList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i) if ((*i)->GetModifier()->m_miscvalue & schoolMask) AdvertisedBenefit += (*i)->GetModifier()->m_amount; @@ -7252,29 +7252,29 @@ bool Unit::IsImmuneToSpell(SpellEntry const* spellInfo) //SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_EFFECT]; SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_DISPEL]; - for(SpellImmuneList::const_iterator itr = dispelList.begin(); itr != dispelList.end(); ++itr) + for (SpellImmuneList::const_iterator itr = dispelList.begin(); itr != dispelList.end(); ++itr) if (itr->type == spellInfo->Dispel) return true; if (!spellInfo->HasAttribute(SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE) && // unaffected by school immunity - !spellInfo->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)) // can remove immune (by dispell or immune it) + !spellInfo->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)) // can remove immune (by dispell or immune it) { SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; - for(SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr) + for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr) if (!(IsPositiveSpell(itr->spellId) && IsPositiveSpell(spellInfo->Id)) && - (itr->type & GetSpellSchoolMask(spellInfo))) + (itr->type & GetSpellSchoolMask(spellInfo))) return true; } - if(uint32 mechanic = spellInfo->Mechanic) + if (uint32 mechanic = spellInfo->Mechanic) { SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC]; - for(SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) + for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) if (itr->type == mechanic) return true; AuraList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MECHANIC_IMMUNITY_MASK); - for(AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) + for (AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) if ((*iter)->GetModifier()->m_miscvalue & (1 << (mechanic-1))) return true; } @@ -7299,7 +7299,7 @@ bool Unit::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex i return true; AuraList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MECHANIC_IMMUNITY_MASK); - for(AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) + for (AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) if ((*iter)->GetModifier()->m_miscvalue & (1 << (mechanic-1))) return true; } @@ -7307,19 +7307,19 @@ bool Unit::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex i if (uint32 aura = spellInfo->EffectApplyAuraName[index]) { SpellImmuneList const& list = m_spellImmune[IMMUNITY_STATE]; - for(SpellImmuneList::const_iterator itr = list.begin(); itr != list.end(); ++itr) + for (SpellImmuneList::const_iterator itr = list.begin(); itr != list.end(); ++itr) if (itr->type == aura) return true; // Check for immune to application of harmful magical effects AuraList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL); if (!immuneAuraApply.empty() && - spellInfo->Dispel == DISPEL_MAGIC && // Magic debuff) - !IsPositiveEffect(spellInfo, index)) // Harmful + spellInfo->Dispel == DISPEL_MAGIC && // Magic debuff) + !IsPositiveEffect(spellInfo, index)) // Harmful { // Check school SpellSchoolMask schoolMask = GetSpellSchoolMask(spellInfo); - for(AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) + for (AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) if ((*iter)->GetModifier()->m_miscvalue & schoolMask) return true; } @@ -7332,7 +7332,7 @@ bool Unit::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex i * Calculates caster part of melee damage bonuses, * also includes different bonuses dependent from target auras */ -uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType attType, SpellEntry const *spellProto, DamageEffectType damagetype, uint32 stack) +uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage,WeaponAttackType attType, SpellEntry const* spellProto, DamageEffectType damagetype, uint32 stack) { if (!pVictim || pdamage == 0 || (spellProto && spellProto->HasAttribute(SPELL_ATTR_EX6_NO_DMG_MODS))) return pdamage; @@ -7352,12 +7352,12 @@ uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType if (!isWeaponDamageBasedSpell) { AuraList const& mModDamageDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE); - for(AuraList::const_iterator i = mModDamageDone.begin(); i != mModDamageDone.end(); ++i) + for (AuraList::const_iterator i = mModDamageDone.begin(); i != mModDamageDone.end(); ++i) { if ((*i)->GetModifier()->m_miscvalue & schoolMask && // schoolmask has to fit with the intrinsic spell school - (*i)->GetModifier()->m_miscvalue & GetMeleeDamageSchoolMask() && // AND schoolmask has to fit with weapon damage school (essential for non-physical spells) - (((*i)->GetSpellProto()->EquippedItemClass == -1) || // general, weapon independent - (pWeapon && pWeapon->IsFitToSpellRequirements((*i)->GetSpellProto())))) // OR used weapon fits aura requirements + (*i)->GetModifier()->m_miscvalue & GetMeleeDamageSchoolMask() && // AND schoolmask has to fit with weapon damage school (essential for non-physical spells) + (((*i)->GetSpellProto()->EquippedItemClass == -1) || // general, weapon independent + (pWeapon && pWeapon->IsFitToSpellRequirements((*i)->GetSpellProto())))) // OR used weapon fits aura requirements { DoneFlat += (*i)->GetModifier()->m_amount; } @@ -7388,15 +7388,15 @@ uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType float DonePercent = 1.0f; // ..done pct, already included in weapon damage based spells - if(!isWeaponDamageBasedSpell) + if (!isWeaponDamageBasedSpell) { AuraList const& mModDamagePercentDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); - for(AuraList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i) + for (AuraList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i) { if ((*i)->GetModifier()->m_miscvalue & schoolMask && // schoolmask has to fit with the intrinsic spell school - (*i)->GetModifier()->m_miscvalue & GetMeleeDamageSchoolMask() && // AND schoolmask has to fit with weapon damage school (essential for non-physical spells) - (((*i)->GetSpellProto()->EquippedItemClass == -1) || // general, weapon independent - (pWeapon && pWeapon->IsFitToSpellRequirements((*i)->GetSpellProto())))) // OR used weapon fits aura requirements + (*i)->GetModifier()->m_miscvalue & GetMeleeDamageSchoolMask() && // AND schoolmask has to fit with weapon damage school (essential for non-physical spells) + (((*i)->GetSpellProto()->EquippedItemClass == -1) || // general, weapon independent + (pWeapon && pWeapon->IsFitToSpellRequirements((*i)->GetSpellProto())))) // OR used weapon fits aura requirements { DonePercent *= ((*i)->GetModifier()->m_amount+100.0f) / 100.0f; } @@ -7411,29 +7411,29 @@ uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType // special dummys/class scripts and other effects // ============================================= - Unit *owner = GetOwner(); + Unit* owner = GetOwner(); if (!owner) owner = this; // ..done (class scripts) - if(spellProto) + if (spellProto) { AuraList const& mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) + for (AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { if (!(*i)->isAffectedOnSpell(spellProto)) continue; - switch((*i)->GetModifier()->m_miscvalue) + switch ((*i)->GetModifier()->m_miscvalue) { - // Tundra Stalker - // Merciless Combat + // Tundra Stalker + // Merciless Combat case 7277: { // Merciless Combat if ((*i)->GetSpellProto()->SpellIconID == 2656) { - if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) + if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) DonePercent *= (100.0f+(*i)->GetModifier()->m_amount)/100.0f; } else // Tundra Stalker @@ -7468,14 +7468,14 @@ uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType // .. done (class scripts) AuraList const& mclassScritAuras = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(AuraList::const_iterator i = mclassScritAuras.begin(); i != mclassScritAuras.end(); ++i) + for (AuraList::const_iterator i = mclassScritAuras.begin(); i != mclassScritAuras.end(); ++i) { - switch((*i)->GetMiscValue()) + switch ((*i)->GetMiscValue()) { - // Dirty Deeds + // Dirty Deeds case 6427: case 6428: - if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) + if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) { Aura* eff0 = GetAura((*i)->GetId(), EFFECT_INDEX_0); if (!eff0 || (*i)->GetEffIndex() != EFFECT_INDEX_1) @@ -7499,20 +7499,20 @@ uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType // search disease bool found = false; Unit::SpellAuraHolderMap const& auras = pVictim->GetSpellAuraHolderMap(); - for(Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) { - if(itr->second->GetSpellProto()->Dispel == DISPEL_DISEASE) + if (itr->second->GetSpellProto()->Dispel == DISPEL_DISEASE) { found = true; break; } } - if(found) + if (found) { // search for Glacier Rot dummy aura Unit::AuraList const& dummyAuras = GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator i = dummyAuras.begin(); i != dummyAuras.end(); ++i) + for (Unit::AuraList::const_iterator i = dummyAuras.begin(); i != dummyAuras.end(); ++i) { if ((*i)->GetSpellProto()->EffectMiscValue[(*i)->GetEffIndex()] == 7244) { @@ -7526,12 +7526,12 @@ uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType else if (spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && spellProto->SpellFamilyFlags & UI64LIT(0x0000000100000000)) { // search for glyph dummy aura - if (Aura *aur = GetDummyAura(56826)) + if (Aura* aur = GetDummyAura(56826)) // check for Serpent Sting at target if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_HUNTER, UI64LIT(0x0000000000004000))) DonePercent *= (aur->GetModifier()->m_amount+100.0f) / 100.0f; } - } + } // final calculation // ================= @@ -7545,7 +7545,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType DoneTotal = SpellBonusWithCoeffs(spellProto, DoneTotal, DoneFlat, APbonus, damagetype, true); } // weapon damage based spells - else if( APbonus || DoneFlat ) + else if (APbonus || DoneFlat) { bool normalized = spellProto ? IsSpellHaveEffect(spellProto, SPELL_EFFECT_NORMALIZED_WEAPON_DMG) : false; DoneTotal += int32(APbonus / 14.0f * GetAPMultiplier(attType,normalized)); @@ -7554,7 +7554,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType // (that are already included into pdamage) to not-yet included DoneFlat // e.g. from doneVersusCreature, apBonusVs... UnitMods unitMod; - switch(attType) + switch (attType) { default: case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break; @@ -7570,9 +7570,9 @@ uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType float tmpDamage = float(int32(pdamage) + DoneTotal * int32(stack)) * DonePercent; // apply spellmod to Done damage - if(spellProto) + if (spellProto) { - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage); } @@ -7584,7 +7584,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit *pVictim, uint32 pdamage,WeaponAttackType * Calculates target part of melee damage bonuses, * will be called on each tick for periodic damage over time auras */ -uint32 Unit::MeleeDamageBonusTaken(Unit *pCaster, uint32 pdamage,WeaponAttackType attType, SpellEntry const *spellProto, DamageEffectType damagetype, uint32 stack) +uint32 Unit::MeleeDamageBonusTaken(Unit* pCaster, uint32 pdamage,WeaponAttackType attType, SpellEntry const* spellProto, DamageEffectType damagetype, uint32 stack) { if (!pCaster) return pdamage; @@ -7625,13 +7625,13 @@ uint32 Unit::MeleeDamageBonusTaken(Unit *pCaster, uint32 pdamage,WeaponAttackTyp TakenPercent *= GetTotalAuraMultiplierByMiscValueForMask(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT,mechanicMask); // ..taken pct (melee/ranged) - if(attType == RANGED_ATTACK) + if (attType == RANGED_ATTACK) TakenPercent *= GetTotalAuraMultiplier(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT); else TakenPercent *= GetTotalAuraMultiplier(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT); // ..taken pct (aoe avoidance) - if(spellProto && IsAreaOfEffectSpell(spellProto)) + if (spellProto && IsAreaOfEffectSpell(spellProto)) { TakenPercent *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, schoolMask); if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsPet()) @@ -7643,14 +7643,14 @@ uint32 Unit::MeleeDamageBonusTaken(Unit *pCaster, uint32 pdamage,WeaponAttackTyp // .. taken (dummy auras) AuraList const& mDummyAuras = GetAurasByType(SPELL_AURA_DUMMY); - for(AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) + for (AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) { - switch((*i)->GetId()) + switch ((*i)->GetId()) { case 45182: // Cheating Death - if((*i)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) + if ((*i)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) { - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) continue; float mod = ((Player*)this)->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*(-8.0f); @@ -7690,7 +7690,7 @@ void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply) for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(), next; itr != m_spellImmune[op].end(); itr = next) { next = itr; ++next; - if(itr->type == type) + if (itr->type == type) { m_spellImmune[op].erase(itr); next = m_spellImmune[op].begin(); @@ -7705,7 +7705,7 @@ void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply) { for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(); itr != m_spellImmune[op].end(); ++itr) { - if(itr->spellId == spellId) + if (itr->spellId == spellId) { m_spellImmune[op].erase(itr); break; @@ -7714,7 +7714,7 @@ void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply) } } -void Unit::ApplySpellDispelImmunity(const SpellEntry * spellProto, DispelType type, bool apply) +void Unit::ApplySpellDispelImmunity(const SpellEntry* spellProto, DispelType type, bool apply) { ApplySpellImmune(spellProto->Id,IMMUNITY_DISPEL, type, apply); @@ -7751,7 +7751,7 @@ void Unit::Mount(uint32 mount, uint32 spellId) SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mount); - SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT ); + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT); if (GetTypeId() == TYPEID_PLAYER) { @@ -7768,7 +7768,7 @@ void Unit::Mount(uint32 mount, uint32 spellId) else if (Pet* pet = GetPet()) { if (pet->IsPermanentPetFor((Player*)this) && !((Player*)this)->InArena() && - sWorld.getConfig(CONFIG_BOOL_PET_UNSUMMON_AT_MOUNT)) + sWorld.getConfig(CONFIG_BOOL_PET_UNSUMMON_AT_MOUNT)) { ((Player*)this)->UnsummonPetTemporaryIfAny(); } @@ -7800,9 +7800,9 @@ void Unit::Unmount(bool from_aura) // only resummon old pet if the player is already added to a map // this prevents adding a pet to a not created map which would otherwise cause a crash // (it could probably happen when logging in after a previous crash) - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { - if(Pet* pet = GetPet()) + if (Pet* pet = GetPet()) pet->ApplyModeFlags(PET_MODE_DISABLE_ACTIONS,false); else ((Player*)this)->ResummonPetTemporaryUnSummonedIfAny(); @@ -7887,7 +7887,7 @@ void Unit::ClearInCombat() m_CombatTimer = 0; RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - if(isCharmed() || (GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->IsPet())) + if (isCharmed() || (GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->IsPet())) RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); // Player's state will be cleared in Player::UpdateContestedPvP @@ -7904,7 +7904,7 @@ void Unit::ClearInCombat() bool Unit::isTargetableForAttack(bool inverseAlive /*=false*/) const { - if (GetTypeId()==TYPEID_PLAYER && ((Player *)this)->isGameMaster()) + if (GetTypeId()==TYPEID_PLAYER && ((Player*)this)->isGameMaster()) return false; if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)) @@ -7925,13 +7925,13 @@ int32 Unit::ModifyHealth(int32 dVal) { int32 gain = 0; - if(dVal==0) + if (dVal==0) return 0; int32 curHealth = (int32)GetHealth(); int32 val = dVal + curHealth; - if(val <= 0) + if (val <= 0) { SetHealth(0); return -curHealth; @@ -7939,12 +7939,12 @@ int32 Unit::ModifyHealth(int32 dVal) int32 maxHealth = (int32)GetMaxHealth(); - if(val < maxHealth) + if (val < maxHealth) { SetHealth(val); gain = val - curHealth; } - else if(curHealth != maxHealth) + else if (curHealth != maxHealth) { SetHealth(maxHealth); gain = maxHealth - curHealth; @@ -7957,13 +7957,13 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) { int32 gain = 0; - if(dVal==0) + if (dVal==0) return 0; int32 curPower = (int32)GetPower(power); int32 val = dVal + curPower; - if(val <= 0) + if (val <= 0) { SetPower(power,0); return -curPower; @@ -7971,12 +7971,12 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) int32 maxPower = (int32)GetMaxPower(power); - if(val < maxPower) + if (val < maxPower) { SetPower(power,val); gain = val - curPower; } - else if(curPower != maxPower) + else if (curPower != maxPower) { SetPower(power,maxPower); gain = maxPower - curPower; @@ -7987,7 +7987,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, bool detect, bool inVisibleList, bool is3dDistance) const { - if(!u || !IsInMap(u)) + if (!u || !IsInMap(u)) return false; // Always can see self @@ -8003,11 +8003,11 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo ((Player*)this)->GetTransport() && ((Player*)this)->GetTransport() == ((Player*)u)->GetTransport(); // not in world - if(!at_same_transport && (!IsInWorld() || !u->IsInWorld())) + if (!at_same_transport && (!IsInWorld() || !u->IsInWorld())) return false; // forbidden to seen (at GM respawn command) - if(m_Visibility==VISIBILITY_RESPAWN) + if (m_Visibility==VISIBILITY_RESPAWN) return false; Map& _map = *u->GetMap(); @@ -8015,17 +8015,17 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo if (u->GetTypeId()==TYPEID_PLAYER) { // non visible at grid for any stealth state - if(!IsVisibleInGridForPlayer((Player *)u)) + if (!IsVisibleInGridForPlayer((Player*)u)) return false; // if player is dead then he can't detect anyone in any cases - if(!u->isAlive()) + if (!u->isAlive()) detect = false; } else { // all dead creatures/players not visible for any creatures - if(!u->isAlive() || !isAlive()) + if (!u->isAlive() || !isAlive()) return false; } @@ -8036,7 +8036,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo if (!IsWithinDistInMap(viewPoint,World::GetMaxVisibleDistanceInFlight()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), is3dDistance)) return false; } - else if(!at_same_transport) // distance for show player/pet/creature (no transport case) + else if (!at_same_transport) // distance for show player/pet/creature (no transport case) { // Any units far than max visible distance for viewer or not in our map are not visible too if (!IsWithinDistInMap(viewPoint, _map.GetVisibilityDistance() + (inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance)) @@ -8051,7 +8051,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo // unit is also invisible for alive.. if an isinvisibleforalive unit dies we // should be able to see it too if (u->isAlive() && isAlive() && isInvisibleForAlive() != u->isInvisibleForAlive()) - if (u->GetTypeId() != TYPEID_PLAYER || !((Player *)u)->isGameMaster()) + if (u->GetTypeId() != TYPEID_PLAYER || !((Player*)u)->isGameMaster()) return false; // Visible units, always are visible for all units, except for units under invisibility and phases @@ -8059,10 +8059,10 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo return true; // GMs see any players, not higher GMs and all units in any phase - if (u->GetTypeId() == TYPEID_PLAYER && ((Player *)u)->isGameMaster()) + if (u->GetTypeId() == TYPEID_PLAYER && ((Player*)u)->isGameMaster()) { - if(GetTypeId() == TYPEID_PLAYER) - return ((Player *)this)->GetSession()->GetSecurity() <= ((Player *)u)->GetSession()->GetSecurity(); + if (GetTypeId() == TYPEID_PLAYER) + return ((Player*)this)->GetSession()->GetSecurity() <= ((Player*)u)->GetSession()->GetSecurity(); else return true; } @@ -8075,27 +8075,27 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo bool invisible = (m_invisibilityMask != 0 || u->m_invisibilityMask !=0); // detectable invisibility case - if( invisible && ( - // Invisible units, always are visible for units under same invisibility type - (m_invisibilityMask & u->m_invisibilityMask)!=0 || - // Invisible units, always are visible for unit that can detect this invisibility (have appropriate level for detect) - u->canDetectInvisibilityOf(this) || - // Units that can detect invisibility always are visible for units that can be detected - canDetectInvisibilityOf(u) )) + if (invisible && ( + // Invisible units, always are visible for units under same invisibility type + (m_invisibilityMask & u->m_invisibilityMask)!=0 || + // Invisible units, always are visible for unit that can detect this invisibility (have appropriate level for detect) + u->canDetectInvisibilityOf(this) || + // Units that can detect invisibility always are visible for units that can be detected + canDetectInvisibilityOf(u))) { invisible = false; } // special cases for always overwrite invisibility/stealth - if(invisible || m_Visibility == VISIBILITY_GROUP_STEALTH) + if (invisible || m_Visibility == VISIBILITY_GROUP_STEALTH) { // non-hostile case if (!u->IsHostileTo(this)) { // player see other player with stealth/invisibility only if he in same group or raid or same team (raid/team case dependent from conf setting) - if(GetTypeId()==TYPEID_PLAYER && u->GetTypeId()==TYPEID_PLAYER) + if (GetTypeId()==TYPEID_PLAYER && u->GetTypeId()==TYPEID_PLAYER) { - if(((Player*)this)->IsGroupVisibleFor(((Player*)u))) + if (((Player*)this)->IsGroupVisibleFor(((Player*)u))) return true; // else apply same rules as for hostile case (detecting check for stealth) @@ -8106,7 +8106,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo { // Hunter mark functionality AuraList const& auras = GetAurasByType(SPELL_AURA_MOD_STALKED); - for(AuraList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter) + for (AuraList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter) if ((*iter)->GetCasterGuid() == u->GetObjectGuid()) return true; @@ -8114,7 +8114,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo } // none other cases for detect invisibility, so invisible - if(invisible) + if (invisible) return false; // else apply stealth detecting check @@ -8139,7 +8139,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo // Special cases // If is attacked then stealth is lost, some creature can use stealth too - if( !getAttackers().empty() ) + if (!getAttackers().empty()) return true; // If there is collision rogue is seen regardless of level difference @@ -8155,11 +8155,11 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo //Always invisible from back (when stealth detection is on), also filter max distance cases bool isInFront = viewPoint->isInFrontInMap(this, visibleDistance); - if(!isInFront) + if (!isInFront) return false; // if doesn't have stealth detection (Shadow Sight), then check how stealthy the unit is, otherwise just check los - if(!u->HasAuraType(SPELL_AURA_DETECT_STEALTH)) + if (!u->HasAuraType(SPELL_AURA_DETECT_STEALTH)) { //Calculation if target is in front @@ -8172,7 +8172,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo //This allows to check talent tree and will add addition stealth dependent on used points) int32 stealthMod = GetTotalAuraModifier(SPELL_AURA_MOD_STEALTH_LEVEL); - if(stealthMod < 0) + if (stealthMod < 0) stealthMod = 0; //-Stealth Mod(positive like Master of Deception) and Stealth Detection(negative like paranoia) @@ -8181,7 +8181,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo visibleDistance = visibleDistance > MAX_PLAYER_STEALTH_DETECT_RANGE ? MAX_PLAYER_STEALTH_DETECT_RANGE : visibleDistance; // recheck new distance - if(visibleDistance <= 0 || !IsWithinDist(viewPoint,visibleDistance)) + if (visibleDistance <= 0 || !IsWithinDist(viewPoint,visibleDistance)) return false; } @@ -8198,7 +8198,7 @@ void Unit::UpdateVisibilityAndView() for (AuraType const* type = &auratypes[0]; *type != SPELL_AURA_NONE; ++type) { AuraList& alist = m_modAuras[*type]; - if(alist.empty()) + if (alist.empty()) continue; for (AuraList::iterator it = alist.begin(); it != alist.end();) @@ -8227,7 +8227,7 @@ void Unit::SetVisibility(UnitVisibility x) { m_Visibility = x; - if(IsInWorld()) + if (IsInWorld()) UpdateVisibilityAndView(); } @@ -8235,7 +8235,7 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const { if (uint32 mask = (m_detectInvisibilityMask & u->m_invisibilityMask)) { - for(int32 i = 0; i < 32; ++i) + for (int32 i = 0; i < 32; ++i) { if (((1 << i) & mask)==0) continue; @@ -8243,14 +8243,14 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const // find invisibility level int32 invLevel = 0; Unit::AuraList const& iAuras = u->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY); - for(Unit::AuraList::const_iterator itr = iAuras.begin(); itr != iAuras.end(); ++itr) + for (Unit::AuraList::const_iterator itr = iAuras.begin(); itr != iAuras.end(); ++itr) if ((*itr)->GetModifier()->m_miscvalue==i && invLevel < (*itr)->GetModifier()->m_amount) invLevel = (*itr)->GetModifier()->m_amount; // find invisibility detect level int32 detectLevel = 0; Unit::AuraList const& dAuras = GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION); - for(Unit::AuraList::const_iterator itr = dAuras.begin(); itr != dAuras.end(); ++itr) + for (Unit::AuraList::const_iterator itr = dAuras.begin(); itr != dAuras.end(); ++itr) if ((*itr)->GetModifier()->m_miscvalue==i && detectLevel < (*itr)->GetModifier()->m_amount) detectLevel = (*itr)->GetModifier()->m_amount; @@ -8268,14 +8268,14 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) { // not in combat pet have same speed as owner - switch(mtype) + switch (mtype) { case MOVE_RUN: case MOVE_WALK: case MOVE_SWIM: if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsPet() && hasUnitState(UNIT_STAT_FOLLOW)) { - if(Unit* owner = GetOwner()) + if (Unit* owner = GetOwner()) { SetSpeedRate(mtype, owner->GetSpeedRate(mtype), forced); return; @@ -8290,7 +8290,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) float stack_bonus = 1.0f; float non_stack_bonus = 1.0f; - switch(mtype) + switch (mtype) { case MOVE_WALK: break; @@ -8346,7 +8346,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) // now we ready for speed calculation float speed = main_speed_mod ? bonus*(100.0f + main_speed_mod)/100.0f : bonus; - switch(mtype) + switch (mtype) { case MOVE_RUN: case MOVE_SWIM: @@ -8354,7 +8354,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) { // Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need // TODO: possible affect only on MOVE_RUN - if(int32 normalization = GetMaxPositiveAuraModifier(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED)) + if (int32 normalization = GetMaxPositiveAuraModifier(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED)) { // Use speed from aura float max_speed = normalization / baseMoveSpeed[mtype]; @@ -8392,7 +8392,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) if (GetTypeId() == TYPEID_UNIT) { - switch(mtype) + switch (mtype) { case MOVE_RUN: speed *= ((Creature*)this)->GetCreatureInfo()->speed_run; @@ -8408,7 +8408,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) SetSpeedRate(mtype, speed * ratio, forced); } -float Unit::GetSpeed( UnitMoveType mtype ) const +float Unit::GetSpeed(UnitMoveType mtype) const { return m_speed_rate[mtype]*baseMoveSpeed[mtype]; } @@ -8485,7 +8485,7 @@ void Unit::SetDeathState(DeathState s) DeleteThreatList(); ClearComboPointHolders(); // any combo points pointed to unit lost at it death - if(IsNonMeleeSpellCasted(false)) + if (IsNonMeleeSpellCasted(false)) InterruptNonMeleeSpells(false); } @@ -8506,9 +8506,9 @@ void Unit::SetDeathState(DeathState s) ClearAllReactives(); ClearDiminishings(); } - else if(s == JUST_ALIVED) + else if (s == JUST_ALIVED) { - RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); // clear skinnable for creature and player (at battleground) + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); // clear skinnable for creature and player (at battleground) } if (m_deathState != ALIVE && s == ALIVE) @@ -8568,7 +8568,7 @@ float Unit::ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask) //====================================================================== -void Unit::AddThreat(Unit* pVictim, float threat /*= 0.0f*/, bool crit /*= false*/, SpellSchoolMask schoolMask /*= SPELL_SCHOOL_MASK_NONE*/, SpellEntry const *threatSpell /*= NULL*/) +void Unit::AddThreat(Unit* pVictim, float threat /*= 0.0f*/, bool crit /*= false*/, SpellSchoolMask schoolMask /*= SPELL_SCHOOL_MASK_NONE*/, SpellEntry const* threatSpell /*= NULL*/) { // Only mobs can manage threat lists if (CanHaveThreatList()) @@ -8597,7 +8597,7 @@ void Unit::TauntApply(Unit* taunter) if (!CanHaveThreatList()) return; - Unit *target = getVictim(); + Unit* target = getVictim(); if (target && target == taunter) return; @@ -8616,7 +8616,7 @@ void Unit::TauntApply(Unit* taunter) //====================================================================== -void Unit::TauntFadeOut(Unit *taunter) +void Unit::TauntFadeOut(Unit* taunter) { MANGOS_ASSERT(GetTypeId() == TYPEID_UNIT); @@ -8626,7 +8626,7 @@ void Unit::TauntFadeOut(Unit *taunter) if (!CanHaveThreatList()) return; - Unit *target = getVictim(); + Unit* target = getVictim(); if (!target || target != taunter) return; @@ -8700,8 +8700,8 @@ bool Unit::SelectHostileTarget() for (AuraList::const_reverse_iterator aura = tauntAuras.rbegin(); aura != tauntAuras.rend(); ++aura) { if ((caster = (*aura)->GetCaster()) && caster->IsInMap(this) && - caster->isTargetableForAttack() && caster->isInAccessablePlaceFor((Creature*)this) && - !IsSecondChoiceTarget(caster, true)) + caster->isTargetableForAttack() && caster->isInAccessablePlaceFor((Creature*)this) && + !IsSecondChoiceTarget(caster, true)) { target = caster; break; @@ -8723,12 +8723,12 @@ bool Unit::SelectHostileTarget() // check if currently selected target is reachable // NOTE: path alrteady generated from AttackStart() - if(!GetMotionMaster()->operator->()->IsReachable()) + if (!GetMotionMaster()->operator->()->IsReachable()) { // remove all taunts RemoveSpellsCausingAura(SPELL_AURA_MOD_TAUNT); - if(m_ThreatManager.getThreatList().size() < 2) + if (m_ThreatManager.getThreatList().size() < 2) { // only one target in list, we have to evade after timer // TODO: make timer - inside Creature class @@ -8760,7 +8760,7 @@ bool Unit::SelectHostileTarget() // Note: creature not have targeted movement generator but have attacker in this case if (GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE) { - for(AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr) + for (AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr) { if ((*itr)->IsInMap(this) && (*itr)->isTargetableForAttack() && (*itr)->isInAccessablePlaceFor((Creature*)this)) return false; @@ -8802,7 +8802,7 @@ int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProt int32 randomPoints = int32(spellProto->EffectDieSides[effect_index]); float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index]; - switch(randomPoints) + switch (randomPoints) { case 0: // not used case 1: basePoints += 1; break; // range 1..1 @@ -8810,8 +8810,8 @@ int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProt { // range can have positive (1..rand) and negative (rand..1) values, so order its for irand int32 randvalue = (randomPoints >= 1) - ? irand(1, randomPoints) - : irand(randomPoints, 1); + ? irand(1, randomPoints) + : irand(randomPoints, 1); basePoints += randvalue; break; @@ -8828,7 +8828,7 @@ int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProt { modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_ALL_EFFECTS, value); - switch(effect_index) + switch (effect_index) { case EFFECT_INDEX_0: modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT1, value); @@ -8859,7 +8859,7 @@ int32 Unit::CalculateAuraDuration(SpellEntry const* spellProto, uint32 effectMas int32 mechanicMod = 0; uint32 mechanicMask = GetSpellMechanicMask(spellProto, effectMask); - for(int32 mechanic = FIRST_MECHANIC; mechanic < MAX_MECHANIC; ++mechanic) + for (int32 mechanic = FIRST_MECHANIC; mechanic < MAX_MECHANIC; ++mechanic) { if (!(mechanicMask & (1 << (mechanic-1)))) continue; @@ -8891,14 +8891,14 @@ int32 Unit::CalculateAuraDuration(SpellEntry const* spellProto, uint32 effectMas if (caster == this) { - switch(spellProto->SpellFamilyName) + switch (spellProto->SpellFamilyName) { case SPELLFAMILY_DRUID: // Thorns if (spellProto->SpellIconID == 53 && (spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000100))) { // Glyph of Thorns - if (Aura *aur = GetAura(57862, EFFECT_INDEX_0)) + if (Aura* aur = GetAura(57862, EFFECT_INDEX_0)) duration += aur->GetModifier()->m_amount * MINUTE * IN_MILLISECONDS; } break; @@ -8907,14 +8907,14 @@ int32 Unit::CalculateAuraDuration(SpellEntry const* spellProto, uint32 effectMas if (spellProto->SpellIconID == 298 && spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000002)) { // Glyph of Blessing of Might - if (Aura *aur = GetAura(57958, EFFECT_INDEX_0)) + if (Aura* aur = GetAura(57958, EFFECT_INDEX_0)) duration += aur->GetModifier()->m_amount * MINUTE * IN_MILLISECONDS; } // Blessing of Wisdom else if (spellProto->SpellIconID == 306 && spellProto->SpellFamilyFlags & UI64LIT(0x0000000000010000)) { // Glyph of Blessing of Wisdom - if (Aura *aur = GetAura(57979, EFFECT_INDEX_0)) + if (Aura* aur = GetAura(57979, EFFECT_INDEX_0)) duration += aur->GetModifier()->m_amount * MINUTE * IN_MILLISECONDS; } break; @@ -8928,12 +8928,12 @@ int32 Unit::CalculateAuraDuration(SpellEntry const* spellProto, uint32 effectMas DiminishingLevels Unit::GetDiminishing(DiminishingGroup group) { - for(Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) + for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) { - if(i->DRGroup != group) + if (i->DRGroup != group) continue; - if(!i->hitCount) + if (!i->hitCount) return DIMINISHING_LEVEL_1; if (!i->hitTime) @@ -8957,24 +8957,24 @@ DiminishingLevels Unit::GetDiminishing(DiminishingGroup group) void Unit::IncrDiminishing(DiminishingGroup group) { // Checking for existing in the table - for(Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) + for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) { - if(i->DRGroup != group) + if (i->DRGroup != group) continue; - if(i->hitCount < DIMINISHING_LEVEL_IMMUNE) + if (i->hitCount < DIMINISHING_LEVEL_IMMUNE) i->hitCount += 1; return; } m_Diminishing.push_back(DiminishingReturn(group,WorldTimer::getMSTime(),DIMINISHING_LEVEL_2)); } -void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster,DiminishingLevels Level, int32 limitduration, bool isReflected) +void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32& duration,Unit* caster,DiminishingLevels Level, int32 limitduration, bool isReflected) { - if(duration == -1 || group == DIMINISHING_NONE || (!isReflected && caster->IsFriendlyTo(this)) ) + if (duration == -1 || group == DIMINISHING_NONE || (!isReflected && caster->IsFriendlyTo(this))) return; // Duration of crowd control abilities on pvp target is limited by 10 sec. (2.2.0) - if(limitduration > 0 && duration > limitduration) + if (limitduration > 0 && duration > limitduration) { // test pet/charm masters instead pets/charmeds Unit const* targetOwner = GetCharmerOrOwner(); @@ -8983,22 +8983,22 @@ void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Un Unit const* target = targetOwner ? targetOwner : this; Unit const* source = casterOwner ? casterOwner : caster; - if(target->GetTypeId() == TYPEID_PLAYER && source->GetTypeId() == TYPEID_PLAYER) + if (target->GetTypeId() == TYPEID_PLAYER && source->GetTypeId() == TYPEID_PLAYER) duration = limitduration; } float mod = 1.0f; // Some diminishings applies to mobs too (for example, Stun) - if((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && GetTypeId() == TYPEID_PLAYER) || GetDiminishingReturnsGroupType(group) == DRTYPE_ALL) + if ((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && GetTypeId() == TYPEID_PLAYER) || GetDiminishingReturnsGroupType(group) == DRTYPE_ALL) { DiminishingLevels diminish = Level; - switch(diminish) + switch (diminish) { case DIMINISHING_LEVEL_1: break; case DIMINISHING_LEVEL_2: mod = 0.5f; break; case DIMINISHING_LEVEL_3: mod = 0.25f; break; - case DIMINISHING_LEVEL_IMMUNE: mod = 0.0f;break; + case DIMINISHING_LEVEL_IMMUNE: mod = 0.0f; break; default: break; } } @@ -9006,17 +9006,17 @@ void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Un duration = int32(duration * mod); } -void Unit::ApplyDiminishingAura( DiminishingGroup group, bool apply ) +void Unit::ApplyDiminishingAura(DiminishingGroup group, bool apply) { // Checking for existing in the table - for(Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) + for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) { - if(i->DRGroup != group) + if (i->DRGroup != group) continue; - if(apply) + if (apply) i->stack += 1; - else if(i->stack) + else if (i->stack) { i->stack -= 1; // Remember time after last aura from group removed @@ -9027,7 +9027,7 @@ void Unit::ApplyDiminishingAura( DiminishingGroup group, bool apply ) } } -bool Unit::isVisibleForInState( Player const* u, WorldObject const* viewPoint, bool inVisibleList ) const +bool Unit::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const { return isVisibleForOrDetect(u, viewPoint, false, inVisibleList, false); } @@ -9043,10 +9043,10 @@ bool Unit::isInvisibleForAlive() const uint32 Unit::GetCreatureType() const { - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { SpellShapeshiftFormEntry const* ssEntry = sSpellShapeshiftFormStore.LookupEntry(GetShapeshiftForm()); - if(ssEntry && ssEntry->creatureType > 0) + if (ssEntry && ssEntry->creatureType > 0) return ssEntry->creatureType; else return CREATURE_TYPE_HUMANOID; @@ -9063,7 +9063,7 @@ uint32 Unit::GetCreatureType() const bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, float amount, bool apply) { - if(unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) + if (unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) { sLog.outError("ERROR in HandleStatModifier(): nonexistent UnitMods or wrong UnitModifierType!"); return false; @@ -9071,7 +9071,7 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f float val = 1.0f; - switch(modifierType) + switch (modifierType) { case BASE_VALUE: case TOTAL_VALUE: @@ -9079,7 +9079,7 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f break; case BASE_PCT: case TOTAL_PCT: - if(amount <= -100.0f) //small hack-fix for -100% modifiers + if (amount <= -100.0f) //small hack-fix for -100% modifiers amount = -200.0f; val = (100.0f + amount) / 100.0f; @@ -9090,10 +9090,10 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f break; } - if(!CanModifyStats()) + if (!CanModifyStats()) return false; - switch(unitMod) + switch (unitMod) { case UNIT_MOD_STAT_STRENGTH: case UNIT_MOD_STAT_AGILITY: @@ -9135,13 +9135,13 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f float Unit::GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) const { - if( unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) + if (unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) { sLog.outError("attempt to access nonexistent modifier value from UnitMods!"); return 0.0f; } - if(modifierType == TOTAL_PCT && m_auraModifiersGroup[unitMod][modifierType] <= 0.0f) + if (modifierType == TOTAL_PCT && m_auraModifiersGroup[unitMod][modifierType] <= 0.0f) return 0.0f; return m_auraModifiersGroup[unitMod][modifierType]; @@ -9151,7 +9151,7 @@ float Unit::GetTotalStatValue(Stats stat) const { UnitMods unitMod = UnitMods(UNIT_MOD_STAT_START + stat); - if(m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) + if (m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) return 0.0f; // value = ((base_value * base_pct) + total_value) * total_pct @@ -9165,13 +9165,13 @@ float Unit::GetTotalStatValue(Stats stat) const float Unit::GetTotalAuraModValue(UnitMods unitMod) const { - if(unitMod >= UNIT_MOD_END) + if (unitMod >= UNIT_MOD_END) { sLog.outError("attempt to access nonexistent UnitMods in GetTotalAuraModValue()!"); return 0.0f; } - if(m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) + if (m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) return 0.0f; float value = m_auraModifiersGroup[unitMod][BASE_VALUE]; @@ -9186,7 +9186,7 @@ SpellSchools Unit::GetSpellSchoolByAuraGroup(UnitMods unitMod) const { SpellSchools school = SPELL_SCHOOL_NORMAL; - switch(unitMod) + switch (unitMod) { case UNIT_MOD_RESISTANCE_HOLY: school = SPELL_SCHOOL_HOLY; break; case UNIT_MOD_RESISTANCE_FIRE: school = SPELL_SCHOOL_FIRE; break; @@ -9206,7 +9206,7 @@ Stats Unit::GetStatByAuraGroup(UnitMods unitMod) const { Stats stat = STAT_STRENGTH; - switch(unitMod) + switch (unitMod) { case UNIT_MOD_STAT_STRENGTH: stat = STAT_STRENGTH; break; case UNIT_MOD_STAT_AGILITY: stat = STAT_AGILITY; break; @@ -9223,7 +9223,7 @@ Stats Unit::GetStatByAuraGroup(UnitMods unitMod) const Powers Unit::GetPowerTypeByAuraGroup(UnitMods unitMod) const { - switch(unitMod) + switch (unitMod) { case UNIT_MOD_MANA: return POWER_MANA; case UNIT_MOD_RAGE: return POWER_RAGE; @@ -9274,24 +9274,24 @@ void Unit::SetLevel(uint32 lvl) void Unit::SetHealth(uint32 val) { uint32 maxHealth = GetMaxHealth(); - if(maxHealth < val) + if (maxHealth < val) val = maxHealth; SetUInt32Value(UNIT_FIELD_HEALTH, val); // group update - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { - if(((Player*)this)->GetGroup()) + if (((Player*)this)->GetGroup()) ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_HP); } - else if(((Creature*)this)->IsPet()) + else if (((Creature*)this)->IsPet()) { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) + Pet* pet = ((Pet*)this); + if (pet->isControlled()) { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + Unit* owner = GetOwner(); + if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_HP); } } @@ -9303,23 +9303,23 @@ void Unit::SetMaxHealth(uint32 val) SetUInt32Value(UNIT_FIELD_MAXHEALTH, val); // group update - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { - if(((Player*)this)->GetGroup()) + if (((Player*)this)->GetGroup()) ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_HP); } - else if(((Creature*)this)->IsPet()) + else if (((Creature*)this)->IsPet()) { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) + Pet* pet = ((Pet*)this); + if (pet->isControlled()) { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + Unit* owner = GetOwner(); + if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_HP); } } - if(val < health) + if (val < health) SetHealth(val); } @@ -9331,11 +9331,11 @@ void Unit::SetHealthPercent(float percent) void Unit::SetPower(Powers power, uint32 val) { - if(GetPower(power) == val) + if (GetPower(power) == val) return; uint32 maxPower = GetMaxPower(power); - if(maxPower < val) + if (maxPower < val) val = maxPower; SetStatInt32Value(UNIT_FIELD_POWER1 + power, val); @@ -9347,23 +9347,23 @@ void Unit::SetPower(Powers power, uint32 val) SendMessageToSet(&data, true); // group update - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { - if(((Player*)this)->GetGroup()) + if (((Player*)this)->GetGroup()) ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_POWER); } - else if(((Creature*)this)->IsPet()) + else if (((Creature*)this)->IsPet()) { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) + Pet* pet = ((Pet*)this); + if (pet->isControlled()) { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + Unit* owner = GetOwner(); + if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER); } // Update the pet's character sheet with happiness damage bonus - if(pet->getPetType() == HUNTER_PET && power == POWER_HAPPINESS) + if (pet->getPetType() == HUNTER_PET && power == POWER_HAPPINESS) { pet->UpdateDamagePhysical(BASE_ATTACK); } @@ -9376,23 +9376,23 @@ void Unit::SetMaxPower(Powers power, uint32 val) SetStatInt32Value(UNIT_FIELD_MAXPOWER1 + power, val); // group update - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { - if(((Player*)this)->GetGroup()) + if (((Player*)this)->GetGroup()) ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_POWER); } - else if(((Creature*)this)->IsPet()) + else if (((Creature*)this)->IsPet()) { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) + Pet* pet = ((Pet*)this); + if (pet->isControlled()) { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + Unit* owner = GetOwner(); + if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_POWER); } } - if(val < cur_power) + if (val < cur_power) SetPower(power, val); } @@ -9401,18 +9401,18 @@ void Unit::ApplyPowerMod(Powers power, uint32 val, bool apply) ApplyModUInt32Value(UNIT_FIELD_POWER1+power, val, apply); // group update - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { - if(((Player*)this)->GetGroup()) + if (((Player*)this)->GetGroup()) ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_POWER); } - else if(((Creature*)this)->IsPet()) + else if (((Creature*)this)->IsPet()) { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) + Pet* pet = ((Pet*)this); + if (pet->isControlled()) { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + Unit* owner = GetOwner(); + if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER); } } @@ -9423,35 +9423,35 @@ void Unit::ApplyMaxPowerMod(Powers power, uint32 val, bool apply) ApplyModUInt32Value(UNIT_FIELD_MAXPOWER1+power, val, apply); // group update - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { - if(((Player*)this)->GetGroup()) + if (((Player*)this)->GetGroup()) ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_POWER); } - else if(((Creature*)this)->IsPet()) + else if (((Creature*)this)->IsPet()) { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) + Pet* pet = ((Pet*)this); + if (pet->isControlled()) { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + Unit* owner = GetOwner(); + if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_POWER); } } } -void Unit::ApplyAuraProcTriggerDamage( Aura* aura, bool apply ) +void Unit::ApplyAuraProcTriggerDamage(Aura* aura, bool apply) { AuraList& tAuraProcTriggerDamage = m_modAuras[SPELL_AURA_PROC_TRIGGER_DAMAGE]; - if(apply) + if (apply) tAuraProcTriggerDamage.push_back(aura); else tAuraProcTriggerDamage.remove(aura); } -uint32 Unit::GetCreatePowers( Powers power ) const +uint32 Unit::GetCreatePowers(Powers power) const { - switch(power) + switch (power) { case POWER_HEALTH: return 0; // is it really should be here? case POWER_MANA: return GetCreateMana(); @@ -9493,7 +9493,7 @@ void Unit::RemoveFromWorld() void Unit::CleanupsBeforeDelete() { - if(m_uint32Values) // only for fully created object + if (m_uint32Values) // only for fully created object { InterruptNonMeleeSpells(true); m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList @@ -9509,39 +9509,39 @@ void Unit::CleanupsBeforeDelete() WorldObject::CleanupsBeforeDelete(); } -CharmInfo* Unit::InitCharmInfo(Unit *charm) +CharmInfo* Unit::InitCharmInfo(Unit* charm) { - if(!m_charmInfo) + if (!m_charmInfo) m_charmInfo = new CharmInfo(charm); return m_charmInfo; } CharmInfo::CharmInfo(Unit* unit) -: m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_reactState(REACT_PASSIVE), m_petnumber(0) + : m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_reactState(REACT_PASSIVE), m_petnumber(0) { - for(int i = 0; i < CREATURE_MAX_SPELLS; ++i) + for (int i = 0; i < CREATURE_MAX_SPELLS; ++i) m_charmspells[i].SetActionAndType(0,ACT_DISABLED); } void CharmInfo::InitPetActionBar() { // the first 3 SpellOrActions are attack, follow and stay - for(uint32 i = 0; i < ACTION_BAR_INDEX_PET_SPELL_START - ACTION_BAR_INDEX_START; ++i) + for (uint32 i = 0; i < ACTION_BAR_INDEX_PET_SPELL_START - ACTION_BAR_INDEX_START; ++i) SetActionBar(ACTION_BAR_INDEX_START + i,COMMAND_ATTACK - i,ACT_COMMAND); // middle 4 SpellOrActions are spells/special attacks/abilities - for(uint32 i = 0; i < ACTION_BAR_INDEX_PET_SPELL_END-ACTION_BAR_INDEX_PET_SPELL_START; ++i) + for (uint32 i = 0; i < ACTION_BAR_INDEX_PET_SPELL_END-ACTION_BAR_INDEX_PET_SPELL_START; ++i) SetActionBar(ACTION_BAR_INDEX_PET_SPELL_START + i,0,ACT_DISABLED); // last 3 SpellOrActions are reactions - for(uint32 i = 0; i < ACTION_BAR_INDEX_END - ACTION_BAR_INDEX_PET_SPELL_END; ++i) + for (uint32 i = 0; i < ACTION_BAR_INDEX_END - ACTION_BAR_INDEX_PET_SPELL_END; ++i) SetActionBar(ACTION_BAR_INDEX_PET_SPELL_END + i,COMMAND_ATTACK - i,ACT_REACTION); } void CharmInfo::InitEmptyActionBar() { SetActionBar(ACTION_BAR_INDEX_START,COMMAND_ATTACK,ACT_COMMAND); - for(uint32 x = ACTION_BAR_INDEX_START+1; x < ACTION_BAR_INDEX_END; ++x) + for (uint32 x = ACTION_BAR_INDEX_START+1; x < ACTION_BAR_INDEX_END; ++x) SetActionBar(x,0,ACT_PASSIVE); } @@ -9549,10 +9549,10 @@ void CharmInfo::InitPossessCreateSpells() { InitEmptyActionBar(); //charm action bar - if(m_unit->GetTypeId() == TYPEID_PLAYER) //possessed players don't have spells, keep the action bar empty + if (m_unit->GetTypeId() == TYPEID_PLAYER) //possessed players don't have spells, keep the action bar empty return; - for(uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) + for (uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) { if (IsPassiveSpell(((Creature*)m_unit)->m_spells[x])) m_unit->CastSpell(m_unit, ((Creature*)m_unit)->m_spells[x], true); @@ -9563,7 +9563,7 @@ void CharmInfo::InitPossessCreateSpells() void CharmInfo::InitCharmCreateSpells() { - if(m_unit->GetTypeId() == TYPEID_PLAYER) //charmed players don't have spells + if (m_unit->GetTypeId() == TYPEID_PLAYER) //charmed players don't have spells { InitEmptyActionBar(); return; @@ -9571,11 +9571,11 @@ void CharmInfo::InitCharmCreateSpells() InitPetActionBar(); - for(uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) + for (uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) { uint32 spellId = ((Creature*)m_unit)->m_spells[x]; - if(!spellId) + if (!spellId) { m_charmspells[x].SetActionAndType(spellId,ACT_DISABLED); continue; @@ -9592,16 +9592,16 @@ void CharmInfo::InitCharmCreateSpells() ActiveStates newstate; bool onlyselfcast = true; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); - if(!spellInfo) onlyselfcast = false; - for(uint32 i = 0; i < 3 && onlyselfcast; ++i) //nonexistent spell will not make any problems as onlyselfcast would be false -> break right away + if (!spellInfo) onlyselfcast = false; + for (uint32 i = 0; i < 3 && onlyselfcast; ++i) //nonexistent spell will not make any problems as onlyselfcast would be false -> break right away { - if(spellInfo->EffectImplicitTargetA[i] != TARGET_SELF && spellInfo->EffectImplicitTargetA[i] != 0) + if (spellInfo->EffectImplicitTargetA[i] != TARGET_SELF && spellInfo->EffectImplicitTargetA[i] != 0) onlyselfcast = false; } - if(onlyselfcast || !IsPositiveSpell(spellId)) // only self cast and spells versus enemies are autocastable + if (onlyselfcast || !IsPositiveSpell(spellId)) // only self cast and spells versus enemies are autocastable newstate = ACT_DISABLED; else newstate = ACT_PASSIVE; @@ -9616,7 +9616,7 @@ bool CharmInfo::AddSpellToActionBar(uint32 spell_id, ActiveStates newstate) uint32 first_id = sSpellMgr.GetFirstSpellInChain(spell_id); // new spell rank can be already listed - for(uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) + for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) { if (uint32 action = PetActionBar[i].GetAction()) { @@ -9629,7 +9629,7 @@ bool CharmInfo::AddSpellToActionBar(uint32 spell_id, ActiveStates newstate) } // or use empty slot in other case - for(uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) + for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) { if (!PetActionBar[i].GetAction() && PetActionBar[i].IsActionBarForSpell()) { @@ -9644,7 +9644,7 @@ bool CharmInfo::RemoveSpellFromActionBar(uint32 spell_id) { uint32 first_id = sSpellMgr.GetFirstSpellInChain(spell_id); - for(uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) + for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) { if (uint32 action = PetActionBar[i].GetAction()) { @@ -9661,24 +9661,24 @@ bool CharmInfo::RemoveSpellFromActionBar(uint32 spell_id) void CharmInfo::ToggleCreatureAutocast(uint32 spellid, bool apply) { - if(IsPassiveSpell(spellid)) + if (IsPassiveSpell(spellid)) return; - for(uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) - if(spellid == m_charmspells[x].GetAction()) + for (uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) + if (spellid == m_charmspells[x].GetAction()) m_charmspells[x].SetType(apply ? ACT_ENABLED : ACT_DISABLED); } void CharmInfo::SetPetNumber(uint32 petnumber, bool statwindow) { m_petnumber = petnumber; - if(statwindow) + if (statwindow) m_unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, m_petnumber); else m_unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, 0); } -void CharmInfo::LoadPetActionBar(const std::string& data ) +void CharmInfo::LoadPetActionBar(const std::string& data) { InitPetActionBar(); @@ -9689,7 +9689,7 @@ void CharmInfo::LoadPetActionBar(const std::string& data ) int index; Tokens::iterator iter; - for(iter = tokens.begin(), index = ACTION_BAR_INDEX_START; index < ACTION_BAR_INDEX_END; ++iter, ++index ) + for (iter = tokens.begin(), index = ACTION_BAR_INDEX_START; index < ACTION_BAR_INDEX_END; ++iter, ++index) { // use unsigned cast to avoid sign negative format use at long-> ActiveStates (int) conversion uint8 type = (uint8)atol((*iter).c_str()); @@ -9699,22 +9699,22 @@ void CharmInfo::LoadPetActionBar(const std::string& data ) PetActionBar[index].SetActionAndType(action,ActiveStates(type)); // check correctness - if(PetActionBar[index].IsActionBarForSpell() && !sSpellStore.LookupEntry(PetActionBar[index].GetAction())) + if (PetActionBar[index].IsActionBarForSpell() && !sSpellStore.LookupEntry(PetActionBar[index].GetAction())) SetActionBar(index,0,ACT_DISABLED); } } -void CharmInfo::BuildActionBar( WorldPacket* data ) +void CharmInfo::BuildActionBar(WorldPacket* data) { - for(uint32 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) + for (uint32 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) *data << uint32(PetActionBar[i].packedData); } -void CharmInfo::SetSpellAutocast( uint32 spell_id, bool state ) +void CharmInfo::SetSpellAutocast(uint32 spell_id, bool state) { - for(int i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) + for (int i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) { - if(spell_id == PetActionBar[i].GetAction() && PetActionBar[i].IsActionBarForSpell()) + if (spell_id == PetActionBar[i].GetAction() && PetActionBar[i].IsActionBarForSpell()) { PetActionBar[i].SetType(state ? ACT_ENABLED : ACT_DISABLED); break; @@ -9729,37 +9729,37 @@ bool Unit::isFrozen() const struct ProcTriggeredData { - ProcTriggeredData(SpellProcEventEntry const * _spellProcEvent, SpellAuraHolder* _triggeredByHolder) + ProcTriggeredData(SpellProcEventEntry const* _spellProcEvent, SpellAuraHolder* _triggeredByHolder) : spellProcEvent(_spellProcEvent), triggeredByHolder(_triggeredByHolder) - {} - SpellProcEventEntry const *spellProcEvent; + {} + SpellProcEventEntry const* spellProcEvent; SpellAuraHolder* triggeredByHolder; }; typedef std::list< ProcTriggeredData > ProcTriggeredList; typedef std::list< uint32> RemoveSpellList; -uint32 createProcExtendMask(SpellNonMeleeDamage *damageInfo, SpellMissInfo missCondition) +uint32 createProcExtendMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missCondition) { uint32 procEx = PROC_EX_NONE; // Check victim state if (missCondition!=SPELL_MISS_NONE) - switch (missCondition) - { - case SPELL_MISS_MISS: procEx|=PROC_EX_MISS; break; - case SPELL_MISS_RESIST: procEx|=PROC_EX_RESIST; break; - case SPELL_MISS_DODGE: procEx|=PROC_EX_DODGE; break; - case SPELL_MISS_PARRY: procEx|=PROC_EX_PARRY; break; - case SPELL_MISS_BLOCK: procEx|=PROC_EX_BLOCK; break; - case SPELL_MISS_EVADE: procEx|=PROC_EX_EVADE; break; - case SPELL_MISS_IMMUNE: procEx|=PROC_EX_IMMUNE; break; - case SPELL_MISS_IMMUNE2: procEx|=PROC_EX_IMMUNE; break; - case SPELL_MISS_DEFLECT: procEx|=PROC_EX_DEFLECT;break; - case SPELL_MISS_ABSORB: procEx|=PROC_EX_ABSORB; break; - case SPELL_MISS_REFLECT: procEx|=PROC_EX_REFLECT;break; - default: - break; - } + switch (missCondition) + { + case SPELL_MISS_MISS: procEx|=PROC_EX_MISS; break; + case SPELL_MISS_RESIST: procEx|=PROC_EX_RESIST; break; + case SPELL_MISS_DODGE: procEx|=PROC_EX_DODGE; break; + case SPELL_MISS_PARRY: procEx|=PROC_EX_PARRY; break; + case SPELL_MISS_BLOCK: procEx|=PROC_EX_BLOCK; break; + case SPELL_MISS_EVADE: procEx|=PROC_EX_EVADE; break; + case SPELL_MISS_IMMUNE: procEx|=PROC_EX_IMMUNE; break; + case SPELL_MISS_IMMUNE2: procEx|=PROC_EX_IMMUNE; break; + case SPELL_MISS_DEFLECT: procEx|=PROC_EX_DEFLECT; break; + case SPELL_MISS_ABSORB: procEx|=PROC_EX_ABSORB; break; + case SPELL_MISS_REFLECT: procEx|=PROC_EX_REFLECT; break; + default: + break; + } else { // On block @@ -9777,7 +9777,7 @@ uint32 createProcExtendMask(SpellNonMeleeDamage *damageInfo, SpellMissInfo missC return procEx; } -void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage ) +void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const* procSpell, uint32 damage) { // For melee/ranged based attack need update skills and set some Aura states if (!(procExtra & PROC_EX_CAST_END) && procFlag & MELEE_BASED_TRIGGER_MASK) @@ -9808,7 +9808,7 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag if (getClass() != CLASS_ROGUE) // skip Rogue Riposte { ModifyAuraState(AURA_STATE_DEFENSE, true); - StartReactiveTimer( REACTIVE_DEFENSE ); + StartReactiveTimer(REACTIVE_DEFENSE); } } // if victim and parry attack @@ -9818,19 +9818,19 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag if (getClass() == CLASS_HUNTER) { ModifyAuraState(AURA_STATE_HUNTER_PARRY, true); - StartReactiveTimer( REACTIVE_HUNTER_PARRY ); + StartReactiveTimer(REACTIVE_HUNTER_PARRY); } else { ModifyAuraState(AURA_STATE_DEFENSE, true); - StartReactiveTimer( REACTIVE_DEFENSE ); + StartReactiveTimer(REACTIVE_DEFENSE); } } // if and victim block attack if (procExtra & PROC_EX_BLOCK) { ModifyAuraState(AURA_STATE_DEFENSE,true); - StartReactiveTimer( REACTIVE_DEFENSE ); + StartReactiveTimer(REACTIVE_DEFENSE); } } else //For attacker @@ -9839,7 +9839,7 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag if (procExtra&PROC_EX_DODGE && GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_WARRIOR) { ((Player*)this)->AddComboPoints(pTarget, 1); - StartReactiveTimer( REACTIVE_OVERPOWER ); + StartReactiveTimer(REACTIVE_OVERPOWER); } } } @@ -9848,18 +9848,18 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag RemoveSpellList removedSpells; ProcTriggeredList procTriggered; // Fill procTriggered list - for(SpellAuraHolderMap::const_iterator itr = GetSpellAuraHolderMap().begin(); itr!= GetSpellAuraHolderMap().end(); ++itr) + for (SpellAuraHolderMap::const_iterator itr = GetSpellAuraHolderMap().begin(); itr!= GetSpellAuraHolderMap().end(); ++itr) { // skip deleted auras (possible at recursive triggered call - if(itr->second->IsDeleted()) + if (itr->second->IsDeleted()) continue; SpellProcEventEntry const* spellProcEvent = NULL; - if(!IsTriggeredAtSpellProcEvent(pTarget, itr->second, procSpell, procFlag, procExtra, attType, isVictim, spellProcEvent)) - continue; + if (!IsTriggeredAtSpellProcEvent(pTarget, itr->second, procSpell, procFlag, procExtra, attType, isVictim, spellProcEvent)) + continue; itr->second->SetInUse(true); // prevent holder deletion - procTriggered.push_back( ProcTriggeredData(spellProcEvent, itr->second) ); + procTriggered.push_back(ProcTriggeredData(spellProcEvent, itr->second)); } // Nothing found @@ -9867,14 +9867,14 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag return; // Handle effects proceed this time - for(ProcTriggeredList::const_iterator itr = procTriggered.begin(); itr != procTriggered.end(); ++itr) + for (ProcTriggeredList::const_iterator itr = procTriggered.begin(); itr != procTriggered.end(); ++itr) { // Some auras can be deleted in function called in this loop (except first, ofc) - SpellAuraHolder *triggeredByHolder = itr->triggeredByHolder; - if(triggeredByHolder->IsDeleted()) + SpellAuraHolder* triggeredByHolder = itr->triggeredByHolder; + if (triggeredByHolder->IsDeleted()) continue; - SpellProcEventEntry const *spellProcEvent = itr->spellProcEvent; + SpellProcEventEntry const* spellProcEvent = itr->spellProcEvent; bool useCharges = triggeredByHolder->GetAuraCharges() > 0; bool procSuccess = true; bool anyAuraProc = false; @@ -9886,7 +9886,7 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { - Aura *triggeredByAura = triggeredByHolder->GetAuraByEffectIndex(SpellEffectIndex(i)); + Aura* triggeredByAura = triggeredByHolder->GetAuraByEffectIndex(SpellEffectIndex(i)); if (!triggeredByAura) continue; @@ -9934,10 +9934,10 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag } // Remove charge (aura can be removed by triggers) - if(useCharges && procSuccess && anyAuraProc && !triggeredByHolder->IsDeleted()) + if (useCharges && procSuccess && anyAuraProc && !triggeredByHolder->IsDeleted()) { // If last charge dropped add spell to remove list - if(triggeredByHolder->DropAuraCharge()) + if (triggeredByHolder->DropAuraCharge()) removedSpells.push_back(triggeredByHolder->GetId()); } @@ -9950,7 +9950,7 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag removedSpells.sort(); removedSpells.unique(); // Remove auras from removedAuras - for(RemoveSpellList::const_iterator i = removedSpells.begin(); i != removedSpells.end();++i) + for (RemoveSpellList::const_iterator i = removedSpells.begin(); i != removedSpells.end(); ++i) RemoveAurasDueToSpell(*i); } } @@ -9962,12 +9962,12 @@ SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const Player* Unit::GetSpellModOwner() const { - if(GetTypeId()==TYPEID_PLAYER) + if (GetTypeId()==TYPEID_PLAYER) return (Player*)this; - if(((Creature*)this)->IsPet() || ((Creature*)this)->IsTotem()) + if (((Creature*)this)->IsPet() || ((Creature*)this)->IsTotem()) { Unit* owner = GetOwner(); - if(owner && owner->GetTypeId()==TYPEID_PLAYER) + if (owner && owner->GetTypeId()==TYPEID_PLAYER) return (Player*)owner; } return NULL; @@ -9976,11 +9976,11 @@ Player* Unit::GetSpellModOwner() const ///----------Pet responses methods----------------- void Unit::SendPetCastFail(uint32 spellid, SpellCastResult msg) { - if(msg == SPELL_CAST_OK) + if (msg == SPELL_CAST_OK) return; - Unit *owner = GetCharmerOrOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + Unit* owner = GetCharmerOrOwner(); + if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; WorldPacket data(SMSG_PET_CAST_FAILED, 1 + 4 + 1); @@ -9989,7 +9989,7 @@ void Unit::SendPetCastFail(uint32 spellid, SpellCastResult msg) data << uint8(msg); // More cases exist, see Spell::SendCastResult (can possibly be unified) - switch(msg) + switch (msg) { case SPELL_FAILED_NOT_READY: data << uint32(0); // unknown @@ -10001,10 +10001,10 @@ void Unit::SendPetCastFail(uint32 spellid, SpellCastResult msg) ((Player*)owner)->GetSession()->SendPacket(&data); } -void Unit::SendPetActionFeedback (uint8 msg) +void Unit::SendPetActionFeedback(uint8 msg) { Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; WorldPacket data(SMSG_PET_ACTION_FEEDBACK, 1); @@ -10012,10 +10012,10 @@ void Unit::SendPetActionFeedback (uint8 msg) ((Player*)owner)->GetSession()->SendPacket(&data); } -void Unit::SendPetTalk (uint32 pettalk) +void Unit::SendPetTalk(uint32 pettalk) { Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; WorldPacket data(SMSG_PET_ACTION_SOUND, 8 + 4); @@ -10027,7 +10027,7 @@ void Unit::SendPetTalk (uint32 pettalk) void Unit::SendPetAIReaction() { Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; WorldPacket data(SMSG_AI_REACTION, 8 + 4); @@ -10111,14 +10111,14 @@ void Unit::SetConfused(bool apply, ObjectGuid casterGuid, uint32 spellID) if (GetTypeId() != TYPEID_PLAYER && isAlive()) { // restore appropriate movement generator - if(getVictim()) + if (getVictim()) GetMotionMaster()->MoveChase(getVictim()); else GetMotionMaster()->Initialize(); } } - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) ((Player*)this)->SetClientControl(this, !apply); } @@ -10138,11 +10138,11 @@ void Unit::SetFeignDeath(bool apply, ObjectGuid casterGuid, uint32 /*spellID*/) else ((Player*)this)->m_movementInfo.SetMovementFlags(MOVEFLAG_NONE); - // blizz like 2.0.x + // blizz like 2.0.x SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); - // blizz like 2.0.x + // blizz like 2.0.x SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); - // blizz like 2.0.x + // blizz like 2.0.x SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); addUnitState(UNIT_STAT_DIED); @@ -10163,11 +10163,11 @@ void Unit::SetFeignDeath(bool apply, ObjectGuid casterGuid, uint32 /*spellID*/) data<MoveChase(getVictim()); else GetMotionMaster()->Initialize(); @@ -10206,7 +10206,7 @@ void Unit::SetStandState(uint8 state) if (IsStandState()) RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_SEATED); - if(GetTypeId()==TYPEID_PLAYER) + if (GetTypeId()==TYPEID_PLAYER) { WorldPacket data(SMSG_STANDSTATE_UPDATE, 1); data << (uint8)state; @@ -10225,13 +10225,13 @@ void Unit::SetDisplayId(uint32 modelId) UpdateModelData(); - if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsPet()) + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsPet()) { - Pet *pet = ((Pet*)this); - if(!pet->isControlled()) + Pet* pet = ((Pet*)this); + if (!pet->isControlled()) return; - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + Unit* owner = GetOwner(); + if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MODEL_ID); } } @@ -10253,7 +10253,7 @@ void Unit::UpdateModelData() void Unit::ClearComboPointHolders() { - while(!m_ComboPointHolders.empty()) + while (!m_ComboPointHolders.empty()) { uint32 lowguid = *m_ComboPointHolders.begin(); @@ -10267,43 +10267,43 @@ void Unit::ClearComboPointHolders() void Unit::ClearAllReactives() { - for(int i=0; i < MAX_REACTIVE; ++i) + for (int i=0; i < MAX_REACTIVE; ++i) m_reactiveTimer[i] = 0; - if (HasAuraState( AURA_STATE_DEFENSE)) + if (HasAuraState(AURA_STATE_DEFENSE)) ModifyAuraState(AURA_STATE_DEFENSE, false); - if (getClass() == CLASS_HUNTER && HasAuraState( AURA_STATE_HUNTER_PARRY)) + if (getClass() == CLASS_HUNTER && HasAuraState(AURA_STATE_HUNTER_PARRY)) ModifyAuraState(AURA_STATE_HUNTER_PARRY, false); - if(getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER) + if (getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER) ((Player*)this)->ClearComboPoints(); } -void Unit::UpdateReactives( uint32 p_time ) +void Unit::UpdateReactives(uint32 p_time) { - for(int i = 0; i < MAX_REACTIVE; ++i) + for (int i = 0; i < MAX_REACTIVE; ++i) { ReactiveType reactive = ReactiveType(i); - if(!m_reactiveTimer[reactive]) + if (!m_reactiveTimer[reactive]) continue; - if ( m_reactiveTimer[reactive] <= p_time) + if (m_reactiveTimer[reactive] <= p_time) { m_reactiveTimer[reactive] = 0; - switch ( reactive ) + switch (reactive) { case REACTIVE_DEFENSE: if (HasAuraState(AURA_STATE_DEFENSE)) ModifyAuraState(AURA_STATE_DEFENSE, false); break; case REACTIVE_HUNTER_PARRY: - if ( getClass() == CLASS_HUNTER && HasAuraState(AURA_STATE_HUNTER_PARRY)) + if (getClass() == CLASS_HUNTER && HasAuraState(AURA_STATE_HUNTER_PARRY)) ModifyAuraState(AURA_STATE_HUNTER_PARRY, false); break; case REACTIVE_OVERPOWER: - if(getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER) + if (getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER) ((Player*)this)->ClearComboPoints(); break; default: @@ -10319,22 +10319,22 @@ void Unit::UpdateReactives( uint32 p_time ) Unit* Unit::SelectRandomUnfriendlyTarget(Unit* except /*= NULL*/, float radius /*= ATTACK_DISTANCE*/) const { - std::list targets; + std::list targets; MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, radius); MaNGOS::UnitListSearcher searcher(targets, u_check); Cell::VisitAllObjects(this, searcher, radius); // remove current target - if(except) + if (except) targets.remove(except); // remove not LoS targets - for(std::list::iterator tIter = targets.begin(); tIter != targets.end();) + for (std::list::iterator tIter = targets.begin(); tIter != targets.end();) { - if(!IsWithinLOSInMap(*tIter)) + if (!IsWithinLOSInMap(*tIter)) { - std::list::iterator tIter2 = tIter; + std::list::iterator tIter2 = tIter; ++tIter; targets.erase(tIter2); } @@ -10343,13 +10343,13 @@ Unit* Unit::SelectRandomUnfriendlyTarget(Unit* except /*= NULL*/, float radius / } // no appropriate targets - if(targets.empty()) + if (targets.empty()) return NULL; // select random uint32 rIdx = urand(0,targets.size()-1); - std::list::const_iterator tcIter = targets.begin(); - for(uint32 i = 0; i < rIdx; ++i) + std::list::const_iterator tcIter = targets.begin(); + for (uint32 i = 0; i < rIdx; ++i) ++tcIter; return *tcIter; @@ -10357,7 +10357,7 @@ Unit* Unit::SelectRandomUnfriendlyTarget(Unit* except /*= NULL*/, float radius / Unit* Unit::SelectRandomFriendlyTarget(Unit* except /*= NULL*/, float radius /*= ATTACK_DISTANCE*/) const { - std::list targets; + std::list targets; MaNGOS::AnyFriendlyUnitInObjectRangeCheck u_check(this, radius); MaNGOS::UnitListSearcher searcher(targets, u_check); @@ -10365,15 +10365,15 @@ Unit* Unit::SelectRandomFriendlyTarget(Unit* except /*= NULL*/, float radius /*= Cell::VisitAllObjects(this, searcher, radius); // remove current target - if(except) + if (except) targets.remove(except); // remove not LoS targets - for(std::list::iterator tIter = targets.begin(); tIter != targets.end();) + for (std::list::iterator tIter = targets.begin(); tIter != targets.end();) { - if(!IsWithinLOSInMap(*tIter)) + if (!IsWithinLOSInMap(*tIter)) { - std::list::iterator tIter2 = tIter; + std::list::iterator tIter2 = tIter; ++tIter; targets.erase(tIter2); } @@ -10382,13 +10382,13 @@ Unit* Unit::SelectRandomFriendlyTarget(Unit* except /*= NULL*/, float radius /*= } // no appropriate targets - if(targets.empty()) + if (targets.empty()) return NULL; // select random uint32 rIdx = urand(0,targets.size()-1); - std::list::const_iterator tcIter = targets.begin(); - for(uint32 i = 0; i < rIdx; ++i) + std::list::const_iterator tcIter = targets.begin(); + for (uint32 i = 0; i < rIdx; ++i) ++tcIter; return *tcIter; @@ -10404,9 +10404,9 @@ bool Unit::hasNegativeAuraWithInterruptFlag(uint32 flag) return false; } -void Unit::ApplyAttackTimePercentMod( WeaponAttackType att,float val, bool apply ) +void Unit::ApplyAttackTimePercentMod(WeaponAttackType att,float val, bool apply) { - if(val > 0) + if (val > 0) { ApplyPercentModFloatVar(m_modAttackSpeedPct[att], val, !apply); ApplyPercentModFloatValue(UNIT_FIELD_BASEATTACKTIME+att,val,!apply); @@ -10418,9 +10418,9 @@ void Unit::ApplyAttackTimePercentMod( WeaponAttackType att,float val, bool apply } } -void Unit::ApplyCastTimePercentMod(float val, bool apply ) +void Unit::ApplyCastTimePercentMod(float val, bool apply) { - if(val > 0) + if (val > 0) ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED,val,!apply); else ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED,-val,apply); @@ -10428,22 +10428,22 @@ void Unit::ApplyCastTimePercentMod(float val, bool apply ) void Unit::UpdateAuraForGroup(uint8 slot) { - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { Player* player = (Player*)this; - if(player->GetGroup()) + if (player->GetGroup()) { player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_AURAS); player->SetAuraUpdateMask(slot); } } - else if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsPet()) + else if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsPet()) { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) + Pet* pet = ((Pet*)this); + if (pet->isControlled()) { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + Unit* owner = GetOwner(); + if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) { ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_AURAS); pet->SetAuraUpdateMask(slot); @@ -10457,7 +10457,7 @@ float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized) if (!normalized || GetTypeId() != TYPEID_PLAYER) return float(GetAttackTime(attType))/1000.0f; - Item *Weapon = ((Player*)this)->GetWeaponForAttack(attType, true, false); + Item* Weapon = ((Player*)this)->GetWeaponForAttack(attType, true, false); if (!Weapon) return 2.4f; // fist attack @@ -10477,17 +10477,17 @@ float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized) } } -Aura* Unit::GetDummyAura( uint32 spell_id ) const +Aura* Unit::GetDummyAura(uint32 spell_id) const { Unit::AuraList const& mDummy = GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr) + for (Unit::AuraList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr) if ((*itr)->GetId() == spell_id) return *itr; return NULL; } -void Unit::SetContestedPvP(Player *attackedPlayer) +void Unit::SetContestedPvP(Player* attackedPlayer) { Player* player = GetCharmerOrOwnerPlayerOrPlayerItself(); @@ -10515,23 +10515,23 @@ void Unit::SetContestedPvP(Player *attackedPlayer) void Unit::AddPetAura(PetAura const* petSpell) { m_petAuras.insert(petSpell); - if(Pet* pet = GetPet()) + if (Pet* pet = GetPet()) pet->CastPetAura(petSpell); } void Unit::RemovePetAura(PetAura const* petSpell) { m_petAuras.erase(petSpell); - if(Pet* pet = GetPet()) + if (Pet* pet = GetPet()) pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry())); } void Unit::RemoveAurasAtMechanicImmunity(uint32 mechMask, uint32 exceptSpellId, bool non_positive /*= false*/) { Unit::SpellAuraHolderMap& auras = GetSpellAuraHolderMap(); - for(Unit::SpellAuraHolderMap::iterator iter = auras.begin(); iter != auras.end();) + for (Unit::SpellAuraHolderMap::iterator iter = auras.begin(); iter != auras.end();) { - SpellEntry const *spell = iter->second->GetSpellProto(); + SpellEntry const* spell = iter->second->GetSpellProto(); if (spell->Id == exceptSpellId) ++iter; else if (non_positive && iter->second->IsPositive()) @@ -10542,11 +10542,11 @@ void Unit::RemoveAurasAtMechanicImmunity(uint32 mechMask, uint32 exceptSpellId, { RemoveAurasDueToSpell(spell->Id); - if(auras.empty()) + if (auras.empty()) break; else iter = auras.begin(); - } + } else ++iter; } @@ -10578,18 +10578,18 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) WorldObject::SetPhaseMask(newPhaseMask, update); } -void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool casting /*= false*/ ) +void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool casting /*= false*/) { DisableSpline(); - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) ((Player*)this)->TeleportTo(GetMapId(), x, y, z, orientation, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0)); else { Creature* c = (Creature*)this; // Creature relocation acts like instant movement generator, so current generator expects interrupt/reset calls to react properly if (!c->GetMotionMaster()->empty()) - if (MovementGenerator *movgen = c->GetMotionMaster()->top()) + if (MovementGenerator* movgen = c->GetMotionMaster()->top()) movgen->Interrupt(*c); GetMap()->CreatureRelocation((Creature*)this, x, y, z, orientation); @@ -10599,7 +10599,7 @@ void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool ca // finished relocation, movegen can different from top before creature relocation, // but apply Reset expected to be safe in any case if (!c->GetMotionMaster()->empty()) - if (MovementGenerator *movgen = c->GetMotionMaster()->top()) + if (MovementGenerator* movgen = c->GetMotionMaster()->top()) movgen->Reset(*c); } } @@ -10619,9 +10619,9 @@ struct SetPvPHelper bool state; }; -void Unit::SetPvP( bool state ) +void Unit::SetPvP(bool state) { - if(state) + if (state) SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); else RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); @@ -10636,9 +10636,9 @@ struct SetFFAPvPHelper bool state; }; -void Unit::SetFFAPvP( bool state ) +void Unit::SetFFAPvP(bool state) { - if(state) + if (state) SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); else RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); @@ -10688,7 +10688,7 @@ float Unit::GetCombatRatingReduction(CombatRating cr) const { // Player's pet get 100% resilience from owner if (Unit* owner = GetOwner()) - if(owner->GetTypeId() == TYPEID_PLAYER) + if (owner->GetTypeId() == TYPEID_PLAYER) return ((Player*)owner)->GetRatingBonusValue(cr); } @@ -10700,7 +10700,7 @@ uint32 Unit::GetCombatRatingDamageReduction(CombatRating cr, float rate, float c float percent = GetCombatRatingReduction(cr) * rate; if (percent > cap) percent = cap; - return uint32 (percent * damage / 100.0f); + return uint32(percent * damage / 100.0f); } void Unit::SendThreatUpdate() @@ -10781,7 +10781,7 @@ void Unit::StopAttackFaction(uint32 faction_id) } AttackerSet const& attackers = getAttackers(); - for(AttackerSet::const_iterator itr = attackers.begin(); itr != attackers.end();) + for (AttackerSet::const_iterator itr = attackers.begin(); itr != attackers.end();) { if ((*itr)->getFactionTemplateEntry()->faction==faction_id) { @@ -10797,10 +10797,10 @@ void Unit::StopAttackFaction(uint32 faction_id) CallForAllControlledUnits(StopAttackFactionHelper(faction_id), CONTROLLED_PET|CONTROLLED_GUARDIANS|CONTROLLED_CHARM); } -bool Unit::IsIgnoreUnitState(SpellEntry const *spell, IgnoreUnitState ignoreState) +bool Unit::IsIgnoreUnitState(SpellEntry const* spell, IgnoreUnitState ignoreState) { Unit::AuraList const& stateAuras = GetAurasByType(SPELL_AURA_IGNORE_UNIT_STATE); - for(Unit::AuraList::const_iterator itr = stateAuras.begin(); itr != stateAuras.end(); ++itr) + for (Unit::AuraList::const_iterator itr = stateAuras.begin(); itr != stateAuras.end(); ++itr) { if ((*itr)->GetModifier()->m_miscvalue == ignoreState) { @@ -10823,7 +10823,7 @@ void Unit::CleanupDeletedAuras() m_deletedHolders.clear(); // really delete auras "deleted" while processing its ApplyModify code - for(AuraList::const_iterator itr = m_deletedAuras.begin(); itr != m_deletedAuras.end(); ++itr) + for (AuraList::const_iterator itr = m_deletedAuras.begin(); itr != m_deletedAuras.end(); ++itr) delete *itr; m_deletedAuras.clear(); } @@ -10839,13 +10839,13 @@ bool Unit::CheckAndIncreaseCastCounter() return true; } -SpellAuraHolder* Unit::GetSpellAuraHolder (uint32 spellid) const +SpellAuraHolder* Unit::GetSpellAuraHolder(uint32 spellid) const { SpellAuraHolderMap::const_iterator itr = m_spellAuraHolders.find(spellid); return itr != m_spellAuraHolders.end() ? itr->second : NULL; } -SpellAuraHolder* Unit::GetSpellAuraHolder (uint32 spellid, ObjectGuid casterGuid) const +SpellAuraHolder* Unit::GetSpellAuraHolder(uint32 spellid, ObjectGuid casterGuid) const { SpellAuraHolderConstBounds bounds = GetSpellAuraHolderBounds(spellid); for (SpellAuraHolderMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter) @@ -10889,36 +10889,36 @@ bool Unit::IsAllowedDamageInArea(Unit* pVictim) const class RelocationNotifyEvent : public BasicEvent { -public: - RelocationNotifyEvent(Unit& owner) : BasicEvent(), m_owner(owner) - { - m_owner._SetAINotifyScheduled(true); - } - - bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) - { - float radius = MAX_CREATURE_ATTACK_RADIUS * sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); - if (m_owner.GetTypeId() == TYPEID_PLAYER) + public: + RelocationNotifyEvent(Unit& owner) : BasicEvent(), m_owner(owner) { - MaNGOS::PlayerRelocationNotifier notify((Player&)m_owner); - Cell::VisitAllObjects(&m_owner,notify,radius); + m_owner._SetAINotifyScheduled(true); } - else //if(m_owner.GetTypeId() == TYPEID_UNIT) + + bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) { - MaNGOS::CreatureRelocationNotifier notify((Creature&)m_owner); - Cell::VisitAllObjects(&m_owner,notify,radius); + float radius = MAX_CREATURE_ATTACK_RADIUS * sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); + if (m_owner.GetTypeId() == TYPEID_PLAYER) + { + MaNGOS::PlayerRelocationNotifier notify((Player&)m_owner); + Cell::VisitAllObjects(&m_owner,notify,radius); + } + else //if(m_owner.GetTypeId() == TYPEID_UNIT) + { + MaNGOS::CreatureRelocationNotifier notify((Creature&)m_owner); + Cell::VisitAllObjects(&m_owner,notify,radius); + } + m_owner._SetAINotifyScheduled(false); + return true; } - m_owner._SetAINotifyScheduled(false); - return true; - } - void Abort(uint64) - { - m_owner._SetAINotifyScheduled(false); - } + void Abort(uint64) + { + m_owner._SetAINotifyScheduled(false); + } -private: - Unit& m_owner; + private: + Unit& m_owner; }; void Unit::ScheduleAINotify(uint32 delay) @@ -10975,7 +10975,8 @@ void Unit::SetVehicleId(uint32 entry) void Unit::UpdateSplineMovement(uint32 t_diff) { - enum{ + enum + { POSITION_UPDATE_DELAY = 400, }; diff --git a/src/game/Unit.h b/src/game/Unit.h index 717431856..99e53dca2 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -634,15 +634,15 @@ enum MovementFlags // flags that use in movement check for example at spell casting MovementFlags const movementFlagsMask = MovementFlags( - MOVEFLAG_FORWARD |MOVEFLAG_BACKWARD |MOVEFLAG_STRAFE_LEFT |MOVEFLAG_STRAFE_RIGHT| - MOVEFLAG_PITCH_UP|MOVEFLAG_PITCH_DOWN|MOVEFLAG_ROOT | - MOVEFLAG_FALLING |MOVEFLAG_FALLINGFAR|MOVEFLAG_ASCENDING | - MOVEFLAG_FLYING |MOVEFLAG_SPLINE_ELEVATION -); + MOVEFLAG_FORWARD |MOVEFLAG_BACKWARD |MOVEFLAG_STRAFE_LEFT |MOVEFLAG_STRAFE_RIGHT| + MOVEFLAG_PITCH_UP|MOVEFLAG_PITCH_DOWN|MOVEFLAG_ROOT | + MOVEFLAG_FALLING |MOVEFLAG_FALLINGFAR|MOVEFLAG_ASCENDING | + MOVEFLAG_FLYING |MOVEFLAG_SPLINE_ELEVATION + ); MovementFlags const movementOrTurningFlagsMask = MovementFlags( - movementFlagsMask | MOVEFLAG_TURN_LEFT | MOVEFLAG_TURN_RIGHT -); + movementFlagsMask | MOVEFLAG_TURN_LEFT | MOVEFLAG_TURN_RIGHT + ); enum MovementFlags2 { @@ -673,8 +673,8 @@ class MovementInfo t_time(0), t_seat(-1), t_time2(0), s_pitch(0.0f), fallTime(0), u_unk1(0.0f) {} // Read/Write methods - void Read(ByteBuffer &data); - void Write(ByteBuffer &data) const; + void Read(ByteBuffer& data); + void Write(ByteBuffer& data) const; // Movement flags manipulations void AddMovementFlag(MovementFlags f) { moveFlags |= f; } @@ -685,7 +685,7 @@ class MovementInfo MovementFlags2 GetMovementFlags2() const { return MovementFlags2(moveFlags2); } // Position manipulations - Position const *GetPos() const { return &pos; } + Position const* GetPos() const { return &pos; } void SetTransportData(ObjectGuid guid, float x, float y, float z, float o, uint32 time, int8 seat) { t_guid = guid; @@ -707,7 +707,7 @@ class MovementInfo t_seat = -1; } ObjectGuid const& GetTransportGuid() const { return t_guid; } - Position const *GetTransportPos() const { return &t_pos; } + Position const* GetTransportPos() const { return &t_pos; } int8 GetTransportSeat() const { return t_seat; } uint32 GetTransportTime() const { return t_time; } uint32 GetFallTime() const { return fallTime; } @@ -756,7 +756,8 @@ inline ByteBuffer& operator>> (ByteBuffer& buf, MovementInfo& mi) return buf; } -namespace Movement{ +namespace Movement +{ class MoveSpline; } @@ -797,7 +798,7 @@ enum MeleeHitOutcome struct CleanDamage { CleanDamage(uint32 _damage, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) : - damage(_damage), attackType(_attackType), hitOutCome(_hitOutCome) {} + damage(_damage), attackType(_attackType), hitOutCome(_hitOutCome) {} uint32 damage; WeaponAttackType attackType; @@ -808,8 +809,8 @@ struct CleanDamage // Need create structure like in SMSG_ATTACKERSTATEUPDATE opcode struct CalcDamageInfo { - Unit *attacker; // Attacker - Unit *target; // Target for damage + Unit* attacker; // Attacker + Unit* target; // Target for damage SpellSchoolMask damageSchoolMask; uint32 damage; uint32 absorb; @@ -827,14 +828,15 @@ struct CalcDamageInfo }; // Spell damage info structure based on structure sending in SMSG_SPELLNONMELEEDAMAGELOG opcode -struct SpellNonMeleeDamage{ - SpellNonMeleeDamage(Unit *_attacker, Unit *_target, uint32 _SpellID, SpellSchoolMask _schoolMask) +struct SpellNonMeleeDamage +{ + SpellNonMeleeDamage(Unit* _attacker, Unit* _target, uint32 _SpellID, SpellSchoolMask _schoolMask) : target(_target), attacker(_attacker), SpellID(_SpellID), damage(0), schoolMask(_schoolMask), - absorb(0), resist(0), physicalLog(false), unused(false), blocked(0), HitInfo(0) + absorb(0), resist(0), physicalLog(false), unused(false), blocked(0), HitInfo(0) {} - Unit *target; - Unit *attacker; + Unit* target; + Unit* attacker; uint32 SpellID; uint32 damage; SpellSchoolMask schoolMask; @@ -848,10 +850,10 @@ struct SpellNonMeleeDamage{ struct SpellPeriodicAuraLogInfo { - SpellPeriodicAuraLogInfo(Aura *_aura, uint32 _damage, uint32 _overDamage, uint32 _absorb, uint32 _resist, float _multiplier, bool _critical = false) + SpellPeriodicAuraLogInfo(Aura* _aura, uint32 _damage, uint32 _overDamage, uint32 _absorb, uint32 _resist, float _multiplier, bool _critical = false) : aura(_aura), damage(_damage), overDamage(_overDamage), absorb(_absorb), resist(_resist), multiplier(_multiplier), critical(_critical) {} - Aura *aura; + Aura* aura; uint32 damage; uint32 overDamage; // overkill/overheal uint32 absorb; @@ -860,7 +862,7 @@ struct SpellPeriodicAuraLogInfo bool critical; }; -uint32 createProcExtendMask(SpellNonMeleeDamage *damageInfo, SpellMissInfo missCondition); +uint32 createProcExtendMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missCondition); enum SpellAuraProcResult { @@ -869,7 +871,7 @@ enum SpellAuraProcResult SPELL_AURA_PROC_CANT_TRIGGER = 2 // aura can't trigger - skip charges taking, move to next aura if exists }; -typedef SpellAuraProcResult(Unit::*pAuraProcHandler)(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); +typedef SpellAuraProcResult(Unit::*pAuraProcHandler)(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); extern pAuraProcHandler AuraProcHandler[TOTAL_AURAS]; #define MAX_DECLINED_NAME_CASES 5 @@ -1006,7 +1008,7 @@ struct CharmInfo void InitPetActionBar(); void InitEmptyActionBar(); - //return true if successful + //return true if successful bool AddSpellToActionBar(uint32 spellid, ActiveStates newstate = ACT_DECIDE); bool RemoveSpellFromActionBar(uint32 spell_id); void LoadPetActionBar(const std::string& data); @@ -1082,14 +1084,14 @@ class MANGOS_DLL_SPEC Unit : public WorldObject typedef std::multimap< uint32, SpellAuraHolder*> SpellAuraHolderMap; typedef std::pair SpellAuraHolderBounds; typedef std::pair SpellAuraHolderConstBounds; - typedef std::list SpellAuraHolderList; - typedef std::list AuraList; + typedef std::list SpellAuraHolderList; + typedef std::list AuraList; typedef std::list Diminishing; typedef std::set ComboPointHolderSet; typedef std::map VisibleAuraMap; typedef std::map SingleCastSpellTargetMap; - virtual ~Unit ( ); + virtual ~Unit(); void AddToWorld(); void RemoveFromWorld(); @@ -1103,7 +1105,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject DiminishingLevels GetDiminishing(DiminishingGroup group); void IncrDiminishing(DiminishingGroup group); - void ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster, DiminishingLevels Level, int32 limitduration, bool isReflected); + void ApplyDiminishingToDuration(DiminishingGroup group, int32& duration,Unit* caster, DiminishingLevels Level, int32 limitduration, bool isReflected); void ApplyDiminishingAura(DiminishingGroup group, bool apply); void ClearDiminishings() { m_Diminishing.clear(); } @@ -1120,7 +1122,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject if (IsInFeralForm()) return false; - switch(attackType) + switch (attackType) { default: case BASE_ATTACK: @@ -1134,17 +1136,17 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool CanReachWithMeleeAttack(Unit* pVictim, float flat_mod = 0.0f) const; uint32 m_extraAttacks; - void _addAttacker(Unit *pAttacker) // must be called only from Unit::Attack(Unit*) + void _addAttacker(Unit* pAttacker) // must be called only from Unit::Attack(Unit*) { AttackerSet::const_iterator itr = m_attackers.find(pAttacker); - if(itr == m_attackers.end()) + if (itr == m_attackers.end()) m_attackers.insert(pAttacker); } - void _removeAttacker(Unit *pAttacker) // must be called only from Unit::AttackStop() + void _removeAttacker(Unit* pAttacker) // must be called only from Unit::AttackStop() { m_attackers.erase(pAttacker); } - Unit * getAttackerForHelper() // If someone wants to help, who to give them + Unit* getAttackerForHelper() // If someone wants to help, who to give them { if (getVictim() != NULL) return getVictim(); @@ -1154,7 +1156,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject return NULL; } - bool Attack(Unit *victim, bool meleeAttack); + bool Attack(Unit* victim, bool meleeAttack); void AttackedBy(Unit* attacker); void CastStop(uint32 except_spellid = 0); bool AttackStop(bool targetSwitch = false); @@ -1199,16 +1201,16 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); } uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); } float GetHealthPercent() const { return (GetHealth()*100.0f) / GetMaxHealth(); } - void SetHealth( uint32 val); + void SetHealth(uint32 val); void SetMaxHealth(uint32 val); void SetHealthPercent(float percent); int32 ModifyHealth(int32 val); Powers getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, 3)); } void setPowerType(Powers power); - uint32 GetPower( Powers power) const { return GetUInt32Value(UNIT_FIELD_POWER1 +power); } + uint32 GetPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_POWER1 +power); } uint32 GetMaxPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_MAXPOWER1+power); } - void SetPower( Powers power, uint32 val); + void SetPower(Powers power, uint32 val); void SetMaxPower(Powers power, uint32 val); int32 ModifyPower(Powers power, int32 val); void ApplyPowerMod(Powers power, uint32 val, bool apply); @@ -1220,11 +1222,11 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void ApplyCastTimePercentMod(float val, bool apply); SheathState GetSheath() const { return SheathState(GetByteValue(UNIT_FIELD_BYTES_2, 0)); } - virtual void SetSheath( SheathState sheathed ) { SetByteValue(UNIT_FIELD_BYTES_2, 0, sheathed); } + virtual void SetSheath(SheathState sheathed) { SetByteValue(UNIT_FIELD_BYTES_2, 0, sheathed); } // faction template id uint32 getFaction() const { return GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE); } - void setFaction(uint32 faction) { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction ); } + void setFaction(uint32 faction) { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction); } FactionTemplateEntry const* getFactionTemplateEntry() const; bool IsHostileTo(Unit const* unit) const; bool IsHostileToPlayers() const; @@ -1232,7 +1234,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool IsNeutralToAll() const; bool IsContestedGuard() const { - if(FactionTemplateEntry const* entry = getFactionTemplateEntry()) + if (FactionTemplateEntry const* entry = getFactionTemplateEntry()) return entry->IsContestedGuardFaction(); return false; @@ -1256,7 +1258,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void SetStandFlags(uint8 flags) { SetByteFlag(UNIT_FIELD_BYTES_1, 2,flags); } void RemoveStandFlags(uint8 flags) { RemoveByteFlag(UNIT_FIELD_BYTES_1, 2,flags); } - bool IsMounted() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT ); } + bool IsMounted() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT); } uint32 GetMountID() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); } void Mount(uint32 mount, uint32 spellId = 0); void Unmount(bool from_aura = false); @@ -1266,29 +1268,29 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void SetVehicleId(uint32 entry); uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? GetLevelForTarget(target) : getLevel()) * 5; } - void DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb); - uint32 DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss); - int32 DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellProto, bool critical = false, uint32 absorb = 0); + void DealDamageMods(Unit* pVictim, uint32& damage, uint32* absorb); + uint32 DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const* spellProto, bool durabilityLoss); + int32 DealHeal(Unit* pVictim, uint32 addhealth, SpellEntry const* spellProto, bool critical = false, uint32 absorb = 0); void PetOwnerKilledUnit(Unit* pVictim); - void ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType = BASE_ATTACK, SpellEntry const *procSpell = NULL); - void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage ); + void ProcDamageAndSpell(Unit* pVictim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType = BASE_ATTACK, SpellEntry const* procSpell = NULL); + void ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const* procSpell, uint32 damage); void HandleEmote(uint32 emote_id); // auto-select command/state void HandleEmoteCommand(uint32 emote_id); void HandleEmoteState(uint32 emote_id); - void AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType = BASE_ATTACK, bool extra = false ); + void AttackerStateUpdate(Unit* pVictim, WeaponAttackType attType = BASE_ATTACK, bool extra = false); - float MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const; + float MeleeMissChanceCalc(const Unit* pVictim, WeaponAttackType attType) const; - void CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType = BASE_ATTACK); - void DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss); + void CalculateMeleeDamage(Unit* pVictim, uint32 damage, CalcDamageInfo* damageInfo, WeaponAttackType attackType = BASE_ATTACK); + void DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss); - bool IsAllowedDamageInArea(Unit * pVictim) const; + bool IsAllowedDamageInArea(Unit* pVictim) const; - void CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType = BASE_ATTACK); - void DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss); + void CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 damage, SpellEntry const* spellInfo, WeaponAttackType attackType = BASE_ATTACK); + void DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss); // player or player's pet resilience (-1%) float GetMeleeCritChanceReduction() const { return GetCombatRatingReduction(CR_CRIT_TAKEN_MELEE); } @@ -1305,15 +1307,15 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint32 GetRangedDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_MELEE, 2.0f, 100.0f, damage); } uint32 GetSpellDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_MELEE, 2.0f, 100.0f, damage); } - float MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32 skillDiff, SpellEntry const *spell); - SpellMissInfo MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell); - SpellMissInfo MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell); - SpellMissInfo SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool canReflect = false); + float MeleeSpellMissChance(Unit* pVictim, WeaponAttackType attType, int32 skillDiff, SpellEntry const* spell); + SpellMissInfo MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell); + SpellMissInfo MagicSpellHitResult(Unit* pVictim, SpellEntry const* spell); + SpellMissInfo SpellHitResult(Unit* pVictim, SpellEntry const* spell, bool canReflect = false); float GetUnitDodgeChance() const; float GetUnitParryChance() const; float GetUnitBlockChance() const; - float GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVictim) const; + float GetUnitCriticalChance(WeaponAttackType attackType, const Unit* pVictim) const; virtual uint32 GetShieldBlockValue() const =0; uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? GetLevelForTarget(target) : getLevel()) * 5; } @@ -1322,32 +1324,32 @@ class MANGOS_DLL_SPEC Unit : public WorldObject float GetWeaponProcChance() const; float GetPPMProcChance(uint32 WeaponSpeed, float PPM) const; - MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType) const; - MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance) const; + MeleeHitOutcome RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackType attType) const; + MeleeHitOutcome RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance) const; - bool isVendor() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR ); } - bool isTrainer() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER ); } - bool isQuestGiver() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER ); } - bool isGossip() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP ); } - bool isTaxi() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_FLIGHTMASTER ); } - bool isGuildMaster() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PETITIONER ); } - bool isBattleMaster() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BATTLEMASTER ); } - bool isBanker() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BANKER ); } - bool isInnkeeper() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_INNKEEPER ); } - bool isSpiritHealer() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER ); } - bool isSpiritGuide() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITGUIDE ); } - bool isTabardDesigner()const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TABARDDESIGNER ); } - bool isAuctioner() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_AUCTIONEER ); } - bool isArmorer() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_REPAIR ); } + bool isVendor() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR); } + bool isTrainer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER); } + bool isQuestGiver() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); } + bool isGossip() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); } + bool isTaxi() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_FLIGHTMASTER); } + bool isGuildMaster() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PETITIONER); } + bool isBattleMaster() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BATTLEMASTER); } + bool isBanker() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BANKER); } + bool isInnkeeper() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_INNKEEPER); } + bool isSpiritHealer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER); } + bool isSpiritGuide() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITGUIDE); } + bool isTabardDesigner()const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TABARDDESIGNER); } + bool isAuctioner() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_AUCTIONEER); } + bool isArmorer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_REPAIR); } bool isServiceProvider() const { - return HasFlag( UNIT_NPC_FLAGS, - UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER | - UNIT_NPC_FLAG_PETITIONER | UNIT_NPC_FLAG_BATTLEMASTER | UNIT_NPC_FLAG_BANKER | - UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_SPIRITHEALER | - UNIT_NPC_FLAG_SPIRITGUIDE | UNIT_NPC_FLAG_TABARDDESIGNER | UNIT_NPC_FLAG_AUCTIONEER ); + return HasFlag(UNIT_NPC_FLAGS, + UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER | + UNIT_NPC_FLAG_PETITIONER | UNIT_NPC_FLAG_BATTLEMASTER | UNIT_NPC_FLAG_BANKER | + UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_SPIRITHEALER | + UNIT_NPC_FLAG_SPIRITGUIDE | UNIT_NPC_FLAG_TABARDDESIGNER | UNIT_NPC_FLAG_AUCTIONEER); } - bool isSpiritService() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE ); } + bool isSpiritService() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE); } bool IsTaxiFlying() const { return hasUnitState(UNIT_STAT_TAXI_FLIGHT); } @@ -1384,7 +1386,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool IsPolymorphed() const; bool isFrozen() const; - bool IsIgnoreUnitState(SpellEntry const *spell, IgnoreUnitState ignoreState); + bool IsIgnoreUnitState(SpellEntry const* spell, IgnoreUnitState ignoreState); bool isTargetableForAttack(bool inversAlive = false) const; bool isPassiveToHostile() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE); } @@ -1393,25 +1395,25 @@ class MANGOS_DLL_SPEC Unit : public WorldObject virtual bool IsUnderWater() const; bool isInAccessablePlaceFor(Creature const* c) const; - void SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, uint32 OverHeal, bool critical = false, uint32 absorb = 0); - void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype); - void EnergizeBySpell(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype); - uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage); - void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); - void CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); - void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); - void CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); - void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); - void CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void SendHealSpellLog(Unit* pVictim, uint32 SpellID, uint32 Damage, uint32 OverHeal, bool critical = false, uint32 absorb = 0); + void SendEnergizeSpellLog(Unit* pVictim, uint32 SpellID, uint32 Damage,Powers powertype); + void EnergizeBySpell(Unit* pVictim, uint32 SpellID, uint32 Damage, Powers powertype); + uint32 SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage); + void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void CastSpell(Unit* Victim,SpellEntry const* spellInfo, bool triggered, Item* castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void CastCustomSpell(Unit* Victim,SpellEntry const* spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void CastSpell(float x, float y, float z, SpellEntry const* spellInfo, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); void DeMorph(); - void SendAttackStateUpdate(CalcDamageInfo *damageInfo); - void SendAttackStateUpdate(uint32 HitInfo, Unit *target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount); - void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage *log); - void SendSpellNonMeleeDamageLog(Unit *target,uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false); - void SendPeriodicAuraLog(SpellPeriodicAuraLogInfo *pInfo); - void SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo); + void SendAttackStateUpdate(CalcDamageInfo* damageInfo); + void SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount); + void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log); + void SendSpellNonMeleeDamageLog(Unit* target,uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false); + void SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* pInfo); + void SendSpellMiss(Unit* target, uint32 spellID, SpellMissInfo missInfo); void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false); void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath = false, bool forceDestination = false); @@ -1431,7 +1433,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void SendThreatUpdate(); bool isAlive() const { return (m_deathState == ALIVE); }; - bool isDead() const { return ( m_deathState == DEAD || m_deathState == CORPSE ); }; + bool isDead() const { return (m_deathState == DEAD || m_deathState == CORPSE); }; DeathState getDeathState() const { return m_deathState; }; virtual void SetDeathState(DeathState s); // overwritten in Creature/Player/Pet @@ -1476,7 +1478,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject Unit* GetCharmerOrOwner() const { return GetCharmerGuid() ? GetCharmer() : GetOwner(); } Unit* GetCharmerOrOwnerOrSelf() { - if(Unit* u = GetCharmerOrOwner()) + if (Unit* u = GetCharmerOrOwner()) return u; return this; @@ -1484,7 +1486,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool IsCharmerOrOwnerPlayerOrPlayerItself() const; Player* GetCharmerOrOwnerPlayerOrPlayerItself(); Player const* GetCharmerOrOwnerPlayerOrPlayerItself() const; - float GetCombatDistance( const Unit* target ) const; + float GetCombatDistance(const Unit* target) const; void SetPet(Pet* pet); void SetCharm(Unit* pet); @@ -1512,21 +1514,21 @@ class MANGOS_DLL_SPEC Unit : public WorldObject template bool CheckAllControlledUnits(Func const& func, uint32 controlledMask) const; - bool AddSpellAuraHolder(SpellAuraHolder *holder); - void AddAuraToModList(Aura *aura); + bool AddSpellAuraHolder(SpellAuraHolder* holder); + void AddAuraToModList(Aura* aura); // removing specific aura stack void RemoveAura(Aura* aura, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveAura(uint32 spellId, SpellEffectIndex effindex, Aura* except = NULL); - void RemoveSpellAuraHolder(SpellAuraHolder *holder, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); - void RemoveSingleAuraFromSpellAuraHolder(SpellAuraHolder *holder, SpellEffectIndex index, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); + void RemoveSpellAuraHolder(SpellAuraHolder* holder, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); + void RemoveSingleAuraFromSpellAuraHolder(SpellAuraHolder* holder, SpellEffectIndex index, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveSingleAuraFromSpellAuraHolder(uint32 id, SpellEffectIndex index, ObjectGuid casterGuid, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); // removing specific aura stacks by diff reasons and selections void RemoveAurasDueToSpell(uint32 spellId, SpellAuraHolder* except = NULL, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId); void RemoveAurasByCasterSpell(uint32 spellId, ObjectGuid casterGuid); - void RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, Unit *stealer); + void RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, Unit* stealer); void RemoveAurasDueToSpellByCancel(uint32 spellId); // removing unknown aura stacks by diff reasons and selections @@ -1535,7 +1537,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void RemoveSpellsCausingAura(AuraType auraType); void RemoveSpellsCausingAura(AuraType auraType, SpellAuraHolder* except); void RemoveRankAurasDueToSpell(uint32 spellId); - bool RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder); + bool RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder* holder); void RemoveAurasWithInterruptFlags(uint32 flags); void RemoveAurasWithAttribute(uint32 flags); void RemoveAurasWithDispelType(DispelType type, ObjectGuid casterGuid = ObjectGuid()); @@ -1545,18 +1547,18 @@ class MANGOS_DLL_SPEC Unit : public WorldObject // removing specific aura FROM stack by diff reasons and selections void RemoveAuraHolderFromStack(uint32 spellId, uint32 stackAmount = 1, ObjectGuid casterGuid = ObjectGuid(), AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); - void RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount, ObjectGuid casterGuid, Unit *dispeller); + void RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount, ObjectGuid casterGuid, Unit* dispeller); void DelaySpellAuraHolder(uint32 spellId, int32 delaytime, ObjectGuid casterGuid); - float GetResistanceBuffMods(SpellSchools school, bool positive) const { return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school ); } + float GetResistanceBuffMods(SpellSchools school, bool positive) const { return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school); } void SetResistanceBuffMods(SpellSchools school, bool positive, float val) { SetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school,val); } void ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply) { ApplyModSignedFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); } void ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply) { ApplyPercentModFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); } void InitStatBuffMods() { - for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_POSSTAT0+i, 0); - for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_NEGSTAT0+i, 0); + for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_POSSTAT0+i, 0); + for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_NEGSTAT0+i, 0); } void ApplyStatBuffMod(Stats stat, float val, bool apply) { ApplyModSignedFloatValue((val > 0 ? UNIT_FIELD_POSSTAT0+stat : UNIT_FIELD_NEGSTAT0+stat), val, apply); } void ApplyStatPercentBuffMod(Stats stat, float val, bool apply) @@ -1574,8 +1576,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0+stat); } float GetCreateStat(Stats stat) const { return m_createStats[stat]; } - void SetCurrentCastedSpell(Spell * pSpell); - virtual void ProhibitSpellSchool(SpellSchoolMask /*idSchoolMask*/, uint32 /*unTimeMs*/ ) { } + void SetCurrentCastedSpell(Spell* pSpell); + virtual void ProhibitSpellSchool(SpellSchoolMask /*idSchoolMask*/, uint32 /*unTimeMs*/) { } void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true, bool sendAutoRepeatCancelToClient = true); void FinishSpell(CurrentSpellTypes spellType, bool ok = true); @@ -1611,7 +1613,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject { ShapeshiftForm form = GetShapeshiftForm(); return form != FORM_NONE && form != FORM_BATTLESTANCE && form != FORM_BERSERKERSTANCE && form != FORM_DEFENSIVESTANCE && - form != FORM_SHADOW; + form != FORM_SHADOW; } float m_modMeleeHitChance; @@ -1664,35 +1666,35 @@ class MANGOS_DLL_SPEC Unit : public WorldObject virtual bool IsVisibleInGridForPlayer(Player* pl) const = 0; bool isInvisibleForAlive() const; - SingleCastSpellTargetMap & GetSingleCastSpellTargets() { return m_singleCastSpellTargets; } + SingleCastSpellTargetMap& GetSingleCastSpellTargets() { return m_singleCastSpellTargets; } SingleCastSpellTargetMap const& GetSingleCastSpellTargets() const { return m_singleCastSpellTargets; } SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]; // Threat related methods bool CanHaveThreatList() const; - void AddThreat(Unit* pVictim, float threat = 0.0f, bool crit = false, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NONE, SpellEntry const *threatSpell = NULL); + void AddThreat(Unit* pVictim, float threat = 0.0f, bool crit = false, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NONE, SpellEntry const* threatSpell = NULL); float ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL); void DeleteThreatList(); bool IsSecondChoiceTarget(Unit* pTarget, bool checkThreatArea) const; bool SelectHostileTarget(); void TauntApply(Unit* pVictim); - void TauntFadeOut(Unit *taunter); + void TauntFadeOut(Unit* taunter); ThreatManager& getThreatManager() { return m_ThreatManager; } ThreatManager const& getThreatManager() const { return m_ThreatManager; } void addHatedBy(HostileReference* pHostileReference) { m_HostileRefManager.insertFirst(pHostileReference); }; - void removeHatedBy(HostileReference* /*pHostileReference*/ ) { /* nothing to do yet */ } + void removeHatedBy(HostileReference* /*pHostileReference*/) { /* nothing to do yet */ } HostileRefManager& getHostileRefManager() { return m_HostileRefManager; } uint32 GetVisibleAura(uint8 slot) const { VisibleAuraMap::const_iterator itr = m_visibleAuras.find(slot); - if(itr != m_visibleAuras.end()) + if (itr != m_visibleAuras.end()) return itr->second; return 0; } void SetVisibleAura(uint8 slot, uint32 spellid) { - if(spellid == 0) + if (spellid == 0) m_visibleAuras.erase(slot); else m_visibleAuras[slot] = spellid; @@ -1702,10 +1704,10 @@ class MANGOS_DLL_SPEC Unit : public WorldObject Aura* GetAura(uint32 spellId, SpellEffectIndex effindex); Aura* GetAura(AuraType type, SpellFamily family, uint64 familyFlag, uint32 familyFlag2 = 0, ObjectGuid casterGuid = ObjectGuid()); - SpellAuraHolder* GetSpellAuraHolder (uint32 spellid) const; - SpellAuraHolder* GetSpellAuraHolder (uint32 spellid, ObjectGuid casterGUID) const; + SpellAuraHolder* GetSpellAuraHolder(uint32 spellid) const; + SpellAuraHolder* GetSpellAuraHolder(uint32 spellid, ObjectGuid casterGUID) const; - SpellAuraHolderMap & GetSpellAuraHolderMap() { return m_spellAuraHolders; } + SpellAuraHolderMap& GetSpellAuraHolderMap() { return m_spellAuraHolders; } SpellAuraHolderMap const& GetSpellAuraHolderMap() const { return m_spellAuraHolders; } AuraList const& GetAurasByType(AuraType type) const { return m_modAuras[type]; } void ApplyAuraProcTriggerDamage(Aura* aura, bool apply); @@ -1762,47 +1764,47 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool HasAuraState(AuraState flag) const { return HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); } bool HasAuraStateForCaster(AuraState flag, ObjectGuid casterGuid) const; void UnsummonAllTotems(); - Unit* SelectMagnetTarget(Unit *victim, Spell* spell = NULL, SpellEffectIndex eff = EFFECT_INDEX_0); + Unit* SelectMagnetTarget(Unit* victim, Spell* spell = NULL, SpellEffectIndex eff = EFFECT_INDEX_0); - int32 SpellBonusWithCoeffs(SpellEntry const *spellProto, int32 total, int32 benefit, int32 ap_benefit, DamageEffectType damagetype, bool donePart, float defCoeffMod = 1.0f); + int32 SpellBonusWithCoeffs(SpellEntry const* spellProto, int32 total, int32 benefit, int32 ap_benefit, DamageEffectType damagetype, bool donePart, float defCoeffMod = 1.0f); int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask); int32 SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask); - uint32 SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1); - uint32 SpellDamageBonusTaken(Unit *pCaster, SpellEntry const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1); + uint32 SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1); + uint32 SpellDamageBonusTaken(Unit* pCaster, SpellEntry const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1); int32 SpellBaseHealingBonusDone(SpellSchoolMask schoolMask); int32 SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask); - uint32 SpellHealingBonusDone(Unit *pVictim, SpellEntry const *spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack = 1); - uint32 SpellHealingBonusTaken(Unit *pCaster, SpellEntry const *spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack = 1); - uint32 MeleeDamageBonusDone(Unit *pVictim, uint32 damage, WeaponAttackType attType, SpellEntry const *spellProto = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, uint32 stack = 1); - uint32 MeleeDamageBonusTaken(Unit *pCaster, uint32 pdamage,WeaponAttackType attType, SpellEntry const *spellProto = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, uint32 stack = 1); + uint32 SpellHealingBonusDone(Unit* pVictim, SpellEntry const* spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack = 1); + uint32 SpellHealingBonusTaken(Unit* pCaster, SpellEntry const* spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack = 1); + uint32 MeleeDamageBonusDone(Unit* pVictim, uint32 damage, WeaponAttackType attType, SpellEntry const* spellProto = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, uint32 stack = 1); + uint32 MeleeDamageBonusTaken(Unit* pCaster, uint32 pdamage,WeaponAttackType attType, SpellEntry const* spellProto = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, uint32 stack = 1); - bool IsSpellBlocked(Unit *pCaster, SpellEntry const *spellProto, WeaponAttackType attackType = BASE_ATTACK); - bool IsSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType = BASE_ATTACK); - uint32 SpellCriticalDamageBonus(SpellEntry const *spellProto, uint32 damage, Unit *pVictim); - uint32 SpellCriticalHealingBonus(SpellEntry const *spellProto, uint32 damage, Unit *pVictim); + bool IsSpellBlocked(Unit* pCaster, SpellEntry const* spellProto, WeaponAttackType attackType = BASE_ATTACK); + bool IsSpellCrit(Unit* pVictim, SpellEntry const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType = BASE_ATTACK); + uint32 SpellCriticalDamageBonus(SpellEntry const* spellProto, uint32 damage, Unit* pVictim); + uint32 SpellCriticalHealingBonus(SpellEntry const* spellProto, uint32 damage, Unit* pVictim); - bool IsTriggeredAtSpellProcEvent(Unit *pVictim, SpellAuraHolder* holder, SpellEntry const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, SpellProcEventEntry const*& spellProcEvent ); + bool IsTriggeredAtSpellProcEvent(Unit* pVictim, SpellAuraHolder* holder, SpellEntry const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, SpellProcEventEntry const*& spellProcEvent); // Aura proc handlers - SpellAuraProcResult HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleHasteAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleSpellCritChanceAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleProcTriggerDamageAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleOverrideClassScriptAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleMendingAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleModCastingSpeedNotStackAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleReflectSpellsSchoolAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleModPowerCostSchoolAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleMechanicImmuneResistanceAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleModDamageFromCasterAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleAddFlatModifierAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleAddPctModifierAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleModDamagePercentDoneAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleModRating(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleSpellMagnetAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleManaShieldAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleModResistanceAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); - SpellAuraProcResult HandleRemoveByDamageChanceProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleHasteAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleSpellCritChanceAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleProcTriggerDamageAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleOverrideClassScriptAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleMendingAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleModCastingSpeedNotStackAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleReflectSpellsSchoolAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleModPowerCostSchoolAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleMechanicImmuneResistanceAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleModDamageFromCasterAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleAddFlatModifierAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleAddPctModifierAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleModDamagePercentDoneAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleModRating(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleSpellMagnetAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleManaShieldAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleModResistanceAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); + SpellAuraProcResult HandleRemoveByDamageChanceProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); SpellAuraProcResult HandleNULLProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* /*triggeredByAura*/, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/) { // no proc handler for this aura type @@ -1825,24 +1827,24 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint32 GetRegenTimer() const { return m_regenTimer; } - void SetContestedPvP(Player *attackedPlayer = NULL); + void SetContestedPvP(Player* attackedPlayer = NULL); void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply); - void ApplySpellDispelImmunity(const SpellEntry * spellProto, DispelType type, bool apply); + void ApplySpellDispelImmunity(const SpellEntry* spellProto, DispelType type, bool apply); virtual bool IsImmuneToSpell(SpellEntry const* spellInfo); - // redefined in Creature + // redefined in Creature bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask); virtual bool IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const; - // redefined in Creature + // redefined in Creature uint32 CalcArmorReducedDamage(Unit* pVictim, const uint32 damage); - void CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist, bool canReflect = false); - void CalculateAbsorbResistBlock(Unit *pCaster, SpellNonMeleeDamage *damageInfo, SpellEntry const* spellProto, WeaponAttackType attType = BASE_ATTACK); - void CalculateHealAbsorb(uint32 heal, uint32 *absorb); + void CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32* absorb, uint32* resist, bool canReflect = false); + void CalculateAbsorbResistBlock(Unit* pCaster, SpellNonMeleeDamage* damageInfo, SpellEntry const* spellProto, WeaponAttackType attType = BASE_ATTACK); + void CalculateHealAbsorb(uint32 heal, uint32* absorb); void UpdateSpeed(UnitMoveType mtype, bool forced, float ratio = 1.0f); - float GetSpeed( UnitMoveType mtype ) const; - float GetSpeedRate( UnitMoveType mtype ) const { return m_speed_rate[mtype]; } + float GetSpeed(UnitMoveType mtype) const; + float GetSpeedRate(UnitMoveType mtype) const { return m_speed_rate[mtype]; } void SetSpeedRate(UnitMoveType mtype, float rate, bool forced = false); void KnockBackFrom(Unit* target, float horizontalSpeed, float verticalSpeed); @@ -1852,14 +1854,14 @@ class MANGOS_DLL_SPEC Unit : public WorldObject int32 CalculateSpellDamage(Unit const* target, SpellEntry const* spellProto, SpellEffectIndex effect_index, int32 const* basePoints = NULL); - uint32 CalcNotIgnoreAbsorbDamage( uint32 damage, SpellSchoolMask damageSchoolMask, SpellEntry const* spellInfo = NULL); + uint32 CalcNotIgnoreAbsorbDamage(uint32 damage, SpellSchoolMask damageSchoolMask, SpellEntry const* spellInfo = NULL); uint32 CalcNotIgnoreDamageReduction(uint32 damage, SpellSchoolMask damageSchoolMask); int32 CalculateAuraDuration(SpellEntry const* spellProto, uint32 effectMask, int32 duration, Unit const* caster); float CalculateLevelPenalty(SpellEntry const* spellProto) const; void addFollower(FollowerReference* pRef) { m_FollowingRefManager.insertFirst(pRef); } - void removeFollower(FollowerReference* /*pRef*/ ) { /* nothing to do yet */ } + void removeFollower(FollowerReference* /*pRef*/) { /* nothing to do yet */ } MotionMaster* GetMotionMaster() { return &i_motionMaster; } @@ -1876,8 +1878,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject ///----------Pet responses methods----------------- void SendPetCastFail(uint32 spellid, SpellCastResult msg); - void SendPetActionFeedback (uint8 msg); - void SendPetTalk (uint32 pettalk); + void SendPetActionFeedback(uint8 msg); + void SendPetTalk(uint32 pettalk); void SendPetAIReaction(); ///----------End of Pet responses methods---------- @@ -1885,7 +1887,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject // reactive attacks void ClearAllReactives(); - void StartReactiveTimer( ReactiveType reactive ) { m_reactiveTimer[reactive] = REACTIVE_TIMER_START;} + void StartReactiveTimer(ReactiveType reactive) { m_reactiveTimer[reactive] = REACTIVE_TIMER_START;} void UpdateReactives(uint32 p_time); // group updates @@ -1899,7 +1901,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject // Movement info MovementInfo m_movementInfo; - Movement::MoveSpline * movespline; + Movement::MoveSpline* movespline; void ScheduleAINotify(uint32 delay); bool IsAINotifyScheduled() const { return m_AINotifyScheduled;} @@ -1909,7 +1911,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool IsLinkingEventTrigger() const { return m_isCreatureLinkingTrigger; } protected: - explicit Unit (); + explicit Unit(); void _UpdateSpells(uint32 time); void _UpdateAutoRepeatSpell(); @@ -1948,7 +1950,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject float m_speed_rate[MAX_MOVE_TYPE]; - CharmInfo *m_charmInfo; + CharmInfo* m_charmInfo; virtual SpellSchoolMask GetMeleeDamageSchoolMask() const; @@ -2039,7 +2041,7 @@ void Unit::CallForAllControlledUnits(Func const& func, uint32 controlledMask) if (controlledMask & CONTROLLED_TOTEMS) { for (int i = 0; i < MAX_TOTEM_SLOT; ++i) - if (Unit *totem = _GetTotem(TotemSlot(i))) + if (Unit* totem = _GetTotem(TotemSlot(i))) func(totem); } @@ -2058,7 +2060,7 @@ bool Unit::CheckAllControlledUnits(Func const& func, uint32 controlledMask) cons return true; if (controlledMask & CONTROLLED_MINIPET) - if(Unit const* mini = GetMiniPet()) + if (Unit const* mini = GetMiniPet()) if (func(mini)) return true; diff --git a/src/game/UnitAuraProcHandler.cpp b/src/game/UnitAuraProcHandler.cpp index 342508e49..60b83c24a 100644 --- a/src/game/UnitAuraProcHandler.cpp +++ b/src/game/UnitAuraProcHandler.cpp @@ -351,9 +351,9 @@ pAuraProcHandler AuraProcHandler[TOTAL_AURAS]= &Unit::HandleNULLProc //316 makes haste affect HOT/DOT ticks }; -bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, SpellAuraHolder* holder, SpellEntry const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, SpellProcEventEntry const*& spellProcEvent ) +bool Unit::IsTriggeredAtSpellProcEvent(Unit* pVictim, SpellAuraHolder* holder, SpellEntry const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, SpellProcEventEntry const*& spellProcEvent) { - SpellEntry const* spellProto = holder->GetSpellProto (); + SpellEntry const* spellProto = holder->GetSpellProto(); // Get proc Event Entry spellProcEvent = sSpellMgr.GetSpellProcEvent(spellProto->Id); @@ -369,7 +369,7 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, SpellAuraHolder* holder, S return false; // Check spellProcEvent data requirements - if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, EventProcFlag, procSpell, procFlag, procExtra)) + if (!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, EventProcFlag, procSpell, procFlag, procExtra)) return false; // In most cases req get honor or XP from kill @@ -384,46 +384,46 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, SpellAuraHolder* holder, S } // Aura added by spell can`t trigger from self (prevent drop charges/do triggers) // But except periodic triggers (can triggered from self) - if(procSpell && procSpell->Id == spellProto->Id && !(EventProcFlag & PROC_FLAG_ON_TAKE_PERIODIC)) + if (procSpell && procSpell->Id == spellProto->Id && !(EventProcFlag & PROC_FLAG_ON_TAKE_PERIODIC)) return false; // Check if current equipment allows aura to proc - if(!isVictim && GetTypeId() == TYPEID_PLAYER) + if (!isVictim && GetTypeId() == TYPEID_PLAYER) { - if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) + if (spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) { - Item *item = NULL; - if(attType == BASE_ATTACK) + Item* item = NULL; + if (attType == BASE_ATTACK) item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); else if (attType == OFF_ATTACK) item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); else item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED); - if(!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_WEAPON || !((1<GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) + if (!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_WEAPON || !((1<GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) return false; } - else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) + else if (spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) { // Check if player is wearing shield - Item *item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - if(!item || item->IsBroken() || !CanUseEquippedWeapon(OFF_ATTACK) || item->GetProto()->Class != ITEM_CLASS_ARMOR || !((1<GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) + Item* item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + if (!item || item->IsBroken() || !CanUseEquippedWeapon(OFF_ATTACK) || item->GetProto()->Class != ITEM_CLASS_ARMOR || !((1<GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) return false; } } // Get chance from spell float chance = (float)spellProto->procChance; // If in spellProcEvent exist custom chance, chance = spellProcEvent->customChance; - if(spellProcEvent && spellProcEvent->customChance) + if (spellProcEvent && spellProcEvent->customChance) chance = spellProcEvent->customChance; // If PPM exist calculate chance from PPM - if(!isVictim && spellProcEvent && spellProcEvent->ppmRate != 0) + if (!isVictim && spellProcEvent && spellProcEvent->ppmRate != 0) { uint32 WeaponSpeed = GetAttackTime(attType); chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate); } // Apply chance modifier aura - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) { modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_FREQUENCY_OF_SUCCESS,chance); @@ -432,29 +432,29 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, SpellAuraHolder* holder, S return roll_chance_f(chance); } -SpellAuraProcResult Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 cooldown) +SpellAuraProcResult Unit::HandleHasteAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 cooldown) { - SpellEntry const *hasteSpell = triggeredByAura->GetSpellProto(); + SpellEntry const* hasteSpell = triggeredByAura->GetSpellProto(); Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER - ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; + ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; uint32 triggered_spell_id = 0; Unit* target = pVictim; int32 basepoints0 = 0; - switch(hasteSpell->SpellFamilyName) + switch (hasteSpell->SpellFamilyName) { case SPELLFAMILY_ROGUE: { - switch(hasteSpell->Id) + switch (hasteSpell->Id) { - // Blade Flurry + // Blade Flurry case 13877: case 33735: { target = SelectRandomUnfriendlyTarget(pVictim); - if(!target) + if (!target) return SPELL_AURA_PROC_FAILED; basepoints0 = damage; triggered_spell_id = 22482; @@ -466,12 +466,12 @@ SpellAuraProcResult Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, Aura } // processed charge only counting case - if(!triggered_spell_id) + if (!triggered_spell_id) return SPELL_AURA_PROC_OK; SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); - if(!triggerEntry) + if (!triggerEntry) { sLog.outError("Unit::HandleHasteAuraProc: Spell %u have nonexistent triggered spell %u",hasteSpell->Id,triggered_spell_id); return SPELL_AURA_PROC_FAILED; @@ -495,27 +495,27 @@ SpellAuraProcResult Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, Aura return SPELL_AURA_PROC_OK; } -SpellAuraProcResult Unit::HandleSpellCritChanceAuraProc(Unit *pVictim, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 cooldown) +SpellAuraProcResult Unit::HandleSpellCritChanceAuraProc(Unit* pVictim, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 cooldown) { if (!procSpell) return SPELL_AURA_PROC_FAILED; - SpellEntry const *triggeredByAuraSpell = triggeredByAura->GetSpellProto(); + SpellEntry const* triggeredByAuraSpell = triggeredByAura->GetSpellProto(); Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER - ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; + ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; uint32 triggered_spell_id = 0; Unit* target = pVictim; int32 basepoints0 = 0; - switch(triggeredByAuraSpell->SpellFamilyName) + switch (triggeredByAuraSpell->SpellFamilyName) { case SPELLFAMILY_MAGE: { - switch(triggeredByAuraSpell->Id) + switch (triggeredByAuraSpell->Id) { - // Focus Magic + // Focus Magic case 54646: { Unit* caster = triggeredByAura->GetCaster(); @@ -536,7 +536,7 @@ SpellAuraProcResult Unit::HandleSpellCritChanceAuraProc(Unit *pVictim, uint32 /* SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); - if(!triggerEntry) + if (!triggerEntry) { sLog.outError("Unit::HandleHasteAuraProc: Spell %u have nonexistent triggered spell %u",triggeredByAuraSpell->Id,triggered_spell_id); return SPELL_AURA_PROC_FAILED; @@ -560,27 +560,27 @@ SpellAuraProcResult Unit::HandleSpellCritChanceAuraProc(Unit *pVictim, uint32 /* return SPELL_AURA_PROC_OK; } -SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) +SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) { - SpellEntry const *dummySpell = triggeredByAura->GetSpellProto (); + SpellEntry const* dummySpell = triggeredByAura->GetSpellProto(); SpellEffectIndex effIndex = triggeredByAura->GetEffIndex(); int32 triggerAmount = triggeredByAura->GetModifier()->m_amount; Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER - ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; + ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; // some dummy spells have trigger spell in spell data already (from 3.0.3) uint32 triggered_spell_id = dummySpell->EffectApplyAuraName[effIndex] == SPELL_AURA_DUMMY ? dummySpell->EffectTriggerSpell[effIndex] : 0; Unit* target = pVictim; int32 basepoints[MAX_EFFECT_INDEX] = {0, 0, 0}; - switch(dummySpell->SpellFamilyName) + switch (dummySpell->SpellFamilyName) { case SPELLFAMILY_GENERIC: { switch (dummySpell->Id) { - // Eye for an Eye + // Eye for an Eye case 9799: case 25988: { @@ -601,7 +601,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; target = SelectRandomUnfriendlyTarget(pVictim); - if(!target) + if (!target) return SPELL_AURA_PROC_FAILED; triggered_spell_id = 26654; @@ -611,7 +611,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura case 21063: triggered_spell_id = 21064; break; - // Unstable Power + // Unstable Power case 24658: { if (!procSpell || procSpell->Id == 24659) @@ -630,27 +630,27 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Adaptive Warding (Frostfire Regalia set) case 28764: { - if(!procSpell) + if (!procSpell) return SPELL_AURA_PROC_FAILED; // find Mage Armor bool found = false; AuraList const& mRegenInterupt = GetAurasByType(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT); - for(AuraList::const_iterator iter = mRegenInterupt.begin(); iter != mRegenInterupt.end(); ++iter) + for (AuraList::const_iterator iter = mRegenInterupt.begin(); iter != mRegenInterupt.end(); ++iter) { - if(SpellEntry const* iterSpellProto = (*iter)->GetSpellProto()) + if (SpellEntry const* iterSpellProto = (*iter)->GetSpellProto()) { - if(iterSpellProto->SpellFamilyName==SPELLFAMILY_MAGE && (iterSpellProto->SpellFamilyFlags & UI64LIT(0x10000000))) + if (iterSpellProto->SpellFamilyName==SPELLFAMILY_MAGE && (iterSpellProto->SpellFamilyFlags & UI64LIT(0x10000000))) { found=true; break; } } } - if(!found) + if (!found) return SPELL_AURA_PROC_FAILED; - switch(GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) + switch (GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) { case SPELL_SCHOOL_NORMAL: case SPELL_SCHOOL_HOLY: @@ -670,10 +670,10 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Obsidian Armor (Justice Bearer`s Pauldrons shoulder) case 27539: { - if(!procSpell) + if (!procSpell) return SPELL_AURA_PROC_FAILED; - switch(GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) + switch (GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) { case SPELL_SCHOOL_NORMAL: return SPELL_AURA_PROC_FAILED; // ignore @@ -695,7 +695,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura { // Cast on owner target = GetOwner(); - if(!target) + if (!target) return SPELL_AURA_PROC_FAILED; triggered_spell_id = 34650; @@ -711,7 +711,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Remove any stun effect on target SpellAuraHolderMap& Auras = pVictim->GetSpellAuraHolderMap(); - for(SpellAuraHolderMap::const_iterator iter = Auras.begin(); iter != Auras.end();) + for (SpellAuraHolderMap::const_iterator iter = Auras.begin(); iter != Auras.end();) { if (iter->second->HasMechanic(MECHANIC_STUN)) { @@ -759,7 +759,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // 41409 Dementia: Every 5 seconds either gives you -5% damage/healing. (Druid, Shaman, Priest, Warlock, Mage, Paladin) case 39446: { - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) return SPELL_AURA_PROC_FAILED; // Select class defined buff @@ -768,14 +768,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura case CLASS_PALADIN: // 39511,40997,40998,40999,41002,41005,41009,41011,41409 case CLASS_DRUID: // 39511,40997,40998,40999,41002,41005,41009,41011,41409 { - uint32 RandomSpell[]={39511,40997,40998,40999,41002,41005,41009,41011,41409}; + uint32 RandomSpell[]= {39511,40997,40998,40999,41002,41005,41009,41011,41409}; triggered_spell_id = RandomSpell[urand(0, countof(RandomSpell)-1)]; break; } case CLASS_ROGUE: // 39511,40997,40998,41002,41005,41011 case CLASS_WARRIOR: // 39511,40997,40998,41002,41005,41011 { - uint32 RandomSpell[]={39511,40997,40998,41002,41005,41011}; + uint32 RandomSpell[]= {39511,40997,40998,41002,41005,41011}; triggered_spell_id = RandomSpell[urand(0, countof(RandomSpell)-1)]; break; } @@ -784,13 +784,13 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura case CLASS_MAGE: // 40999,41002,41005,41009,41011,41406,41409 case CLASS_WARLOCK: // 40999,41002,41005,41009,41011,41406,41409 { - uint32 RandomSpell[]={40999,41002,41005,41009,41011,41406,41409}; + uint32 RandomSpell[]= {40999,41002,41005,41009,41011,41406,41409}; triggered_spell_id = RandomSpell[urand(0, countof(RandomSpell)-1)]; break; } case CLASS_HUNTER: // 40997,40999,41002,41005,41009,41011,41406,41409 { - uint32 RandomSpell[]={40997,40999,41002,41005,41009,41011,41406,41409}; + uint32 RandomSpell[]= {40997,40999,41002,41005,41009,41011,41406,41409}; triggered_spell_id = RandomSpell[urand(0, countof(RandomSpell)-1)]; break; } @@ -808,30 +808,30 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // cast 45429 Arcane Bolt if Exalted by Scryers case 45481: { - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) return SPELL_AURA_PROC_FAILED; // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + if (((Player*)this)->GetReputationRank(932) == REP_EXALTED) { target = this; triggered_spell_id = 45479; break; } // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + if (((Player*)this)->GetReputationRank(934) == REP_EXALTED) { // triggered at positive/self casts also, current attack target used then - if(IsFriendlyTo(target)) + if (IsFriendlyTo(target)) { target = getVictim(); - if(!target) + if (!target) { - target = ObjectAccessor::GetUnit(*this,((Player *)this)->GetSelectionGuid()); - if(!target) + target = ObjectAccessor::GetUnit(*this,((Player*)this)->GetSelectionGuid()); + if (!target) return SPELL_AURA_PROC_FAILED; } - if(IsFriendlyTo(target)) + if (IsFriendlyTo(target)) return SPELL_AURA_PROC_FAILED; } @@ -845,18 +845,18 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // cast 45428 Arcane Strike if Exalted by Scryers case 45482: { - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) return SPELL_AURA_PROC_FAILED; // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + if (((Player*)this)->GetReputationRank(932) == REP_EXALTED) { target = this; triggered_spell_id = 45480; break; } // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + if (((Player*)this)->GetReputationRank(934) == REP_EXALTED) { triggered_spell_id = 45428; break; @@ -868,18 +868,18 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // cast 45432 Light's Ward if Exalted by Scryers case 45483: { - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) return SPELL_AURA_PROC_FAILED; // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + if (((Player*)this)->GetReputationRank(932) == REP_EXALTED) { target = this; triggered_spell_id = 45432; break; } // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + if (((Player*)this)->GetReputationRank(934) == REP_EXALTED) { target = this; triggered_spell_id = 45431; @@ -892,18 +892,18 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // cast 45430 Arcane Surge if Exalted by Scryers case 45484: { - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) return SPELL_AURA_PROC_FAILED; // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + if (((Player*)this)->GetReputationRank(932) == REP_EXALTED) { target = this; triggered_spell_id = 45478; break; } // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + if (((Player*)this)->GetReputationRank(934) == REP_EXALTED) { triggered_spell_id = 45430; break; @@ -916,7 +916,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // cast ??? Arcane Bolt if Exalted by Scryers*/ case 46569: return SPELL_AURA_PROC_FAILED; // old unused version - // Living Seed + // Living Seed case 48504: { triggered_spell_id = 48503; @@ -936,7 +936,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Shadowfiend Death (Gain mana if pet dies with Glyph of Shadowfiend) case 57989: { - Unit *owner = GetOwner(); + Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return SPELL_AURA_PROC_FAILED; @@ -959,27 +959,27 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura case 63320: triggered_spell_id = 63321; break; - // Meteor Fists + // Meteor Fists case 66725: case 68161: triggered_spell_id = 66765; break; - // Meteor Fists + // Meteor Fists case 66808: case 68160: triggered_spell_id = 66809; break; - // Shiny Shard of the Scale - Equip Effect + // Shiny Shard of the Scale - Equip Effect case 69739: // Cauterizing Heal or Searing Flame triggered_spell_id = (procFlag & PROC_FLAG_SUCCESSFUL_POSITIVE_SPELL) ? 69734 : 69730; break; - // Purified Shard of the Scale - Equip Effect + // Purified Shard of the Scale - Equip Effect case 69755: // Cauterizing Heal or Searing Flame triggered_spell_id = (procFlag & PROC_FLAG_SUCCESSFUL_POSITIVE_SPELL) ? 69733 : 69729; break; - // Item - Shadowmourne Legendary + // Item - Shadowmourne Legendary case 71903: { if (!roll_chance_i(triggerAmount)) @@ -987,7 +987,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura triggered_spell_id = 71905; // Soul Fragment - SpellAuraHolder *aurHolder = GetSpellAuraHolder(triggered_spell_id); + SpellAuraHolder* aurHolder = GetSpellAuraHolder(triggered_spell_id); // will added first to stack if (!aurHolder) @@ -1024,7 +1024,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Master of Elements if (dummySpell->SpellIconID == 1920) { - if(!procSpell) + if (!procSpell) return SPELL_AURA_PROC_FAILED; // mana cost save @@ -1041,7 +1041,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Arcane Potency if (dummySpell->SpellIconID == 2120) { - if(!procSpell) + if (!procSpell) return SPELL_AURA_PROC_FAILED; target = this; @@ -1061,12 +1061,12 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura { if (effIndex != EFFECT_INDEX_0) return SPELL_AURA_PROC_OK; - Aura *counter = GetAura(triggeredByAura->GetId(), EFFECT_INDEX_1); + Aura* counter = GetAura(triggeredByAura->GetId(), EFFECT_INDEX_1); if (!counter) return SPELL_AURA_PROC_OK; // Count spell criticals in a row in second aura - Modifier *mod = counter->GetModifier(); + Modifier* mod = counter->GetModifier(); if (procEx & PROC_EX_CRITICAL_HIT) { mod->m_amount *=2; @@ -1082,7 +1082,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Burnout if (dummySpell->SpellIconID == 2998) { - if(!procSpell) + if (!procSpell) return SPELL_AURA_PROC_FAILED; int32 cost = procSpell->manaCost + procSpell->ManaCostPercentage * GetCreateMana() / 100; @@ -1093,9 +1093,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura target = this; break; } - switch(dummySpell->Id) + switch (dummySpell->Id) { - // Ignite + // Ignite case 11119: case 11120: case 12846: @@ -1180,7 +1180,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura case 42770: triggered_spell_id=42771; break; default: sLog.outError("Unit::HandleDummyAuraProc: non handled spell id: %u (SW)",dummySpell->Id); - return SPELL_AURA_PROC_FAILED; + return SPELL_AURA_PROC_FAILED; } target = this; @@ -1198,11 +1198,11 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura if (dummySpell->Id == 12328) { // prevent chain of triggered spell from same triggered spell - if(procSpell && procSpell->Id == 26654) + if (procSpell && procSpell->Id == 26654) return SPELL_AURA_PROC_FAILED; target = SelectRandomUnfriendlyTarget(pVictim); - if(!target) + if (!target) return SPELL_AURA_PROC_FAILED; triggered_spell_id = 26654; @@ -1217,7 +1217,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura { Modifier* mod = triggeredByAura->GetModifier(); // if damage is more than need or target die from damage deal finish spell - if( mod->m_amount <= (int32)damage || GetHealth() <= damage ) + if (mod->m_amount <= (int32)damage || GetHealth() <= damage) { // remember guid before aura delete ObjectGuid casterGuid = triggeredByAura->GetCasterGuid(); @@ -1239,7 +1239,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura { Modifier* mod = triggeredByAura->GetModifier(); // if damage is more than need deal finish spell - if( mod->m_amount <= (int32)damage ) + if (mod->m_amount <= (int32)damage) { // remember guid before aura delete ObjectGuid casterGuid = triggeredByAura->GetCasterGuid(); @@ -1265,9 +1265,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura triggered_spell_id = 54181; break; } - switch(dummySpell->Id) + switch (dummySpell->Id) { - // Nightfall & Glyph of Corruption + // Nightfall & Glyph of Corruption case 18094: case 18095: case 56218: @@ -1315,7 +1315,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura case 63108: { // Glyph of Siphon Life - if (Aura *aur = GetAura(56216, EFFECT_INDEX_0)) + if (Aura* aur = GetAura(56216, EFFECT_INDEX_0)) triggerAmount += triggerAmount * aur->GetModifier()->m_amount / 100; basepoints[0] = int32(damage * triggerAmount / 100); @@ -1342,12 +1342,12 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura return SPELL_AURA_PROC_OK; // no hidden cooldown } - switch(dummySpell->SpellIconID) + switch (dummySpell->SpellIconID) { - // Improved Shadowform + // Improved Shadowform case 217: { - if(!roll_chance_i(triggerAmount)) + if (!roll_chance_i(triggerAmount)) return SPELL_AURA_PROC_FAILED; RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); @@ -1395,9 +1395,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura } } - switch(dummySpell->Id) + switch (dummySpell->Id) { - // Vampiric Embrace + // Vampiric Embrace case 15286: { // Return if self damage @@ -1437,7 +1437,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Frozen Shadoweave (Shadow's Embrace set) warning! its not only priest set case 39372: { - if(!procSpell || (GetSpellSchoolMask(procSpell) & (SPELL_SCHOOL_MASK_FROST | SPELL_SCHOOL_MASK_SHADOW))==0 ) + if (!procSpell || (GetSpellSchoolMask(procSpell) & (SPELL_SCHOOL_MASK_FROST | SPELL_SCHOOL_MASK_SHADOW))==0) return SPELL_AURA_PROC_FAILED; // heal amount @@ -1455,7 +1455,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Glyph of Dispel Magic case 55677: { - if(!target->IsFriendlyTo(this)) + if (!target->IsFriendlyTo(this)) return SPELL_AURA_PROC_FAILED; basepoints[0] = int32(target->GetMaxHealth() * triggerAmount / 100); @@ -1481,9 +1481,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura } case SPELLFAMILY_DRUID: { - switch(dummySpell->Id) + switch (dummySpell->Id) { - // Leader of the Pack + // Leader of the Pack case 24932: { // dummy m_amount store health percent (!=0 if Improved Leader of the Pack applied) @@ -1604,7 +1604,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura ((Player*)this)->ApplySpellMod(procSpell->Id, SPELLMOD_RADIUS, radius,NULL); - Unit *second = pVictim->SelectRandomFriendlyTarget(pVictim, radius); + Unit* second = pVictim->SelectRandomFriendlyTarget(pVictim, radius); if (!second) return SPELL_AURA_PROC_FAILED; @@ -1681,16 +1681,16 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura } case SPELLFAMILY_ROGUE: { - switch(dummySpell->Id) + switch (dummySpell->Id) { - // Clean Escape + // Clean Escape case 23582: // triggered spell have same masks and etc with main Vanish spell if (!procSpell || procSpell->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_NONE) return SPELL_AURA_PROC_FAILED; triggered_spell_id = 23583; break; - // Deadly Throw Interrupt + // Deadly Throw Interrupt case 32748: { // Prevent cast Deadly Throw Interrupt on self from last effect (apply dummy) of Deadly Throw @@ -1718,11 +1718,11 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // "refresh your Slice and Dice duration to its 5 combo point maximum" // lookup Slice and Dice AuraList const& sd = GetAurasByType(SPELL_AURA_MOD_MELEE_HASTE); - for(AuraList::const_iterator itr = sd.begin(); itr != sd.end(); ++itr) + for (AuraList::const_iterator itr = sd.begin(); itr != sd.end(); ++itr) { - SpellEntry const *spellProto = (*itr)->GetSpellProto(); + SpellEntry const* spellProto = (*itr)->GetSpellProto(); if (spellProto->SpellFamilyName == SPELLFAMILY_ROGUE && - (spellProto->SpellFamilyFlags & UI64LIT(0x0000000000040000))) + (spellProto->SpellFamilyFlags & UI64LIT(0x0000000000040000))) { (*itr)->GetHolder()->RefreshHolder(); return SPELL_AURA_PROC_OK; @@ -1739,7 +1739,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Quick Recovery if (dummySpell->SpellIconID == 2116) { - if(!procSpell) + if (!procSpell) return SPELL_AURA_PROC_FAILED; // energy cost save @@ -1779,7 +1779,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura break; } // Lock and Load - if ( dummySpell->SpellIconID == 3579 ) + if (dummySpell->SpellIconID == 3579) { // Proc only from periodic (from trap activation proc another aura of this spell) if (!(procFlag & PROC_FLAG_ON_DO_PERIODIC) || !roll_chance_i(triggerAmount)) @@ -1789,7 +1789,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura break; } // Rapid Recuperation - if ( dummySpell->SpellIconID == 3560 ) + if (dummySpell->SpellIconID == 3560) { // This effect only from Rapid Killing (mana regen) if (!(procSpell->SpellFamilyFlags & UI64LIT(0x0100000000000000))) @@ -1797,7 +1797,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura target = this; - switch(dummySpell->Id) + switch (dummySpell->Id) { case 53228: // Rank 1 triggered_spell_id = 56654; @@ -1809,13 +1809,13 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura break; } // Glyph of Mend Pet - if(dummySpell->Id == 57870) + if (dummySpell->Id == 57870) { pVictim->CastSpell(pVictim, 57894, true, NULL, NULL, GetObjectGuid()); return SPELL_AURA_PROC_OK; } // Misdirection - else if(dummySpell->Id == 34477) + else if (dummySpell->Id == 34477) { triggered_spell_id = 35079; // 4 sec buff on self target = this; @@ -1850,16 +1850,16 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura basepoints[0] = triggerAmount * damage / 100 / GetSpellAuraMaxTicks(triggered_spell_id); break; } - switch(dummySpell->Id) + switch (dummySpell->Id) { - // Judgement of Light + // Judgement of Light case 20185: { // only at real damage if (!damage) return SPELL_AURA_PROC_FAILED; - basepoints[0] = int32( pVictim->GetMaxHealth() * triggeredByAura->GetModifier()->m_amount / 100 ); + basepoints[0] = int32(pVictim->GetMaxHealth() * triggeredByAura->GetModifier()->m_amount / 100); pVictim->CastCustomSpell(pVictim, 20267, &basepoints[0], NULL, NULL, true, NULL, triggeredByAura); return SPELL_AURA_PROC_OK; } @@ -1882,11 +1882,11 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura case 20335: triggered_spell_id = 21183; break; - // Heart of the Crusader (Rank 2) + // Heart of the Crusader (Rank 2) case 20336: triggered_spell_id = 54498; break; - // Heart of the Crusader (Rank 3) + // Heart of the Crusader (Rank 3) case 20337: triggered_spell_id = 54499; break; @@ -1907,7 +1907,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Holy Power (Redemption Armor set) case 28789: { - if(!pVictim) + if (!pVictim) return SPELL_AURA_PROC_FAILED; // Set class defined buff @@ -1959,13 +1959,13 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; // At melee attack or Hammer of the Righteous spell damage considered as melee attack - if ((procFlag & PROC_FLAG_SUCCESSFUL_MELEE_HIT) || (procSpell && procSpell->Id == 53595) ) + if ((procFlag & PROC_FLAG_SUCCESSFUL_MELEE_HIT) || (procSpell && procSpell->Id == 53595)) triggered_spell_id = 31803; // Holy Vengeance // Add 5-stack effect from Holy Vengeance uint32 stacks = 0; AuraList const& auras = target->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); - for(AuraList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (AuraList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) { if (((*itr)->GetId() == 31803) && (*itr)->GetCasterGuid() == GetObjectGuid()) { @@ -1982,7 +1982,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura case 31877: case 31878: // triggered only at casted Judgement spells, not at additional Judgement effects - if(!procSpell || procSpell->Category != 1210) + if (!procSpell || procSpell->Category != 1210) return SPELL_AURA_PROC_FAILED; target = this; @@ -1991,7 +1991,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Replenishment CastSpell(this, 57669, true, NULL, triggeredByAura); break; - // Paladin Tier 6 Trinket (Ashtongue Talisman of Zeal) + // Paladin Tier 6 Trinket (Ashtongue Talisman of Zeal) case 40470: { if (!procSpell) @@ -2034,7 +2034,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // find caster main aura at beacon Aura* dummy = NULL; Unit::AuraList const& baa = beacon->GetAurasByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL); - for(Unit::AuraList::const_iterator i = baa.begin(); i != baa.end(); ++i) + for (Unit::AuraList::const_iterator i = baa.begin(); i != baa.end(); ++i) { if ((*i)->GetId() == 53563 && (*i)->GetCasterGuid() == pVictim->GetObjectGuid()) { @@ -2067,7 +2067,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Add 5-stack effect from Blood Corruption uint32 stacks = 0; AuraList const& auras = target->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); - for(AuraList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (AuraList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) { if (((*itr)->GetId() == 53742) && (*itr)->GetCasterGuid() == GetObjectGuid()) { @@ -2120,7 +2120,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; uint32 maxStack = mote->StackAmount - (dummySpell->Id == 71545 ? 1 : 0); - SpellAuraHolder *aurHolder = GetSpellAuraHolder(71432); + SpellAuraHolder* aurHolder = GetSpellAuraHolder(71432); if (aurHolder && uint32(aurHolder->GetStackAmount() +1) >= maxStack) { RemoveAurasDueToSpell(71432); // Mote of Anger @@ -2137,7 +2137,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Heartpierce, Item - Icecrown 25 Normal Dagger Proc case 71880: { - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) return SPELL_AURA_PROC_FAILED; switch (this->getPowerType()) @@ -2153,7 +2153,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Heartpierce, Item - Icecrown 25 Heroic Dagger Proc case 71892: { - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) return SPELL_AURA_PROC_FAILED; switch (this->getPowerType()) @@ -2171,12 +2171,12 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura } case SPELLFAMILY_SHAMAN: { - switch(dummySpell->Id) + switch (dummySpell->Id) { - // Totemic Power (The Earthshatterer set) + // Totemic Power (The Earthshatterer set) case 28823: { - if( !pVictim ) + if (!pVictim) return SPELL_AURA_PROC_FAILED; // Set class defined buff @@ -2214,14 +2214,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Windfury Weapon (Passive) 1-5 Ranks case 33757: { - if(GetTypeId()!=TYPEID_PLAYER) + if (GetTypeId()!=TYPEID_PLAYER) return SPELL_AURA_PROC_FAILED; - if(!castItem || !castItem->IsEquipped()) + if (!castItem || !castItem->IsEquipped()) return SPELL_AURA_PROC_FAILED; // custom cooldown processing case - if( cooldown && ((Player*)this)->HasSpellCooldown(dummySpell->Id)) + if (cooldown && ((Player*)this)->HasSpellCooldown(dummySpell->Id)) return SPELL_AURA_PROC_FAILED; // Now amount of extra power stored in 1 effect of Enchant spell @@ -2240,13 +2240,13 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura default: { sLog.outError("Unit::HandleDummyAuraProc: non handled item enchantment (rank?) %u for spell id: %u (Windfury)", - castItem->GetEnchantmentId(EnchantmentSlot(TEMP_ENCHANTMENT_SLOT)),dummySpell->Id); + castItem->GetEnchantmentId(EnchantmentSlot(TEMP_ENCHANTMENT_SLOT)),dummySpell->Id); return SPELL_AURA_PROC_FAILED; } } SpellEntry const* windfurySpellEntry = sSpellStore.LookupEntry(spellId); - if(!windfurySpellEntry) + if (!windfurySpellEntry) { sLog.outError("Unit::HandleDummyAuraProc: nonexistent spell id: %u (Windfury)",spellId); return SPELL_AURA_PROC_FAILED; @@ -2274,11 +2274,11 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura } // apply cooldown before cast to prevent processing itself - if( cooldown ) + if (cooldown) ((Player*)this)->AddSpellCooldown(dummySpell->Id,0,time(NULL) + cooldown); // Attack Twice - for ( uint32 i = 0; i<2; ++i ) + for (uint32 i = 0; i<2; ++i) CastCustomSpell(pVictim,triggered_spell_id,&basepoints[0],NULL,NULL,true,castItem,triggeredByAura); return SPELL_AURA_PROC_OK; @@ -2286,7 +2286,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Shaman Tier 6 Trinket case 40463: { - if( !procSpell ) + if (!procSpell) return SPELL_AURA_PROC_FAILED; float chance; @@ -2345,11 +2345,11 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // find totem aura bonus AuraList const& spellPower = totem->GetAurasByType(SPELL_AURA_NONE); - for(AuraList::const_iterator i = spellPower.begin();i != spellPower.end(); ++i) + for (AuraList::const_iterator i = spellPower.begin(); i != spellPower.end(); ++i) { // select proper aura for format aura type in spell proto if ((*i)->GetTarget()==totem && (*i)->GetSpellProto()->EffectApplyAuraName[(*i)->GetEffIndex()] == SPELL_AURA_MOD_HEALING_DONE && - (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_SHAMAN && (*i)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000004000000)) + (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_SHAMAN && (*i)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000004000000)) { basepoints[0] = triggerAmount * (*i)->GetModifier()->m_amount / 100; break; @@ -2390,7 +2390,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura if (dummySpell->SpellIconID == 3063) { // Earthbind Totem summon only - if(procSpell->Id != 2484) + if (procSpell->Id != 2484) return SPELL_AURA_PROC_FAILED; if (!roll_chance_i(triggerAmount)) @@ -2414,7 +2414,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; // Only proc for enchanted weapon - Item *usedWeapon = ((Player *)this)->GetWeaponForAttack(procFlag & PROC_FLAG_SUCCESSFUL_OFFHAND_HIT ? OFF_ATTACK : BASE_ATTACK, true, true); + Item* usedWeapon = ((Player*)this)->GetWeaponForAttack(procFlag & PROC_FLAG_SUCCESSFUL_OFFHAND_HIT ? OFF_ATTACK : BASE_ATTACK, true, true); if (usedWeapon != castItem) return SPELL_AURA_PROC_FAILED; @@ -2442,7 +2442,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura basepoints[0] = triggerAmount; // Glyph of Earth Shield - if(Unit* caster = triggeredByAura->GetCaster()) + if (Unit* caster = triggeredByAura->GetCaster()) { if (Aura* aur = caster->GetDummyAura(63279)) { @@ -2468,10 +2468,10 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; // lookup water shield AuraList const& vs = GetAurasByType(SPELL_AURA_PROC_TRIGGER_SPELL); - for(AuraList::const_iterator itr = vs.begin(); itr != vs.end(); ++itr) + for (AuraList::const_iterator itr = vs.begin(); itr != vs.end(); ++itr) { if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_SHAMAN && - ((*itr)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000002000000000))) + ((*itr)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000002000000000))) { uint32 spell = (*itr)->GetSpellProto()->EffectTriggerSpell[(*itr)->GetEffIndex()]; CastSpell(this, spell, true, castItem, triggeredByAura); @@ -2483,18 +2483,18 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Lightning Overload if (dummySpell->SpellIconID == 2018) // only this spell have SpellFamily Shaman SpellIconID == 2018 and dummy aura { - if(!procSpell || GetTypeId() != TYPEID_PLAYER || !pVictim ) + if (!procSpell || GetTypeId() != TYPEID_PLAYER || !pVictim) return SPELL_AURA_PROC_FAILED; // custom cooldown processing case - if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(dummySpell->Id)) + if (cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(dummySpell->Id)) return SPELL_AURA_PROC_FAILED; uint32 spellId = 0; // Every Lightning Bolt and Chain Lightning spell have duplicate vs half damage and zero cost switch (procSpell->Id) { - // Lightning Bolt + // Lightning Bolt case 403: spellId = 45284; break; // Rank 1 case 529: spellId = 45286; break; // Rank 2 case 548: spellId = 45287; break; // Rank 3 @@ -2509,7 +2509,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura case 25449: spellId = 45296; break; // Rank 12 case 49237: spellId = 49239; break; // Rank 13 case 49238: spellId = 49240; break; // Rank 14 - // Chain Lightning + // Chain Lightning case 421: spellId = 45297; break; // Rank 1 case 930: spellId = 45298; break; // Rank 2 case 2860: spellId = 45299; break; // Rank 3 @@ -2535,14 +2535,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura return SPELL_AURA_PROC_OK; } // Static Shock - if(dummySpell->SpellIconID == 3059) + if (dummySpell->SpellIconID == 3059) { // lookup Lightning Shield AuraList const& vs = GetAurasByType(SPELL_AURA_PROC_TRIGGER_SPELL); - for(AuraList::const_iterator itr = vs.begin(); itr != vs.end(); ++itr) + for (AuraList::const_iterator itr = vs.begin(); itr != vs.end(); ++itr) { if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_SHAMAN && - ((*itr)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000400))) + ((*itr)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000400))) { uint32 spell = 0; switch ((*itr)->GetId()) @@ -2572,7 +2572,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Frozen Power if (dummySpell->SpellIconID == 3780) { - Unit *caster = triggeredByAura->GetCaster(); + Unit* caster = triggeredByAura->GetCaster(); if (!procSpell || !caster) return SPELL_AURA_PROC_FAILED; @@ -2584,7 +2584,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; // make triggered cast apply after current damage spell processing for prevent remove by it - if(Spell* spell = GetCurrentSpell(CURRENT_GENERIC_SPELL)) + if (Spell* spell = GetCurrentSpell(CURRENT_GENERIC_SPELL)) spell->AddTriggeredSpell(63685); return SPELL_AURA_PROC_OK; } @@ -2648,7 +2648,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura switch (procSpell->Id) { - // Obliterate + // Obliterate case 49020: // Rank 1 triggered_spell_id = 66198; break; case 51423: // Rank 2 @@ -2657,7 +2657,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura triggered_spell_id = 66973; break; case 51425: // Rank 4 triggered_spell_id = 66974; break; - // Frost Strike + // Frost Strike case 49143: // Rank 1 triggered_spell_id = 66196; break; case 51416: // Rank 2 @@ -2670,7 +2670,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura triggered_spell_id = 66961; break; case 55268: // Rank 6 triggered_spell_id = 66962; break; - // Plague Strike + // Plague Strike case 45462: // Rank 1 triggered_spell_id = 66216; break; case 49917: // Rank 2 @@ -2683,7 +2683,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura triggered_spell_id = 66991; break; case 49921: // Rank 6 triggered_spell_id = 66992; break; - // Death Strike + // Death Strike case 49998: // Rank 1 triggered_spell_id = 66188; break; case 49999: // Rank 2 @@ -2694,10 +2694,10 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura triggered_spell_id = 66952; break; case 49924: // Rank 5 triggered_spell_id = 66953; break; - // Rune Strike + // Rune Strike case 56815: triggered_spell_id = 66217; break; - // Blood Strike + // Blood Strike case 45902: // Rank 1 triggered_spell_id = 66215; break; case 49926: // Rank 2 @@ -2774,10 +2774,10 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura if (basepoints[EFFECT_INDEX_0] || basepoints[EFFECT_INDEX_1] || basepoints[EFFECT_INDEX_2]) CastCustomSpell(target, triggered_spell_id, - basepoints[EFFECT_INDEX_0] ? &basepoints[EFFECT_INDEX_0] : NULL, - basepoints[EFFECT_INDEX_1] ? &basepoints[EFFECT_INDEX_1] : NULL, - basepoints[EFFECT_INDEX_2] ? &basepoints[EFFECT_INDEX_2] : NULL, - true, castItem, triggeredByAura); + basepoints[EFFECT_INDEX_0] ? &basepoints[EFFECT_INDEX_0] : NULL, + basepoints[EFFECT_INDEX_1] ? &basepoints[EFFECT_INDEX_1] : NULL, + basepoints[EFFECT_INDEX_2] ? &basepoints[EFFECT_INDEX_2] : NULL, + true, castItem, triggeredByAura); else CastSpell(target, triggered_spell_id, true, castItem, triggeredByAura); @@ -2787,7 +2787,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura return SPELL_AURA_PROC_OK; } -SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlags, uint32 procEx, uint32 cooldown) +SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlags, uint32 procEx, uint32 cooldown) { // Get triggered aura spell info SpellEntry const* auraSpellInfo = triggeredByAura->GetSpellProto(); @@ -2800,11 +2800,11 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d Unit* target = NULL; int32 basepoints[MAX_EFFECT_INDEX] = {0, 0, 0}; - if(triggeredByAura->GetModifier()->m_auraname == SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE) + if (triggeredByAura->GetModifier()->m_auraname == SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE) basepoints[0] = triggerAmount; Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER - ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; + ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; // Try handle unknown trigger spells // Custom requirements (not listed in procEx) Warning! damage dealing after this @@ -2812,35 +2812,35 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d switch (auraSpellInfo->SpellFamilyName) { case SPELLFAMILY_GENERIC: - switch(auraSpellInfo->Id) + switch (auraSpellInfo->Id) { - //case 191: // Elemental Response - // switch (procSpell->School) - // { - // case SPELL_SCHOOL_FIRE: trigger_spell_id = 34192; break; - // case SPELL_SCHOOL_FROST: trigger_spell_id = 34193; break; - // case SPELL_SCHOOL_ARCANE:trigger_spell_id = 34194; break; - // case SPELL_SCHOOL_NATURE:trigger_spell_id = 34195; break; - // case SPELL_SCHOOL_SHADOW:trigger_spell_id = 34196; break; - // case SPELL_SCHOOL_HOLY: trigger_spell_id = 34197; break; - // case SPELL_SCHOOL_NORMAL:trigger_spell_id = 34198; break; - // } - // break; - //case 5301: break; // Defensive State (DND) - //case 7137: break: // Shadow Charge (Rank 1) - //case 7377: break: // Take Immune Periodic Damage - //case 13358: break; // Defensive State (DND) - //case 16092: break; // Defensive State (DND) - //case 18943: break; // Double Attack - //case 19194: break; // Double Attack - //case 19817: break; // Double Attack - //case 19818: break; // Double Attack - //case 22835: break; // Drunken Rage - // trigger_spell_id = 14822; break; + //case 191: // Elemental Response + // switch (procSpell->School) + // { + // case SPELL_SCHOOL_FIRE: trigger_spell_id = 34192; break; + // case SPELL_SCHOOL_FROST: trigger_spell_id = 34193; break; + // case SPELL_SCHOOL_ARCANE:trigger_spell_id = 34194; break; + // case SPELL_SCHOOL_NATURE:trigger_spell_id = 34195; break; + // case SPELL_SCHOOL_SHADOW:trigger_spell_id = 34196; break; + // case SPELL_SCHOOL_HOLY: trigger_spell_id = 34197; break; + // case SPELL_SCHOOL_NORMAL:trigger_spell_id = 34198; break; + // } + // break; + //case 5301: break; // Defensive State (DND) + //case 7137: break: // Shadow Charge (Rank 1) + //case 7377: break: // Take Immune Periodic Damage + //case 13358: break; // Defensive State (DND) + //case 16092: break; // Defensive State (DND) + //case 18943: break; // Double Attack + //case 19194: break; // Double Attack + //case 19817: break; // Double Attack + //case 19818: break; // Double Attack + //case 22835: break; // Drunken Rage + // trigger_spell_id = 14822; break; case 23780: // Aegis of Preservation (Aegis of Preservation trinket) trigger_spell_id = 23781; break; - //case 24949: break; // Defensive State 2 (DND) + //case 24949: break; // Defensive State 2 (DND) case 27522: // Mana Drain Trigger case 40336: // Mana Drain Trigger case 46939: // Black Bow of the Betrayer @@ -2864,65 +2864,65 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d case 33896: // Desperate Defense (Stonescythe Whelp, Stonescythe Alpha, Stonescythe Ambusher) trigger_spell_id = 33898; break; - //case 34082: break; // Advantaged State (DND) - //case 34783: break: // Spell Reflection - //case 35205: break: // Vanish - //case 35321: break; // Gushing Wound - //case 36096: break: // Spell Reflection - //case 36207: break: // Steal Weapon - //case 36576: break: // Shaleskin (Shaleskin Flayer, Shaleskin Ripper) 30023 trigger - //case 37030: break; // Chaotic Temperament - //case 38363: break; // Gushing Wound - //case 39215: break; // Gushing Wound - //case 40250: break; // Improved Duration - //case 40329: break; // Demo Shout Sensor - //case 40364: break; // Entangling Roots Sensor - //case 41054: break; // Copy Weapon - // trigger_spell_id = 41055; break; - //case 41248: break; // Consuming Strikes - // trigger_spell_id = 41249; break; - //case 42730: break: // Woe Strike - //case 43453: break: // Rune Ward - //case 43504: break; // Alterac Valley OnKill Proc Aura - //case 44326: break: // Pure Energy Passive - //case 44526: break; // Hate Monster (Spar) (30 sec) - //case 44527: break; // Hate Monster (Spar Buddy) (30 sec) - //case 44819: break; // Hate Monster (Spar Buddy) (>30% Health) - //case 44820: break; // Hate Monster (Spar) (<30%) + //case 34082: break; // Advantaged State (DND) + //case 34783: break: // Spell Reflection + //case 35205: break: // Vanish + //case 35321: break; // Gushing Wound + //case 36096: break: // Spell Reflection + //case 36207: break: // Steal Weapon + //case 36576: break: // Shaleskin (Shaleskin Flayer, Shaleskin Ripper) 30023 trigger + //case 37030: break; // Chaotic Temperament + //case 38363: break; // Gushing Wound + //case 39215: break; // Gushing Wound + //case 40250: break; // Improved Duration + //case 40329: break; // Demo Shout Sensor + //case 40364: break; // Entangling Roots Sensor + //case 41054: break; // Copy Weapon + // trigger_spell_id = 41055; break; + //case 41248: break; // Consuming Strikes + // trigger_spell_id = 41249; break; + //case 42730: break: // Woe Strike + //case 43453: break: // Rune Ward + //case 43504: break; // Alterac Valley OnKill Proc Aura + //case 44326: break: // Pure Energy Passive + //case 44526: break; // Hate Monster (Spar) (30 sec) + //case 44527: break; // Hate Monster (Spar Buddy) (30 sec) + //case 44819: break; // Hate Monster (Spar Buddy) (>30% Health) + //case 44820: break; // Hate Monster (Spar) (<30%) case 45057: // Evasive Maneuvers (Commendation of Kael`thas trinket) // reduce you below $s1% health (in fact in this specific case can proc from any attack while health in result less $s1%) if (int32(GetHealth()) - int32(damage) >= int32(GetMaxHealth() * triggerAmount / 100)) return SPELL_AURA_PROC_FAILED; break; - //case 45903: break: // Offensive State - //case 46146: break: // [PH] Ahune Spanky Hands + //case 45903: break: // Offensive State + //case 46146: break: // [PH] Ahune Spanky Hands case 43820: // Charm of the Witch Doctor (Amani Charm of the Witch Doctor trinket) // Pct value stored in dummy basepoints[0] = pVictim->GetCreateHealth() * auraSpellInfo->CalculateSimpleValue(EFFECT_INDEX_1) / 100; target = pVictim; break; - //case 45205: break; // Copy Offhand Weapon - //case 45343: break; // Dark Flame Aura - //case 47300: break; // Dark Flame Aura - //case 48876: break; // Beast's Mark - // trigger_spell_id = 48877; break; - //case 49059: break; // Horde, Hate Monster (Spar Buddy) (>30% Health) - //case 50051: break; // Ethereal Pet Aura - //case 50689: break; // Blood Presence (Rank 1) - //case 50844: break; // Blood Mirror - //case 52856: break; // Charge - //case 54072: break; // Knockback Ball Passive - //case 54476: break; // Blood Presence - //case 54775: break; // Abandon Vehicle on Poly + //case 45205: break; // Copy Offhand Weapon + //case 45343: break; // Dark Flame Aura + //case 47300: break; // Dark Flame Aura + //case 48876: break; // Beast's Mark + // trigger_spell_id = 48877; break; + //case 49059: break; // Horde, Hate Monster (Spar Buddy) (>30% Health) + //case 50051: break; // Ethereal Pet Aura + //case 50689: break; // Blood Presence (Rank 1) + //case 50844: break; // Blood Mirror + //case 52856: break; // Charge + //case 54072: break; // Knockback Ball Passive + //case 54476: break; // Blood Presence + //case 54775: break; // Abandon Vehicle on Poly case 57345: // Darkmoon Card: Greatness { float stat = 0.0f; // strength - if (GetStat(STAT_STRENGTH) > stat) { trigger_spell_id = 60229;stat = GetStat(STAT_STRENGTH); } + if (GetStat(STAT_STRENGTH) > stat) { trigger_spell_id = 60229; stat = GetStat(STAT_STRENGTH); } // agility - if (GetStat(STAT_AGILITY) > stat) { trigger_spell_id = 60233;stat = GetStat(STAT_AGILITY); } + if (GetStat(STAT_AGILITY) > stat) { trigger_spell_id = 60233; stat = GetStat(STAT_AGILITY); } // intellect - if (GetStat(STAT_INTELLECT)> stat) { trigger_spell_id = 60234;stat = GetStat(STAT_INTELLECT);} + if (GetStat(STAT_INTELLECT)> stat) { trigger_spell_id = 60234; stat = GetStat(STAT_INTELLECT);} // spirit if (GetStat(STAT_SPIRIT) > stat) { trigger_spell_id = 60235; } break; @@ -2971,7 +2971,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d { float stat = 0.0f; // strength - if (GetStat(STAT_STRENGTH) > stat) { trigger_spell_id = 67708;stat = GetStat(STAT_STRENGTH); } + if (GetStat(STAT_STRENGTH) > stat) { trigger_spell_id = 67708; stat = GetStat(STAT_STRENGTH); } // agility if (GetStat(STAT_AGILITY) > stat) { trigger_spell_id = 67703; } break; @@ -2980,14 +2980,14 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d { float stat = 0.0f; // strength - if (GetStat(STAT_STRENGTH) > stat) { trigger_spell_id = 67773;stat = GetStat(STAT_STRENGTH); } + if (GetStat(STAT_STRENGTH) > stat) { trigger_spell_id = 67773; stat = GetStat(STAT_STRENGTH); } // agility if (GetStat(STAT_AGILITY) > stat) { trigger_spell_id = 67772; } break; } case 69023: // Mirrored Soul { - int32 basepoints = (int32) (damage * 0.45f); + int32 basepoints = (int32)(damage * 0.45f); if (Unit* caster = triggeredByAura->GetCaster()) // Actually this spell should be sent with SMSG_SPELL_START CastCustomSpell(caster, 69034, &basepoints, NULL, NULL, true, NULL, triggeredByAura, GetObjectGuid()); @@ -3010,18 +3010,18 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d return SPELL_AURA_PROC_FAILED; } } - else if(auraSpellInfo->Id == 26467) // Persistent Shield (Scarab Brooch trinket) + else if (auraSpellInfo->Id == 26467) // Persistent Shield (Scarab Brooch trinket) { // This spell originally trigger 13567 - Dummy Trigger (vs dummy effect) basepoints[0] = damage * 15 / 100; target = pVictim; trigger_spell_id = 26470; } - else if(auraSpellInfo->Id == 71761) // Deep Freeze Immunity State + else if (auraSpellInfo->Id == 71761) // Deep Freeze Immunity State { // spell applied only to permanent immunes to stun targets (bosses) if (pVictim->GetTypeId() != TYPEID_UNIT || - (((Creature*)pVictim)->GetCreatureInfo()->MechanicImmuneMask & (1 << (MECHANIC_STUN - 1))) == 0) + (((Creature*)pVictim)->GetCreatureInfo()->MechanicImmuneMask & (1 << (MECHANIC_STUN - 1))) == 0) return SPELL_AURA_PROC_FAILED; } break; @@ -3042,7 +3042,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d case 12834: basepoints[0] = int32(weaponDamage * 16 / 100); break; case 12849: basepoints[0] = int32(weaponDamage * 32 / 100); break; case 12867: basepoints[0] = int32(weaponDamage * 48 / 100); break; - // Impossible case + // Impossible case default: sLog.outError("Unit::HandleProcTriggerSpellAuraProc: DW unknown spell rank %u",auraSpellInfo->Id); return SPELL_AURA_PROC_FAILED; @@ -3070,7 +3070,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d { // search for "Improved Drain Soul" dummy aura Unit::AuraList const& mDummyAura = GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator i = mDummyAura.begin(); i != mDummyAura.end(); ++i) + for (Unit::AuraList::const_iterator i = mDummyAura.begin(); i != mDummyAura.end(); ++i) { if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && (*i)->GetSpellProto()->SpellIconID == 113) { @@ -3096,7 +3096,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d { if (!procSpell) return SPELL_AURA_PROC_FAILED; - switch(GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) + switch (GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) { case SPELL_SCHOOL_NORMAL: return SPELL_AURA_PROC_FAILED; // ignore @@ -3122,7 +3122,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d else if (auraSpellInfo->Id == 63156 || auraSpellInfo->Id == 63158) { // Looking for dummy effect - Aura *aur = GetAura(auraSpellInfo->Id, EFFECT_INDEX_1); + Aura* aur = GetAura(auraSpellInfo->Id, EFFECT_INDEX_1); if (!aur) return SPELL_AURA_PROC_FAILED; @@ -3155,7 +3155,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d case 27816: trigger_spell_id = 27818; break; default: sLog.outError("Unit::HandleProcTriggerSpellAuraProc: Spell %u not handled in BR", auraSpellInfo->Id); - return SPELL_AURA_PROC_FAILED; + return SPELL_AURA_PROC_FAILED; } basepoints[0] = damage * triggerAmount / 100 / 3; target = this; @@ -3170,14 +3170,14 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d // Druid Forms Trinket if (auraSpellInfo->Id==37336) { - switch(GetShapeshiftForm()) + switch (GetShapeshiftForm()) { - case FORM_NONE: trigger_spell_id = 37344;break; - case FORM_CAT: trigger_spell_id = 37341;break; + case FORM_NONE: trigger_spell_id = 37344; break; + case FORM_CAT: trigger_spell_id = 37341; break; case FORM_BEAR: - case FORM_DIREBEAR: trigger_spell_id = 37340;break; - case FORM_TREE: trigger_spell_id = 37342;break; - case FORM_MOONKIN: trigger_spell_id = 37343;break; + case FORM_DIREBEAR: trigger_spell_id = 37340; break; + case FORM_TREE: trigger_spell_id = 37342; break; + case FORM_MOONKIN: trigger_spell_id = 37343; break; default: return SPELL_AURA_PROC_FAILED; } @@ -3185,7 +3185,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d // Druid T9 Feral Relic (Lacerate, Swipe, Mangle, and Shred) else if (auraSpellInfo->Id==67353) { - switch(GetShapeshiftForm()) + switch (GetShapeshiftForm()) { case FORM_CAT: trigger_spell_id = 67355; break; case FORM_BEAR: @@ -3270,14 +3270,14 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d // Illumination else if (auraSpellInfo->SpellIconID==241) { - if(!procSpell) + if (!procSpell) return SPELL_AURA_PROC_FAILED; // procspell is triggered spell but we need mana cost of original casted spell uint32 originalSpellId = procSpell->Id; // Holy Shock heal if (procSpell->SpellFamilyFlags & UI64LIT(0x0001000000000000)) { - switch(procSpell->Id) + switch (procSpell->Id) { case 25914: originalSpellId = 20473; break; case 25913: originalSpellId = 20929; break; @@ -3291,8 +3291,8 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d return SPELL_AURA_PROC_FAILED; } } - SpellEntry const *originalSpell = sSpellStore.LookupEntry(originalSpellId); - if(!originalSpell) + SpellEntry const* originalSpell = sSpellStore.LookupEntry(originalSpellId); + if (!originalSpell) { sLog.outError("Unit::HandleProcTriggerSpellAuraProc: Spell %u unknown but selected as original in Illu",originalSpellId); return SPELL_AURA_PROC_FAILED; @@ -3306,14 +3306,14 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d // Lightning Capacitor else if (auraSpellInfo->Id==37657) { - if(!pVictim || !pVictim->isAlive()) + if (!pVictim || !pVictim->isAlive()) return SPELL_AURA_PROC_FAILED; // stacking CastSpell(this, 37658, true, NULL, triggeredByAura); - Aura * dummy = GetDummyAura(37658); + Aura* dummy = GetDummyAura(37658); // release at 3 aura in stack (cont contain in basepoint of trigger aura) - if(!dummy || dummy->GetStackAmount() < uint32(triggerAmount)) + if (!dummy || dummy->GetStackAmount() < uint32(triggerAmount)) return SPELL_AURA_PROC_FAILED; RemoveAurasDueToSpell(37658); @@ -3330,15 +3330,15 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d // Thunder Capacitor else if (auraSpellInfo->Id == 54841) { - if(!pVictim || !pVictim->isAlive()) + if (!pVictim || !pVictim->isAlive()) return SPELL_AURA_PROC_FAILED; // stacking CastSpell(this, 54842, true, NULL, triggeredByAura); // counting - Aura * dummy = GetDummyAura(54842); + Aura* dummy = GetDummyAura(54842); // release at 3 aura in stack (cont contain in basepoint of trigger aura) - if(!dummy || dummy->GetStackAmount() < uint32(triggerAmount)) + if (!dummy || dummy->GetStackAmount() < uint32(triggerAmount)) return SPELL_AURA_PROC_FAILED; RemoveAurasDueToSpell(54842); @@ -3352,7 +3352,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d // Lightning Shield (overwrite non existing triggered spell call in spell.dbc if (auraSpellInfo->SpellFamilyFlags & UI64LIT(0x0000000000000400)) { - switch(auraSpellInfo->Id) + switch (auraSpellInfo->Id) { case 324: // Rank 1 trigger_spell_id = 26364; break; @@ -3393,7 +3393,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d // Mana Surge (The Earthfury set) else if (auraSpellInfo->Id == 23572) { - if(!procSpell) + if (!procSpell) return SPELL_AURA_PROC_FAILED; basepoints[0] = procSpell->manaCost * 35 / 100; trigger_spell_id = 23571; @@ -3407,7 +3407,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d if (int32(GetHealth()) - int32(damage) >= health30) return SPELL_AURA_PROC_FAILED; - if(pVictim && pVictim->isAlive()) + if (pVictim && pVictim->isAlive()) pVictim->getThreatManager().modifyThreatPercent(this,-10); basepoints[0] = triggerAmount * GetMaxHealth() / 100; @@ -3423,7 +3423,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d { if (!procSpell) return SPELL_AURA_PROC_FAILED; - switch(GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) + switch (GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) { case SPELL_SCHOOL_NORMAL: return SPELL_AURA_PROC_FAILED; // ignore @@ -3441,7 +3441,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d else if (auraSpellInfo->SpellIconID == 85) { if (GetTypeId() != TYPEID_PLAYER || getClass() != CLASS_DEATH_KNIGHT || - !((Player*)this)->IsBaseRuneSlotsOnCooldown(RUNE_BLOOD)) + !((Player*)this)->IsBaseRuneSlotsOnCooldown(RUNE_BLOOD)) return SPELL_AURA_PROC_FAILED; } // Improved Blood Presence @@ -3473,9 +3473,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d // Custom basepoints/target for exist spell // dummy basepoints or other customs - switch(trigger_spell_id) + switch (trigger_spell_id) { - // Cast positive spell on enemy target + // Cast positive spell on enemy target case 7099: // Curse of Mending case 39647: // Curse of Mending case 29494: // Temptation @@ -3487,7 +3487,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d // Combo points add triggers (need add combopoint only for main target, and after possible combopoints reset) case 15250: // Rogue Setup { - if(!pVictim || pVictim != getVictim()) // applied only for main target + if (!pVictim || pVictim != getVictim()) // applied only for main target return SPELL_AURA_PROC_FAILED; break; // continue normal case } @@ -3519,7 +3519,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d // Enlightenment (trigger only from mana cost spells) case 35095: { - if(!procSpell || procSpell->powerType!=POWER_MANA || procSpell->manaCost==0 && procSpell->ManaCostPercentage==0 && procSpell->manaCostPerlevel==0) + if (!procSpell || procSpell->powerType!=POWER_MANA || procSpell->manaCost==0 && procSpell->ManaCostPercentage==0 && procSpell->manaCostPerlevel==0) return SPELL_AURA_PROC_FAILED; break; } @@ -3536,7 +3536,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d if (Aura* aur = owner->GetAura(48090, EFFECT_INDEX_0)) curBonus = aur->GetModifier()->m_amount; int32 spellDamage = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_MAGIC) - curBonus; - if(spellDamage <= 0) + if (spellDamage <= 0) return SPELL_AURA_PROC_FAILED; // percent stored in owner talent dummy @@ -3566,30 +3566,30 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d // PPM = 2.5 * (rank of talent), uint32 rank = sSpellMgr.GetSpellRank(auraSpellInfo->Id); // 5 rank -> 100% 4 rank -> 80% and etc from full rate - if(!roll_chance_i(20*rank)) + if (!roll_chance_i(20*rank)) return SPELL_AURA_PROC_FAILED; break; } // Brain Freeze case 57761: { - if(!procSpell) + if (!procSpell) return SPELL_AURA_PROC_FAILED; // For trigger from Blizzard need exist Improved Blizzard if (procSpell->SpellFamilyName==SPELLFAMILY_MAGE && (procSpell->SpellFamilyFlags & UI64LIT(0x0000000000000080))) { bool found = false; AuraList const& mOverrideClassScript = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) + for (AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { int32 script = (*i)->GetModifier()->m_miscvalue; - if(script==836 || script==988 || script==989) + if (script==836 || script==988 || script==989) { found=true; break; } } - if(!found) + if (!found) return SPELL_AURA_PROC_FAILED; } break; @@ -3608,7 +3608,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d // Burning Determination case 54748: { - if(!procSpell) + if (!procSpell) return SPELL_AURA_PROC_FAILED; // Need Interrupt or Silenced mechanic if (!(GetAllSpellMechanicMask(procSpell) & IMMUNE_TO_INTERRUPT_AND_SILENCE_MASK)) @@ -3652,10 +3652,10 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d if (basepoints[EFFECT_INDEX_0] || basepoints[EFFECT_INDEX_1] || basepoints[EFFECT_INDEX_2]) CastCustomSpell(target,trigger_spell_id, - basepoints[EFFECT_INDEX_0] ? &basepoints[EFFECT_INDEX_0] : NULL, - basepoints[EFFECT_INDEX_1] ? &basepoints[EFFECT_INDEX_1] : NULL, - basepoints[EFFECT_INDEX_2] ? &basepoints[EFFECT_INDEX_2] : NULL, - true, castItem, triggeredByAura); + basepoints[EFFECT_INDEX_0] ? &basepoints[EFFECT_INDEX_0] : NULL, + basepoints[EFFECT_INDEX_1] ? &basepoints[EFFECT_INDEX_1] : NULL, + basepoints[EFFECT_INDEX_2] ? &basepoints[EFFECT_INDEX_2] : NULL, + true, castItem, triggeredByAura); else CastSpell(target,trigger_spell_id,true,castItem,triggeredByAura); @@ -3665,11 +3665,11 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d return SPELL_AURA_PROC_OK; } -SpellAuraProcResult Unit::HandleProcTriggerDamageAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlags, uint32 procEx, uint32 cooldown) +SpellAuraProcResult Unit::HandleProcTriggerDamageAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlags, uint32 procEx, uint32 cooldown) { - SpellEntry const *spellInfo = triggeredByAura->GetSpellProto(); + SpellEntry const* spellInfo = triggeredByAura->GetSpellProto(); DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "ProcDamageAndSpell: doing %u damage from spell id %u (triggered by auratype %u of spell %u)", - triggeredByAura->GetModifier()->m_amount, spellInfo->Id, triggeredByAura->GetModifier()->m_auraname, triggeredByAura->GetId()); + triggeredByAura->GetModifier()->m_amount, spellInfo->Id, triggeredByAura->GetModifier()->m_auraname, triggeredByAura->GetId()); SpellNonMeleeDamage damageInfo(this, pVictim, spellInfo->Id, SpellSchoolMask(spellInfo->SchoolMask)); CalculateSpellDamage(&damageInfo, triggeredByAura->GetModifier()->m_amount, spellInfo); damageInfo.target->CalculateAbsorbResistBlock(this, &damageInfo, spellInfo); @@ -3679,22 +3679,22 @@ SpellAuraProcResult Unit::HandleProcTriggerDamageAuraProc(Unit *pVictim, uint32 return SPELL_AURA_PROC_OK; } -SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, uint32 /*damage*/, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 /*procFlag*/, uint32 /*procEx*/ ,uint32 cooldown) +SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit* pVictim, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 /*procFlag*/, uint32 /*procEx*/ ,uint32 cooldown) { int32 scriptId = triggeredByAura->GetModifier()->m_miscvalue; - if(!pVictim || !pVictim->isAlive()) + if (!pVictim || !pVictim->isAlive()) return SPELL_AURA_PROC_FAILED; Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER - ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; + ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; // Basepoints of trigger aura int32 triggerAmount = triggeredByAura->GetModifier()->m_amount; uint32 triggered_spell_id = 0; - switch(scriptId) + switch (scriptId) { case 836: // Improved Blizzard (Rank 1) { @@ -3720,7 +3720,7 @@ SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, uint3 case 4086: // Improved Mend Pet (Rank 1) case 4087: // Improved Mend Pet (Rank 2) { - if(!roll_chance_i(triggerAmount)) + if (!roll_chance_i(triggerAmount)) return SPELL_AURA_PROC_FAILED; triggered_spell_id = 24406; @@ -3755,10 +3755,10 @@ SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, uint3 case 7011: // Revitalize (rank 2) case 7012: // Revitalize (rank 3) { - if(!roll_chance_i(triggerAmount)) + if (!roll_chance_i(triggerAmount)) return SPELL_AURA_PROC_FAILED; - switch( pVictim->getPowerType() ) + switch (pVictim->getPowerType()) { case POWER_MANA: triggered_spell_id = 48542; break; case POWER_RAGE: triggered_spell_id = 48541; break; @@ -3771,30 +3771,30 @@ SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, uint3 } // not processed - if(!triggered_spell_id) + if (!triggered_spell_id) return SPELL_AURA_PROC_FAILED; // standard non-dummy case SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); - if(!triggerEntry) + if (!triggerEntry) { sLog.outError("Unit::HandleOverrideClassScriptAuraProc: Spell %u triggering for class script id %u",triggered_spell_id,scriptId); return SPELL_AURA_PROC_FAILED; } - if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + if (cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) return SPELL_AURA_PROC_FAILED; CastSpell(pVictim, triggered_spell_id, true, castItem, triggeredByAura); - if( cooldown && GetTypeId()==TYPEID_PLAYER ) + if (cooldown && GetTypeId()==TYPEID_PLAYER) ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); return SPELL_AURA_PROC_OK; } -SpellAuraProcResult Unit::HandleMendingAuraProc( Unit* /*pVictim*/, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/ ) +SpellAuraProcResult Unit::HandleMendingAuraProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/) { // aura can be deleted at casts SpellEntry const* spellProto = triggeredByAura->GetSpellProto(); @@ -3814,23 +3814,23 @@ SpellAuraProcResult Unit::HandleMendingAuraProc( Unit* /*pVictim*/, uint32 /*dam else radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); - if(Player* caster = ((Player*)triggeredByAura->GetCaster())) + if (Player* caster = ((Player*)triggeredByAura->GetCaster())) { caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius, NULL); - if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius)) + if (Player* target = ((Player*)this)->GetNextRandomRaidMember(radius)) { - SpellAuraHolder *holder = GetSpellAuraHolder(spellProto->Id, caster->GetObjectGuid()); - SpellAuraHolder *new_holder = CreateSpellAuraHolder(spellProto, target, caster); + SpellAuraHolder* holder = GetSpellAuraHolder(spellProto->Id, caster->GetObjectGuid()); + SpellAuraHolder* new_holder = CreateSpellAuraHolder(spellProto, target, caster); for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { - Aura *aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i)); + Aura* aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i)); if (!aur) continue; int32 basePoints = aur->GetBasePoints(); - Aura * new_aur = CreateAura(spellProto, aur->GetEffIndex(), &basePoints, new_holder, target, caster); + Aura* new_aur = CreateAura(spellProto, aur->GetEffIndex(), &basePoints, new_holder, target, caster); new_holder->AddAura(new_aur, new_aur->GetEffIndex()); } new_holder->SetAuraCharges(jumps, false); @@ -3865,15 +3865,15 @@ SpellAuraProcResult Unit::HandleModPowerCostSchoolAuraProc(Unit* /*pVictim*/, ui { // Skip melee hits and spells ws wrong school or zero cost return !(procSpell == NULL || - (procSpell->manaCost == 0 && procSpell->ManaCostPercentage == 0) || // Cost check - (triggeredByAura->GetModifier()->m_miscvalue & procSpell->SchoolMask) == 0) ? SPELL_AURA_PROC_OK : SPELL_AURA_PROC_FAILED; // School check + (procSpell->manaCost == 0 && procSpell->ManaCostPercentage == 0) || // Cost check + (triggeredByAura->GetModifier()->m_miscvalue & procSpell->SchoolMask) == 0) ? SPELL_AURA_PROC_OK : SPELL_AURA_PROC_FAILED; // School check } SpellAuraProcResult Unit::HandleMechanicImmuneResistanceAuraProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/) { // Compare mechanic return !(procSpell==NULL || int32(procSpell->Mechanic) != triggeredByAura->GetModifier()->m_miscvalue) - ? SPELL_AURA_PROC_OK : SPELL_AURA_PROC_FAILED; + ? SPELL_AURA_PROC_OK : SPELL_AURA_PROC_FAILED; } SpellAuraProcResult Unit::HandleModDamageFromCasterAuraProc(Unit* pVictim, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/) @@ -3882,9 +3882,9 @@ SpellAuraProcResult Unit::HandleModDamageFromCasterAuraProc(Unit* pVictim, uint3 return triggeredByAura->GetCasterGuid() == pVictim->GetObjectGuid() ? SPELL_AURA_PROC_OK : SPELL_AURA_PROC_FAILED; } -SpellAuraProcResult Unit::HandleAddFlatModifierAuraProc(Unit* pVictim, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/) +SpellAuraProcResult Unit::HandleAddFlatModifierAuraProc(Unit* pVictim, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/) { - SpellEntry const *spellInfo = triggeredByAura->GetSpellProto(); + SpellEntry const* spellInfo = triggeredByAura->GetSpellProto(); if (spellInfo->Id == 55166) // Tidal Force { @@ -3907,13 +3907,13 @@ SpellAuraProcResult Unit::HandleAddFlatModifierAuraProc(Unit* pVictim, uint32 /* return SPELL_AURA_PROC_OK; } -SpellAuraProcResult Unit::HandleAddPctModifierAuraProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 /*procFlag*/, uint32 procEx, uint32 /*cooldown*/) +SpellAuraProcResult Unit::HandleAddPctModifierAuraProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 /*procFlag*/, uint32 procEx, uint32 /*cooldown*/) { - SpellEntry const *spellInfo = triggeredByAura->GetSpellProto(); + SpellEntry const* spellInfo = triggeredByAura->GetSpellProto(); Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER - ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; + ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; - switch(spellInfo->SpellFamilyName) + switch (spellInfo->SpellFamilyName) { case SPELLFAMILY_MAGE: { @@ -3921,7 +3921,7 @@ SpellAuraProcResult Unit::HandleAddPctModifierAuraProc(Unit* /*pVictim*/, uint32 if (spellInfo->Id == 11129) { //last charge and crit - if (triggeredByAura->GetHolder()->GetAuraCharges() <= 1 && (procEx & PROC_EX_CRITICAL_HIT) ) + if (triggeredByAura->GetHolder()->GetAuraCharges() <= 1 && (procEx & PROC_EX_CRITICAL_HIT)) return SPELL_AURA_PROC_OK; // charge counting (will removed) CastSpell(this, 28682, true, castItem, triggeredByAura); @@ -3952,11 +3952,11 @@ SpellAuraProcResult Unit::HandleAddPctModifierAuraProc(Unit* /*pVictim*/, uint32 return SPELL_AURA_PROC_OK; } -SpellAuraProcResult Unit::HandleModDamagePercentDoneAuraProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 /*procFlag*/, uint32 procEx, uint32 cooldown) +SpellAuraProcResult Unit::HandleModDamagePercentDoneAuraProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 /*procFlag*/, uint32 procEx, uint32 cooldown) { - SpellEntry const *spellInfo = triggeredByAura->GetSpellProto(); + SpellEntry const* spellInfo = triggeredByAura->GetSpellProto(); Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER - ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; + ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; // Aspect of the Viper if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo->SpellFamilyFlags & UI64LIT(0x4000000000000)) @@ -3964,7 +3964,7 @@ SpellAuraProcResult Unit::HandleModDamagePercentDoneAuraProc(Unit* /*pVictim*/, uint32 maxmana = GetMaxPower(POWER_MANA); int32 bp = int32(maxmana* GetAttackTime(RANGED_ATTACK)/1000.0f/100.0f); - if(cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(34075)) + if (cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(34075)) return SPELL_AURA_PROC_FAILED; CastCustomSpell(this, 34075, &bp, NULL, NULL, true, castItem, triggeredByAura); @@ -3977,9 +3977,9 @@ SpellAuraProcResult Unit::HandleModDamagePercentDoneAuraProc(Unit* /*pVictim*/, return SPELL_AURA_PROC_OK; } -SpellAuraProcResult Unit::HandleModRating(Unit* /*pVictim*/, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const * /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/) +SpellAuraProcResult Unit::HandleModRating(Unit* /*pVictim*/, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/) { - SpellEntry const *spellInfo = triggeredByAura->GetSpellProto(); + SpellEntry const* spellInfo = triggeredByAura->GetSpellProto(); if (spellInfo->Id == 71564) // Deadly Precision { @@ -3991,7 +3991,7 @@ SpellAuraProcResult Unit::HandleModRating(Unit* /*pVictim*/, uint32 /*damage*/, return SPELL_AURA_PROC_OK; } -SpellAuraProcResult Unit::HandleSpellMagnetAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) +SpellAuraProcResult Unit::HandleSpellMagnetAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) { if (triggeredByAura->GetId() == 8178) // Grounding Totem Effect { @@ -4005,17 +4005,17 @@ SpellAuraProcResult Unit::HandleSpellMagnetAuraProc(Unit *pVictim, uint32 damage return SPELL_AURA_PROC_OK; } -SpellAuraProcResult Unit::HandleManaShieldAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) +SpellAuraProcResult Unit::HandleManaShieldAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) { - SpellEntry const *dummySpell = triggeredByAura->GetSpellProto (); + SpellEntry const* dummySpell = triggeredByAura->GetSpellProto(); Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER - ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; + ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; uint32 triggered_spell_id = 0; Unit* target = pVictim; - switch(dummySpell->SpellFamilyName) + switch (dummySpell->SpellFamilyName) { case SPELLFAMILY_MAGE: { @@ -4064,7 +4064,7 @@ SpellAuraProcResult Unit::HandleManaShieldAuraProc(Unit *pVictim, uint32 damage, SpellAuraProcResult Unit::HandleModResistanceAuraProc(Unit* /*pVictim*/, uint32 damage, Aura* triggeredByAura, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/) { - SpellEntry const *spellInfo = triggeredByAura->GetSpellProto(); + SpellEntry const* spellInfo = triggeredByAura->GetSpellProto(); // Inner Fire if (spellInfo->IsFitToFamily(SPELLFAMILY_PRIEST, UI64LIT(0x0000000000002))) @@ -4077,7 +4077,7 @@ SpellAuraProcResult Unit::HandleModResistanceAuraProc(Unit* /*pVictim*/, uint32 return SPELL_AURA_PROC_OK; } -SpellAuraProcResult Unit::HandleRemoveByDamageChanceProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) +SpellAuraProcResult Unit::HandleRemoveByDamageChanceProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) { // The chance to dispel an aura depends on the damage taken with respect to the casters level. uint32 max_dmg = getLevel() > 8 ? 25 * getLevel() - 150 : 50; diff --git a/src/game/UpdateData.cpp b/src/game/UpdateData.cpp index f04baf7e5..c009cb883 100644 --- a/src/game/UpdateData.cpp +++ b/src/game/UpdateData.cpp @@ -35,18 +35,18 @@ void UpdateData::AddOutOfRangeGUID(GuidSet& guids) m_outOfRangeGUIDs.insert(guids.begin(),guids.end()); } -void UpdateData::AddOutOfRangeGUID(ObjectGuid const &guid) +void UpdateData::AddOutOfRangeGUID(ObjectGuid const& guid) { m_outOfRangeGUIDs.insert(guid); } -void UpdateData::AddUpdateBlock(const ByteBuffer &block) +void UpdateData::AddUpdateBlock(const ByteBuffer& block) { m_data.append(block); ++m_blockCount; } -void UpdateData::Compress(void* dst, uint32 *dst_size, void* src, int src_size) +void UpdateData::Compress(void* dst, uint32* dst_size, void* src, int src_size) { z_stream c_stream; @@ -102,20 +102,20 @@ void UpdateData::Compress(void* dst, uint32 *dst_size, void* src, int src_size) *dst_size = c_stream.total_out; } -bool UpdateData::BuildPacket(WorldPacket *packet) +bool UpdateData::BuildPacket(WorldPacket* packet) { MANGOS_ASSERT(packet->empty()); // shouldn't happen ByteBuffer buf(4 + (m_outOfRangeGUIDs.empty() ? 0 : 1 + 4 + 9 * m_outOfRangeGUIDs.size()) + m_data.wpos()); - buf << (uint32) (!m_outOfRangeGUIDs.empty() ? m_blockCount + 1 : m_blockCount); + buf << (uint32)(!m_outOfRangeGUIDs.empty() ? m_blockCount + 1 : m_blockCount); - if(!m_outOfRangeGUIDs.empty()) + if (!m_outOfRangeGUIDs.empty()) { buf << (uint8) UPDATETYPE_OUT_OF_RANGE_OBJECTS; buf << (uint32) m_outOfRangeGUIDs.size(); - for(GuidSet::const_iterator i = m_outOfRangeGUIDs.begin(); i != m_outOfRangeGUIDs.end(); ++i) + for (GuidSet::const_iterator i = m_outOfRangeGUIDs.begin(); i != m_outOfRangeGUIDs.end(); ++i) buf << i->WriteAsPacked(); } @@ -123,23 +123,23 @@ bool UpdateData::BuildPacket(WorldPacket *packet) size_t pSize = buf.wpos(); // use real used data size - if (pSize > 100 ) // compress large packets + if (pSize > 100) // compress large packets { uint32 destsize = compressBound(pSize); - packet->resize( destsize + sizeof(uint32) ); + packet->resize(destsize + sizeof(uint32)); packet->put(0, pSize); Compress(const_cast(packet->contents()) + sizeof(uint32), &destsize, (void*)buf.contents(), pSize); if (destsize == 0) return false; - packet->resize( destsize + sizeof(uint32) ); - packet->SetOpcode( SMSG_COMPRESSED_UPDATE_OBJECT ); + packet->resize(destsize + sizeof(uint32)); + packet->SetOpcode(SMSG_COMPRESSED_UPDATE_OBJECT); } else // send small packets without compression { - packet->append( buf ); - packet->SetOpcode( SMSG_UPDATE_OBJECT ); + packet->append(buf); + packet->SetOpcode(SMSG_UPDATE_OBJECT); } return true; diff --git a/src/game/UpdateData.h b/src/game/UpdateData.h index 162e3278a..a9da30e13 100644 --- a/src/game/UpdateData.h +++ b/src/game/UpdateData.h @@ -55,9 +55,9 @@ class UpdateData UpdateData(); void AddOutOfRangeGUID(GuidSet& guids); - void AddOutOfRangeGUID(ObjectGuid const &guid); - void AddUpdateBlock(const ByteBuffer &block); - bool BuildPacket(WorldPacket *packet); + void AddOutOfRangeGUID(ObjectGuid const& guid); + void AddUpdateBlock(const ByteBuffer& block); + bool BuildPacket(WorldPacket* packet); bool HasData() { return m_blockCount > 0 || !m_outOfRangeGUIDs.empty(); } void Clear(); @@ -68,6 +68,6 @@ class UpdateData GuidSet m_outOfRangeGUIDs; ByteBuffer m_data; - void Compress(void* dst, uint32 *dst_size, void* src, int src_size); + void Compress(void* dst, uint32* dst_size, void* src, int src_size); }; #endif diff --git a/src/game/UpdateMask.h b/src/game/UpdateMask.h index 6766c0b50..b95655ca5 100644 --- a/src/game/UpdateMask.h +++ b/src/game/UpdateMask.h @@ -25,28 +25,28 @@ class UpdateMask { public: - UpdateMask( ) : mCount( 0 ), mBlocks( 0 ), mUpdateMask( 0 ) { } - UpdateMask( const UpdateMask& mask ) : mUpdateMask( 0 ) { *this = mask; } + UpdateMask() : mCount(0), mBlocks(0), mUpdateMask(0) { } + UpdateMask(const UpdateMask& mask) : mUpdateMask(0) { *this = mask; } - ~UpdateMask( ) + ~UpdateMask() { - if(mUpdateMask) + if (mUpdateMask) delete [] mUpdateMask; } - void SetBit (uint32 index) + void SetBit(uint32 index) { - ( (uint8 *)mUpdateMask )[ index >> 3 ] |= 1 << ( index & 0x7 ); + ((uint8*)mUpdateMask)[ index >> 3 ] |= 1 << (index & 0x7); } - void UnsetBit (uint32 index) + void UnsetBit(uint32 index) { - ( (uint8 *)mUpdateMask )[ index >> 3 ] &= (0xff ^ (1 << ( index & 0x7 ) ) ); + ((uint8*)mUpdateMask)[ index >> 3 ] &= (0xff ^ (1 << (index & 0x7))); } - bool GetBit (uint32 index) const + bool GetBit(uint32 index) const { - return ( ( (uint8 *)mUpdateMask)[ index >> 3 ] & ( 1 << ( index & 0x7 ) )) != 0; + return (((uint8*)mUpdateMask)[ index >> 3 ] & (1 << (index & 0x7))) != 0; } uint32 GetBlockCount() const { return mBlocks; } @@ -54,9 +54,9 @@ class UpdateMask uint32 GetCount() const { return mCount; } uint8* GetMask() { return (uint8*)mUpdateMask; } - void SetCount (uint32 valuesCount) + void SetCount(uint32 valuesCount) { - if(mUpdateMask) + if (mUpdateMask) delete [] mUpdateMask; mCount = valuesCount; @@ -72,7 +72,7 @@ class UpdateMask memset(mUpdateMask, 0, mBlocks << 2); } - UpdateMask& operator = ( const UpdateMask& mask ) + UpdateMask& operator = (const UpdateMask& mask) { SetCount(mask.mCount); memcpy(mUpdateMask, mask.mUpdateMask, mBlocks << 2); @@ -80,21 +80,21 @@ class UpdateMask return *this; } - void operator &= ( const UpdateMask& mask ) + void operator &= (const UpdateMask& mask) { MANGOS_ASSERT(mask.mCount <= mCount); for (uint32 i = 0; i < mBlocks; ++i) mUpdateMask[i] &= mask.mUpdateMask[i]; } - void operator |= ( const UpdateMask& mask ) + void operator |= (const UpdateMask& mask) { MANGOS_ASSERT(mask.mCount <= mCount); for (uint32 i = 0; i < mBlocks; ++i) mUpdateMask[i] |= mask.mUpdateMask[i]; } - UpdateMask operator & ( const UpdateMask& mask ) const + UpdateMask operator & (const UpdateMask& mask) const { MANGOS_ASSERT(mask.mCount <= mCount); @@ -105,7 +105,7 @@ class UpdateMask return newmask; } - UpdateMask operator | ( const UpdateMask& mask ) const + UpdateMask operator | (const UpdateMask& mask) const { MANGOS_ASSERT(mask.mCount <= mCount); @@ -119,6 +119,6 @@ class UpdateMask private: uint32 mCount; uint32 mBlocks; - uint32 *mUpdateMask; + uint32* mUpdateMask; }; #endif diff --git a/src/game/VoiceChatHandler.cpp b/src/game/VoiceChatHandler.cpp index 5e23ed690..21ed22127 100644 --- a/src/game/VoiceChatHandler.cpp +++ b/src/game/VoiceChatHandler.cpp @@ -22,7 +22,7 @@ #include "Opcodes.h" #include "Log.h" -void WorldSession::HandleVoiceSessionEnableOpcode( WorldPacket & recv_data ) +void WorldSession::HandleVoiceSessionEnableOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_VOICE_SESSION_ENABLE"); // uint8 isVoiceEnabled, uint8 isMicrophoneEnabled @@ -31,14 +31,14 @@ void WorldSession::HandleVoiceSessionEnableOpcode( WorldPacket & recv_data ) recv_data.hexlike(); } -void WorldSession::HandleChannelVoiceOnOpcode( WorldPacket & recv_data ) +void WorldSession::HandleChannelVoiceOnOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_CHANNEL_VOICE_ON"); // Enable Voice button in channel context menu recv_data.hexlike(); } -void WorldSession::HandleSetActiveVoiceChannel( WorldPacket & recv_data ) +void WorldSession::HandleSetActiveVoiceChannel(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_SET_ACTIVE_VOICE_CHANNEL"); recv_data.read_skip(); diff --git a/src/game/WaypointManager.cpp b/src/game/WaypointManager.cpp index d924905c3..7e0ff7e08 100644 --- a/src/game/WaypointManager.cpp +++ b/src/game/WaypointManager.cpp @@ -32,20 +32,20 @@ bool WaypointBehavior::isEmpty() if (emote || spell || model1 || model2) return false; - for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) - if(textid[i]) + for (int i = 0; i < MAX_WAYPOINT_TEXT; ++i) + if (textid[i]) return false; return true; } -WaypointBehavior::WaypointBehavior(const WaypointBehavior &b) +WaypointBehavior::WaypointBehavior(const WaypointBehavior& b) { emote = b.emote; spell = b.spell; model1 = b.model1; model2 = b.model2; - for(int i=0; i < MAX_WAYPOINT_TEXT; ++i) + for (int i=0; i < MAX_WAYPOINT_TEXT; ++i) textid[i] = b.textid[i]; } @@ -59,18 +59,18 @@ void WaypointManager::Load() std::set movementScriptSet; - for(ScriptMapMap::const_iterator itr = sCreatureMovementScripts.second.begin(); itr != sCreatureMovementScripts.second.end(); ++itr) + for (ScriptMapMap::const_iterator itr = sCreatureMovementScripts.second.begin(); itr != sCreatureMovementScripts.second.end(); ++itr) movementScriptSet.insert(itr->first); // creature_movement - QueryResult *result = WorldDatabase.Query("SELECT id, COUNT(point) FROM creature_movement GROUP BY id"); + QueryResult* result = WorldDatabase.Query("SELECT id, COUNT(point) FROM creature_movement GROUP BY id"); if (!result) { BarGoLink bar(1); bar.step(); sLog.outString(); - sLog.outString( ">> Loaded 0 paths. DB table `creature_movement` is empty." ); + sLog.outString(">> Loaded 0 paths. DB table `creature_movement` is empty."); } else { @@ -80,7 +80,7 @@ void WaypointManager::Load() do { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 id = fields[0].GetUInt32(); uint32 count = fields[1].GetUInt32(); @@ -88,17 +88,17 @@ void WaypointManager::Load() m_pathMap[id].resize(count); total_nodes += count; } - while(result->NextRow()); + while (result->NextRow()); sLog.outString(); - sLog.outString( ">> Paths loaded" ); + sLog.outString(">> Paths loaded"); delete result; // 0 1 2 3 4 5 6 result = WorldDatabase.Query("SELECT id, point, position_x, position_y, position_z, waittime, script_id," - // 7 8 9 10 11 12 13 14 15 16 - "textid1, textid2, textid3, textid4, textid5, emote, spell, orientation, model1, model2 FROM creature_movement"); + // 7 8 9 10 11 12 13 14 15 16 + "textid1, textid2, textid3, textid4, textid5, emote, spell, orientation, model1, model2 FROM creature_movement"); BarGoLink barRow((int)result->GetRowCount()); @@ -108,7 +108,7 @@ void WaypointManager::Load() do { barRow.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 id = fields[0].GetUInt32(); uint32 point = fields[1].GetUInt32(); @@ -123,12 +123,12 @@ void WaypointManager::Load() if (cData->movementType != WAYPOINT_MOTION_TYPE) creatureNoMoveType.insert(id); - WaypointPath &path = m_pathMap[id]; + WaypointPath& path = m_pathMap[id]; // the cleanup queries make sure the following is true MANGOS_ASSERT(point >= 1 && point <= path.size()); - WaypointNode &node = path[point-1]; + WaypointNode& node = path[point-1]; node.x = fields[2].GetFloat(); node.y = fields[3].GetFloat(); @@ -140,13 +140,13 @@ void WaypointManager::Load() // prevent using invalid coordinates if (!MaNGOS::IsValidMapCoord(node.x, node.y, node.z, node.orientation)) { - QueryResult *result1 = WorldDatabase.PQuery("SELECT id, map FROM creature WHERE guid = '%u'", id); + QueryResult* result1 = WorldDatabase.PQuery("SELECT id, map FROM creature WHERE guid = '%u'", id); if (result1) sLog.outErrorDb("Creature (guidlow %d, entry %d) have invalid coordinates in his waypoint %d (X: %f, Y: %f).", - id, result1->Fetch()[0].GetUInt32(), point, node.x, node.y); + id, result1->Fetch()[0].GetUInt32(), point, node.x, node.y); else sLog.outErrorDb("Waypoint path %d, have invalid coordinates in his waypoint %d (X: %f, Y: %f).", - id, point, node.x, node.y); + id, point, node.x, node.y); MaNGOS::NormalizeMapCoord(node.x); MaNGOS::NormalizeMapCoord(node.y); @@ -179,7 +179,7 @@ void WaypointManager::Load() be.emote = fields[12].GetUInt32(); be.spell = fields[13].GetUInt32(); - for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) + for (int i = 0; i < MAX_WAYPOINT_TEXT; ++i) { be.textid[i] = fields[7+i].GetUInt32(); @@ -187,7 +187,7 @@ void WaypointManager::Load() { if (be.textid[i] < MIN_DB_SCRIPT_STRING_ID || be.textid[i] >= MAX_DB_SCRIPT_STRING_ID) { - sLog.outErrorDb( "Table `db_script_string` not have string id %u", be.textid[i]); + sLog.outErrorDb("Table `db_script_string` not have string id %u", be.textid[i]); continue; } } @@ -214,11 +214,11 @@ void WaypointManager::Load() else node.behavior = NULL; } - while(result->NextRow()); + while (result->NextRow()); if (!creatureNoMoveType.empty()) { - for(std::set::const_iterator itr = creatureNoMoveType.begin(); itr != creatureNoMoveType.end(); ++itr) + for (std::set::const_iterator itr = creatureNoMoveType.begin(); itr != creatureNoMoveType.end(); ++itr) { const CreatureData* cData = sObjectMgr.GetCreatureData(*itr); const CreatureInfo* cInfo = ObjectMgr::GetCreatureTemplate(cData->id); @@ -231,9 +231,9 @@ void WaypointManager::Load() } sLog.outString(); - sLog.outString( ">> Waypoints and behaviors loaded" ); + sLog.outString(">> Waypoints and behaviors loaded"); sLog.outString(); - sLog.outString( ">>> Loaded %u paths, %u nodes and %u behaviors", total_paths, total_nodes, total_behaviors); + sLog.outString(">>> Loaded %u paths, %u nodes and %u behaviors", total_paths, total_nodes, total_behaviors); delete result; } @@ -246,7 +246,7 @@ void WaypointManager::Load() BarGoLink bar(1); bar.step(); sLog.outString(); - sLog.outString( ">> Loaded 0 path templates. DB table `creature_movement_template` is empty." ); + sLog.outString(">> Loaded 0 path templates. DB table `creature_movement_template` is empty."); } else { @@ -258,7 +258,7 @@ void WaypointManager::Load() do { barRow.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 entry = fields[0].GetUInt32(); uint32 count = fields[1].GetUInt32(); @@ -266,7 +266,7 @@ void WaypointManager::Load() m_pathTemplateMap[entry].resize(count); total_nodes += count; } - while(result->NextRow()); + while (result->NextRow()); delete result; @@ -275,15 +275,15 @@ void WaypointManager::Load() // 0 1 2 3 4 5 6 result = WorldDatabase.Query("SELECT entry, point, position_x, position_y, position_z, waittime, script_id," - // 7 8 9 10 11 12 13 14 15 16 - "textid1, textid2, textid3, textid4, textid5, emote, spell, orientation, model1, model2 FROM creature_movement_template"); + // 7 8 9 10 11 12 13 14 15 16 + "textid1, textid2, textid3, textid4, textid5, emote, spell, orientation, model1, model2 FROM creature_movement_template"); BarGoLink bar(result->GetRowCount()); do { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 entry = fields[0].GetUInt32(); uint32 point = fields[1].GetUInt32(); @@ -296,12 +296,12 @@ void WaypointManager::Load() continue; } - WaypointPath &path = m_pathTemplateMap[entry]; + WaypointPath& path = m_pathTemplateMap[entry]; // the cleanup queries make sure the following is true MANGOS_ASSERT(point >= 1 && point <= path.size()); - WaypointNode &node = path[point-1]; + WaypointNode& node = path[point-1]; node.x = fields[2].GetFloat(); node.y = fields[3].GetFloat(); @@ -314,13 +314,13 @@ void WaypointManager::Load() if (!MaNGOS::IsValidMapCoord(node.x, node.y, node.z, node.orientation)) { sLog.outErrorDb("Table creature_movement_template for entry %u (point %u) are using invalid coordinates position_x: %f, position_y: %f)", - entry, point, node.x, node.y); + entry, point, node.x, node.y); MaNGOS::NormalizeMapCoord(node.x); MaNGOS::NormalizeMapCoord(node.y); sLog.outErrorDb("Table creature_movement_template for entry %u (point %u) are auto corrected to normalized position_x=%f, position_y=%f", - entry, point, node.x, node.y); + entry, point, node.x, node.y); WorldDatabase.PExecute("UPDATE creature_movement_template SET position_x = '%f', position_y = '%f' WHERE entry = %u AND point = %u", node.x, node.y, entry, point); } @@ -342,7 +342,7 @@ void WaypointManager::Load() be.emote = fields[12].GetUInt32(); be.spell = fields[13].GetUInt32(); - for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) + for (int i = 0; i < MAX_WAYPOINT_TEXT; ++i) { be.textid[i] = fields[7+i].GetUInt32(); @@ -350,7 +350,7 @@ void WaypointManager::Load() { if (be.textid[i] < MIN_DB_SCRIPT_STRING_ID || be.textid[i] >= MAX_DB_SCRIPT_STRING_ID) { - sLog.outErrorDb( "Table `db_script_string` not have string id %u", be.textid[i]); + sLog.outErrorDb("Table `db_script_string` not have string id %u", be.textid[i]); continue; } } @@ -377,19 +377,19 @@ void WaypointManager::Load() else node.behavior = NULL; } - while(result->NextRow()); + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Waypoint templates loaded" ); + sLog.outString(">> Waypoint templates loaded"); sLog.outString(); - sLog.outString( ">>> Loaded %u path templates with %u nodes and %u behaviors", total_paths, total_nodes, total_behaviors); + sLog.outString(">>> Loaded %u path templates with %u nodes and %u behaviors", total_paths, total_nodes, total_behaviors); } if (!movementScriptSet.empty()) { - for(std::set::const_iterator itr = movementScriptSet.begin(); itr != movementScriptSet.end(); ++itr) + for (std::set::const_iterator itr = movementScriptSet.begin(); itr != movementScriptSet.end(); ++itr) sLog.outErrorDb("Table `creature_movement_scripts` contain unused script, id %u.", *itr); } } @@ -397,7 +397,7 @@ void WaypointManager::Load() void WaypointManager::Cleanup() { // check if points need to be renumbered and do it - if (QueryResult *result = WorldDatabase.Query("SELECT 1 from creature_movement As T WHERE point <> (SELECT COUNT(*) FROM creature_movement WHERE id = T.id AND point <= T.point) LIMIT 1")) + if (QueryResult* result = WorldDatabase.Query("SELECT 1 from creature_movement As T WHERE point <> (SELECT COUNT(*) FROM creature_movement WHERE id = T.id AND point <= T.point) LIMIT 1")) { delete result; WorldDatabase.DirectExecute("CREATE TEMPORARY TABLE temp LIKE creature_movement"); @@ -412,7 +412,7 @@ void WaypointManager::Cleanup() MANGOS_ASSERT(!(result = WorldDatabase.Query("SELECT 1 from creature_movement As T WHERE point <> (SELECT COUNT(*) FROM creature_movement WHERE id = T.id AND point <= T.point) LIMIT 1"))); } - if (QueryResult *result = WorldDatabase.Query("SELECT 1 from creature_movement_template As T WHERE point <> (SELECT COUNT(*) FROM creature_movement_template WHERE entry = T.entry AND point <= T.point) LIMIT 1")) + if (QueryResult* result = WorldDatabase.Query("SELECT 1 from creature_movement_template As T WHERE point <> (SELECT COUNT(*) FROM creature_movement_template WHERE entry = T.entry AND point <= T.point) LIMIT 1")) { delete result; WorldDatabase.DirectExecute("CREATE TEMPORARY TABLE temp LIKE creature_movement_template"); @@ -430,15 +430,15 @@ void WaypointManager::Cleanup() void WaypointManager::Unload() { - for(WaypointPathMap::iterator itr = m_pathMap.begin(); itr != m_pathMap.end(); ++itr) + for (WaypointPathMap::iterator itr = m_pathMap.begin(); itr != m_pathMap.end(); ++itr) _clearPath(itr->second); m_pathMap.clear(); } -void WaypointManager::_clearPath(WaypointPath &path) +void WaypointManager::_clearPath(WaypointPath& path) { - for(WaypointPath::const_iterator itr = path.begin(); itr != path.end(); ++itr) - if(itr->behavior) + for (WaypointPath::const_iterator itr = path.begin(); itr != path.end(); ++itr) + if (itr->behavior) delete itr->behavior; path.clear(); } @@ -452,7 +452,7 @@ void WaypointManager::AddLastNode(uint32 id, float x, float y, float z, float o, /// - Insert after a certain point void WaypointManager::AddAfterNode(uint32 id, uint32 point, float x, float y, float z, float o, uint32 delay, uint32 wpGuid) { - for(uint32 i = GetLastPoint(id, 0); i > point; i--) + for (uint32 i = GetLastPoint(id, 0); i > point; i--) WorldDatabase.PExecuteLog("UPDATE creature_movement SET point=point+1 WHERE id=%u AND point=%u", id, i); _addNode(id, point + 1, x, y, z, o, delay, wpGuid); @@ -461,12 +461,12 @@ void WaypointManager::AddAfterNode(uint32 id, uint32 point, float x, float y, fl /// - Insert without checking for collision void WaypointManager::_addNode(uint32 id, uint32 point, float x, float y, float z, float o, uint32 delay, uint32 wpGuid) { - if(point == 0) return; // counted from 1 in the DB + if (point == 0) return; // counted from 1 in the DB WorldDatabase.PExecuteLog("INSERT INTO creature_movement (id,point,position_x,position_y,position_z,orientation,wpguid,waittime) " - "VALUES (%u,%u, %f,%f,%f,%f, %u,%u)", - id, point, x, y, z, o, wpGuid, delay); + "VALUES (%u,%u, %f,%f,%f,%f, %u,%u)", + id, point, x, y, z, o, wpGuid, delay); WaypointPathMap::iterator itr = m_pathMap.find(id); - if(itr == m_pathMap.end()) + if (itr == m_pathMap.end()) itr = m_pathMap.insert(WaypointPathMap::value_type(id, WaypointPath())).first; itr->second.insert(itr->second.begin() + (point - 1), WaypointNode(x, y, z, o, delay, 0, NULL)); } @@ -481,18 +481,18 @@ uint32 WaypointManager::GetLastPoint(uint32 id, uint32 default_notfound) delete result; }*/ WaypointPathMap::const_iterator itr = m_pathMap.find(id); - if(itr != m_pathMap.end() && itr->second.size() != 0) + if (itr != m_pathMap.end() && itr->second.size() != 0) point = itr->second.size(); return point; } void WaypointManager::DeleteNode(uint32 id, uint32 point) { - if(point == 0) return; // counted from 1 in the DB + if (point == 0) return; // counted from 1 in the DB WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id=%u AND point=%u", id, point); WorldDatabase.PExecuteLog("UPDATE creature_movement SET point=point-1 WHERE id=%u AND point>%u", id, point); WaypointPathMap::iterator itr = m_pathMap.find(id); - if(itr != m_pathMap.end() && point <= itr->second.size()) + if (itr != m_pathMap.end() && point <= itr->second.size()) itr->second.erase(itr->second.begin() + (point-1)); } @@ -500,7 +500,7 @@ void WaypointManager::DeletePath(uint32 id) { WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id=%u", id); WaypointPathMap::iterator itr = m_pathMap.find(id); - if(itr != m_pathMap.end()) + if (itr != m_pathMap.end()) _clearPath(itr->second); // the path is not removed from the map, just cleared // WMGs have pointers to the path, so deleting them would crash @@ -510,10 +510,10 @@ void WaypointManager::DeletePath(uint32 id) void WaypointManager::SetNodePosition(uint32 id, uint32 point, float x, float y, float z) { - if(point == 0) return; // counted from 1 in the DB + if (point == 0) return; // counted from 1 in the DB WorldDatabase.PExecuteLog("UPDATE creature_movement SET position_x=%f, position_y=%f, position_z=%f WHERE id=%u AND point=%u", x, y, z, id, point); WaypointPathMap::iterator itr = m_pathMap.find(id); - if(itr != m_pathMap.end() && point <= itr->second.size()) + if (itr != m_pathMap.end() && point <= itr->second.size()) { itr->second[point-1].x = x; itr->second[point-1].y = y; @@ -521,14 +521,14 @@ void WaypointManager::SetNodePosition(uint32 id, uint32 point, float x, float y, } } -void WaypointManager::SetNodeText(uint32 id, uint32 point, const char *text_field, const char *text) +void WaypointManager::SetNodeText(uint32 id, uint32 point, const char* text_field, const char* text) { - if(point == 0) return; // counted from 1 in the DB - if(!text_field) return; + if (point == 0) return; // counted from 1 in the DB + if (!text_field) return; std::string field = text_field; WorldDatabase.escape_string(field); - if(!text) + if (!text) { WorldDatabase.PExecuteLog("UPDATE creature_movement SET %s=NULL WHERE id='%u' AND point='%u'", field.c_str(), id, point); } @@ -540,27 +540,27 @@ void WaypointManager::SetNodeText(uint32 id, uint32 point, const char *text_fiel } WaypointPathMap::iterator itr = m_pathMap.find(id); - if(itr != m_pathMap.end() && point <= itr->second.size()) + if (itr != m_pathMap.end() && point <= itr->second.size()) { - WaypointNode &node = itr->second[point-1]; - if(!node.behavior) node.behavior = new WaypointBehavior(); + WaypointNode& node = itr->second[point-1]; + if (!node.behavior) node.behavior = new WaypointBehavior(); // if(field == "text1") node.behavior->text[0] = text ? text : ""; // if(field == "text2") node.behavior->text[1] = text ? text : ""; // if(field == "text3") node.behavior->text[2] = text ? text : ""; // if(field == "text4") node.behavior->text[3] = text ? text : ""; // if(field == "text5") node.behavior->text[4] = text ? text : ""; - if(field == "emote") node.behavior->emote = text ? atoi(text) : 0; - if(field == "spell") node.behavior->spell = text ? atoi(text) : 0; - if(field == "model1") node.behavior->model1 = text ? atoi(text) : 0; - if(field == "model2") node.behavior->model2 = text ? atoi(text) : 0; + if (field == "emote") node.behavior->emote = text ? atoi(text) : 0; + if (field == "spell") node.behavior->spell = text ? atoi(text) : 0; + if (field == "model1") node.behavior->model1 = text ? atoi(text) : 0; + if (field == "model2") node.behavior->model2 = text ? atoi(text) : 0; } } void WaypointManager::CheckTextsExistance(std::set& ids) { WaypointPathMap::const_iterator pmItr = m_pathMap.begin(); - for ( ; pmItr != m_pathMap.end(); ++pmItr) + for (; pmItr != m_pathMap.end(); ++pmItr) { for (size_t i = 0; i < pmItr->second.size(); ++i) { @@ -604,7 +604,7 @@ void WaypointManager::CheckTextsExistance(std::set& ids) } WaypointPathTemplateMap::const_iterator wptItr = m_pathTemplateMap.begin(); - for ( ; wptItr != m_pathTemplateMap.end(); ++wptItr) + for (; wptItr != m_pathTemplateMap.end(); ++wptItr) { for (size_t i = 0; i < wptItr->second.size(); ++i) { diff --git a/src/game/WaypointManager.h b/src/game/WaypointManager.h index 34cda88fa..570422716 100644 --- a/src/game/WaypointManager.h +++ b/src/game/WaypointManager.h @@ -36,7 +36,7 @@ struct WaypointBehavior bool isEmpty(); WaypointBehavior() {} - WaypointBehavior(const WaypointBehavior &b); + WaypointBehavior(const WaypointBehavior& b); }; struct WaypointNode @@ -47,10 +47,10 @@ struct WaypointNode float orientation; uint32 delay; uint32 script_id; // Added may 2010. WaypointBehavior w/DB data should in time be removed. - WaypointBehavior * behavior; + WaypointBehavior* behavior; WaypointNode() : x(0.0f), y(0.0f), z(0.0f), orientation(0.0f), delay(0), script_id(0), behavior(NULL) {} - WaypointNode(float _x, float _y, float _z, float _o, uint32 _delay, uint32 _script_id, WaypointBehavior * _behavior) - : x(_x), y(_y), z(_z), orientation(_o), delay(_delay), script_id(_script_id), behavior(_behavior) {} + WaypointNode(float _x, float _y, float _z, float _o, uint32 _delay, uint32 _script_id, WaypointBehavior* _behavior) + : x(_x), y(_y), z(_z), orientation(_o), delay(_delay), script_id(_script_id), behavior(_behavior) {} }; typedef std::vector WaypointPath; @@ -66,13 +66,13 @@ class WaypointManager void Cleanup(); - WaypointPath *GetPath(uint32 id) + WaypointPath* GetPath(uint32 id) { WaypointPathMap::iterator itr = m_pathMap.find(id); return itr != m_pathMap.end() ? &itr->second : NULL; } - WaypointPath *GetPathTemplate(uint32 entry) + WaypointPath* GetPathTemplate(uint32 entry) { WaypointPathTemplateMap::iterator itr = m_pathTemplateMap.find(entry); return itr != m_pathTemplateMap.end() ? &itr->second : NULL; @@ -84,12 +84,12 @@ class WaypointManager void DeleteNode(uint32 id, uint32 point); void DeletePath(uint32 id); void SetNodePosition(uint32 id, uint32 point, float x, float y, float z); - void SetNodeText(uint32 id, uint32 point, const char *text_field, const char *text); + void SetNodeText(uint32 id, uint32 point, const char* text_field, const char* text); void CheckTextsExistance(std::set& ids); private: void _addNode(uint32 id, uint32 point, float x, float y, float z, float o, uint32 delay, uint32 wpGuid); - void _clearPath(WaypointPath &path); + void _clearPath(WaypointPath& path); typedef UNORDERED_MAP WaypointPathMap; WaypointPathMap m_pathMap; diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index fb3012aac..ad1387f2d 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -45,7 +45,7 @@ alter table creature_movement add `wpguid` int(11) default '0'; #include //-----------------------------------------------// -void WaypointMovementGenerator::LoadPath(Creature &creature) +void WaypointMovementGenerator::LoadPath(Creature& creature) { DETAIL_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "LoadPath: loading waypoint path for %s", creature.GetGuidStr().c_str()); @@ -71,7 +71,7 @@ void WaypointMovementGenerator::LoadPath(Creature &creature) if (!i_path) { sLog.outErrorDb("WaypointMovementGenerator::LoadPath: creature %s (Entry: %u GUID: %u) doesn't have waypoint path", - creature.GetName(), creature.GetEntry(), creature.GetGUIDLow()); + creature.GetName(), creature.GetEntry(), creature.GetGUIDLow()); return; } } @@ -79,25 +79,25 @@ void WaypointMovementGenerator::LoadPath(Creature &creature) StartMoveNow(creature); } -void WaypointMovementGenerator::Initialize(Creature &creature) +void WaypointMovementGenerator::Initialize(Creature& creature) { LoadPath(creature); creature.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); } -void WaypointMovementGenerator::Finalize(Creature &creature) +void WaypointMovementGenerator::Finalize(Creature& creature) { creature.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); creature.SetWalk(false); } -void WaypointMovementGenerator::Interrupt(Creature &creature) +void WaypointMovementGenerator::Interrupt(Creature& creature) { creature.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); creature.SetWalk(false); } -void WaypointMovementGenerator::Reset(Creature &creature) +void WaypointMovementGenerator::Reset(Creature& creature) { creature.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); StartMoveNow(creature); @@ -121,7 +121,7 @@ void WaypointMovementGenerator::OnArrived(Creature& creature) } // We have reached the destination and can process behavior - if (WaypointBehavior *behavior = i_path->at(i_currentNode).behavior) + if (WaypointBehavior* behavior = i_path->at(i_currentNode).behavior) { if (behavior->emote != 0) creature.HandleEmote(behavior->emote); @@ -139,7 +139,7 @@ void WaypointMovementGenerator::OnArrived(Creature& creature) { // Select one from max 5 texts (0 and 1 already checked) int i = 2; - for(; i < MAX_WAYPOINT_TEXT; ++i) + for (; i < MAX_WAYPOINT_TEXT; ++i) { if (!behavior->textid[i]) break; @@ -157,7 +157,7 @@ void WaypointMovementGenerator::OnArrived(Creature& creature) Stop(i_path->at(i_currentNode).delay); } -void WaypointMovementGenerator::StartMove(Creature &creature) +void WaypointMovementGenerator::StartMove(Creature& creature) { if (!i_path || i_path->empty()) return; @@ -165,7 +165,7 @@ void WaypointMovementGenerator::StartMove(Creature &creature) if (Stopped()) return; - if (WaypointBehavior *behavior = i_path->at(i_currentNode).behavior) + if (WaypointBehavior* behavior = i_path->at(i_currentNode).behavior) { if (behavior->model2 != 0) creature.SetDisplayId(behavior->model2); @@ -179,7 +179,7 @@ void WaypointMovementGenerator::StartMove(Creature &creature) creature.addUnitState(UNIT_STAT_ROAMING_MOVE); - const WaypointNode &node = i_path->at(i_currentNode); + const WaypointNode& node = i_path->at(i_currentNode); Movement::MoveSplineInit init(creature); init.MoveTo(node.x, node.y, node.z, true); @@ -189,7 +189,7 @@ void WaypointMovementGenerator::StartMove(Creature &creature) init.Launch(); } -bool WaypointMovementGenerator::Update(Creature &creature, const uint32 &diff) +bool WaypointMovementGenerator::Update(Creature& creature, const uint32& diff) { // Waypoint movement can be switched on/off // This is quite handy for escort quests and other stuff @@ -224,7 +224,7 @@ bool WaypointMovementGenerator::Update(Creature &creature, const uint3 return true; } -void WaypointMovementGenerator::MovementInform(Creature &creature) +void WaypointMovementGenerator::MovementInform(Creature& creature) { if (creature.AI()) creature.AI()->MovementInform(WAYPOINT_MOTION_TYPE, i_currentNode); @@ -249,7 +249,7 @@ uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const uint32 curMapId = (*i_path)[i_currentNode].mapid; - for(uint32 i = i_currentNode; i < i_path->size(); ++i) + for (uint32 i = i_currentNode; i < i_path->size(); ++i) { if ((*i_path)[i].mapid != curMapId) return i; @@ -258,12 +258,12 @@ uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const return i_path->size(); } -void FlightPathMovementGenerator::Initialize(Player &player) +void FlightPathMovementGenerator::Initialize(Player& player) { Reset(player); } -void FlightPathMovementGenerator::Finalize(Player & player) +void FlightPathMovementGenerator::Finalize(Player& player) { // remove flag to prevent send object build movement packets for flight state and crash (movement generator already not at top of stack) player.clearUnitState(UNIT_STAT_TAXI_FLIGHT); @@ -271,10 +271,10 @@ void FlightPathMovementGenerator::Finalize(Player & player) player.Unmount(); player.RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); - if(player.m_taxi.empty()) + if (player.m_taxi.empty()) { player.getHostileRefManager().setOnlineOfflineState(true); - if(player.pvpInfo.inHostileArea) + if (player.pvpInfo.inHostileArea) player.CastSpell(&player, 2479, true); // update z position to ground and orientation for landing point @@ -284,14 +284,14 @@ void FlightPathMovementGenerator::Finalize(Player & player) } } -void FlightPathMovementGenerator::Interrupt(Player & player) +void FlightPathMovementGenerator::Interrupt(Player& player) { player.clearUnitState(UNIT_STAT_TAXI_FLIGHT); } #define PLAYER_FLIGHT_SPEED 32.0f -void FlightPathMovementGenerator::Reset(Player & player) +void FlightPathMovementGenerator::Reset(Player& player) { player.getHostileRefManager().setOnlineOfflineState(false); player.addUnitState(UNIT_STAT_TAXI_FLIGHT); @@ -310,7 +310,7 @@ void FlightPathMovementGenerator::Reset(Player & player) init.Launch(); } -bool FlightPathMovementGenerator::Update(Player &player, const uint32 &diff) +bool FlightPathMovementGenerator::Update(Player& player, const uint32& diff) { uint32 pointId = (uint32)player.movespline->currentPathIdx(); if (pointId > i_currentNode) @@ -323,7 +323,8 @@ bool FlightPathMovementGenerator::Update(Player &player, const uint32 &diff) break; i_currentNode += (uint32)departureEvent; departureEvent = !departureEvent; - } while(true); + } + while (true); } return i_currentNode < (i_path->size()-1); diff --git a/src/game/WaypointMovementGenerator.h b/src/game/WaypointMovementGenerator.h index 27541ea12..6b3eac33b 100644 --- a/src/game/WaypointMovementGenerator.h +++ b/src/game/WaypointMovementGenerator.h @@ -44,7 +44,7 @@ class MANGOS_DLL_SPEC PathMovementBase virtual ~PathMovementBase() {}; // template pattern, not defined .. override required - void LoadPath(T &); + void LoadPath(T&); uint32 GetCurrentNode() const { return i_currentNode; } protected: @@ -62,24 +62,24 @@ class MANGOS_DLL_SPEC WaypointMovementGenerator; template<> class MANGOS_DLL_SPEC WaypointMovementGenerator -: public MovementGeneratorMedium< Creature, WaypointMovementGenerator >, -public PathMovementBase + : public MovementGeneratorMedium< Creature, WaypointMovementGenerator >, + public PathMovementBase { public: - WaypointMovementGenerator(Creature &) : i_nextMoveTime(0), m_isArrivalDone(false) {} + WaypointMovementGenerator(Creature&) : i_nextMoveTime(0), m_isArrivalDone(false) {} ~WaypointMovementGenerator() { i_path = NULL; } - void Initialize(Creature &u); - void Interrupt(Creature &); - void Finalize(Creature &); - void Reset(Creature &u); - bool Update(Creature &u, const uint32 &diff); + void Initialize(Creature& u); + void Interrupt(Creature&); + void Finalize(Creature&); + void Reset(Creature& u); + bool Update(Creature& u, const uint32& diff); - void MovementInform(Creature &); + void MovementInform(Creature&); MovementGeneratorType GetMovementGeneratorType() const { return WAYPOINT_MOTION_TYPE; } // now path movement implmementation - void LoadPath(Creature &c); + void LoadPath(Creature& c); bool GetResetPosition(Creature&, float& x, float& y, float& z); @@ -112,8 +112,8 @@ public PathMovementBase * and hence generates ground and activities for the player. */ class MANGOS_DLL_SPEC FlightPathMovementGenerator -: public MovementGeneratorMedium< Player, FlightPathMovementGenerator >, -public PathMovementBase + : public MovementGeneratorMedium< Player, FlightPathMovementGenerator >, + public PathMovementBase { public: explicit FlightPathMovementGenerator(TaxiPathNodeList const& pathnodes, uint32 startNode = 0) @@ -121,11 +121,11 @@ public PathMovementBase i_path = &pathnodes; i_currentNode = startNode; } - void Initialize(Player &); - void Finalize(Player &); - void Interrupt(Player &); - void Reset(Player &); - bool Update(Player &, const uint32 &); + void Initialize(Player&); + void Finalize(Player&); + void Interrupt(Player&); + void Reset(Player&); + bool Update(Player&, const uint32&); MovementGeneratorType GetMovementGeneratorType() const { return FLIGHT_MOTION_TYPE; } TaxiPathNodeList const& GetPath() { return *i_path; } diff --git a/src/game/Weather.cpp b/src/game/Weather.cpp index 169fb2154..4fc637866 100644 --- a/src/game/Weather.cpp +++ b/src/game/Weather.cpp @@ -35,7 +35,7 @@ Weather::Weather(uint32 zone, WeatherZoneChances const* weatherChances) : m_zone m_type = WEATHER_TYPE_FINE; m_grade = 0; - DETAIL_FILTER_LOG(LOG_FILTER_WEATHER, "WORLD: Starting weather system for zone %u (change every %u minutes).", m_zone, (m_timer.GetInterval() / (MINUTE*IN_MILLISECONDS)) ); + DETAIL_FILTER_LOG(LOG_FILTER_WEATHER, "WORLD: Starting weather system for zone %u (change every %u minutes).", m_zone, (m_timer.GetInterval() / (MINUTE*IN_MILLISECONDS))); } /// Launch a weather update @@ -44,14 +44,14 @@ bool Weather::Update(time_t diff) m_timer.Update(diff); ///- If the timer has passed, ReGenerate the weather - if(m_timer.Passed()) + if (m_timer.Passed()) { m_timer.Reset(); // update only if Regenerate has changed the weather - if(ReGenerate()) + if (ReGenerate()) { ///- Weather will be removed if not updated (no players in zone anymore) - if(!UpdateWeather()) + if (!UpdateWeather()) return false; } } @@ -85,7 +85,7 @@ bool Weather::ReGenerate() //78 days between January 1st and March 20nd; 365/4=91 days by season // season source http://aa.usno.navy.mil/data/docs/EarthSeasons.html time_t gtime = sWorld.GetGameTime(); - struct tm * ltime = localtime(>ime); + struct tm* ltime = localtime(>ime); uint32 season = ((ltime->tm_yday - 78 + 365)/91)%4; static char const* seasonName[WEATHER_SEASONS] = { "spring", "summer", "fall", "winter" }; @@ -126,7 +126,7 @@ bool Weather::ReGenerate() { if (m_grade > 0.6666667f) { - // Severe change, but how severe? + // Severe change, but how severe? uint32 rnd = urand(0,99); if (rnd < 50) { @@ -145,11 +145,11 @@ bool Weather::ReGenerate() uint32 chance3 = chance2+ m_weatherChances->data[season].stormChance; uint32 rnd = urand(0, 99); - if(rnd <= chance1) + if (rnd <= chance1) m_type = WEATHER_TYPE_RAIN; - else if(rnd <= chance2) + else if (rnd <= chance2) m_type = WEATHER_TYPE_SNOW; - else if(rnd <= chance3) + else if (rnd <= chance3) m_type = WEATHER_TYPE_STORM; else m_type = WEATHER_TYPE_FINE; @@ -182,27 +182,27 @@ bool Weather::ReGenerate() return m_type != old_type || m_grade != old_grade; } -void Weather::SendWeatherUpdateToPlayer(Player *player) +void Weather::SendWeatherUpdateToPlayer(Player* player) { - WorldPacket data( SMSG_WEATHER, (4+4+1) ); + WorldPacket data(SMSG_WEATHER, (4+4+1)); data << uint32(GetWeatherState()) << (float)m_grade << uint8(0); - player->GetSession()->SendPacket( &data ); + player->GetSession()->SendPacket(&data); } -void Weather::SendFineWeatherUpdateToPlayer(Player *player) +void Weather::SendFineWeatherUpdateToPlayer(Player* player) { - WorldPacket data( SMSG_WEATHER, (4+4+1) ); + WorldPacket data(SMSG_WEATHER, (4+4+1)); data << (uint32)WEATHER_STATE_FINE << (float)0.0f << uint8(0); - player->GetSession()->SendPacket( &data ); + player->GetSession()->SendPacket(&data); } /// Send the new weather to all players in the zone bool Weather::UpdateWeather() { Player* player = sWorld.FindPlayerInZone(m_zone); - if(!player) + if (!player) return false; ///- Send the weather packet to all players in this zone @@ -213,13 +213,13 @@ bool Weather::UpdateWeather() WeatherState state = GetWeatherState(); - WorldPacket data( SMSG_WEATHER, (4+4+1) ); + WorldPacket data(SMSG_WEATHER, (4+4+1)); data << uint32(state) << (float)m_grade << uint8(0); - player->SendMessageToSet( &data, true ); + player->SendMessageToSet(&data, true); ///- Log the event char const* wthstr; - switch(state) + switch (state) { case WEATHER_STATE_LIGHT_RAIN: wthstr = "light rain"; @@ -268,7 +268,7 @@ bool Weather::UpdateWeather() /// Set the weather void Weather::SetWeather(WeatherType type, float grade) { - if(m_type == type && m_grade == grade) + if (m_type == type && m_grade == grade) return; m_type = type; @@ -282,26 +282,26 @@ WeatherState Weather::GetWeatherState() const if (m_grade<0.27f) return WEATHER_STATE_FINE; - switch(m_type) + switch (m_type) { case WEATHER_TYPE_RAIN: - if(m_grade<0.40f) + if (m_grade<0.40f) return WEATHER_STATE_LIGHT_RAIN; - else if(m_grade<0.70f) + else if (m_grade<0.70f) return WEATHER_STATE_MEDIUM_RAIN; else return WEATHER_STATE_HEAVY_RAIN; case WEATHER_TYPE_SNOW: - if(m_grade<0.40f) + if (m_grade<0.40f) return WEATHER_STATE_LIGHT_SNOW; - else if(m_grade<0.70f) + else if (m_grade<0.70f) return WEATHER_STATE_MEDIUM_SNOW; else return WEATHER_STATE_HEAVY_SNOW; case WEATHER_TYPE_STORM: - if(m_grade<0.40f) + if (m_grade<0.40f) return WEATHER_STATE_LIGHT_SANDSTORM; - else if(m_grade<0.70f) + else if (m_grade<0.70f) return WEATHER_STATE_MEDIUM_SANDSTORM; else return WEATHER_STATE_HEAVY_SANDSTORM; diff --git a/src/game/Weather.h b/src/game/Weather.h index 8281e81d9..7670247af 100644 --- a/src/game/Weather.h +++ b/src/game/Weather.h @@ -55,8 +55,8 @@ class Weather ~Weather() { }; bool ReGenerate(); bool UpdateWeather(); - void SendWeatherUpdateToPlayer(Player *player); - static void SendFineWeatherUpdateToPlayer(Player *player); + void SendWeatherUpdateToPlayer(Player* player); + static void SendFineWeatherUpdateToPlayer(Player* player); void SetWeather(WeatherType type, float grade); /// For which zone is this weather? uint32 GetZone() { return m_zone; }; diff --git a/src/game/World.cpp b/src/game/World.cpp index 93d82cfe5..59f9a9fb8 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -66,7 +66,7 @@ #include "CharacterDatabaseCleaner.h" #include "CreatureLinkingMgr.h" -INSTANTIATE_SINGLETON_1( World ); +INSTANTIATE_SINGLETON_1(World); volatile bool World::m_stopEvent = false; uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE; @@ -100,16 +100,16 @@ World::World() m_defaultDbcLocale = LOCALE_enUS; m_availableDbcLocaleMask = 0; - for(int i = 0; i < CONFIG_UINT32_VALUE_COUNT; ++i) + for (int i = 0; i < CONFIG_UINT32_VALUE_COUNT; ++i) m_configUint32Values[i] = 0; - for(int i = 0; i < CONFIG_INT32_VALUE_COUNT; ++i) + for (int i = 0; i < CONFIG_INT32_VALUE_COUNT; ++i) m_configInt32Values[i] = 0; - for(int i = 0; i < CONFIG_FLOAT_VALUE_COUNT; ++i) + for (int i = 0; i < CONFIG_FLOAT_VALUE_COUNT; ++i) m_configFloatValues[i] = 0.0f; - for(int i = 0; i < CONFIG_BOOL_VALUE_COUNT; ++i) + for (int i = 0; i < CONFIG_BOOL_VALUE_COUNT; ++i) m_configBoolValues[i] = false; } @@ -147,12 +147,12 @@ Player* World::FindPlayerInZone(uint32 zone) SessionMap::const_iterator itr; for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) { - if(!itr->second) + if (!itr->second) continue; - Player *player = itr->second->GetPlayer(); - if(!player) + Player* player = itr->second->GetPlayer(); + if (!player) continue; - if( player->IsInWorld() && player->GetZoneId() == zone ) + if (player->IsInWorld() && player->GetZoneId() == zone) { // Used by the weather system. We return the player to broadcast the change weather message to him and all players in the zone. return player; @@ -166,7 +166,7 @@ WorldSession* World::FindSession(uint32 id) const { SessionMap::const_iterator itr = m_sessions.find(id); - if(itr != m_sessions.end()) + if (itr != m_sessions.end()) return itr->second; // also can return NULL for kicked session else return NULL; @@ -178,7 +178,7 @@ bool World::RemoveSession(uint32 id) ///- Find the session, kick the user, but we can't delete session at this moment to prevent iterator invalidation SessionMap::const_iterator itr = m_sessions.find(id); - if(itr != m_sessions.end() && itr->second) + if (itr != m_sessions.end() && itr->second) { if (itr->second->PlayerLoading()) return false; @@ -194,17 +194,17 @@ void World::AddSession(WorldSession* s) } void -World::AddSession_ (WorldSession* s) +World::AddSession_(WorldSession* s) { - MANGOS_ASSERT (s); + MANGOS_ASSERT(s); //NOTE - Still there is race condition in WorldSession* being used in the Sockets ///- kick already loaded player with same account (if any) and remove session ///- if player is in loading and want to load again, return - if (!RemoveSession (s->GetAccountId ())) + if (!RemoveSession(s->GetAccountId())) { - s->KickPlayer (); + s->KickPlayer(); delete s; // session not added yet in session list, so not listed in queue return; } @@ -215,19 +215,19 @@ World::AddSession_ (WorldSession* s) // if session already exist, prepare to it deleting at next world update // NOTE - KickPlayer() should be called on "old" in RemoveSession() { - SessionMap::const_iterator old = m_sessions.find(s->GetAccountId ()); + SessionMap::const_iterator old = m_sessions.find(s->GetAccountId()); - if(old != m_sessions.end()) + if (old != m_sessions.end()) { // prevent decrease sessions count if session queued - if(RemoveQueuedSession(old->second)) + if (RemoveQueuedSession(old->second)) decrease_session = false; // not remove replaced session form queue if listed delete old->second; } } - m_sessions[s->GetAccountId ()] = s; + m_sessions[s->GetAccountId()] = s; uint32 Sessions = GetActiveAndQueuedSessionCount(); uint32 pLimit = GetPlayerAmountLimit(); @@ -235,14 +235,14 @@ World::AddSession_ (WorldSession* s) //so we don't count the user trying to //login as a session and queue the socket that we are using - if(decrease_session) + if (decrease_session) --Sessions; - if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity () == SEC_PLAYER ) + if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity() == SEC_PLAYER) { AddQueuedSession(s); UpdateMaxSessionCounters(); - DETAIL_LOG("PlayerQueue: Account id %u is in Queue Position (%u).", s->GetAccountId (), ++QueueSize); + DETAIL_LOG("PlayerQueue: Account id %u is in Queue Position (%u).", s->GetAccountId(), ++QueueSize); return; } @@ -262,7 +262,7 @@ World::AddSession_ (WorldSession* s) s->SendTutorialsData(); - UpdateMaxSessionCounters (); + UpdateMaxSessionCounters(); // Updates the population if (pLimit > 0) @@ -284,8 +284,8 @@ int32 World::GetQueuedSessionPos(WorldSession* sess) { uint32 position = 1; - for(Queue::const_iterator iter = m_QueuedSessions.begin(); iter != m_QueuedSessions.end(); ++iter, ++position) - if((*iter) == sess) + for (Queue::const_iterator iter = m_QueuedSessions.begin(); iter != m_QueuedSessions.end(); ++iter, ++position) + if ((*iter) == sess) return position; return 0; @@ -294,10 +294,10 @@ int32 World::GetQueuedSessionPos(WorldSession* sess) void World::AddQueuedSession(WorldSession* sess) { sess->SetInQueue(true); - m_QueuedSessions.push_back (sess); + m_QueuedSessions.push_back(sess); // The 1st SMSG_AUTH_RESPONSE needs to contain other info too. - WorldPacket packet (SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1 + 4 + 1); + WorldPacket packet(SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1 + 4 + 1); packet << uint8(AUTH_WAIT_QUEUE); packet << uint32(0); // BillingTimeRemaining packet << uint8(0); // BillingPlanFlags @@ -319,9 +319,9 @@ bool World::RemoveQueuedSession(WorldSession* sess) // search to remove and count skipped positions bool found = false; - for(;iter != m_QueuedSessions.end(); ++iter, ++position) + for (; iter != m_QueuedSessions.end(); ++iter, ++position) { - if(*iter==sess) + if (*iter==sess) { sess->SetInQueue(false); iter = m_QueuedSessions.erase(iter); @@ -334,11 +334,11 @@ bool World::RemoveQueuedSession(WorldSession* sess) // position store position of removed socket and then new position next socket after removed // if session not queued then we need decrease sessions count - if(!found && sessions) + if (!found && sessions) --sessions; // accept first in queue - if( (!m_playerLimit || (int32)sessions < m_playerLimit) && !m_QueuedSessions.empty() ) + if ((!m_playerLimit || (int32)sessions < m_playerLimit) && !m_QueuedSessions.empty()) { WorldSession* pop_sess = m_QueuedSessions.front(); pop_sess->SetInQueue(false); @@ -361,7 +361,7 @@ bool World::RemoveQueuedSession(WorldSession* sess) // update position from iter to end() // iter point to first not updated socket, position store new position - for(; iter != m_QueuedSessions.end(); ++iter, ++position) + for (; iter != m_QueuedSessions.end(); ++iter, ++position) (*iter)->SendAuthWaitQue(position); return found; @@ -372,7 +372,7 @@ Weather* World::FindWeather(uint32 id) const { WeatherMap::const_iterator itr = m_weathers.find(id); - if(itr != m_weathers.end()) + if (itr != m_weathers.end()) return itr->second; else return 0; @@ -384,7 +384,7 @@ void World::RemoveWeather(uint32 id) // not called at the moment. Kept for completeness WeatherMap::iterator itr = m_weathers.find(id); - if(itr != m_weathers.end()) + if (itr != m_weathers.end()) { delete itr->second; m_weathers.erase(itr); @@ -397,7 +397,7 @@ Weather* World::AddWeather(uint32 zone_id) WeatherZoneChances const* weatherChances = sObjectMgr.GetWeatherChances(zone_id); // zone not have weather, ignore - if(!weatherChances) + if (!weatherChances) return NULL; Weather* w = new Weather(zone_id,weatherChances); @@ -443,8 +443,8 @@ void World::LoadConfigSettings(bool reload) } ///- Read the player limit and the Message of the day from the config file - SetPlayerLimit( sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT), true ); - SetMotd( sConfig.GetStringDefault("Motd", "Welcome to the Massive Network Game Object Server." ) ); + SetPlayerLimit(sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT), true); + SetMotd(sConfig.GetStringDefault("Motd", "Welcome to the Massive Network Game Object Server.")); ///- Read all rates from the config file setConfigPos(CONFIG_FLOAT_RATE_HEALTH, "Rate.Health", 1.0f); @@ -755,10 +755,10 @@ void World::LoadConfigSettings(bool reload) setConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET, "Network.KickOnBadPacket", false); - if(int clientCacheId = sConfig.GetIntDefault("ClientCacheVersion", 0)) + if (int clientCacheId = sConfig.GetIntDefault("ClientCacheVersion", 0)) { // overwrite DB/old value - if(clientCacheId > 0) + if (clientCacheId > 0) { setConfig(CONFIG_UINT32_CLIENTCACHE_VERSION, clientCacheId); sLog.outString("Client cache version set to: %u", clientCacheId); @@ -785,13 +785,13 @@ void World::LoadConfigSettings(bool reload) m_relocation_lower_limit_sq = pow(sConfig.GetFloatDefault("Visibility.RelocationLowerLimit",10), 2); m_VisibleUnitGreyDistance = sConfig.GetFloatDefault("Visibility.Distance.Grey.Unit", 1); - if(m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) + if (m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { sLog.outError("Visibility.Distance.Grey.Unit can't be greater %f",MAX_VISIBILITY_DISTANCE); m_VisibleUnitGreyDistance = MAX_VISIBILITY_DISTANCE; } m_VisibleObjectGreyDistance = sConfig.GetFloatDefault("Visibility.Distance.Grey.Object", 10); - if(m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) + if (m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) { sLog.outError("Visibility.Distance.Grey.Object can't be greater %f",MAX_VISIBILITY_DISTANCE); m_VisibleObjectGreyDistance = MAX_VISIBILITY_DISTANCE; @@ -799,12 +799,12 @@ void World::LoadConfigSettings(bool reload) //visibility on continents m_MaxVisibleDistanceOnContinents = sConfig.GetFloatDefault("Visibility.Distance.Continents", DEFAULT_VISIBILITY_DISTANCE); - if(m_MaxVisibleDistanceOnContinents < 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)) + if (m_MaxVisibleDistanceOnContinents < 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)) { sLog.outError("Visibility.Distance.Continents can't be less max aggro radius %f", 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)); m_MaxVisibleDistanceOnContinents = 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); } - else if(m_MaxVisibleDistanceOnContinents + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) + else if (m_MaxVisibleDistanceOnContinents + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { sLog.outError("Visibility.Distance.Continents can't be greater %f",MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); m_MaxVisibleDistanceOnContinents = MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance; @@ -812,12 +812,12 @@ void World::LoadConfigSettings(bool reload) //visibility in instances m_MaxVisibleDistanceInInstances = sConfig.GetFloatDefault("Visibility.Distance.Instances", DEFAULT_VISIBILITY_INSTANCE); - if(m_MaxVisibleDistanceInInstances < 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)) + if (m_MaxVisibleDistanceInInstances < 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)) { sLog.outError("Visibility.Distance.Instances can't be less max aggro radius %f",45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)); m_MaxVisibleDistanceInInstances = 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); } - else if(m_MaxVisibleDistanceInInstances + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) + else if (m_MaxVisibleDistanceInInstances + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { sLog.outError("Visibility.Distance.Instances can't be greater %f",MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); m_MaxVisibleDistanceInInstances = MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance; @@ -825,19 +825,19 @@ void World::LoadConfigSettings(bool reload) //visibility in BG/Arenas m_MaxVisibleDistanceInBGArenas = sConfig.GetFloatDefault("Visibility.Distance.BGArenas", DEFAULT_VISIBILITY_BGARENAS); - if(m_MaxVisibleDistanceInBGArenas < 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)) + if (m_MaxVisibleDistanceInBGArenas < 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)) { sLog.outError("Visibility.Distance.BGArenas can't be less max aggro radius %f",45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)); m_MaxVisibleDistanceInBGArenas = 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); } - else if(m_MaxVisibleDistanceInBGArenas + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) + else if (m_MaxVisibleDistanceInBGArenas + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { sLog.outError("Visibility.Distance.BGArenas can't be greater %f",MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); m_MaxVisibleDistanceInBGArenas = MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance; } m_MaxVisibleDistanceInFlight = sConfig.GetFloatDefault("Visibility.Distance.InFlight", DEFAULT_VISIBILITY_DISTANCE); - if(m_MaxVisibleDistanceInFlight + m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) + if (m_MaxVisibleDistanceInFlight + m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) { sLog.outError("Visibility.Distance.InFlight can't be greater %f",MAX_VISIBILITY_DISTANCE-m_VisibleObjectGreyDistance); m_MaxVisibleDistanceInFlight = MAX_VISIBILITY_DISTANCE - m_VisibleObjectGreyDistance; @@ -887,9 +887,9 @@ void World::LoadConfigSettings(bool reload) VMAP::VMapFactory::createOrGetVMapManager()->setEnableLineOfSightCalc(enableLOS); VMAP::VMapFactory::createOrGetVMapManager()->setEnableHeightCalc(enableHeight); VMAP::VMapFactory::preventSpellsFromBeingTestedForLoS(ignoreSpellIds.c_str()); - sLog.outString( "WORLD: VMap support included. LineOfSight:%i, getHeight:%i, indoorCheck:%i", - enableLOS, enableHeight, getConfig(CONFIG_BOOL_VMAP_INDOOR_CHECK) ? 1 : 0); - sLog.outString( "WORLD: VMap data directory is: %svmaps",m_dataPath.c_str()); + sLog.outString("WORLD: VMap support included. LineOfSight:%i, getHeight:%i, indoorCheck:%i", + enableLOS, enableHeight, getConfig(CONFIG_BOOL_VMAP_INDOOR_CHECK) ? 1 : 0); + sLog.outString("WORLD: VMap data directory is: %svmaps",m_dataPath.c_str()); setConfig(CONFIG_BOOL_MMAP_ENABLED, "mmap.enabled", true); std::string ignoreMapIds = sConfig.GetStringDefault("mmap.ignoreMapIds", ""); @@ -914,14 +914,14 @@ void World::SetInitialWorldSettings() ///- Check the existence of the map files for all races start areas. if (!MapManager::ExistMapAndVMap(0,-6240.32f, 331.033f) || - !MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f) || - !MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f) || - !MapManager::ExistMapAndVMap(1,-618.518f,-4251.67f) || - !MapManager::ExistMapAndVMap(0, 1676.35f, 1677.45f) || - !MapManager::ExistMapAndVMap(1, 10311.3f, 832.463f) || - !MapManager::ExistMapAndVMap(1,-2917.58f,-257.98f) || - (m_configUint32Values[CONFIG_UINT32_EXPANSION] && - (!MapManager::ExistMapAndVMap(530,10349.6f,-6357.29f) || !MapManager::ExistMapAndVMap(530,-3961.64f,-13931.2f)))) + !MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f) || + !MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f) || + !MapManager::ExistMapAndVMap(1,-618.518f,-4251.67f) || + !MapManager::ExistMapAndVMap(0, 1676.35f, 1677.45f) || + !MapManager::ExistMapAndVMap(1, 10311.3f, 832.463f) || + !MapManager::ExistMapAndVMap(1,-2917.58f,-257.98f) || + (m_configUint32Values[CONFIG_UINT32_EXPANSION] && + (!MapManager::ExistMapAndVMap(530,10349.6f,-6357.29f) || !MapManager::ExistMapAndVMap(530,-3961.64f,-13931.2f)))) { sLog.outError("Correct *.map files not found in path '%smaps' or *.vmtree/*.vmtile files in '%svmaps'. Please place *.map and vmap files in appropriate directories or correct the DataDir value in the mangosd.conf file.",m_dataPath.c_str(),m_dataPath.c_str()); Log::WaitBeforeContinueIfNeed(); @@ -954,16 +954,16 @@ void World::SetInitialWorldSettings() DetectDBCLang(); sObjectMgr.SetDBCLocaleIndex(GetDefaultDbcLocale()); // Get once for all the locale index of DBC language (console/broadcasts) - sLog.outString( "Loading SpellTemplate..." ); + sLog.outString("Loading SpellTemplate..."); sObjectMgr.LoadSpellTemplate(); - sLog.outString( "Loading Script Names..."); + sLog.outString("Loading Script Names..."); sScriptMgr.LoadScriptNames(); - sLog.outString( "Loading WorldTemplate..." ); + sLog.outString("Loading WorldTemplate..."); sObjectMgr.LoadWorldTemplate(); - sLog.outString( "Loading InstanceTemplate..." ); + sLog.outString("Loading InstanceTemplate..."); sObjectMgr.LoadInstanceTemplate(); sLog.outString("Loading SkillLineAbilityMultiMap Data..."); @@ -973,53 +973,53 @@ void World::SetInitialWorldSettings() sSpellMgr.LoadSkillRaceClassInfoMap(); ///- Clean up and pack instances - sLog.outString( "Cleaning up instances..." ); + sLog.outString("Cleaning up instances..."); sMapPersistentStateMgr.CleanupInstances(); // must be called before `creature_respawn`/`gameobject_respawn` tables - sLog.outString( "Packing instances..." ); + sLog.outString("Packing instances..."); sMapPersistentStateMgr.PackInstances(); - sLog.outString( "Packing groups..." ); + sLog.outString("Packing groups..."); sObjectMgr.PackGroupIds(); // must be after CleanupInstances ///- Init highest guids before any guid using table loading to prevent using not initialized guids in some code. sObjectMgr.SetHighestGuids(); // must be after PackInstances() and PackGroupIds() sLog.outString(); - sLog.outString( "Loading Page Texts..." ); + sLog.outString("Loading Page Texts..."); sObjectMgr.LoadPageTexts(); - sLog.outString( "Loading Game Object Templates..." ); // must be after LoadPageTexts + sLog.outString("Loading Game Object Templates..."); // must be after LoadPageTexts sObjectMgr.LoadGameobjectInfo(); - sLog.outString( "Loading Spell Chain Data..." ); + sLog.outString("Loading Spell Chain Data..."); sSpellMgr.LoadSpellChains(); - sLog.outString( "Loading Spell Elixir types..." ); + sLog.outString("Loading Spell Elixir types..."); sSpellMgr.LoadSpellElixirs(); - sLog.outString( "Loading Spell Learn Skills..." ); + sLog.outString("Loading Spell Learn Skills..."); sSpellMgr.LoadSpellLearnSkills(); // must be after LoadSpellChains - sLog.outString( "Loading Spell Learn Spells..." ); + sLog.outString("Loading Spell Learn Spells..."); sSpellMgr.LoadSpellLearnSpells(); - sLog.outString( "Loading Spell Proc Event conditions..." ); + sLog.outString("Loading Spell Proc Event conditions..."); sSpellMgr.LoadSpellProcEvents(); - sLog.outString( "Loading Spell Bonus Data..." ); + sLog.outString("Loading Spell Bonus Data..."); sSpellMgr.LoadSpellBonuses(); // must be after LoadSpellChains - sLog.outString( "Loading Spell Proc Item Enchant..." ); + sLog.outString("Loading Spell Proc Item Enchant..."); sSpellMgr.LoadSpellProcItemEnchant(); // must be after LoadSpellChains - sLog.outString( "Loading Aggro Spells Definitions..."); + sLog.outString("Loading Aggro Spells Definitions..."); sSpellMgr.LoadSpellThreats(); - sLog.outString( "Loading NPC Texts..." ); + sLog.outString("Loading NPC Texts..."); sObjectMgr.LoadGossipText(); - sLog.outString( "Loading Item Random Enchantments Table..." ); + sLog.outString("Loading Item Random Enchantments Table..."); LoadRandomEnchantmentsTable(); sLog.outString("Loading Items..."); // must be after LoadRandomEnchantmentsTable and LoadPageTexts @@ -1031,207 +1031,207 @@ void World::SetInitialWorldSettings() sLog.outString("Loading Item expire converts..."); // must be after LoadItemPrototypes sObjectMgr.LoadItemExpireConverts(); - sLog.outString( "Loading Creature Model Based Info Data..." ); + sLog.outString("Loading Creature Model Based Info Data..."); sObjectMgr.LoadCreatureModelInfo(); - sLog.outString( "Loading Equipment templates..."); + sLog.outString("Loading Equipment templates..."); sObjectMgr.LoadEquipmentTemplates(); - sLog.outString( "Loading Creature templates..." ); + sLog.outString("Loading Creature templates..."); sObjectMgr.LoadCreatureTemplates(); - sLog.outString( "Loading Creature Model for race..." ); // must be after creature templates + sLog.outString("Loading Creature Model for race..."); // must be after creature templates sObjectMgr.LoadCreatureModelRace(); - sLog.outString( "Loading SpellsScriptTarget..."); + sLog.outString("Loading SpellsScriptTarget..."); sSpellMgr.LoadSpellScriptTarget(); // must be after LoadCreatureTemplates and LoadGameobjectInfo - sLog.outString( "Loading ItemRequiredTarget..."); + sLog.outString("Loading ItemRequiredTarget..."); sObjectMgr.LoadItemRequiredTarget(); - sLog.outString( "Loading Reputation Reward Rates..."); + sLog.outString("Loading Reputation Reward Rates..."); sObjectMgr.LoadReputationRewardRate(); - sLog.outString( "Loading Creature Reputation OnKill Data..." ); + sLog.outString("Loading Creature Reputation OnKill Data..."); sObjectMgr.LoadReputationOnKill(); - sLog.outString( "Loading Reputation Spillover Data..." ); + sLog.outString("Loading Reputation Spillover Data..."); sObjectMgr.LoadReputationSpilloverTemplate(); - sLog.outString( "Loading Points Of Interest Data..." ); + sLog.outString("Loading Points Of Interest Data..."); sObjectMgr.LoadPointsOfInterest(); - sLog.outString( "Loading Creature Data..." ); + sLog.outString("Loading Creature Data..."); sObjectMgr.LoadCreatures(); - sLog.outString( "Loading pet levelup spells..." ); + sLog.outString("Loading pet levelup spells..."); sSpellMgr.LoadPetLevelupSpellMap(); - sLog.outString( "Loading pet default spell additional to levelup spells..." ); + sLog.outString("Loading pet default spell additional to levelup spells..."); sSpellMgr.LoadPetDefaultSpells(); - sLog.outString( "Loading Creature Addon Data..." ); + sLog.outString("Loading Creature Addon Data..."); sLog.outString(); sObjectMgr.LoadCreatureAddons(); // must be after LoadCreatureTemplates() and LoadCreatures() - sLog.outString( ">>> Creature Addon Data loaded" ); + sLog.outString(">>> Creature Addon Data loaded"); sLog.outString(); - sLog.outString( "Loading Gameobject Data..." ); + sLog.outString("Loading Gameobject Data..."); sObjectMgr.LoadGameObjects(); - sLog.outString( "Loading Gameobject Addon Data..." ); + sLog.outString("Loading Gameobject Addon Data..."); sObjectMgr.LoadGameObjectAddon(); - sLog.outString( "Loading CreatureLinking Data..." ); // must be after Creatures + sLog.outString("Loading CreatureLinking Data..."); // must be after Creatures sCreatureLinkingMgr.LoadFromDB(); - sLog.outString( "Loading Objects Pooling Data..."); + sLog.outString("Loading Objects Pooling Data..."); sPoolMgr.LoadFromDB(); - sLog.outString( "Loading Weather Data..." ); + sLog.outString("Loading Weather Data..."); sObjectMgr.LoadWeatherZoneChances(); - sLog.outString( "Loading Quests..." ); + sLog.outString("Loading Quests..."); sObjectMgr.LoadQuests(); // must be loaded after DBCs, creature_template, item_template, gameobject tables - sLog.outString( "Loading Quest POI" ); + sLog.outString("Loading Quest POI"); sObjectMgr.LoadQuestPOI(); - sLog.outString( "Loading Quests Relations..." ); + sLog.outString("Loading Quests Relations..."); sLog.outString(); sObjectMgr.LoadQuestRelations(); // must be after quest load - sLog.outString( ">>> Quests Relations loaded" ); + sLog.outString(">>> Quests Relations loaded"); sLog.outString(); - sLog.outString( "Loading Game Event Data..."); // must be after sPoolMgr.LoadFromDB and quests to properly load pool events and quests for events + sLog.outString("Loading Game Event Data..."); // must be after sPoolMgr.LoadFromDB and quests to properly load pool events and quests for events sLog.outString(); sGameEventMgr.LoadFromDB(); - sLog.outString( ">>> Game Event Data loaded" ); + sLog.outString(">>> Game Event Data loaded"); sLog.outString(); // Load Conditions - sLog.outString( "Loading Conditions..." ); + sLog.outString("Loading Conditions..."); sObjectMgr.LoadConditions(); - sLog.outString( "Creating map persistent states for non-instanceable maps..." ); // must be after PackInstances(), LoadCreatures(), sPoolMgr.LoadFromDB(), sGameEventMgr.LoadFromDB(); + sLog.outString("Creating map persistent states for non-instanceable maps..."); // must be after PackInstances(), LoadCreatures(), sPoolMgr.LoadFromDB(), sGameEventMgr.LoadFromDB(); sMapPersistentStateMgr.InitWorldMaps(); - sLog.outString( "Loading Creature Respawn Data..." ); // must be after LoadCreatures(), and sMapPersistentStateMgr.InitWorldMaps() + sLog.outString("Loading Creature Respawn Data..."); // must be after LoadCreatures(), and sMapPersistentStateMgr.InitWorldMaps() sMapPersistentStateMgr.LoadCreatureRespawnTimes(); - sLog.outString( "Loading Gameobject Respawn Data..." ); // must be after LoadGameObjects(), and sMapPersistentStateMgr.InitWorldMaps() + sLog.outString("Loading Gameobject Respawn Data..."); // must be after LoadGameObjects(), and sMapPersistentStateMgr.InitWorldMaps() sMapPersistentStateMgr.LoadGameobjectRespawnTimes(); - sLog.outString( "Loading UNIT_NPC_FLAG_SPELLCLICK Data..." ); + sLog.outString("Loading UNIT_NPC_FLAG_SPELLCLICK Data..."); sObjectMgr.LoadNPCSpellClickSpells(); - sLog.outString( "Loading SpellArea Data..." ); // must be after quest load + sLog.outString("Loading SpellArea Data..."); // must be after quest load sSpellMgr.LoadSpellAreas(); - sLog.outString( "Loading AreaTrigger definitions..." ); + sLog.outString("Loading AreaTrigger definitions..."); sObjectMgr.LoadAreaTriggerTeleports(); // must be after item template load - sLog.outString( "Loading Quest Area Triggers..." ); + sLog.outString("Loading Quest Area Triggers..."); sObjectMgr.LoadQuestAreaTriggers(); // must be after LoadQuests - sLog.outString( "Loading Tavern Area Triggers..." ); + sLog.outString("Loading Tavern Area Triggers..."); sObjectMgr.LoadTavernAreaTriggers(); - sLog.outString( "Loading AreaTrigger script names..." ); + sLog.outString("Loading AreaTrigger script names..."); sScriptMgr.LoadAreaTriggerScripts(); - sLog.outString( "Loading event id script names..." ); + sLog.outString("Loading event id script names..."); sScriptMgr.LoadEventIdScripts(); - sLog.outString( "Loading Graveyard-zone links..."); + sLog.outString("Loading Graveyard-zone links..."); sObjectMgr.LoadGraveyardZones(); - sLog.outString( "Loading spell target destination coordinates..." ); + sLog.outString("Loading spell target destination coordinates..."); sSpellMgr.LoadSpellTargetPositions(); - sLog.outString( "Loading spell pet auras..." ); + sLog.outString("Loading spell pet auras..."); sSpellMgr.LoadSpellPetAuras(); - sLog.outString( "Loading Player Create Info & Level Stats..." ); + sLog.outString("Loading Player Create Info & Level Stats..."); sLog.outString(); sObjectMgr.LoadPlayerInfo(); - sLog.outString( ">>> Player Create Info & Level Stats loaded" ); + sLog.outString(">>> Player Create Info & Level Stats loaded"); sLog.outString(); - sLog.outString( "Loading Exploration BaseXP Data..." ); + sLog.outString("Loading Exploration BaseXP Data..."); sObjectMgr.LoadExplorationBaseXP(); - sLog.outString( "Loading Pet Name Parts..." ); + sLog.outString("Loading Pet Name Parts..."); sObjectMgr.LoadPetNames(); CharacterDatabaseCleaner::CleanDatabase(); - sLog.outString( "Loading the max pet number..." ); + sLog.outString("Loading the max pet number..."); sObjectMgr.LoadPetNumber(); - sLog.outString( "Loading pet level stats..." ); + sLog.outString("Loading pet level stats..."); sObjectMgr.LoadPetLevelInfo(); - sLog.outString( "Loading Player Corpses..." ); + sLog.outString("Loading Player Corpses..."); sObjectMgr.LoadCorpses(); - sLog.outString( "Loading Player level dependent mail rewards..." ); + sLog.outString("Loading Player level dependent mail rewards..."); sObjectMgr.LoadMailLevelRewards(); - sLog.outString( "Loading Loot Tables..." ); + sLog.outString("Loading Loot Tables..."); sLog.outString(); LoadLootTables(); - sLog.outString( ">>> Loot Tables loaded" ); + sLog.outString(">>> Loot Tables loaded"); sLog.outString(); - sLog.outString( "Loading Skill Discovery Table..." ); + sLog.outString("Loading Skill Discovery Table..."); LoadSkillDiscoveryTable(); - sLog.outString( "Loading Skill Extra Item Table..." ); + sLog.outString("Loading Skill Extra Item Table..."); LoadSkillExtraItemTable(); - sLog.outString( "Loading Skill Fishing base level requirements..." ); + sLog.outString("Loading Skill Fishing base level requirements..."); sObjectMgr.LoadFishingBaseSkillLevel(); sLog.outString(); - sLog.outString( "Loading Achievements..." ); + sLog.outString("Loading Achievements..."); sAchievementMgr.LoadAchievementReferenceList(); sAchievementMgr.LoadAchievementCriteriaList(); sAchievementMgr.LoadAchievementCriteriaRequirements(); sAchievementMgr.LoadRewards(); sAchievementMgr.LoadRewardLocales(); sAchievementMgr.LoadCompletedAchievements(); - sLog.outString( ">>> Achievements loaded" ); + sLog.outString(">>> Achievements loaded"); sLog.outString(); - sLog.outString( "Loading Instance encounters data..." ); // must be after Creature loading + sLog.outString("Loading Instance encounters data..."); // must be after Creature loading sObjectMgr.LoadInstanceEncounters(); - sLog.outString( "Loading Npc Text Id..." ); + sLog.outString("Loading Npc Text Id..."); sObjectMgr.LoadNpcGossips(); // must be after load Creature and LoadGossipText - sLog.outString( "Loading Gossip scripts..." ); + sLog.outString("Loading Gossip scripts..."); sScriptMgr.LoadGossipScripts(); // must be before gossip menu options sObjectMgr.LoadGossipMenus(); - sLog.outString( "Loading Vendors..." ); + sLog.outString("Loading Vendors..."); sObjectMgr.LoadVendorTemplates(); // must be after load ItemTemplate sObjectMgr.LoadVendors(); // must be after load CreatureTemplate, VendorTemplate, and ItemTemplate - sLog.outString( "Loading Trainers..." ); + sLog.outString("Loading Trainers..."); sObjectMgr.LoadTrainerTemplates(); // must be after load CreatureTemplate sObjectMgr.LoadTrainers(); // must be after load CreatureTemplate, TrainerTemplate - sLog.outString( "Loading Waypoint scripts..." ); // before loading from creature_movement + sLog.outString("Loading Waypoint scripts..."); // before loading from creature_movement sScriptMgr.LoadCreatureMovementScripts(); - sLog.outString( "Loading Waypoints..." ); + sLog.outString("Loading Waypoints..."); sLog.outString(); sWaypointMgr.Load(); ///- Loading localization data - sLog.outString( "Loading Localization strings..." ); + sLog.outString("Loading Localization strings..."); sObjectMgr.LoadCreatureLocales(); // must be after CreatureInfo loading sObjectMgr.LoadGameObjectLocales(); // must be after GameobjectInfo loading sObjectMgr.LoadItemLocales(); // must be after ItemPrototypes loading @@ -1240,50 +1240,50 @@ void World::SetInitialWorldSettings() sObjectMgr.LoadPageTextLocales(); // must be after PageText loading sObjectMgr.LoadGossipMenuItemsLocales(); // must be after gossip menu items loading sObjectMgr.LoadPointOfInterestLocales(); // must be after POI loading - sLog.outString( ">>> Localization strings loaded" ); + sLog.outString(">>> Localization strings loaded"); sLog.outString(); ///- Load dynamic data tables from the database - sLog.outString( "Loading Auctions..." ); + sLog.outString("Loading Auctions..."); sLog.outString(); sAuctionMgr.LoadAuctionItems(); sAuctionMgr.LoadAuctions(); - sLog.outString( ">>> Auctions loaded" ); + sLog.outString(">>> Auctions loaded"); sLog.outString(); - sLog.outString( "Loading Guilds..." ); + sLog.outString("Loading Guilds..."); sGuildMgr.LoadGuilds(); - sLog.outString( "Loading ArenaTeams..." ); + sLog.outString("Loading ArenaTeams..."); sObjectMgr.LoadArenaTeams(); - sLog.outString( "Loading Groups..." ); + sLog.outString("Loading Groups..."); sObjectMgr.LoadGroups(); - sLog.outString( "Loading ReservedNames..." ); + sLog.outString("Loading ReservedNames..."); sObjectMgr.LoadReservedPlayersNames(); - sLog.outString( "Loading GameObjects for quests..." ); + sLog.outString("Loading GameObjects for quests..."); sObjectMgr.LoadGameObjectForQuests(); - sLog.outString( "Loading BattleMasters..." ); + sLog.outString("Loading BattleMasters..."); sBattleGroundMgr.LoadBattleMastersEntry(); - sLog.outString( "Loading BattleGround event indexes..." ); + sLog.outString("Loading BattleGround event indexes..."); sBattleGroundMgr.LoadBattleEventIndexes(); - sLog.outString( "Loading GameTeleports..." ); + sLog.outString("Loading GameTeleports..."); sObjectMgr.LoadGameTele(); - sLog.outString( "Loading GM tickets..."); + sLog.outString("Loading GM tickets..."); sTicketMgr.LoadGMTickets(); ///- Handle outdated emails (delete/return) - sLog.outString( "Returning old mails..." ); + sLog.outString("Returning old mails..."); sObjectMgr.ReturnOrDeleteOldMails(false); ///- Load and initialize scripts - sLog.outString( "Loading Scripts..." ); + sLog.outString("Loading Scripts..."); sLog.outString(); sScriptMgr.LoadQuestStartScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate sScriptMgr.LoadQuestEndScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate @@ -1291,23 +1291,23 @@ void World::SetInitialWorldSettings() sScriptMgr.LoadGameObjectScripts(); // must be after load Creature/Gameobject(Template/Data) sScriptMgr.LoadGameObjectTemplateScripts(); // must be after load Creature/Gameobject(Template/Data) sScriptMgr.LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data) - sLog.outString( ">>> Scripts loaded" ); + sLog.outString(">>> Scripts loaded"); sLog.outString(); - sLog.outString( "Loading Scripts text locales..." ); // must be after Load*Scripts calls + sLog.outString("Loading Scripts text locales..."); // must be after Load*Scripts calls sScriptMgr.LoadDbScriptStrings(); - sLog.outString( "Loading CreatureEventAI Texts..."); + sLog.outString("Loading CreatureEventAI Texts..."); sEventAIMgr.LoadCreatureEventAI_Texts(false); // false, will checked in LoadCreatureEventAI_Scripts - sLog.outString( "Loading CreatureEventAI Summons..."); + sLog.outString("Loading CreatureEventAI Summons..."); sEventAIMgr.LoadCreatureEventAI_Summons(false); // false, will checked in LoadCreatureEventAI_Scripts - sLog.outString( "Loading CreatureEventAI Scripts..."); + sLog.outString("Loading CreatureEventAI Scripts..."); sEventAIMgr.LoadCreatureEventAI_Scripts(); sLog.outString("Initializing Scripts..."); - switch(sScriptMgr.LoadScriptLibrary(MANGOS_SCRIPT_NAME)) + switch (sScriptMgr.LoadScriptLibrary(MANGOS_SCRIPT_NAME)) { case SCRIPT_LOAD_OK: sLog.outString("Scripting library loaded."); @@ -1324,7 +1324,7 @@ void World::SetInitialWorldSettings() } ///- Initialize game time and timers - sLog.outString( "DEBUG:: Initialize game time and timers" ); + sLog.outString("DEBUG:: Initialize game time and timers"); m_gameTime = time(NULL); m_startTime=m_gameTime; @@ -1333,16 +1333,16 @@ void World::SetInitialWorldSettings() time(&curr); local=*(localtime(&curr)); // dereference and assign char isoDate[128]; - sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d", - local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec); + sprintf(isoDate, "%04d-%02d-%02d %02d:%02d:%02d", + local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec); LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)", - realmID, uint64(m_startTime), isoDate); + realmID, uint64(m_startTime), isoDate); m_timers[WUPDATE_WEATHERS].SetInterval(1*IN_MILLISECONDS); m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE*IN_MILLISECONDS); m_timers[WUPDATE_UPTIME].SetInterval(getConfig(CONFIG_UINT32_UPTIME_UPDATE)*MINUTE*IN_MILLISECONDS); - //Update "uptime" table based on configuration entry in minutes. + //Update "uptime" table based on configuration entry in minutes. m_timers[WUPDATE_CORPSES].SetInterval(20*MINUTE*IN_MILLISECONDS); m_timers[WUPDATE_DELETECHARS].SetInterval(DAY*IN_MILLISECONDS); // check for chars to delete every day @@ -1352,9 +1352,9 @@ void World::SetInitialWorldSettings() //to set mailtimer to return mails every day between 4 and 5 am //mailtimer is increased when updating auctions //one second is 1000 -(tested on win system) - mail_timer = uint32((((localtime( &m_gameTime )->tm_hour + 20) % 24)* HOUR * IN_MILLISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval() ); - //1440 - mail_timer_expires = uint32( (DAY * IN_MILLISECONDS) / (m_timers[WUPDATE_AUCTIONS].GetInterval())); + mail_timer = uint32((((localtime(&m_gameTime)->tm_hour + 20) % 24)* HOUR * IN_MILLISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval()); + //1440 + mail_timer_expires = uint32((DAY * IN_MILLISECONDS) / (m_timers[WUPDATE_AUCTIONS].GetInterval())); DEBUG_LOG("Mail timer set to: %u, mail return is called every %u minutes", mail_timer, mail_timer_expires); ///- Initialize static helper structures @@ -1362,31 +1362,31 @@ void World::SetInitialWorldSettings() Player::InitVisibleBits(); ///- Initialize MapManager - sLog.outString( "Starting Map System" ); + sLog.outString("Starting Map System"); sMapMgr.Initialize(); ///- Initialize Battlegrounds - sLog.outString( "Starting BattleGround System" ); + sLog.outString("Starting BattleGround System"); sBattleGroundMgr.CreateInitialBattleGrounds(); sBattleGroundMgr.InitAutomaticArenaPointDistribution(); //Not sure if this can be moved up in the sequence (with static data loading) as it uses MapManager - sLog.outString( "Loading Transports..." ); + sLog.outString("Loading Transports..."); sMapMgr.LoadTransports(); - sLog.outString("Deleting expired bans..." ); + sLog.outString("Deleting expired bans..."); LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); - sLog.outString("Calculate next daily quest reset time..." ); + sLog.outString("Calculate next daily quest reset time..."); InitDailyQuestResetTime(); - sLog.outString("Calculate next weekly quest reset time..." ); + sLog.outString("Calculate next weekly quest reset time..."); InitWeeklyQuestResetTime(); - sLog.outString("Calculate next monthly quest reset time..." ); + sLog.outString("Calculate next monthly quest reset time..."); SetMonthlyQuestResetTime(); - sLog.outString("Starting Game Event system..." ); + sLog.outString("Starting Game Event system..."); uint32 nextGameEvent = sGameEventMgr.Initialize(); m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); //depend on next event @@ -1396,10 +1396,10 @@ void World::SetInitialWorldSettings() sLog.outString("Initialize AuctionHouseBot..."); sAuctionBot.Initialize(); - sLog.outString( "WORLD: World initialized" ); + sLog.outString("WORLD: World initialized"); uint32 uStartInterval = WorldTimer::getMSTimeDiff(uStartTime, WorldTimer::getMSTime()); - sLog.outString( "SERVER STARTUP TIME: %i minutes %i seconds", uStartInterval / 60000, (uStartInterval % 60000) / 1000 ); + sLog.outString("SERVER STARTUP TIME: %i minutes %i seconds", uStartInterval / 60000, (uStartInterval % 60000) / 1000); } void World::DetectDBCLang() @@ -1430,7 +1430,7 @@ void World::DetectDBCLang() } if (default_locale != m_lang_confid && m_lang_confid < MAX_LOCALE && - (m_availableDbcLocaleMask & (1 << m_lang_confid)) ) + (m_availableDbcLocaleMask & (1 << m_lang_confid))) { default_locale = m_lang_confid; } @@ -1452,7 +1452,7 @@ void World::DetectDBCLang() void World::Update(uint32 diff) { ///- Update the different timers - for(int i = 0; i < WUPDATE_COUNT; ++i) + for (int i = 0; i < WUPDATE_COUNT; ++i) { if (m_timers[i].GetCurrent()>=0) m_timers[i].Update(diff); @@ -1509,11 +1509,11 @@ void World::Update(uint32 diff) if (m_timers[WUPDATE_WEATHERS].Passed()) { ///- Send an update signal to Weather objects - for (WeatherMap::iterator itr = m_weathers.begin(); itr != m_weathers.end(); ) + for (WeatherMap::iterator itr = m_weathers.begin(); itr != m_weathers.end();) { ///- and remove Weather objects for zones with no player - //As interval > WorldTick - if(!itr->second->Update(m_timers[WUPDATE_WEATHERS].GetInterval())) + //As interval > WorldTick + if (!itr->second->Update(m_timers[WUPDATE_WEATHERS].GetInterval())) { delete itr->second; m_weathers.erase(itr++); @@ -1587,10 +1587,10 @@ void World::SendGlobalMessage(WorldPacket* packet, WorldSession* self /*= NULL*/ for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) { if (itr->second && - itr->second->GetPlayer() && - itr->second->GetPlayer()->IsInWorld() && - itr->second != self && - (team == TEAM_NONE || itr->second->GetPlayer()->GetTeam() == team)) + itr->second->GetPlayer() && + itr->second->GetPlayer()->IsInWorld() && + itr->second != self && + (team == TEAM_NONE || itr->second->GetPlayer()->GetTeam() == team)) { itr->second->SendPacket(packet); } @@ -1608,14 +1608,14 @@ namespace MaNGOS { char const* text = sObjectMgr.GetMangosString(i_textId,loc_idx); - if(i_args) + if (i_args) { // we need copy va_list before use or original va_list will corrupted va_list ap; va_copy(ap,*i_args); char str [2048]; - vsnprintf(str,2048,text, ap ); + vsnprintf(str,2048,text, ap); va_end(ap); do_helper(data_list,&str[0]); @@ -1629,7 +1629,7 @@ namespace MaNGOS { char* pos = text; - while(char* line = lineFromMessage(pos)) + while (char* line = lineFromMessage(pos)) { WorldPacket* data = new WorldPacket(); @@ -1662,9 +1662,9 @@ void World::SendWorldText(int32 string_id, ...) MaNGOS::WorldWorldTextBuilder wt_builder(string_id, &ap); MaNGOS::LocalizedPacketListDo wt_do(wt_builder); - for(SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) { - if(!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld() ) + if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld()) continue; wt_do(itr->second->GetPlayer()); @@ -1698,11 +1698,11 @@ void World::SendZoneMessage(uint32 zone, WorldPacket* packet, WorldSession* self for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) { if (itr->second && - itr->second->GetPlayer() && - itr->second->GetPlayer()->IsInWorld() && - itr->second->GetPlayer()->GetZoneId() == zone && - itr->second != self && - (team == TEAM_NONE || itr->second->GetPlayer()->GetTeam() == team)) + itr->second->GetPlayer() && + itr->second->GetPlayer()->IsInWorld() && + itr->second->GetPlayer()->GetZoneId() == zone && + itr->second != self && + (team == TEAM_NONE || itr->second->GetPlayer()->GetTeam() == team)) { itr->second->SendPacket(packet); } @@ -1732,7 +1732,7 @@ void World::KickAllLess(AccountTypes sec) { // session not removed at kick and will removed in next update tick for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) - if(itr->second->GetSecurity() < sec) + if (itr->second->GetSecurity() < sec) itr->second->KickPlayer(); } @@ -1744,10 +1744,10 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, uint32 duration_ std::string safe_author=author; LoginDatabase.escape_string(safe_author); - QueryResult *resultAccounts = NULL; //used for kicking + QueryResult* resultAccounts = NULL; //used for kicking ///- Update the database with ban information - switch(mode) + switch (mode) { case BAN_IP: //No SQL injection as strings are escaped @@ -1766,9 +1766,9 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, uint32 duration_ return BAN_SYNTAX_ERROR; } - if(!resultAccounts) + if (!resultAccounts) { - if(mode==BAN_IP) + if (mode==BAN_IP) return BAN_SUCCESS; // ip correctly banned but nobody affected (yet) else return BAN_NOTFOUND; // Nobody to ban @@ -1780,18 +1780,18 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, uint32 duration_ Field* fieldsAccount = resultAccounts->Fetch(); uint32 account = fieldsAccount->GetUInt32(); - if(mode!=BAN_IP) + if (mode!=BAN_IP) { //No SQL injection as strings are escaped LoginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')", - account,duration_secs,safe_author.c_str(),reason.c_str()); + account,duration_secs,safe_author.c_str(),reason.c_str()); } if (WorldSession* sess = FindSession(account)) - if(std::string(sess->GetPlayerName()) != author) + if (std::string(sess->GetPlayerName()) != author) sess->KickPlayer(); } - while( resultAccounts->NextRow() ); + while (resultAccounts->NextRow()); delete resultAccounts; return BAN_SUCCESS; @@ -1809,9 +1809,9 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP) { uint32 account = 0; if (mode == BAN_ACCOUNT) - account = sAccountMgr.GetId (nameOrIP); + account = sAccountMgr.GetId(nameOrIP); else if (mode == BAN_CHARACTER) - account = sObjectMgr.GetPlayerAccountIdByPlayerName (nameOrIP); + account = sObjectMgr.GetPlayerAccountIdByPlayerName(nameOrIP); if (!account) return false; @@ -1831,12 +1831,12 @@ void World::_UpdateGameTime() m_gameTime = thisTime; ///- if there is a shutdown timer - if(!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0) + if (!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0) { ///- ... and it is overdue, stop the world (set m_stopEvent) - if( m_ShutdownTimer <= elapsed ) + if (m_ShutdownTimer <= elapsed) { - if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) + if (!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) m_stopEvent = true; // exist code already set else m_ShutdownTimer = 1; // minimum timer value to wait idle state @@ -1855,16 +1855,16 @@ void World::_UpdateGameTime() void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode) { // ignore if server shutdown at next tick - if(m_stopEvent) + if (m_stopEvent) return; m_ShutdownMask = options; m_ExitCode = exitcode; ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions) - if(time==0) + if (time==0) { - if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) + if (!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) m_stopEvent = true; // exist code already set else m_ShutdownTimer = 1; //So that the session count is re-evaluated at next world tick @@ -1881,16 +1881,16 @@ void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode) void World::ShutdownMsg(bool show, Player* player) { // not show messages for idle shutdown mode - if(m_ShutdownMask & SHUTDOWN_MASK_IDLE) + if (m_ShutdownMask & SHUTDOWN_MASK_IDLE) return; ///- Display a message every 12 hours, 1 hour, 5 minutes, 1 minute and 15 seconds if (show || - (m_ShutdownTimer < 5 * MINUTE && (m_ShutdownTimer % 15) == 0) || // < 5 min; every 15 sec - (m_ShutdownTimer < 15 * MINUTE && (m_ShutdownTimer % MINUTE) == 0) || // < 15 min; every 1 min - (m_ShutdownTimer < 30 * MINUTE && (m_ShutdownTimer % (5 * MINUTE)) == 0) || // < 30 min; every 5 min - (m_ShutdownTimer < 12 * HOUR && (m_ShutdownTimer % HOUR) == 0) || // < 12 h; every 1 h - (m_ShutdownTimer >= 12 * HOUR && (m_ShutdownTimer % (12 * HOUR)) == 0)) // >= 12 h; every 12 h + (m_ShutdownTimer < 5 * MINUTE && (m_ShutdownTimer % 15) == 0) || // < 5 min; every 15 sec + (m_ShutdownTimer < 15 * MINUTE && (m_ShutdownTimer % MINUTE) == 0) || // < 15 min; every 1 min + (m_ShutdownTimer < 30 * MINUTE && (m_ShutdownTimer % (5 * MINUTE)) == 0) || // < 30 min; every 5 min + (m_ShutdownTimer < 12 * HOUR && (m_ShutdownTimer % HOUR) == 0) || // < 12 h; every 1 h + (m_ShutdownTimer >= 12 * HOUR && (m_ShutdownTimer % (12 * HOUR)) == 0)) // >= 12 h; every 12 h { std::string str = secsToTimeString(m_ShutdownTimer); @@ -1905,7 +1905,7 @@ void World::ShutdownMsg(bool show, Player* player) void World::ShutdownCancel() { // nothing cancel or too later - if(!m_ShutdownTimer || m_stopEvent) + if (!m_ShutdownTimer || m_stopEvent) return; ServerMessageType msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_CANCELLED : SERVER_MSG_SHUTDOWN_CANCELLED; @@ -1931,12 +1931,12 @@ void World::SendServerMessage(ServerMessageType type, const char* text /*=""*/, SendGlobalMessage(&data); } -void World::UpdateSessions( uint32 diff ) +void World::UpdateSessions(uint32 diff) { ///- Add new sessions WorldSession* sess; - while(addSessQueue.next(sess)) - AddSession_ (sess); + while (addSessQueue.next(sess)) + AddSession_(sess); ///- Then send an update signal to remaining ones for (SessionMap::iterator itr = m_sessions.begin(), next; itr != m_sessions.end(); itr = next) @@ -1944,10 +1944,10 @@ void World::UpdateSessions( uint32 diff ) next = itr; ++next; ///- and remove not active sessions from the list - WorldSession * pSession = itr->second; + WorldSession* pSession = itr->second; WorldSessionFilter updater(pSession); - if(!pSession->Update(updater)) + if (!pSession->Update(updater)) { RemoveQueuedSession(pSession); m_sessions.erase(itr); @@ -1970,7 +1970,7 @@ void World::ProcessCliCommands() CliHandler handler(command->m_cliAccountId, command->m_cliAccessLevel, callbackArg, zprint); handler.ParseCommands(command->m_command); - if(command->m_commandFinished) + if (command->m_commandFinished) command->m_commandFinished(callbackArg, !handler.HasSentErrorMessage()); delete command; @@ -1992,14 +1992,14 @@ void World::UpdateResultQueue() void World::UpdateRealmCharCount(uint32 accountId) { CharacterDatabase.AsyncPQuery(this, &World::_UpdateRealmCharCount, accountId, - "SELECT COUNT(guid) FROM characters WHERE account = '%u'", accountId); + "SELECT COUNT(guid) FROM characters WHERE account = '%u'", accountId); } -void World::_UpdateRealmCharCount(QueryResult *resultCharCount, uint32 accountId) +void World::_UpdateRealmCharCount(QueryResult* resultCharCount, uint32 accountId) { if (resultCharCount) { - Field *fields = resultCharCount->Fetch(); + Field* fields = resultCharCount->Fetch(); uint32 charCount = fields[0].GetUInt32(); delete resultCharCount; @@ -2012,7 +2012,7 @@ void World::_UpdateRealmCharCount(QueryResult *resultCharCount, uint32 accountId void World::InitWeeklyQuestResetTime() { - QueryResult * result = CharacterDatabase.Query("SELECT NextWeeklyQuestResetTime FROM saved_variables"); + QueryResult* result = CharacterDatabase.Query("SELECT NextWeeklyQuestResetTime FROM saved_variables"); if (!result) m_NextWeeklyQuestReset = time_t(time(NULL)); // game time not yet init else @@ -2046,7 +2046,7 @@ void World::InitWeeklyQuestResetTime() void World::InitDailyQuestResetTime() { - QueryResult * result = CharacterDatabase.Query("SELECT NextDailyQuestResetTime FROM saved_variables"); + QueryResult* result = CharacterDatabase.Query("SELECT NextDailyQuestResetTime FROM saved_variables"); if (!result) m_NextDailyQuestReset = time_t(time(NULL)); // game time not yet init else @@ -2079,7 +2079,7 @@ void World::SetMonthlyQuestResetTime(bool initialize) { if (initialize) { - QueryResult * result = CharacterDatabase.Query("SELECT NextMonthlyQuestResetTime FROM saved_variables"); + QueryResult* result = CharacterDatabase.Query("SELECT NextMonthlyQuestResetTime FROM saved_variables"); if (!result) m_NextMonthlyQuestReset = time_t(time(NULL)); @@ -2125,7 +2125,7 @@ void World::ResetDailyQuests() { DETAIL_LOG("Daily quests reset for all characters."); CharacterDatabase.Execute("DELETE FROM character_queststatus_daily"); - for(SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) if (itr->second->GetPlayer()) itr->second->GetPlayer()->ResetDailyQuestStatus(); @@ -2137,7 +2137,7 @@ void World::ResetWeeklyQuests() { DETAIL_LOG("Weekly quests reset for all characters."); CharacterDatabase.Execute("DELETE FROM character_queststatus_weekly"); - for(SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) if (itr->second->GetPlayer()) itr->second->GetPlayer()->ResetWeeklyQuestStatus(); @@ -2150,14 +2150,14 @@ void World::ResetMonthlyQuests() DETAIL_LOG("Monthly quests reset for all characters."); CharacterDatabase.Execute("TRUNCATE character_queststatus_monthly"); - for(SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) if (itr->second->GetPlayer()) itr->second->GetPlayer()->ResetMonthlyQuestStatus(); SetMonthlyQuestResetTime(false); } -void World::SetPlayerLimit( int32 limit, bool needUpdate ) +void World::SetPlayerLimit(int32 limit, bool needUpdate) { if (limit < -SEC_ADMINISTRATOR) limit = -SEC_ADMINISTRATOR; @@ -2169,7 +2169,7 @@ void World::SetPlayerLimit( int32 limit, bool needUpdate ) if (db_update_need) LoginDatabase.PExecute("UPDATE realmlist SET allowedSecurityLevel = '%u' WHERE id = '%u'", - uint32(GetPlayerSecurityLimit()), realmID); + uint32(GetPlayerSecurityLimit()), realmID); } void World::UpdateMaxSessionCounters() @@ -2181,7 +2181,7 @@ void World::UpdateMaxSessionCounters() void World::LoadDBVersion() { QueryResult* result = WorldDatabase.Query("SELECT version, creature_ai_version, cache_id FROM db_version LIMIT 1"); - if(result) + if (result) { Field* fields = result->Fetch(); @@ -2193,10 +2193,10 @@ void World::LoadDBVersion() delete result; } - if(m_DBVersion.empty()) + if (m_DBVersion.empty()) m_DBVersion = "Unknown world database."; - if(m_CreatureEventAIVersion.empty()) + if (m_CreatureEventAIVersion.empty()) m_CreatureEventAIVersion = "Unknown creature EventAI."; } @@ -2220,7 +2220,7 @@ void World::setConfig(eConfigFloatValues index, char const* fieldname, float def setConfig(index, sConfig.GetFloatDefault(fieldname,defvalue)); } -void World::setConfig( eConfigBoolValues index, char const* fieldname, bool defvalue ) +void World::setConfig(eConfigBoolValues index, char const* fieldname, bool defvalue) { setConfig(index, sConfig.GetBoolDefault(fieldname,defvalue)); } diff --git a/src/game/World.h b/src/game/World.h index 660b636b6..e82070dbb 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -360,7 +360,7 @@ enum RealmType REALM_TYPE_RP = 6, REALM_TYPE_RPPVP = 8, REALM_TYPE_FFA_PVP = 16 // custom, free for all pvp mode like arena PvP in all zones except rest activated places and sanctuaries - // replaced by REALM_PVP in realm list + // replaced by REALM_PVP in realm list }; /// This is values from first column of Cfg_Categories.dbc (1.12.1 have another numeration) @@ -416,11 +416,11 @@ struct CliCommandHolder uint32 m_cliAccountId; // 0 for console and real account id for RA/soap AccountTypes m_cliAccessLevel; void* m_callbackArg; - char *m_command; + char* m_command; Print* m_print; CommandFinished* m_commandFinished; - CliCommandHolder(uint32 accountId, AccountTypes cliAccessLevel, void* callbackArg, const char *command, Print* zprint, CommandFinished* commandFinished) + CliCommandHolder(uint32 accountId, AccountTypes cliAccessLevel, void* callbackArg, const char* command, Print* zprint, CommandFinished* commandFinished) : m_cliAccountId(accountId), m_cliAccessLevel(cliAccessLevel), m_callbackArg(callbackArg), m_print(zprint), m_commandFinished(commandFinished) { size_t len = strlen(command)+1; @@ -441,7 +441,7 @@ class World ~World(); WorldSession* FindSession(uint32 id) const; - void AddSession(WorldSession *s); + void AddSession(WorldSession* s); bool RemoveSession(uint32 id); /// Get the number of current active sessions void UpdateMaxSessionCounters(); @@ -524,7 +524,7 @@ class World void Update(uint32 diff); - void UpdateSessions( uint32 diff ); + void UpdateSessions(uint32 diff); /// Get a server configuration element (see #eConfigFloatValues) void setConfig(eConfigFloatValues index,float value) { m_configFloatValues[index]=value; } @@ -575,7 +575,7 @@ class World void UpdateRealmCharCount(uint32 accid); - LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if(m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; } + LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if (m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; } //used World DB version void LoadDBVersion(); @@ -585,7 +585,7 @@ class World protected: void _UpdateGameTime(); // callback for UpdateRealmCharacters - void _UpdateRealmCharCount(QueryResult *resultCharCount, uint32 accountId); + void _UpdateRealmCharCount(QueryResult* resultCharCount, uint32 accountId); void InitDailyQuestResetTime(); void InitWeeklyQuestResetTime(); diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 837e7d69f..3bf55ea99 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -48,7 +48,7 @@ static bool MapSessionFilterHelper(WorldSession* session, OpcodeHandler const& o return false; // we do not process not loggined player packets - Player * plr = session->GetPlayer(); + Player* plr = session->GetPlayer(); if (!plr) return false; @@ -57,7 +57,7 @@ static bool MapSessionFilterHelper(WorldSession* session, OpcodeHandler const& o } -bool MapSessionFilter::Process(WorldPacket * packet) +bool MapSessionFilter::Process(WorldPacket* packet) { OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()]; if (opHandle.packetProcessing == PROCESS_INPLACE) @@ -81,16 +81,16 @@ bool WorldSessionFilter::Process(WorldPacket* packet) } /// WorldSession constructor -WorldSession::WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale) : -m_muteTime(mute_time), _player(NULL), m_Socket(sock),_security(sec), _accountId(id), m_expansion(expansion), _logoutTime(0), -m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyLogout(false), m_playerSave(false), -m_sessionDbcLocale(sWorld.GetAvailableDbcLocale(locale)), m_sessionDbLocaleIndex(sObjectMgr.GetIndexForLocale(locale)), -m_latency(0), m_tutorialState(TUTORIALDATA_UNCHANGED) +WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale) : + m_muteTime(mute_time), _player(NULL), m_Socket(sock),_security(sec), _accountId(id), m_expansion(expansion), _logoutTime(0), + m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyLogout(false), m_playerSave(false), + m_sessionDbcLocale(sWorld.GetAvailableDbcLocale(locale)), m_sessionDbLocaleIndex(sObjectMgr.GetIndexForLocale(locale)), + m_latency(0), m_tutorialState(TUTORIALDATA_UNCHANGED) { if (sock) { - m_Address = sock->GetRemoteAddress (); - sock->AddReference (); + m_Address = sock->GetRemoteAddress(); + sock->AddReference(); } } @@ -99,26 +99,26 @@ WorldSession::~WorldSession() { ///- unload player if not unloaded if (_player) - LogoutPlayer (true); + LogoutPlayer(true); /// - If have unclosed socket, close it if (m_Socket) { - m_Socket->CloseSocket (); - m_Socket->RemoveReference (); + m_Socket->CloseSocket(); + m_Socket->RemoveReference(); m_Socket = NULL; } ///- empty incoming packet queue WorldPacket* packet = NULL; - while(_recvQueue.next(packet)) + while (_recvQueue.next(packet)) delete packet; } void WorldSession::SizeError(WorldPacket const& packet, uint32 size) const { sLog.outError("Client (account %u) send packet %s (%u) with size " SIZEFMTD " but expected %u (attempt crash server?), skipped", - GetAccountId(),LookupOpcodeName(packet.GetOpcode()),packet.GetOpcode(),packet.size(),size); + GetAccountId(),LookupOpcodeName(packet.GetOpcode()),packet.GetOpcode(),packet.size(),size); } /// Get the player name @@ -133,7 +133,7 @@ void WorldSession::SendPacket(WorldPacket const* packet) if (!m_Socket) return; - #ifdef MANGOS_DEBUG +#ifdef MANGOS_DEBUG // Code for network use statistic static uint64 sendPacketCount = 0; @@ -147,7 +147,7 @@ void WorldSession::SendPacket(WorldPacket const* packet) time_t cur_time = time(NULL); - if((cur_time - lastTime) < 60) + if ((cur_time - lastTime) < 60) { sendPacketCount+=1; sendPacketBytes+=packet->size(); @@ -167,10 +167,10 @@ void WorldSession::SendPacket(WorldPacket const* packet) sendLastPacketBytes = packet->wpos(); // wpos is real written size } - #endif // !MANGOS_DEBUG +#endif // !MANGOS_DEBUG - if (m_Socket->SendPacket (*packet) == -1) - m_Socket->CloseSocket (); + if (m_Socket->SendPacket(*packet) == -1) + m_Socket->CloseSocket(); } /// Add an incoming packet to the queue @@ -180,21 +180,21 @@ void WorldSession::QueuePacket(WorldPacket* new_packet) } /// Logging helper for unexpected opcodes -void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char *reason) +void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char* reason) { - sLog.outError( "SESSION: received unexpected opcode %s (0x%.4X) %s", - LookupOpcodeName(packet->GetOpcode()), - packet->GetOpcode(), - reason); + sLog.outError("SESSION: received unexpected opcode %s (0x%.4X) %s", + LookupOpcodeName(packet->GetOpcode()), + packet->GetOpcode(), + reason); } /// Logging helper for unexpected opcodes -void WorldSession::LogUnprocessedTail(WorldPacket *packet) +void WorldSession::LogUnprocessedTail(WorldPacket* packet) { - sLog.outError( "SESSION: opcode %s (0x%.4X) have unprocessed tail data (read stop at " SIZEFMTD " from " SIZEFMTD ")", - LookupOpcodeName(packet->GetOpcode()), - packet->GetOpcode(), - packet->rpos(),packet->wpos()); + sLog.outError("SESSION: opcode %s (0x%.4X) have unprocessed tail data (read stop at " SIZEFMTD " from " SIZEFMTD ")", + LookupOpcodeName(packet->GetOpcode()), + packet->GetOpcode(), + packet->rpos(),packet->wpos()); } /// Update the WorldSession (triggered by World update) @@ -217,19 +217,19 @@ bool WorldSession::Update(PacketFilter& updater) switch (opHandle.status) { case STATUS_LOGGEDIN: - if(!_player) + if (!_player) { // skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets - if(!m_playerRecentlyLogout) + if (!m_playerRecentlyLogout) LogUnexpectedOpcode(packet, "the player has not logged in yet"); } - else if(_player->IsInWorld()) + else if (_player->IsInWorld()) ExecuteOpcode(opHandle, packet); // lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer break; case STATUS_LOGGEDIN_OR_RECENTLY_LOGGEDOUT: - if(!_player && !m_playerRecentlyLogout) + if (!_player && !m_playerRecentlyLogout) { LogUnexpectedOpcode(packet, "the player has not logged in yet and not recently logout"); } @@ -238,16 +238,16 @@ bool WorldSession::Update(PacketFilter& updater) ExecuteOpcode(opHandle, packet); break; case STATUS_TRANSFER: - if(!_player) + if (!_player) LogUnexpectedOpcode(packet, "the player has not logged in yet"); - else if(_player->IsInWorld()) + else if (_player->IsInWorld()) LogUnexpectedOpcode(packet, "the player is still in world"); else ExecuteOpcode(opHandle, packet); break; case STATUS_AUTHED: // prevent cheating with skip queue wait - if(m_inQueue) + if (m_inQueue) { LogUnexpectedOpcode(packet, "the player not pass queue yet"); break; @@ -261,26 +261,26 @@ bool WorldSession::Update(PacketFilter& updater) ExecuteOpcode(opHandle, packet); break; case STATUS_NEVER: - sLog.outError( "SESSION: received not allowed opcode %s (0x%.4X)", - LookupOpcodeName(packet->GetOpcode()), - packet->GetOpcode()); + sLog.outError("SESSION: received not allowed opcode %s (0x%.4X)", + LookupOpcodeName(packet->GetOpcode()), + packet->GetOpcode()); break; case STATUS_UNHANDLED: DEBUG_LOG("SESSION: received not handled opcode %s (0x%.4X)", - LookupOpcodeName(packet->GetOpcode()), - packet->GetOpcode()); + LookupOpcodeName(packet->GetOpcode()), + packet->GetOpcode()); break; default: sLog.outError("SESSION: received wrong-status-req opcode %s (0x%.4X)", - LookupOpcodeName(packet->GetOpcode()), - packet->GetOpcode()); + LookupOpcodeName(packet->GetOpcode()), + packet->GetOpcode()); break; } } - catch (ByteBufferException &) + catch (ByteBufferException&) { sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.", - packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId()); + packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId()); if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) { DEBUG_LOG("Dumping error causing packet:"); @@ -290,7 +290,7 @@ bool WorldSession::Update(PacketFilter& updater) if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET)) { DETAIL_LOG("Disconnecting session [account id %u / address %s] for badly formatted packet.", - GetAccountId(), GetRemoteAddress().c_str()); + GetAccountId(), GetRemoteAddress().c_str()); KickPlayer(); } @@ -300,15 +300,15 @@ bool WorldSession::Update(PacketFilter& updater) } ///- Cleanup socket pointer if need - if (m_Socket && m_Socket->IsClosed ()) + if (m_Socket && m_Socket->IsClosed()) { - m_Socket->RemoveReference (); + m_Socket->RemoveReference(); m_Socket = NULL; } //check if we are safe to proceed with logout //logout procedure should happen only in World::UpdateSessions() method!!! - if(updater.ProcessLogout()) + if (updater.ProcessLogout()) { ///- If necessary, log the player out time_t currTime = time(NULL); @@ -326,7 +326,7 @@ bool WorldSession::Update(PacketFilter& updater) void WorldSession::LogoutPlayer(bool Save) { // finish pending transfers before starting the logout - while(_player && _player->IsBeingTeleportedFar()) + while (_player && _player->IsBeingTeleportedFar()) HandleMoveWorldportAckOpcode(); m_playerLogout = true; @@ -355,16 +355,15 @@ void WorldSession::LogoutPlayer(bool Save) // build set of player who attack _player or who have pet attacking of _player std::set aset; - for(Unit::AttackerSet::const_iterator itr = _player->getAttackers().begin(); itr != _player->getAttackers().end(); ++itr) + for (Unit::AttackerSet::const_iterator itr = _player->getAttackers().begin(); itr != _player->getAttackers().end(); ++itr) { Unit* owner = (*itr)->GetOwner(); // including player controlled case - if(owner) + if (owner) { - if(owner->GetTypeId()==TYPEID_PLAYER) + if (owner->GetTypeId()==TYPEID_PLAYER) aset.insert((Player*)owner); } - else - if((*itr)->GetTypeId()==TYPEID_PLAYER) + else if ((*itr)->GetTypeId()==TYPEID_PLAYER) aset.insert((Player*)(*itr)); } @@ -374,16 +373,16 @@ void WorldSession::LogoutPlayer(bool Save) _player->RepopAtGraveyard(); // give honor to all attackers from set like group case - for(std::set::const_iterator itr = aset.begin(); itr != aset.end(); ++itr) + for (std::set::const_iterator itr = aset.begin(); itr != aset.end(); ++itr) (*itr)->RewardHonor(_player,aset.size()); // give bg rewards and update counters like kill by first from attackers // this can't be called for all attackers. - if(!aset.empty()) - if(BattleGround *bg = _player->GetBattleGround()) + if (!aset.empty()) + if (BattleGround* bg = _player->GetBattleGround()) bg->HandleKillPlayer(_player,*aset.begin()); } - else if(_player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) + else if (_player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) { // this will kill character by SPELL_AURA_SPIRIT_OF_REDEMPTION _player->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT); @@ -393,11 +392,11 @@ void WorldSession::LogoutPlayer(bool Save) _player->RepopAtGraveyard(); } //drop a flag if player is carrying it - if(BattleGround *bg = _player->GetBattleGround()) + if (BattleGround* bg = _player->GetBattleGround()) bg->EventPlayerLoggedOut(_player); ///- Teleport to home if the player is in an invalid instance - if(!_player->m_InstanceValid && !_player->isGameMaster()) + if (!_player->m_InstanceValid && !_player->isGameMaster()) { _player->TeleportToHomebind(); //this is a bad place to call for far teleport because we need player to be in world for successful logout @@ -406,12 +405,12 @@ void WorldSession::LogoutPlayer(bool Save) // FG: finish pending transfers after starting the logout // this should fix players beeing able to logout and login back with full hp at death position - while(_player->IsBeingTeleportedFar()) + while (_player->IsBeingTeleportedFar()) HandleMoveWorldportAckOpcode(); for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) { - if(BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i)) + if (BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i)) { _player->RemoveBattleGroundQueueId(bgQueueTypeId); sBattleGroundMgr.m_BattleGroundQueues[ bgQueueTypeId ].RemovePlayer(_player->GetObjectGuid(), true); @@ -443,7 +442,7 @@ void WorldSession::LogoutPlayer(bool Save) ///- empty buyback items and save the player in the database // some save parts only correctly work in case player present in map/player_lists (pets, etc) - if(Save) + if (Save) _player->SaveToDB(); ///- Leave all channels before player delete... @@ -454,16 +453,16 @@ void WorldSession::LogoutPlayer(bool Save) // remove player from the group if he is: // a) in group; b) not in raid group; c) logging out normally (not being kicked or disconnected) - if(_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && m_Socket) + if (_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && m_Socket) _player->RemoveFromGroup(); ///- Send update to group - if(_player->GetGroup()) + if (_player->GetGroup()) _player->GetGroup()->SendUpdate(); ///- Broadcast a logout message to the player's friends sSocialMgr.SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetObjectGuid(), true); - sSocialMgr.RemovePlayerSocial (_player->GetGUIDLow ()); + sSocialMgr.RemovePlayerSocial(_player->GetGUIDLow()); ///- Remove the player from the world // the player may not be in the world when logging out @@ -483,8 +482,8 @@ void WorldSession::LogoutPlayer(bool Save) SetPlayer(NULL); // deleted in Remove/DeleteFromWorld call ///- Send the 'logout complete' packet to the client - WorldPacket data( SMSG_LOGOUT_COMPLETE, 0 ); - SendPacket( &data ); + WorldPacket data(SMSG_LOGOUT_COMPLETE, 0); + SendPacket(&data); ///- Since each account can only have one online character at any given time, ensure all characters for active account are marked as offline //No SQL injection as AccountId is uint32 @@ -494,7 +493,7 @@ void WorldSession::LogoutPlayer(bool Save) stmt = CharacterDatabase.CreateStatement(updChars, "UPDATE characters SET online = 0 WHERE account = ?"); stmt.PExecute(GetAccountId()); - DEBUG_LOG( "SESSION: Sent SMSG_LOGOUT_COMPLETE Message" ); + DEBUG_LOG("SESSION: Sent SMSG_LOGOUT_COMPLETE Message"); } m_playerLogout = false; @@ -507,7 +506,7 @@ void WorldSession::LogoutPlayer(bool Save) void WorldSession::KickPlayer() { if (m_Socket) - m_Socket->CloseSocket (); + m_Socket->CloseSocket(); } /// Cancel channeling handler @@ -519,7 +518,7 @@ void WorldSession::SendAreaTriggerMessage(const char* Text, ...) szStr[0] = '\0'; va_start(ap, Text); - vsnprintf( szStr, 1024, Text, ap ); + vsnprintf(szStr, 1024, Text, ap); va_end(ap); uint32 length = strlen(szStr)+1; @@ -529,15 +528,15 @@ void WorldSession::SendAreaTriggerMessage(const char* Text, ...) SendPacket(&data); } -void WorldSession::SendNotification(const char *format,...) +void WorldSession::SendNotification(const char* format,...) { - if(format) + if (format) { va_list ap; char szStr [1024]; szStr[0] = '\0'; va_start(ap, format); - vsnprintf( szStr, 1024, format, ap ); + vsnprintf(szStr, 1024, format, ap); va_end(ap); WorldPacket data(SMSG_NOTIFICATION, (strlen(szStr)+1)); @@ -549,13 +548,13 @@ void WorldSession::SendNotification(const char *format,...) void WorldSession::SendNotification(int32 string_id,...) { char const* format = GetMangosString(string_id); - if(format) + if (format) { va_list ap; char szStr [1024]; szStr[0] = '\0'; va_start(ap, string_id); - vsnprintf( szStr, 1024, format, ap ); + vsnprintf(szStr, 1024, format, ap); va_end(ap); WorldPacket data(SMSG_NOTIFICATION, (strlen(szStr)+1)); @@ -571,50 +570,50 @@ void WorldSession::SendSetPhaseShift(uint32 PhaseShift) SendPacket(&data); } -const char * WorldSession::GetMangosString( int32 entry ) const +const char* WorldSession::GetMangosString(int32 entry) const { return sObjectMgr.GetMangosString(entry,GetSessionDbLocaleIndex()); } -void WorldSession::Handle_NULL( WorldPacket& recvPacket ) +void WorldSession::Handle_NULL(WorldPacket& recvPacket) { DEBUG_LOG("SESSION: received unimplemented opcode %s (0x%.4X)", - LookupOpcodeName(recvPacket.GetOpcode()), - recvPacket.GetOpcode()); + LookupOpcodeName(recvPacket.GetOpcode()), + recvPacket.GetOpcode()); } -void WorldSession::Handle_EarlyProccess( WorldPacket& recvPacket ) +void WorldSession::Handle_EarlyProccess(WorldPacket& recvPacket) { - sLog.outError( "SESSION: received opcode %s (0x%.4X) that must be processed in WorldSocket::OnRead", - LookupOpcodeName(recvPacket.GetOpcode()), - recvPacket.GetOpcode()); + sLog.outError("SESSION: received opcode %s (0x%.4X) that must be processed in WorldSocket::OnRead", + LookupOpcodeName(recvPacket.GetOpcode()), + recvPacket.GetOpcode()); } -void WorldSession::Handle_ServerSide( WorldPacket& recvPacket ) +void WorldSession::Handle_ServerSide(WorldPacket& recvPacket) { sLog.outError("SESSION: received server-side opcode %s (0x%.4X)", - LookupOpcodeName(recvPacket.GetOpcode()), - recvPacket.GetOpcode()); + LookupOpcodeName(recvPacket.GetOpcode()), + recvPacket.GetOpcode()); } -void WorldSession::Handle_Deprecated( WorldPacket& recvPacket ) +void WorldSession::Handle_Deprecated(WorldPacket& recvPacket) { - sLog.outError( "SESSION: received deprecated opcode %s (0x%.4X)", - LookupOpcodeName(recvPacket.GetOpcode()), - recvPacket.GetOpcode()); + sLog.outError("SESSION: received deprecated opcode %s (0x%.4X)", + LookupOpcodeName(recvPacket.GetOpcode()), + recvPacket.GetOpcode()); } void WorldSession::SendAuthWaitQue(uint32 position) { - if(position == 0) + if (position == 0) { - WorldPacket packet( SMSG_AUTH_RESPONSE, 1 ); - packet << uint8( AUTH_OK ); + WorldPacket packet(SMSG_AUTH_RESPONSE, 1); + packet << uint8(AUTH_OK); SendPacket(&packet); } else { - WorldPacket packet( SMSG_AUTH_RESPONSE, 1+4+1 ); + WorldPacket packet(SMSG_AUTH_RESPONSE, 1+4+1); packet << uint8(AUTH_WAIT_QUEUE); packet << uint32(position); packet << uint8(0); // unk 3.3.0 @@ -636,32 +635,33 @@ void WorldSession::LoadAccountData(QueryResult* result, uint32 mask) if (mask & (1 << i)) m_accountData[i] = AccountData(); - if(!result) + if (!result) return; do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 type = fields[0].GetUInt32(); if (type >= NUM_ACCOUNT_DATA_TYPES) { sLog.outError("Table `%s` have invalid account data type (%u), ignore.", - mask == GLOBAL_CACHE_MASK ? "account_data" : "character_account_data", type); + mask == GLOBAL_CACHE_MASK ? "account_data" : "character_account_data", type); continue; } if ((mask & (1 << type))==0) { sLog.outError("Table `%s` have non appropriate for table account data type (%u), ignore.", - mask == GLOBAL_CACHE_MASK ? "account_data" : "character_account_data", type); + mask == GLOBAL_CACHE_MASK ? "account_data" : "character_account_data", type); continue; } m_accountData[type].Time = time_t(fields[1].GetUInt64()); m_accountData[type].Data = fields[2].GetCppString(); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } @@ -675,7 +675,7 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin static SqlStatementID delId; static SqlStatementID insId; - CharacterDatabase.BeginTransaction (); + CharacterDatabase.BeginTransaction(); SqlStatement stmt = CharacterDatabase.CreateStatement(delId, "DELETE FROM account_data WHERE account=? AND type=?"); stmt.PExecute(acc, uint32(type)); @@ -683,18 +683,18 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin stmt = CharacterDatabase.CreateStatement(insId, "INSERT INTO account_data VALUES (?,?,?,?)"); stmt.PExecute(acc, uint32(type), uint64(time_), data.c_str()); - CharacterDatabase.CommitTransaction (); + CharacterDatabase.CommitTransaction(); } else { // _player can be NULL and packet received after logout but m_GUID still store correct guid - if(!m_GUIDLow) + if (!m_GUIDLow) return; static SqlStatementID delId; static SqlStatementID insId; - CharacterDatabase.BeginTransaction (); + CharacterDatabase.BeginTransaction(); SqlStatement stmt = CharacterDatabase.CreateStatement(delId, "DELETE FROM character_account_data WHERE guid=? AND type=?"); stmt.PExecute(m_GUIDLow, uint32(type)); @@ -702,7 +702,7 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin stmt = CharacterDatabase.CreateStatement(insId, "INSERT INTO character_account_data VALUES (?,?,?,?)"); stmt.PExecute(m_GUIDLow, uint32(type), uint64(time_), data.c_str()); - CharacterDatabase.CommitTransaction (); + CharacterDatabase.CommitTransaction(); } m_accountData[type].Time = time_; @@ -711,24 +711,24 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin void WorldSession::SendAccountDataTimes(uint32 mask) { - WorldPacket data( SMSG_ACCOUNT_DATA_TIMES, 4+1+4+8*4 ); // changed in WotLK + WorldPacket data(SMSG_ACCOUNT_DATA_TIMES, 4+1+4+8*4); // changed in WotLK data << uint32(time(NULL)); // unix time of something data << uint8(1); data << uint32(mask); // type mask - for(uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i) - if(mask & (1 << i)) + for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i) + if (mask & (1 << i)) data << uint32(GetAccountData(AccountDataType(i))->Time);// also unix time SendPacket(&data); } void WorldSession::LoadTutorialsData() { - for ( int aX = 0 ; aX < 8 ; ++aX ) + for (int aX = 0 ; aX < 8 ; ++aX) m_Tutorials[ aX ] = 0; - QueryResult *result = CharacterDatabase.PQuery("SELECT tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7 FROM character_tutorial WHERE account = '%u'", GetAccountId()); + QueryResult* result = CharacterDatabase.PQuery("SELECT tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7 FROM character_tutorial WHERE account = '%u'", GetAccountId()); - if(!result) + if (!result) { m_tutorialState = TUTORIALDATA_NEW; return; @@ -736,12 +736,12 @@ void WorldSession::LoadTutorialsData() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); for (int iI = 0; iI < 8; ++iI) m_Tutorials[iI] = fields[iI].GetUInt32(); } - while( result->NextRow() ); + while (result->NextRow()); delete result; @@ -751,7 +751,7 @@ void WorldSession::LoadTutorialsData() void WorldSession::SendTutorialsData() { WorldPacket data(SMSG_TUTORIAL_FLAGS, 4*8); - for(uint32 i = 0; i < 8; ++i) + for (uint32 i = 0; i < 8; ++i) data << m_Tutorials[i]; SendPacket(&data); } @@ -761,30 +761,30 @@ void WorldSession::SaveTutorialsData() static SqlStatementID updTutorial ; static SqlStatementID insTutorial ; - switch(m_tutorialState) + switch (m_tutorialState) { case TUTORIALDATA_CHANGED: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(updTutorial, "UPDATE character_tutorial SET tut0=?, tut1=?, tut2=?, tut3=?, tut4=?, tut5=?, tut6=?, tut7=? WHERE account = ?"); - for (int i = 0; i < 8; ++i) - stmt.addUInt32(m_Tutorials[i]); + { + SqlStatement stmt = CharacterDatabase.CreateStatement(updTutorial, "UPDATE character_tutorial SET tut0=?, tut1=?, tut2=?, tut3=?, tut4=?, tut5=?, tut6=?, tut7=? WHERE account = ?"); + for (int i = 0; i < 8; ++i) + stmt.addUInt32(m_Tutorials[i]); - stmt.addUInt32(GetAccountId()); - stmt.Execute(); - } - break; + stmt.addUInt32(GetAccountId()); + stmt.Execute(); + } + break; case TUTORIALDATA_NEW: - { - SqlStatement stmt = CharacterDatabase.CreateStatement(insTutorial, "INSERT INTO character_tutorial (account,tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); + { + SqlStatement stmt = CharacterDatabase.CreateStatement(insTutorial, "INSERT INTO character_tutorial (account,tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); - stmt.addUInt32(GetAccountId()); - for (int i = 0; i < 8; ++i) - stmt.addUInt32(m_Tutorials[i]); + stmt.addUInt32(GetAccountId()); + for (int i = 0; i < 8; ++i) + stmt.addUInt32(m_Tutorials[i]); - stmt.Execute(); - } - break; + stmt.Execute(); + } + break; case TUTORIALDATA_UNCHANGED: break; } @@ -792,17 +792,17 @@ void WorldSession::SaveTutorialsData() m_tutorialState = TUTORIALDATA_UNCHANGED; } -void WorldSession::ReadAddonsInfo(WorldPacket &data) +void WorldSession::ReadAddonsInfo(WorldPacket& data) { if (data.rpos() + 4 > data.size()) return; uint32 size; data >> size; - if(!size) + if (!size) return; - if(size > 0xFFFFF) + if (size > 0xFFFFF) { sLog.outError("WorldSession::ReadAddonsInfo addon info too big, size %u", size); return; @@ -820,14 +820,14 @@ void WorldSession::ReadAddonsInfo(WorldPacket &data) uint32 addonsCount; addonInfo >> addonsCount; // addons count - for(uint32 i = 0; i < addonsCount; ++i) + for (uint32 i = 0; i < addonsCount; ++i) { std::string addonName; uint8 enabled; uint32 crc, unk1; // check next addon data format correctness - if(addonInfo.rpos()+1 > addonInfo.size()) + if (addonInfo.rpos()+1 > addonInfo.size()) return; addonInfo >> addonName; @@ -842,7 +842,7 @@ void WorldSession::ReadAddonsInfo(WorldPacket &data) uint32 unk2; addonInfo >> unk2; - if(addonInfo.rpos() != addonInfo.size()) + if (addonInfo.rpos() != addonInfo.size()) DEBUG_LOG("packet under read!"); } else @@ -873,7 +873,7 @@ void WorldSession::SendAddonsInfo() WorldPacket data(SMSG_ADDON_INFO, 4); - for(AddonsList::iterator itr = m_addonsList.begin(); itr != m_addonsList.end(); ++itr) + for (AddonsList::iterator itr = m_addonsList.begin(); itr != m_addonsList.end(); ++itr) { uint8 state = 2; // 2 is sent here data << uint8(state); @@ -916,12 +916,12 @@ void WorldSession::SendAddonsInfo() SendPacket(&data); } -void WorldSession::SetPlayer( Player *plr ) +void WorldSession::SetPlayer(Player* plr) { _player = plr; // set m_GUID that can be used while player loggined and later until m_playerRecentlyLogout not reset - if(_player) + if (_player) m_GUIDLow = _player->GetGUIDLow(); } @@ -944,7 +944,7 @@ void WorldSession::SendRedirectClient(std::string& ip, uint16 port) SendPacket(&pkt); } -void WorldSession::ExecuteOpcode( OpcodeHandler const& opHandle, WorldPacket* packet ) +void WorldSession::ExecuteOpcode(OpcodeHandler const& opHandle, WorldPacket* packet) { // need prevent do internal far teleports in handlers because some handlers do lot steps // or call code that can do far teleports in some conditions unexpectedly for generic way work code diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 641ebc595..443837560 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -190,24 +190,24 @@ enum TutorialDataState class PacketFilter { public: - explicit PacketFilter(WorldSession * pSession) : m_pSession(pSession) {} + explicit PacketFilter(WorldSession* pSession) : m_pSession(pSession) {} virtual ~PacketFilter() {} - virtual bool Process(WorldPacket * packet) { return true; } + virtual bool Process(WorldPacket* packet) { return true; } virtual bool ProcessLogout() const { return true; } protected: - WorldSession * const m_pSession; + WorldSession* const m_pSession; }; //process only thread-safe packets in Map::Update() class MapSessionFilter : public PacketFilter { public: - explicit MapSessionFilter(WorldSession * pSession) : PacketFilter(pSession) {} + explicit MapSessionFilter(WorldSession* pSession) : PacketFilter(pSession) {} ~MapSessionFilter() {} - virtual bool Process(WorldPacket * packet); + virtual bool Process(WorldPacket* packet); //in Map::Update() we do not process player logout! virtual bool ProcessLogout() const { return false; } }; @@ -217,7 +217,7 @@ class MapSessionFilter : public PacketFilter class WorldSessionFilter : public PacketFilter { public: - explicit WorldSessionFilter(WorldSession * pSession) : PacketFilter(pSession) {} + explicit WorldSessionFilter(WorldSession* pSession) : PacketFilter(pSession) {} ~WorldSessionFilter() {} virtual bool Process(WorldPacket* packet); @@ -226,9 +226,9 @@ class WorldSessionFilter : public PacketFilter /// Player session in the World class MANGOS_DLL_SPEC WorldSession { - friend class CharacterHandler; + friend class CharacterHandler; public: - WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale); + WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale); ~WorldSession(); bool PlayerLoading() const { return m_playerLoading; } @@ -237,13 +237,13 @@ class MANGOS_DLL_SPEC WorldSession void SizeError(WorldPacket const& packet, uint32 size) const; - void ReadAddonsInfo(WorldPacket &data); + void ReadAddonsInfo(WorldPacket& data); void SendAddonsInfo(); void SendPacket(WorldPacket const* packet); - void SendNotification(const char *format,...) ATTR_PRINTF(2,3); + void SendNotification(const char* format,...) ATTR_PRINTF(2,3); void SendNotification(int32 string_id,...); - void SendPetNameInvalid(uint32 error, const std::string& name, DeclinedName *declinedName); + void SendPetNameInvalid(uint32 error, const std::string& name, DeclinedName* declinedName); void SendLfgSearchResults(LfgType type, uint32 entry); void SendLfgJoinResult(LfgJoinResult result); void SendLfgUpdate(bool isGroup, LfgUpdateType updateType, uint32 id); @@ -259,7 +259,7 @@ class MANGOS_DLL_SPEC WorldSession char const* GetPlayerName() const; void SetSecurity(AccountTypes security) { _security = security; } std::string const& GetRemoteAddress() { return m_Address; } - void SetPlayer(Player *plr); + void SetPlayer(Player* plr); uint8 Expansion() const { return m_expansion; } /// Session in auth.queue currently @@ -292,10 +292,10 @@ class MANGOS_DLL_SPEC WorldSession void SendNameQueryOpcode(Player* p); void SendNameQueryOpcodeFromDB(ObjectGuid guid); - static void SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 accountId); + static void SendNameQueryOpcodeFromDBCallBack(QueryResult* result, uint32 accountId); void SendTrainerList(ObjectGuid guid); - void SendTrainerList(ObjectGuid guid, const std::string& strTitle ); + void SendTrainerList(ObjectGuid guid, const std::string& strTitle); void SendListInventory(ObjectGuid guid); bool CheckBanker(ObjectGuid guid); @@ -305,8 +305,8 @@ class MANGOS_DLL_SPEC WorldSession void SendTabardVendorActivate(ObjectGuid guid); void SendSpiritResurrect(); void SendBindPoint(Creature* npc); - void SendGMTicketGetTicket(uint32 status, GMTicket *ticket = NULL); - void SendGMResponse(GMTicket *ticket); + void SendGMTicketGetTicket(uint32 status, GMTicket* ticket = NULL); + void SendGMResponse(GMTicket* ticket); void SendAttackStop(Unit const* enemy); @@ -325,7 +325,7 @@ class MANGOS_DLL_SPEC WorldSession bool CheckStableMaster(ObjectGuid guid); // Account Data - AccountData *GetAccountData(AccountDataType type) { return &m_accountData[type]; } + AccountData* GetAccountData(AccountDataType type) { return &m_accountData[type]; } void SetAccountData(AccountDataType type, time_t time_, std::string data); void SendAccountDataTimes(uint32 mask); void LoadGlobalAccountData(); @@ -333,33 +333,33 @@ class MANGOS_DLL_SPEC WorldSession void LoadTutorialsData(); void SendTutorialsData(); void SaveTutorialsData(); - uint32 GetTutorialInt(uint32 intId ) + uint32 GetTutorialInt(uint32 intId) { return m_Tutorials[intId]; } void SetTutorialInt(uint32 intId, uint32 value) { - if(m_Tutorials[intId] != value) + if (m_Tutorials[intId] != value) { m_Tutorials[intId] = value; - if(m_tutorialState == TUTORIALDATA_UNCHANGED) + if (m_tutorialState == TUTORIALDATA_UNCHANGED) m_tutorialState = TUTORIALDATA_CHANGED; } } //used with item_page table - bool SendItemInfo( uint32 itemid, WorldPacket data ); + bool SendItemInfo(uint32 itemid, WorldPacket data); //auction - void SendAuctionHello(Unit *unit); - void SendAuctionCommandResult(AuctionEntry *auc, AuctionAction Action, AuctionError ErrorCode, InventoryResult invError = EQUIP_ERR_OK); - void SendAuctionBidderNotification(AuctionEntry *auction); - void SendAuctionOwnerNotification(AuctionEntry *auction); + void SendAuctionHello(Unit* unit); + void SendAuctionCommandResult(AuctionEntry* auc, AuctionAction Action, AuctionError ErrorCode, InventoryResult invError = EQUIP_ERR_OK); + void SendAuctionBidderNotification(AuctionEntry* auction); + void SendAuctionOwnerNotification(AuctionEntry* auction); void SendAuctionRemovedNotification(AuctionEntry* auction); - static void SendAuctionOutbiddedMail(AuctionEntry *auction); - void SendAuctionCancelledToBidderMail(AuctionEntry *auction); + static void SendAuctionOutbiddedMail(AuctionEntry* auction); + void SendAuctionCancelledToBidderMail(AuctionEntry* auction); void BuildListAuctionItems(std::vector const& auctions, WorldPacket& data, std::wstring const& searchedname, uint32 listfrom, uint32 levelmin, - uint32 levelmax, uint32 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32& count, uint32& totalcount, bool isFull); + uint32 levelmax, uint32 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32& count, uint32& totalcount, bool isFull); AuctionHouseEntry const* GetCheckedAuctionHouseForAuctioneer(ObjectGuid guid); @@ -369,18 +369,18 @@ class MANGOS_DLL_SPEC WorldSession //Taxi void SendTaxiStatus(ObjectGuid guid); - void SendTaxiMenu( Creature* unit ); - void SendDoFlight( uint32 mountDisplayId, uint32 path, uint32 pathNode = 0 ); - bool SendLearnNewTaxiNode( Creature* unit ); + void SendTaxiMenu(Creature* unit); + void SendDoFlight(uint32 mountDisplayId, uint32 path, uint32 pathNode = 0); + bool SendLearnNewTaxiNode(Creature* unit); // Guild/Arena Team void SendGuildCommandResult(uint32 typecmd, const std::string& str, uint32 cmdresult); void SendArenaTeamCommandResult(uint32 team_action, const std::string& team, const std::string& player, uint32 error_id); void SendNotInArenaTeamPacket(uint8 type); void SendPetitionShowList(ObjectGuid guid); - void SendSaveGuildEmblem( uint32 msg ); + void SendSaveGuildEmblem(uint32 msg); - void BuildPartyMemberStatsChangedPacket(Player *player, WorldPacket *data); + void BuildPartyMemberStatsChangedPacket(Player* player, WorldPacket* data); void DoLootRelease(ObjectGuid lguid); @@ -390,16 +390,16 @@ class MANGOS_DLL_SPEC WorldSession // Locales LocaleConstant GetSessionDbcLocale() const { return m_sessionDbcLocale; } int GetSessionDbLocaleIndex() const { return m_sessionDbLocaleIndex; } - const char *GetMangosString(int32 entry) const; + const char* GetMangosString(int32 entry) const; uint32 GetLatency() const { return m_latency; } void SetLatency(uint32 latency) { m_latency = latency; } - uint32 getDialogStatus(Player *pPlayer, Object* questgiver, uint32 defstatus); + uint32 getDialogStatus(Player* pPlayer, Object* questgiver, uint32 defstatus); public: // opcodes handlers void Handle_NULL(WorldPacket& recvPacket); // not used - void Handle_EarlyProccess( WorldPacket& recvPacket);// just mark packets processed in WorldSocket::OnRead + void Handle_EarlyProccess(WorldPacket& recvPacket); // just mark packets processed in WorldSocket::OnRead void Handle_ServerSide(WorldPacket& recvPacket); // sever side only, can't be accepted from client void Handle_Deprecated(WorldPacket& recvPacket); // never used anymore by client @@ -407,8 +407,8 @@ class MANGOS_DLL_SPEC WorldSession void HandleCharDeleteOpcode(WorldPacket& recvPacket); void HandleCharCreateOpcode(WorldPacket& recvPacket); void HandlePlayerLoginOpcode(WorldPacket& recvPacket); - void HandleCharEnum(QueryResult * result); - void HandlePlayerLogin(LoginQueryHolder * holder); + void HandleCharEnum(QueryResult* result); + void HandlePlayerLogin(LoginQueryHolder* holder); // played time void HandlePlayedTime(WorldPacket& recvPacket); @@ -424,11 +424,11 @@ class MANGOS_DLL_SPEC WorldSession void HandleInspectHonorStatsOpcode(WorldPacket& recvPacket); void HandleMoveWaterWalkAck(WorldPacket& recvPacket); - void HandleFeatherFallAck(WorldPacket &recv_data); + void HandleFeatherFallAck(WorldPacket& recv_data); - void HandleMoveHoverAck( WorldPacket & recv_data ); + void HandleMoveHoverAck(WorldPacket& recv_data); - void HandleMountSpecialAnimOpcode(WorldPacket &recvdata); + void HandleMountSpecialAnimOpcode(WorldPacket& recvdata); // character view void HandleShowingHelmOpcode(WorldPacket& recv_data); @@ -441,7 +441,7 @@ class MANGOS_DLL_SPEC WorldSession void HandleMoveKnockBackAck(WorldPacket& recvPacket); void HandleMoveTeleportAckOpcode(WorldPacket& recvPacket); - void HandleForceSpeedChangeAckOpcodes( WorldPacket & recv_data ); + void HandleForceSpeedChangeAckOpcodes(WorldPacket& recv_data); void HandlePingOpcode(WorldPacket& recvPacket); void HandleAuthSessionOpcode(WorldPacket& recvPacket); @@ -474,10 +474,10 @@ class MANGOS_DLL_SPEC WorldSession void HandleEmoteOpcode(WorldPacket& recvPacket); void HandleContactListOpcode(WorldPacket& recvPacket); void HandleAddFriendOpcode(WorldPacket& recvPacket); - static void HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 accountId, std::string friendNote); + static void HandleAddFriendOpcodeCallBack(QueryResult* result, uint32 accountId, std::string friendNote); void HandleDelFriendOpcode(WorldPacket& recvPacket); void HandleAddIgnoreOpcode(WorldPacket& recvPacket); - static void HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 accountId); + static void HandleAddIgnoreOpcodeCallBack(QueryResult* result, uint32 accountId); void HandleDelIgnoreOpcode(WorldPacket& recvPacket); void HandleSetContactNotesOpcode(WorldPacket& recvPacket); void HandleBugOpcode(WorldPacket& recvPacket); @@ -486,9 +486,9 @@ class MANGOS_DLL_SPEC WorldSession void HandleAreaTriggerOpcode(WorldPacket& recvPacket); - void HandleSetFactionAtWarOpcode( WorldPacket & recv_data ); - void HandleSetWatchedFactionOpcode(WorldPacket & recv_data); - void HandleSetFactionInactiveOpcode(WorldPacket & recv_data); + void HandleSetFactionAtWarOpcode(WorldPacket& recv_data); + void HandleSetWatchedFactionOpcode(WorldPacket& recv_data); + void HandleSetFactionInactiveOpcode(WorldPacket& recv_data); void HandleUpdateAccountData(WorldPacket& recvPacket); void HandleRequestAccountData(WorldPacket& recvPacket); @@ -509,12 +509,12 @@ class MANGOS_DLL_SPEC WorldSession void HandleMoveWorldportAckOpcode(); // for server-side calls void HandleMovementOpcodes(WorldPacket& recvPacket); - void HandleSetActiveMoverOpcode(WorldPacket &recv_data); - void HandleMoveNotActiveMoverOpcode(WorldPacket &recv_data); - void HandleDismissControlledVehicle(WorldPacket &recv_data); - void HandleMoveTimeSkippedOpcode(WorldPacket &recv_data); + void HandleSetActiveMoverOpcode(WorldPacket& recv_data); + void HandleMoveNotActiveMoverOpcode(WorldPacket& recv_data); + void HandleDismissControlledVehicle(WorldPacket& recv_data); + void HandleMoveTimeSkippedOpcode(WorldPacket& recv_data); - void HandleRequestRaidInfoOpcode( WorldPacket & recv_data ); + void HandleRequestRaidInfoOpcode(WorldPacket& recv_data); void HandleGroupInviteOpcode(WorldPacket& recvPacket); void HandleGroupAcceptOpcode(WorldPacket& recvPacket); @@ -523,18 +523,18 @@ class MANGOS_DLL_SPEC WorldSession void HandleGroupUninviteGuidOpcode(WorldPacket& recvPacket); void HandleGroupSetLeaderOpcode(WorldPacket& recvPacket); void HandleGroupDisbandOpcode(WorldPacket& recvPacket); - void HandleOptOutOfLootOpcode( WorldPacket &recv_data ); - void HandleSetAllowLowLevelRaidOpcode( WorldPacket & recv_data ); + void HandleOptOutOfLootOpcode(WorldPacket& recv_data); + void HandleSetAllowLowLevelRaidOpcode(WorldPacket& recv_data); void HandleLootMethodOpcode(WorldPacket& recvPacket); - void HandleLootRoll( WorldPacket &recv_data ); - void HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data ); - void HandleRaidTargetUpdateOpcode( WorldPacket & recv_data ); - void HandleRaidReadyCheckOpcode( WorldPacket & recv_data ); - void HandleRaidReadyCheckFinishedOpcode( WorldPacket & recv_data ); - void HandleGroupRaidConvertOpcode( WorldPacket & recv_data ); - void HandleGroupChangeSubGroupOpcode( WorldPacket & recv_data ); - void HandleGroupAssistantLeaderOpcode( WorldPacket & recv_data ); - void HandlePartyAssignmentOpcode( WorldPacket & recv_data ); + void HandleLootRoll(WorldPacket& recv_data); + void HandleRequestPartyMemberStatsOpcode(WorldPacket& recv_data); + void HandleRaidTargetUpdateOpcode(WorldPacket& recv_data); + void HandleRaidReadyCheckOpcode(WorldPacket& recv_data); + void HandleRaidReadyCheckFinishedOpcode(WorldPacket& recv_data); + void HandleGroupRaidConvertOpcode(WorldPacket& recv_data); + void HandleGroupChangeSubGroupOpcode(WorldPacket& recv_data); + void HandleGroupAssistantLeaderOpcode(WorldPacket& recv_data); + void HandlePartyAssignmentOpcode(WorldPacket& recv_data); void HandlePetitionBuyOpcode(WorldPacket& recv_data); void HandlePetitionShowSignOpcode(WorldPacket& recv_data); @@ -607,30 +607,30 @@ class MANGOS_DLL_SPEC WorldSession void HandleUnacceptTradeOpcode(WorldPacket& recvPacket); void HandleAuctionHelloOpcode(WorldPacket& recvPacket); - void HandleAuctionListItems( WorldPacket & recv_data ); - void HandleAuctionListBidderItems( WorldPacket & recv_data ); - void HandleAuctionSellItem( WorldPacket & recv_data ); + void HandleAuctionListItems(WorldPacket& recv_data); + void HandleAuctionListBidderItems(WorldPacket& recv_data); + void HandleAuctionSellItem(WorldPacket& recv_data); - void HandleAuctionRemoveItem( WorldPacket & recv_data ); - void HandleAuctionListOwnerItems( WorldPacket & recv_data ); - void HandleAuctionPlaceBid( WorldPacket & recv_data ); + void HandleAuctionRemoveItem(WorldPacket& recv_data); + void HandleAuctionListOwnerItems(WorldPacket& recv_data); + void HandleAuctionPlaceBid(WorldPacket& recv_data); - void AuctionBind( uint32 price, AuctionEntry * auction, Player * pl, Player* auction_owner ); - void HandleAuctionListPendingSales( WorldPacket & recv_data ); + void AuctionBind(uint32 price, AuctionEntry* auction, Player* pl, Player* auction_owner); + void HandleAuctionListPendingSales(WorldPacket& recv_data); - void HandleGetMailList( WorldPacket & recv_data ); - void HandleSendMail( WorldPacket & recv_data ); - void HandleMailTakeMoney( WorldPacket & recv_data ); - void HandleMailTakeItem( WorldPacket & recv_data ); - void HandleMailMarkAsRead( WorldPacket & recv_data ); - void HandleMailReturnToSender( WorldPacket & recv_data ); - void HandleMailDelete( WorldPacket & recv_data ); - void HandleItemTextQuery( WorldPacket & recv_data); - void HandleMailCreateTextItem(WorldPacket & recv_data ); - void HandleQueryNextMailTime(WorldPacket & recv_data ); - void HandleCancelChanneling(WorldPacket & recv_data ); + void HandleGetMailList(WorldPacket& recv_data); + void HandleSendMail(WorldPacket& recv_data); + void HandleMailTakeMoney(WorldPacket& recv_data); + void HandleMailTakeItem(WorldPacket& recv_data); + void HandleMailMarkAsRead(WorldPacket& recv_data); + void HandleMailReturnToSender(WorldPacket& recv_data); + void HandleMailDelete(WorldPacket& recv_data); + void HandleItemTextQuery(WorldPacket& recv_data); + void HandleMailCreateTextItem(WorldPacket& recv_data); + void HandleQueryNextMailTime(WorldPacket& recv_data); + void HandleCancelChanneling(WorldPacket& recv_data); - void SendItemPageInfo( ItemPrototype *itemProto ); + void SendItemPageInfo(ItemPrototype* itemProto); void HandleSplitItemOpcode(WorldPacket& recvPacket); void HandleSwapInvItemOpcode(WorldPacket& recvPacket); void HandleDestroyItemOpcode(WorldPacket& recvPacket); @@ -642,9 +642,9 @@ class MANGOS_DLL_SPEC WorldSession void HandleListInventoryOpcode(WorldPacket& recvPacket); void HandleAutoStoreBagItemOpcode(WorldPacket& recvPacket); void HandleReadItemOpcode(WorldPacket& recvPacket); - void HandleAutoEquipItemSlotOpcode(WorldPacket & recvPacket); - void HandleSwapItem( WorldPacket & recvPacket); - void HandleBuybackItem(WorldPacket & recvPacket); + void HandleAutoEquipItemSlotOpcode(WorldPacket& recvPacket); + void HandleSwapItem(WorldPacket& recvPacket); + void HandleBuybackItem(WorldPacket& recvPacket); void HandleAutoBankItemOpcode(WorldPacket& recvPacket); void HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket); void HandleWrapItemOpcode(WorldPacket& recvPacket); @@ -674,8 +674,8 @@ class MANGOS_DLL_SPEC WorldSession void HandleQuestgiverChooseRewardOpcode(WorldPacket& recvPacket); void HandleQuestgiverRequestRewardOpcode(WorldPacket& recvPacket); void HandleQuestQueryOpcode(WorldPacket& recvPacket); - void HandleQuestgiverCancel(WorldPacket& recv_data ); - void HandleQuestLogSwapQuest(WorldPacket& recv_data ); + void HandleQuestgiverCancel(WorldPacket& recv_data); + void HandleQuestLogSwapQuest(WorldPacket& recv_data); void HandleQuestLogRemoveQuest(WorldPacket& recv_data); void HandleQuestConfirmAccept(WorldPacket& recv_data); void HandleQuestgiverCompleteQuest(WorldPacket& recv_data); @@ -694,9 +694,9 @@ class MANGOS_DLL_SPEC WorldSession void HandleTextEmoteOpcode(WorldPacket& recvPacket); void HandleChatIgnoredOpcode(WorldPacket& recvPacket); - void HandleReclaimCorpseOpcode( WorldPacket& recvPacket ); - void HandleCorpseQueryOpcode( WorldPacket& recvPacket ); - void HandleCorpseMapPositionQueryOpcode( WorldPacket& recvPacket ); + void HandleReclaimCorpseOpcode(WorldPacket& recvPacket); + void HandleCorpseQueryOpcode(WorldPacket& recvPacket); + void HandleCorpseMapPositionQueryOpcode(WorldPacket& recvPacket); void HandleResurrectResponseOpcode(WorldPacket& recvPacket); void HandleSummonResponseOpcode(WorldPacket& recv_data); @@ -726,43 +726,43 @@ class MANGOS_DLL_SPEC WorldSession void HandlePageQuerySkippedOpcode(WorldPacket& recvPacket); void HandlePageTextQueryOpcode(WorldPacket& recvPacket); - void HandleTutorialFlagOpcode ( WorldPacket & recv_data ); - void HandleTutorialClearOpcode( WorldPacket & recv_data ); - void HandleTutorialResetOpcode( WorldPacket & recv_data ); + void HandleTutorialFlagOpcode(WorldPacket& recv_data); + void HandleTutorialClearOpcode(WorldPacket& recv_data); + void HandleTutorialResetOpcode(WorldPacket& recv_data); //Pet - void HandlePetAction( WorldPacket & recv_data ); + void HandlePetAction(WorldPacket& recv_data); void HandlePetStopAttack(WorldPacket& recv_data); - void HandlePetNameQueryOpcode( WorldPacket & recv_data ); - void HandlePetSetAction( WorldPacket & recv_data ); - void HandlePetAbandon( WorldPacket & recv_data ); - void HandlePetRename( WorldPacket & recv_data ); - void HandlePetCancelAuraOpcode( WorldPacket& recvPacket ); - void HandlePetUnlearnOpcode( WorldPacket& recvPacket ); - void HandlePetSpellAutocastOpcode( WorldPacket& recvPacket ); - void HandlePetCastSpellOpcode( WorldPacket& recvPacket ); - void HandlePetLearnTalent( WorldPacket& recvPacket ); - void HandleLearnPreviewTalentsPet( WorldPacket& recvPacket ); + void HandlePetNameQueryOpcode(WorldPacket& recv_data); + void HandlePetSetAction(WorldPacket& recv_data); + void HandlePetAbandon(WorldPacket& recv_data); + void HandlePetRename(WorldPacket& recv_data); + void HandlePetCancelAuraOpcode(WorldPacket& recvPacket); + void HandlePetUnlearnOpcode(WorldPacket& recvPacket); + void HandlePetSpellAutocastOpcode(WorldPacket& recvPacket); + void HandlePetCastSpellOpcode(WorldPacket& recvPacket); + void HandlePetLearnTalent(WorldPacket& recvPacket); + void HandleLearnPreviewTalentsPet(WorldPacket& recvPacket); void HandleSetActionBarTogglesOpcode(WorldPacket& recv_data); void HandleCharRenameOpcode(WorldPacket& recv_data); - static void HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uint32 accountId, std::string newname); + static void HandleChangePlayerNameOpcodeCallBack(QueryResult* result, uint32 accountId, std::string newname); void HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data); void HandleTotemDestroyed(WorldPacket& recv_data); //BattleGround - void HandleBattlemasterHelloOpcode(WorldPacket &recv_data); - void HandleBattlemasterJoinOpcode(WorldPacket &recv_data); + void HandleBattlemasterHelloOpcode(WorldPacket& recv_data); + void HandleBattlemasterJoinOpcode(WorldPacket& recv_data); void HandleBattleGroundPlayerPositionsOpcode(WorldPacket& recv_data); - void HandlePVPLogDataOpcode( WorldPacket &recv_data ); - void HandleBattlefieldStatusOpcode(WorldPacket &recv_data); - void HandleBattleFieldPortOpcode( WorldPacket &recv_data ); - void HandleBattlefieldListOpcode( WorldPacket &recv_data ); - void HandleLeaveBattlefieldOpcode( WorldPacket &recv_data ); - void HandleBattlemasterJoinArena( WorldPacket &recv_data ); - void HandleReportPvPAFK( WorldPacket &recv_data ); + void HandlePVPLogDataOpcode(WorldPacket& recv_data); + void HandleBattlefieldStatusOpcode(WorldPacket& recv_data); + void HandleBattleFieldPortOpcode(WorldPacket& recv_data); + void HandleBattlefieldListOpcode(WorldPacket& recv_data); + void HandleLeaveBattlefieldOpcode(WorldPacket& recv_data); + void HandleBattlemasterJoinArena(WorldPacket& recv_data); + void HandleReportPvPAFK(WorldPacket& recv_data); void HandleWardenDataOpcode(WorldPacket& recv_data); void HandleWorldTeleportOpcode(WorldPacket& recv_data); @@ -782,7 +782,7 @@ class MANGOS_DLL_SPEC WorldSession void HandleTimeSyncResp(WorldPacket& recv_data); void HandleWhoisOpcode(WorldPacket& recv_data); void HandleResetInstancesOpcode(WorldPacket& recv_data); - void HandleHearthandResurrect(WorldPacket & recv_data); + void HandleHearthandResurrect(WorldPacket& recv_data); // Arena Team void HandleInspectArenaTeamsOpcode(WorldPacket& recv_data); @@ -809,7 +809,7 @@ class MANGOS_DLL_SPEC WorldSession void HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data); void HandleItemRefundInfoRequest(WorldPacket& recv_data); - void HandleChannelVoiceOnOpcode(WorldPacket & recv_data); + void HandleChannelVoiceOnOpcode(WorldPacket& recv_data); void HandleVoiceSessionEnableOpcode(WorldPacket& recv_data); void HandleSetActiveVoiceChannel(WorldPacket& recv_data); void HandleSetTaxiBenchmarkOpcode(WorldPacket& recv_data); @@ -864,15 +864,15 @@ class MANGOS_DLL_SPEC WorldSession bool VerifyMovementInfo(MovementInfo const& movementInfo, ObjectGuid const& guid) const; void HandleMoverRelocation(MovementInfo& movementInfo); - void ExecuteOpcode( OpcodeHandler const& opHandle, WorldPacket* packet ); + void ExecuteOpcode(OpcodeHandler const& opHandle, WorldPacket* packet); // logging helper - void LogUnexpectedOpcode(WorldPacket *packet, const char * reason); - void LogUnprocessedTail(WorldPacket *packet); + void LogUnexpectedOpcode(WorldPacket* packet, const char* reason); + void LogUnprocessedTail(WorldPacket* packet); uint32 m_GUIDLow; // set logged or recently logout player (while m_playerRecentlyLogout set) - Player *_player; - WorldSocket *m_Socket; + Player* _player; + WorldSocket* m_Socket; std::string m_Address; AccountTypes _security; diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index 62beec037..4e38ba938 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -57,7 +57,7 @@ struct ServerPktHeader ServerPktHeader(uint32 size, uint16 cmd) : size(size) { uint8 headerIndex=0; - if(isLargePacket()) + if (isLargePacket()) { DEBUG_LOG("initializing large server to client packet. Size: %u, cmd: %u", size, cmd); header[headerIndex++] = 0x80|(0xFF &(size>>16)); @@ -96,70 +96,70 @@ struct ClientPktHeader #pragma pack(pop) #endif -WorldSocket::WorldSocket (void) : -WorldHandler (), -m_LastPingTime (ACE_Time_Value::zero), -m_OverSpeedPings (0), -m_Session (0), -m_RecvWPct (0), -m_RecvPct (), -m_Header (sizeof (ClientPktHeader)), -m_OutBuffer (0), -m_OutBufferSize (65536), -m_OutActive (false), -m_Seed (static_cast (rand32 ())) +WorldSocket::WorldSocket(void) : + WorldHandler(), + m_LastPingTime(ACE_Time_Value::zero), + m_OverSpeedPings(0), + m_Session(0), + m_RecvWPct(0), + m_RecvPct(), + m_Header(sizeof(ClientPktHeader)), + m_OutBuffer(0), + m_OutBufferSize(65536), + m_OutActive(false), + m_Seed(static_cast(rand32())) { - reference_counting_policy ().value (ACE_Event_Handler::Reference_Counting_Policy::ENABLED); + reference_counting_policy().value(ACE_Event_Handler::Reference_Counting_Policy::ENABLED); msg_queue()->high_water_mark(8*1024*1024); msg_queue()->low_water_mark(8*1024*1024); } -WorldSocket::~WorldSocket (void) +WorldSocket::~WorldSocket(void) { if (m_RecvWPct) delete m_RecvWPct; if (m_OutBuffer) - m_OutBuffer->release (); + m_OutBuffer->release(); closing_ = true; - peer ().close (); + peer().close(); } -bool WorldSocket::IsClosed (void) const +bool WorldSocket::IsClosed(void) const { return closing_; } -void WorldSocket::CloseSocket (void) +void WorldSocket::CloseSocket(void) { { - ACE_GUARD (LockType, Guard, m_OutBufferLock); + ACE_GUARD(LockType, Guard, m_OutBufferLock); if (closing_) return; closing_ = true; - peer ().close_writer (); + peer().close_writer(); } { - ACE_GUARD (LockType, Guard, m_SessionLock); + ACE_GUARD(LockType, Guard, m_SessionLock); m_Session = NULL; } } -const std::string& WorldSocket::GetRemoteAddress (void) const +const std::string& WorldSocket::GetRemoteAddress(void) const { return m_Address; } -int WorldSocket::SendPacket (const WorldPacket& pct) +int WorldSocket::SendPacket(const WorldPacket& pct) { - ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1); + ACE_GUARD_RETURN(LockType, Guard, m_OutBufferLock, -1); if (closing_) return -1; @@ -168,31 +168,31 @@ int WorldSocket::SendPacket (const WorldPacket& pct) sLog.outWorldPacketDump(uint32(get_handle()), pct.GetOpcode(), LookupOpcodeName(pct.GetOpcode()), &pct, false); ServerPktHeader header(pct.size()+2, pct.GetOpcode()); - m_Crypt.EncryptSend ((uint8*)header.header, header.getHeaderLength()); + m_Crypt.EncryptSend((uint8*)header.header, header.getHeaderLength()); - if (m_OutBuffer->space () >= pct.size () + header.getHeaderLength() && msg_queue()->is_empty()) + if (m_OutBuffer->space() >= pct.size() + header.getHeaderLength() && msg_queue()->is_empty()) { // Put the packet on the buffer. - if (m_OutBuffer->copy ((char*) header.header, header.getHeaderLength()) == -1) - MANGOS_ASSERT (false); + if (m_OutBuffer->copy((char*) header.header, header.getHeaderLength()) == -1) + MANGOS_ASSERT(false); - if (!pct.empty ()) - if (m_OutBuffer->copy ((char*) pct.contents (), pct.size ()) == -1) - MANGOS_ASSERT (false); + if (!pct.empty()) + if (m_OutBuffer->copy((char*) pct.contents(), pct.size()) == -1) + MANGOS_ASSERT(false); } else { // Enqueue the packet. ACE_Message_Block* mb; - ACE_NEW_RETURN(mb, ACE_Message_Block(pct.size () + header.getHeaderLength()), -1); + ACE_NEW_RETURN(mb, ACE_Message_Block(pct.size() + header.getHeaderLength()), -1); mb->copy((char*) header.header, header.getHeaderLength()); - if (!pct.empty ()) - mb->copy((const char*)pct.contents(), pct.size ()); + if (!pct.empty()) + mb->copy((const char*)pct.contents(), pct.size()); - if(msg_queue()->enqueue_tail(mb,(ACE_Time_Value*)&ACE_Time_Value::zero) == -1) + if (msg_queue()->enqueue_tail(mb,(ACE_Time_Value*)&ACE_Time_Value::zero) == -1) { sLog.outError("WorldSocket::SendPacket enqueue_tail"); mb->release(); @@ -203,19 +203,19 @@ int WorldSocket::SendPacket (const WorldPacket& pct) return 0; } -long WorldSocket::AddReference (void) +long WorldSocket::AddReference(void) { - return static_cast (add_reference ()); + return static_cast(add_reference()); } -long WorldSocket::RemoveReference (void) +long WorldSocket::RemoveReference(void) { - return static_cast (remove_reference ()); + return static_cast(remove_reference()); } -int WorldSocket::open (void *a) +int WorldSocket::open(void* a) { - ACE_UNUSED_ARG (a); + ACE_UNUSED_ARG(a); // Prevent double call to this func. if (m_OutBuffer) @@ -226,25 +226,25 @@ int WorldSocket::open (void *a) m_OutActive = true; // Hook for the manager. - if (sWorldSocketMgr->OnSocketOpen (this) == -1) + if (sWorldSocketMgr->OnSocketOpen(this) == -1) return -1; // Allocate the buffer. - ACE_NEW_RETURN (m_OutBuffer, ACE_Message_Block (m_OutBufferSize), -1); + ACE_NEW_RETURN(m_OutBuffer, ACE_Message_Block(m_OutBufferSize), -1); // Store peer address. ACE_INET_Addr remote_addr; - if (peer ().get_remote_addr (remote_addr) == -1) + if (peer().get_remote_addr(remote_addr) == -1) { - sLog.outError ("WorldSocket::open: peer ().get_remote_addr errno = %s", ACE_OS::strerror (errno)); + sLog.outError("WorldSocket::open: peer ().get_remote_addr errno = %s", ACE_OS::strerror(errno)); return -1; } - m_Address = remote_addr.get_host_addr (); + m_Address = remote_addr.get_host_addr(); // Send startup packet. - WorldPacket packet (SMSG_AUTH_CHALLENGE, 40); + WorldPacket packet(SMSG_AUTH_CHALLENGE, 40); packet << uint32(1); // 1...31 packet << m_Seed; @@ -256,56 +256,56 @@ int WorldSocket::open (void *a) seed2.SetRand(16 * 8); packet.append(seed2.AsByteArray(16), 16); // new encryption seeds - if (SendPacket (packet) == -1) + if (SendPacket(packet) == -1) return -1; // Register with ACE Reactor - if (reactor ()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1) + if (reactor()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1) { - sLog.outError ("WorldSocket::open: unable to register client handler errno = %s", ACE_OS::strerror (errno)); + sLog.outError("WorldSocket::open: unable to register client handler errno = %s", ACE_OS::strerror(errno)); return -1; } // reactor takes care of the socket from now on - remove_reference (); + remove_reference(); return 0; } -int WorldSocket::close (int) +int WorldSocket::close(int) { - shutdown (); + shutdown(); closing_ = true; - remove_reference (); + remove_reference(); return 0; } -int WorldSocket::handle_input (ACE_HANDLE) +int WorldSocket::handle_input(ACE_HANDLE) { if (closing_) return -1; - switch (handle_input_missing_data ()) + switch (handle_input_missing_data()) { case -1 : { if ((errno == EWOULDBLOCK) || - (errno == EAGAIN)) + (errno == EAGAIN)) { - return Update (); // interesting line ,isn't it ? + return Update(); // interesting line ,isn't it ? } - DEBUG_LOG ("WorldSocket::handle_input: Peer error closing connection errno = %s", ACE_OS::strerror (errno)); + DEBUG_LOG("WorldSocket::handle_input: Peer error closing connection errno = %s", ACE_OS::strerror(errno)); errno = ECONNRESET; return -1; } case 0: { - DEBUG_LOG ("WorldSocket::handle_input: Peer has closed connection"); + DEBUG_LOG("WorldSocket::handle_input: Peer has closed connection"); errno = ECONNRESET; return -1; @@ -313,28 +313,28 @@ int WorldSocket::handle_input (ACE_HANDLE) case 1: return 1; default: - return Update (); // another interesting line ;) + return Update(); // another interesting line ;) } ACE_NOTREACHED(return -1); } -int WorldSocket::handle_output (ACE_HANDLE) +int WorldSocket::handle_output(ACE_HANDLE) { - ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1); + ACE_GUARD_RETURN(LockType, Guard, m_OutBufferLock, -1); if (closing_) return -1; - const size_t send_len = m_OutBuffer->length (); + const size_t send_len = m_OutBuffer->length(); if (send_len == 0) - return handle_output_queue (Guard); + return handle_output_queue(Guard); #ifdef MSG_NOSIGNAL - ssize_t n = peer ().send (m_OutBuffer->rd_ptr (), send_len, MSG_NOSIGNAL); + ssize_t n = peer().send(m_OutBuffer->rd_ptr(), send_len, MSG_NOSIGNAL); #else - ssize_t n = peer ().send (m_OutBuffer->rd_ptr (), send_len); + ssize_t n = peer().send(m_OutBuffer->rd_ptr(), send_len); #endif // MSG_NOSIGNAL if (n == 0) @@ -342,48 +342,48 @@ int WorldSocket::handle_output (ACE_HANDLE) else if (n == -1) { if (errno == EWOULDBLOCK || errno == EAGAIN) - return schedule_wakeup_output (Guard); + return schedule_wakeup_output(Guard); return -1; } else if (n < (ssize_t)send_len) //now n > 0 { - m_OutBuffer->rd_ptr (static_cast (n)); + m_OutBuffer->rd_ptr(static_cast(n)); // move the data to the base of the buffer - m_OutBuffer->crunch (); + m_OutBuffer->crunch(); - return schedule_wakeup_output (Guard); + return schedule_wakeup_output(Guard); } else //now n == send_len { - m_OutBuffer->reset (); + m_OutBuffer->reset(); - return handle_output_queue (Guard); + return handle_output_queue(Guard); } - ACE_NOTREACHED (return 0); + ACE_NOTREACHED(return 0); } -int WorldSocket::handle_output_queue (GuardType& g) +int WorldSocket::handle_output_queue(GuardType& g) { - if(msg_queue()->is_empty()) + if (msg_queue()->is_empty()) return cancel_wakeup_output(g); - ACE_Message_Block *mblk; + ACE_Message_Block* mblk; - if(msg_queue()->dequeue_head(mblk, (ACE_Time_Value*)&ACE_Time_Value::zero) == -1) + if (msg_queue()->dequeue_head(mblk, (ACE_Time_Value*)&ACE_Time_Value::zero) == -1) { sLog.outError("WorldSocket::handle_output_queue dequeue_head"); return -1; } - const size_t send_len = mblk->length (); + const size_t send_len = mblk->length(); #ifdef MSG_NOSIGNAL - ssize_t n = peer ().send (mblk->rd_ptr (), send_len, MSG_NOSIGNAL); + ssize_t n = peer().send(mblk->rd_ptr(), send_len, MSG_NOSIGNAL); #else - ssize_t n = peer ().send (mblk->rd_ptr (), send_len); + ssize_t n = peer().send(mblk->rd_ptr(), send_len); #endif // MSG_NOSIGNAL if (n == 0) @@ -397,7 +397,7 @@ int WorldSocket::handle_output_queue (GuardType& g) if (errno == EWOULDBLOCK || errno == EAGAIN) { msg_queue()->enqueue_head(mblk, (ACE_Time_Value*) &ACE_Time_Value::zero); - return schedule_wakeup_output (g); + return schedule_wakeup_output(g); } mblk->release(); @@ -405,7 +405,7 @@ int WorldSocket::handle_output_queue (GuardType& g) } else if (n < (ssize_t)send_len) //now n > 0 { - mblk->rd_ptr (static_cast (n)); + mblk->rd_ptr(static_cast(n)); if (msg_queue()->enqueue_head(mblk, (ACE_Time_Value*) &ACE_Time_Value::zero) == -1) { @@ -414,7 +414,7 @@ int WorldSocket::handle_output_queue (GuardType& g) return -1; } - return schedule_wakeup_output (g); + return schedule_wakeup_output(g); } else //now n == send_len { @@ -426,21 +426,21 @@ int WorldSocket::handle_output_queue (GuardType& g) ACE_NOTREACHED(return -1); } -int WorldSocket::handle_close (ACE_HANDLE h, ACE_Reactor_Mask) +int WorldSocket::handle_close(ACE_HANDLE h, ACE_Reactor_Mask) { // Critical section { - ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1); + ACE_GUARD_RETURN(LockType, Guard, m_OutBufferLock, -1); closing_ = true; if (h == ACE_INVALID_HANDLE) - peer ().close_writer (); + peer().close_writer(); } // Critical section { - ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1); + ACE_GUARD_RETURN(LockType, Guard, m_SessionLock, -1); m_Session = NULL; } @@ -449,39 +449,39 @@ int WorldSocket::handle_close (ACE_HANDLE h, ACE_Reactor_Mask) return 0; } -int WorldSocket::Update (void) +int WorldSocket::Update(void) { if (closing_) return -1; - if (m_OutActive || (m_OutBuffer->length () == 0 && msg_queue()->is_empty())) + if (m_OutActive || (m_OutBuffer->length() == 0 && msg_queue()->is_empty())) return 0; int ret; do - ret = handle_output (get_handle ()); - while( ret > 0 ); + ret = handle_output(get_handle()); + while (ret > 0); return ret; } -int WorldSocket::handle_input_header (void) +int WorldSocket::handle_input_header(void) { - MANGOS_ASSERT (m_RecvWPct == NULL); + MANGOS_ASSERT(m_RecvWPct == NULL); - MANGOS_ASSERT (m_Header.length () == sizeof (ClientPktHeader)); + MANGOS_ASSERT(m_Header.length() == sizeof(ClientPktHeader)); - m_Crypt.DecryptRecv ((uint8*) m_Header.rd_ptr (), sizeof (ClientPktHeader)); + m_Crypt.DecryptRecv((uint8*) m_Header.rd_ptr(), sizeof(ClientPktHeader)); - ClientPktHeader& header = *((ClientPktHeader*) m_Header.rd_ptr ()); + ClientPktHeader& header = *((ClientPktHeader*) m_Header.rd_ptr()); EndianConvertReverse(header.size); EndianConvert(header.cmd); if ((header.size < 4) || (header.size > 10240) || (header.cmd > 10240)) { - sLog.outError ("WorldSocket::handle_input_header: client sent malformed packet size = %d , cmd = %d", - header.size, header.cmd); + sLog.outError("WorldSocket::handle_input_header: client sent malformed packet size = %d , cmd = %d", + header.size, header.cmd); errno = EINVAL; return -1; @@ -489,12 +489,12 @@ int WorldSocket::handle_input_header (void) header.size -= 4; - ACE_NEW_RETURN (m_RecvWPct, WorldPacket ((uint16) header.cmd, header.size), -1); + ACE_NEW_RETURN(m_RecvWPct, WorldPacket((uint16) header.cmd, header.size), -1); - if(header.size > 0) + if (header.size > 0) { - m_RecvWPct->resize (header.size); - m_RecvPct.base ((char*) m_RecvWPct->contents (), m_RecvWPct->size ()); + m_RecvWPct->resize(header.size); + m_RecvPct.base((char*) m_RecvWPct->contents(), m_RecvWPct->size()); } else { @@ -504,22 +504,22 @@ int WorldSocket::handle_input_header (void) return 0; } -int WorldSocket::handle_input_payload (void) +int WorldSocket::handle_input_payload(void) { // set errno properly here on error !!! // now have a header and payload - MANGOS_ASSERT (m_RecvPct.space () == 0); - MANGOS_ASSERT (m_Header.space () == 0); - MANGOS_ASSERT (m_RecvWPct != NULL); + MANGOS_ASSERT(m_RecvPct.space() == 0); + MANGOS_ASSERT(m_Header.space() == 0); + MANGOS_ASSERT(m_RecvWPct != NULL); - const int ret = ProcessIncoming (m_RecvWPct); + const int ret = ProcessIncoming(m_RecvWPct); - m_RecvPct.base (NULL, 0); - m_RecvPct.reset (); + m_RecvPct.base(NULL, 0); + m_RecvPct.reset(); m_RecvWPct = NULL; - m_Header.reset (); + m_Header.reset(); if (ret == -1) errno = EINVAL; @@ -527,53 +527,53 @@ int WorldSocket::handle_input_payload (void) return ret; } -int WorldSocket::handle_input_missing_data (void) +int WorldSocket::handle_input_missing_data(void) { char buf [4096]; - ACE_Data_Block db ( sizeof (buf), - ACE_Message_Block::MB_DATA, - buf, - 0, - 0, - ACE_Message_Block::DONT_DELETE, - 0); + ACE_Data_Block db(sizeof(buf), + ACE_Message_Block::MB_DATA, + buf, + 0, + 0, + ACE_Message_Block::DONT_DELETE, + 0); ACE_Message_Block message_block(&db, ACE_Message_Block::DONT_DELETE, 0); - const size_t recv_size = message_block.space (); + const size_t recv_size = message_block.space(); - const ssize_t n = peer ().recv (message_block.wr_ptr (), - recv_size); + const ssize_t n = peer().recv(message_block.wr_ptr(), + recv_size); if (n <= 0) return (int)n; - message_block.wr_ptr (n); + message_block.wr_ptr(n); - while (message_block.length () > 0) + while (message_block.length() > 0) { - if (m_Header.space () > 0) + if (m_Header.space() > 0) { //need to receive the header - const size_t to_header = (message_block.length () > m_Header.space () ? m_Header.space () : message_block.length ()); - m_Header.copy (message_block.rd_ptr (), to_header); - message_block.rd_ptr (to_header); + const size_t to_header = (message_block.length() > m_Header.space() ? m_Header.space() : message_block.length()); + m_Header.copy(message_block.rd_ptr(), to_header); + message_block.rd_ptr(to_header); - if (m_Header.space () > 0) + if (m_Header.space() > 0) { // Couldn't receive the whole header this time. - MANGOS_ASSERT (message_block.length () == 0); + MANGOS_ASSERT(message_block.length() == 0); errno = EWOULDBLOCK; return -1; } // We just received nice new header - if (handle_input_header () == -1) + if (handle_input_header() == -1) { - MANGOS_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN)); + MANGOS_ASSERT((errno != EWOULDBLOCK) && (errno != EAGAIN)); return -1; } } @@ -583,32 +583,32 @@ int WorldSocket::handle_input_missing_data (void) // hope this is not hack ,as proper m_RecvWPct is asserted around if (!m_RecvWPct) { - sLog.outError ("Forcing close on input m_RecvWPct = NULL"); + sLog.outError("Forcing close on input m_RecvWPct = NULL"); errno = EINVAL; return -1; } // We have full read header, now check the data payload - if (m_RecvPct.space () > 0) + if (m_RecvPct.space() > 0) { //need more data in the payload - const size_t to_data = (message_block.length () > m_RecvPct.space () ? m_RecvPct.space () : message_block.length ()); - m_RecvPct.copy (message_block.rd_ptr (), to_data); - message_block.rd_ptr (to_data); + const size_t to_data = (message_block.length() > m_RecvPct.space() ? m_RecvPct.space() : message_block.length()); + m_RecvPct.copy(message_block.rd_ptr(), to_data); + message_block.rd_ptr(to_data); - if (m_RecvPct.space () > 0) + if (m_RecvPct.space() > 0) { // Couldn't receive the whole data this time. - MANGOS_ASSERT (message_block.length () == 0); + MANGOS_ASSERT(message_block.length() == 0); errno = EWOULDBLOCK; return -1; } } //just received fresh new payload - if (handle_input_payload () == -1) + if (handle_input_payload() == -1) { - MANGOS_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN)); + MANGOS_ASSERT((errno != EWOULDBLOCK) && (errno != EAGAIN)); return -1; } } @@ -616,57 +616,57 @@ int WorldSocket::handle_input_missing_data (void) return size_t(n) == recv_size ? 1 : 2; } -int WorldSocket::cancel_wakeup_output (GuardType& g) +int WorldSocket::cancel_wakeup_output(GuardType& g) { if (!m_OutActive) return 0; m_OutActive = false; - g.release (); + g.release(); - if (reactor ()->cancel_wakeup - (this, ACE_Event_Handler::WRITE_MASK) == -1) + if (reactor()->cancel_wakeup + (this, ACE_Event_Handler::WRITE_MASK) == -1) { // would be good to store errno from reactor with errno guard - sLog.outError ("WorldSocket::cancel_wakeup_output"); + sLog.outError("WorldSocket::cancel_wakeup_output"); return -1; } return 0; } -int WorldSocket::schedule_wakeup_output (GuardType& g) +int WorldSocket::schedule_wakeup_output(GuardType& g) { if (m_OutActive) return 0; m_OutActive = true; - g.release (); + g.release(); - if (reactor ()->schedule_wakeup - (this, ACE_Event_Handler::WRITE_MASK) == -1) + if (reactor()->schedule_wakeup + (this, ACE_Event_Handler::WRITE_MASK) == -1) { - sLog.outError ("WorldSocket::schedule_wakeup_output"); + sLog.outError("WorldSocket::schedule_wakeup_output"); return -1; } return 0; } -int WorldSocket::ProcessIncoming (WorldPacket* new_pct) +int WorldSocket::ProcessIncoming(WorldPacket* new_pct) { - MANGOS_ASSERT (new_pct); + MANGOS_ASSERT(new_pct); // manage memory ;) - ACE_Auto_Ptr aptr (new_pct); + ACE_Auto_Ptr aptr(new_pct); - const ACE_UINT16 opcode = new_pct->GetOpcode (); + const ACE_UINT16 opcode = new_pct->GetOpcode(); if (opcode >= NUM_MSG_TYPES) { - sLog.outError( "SESSION: received nonexistent opcode 0x%.4X", opcode); + sLog.outError("SESSION: received nonexistent opcode 0x%.4X", opcode); return -1; } @@ -678,47 +678,47 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct) try { - switch(opcode) + switch (opcode) { case CMSG_PING: - return HandlePing (*new_pct); + return HandlePing(*new_pct); case CMSG_AUTH_SESSION: if (m_Session) { - sLog.outError ("WorldSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again"); + sLog.outError("WorldSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again"); return -1; } - return HandleAuthSession (*new_pct); + return HandleAuthSession(*new_pct); case CMSG_KEEP_ALIVE: - DEBUG_LOG ("CMSG_KEEP_ALIVE ,size: "SIZEFMTD" ", new_pct->size ()); + DEBUG_LOG("CMSG_KEEP_ALIVE ,size: "SIZEFMTD" ", new_pct->size()); return 0; default: { - ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1); + ACE_GUARD_RETURN(LockType, Guard, m_SessionLock, -1); if (m_Session != NULL) { // OK ,give the packet to WorldSession - aptr.release (); + aptr.release(); // WARNING here we call it with locks held. // Its possible to cause deadlock if QueuePacket calls back - m_Session->QueuePacket (new_pct); + m_Session->QueuePacket(new_pct); return 0; } else { - sLog.outError ("WorldSocket::ProcessIncoming: Client not authed opcode = %u", uint32(opcode)); + sLog.outError("WorldSocket::ProcessIncoming: Client not authed opcode = %u", uint32(opcode)); return -1; } } } } - catch (ByteBufferException &) + catch (ByteBufferException&) { sLog.outError("WorldSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i.", - opcode, GetRemoteAddress().c_str(), m_Session?m_Session->GetAccountId():-1); + opcode, GetRemoteAddress().c_str(), m_Session?m_Session->GetAccountId():-1); if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) { DEBUG_LOG("Dumping error-causing packet:"); @@ -728,7 +728,7 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct) if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET)) { DETAIL_LOG("Disconnecting session [account id %i / address %s] for badly formatted packet.", - m_Session?m_Session->GetAccountId():-1, GetRemoteAddress().c_str()); + m_Session?m_Session->GetAccountId():-1, GetRemoteAddress().c_str()); return -1; } @@ -736,10 +736,10 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct) return 0; } - ACE_NOTREACHED (return 0); + ACE_NOTREACHED(return 0); } -int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) +int WorldSocket::HandleAuthSession(WorldPacket& recvPacket) { // NOTE: ATM the socket is singlethread, have this in mind ... uint8 digest[20]; @@ -762,87 +762,87 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) recvPacket.read_skip(); recvPacket.read_skip(); recvPacket.read_skip(); - recvPacket.read (digest, 20); + recvPacket.read(digest, 20); - DEBUG_LOG ("WorldSocket::HandleAuthSession: client build %u, account %s, clientseed %X", - ClientBuild, - account.c_str(), - clientSeed); + DEBUG_LOG("WorldSocket::HandleAuthSession: client build %u, account %s, clientseed %X", + ClientBuild, + account.c_str(), + clientSeed); // Check the version of client trying to connect - if(!IsAcceptableClientBuild(ClientBuild)) + if (!IsAcceptableClientBuild(ClientBuild)) { - packet.Initialize (SMSG_AUTH_RESPONSE, 1); - packet << uint8 (AUTH_VERSION_MISMATCH); + packet.Initialize(SMSG_AUTH_RESPONSE, 1); + packet << uint8(AUTH_VERSION_MISMATCH); - SendPacket (packet); + SendPacket(packet); - sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (version mismatch)."); + sLog.outError("WorldSocket::HandleAuthSession: Sent Auth Response (version mismatch)."); return -1; } // Get the account information from the realmd database std::string safe_account = account; // Duplicate, else will screw the SHA hash verification below - LoginDatabase.escape_string (safe_account); + LoginDatabase.escape_string(safe_account); // No SQL injection, username escaped. - QueryResult *result = - LoginDatabase.PQuery ("SELECT " - "id, " //0 - "gmlevel, " //1 - "sessionkey, " //2 - "last_ip, " //3 - "locked, " //4 - "v, " //5 - "s, " //6 - "expansion, " //7 - "mutetime, " //8 - "locale " //9 - "FROM account " - "WHERE username = '%s'", - safe_account.c_str ()); + QueryResult* result = + LoginDatabase.PQuery("SELECT " + "id, " //0 + "gmlevel, " //1 + "sessionkey, " //2 + "last_ip, " //3 + "locked, " //4 + "v, " //5 + "s, " //6 + "expansion, " //7 + "mutetime, " //8 + "locale " //9 + "FROM account " + "WHERE username = '%s'", + safe_account.c_str()); // Stop if the account is not found if (!result) { - packet.Initialize (SMSG_AUTH_RESPONSE, 1); - packet << uint8 (AUTH_UNKNOWN_ACCOUNT); + packet.Initialize(SMSG_AUTH_RESPONSE, 1); + packet << uint8(AUTH_UNKNOWN_ACCOUNT); - SendPacket (packet); + SendPacket(packet); - sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (unknown account)."); + sLog.outError("WorldSocket::HandleAuthSession: Sent Auth Response (unknown account)."); return -1; } - Field* fields = result->Fetch (); + Field* fields = result->Fetch(); expansion = ((sWorld.getConfig(CONFIG_UINT32_EXPANSION) > fields[7].GetUInt8()) ? fields[7].GetUInt8() : sWorld.getConfig(CONFIG_UINT32_EXPANSION)); - N.SetHexStr ("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7"); - g.SetDword (7); + N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7"); + g.SetDword(7); v.SetHexStr(fields[5].GetString()); - s.SetHexStr (fields[6].GetString()); + s.SetHexStr(fields[6].GetString()); m_s = s; - const char* sStr = s.AsHexStr (); //Must be freed by OPENSSL_free() - const char* vStr = v.AsHexStr (); //Must be freed by OPENSSL_free() + const char* sStr = s.AsHexStr(); //Must be freed by OPENSSL_free() + const char* vStr = v.AsHexStr(); //Must be freed by OPENSSL_free() - DEBUG_LOG ("WorldSocket::HandleAuthSession: (s,v) check s: %s v: %s", - sStr, - vStr); + DEBUG_LOG("WorldSocket::HandleAuthSession: (s,v) check s: %s v: %s", + sStr, + vStr); - OPENSSL_free ((void*) sStr); - OPENSSL_free ((void*) vStr); + OPENSSL_free((void*) sStr); + OPENSSL_free((void*) vStr); ///- Re-check ip locking (same check as in realmd). - if (fields[4].GetUInt8 () == 1) // if ip is locked + if (fields[4].GetUInt8() == 1) // if ip is locked { - if (strcmp (fields[3].GetString (), GetRemoteAddress ().c_str ())) + if (strcmp(fields[3].GetString(), GetRemoteAddress().c_str())) { - packet.Initialize (SMSG_AUTH_RESPONSE, 1); - packet << uint8 (AUTH_FAILED); - SendPacket (packet); + packet.Initialize(SMSG_AUTH_RESPONSE, 1); + packet << uint8(AUTH_FAILED); + SendPacket(packet); delete result; BASIC_LOG("WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs)."); @@ -850,49 +850,49 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) } } - id = fields[0].GetUInt32 (); - security = fields[1].GetUInt16 (); - if(security > SEC_ADMINISTRATOR) // prevent invalid security settings in DB + id = fields[0].GetUInt32(); + security = fields[1].GetUInt16(); + if (security > SEC_ADMINISTRATOR) // prevent invalid security settings in DB security = SEC_ADMINISTRATOR; - K.SetHexStr (fields[2].GetString ()); + K.SetHexStr(fields[2].GetString()); - time_t mutetime = time_t (fields[8].GetUInt64 ()); + time_t mutetime = time_t (fields[8].GetUInt64()); - locale = LocaleConstant (fields[9].GetUInt8 ()); + locale = LocaleConstant(fields[9].GetUInt8()); if (locale >= MAX_LOCALE) locale = LOCALE_enUS; delete result; // Re-check account ban (same check as in realmd) - QueryResult *banresult = - LoginDatabase.PQuery ("SELECT 1 FROM account_banned WHERE id = %u AND active = 1 AND (unbandate > UNIX_TIMESTAMP() OR unbandate = bandate)" - "UNION " - "SELECT 1 FROM ip_banned WHERE (unbandate = bandate OR unbandate > UNIX_TIMESTAMP()) AND ip = '%s'", - id, GetRemoteAddress().c_str()); + QueryResult* banresult = + LoginDatabase.PQuery("SELECT 1 FROM account_banned WHERE id = %u AND active = 1 AND (unbandate > UNIX_TIMESTAMP() OR unbandate = bandate)" + "UNION " + "SELECT 1 FROM ip_banned WHERE (unbandate = bandate OR unbandate > UNIX_TIMESTAMP()) AND ip = '%s'", + id, GetRemoteAddress().c_str()); if (banresult) // if account banned { - packet.Initialize (SMSG_AUTH_RESPONSE, 1); - packet << uint8 (AUTH_BANNED); - SendPacket (packet); + packet.Initialize(SMSG_AUTH_RESPONSE, 1); + packet << uint8(AUTH_BANNED); + SendPacket(packet); delete banresult; - sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (Account banned)."); + sLog.outError("WorldSocket::HandleAuthSession: Sent Auth Response (Account banned)."); return -1; } // Check locked state for server - AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit (); + AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit(); if (allowedAccountType > SEC_PLAYER && AccountTypes(security) < allowedAccountType) { - WorldPacket Packet (SMSG_AUTH_RESPONSE, 1); - Packet << uint8 (AUTH_UNAVAILABLE); + WorldPacket Packet(SMSG_AUTH_RESPONSE, 1); + Packet << uint8(AUTH_UNAVAILABLE); - SendPacket (packet); + SendPacket(packet); BASIC_LOG("WorldSocket::HandleAuthSession: User tries to login but his security level is not enough"); return -1; @@ -904,29 +904,29 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) uint32 t = 0; uint32 seed = m_Seed; - sha.UpdateData (account); - sha.UpdateData ((uint8 *) & t, 4); - sha.UpdateData ((uint8 *) & clientSeed, 4); - sha.UpdateData ((uint8 *) & seed, 4); - sha.UpdateBigNumbers (&K, NULL); - sha.Finalize (); + sha.UpdateData(account); + sha.UpdateData((uint8*) & t, 4); + sha.UpdateData((uint8*) & clientSeed, 4); + sha.UpdateData((uint8*) & seed, 4); + sha.UpdateBigNumbers(&K, NULL); + sha.Finalize(); - if (memcmp (sha.GetDigest (), digest, 20)) + if (memcmp(sha.GetDigest(), digest, 20)) { - packet.Initialize (SMSG_AUTH_RESPONSE, 1); - packet << uint8 (AUTH_FAILED); + packet.Initialize(SMSG_AUTH_RESPONSE, 1); + packet << uint8(AUTH_FAILED); - SendPacket (packet); + SendPacket(packet); - sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (authentification failed)."); + sLog.outError("WorldSocket::HandleAuthSession: Sent Auth Response (authentification failed)."); return -1; } - std::string address = GetRemoteAddress (); + std::string address = GetRemoteAddress(); - DEBUG_LOG ("WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.", - account.c_str (), - address.c_str ()); + DEBUG_LOG("WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.", + account.c_str(), + address.c_str()); // Update the last_ip in the database // No SQL injection, username escaped. @@ -936,7 +936,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) stmt.PExecute(address.c_str(), account.c_str()); // NOTE ATM the socket is single-threaded, have this in mind ... - ACE_NEW_RETURN (m_Session, WorldSession (id, this, AccountTypes(security), expansion, mutetime, locale), -1); + ACE_NEW_RETURN(m_Session, WorldSession(id, this, AccountTypes(security), expansion, mutetime, locale), -1); m_Crypt.Init(&K); @@ -945,14 +945,14 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) m_Session->ReadAddonsInfo(recvPacket); // In case needed sometime the second arg is in microseconds 1 000 000 = 1 sec - ACE_OS::sleep (ACE_Time_Value (0, 10000)); + ACE_OS::sleep(ACE_Time_Value(0, 10000)); - sWorld.AddSession (m_Session); + sWorld.AddSession(m_Session); return 0; } -int WorldSocket::HandlePing (WorldPacket& recvPacket) +int WorldSocket::HandlePing(WorldPacket& recvPacket) { uint32 ping; uint32 latency; @@ -962,29 +962,29 @@ int WorldSocket::HandlePing (WorldPacket& recvPacket) recvPacket >> latency; if (m_LastPingTime == ACE_Time_Value::zero) - m_LastPingTime = ACE_OS::gettimeofday (); // for 1st ping + m_LastPingTime = ACE_OS::gettimeofday(); // for 1st ping else { - ACE_Time_Value cur_time = ACE_OS::gettimeofday (); - ACE_Time_Value diff_time (cur_time); + ACE_Time_Value cur_time = ACE_OS::gettimeofday(); + ACE_Time_Value diff_time(cur_time); diff_time -= m_LastPingTime; m_LastPingTime = cur_time; - if (diff_time < ACE_Time_Value (27)) + if (diff_time < ACE_Time_Value(27)) { ++m_OverSpeedPings; - uint32 max_count = sWorld.getConfig (CONFIG_UINT32_MAX_OVERSPEED_PINGS); + uint32 max_count = sWorld.getConfig(CONFIG_UINT32_MAX_OVERSPEED_PINGS); if (max_count && m_OverSpeedPings > max_count) { - ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1); + ACE_GUARD_RETURN(LockType, Guard, m_SessionLock, -1); - if (m_Session && m_Session->GetSecurity () == SEC_PLAYER) + if (m_Session && m_Session->GetSecurity() == SEC_PLAYER) { - sLog.outError ("WorldSocket::HandlePing: Player kicked for " - "overspeeded pings address = %s", - GetRemoteAddress ().c_str ()); + sLog.outError("WorldSocket::HandlePing: Player kicked for " + "overspeeded pings address = %s", + GetRemoteAddress().c_str()); return -1; } @@ -996,21 +996,21 @@ int WorldSocket::HandlePing (WorldPacket& recvPacket) // critical section { - ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1); + ACE_GUARD_RETURN(LockType, Guard, m_SessionLock, -1); if (m_Session) - m_Session->SetLatency (latency); + m_Session->SetLatency(latency); else { - sLog.outError ("WorldSocket::HandlePing: peer sent CMSG_PING, " - "but is not authenticated or got recently kicked," - " address = %s", - GetRemoteAddress ().c_str ()); - return -1; + sLog.outError("WorldSocket::HandlePing: peer sent CMSG_PING, " + "but is not authenticated or got recently kicked," + " address = %s", + GetRemoteAddress().c_str()); + return -1; } } - WorldPacket packet (SMSG_PONG, 4); + WorldPacket packet(SMSG_PONG, 4); packet << ping; - return SendPacket (packet); + return SendPacket(packet); } diff --git a/src/game/WorldSocket.h b/src/game/WorldSocket.h index f931335e2..22fa2febc 100644 --- a/src/game/WorldSocket.h +++ b/src/game/WorldSocket.h @@ -103,75 +103,75 @@ class WorldSocket : protected WorldHandler typedef ACE_Guard GuardType; /// Check if socket is closed. - bool IsClosed (void) const; + bool IsClosed(void) const; /// Close the socket. - void CloseSocket (void); + void CloseSocket(void); /// Get address of connected peer. - const std::string& GetRemoteAddress (void) const; + const std::string& GetRemoteAddress(void) const; /// Send A packet on the socket, this function is reentrant. /// @param pct packet to send /// @return -1 of failure - int SendPacket (const WorldPacket& pct); + int SendPacket(const WorldPacket& pct); /// Add reference to this object. - long AddReference (void); + long AddReference(void); /// Remove reference to this object. - long RemoveReference (void); + long RemoveReference(void); /// Return the session key BigNumber& GetSessionKey() { return m_s; } protected: /// things called by ACE framework. - WorldSocket (void); - virtual ~WorldSocket (void); + WorldSocket(void); + virtual ~WorldSocket(void); /// Called on open ,the void* is the acceptor. - virtual int open (void *); + virtual int open(void*); /// Called on failures inside of the acceptor, don't call from your code. - virtual int close (int); + virtual int close(int); /// Called when we can read from the socket. - virtual int handle_input (ACE_HANDLE = ACE_INVALID_HANDLE); + virtual int handle_input(ACE_HANDLE = ACE_INVALID_HANDLE); /// Called when the socket can write. - virtual int handle_output (ACE_HANDLE = ACE_INVALID_HANDLE); + virtual int handle_output(ACE_HANDLE = ACE_INVALID_HANDLE); /// Called when connection is closed or error happens. - virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, - ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); + virtual int handle_close(ACE_HANDLE = ACE_INVALID_HANDLE, + ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); /// Called by WorldSocketMgr/ReactorRunnable. - int Update (void); + int Update(void); private: /// Helper functions for processing incoming data. - int handle_input_header (void); - int handle_input_payload (void); - int handle_input_missing_data (void); + int handle_input_header(void); + int handle_input_payload(void); + int handle_input_missing_data(void); /// Help functions to mark/unmark the socket for output. /// @param g the guard is for m_OutBufferLock, the function will release it - int cancel_wakeup_output (GuardType& g); - int schedule_wakeup_output (GuardType& g); + int cancel_wakeup_output(GuardType& g); + int schedule_wakeup_output(GuardType& g); /// Drain the queue if its not empty. - int handle_output_queue (GuardType& g); + int handle_output_queue(GuardType& g); /// process one incoming packet. /// @param new_pct received packet ,note that you need to delete it. - int ProcessIncoming (WorldPacket* new_pct); + int ProcessIncoming(WorldPacket* new_pct); /// Called by ProcessIncoming() on CMSG_AUTH_SESSION. - int HandleAuthSession (WorldPacket& recvPacket); + int HandleAuthSession(WorldPacket& recvPacket); /// Called by ProcessIncoming() on CMSG_PING. - int HandlePing (WorldPacket& recvPacket); + int HandlePing(WorldPacket& recvPacket); private: /// Time in which the last ping was received @@ -207,7 +207,7 @@ class WorldSocket : protected WorldHandler LockType m_OutBufferLock; /// Buffer used for writing output. - ACE_Message_Block *m_OutBuffer; + ACE_Message_Block* m_OutBuffer; /// Size of the m_OutBuffer. size_t m_OutBufferSize; diff --git a/src/game/WorldSocketMgr.cpp b/src/game/WorldSocketMgr.cpp index 24fbb6661..17e577649 100644 --- a/src/game/WorldSocketMgr.cpp +++ b/src/game/WorldSocketMgr.cpp @@ -53,25 +53,25 @@ class ReactorRunnable : protected ACE_Task_Base { public: ReactorRunnable() : - m_Reactor (0), - m_Connections (0), - m_ThreadId (-1) + m_Reactor(0), + m_Connections(0), + m_ThreadId(-1) { ACE_Reactor_Impl* imp = 0; - #if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL) +#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL) imp = new ACE_Dev_Poll_Reactor(); imp->max_notify_iterations(128); imp->restart(1); - #else +#else imp = new ACE_TP_Reactor(); imp->max_notify_iterations(128); - #endif +#endif m_Reactor = new ACE_Reactor(imp, 1); } @@ -102,17 +102,17 @@ class ReactorRunnable : protected ACE_Task_Base long Connections() { - return static_cast (m_Connections.value()); + return static_cast(m_Connections.value()); } - int AddSocket (WorldSocket* sock) + int AddSocket(WorldSocket* sock) { - ACE_GUARD_RETURN (ACE_Thread_Mutex, Guard, m_NewSockets_Lock, -1); + ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, m_NewSockets_Lock, -1); ++m_Connections; sock->AddReference(); - sock->reactor (m_Reactor); - m_NewSockets.insert (sock); + sock->reactor(m_Reactor); + m_NewSockets.insert(sock); return 0; } @@ -125,7 +125,7 @@ class ReactorRunnable : protected ACE_Task_Base protected: void AddNewSockets() { - ACE_GUARD (ACE_Thread_Mutex, Guard, m_NewSockets_Lock); + ACE_GUARD(ACE_Thread_Mutex, Guard, m_NewSockets_Lock); if (m_NewSockets.empty()) return; @@ -148,7 +148,7 @@ class ReactorRunnable : protected ACE_Task_Base virtual int svc() { - DEBUG_LOG ("Network Thread Starting"); + DEBUG_LOG("Network Thread Starting"); WorldDatabase.ThreadStart(); @@ -160,9 +160,9 @@ class ReactorRunnable : protected ACE_Task_Base { // dont be too smart to move this outside the loop // the run_reactor_event_loop will modify interval - ACE_Time_Value interval (0, 10000); + ACE_Time_Value interval(0, 10000); - if (m_Reactor->run_reactor_event_loop (interval) == -1) + if (m_Reactor->run_reactor_event_loop(interval) == -1) break; AddNewSockets(); @@ -185,7 +185,7 @@ class ReactorRunnable : protected ACE_Task_Base WorldDatabase.ThreadEnd(); - DEBUG_LOG ("Network Thread Exitting"); + DEBUG_LOG("Network Thread Exitting"); return 0; } @@ -219,23 +219,23 @@ WorldSocketMgr::~WorldSocketMgr() if (m_NetThreads) delete [] m_NetThreads; - if(m_Acceptor) + if (m_Acceptor) delete m_Acceptor; } -int WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address) +int WorldSocketMgr::StartReactiveIO(ACE_UINT16 port, const char* address) { - m_UseNoDelay = sConfig.GetBoolDefault ("Network.TcpNodelay", true); + m_UseNoDelay = sConfig.GetBoolDefault("Network.TcpNodelay", true); - int num_threads = sConfig.GetIntDefault ("Network.Threads", 1); + int num_threads = sConfig.GetIntDefault("Network.Threads", 1); if (num_threads <= 0) { - sLog.outError ("Network.Threads is wrong in your config file"); + sLog.outError("Network.Threads is wrong in your config file"); return -1; } - m_NetThreadsCount = static_cast (num_threads + 1); + m_NetThreadsCount = static_cast(num_threads + 1); m_NetThreads = new ReactorRunnable[m_NetThreadsCount]; @@ -248,18 +248,18 @@ int WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address) if (m_SockOutUBuff <= 0) { - sLog.outError ("Network.OutUBuff is wrong in your config file"); + sLog.outError("Network.OutUBuff is wrong in your config file"); return -1; } WorldSocket::Acceptor* acc = new WorldSocket::Acceptor; m_Acceptor = acc; - ACE_INET_Addr listen_addr (port, address); + ACE_INET_Addr listen_addr(port, address); - if (acc->open (listen_addr, m_NetThreads[0].GetReactor(), ACE_NONBLOCK) == -1) + if (acc->open(listen_addr, m_NetThreads[0].GetReactor(), ACE_NONBLOCK) == -1) { - sLog.outError ("Failed to open acceptor, check if the port is free"); + sLog.outError("Failed to open acceptor, check if the port is free"); return -1; } @@ -269,15 +269,15 @@ int WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address) return 0; } -int WorldSocketMgr::StartNetwork (ACE_UINT16 port, std::string& address) +int WorldSocketMgr::StartNetwork(ACE_UINT16 port, std::string& address) { m_addr = address; m_port = port; if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) - ACE_Log_Msg::instance()->priority_mask (LM_ERROR, ACE_Log_Msg::PROCESS); + ACE_Log_Msg::instance()->priority_mask(LM_ERROR, ACE_Log_Msg::PROCESS); - if (StartReactiveIO (port, address.c_str()) == -1) + if (StartReactiveIO(port, address.c_str()) == -1) return -1; return 0; @@ -318,7 +318,7 @@ int WorldSocketMgr::OnSocketOpen(WorldSocket* sock) { if (sock->peer().set_option(SOL_SOCKET, SO_SNDBUF, (void*)&m_SockOutKBuff, sizeof(int)) == -1 && errno != ENOTSUP) { - sLog.outError ("WorldSocketMgr::OnSocketOpen set_option SO_SNDBUF"); + sLog.outError("WorldSocketMgr::OnSocketOpen set_option SO_SNDBUF"); return -1; } } @@ -328,25 +328,25 @@ int WorldSocketMgr::OnSocketOpen(WorldSocket* sock) // Set TCP_NODELAY. if (m_UseNoDelay) { - if (sock->peer().set_option(ACE_IPPROTO_TCP, TCP_NODELAY, (void*)&ndoption, sizeof (int)) == -1) + if (sock->peer().set_option(ACE_IPPROTO_TCP, TCP_NODELAY, (void*)&ndoption, sizeof(int)) == -1) { sLog.outError("WorldSocketMgr::OnSocketOpen: peer().set_option TCP_NODELAY errno = %s", ACE_OS::strerror(errno)); return -1; } } - sock->m_OutBufferSize = static_cast (m_SockOutUBuff); + sock->m_OutBufferSize = static_cast(m_SockOutUBuff); // we skip the Acceptor Thread size_t min = 1; - MANGOS_ASSERT (m_NetThreadsCount >= 1); + MANGOS_ASSERT(m_NetThreadsCount >= 1); for (size_t i = 1; i < m_NetThreadsCount; ++i) if (m_NetThreads[i].Connections() < m_NetThreads[min].Connections()) min = i; - return m_NetThreads[min].AddSocket (sock); + return m_NetThreads[min].AddSocket(sock); } WorldSocketMgr* WorldSocketMgr::Instance()