diff options
Diffstat (limited to 'src')
313 files changed, 5760 insertions, 6209 deletions
diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp index 1b0800e48ae..7b2ad044eb9 100755 --- a/src/server/authserver/Server/AuthSocket.cpp +++ b/src/server/authserver/Server/AuthSocket.cpp @@ -27,6 +27,7 @@ #include "AuthSocket.h" #include "AuthCodes.h" #include "SHA1.h" +#include "openssl/crypto.h" #define ChunkSize 2048 diff --git a/src/server/collision/BoundingIntervalHierarchy.h b/src/server/collision/BoundingIntervalHierarchy.h index 0dc597e98bc..cb6158e94eb 100755 --- a/src/server/collision/BoundingIntervalHierarchy.h +++ b/src/server/collision/BoundingIntervalHierarchy.h @@ -88,6 +88,7 @@ class BIH { if (primitives.empty()) return; + buildData dat; dat.maxPrims = leafSize; dat.numPrims = primitives.size(); diff --git a/src/server/collision/Models/WorldModel.cpp b/src/server/collision/Models/WorldModel.cpp index 55aad9bb029..118ae098c25 100644 --- a/src/server/collision/Models/WorldModel.cpp +++ b/src/server/collision/Models/WorldModel.cpp @@ -362,6 +362,7 @@ namespace VMAP { if (triangles.empty()) return false; + GModelRayCallback callback(triangles, vertices); meshTree.intersectRay(ray, callback, distance, stopAtFirstHit); return callback.hit; @@ -470,6 +471,7 @@ namespace VMAP { if (groupModels.empty()) return false; + WModelAreaCallback callback(groupModels, down); groupTree.intersectPoint(p, callback); if (callback.hit != groupModels.end()) @@ -488,6 +490,7 @@ namespace VMAP { if (groupModels.empty()) return false; + WModelAreaCallback callback(groupModels, down); groupTree.intersectPoint(p, callback); if (callback.hit != groupModels.end()) diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 5a0c199a4c0..e009bf9d12a 100755 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -180,7 +180,7 @@ void PetAI::UpdateAI(const uint32 diff) if (!spellUsed) delete spell; } - else if (me->getVictim() && _CanAttack(me->getVictim()) && spellInfo->CanBeUsedInCombat()) + else if (me->getVictim() && CanAttack(me->getVictim()) && spellInfo->CanBeUsedInCombat()) { Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0); if (spell->CanAutoCast(me->getVictim())) @@ -290,7 +290,7 @@ void PetAI::AttackStart(Unit* target) // Overrides Unit::AttackStart to correctly evaluate Pet states // Check all pet states to decide if we can attack this target - if (!_CanAttack(target)) + if (!CanAttack(target)) return; targetHasCC = _CheckTargetCC(target); @@ -440,7 +440,7 @@ void PetAI::MovementInform(uint32 moveType, uint32 data) } } -bool PetAI::_CanAttack(Unit* target) +bool PetAI::CanAttack(Unit* target) { // Evaluates wether a pet can attack a specific // target based on CommandState, ReactState and other flags diff --git a/src/server/game/AI/CoreAI/PetAI.h b/src/server/game/AI/CoreAI/PetAI.h index 9f0472cfe4d..8d72b34cf8f 100755 --- a/src/server/game/AI/CoreAI/PetAI.h +++ b/src/server/game/AI/CoreAI/PetAI.h @@ -57,7 +57,7 @@ class PetAI : public CreatureAI Unit* SelectNextTarget(); void HandleReturnMovement(); void DoAttack(Unit* target, bool chase); - bool _CanAttack(Unit* target); + bool CanAttack(Unit* target); bool _CheckTargetCC(Unit* target); }; #endif diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp index 62d7a1f4f58..be0dd8c3679 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp @@ -1177,9 +1177,8 @@ inline Unit* CreatureEventAI::GetTargetByType(uint32 target, Unit* actionInvoker Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff) { - CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Unit* unit = NULL; @@ -1199,9 +1198,8 @@ Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff) void CreatureEventAI::DoFindFriendlyCC(std::list<Creature*>& _list, float range) { - CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::FriendlyCCedInRange u_check(me, range); @@ -1209,14 +1207,13 @@ void CreatureEventAI::DoFindFriendlyCC(std::list<Creature*>& _list, float range) TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange>, GridTypeMapContainer > grid_creature_searcher(searcher); - cell.Visit(p, grid_creature_searcher, *me->GetMap()); + cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range); } void CreatureEventAI::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid) { - CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::FriendlyMissingBuffInRange u_check(me, range, spellid); @@ -1224,7 +1221,7 @@ void CreatureEventAI::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, flo TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher); - cell.Visit(p, grid_creature_searcher, *me->GetMap()); + cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range); } // ********************************* diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 2322e88d105..953bbf7521a 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -363,16 +363,15 @@ Player* ScriptedAI::GetPlayerAtMinimumRange(float minimumRange) { Player* player = NULL; - CellPair pair(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); + CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::PlayerAtMinimumRangeAway check(me, minimumRange); Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway> searcher(me, player, check); TypeContainerVisitor<Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway>, GridTypeMapContainer> visitor(searcher); - cell.Visit(pair, visitor, *(me->GetMap())); + cell.Visit(pair, visitor, *me->GetMap(), *me, minimumRange); return player; } diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index cdea190dfbc..06c1570ccd9 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -218,7 +218,7 @@ void npc_escortAI::UpdateAI(uint32 const diff) if (m_bCanReturnToStart) { float fRetX, fRetY, fRetZ; - me->GetRespawnCoord(fRetX, fRetY, fRetZ); + me->GetRespawnPosition(fRetX, fRetY, fRetZ); me->GetMotionMaster()->MovePoint(POINT_HOME, fRetX, fRetY, fRetZ); @@ -493,7 +493,7 @@ void npc_escortAI::SetEscortPaused(bool on) bool npc_escortAI::SetNextWaypoint(uint32 pointId, float x, float y, float z, float orientation) { - me->SetPosition(x, y, z, orientation); + me->UpdatePosition(x, y, z, orientation); return SetNextWaypoint(pointId, false, true); } @@ -516,7 +516,7 @@ bool npc_escortAI::SetNextWaypoint(uint32 pointId, bool setPosition, bool resetW if (waypoint.id == pointId) { if (setPosition) - me->SetPosition(waypoint.x, waypoint.y, waypoint.z, me->GetOrientation()); + me->UpdatePosition(waypoint.x, waypoint.y, waypoint.z, me->GetOrientation()); CurrentWP = WaypointList.begin(); return true; diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 0b77dd03e87..afa7e9c2932 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -450,12 +450,14 @@ void SmartAI::EnterEvadeMode() { AddEscortState(SMART_ESCORT_RETURNING); ReturnToLastOOCPos(); - } else if (mFollowGuid){ + } + else if (mFollowGuid) + { if (Unit* target = me->GetUnit(*me, mFollowGuid)) me->GetMotionMaster()->MoveFollow(target, mFollowDist, mFollowAngle); - } else { - me->GetMotionMaster()->MoveTargetedHome(); } + else + me->GetMotionMaster()->MoveTargetedHome(); Reset(); } @@ -705,12 +707,24 @@ void SmartAI::SetRun(bool run) me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); else me->AddUnitMovementFlag(MOVEMENTFLAG_WALKING); + me->SendMovementFlagUpdate(); mRun = run; } void SmartAI::SetFly(bool fly) { + if (fly) + { + me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + me->SetByteFlag(UNIT_FIELD_BYTES_1, 3, 0x01); + } + else + { + me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + me->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, 0x01); + } me->SetFlying(fly); + me->SendMovementFlagUpdate(); } void SmartAI::SetSwim(bool swim) @@ -719,6 +733,7 @@ void SmartAI::SetSwim(bool swim) me->AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING); else me->RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING); + me->SendMovementFlagUpdate(); } void SmartAI::sGossipHello(Player* player) @@ -781,8 +796,8 @@ void SmartAI::SetFollow(Unit* target, float dist, float angle, uint32 credit, ui return; SetRun(mRun); mFollowGuid = target->GetGUID(); - mFollowDist = dist; - mFollowAngle = angle; + mFollowDist = dist ? dist : PET_FOLLOW_DIST; + mFollowAngle = angle ? angle : me->GetFollowAngle(); mFollowArrivedTimer = 1000; mFollowCredit = credit; mFollowArrivedEntry = end; @@ -902,13 +917,13 @@ class SmartTrigger : public AreaTriggerScript { public: - SmartTrigger() - : AreaTriggerScript("SmartTrigger") - { - } + SmartTrigger() : AreaTriggerScript("SmartTrigger") {} bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) { + if (!player->isAlive()) + return false; + sLog->outDebug(LOG_FILTER_DATABASE_AI, "AreaTrigger %u is using SmartTrigger script", trigger->id); SmartScript script; script.OnInitialize(NULL, trigger); diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 54c69080c41..29340660435 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -32,6 +32,7 @@ #include "SmartAI.h" #include "Group.h" #include "Vehicle.h" +#include "ScriptedGossip.h" SmartScript::SmartScript() { @@ -139,6 +140,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ObjectList* targets = GetTargets(e, unit); Creature* talker = me; + Player* targetPlayer = NULL; if (targets) { for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) @@ -148,14 +150,26 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u talker = (*itr)->ToCreature(); break; } + else if (IsPlayer((*itr))) + { + targetPlayer = (*itr)->ToPlayer(); + break; + } } delete targets; } + mTalkerEntry = talker->GetEntry(); mLastTextID = e.action.talk.textGroupID; mTextTimer = e.action.talk.duration; - mTextGUID = IsPlayer(GetLastInvoker()) ? GetLastInvoker()->GetGUID() : 0;//invoker, used for $vars in texts + if (IsPlayer(GetLastInvoker())) // used for $vars in texts and whisper target + mTextGUID = GetLastInvoker()->GetGUID(); + else if (targetPlayer) + mTextGUID = targetPlayer->GetGUID(); + else + mTextGUID = 0; + mUseTextTimer = true; sCreatureTextMgr->SendChat(talker, uint8(e.action.talk.textGroupID), mTextGUID); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_TALK: talker: %s (GuidLow: %u), textGuid: %u", @@ -210,7 +224,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsPlayer(*itr)) + if (IsUnit(*itr)) { (*itr)->SendPlaySound(e.action.sound.sound, e.action.sound.range > 0 ? true : false); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: %s (GuidLow: %u), sound: %u, onlyself: %u", @@ -1323,7 +1337,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (IsCreature(*itr)) (*itr)->ToCreature()->Respawn(); else if (IsGameObject(*itr)) - (*itr)->ToGameObject()->SetRespawnTime(e.action.RespawnTarget.GoRespawnTime); + (*itr)->ToGameObject()->SetRespawnTime(e.action.RespawnTarget.goRespawnTime); } delete targets; @@ -1458,28 +1472,6 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u case SMART_ACTION_CALL_SCRIPT_RESET: OnReset(); break; - case SMART_ACTION_ENTER_VEHICLE: - { - if (!me) - return; - - ObjectList* targets = GetTargets(e, unit); - if (!targets) - return; - - for (ObjectList::iterator itr = targets->begin(); itr != targets->end(); ++itr) - { - if (IsUnit(*itr) && (*itr)->ToUnit()->GetVehicleKit()) - { - me->EnterVehicle((*itr)->ToUnit(), e.action.enterVehicle.seat); - delete targets; - return; - } - } - - delete targets; - break; - } case SMART_ACTION_CALL_TIMED_ACTIONLIST: { if (e.GetTargetType() == SMART_TARGET_NONE) @@ -1781,7 +1773,38 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } case SMART_ACTION_JUMP_TO_POS: { + if (!me) + return; + + me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveJump(e.target.x, e.target.y, e.target.z, (float)e.action.jump.speedxy, (float)e.action.jump.speedz); + // TODO: Resume path when reached jump location + break; + } + case SMART_ACTION_SEND_GOSSIP_MENU: + { + if (!GetBaseObject()) + return; + + sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SEND_GOSSIP_MENU: gossipMenuId %d, gossip_option_id %d", + e.action.sendGossipMenu.gossipMenuId, e.action.sendGossipMenu.gossipOptionId); + + ObjectList* targets = GetTargets(e, unit); + if (!targets) + return; + + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) + if (Player* player = (*itr)->ToPlayer()) + { + if (e.action.sendGossipMenu.gossipMenuId) + player->PrepareGossipMenu(GetBaseObject(), e.action.sendGossipMenu.gossipMenuId, true); + else + player->PlayerTalkClass->ClearMenus(); + + player->SEND_GOSSIP_MENU(e.action.sendGossipMenu.gossipOptionId, GetBaseObject()->GetGUID()); + } + + delete targets; break; } default: @@ -2122,6 +2145,16 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* l->push_back(target); break; } + case SMART_TARGET_CLOSEST_PLAYER: + { + if (me) + { + Player* target = me->SelectNearestPlayer((float)e.target.playerDistance.dist); + if (target) + l->push_back(target); + } + break; + } case SMART_TARGET_OWNER_OR_SUMMONER: { if (me) @@ -2608,6 +2641,19 @@ void SmartScript::UpdateTimer(SmartScriptHolder& e, uint32 const diff) if (e.timer < diff) { + // delay spell cast event if another spell is being casted + if (e.GetActionType() == SMART_ACTION_CAST) + { + if (!(e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS)) + { + if (me && me->HasUnitState(UNIT_STAT_CASTING)) + { + e.timer = 1; + return; + } + } + } + e.active = true;//activate events with cooldown switch (e.GetEventType())//process ONLY timed events { @@ -2877,10 +2923,11 @@ uint32 SmartScript::DoChat(int8 id, uint64 whisperGuid) Unit* SmartScript::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) { - if (!me) return NULL; - CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); + if (!me) + return NULL; + + CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Unit* unit = NULL; @@ -2896,10 +2943,11 @@ Unit* SmartScript::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) void SmartScript::DoFindFriendlyCC(std::list<Creature*>& _list, float range) { - if (!me) return; - CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); + if (!me) + return; + + CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::FriendlyCCedInRange u_check(me, range); @@ -2907,15 +2955,16 @@ void SmartScript::DoFindFriendlyCC(std::list<Creature*>& _list, float range) TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange>, GridTypeMapContainer > grid_creature_searcher(searcher); - cell.Visit(p, grid_creature_searcher, *me->GetMap()); + cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range); } void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float range, uint32 spellid) { - if (!me) return; - CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); + if (!me) + return; + + CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::FriendlyMissingBuffInRange u_check(me, range, spellid); @@ -2923,7 +2972,7 @@ void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float ra TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher); - cell.Visit(p, grid_creature_searcher, *me->GetMap()); + cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range); } void SmartScript::SetScript9(SmartScriptHolder& e, uint32 entry) diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index aa4eeb602c0..7ebe8ca500f 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -155,33 +155,31 @@ class SmartScript { GameObject* gameObject = NULL; - CellPair p(Trinity::ComputeCellPair(searchObject->GetPositionX(), searchObject->GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; Trinity::GameObjectWithDbGUIDCheck goCheck(*searchObject, guid); Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(searchObject, gameObject, goCheck); TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > objectChecker(checker); - cell.Visit(p, objectChecker, *searchObject->GetMap()); + cell.Visit(p, objectChecker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange()); return gameObject; } Creature* FindCreatureNear(WorldObject* searchObject, uint32 guid) const { - Creature* crea = NULL; - CellPair p(Trinity::ComputeCellPair(searchObject->GetPositionX(), searchObject->GetPositionY())); + Creature* creature = NULL; + CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; Trinity::CreatureWithDbGUIDCheck target_check(searchObject, guid); - Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(searchObject, crea, target_check); + Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(searchObject, creature, target_check); TypeContainerVisitor<Trinity::CreatureSearcher <Trinity::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker); - cell.Visit(p, unit_checker, *searchObject->GetMap()); + cell.Visit(p, unit_checker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange()); - return crea; + return creature; } ObjectListMap* mTargetStorage; @@ -224,7 +222,7 @@ class SmartScript } void DecPhase(int32 p = 1) { mEventPhase -= (mEventPhase < (uint32)p ? (uint32)p - mEventPhase : (uint32)p); } - bool IsInPhase(uint32 p) const { return mEventPhase & p; } + bool IsInPhase(uint32 p) const { return (1 << (mEventPhase - 1)) & p; } void SetPhase(uint32 p = 0) { mEventPhase = p; } SmartAIEventList mEvents; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index fab2a6b7722..fc3db7a0fe6 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -158,7 +158,8 @@ void SmartAIMgr::LoadSmartAIFromDB() sLog->outErrorDb("SmartAIMgr::LoadSmartAIFromDB: not yet implemented source_type %u", (uint32)source_type); continue; } - }else + } + else { if (!sObjectMgr->GetCreatureData(uint32(abs(temp.entryOrGuid)))) { @@ -166,6 +167,7 @@ void SmartAIMgr::LoadSmartAIFromDB() continue; } } + temp.source_type = source_type; temp.event_id = fields[2].GetUInt16(); temp.link = fields[3].GetUInt16(); @@ -224,41 +226,50 @@ void SmartAIMgr::LoadSmartAIFromDB() bool SmartAIMgr::IsTargetValid(SmartScriptHolder const& e) { if (e.GetActionType() == SMART_ACTION_INSTALL_AI_TEMPLATE) - return true; //AI template has special handling + return true; // AI template has special handling switch (e.GetTargetType()) { case SMART_TARGET_CREATURE_DISTANCE: case SMART_TARGET_CREATURE_RANGE: + { + if (e.target.unitDistance.creature && !sObjectMgr->GetCreatureTemplate(e.target.unitDistance.creature)) { - if (e.target.unitDistance.creature && !sObjectMgr->GetCreatureTemplate(e.target.unitDistance.creature)) - { - sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Creature entry %u as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.target.unitDistance.creature); - return false; - } - break; + sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Creature entry %u as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.target.unitDistance.creature); + return false; } + break; + } case SMART_TARGET_GAMEOBJECT_DISTANCE: case SMART_TARGET_GAMEOBJECT_RANGE: + { + if (e.target.goDistance.entry && !sObjectMgr->GetGameObjectTemplate(e.target.goDistance.entry)) { - if (e.target.goDistance.entry && !sObjectMgr->GetGameObjectTemplate(e.target.goDistance.entry)) - { - sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent GameObject entry %u as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.target.goDistance.entry); - return false; - } - break; + sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent GameObject entry %u as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.target.goDistance.entry); + return false; } + break; + } case SMART_TARGET_CREATURE_GUID: - { - if (e.target.unitGUID.entry && !IsCreatureValid(e, e.target.unitGUID.entry)) return false; - break; - } + { + if (e.target.unitGUID.entry && !IsCreatureValid(e, e.target.unitGUID.entry)) return false; + break; + } case SMART_TARGET_GAMEOBJECT_GUID: + { + if (e.target.goGUID.entry && !IsGameObjectValid(e, e.target.goGUID.entry)) return false; + break; + } + case SMART_TARGET_PLAYER_DISTANCE: + case SMART_TARGET_CLOSEST_PLAYER: + { + if (e.target.playerDistance.dist == 0) { - if (e.target.goGUID.entry && !IsGameObjectValid(e, e.target.goGUID.entry)) return false; - break; + sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u has maxDist 0 as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType()); + return false; } + break; + } case SMART_TARGET_PLAYER_RANGE: - case SMART_TARGET_PLAYER_DISTANCE: case SMART_TARGET_SELF: case SMART_TARGET_VICTIM: case SMART_TARGET_HOSTILE_SECOND_AGGRO: @@ -268,12 +279,11 @@ bool SmartAIMgr::IsTargetValid(SmartScriptHolder const& e) case SMART_TARGET_ACTION_INVOKER: case SMART_TARGET_POSITION: case SMART_TARGET_NONE: - case SMART_TARGET_CLOSEST_CREATURE: - case SMART_TARGET_CLOSEST_GAMEOBJECT: - case SMART_TARGET_CLOSEST_PLAYER: case SMART_TARGET_ACTION_INVOKER_VEHICLE: case SMART_TARGET_OWNER_OR_SUMMONER: case SMART_TARGET_THREAT_LIST: + case SMART_TARGET_CLOSEST_GAMEOBJECT: + case SMART_TARGET_CLOSEST_CREATURE: break; default: sLog->outErrorDb("SmartAIMgr: Not handled target_type(%u), Entry %d SourceType %u Event %u Action %u, skipped.", e.GetTargetType(), e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType()); @@ -394,7 +404,8 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) break; case SMART_EVENT_ACCEPTED_QUEST: case SMART_EVENT_REWARD_QUEST: - if (!IsQuestValid(e, e.event.quest.quest)) return false; + if (e.event.quest.quest && !IsQuestValid(e, e.event.quest.quest)) + return false; break; case SMART_EVENT_RECEIVE_EMOTE: { @@ -526,7 +537,8 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) } break; case SMART_ACTION_SOUND: - if (!IsSoundValid(e, e.action.sound.sound)) return false; + if (!IsSoundValid(e, e.action.sound.sound)) + return false; if (e.action.sound.range > TEXT_RANGE_WORLD) { sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses invalid Text Range %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.sound.range); @@ -539,7 +551,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) break; case SMART_ACTION_FAIL_QUEST: case SMART_ACTION_ADD_QUEST: - if (e.action.quest.quest && !IsQuestValid(e, e.action.quest.quest)) return false; + if (!e.action.quest.quest || !IsQuestValid(e, e.action.quest.quest)) return false; break; case SMART_ACTION_ACTIVATE_TAXI: { @@ -755,7 +767,6 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) case SMART_ACTION_RESET_SCRIPT_BASE_OBJECT: case SMART_ACTION_ACTIVATE_GOBJECT: case SMART_ACTION_CALL_SCRIPT_RESET: - case SMART_ACTION_ENTER_VEHICLE: case SMART_ACTION_NONE: case SMART_ACTION_CALL_TIMED_ACTIONLIST: case SMART_ACTION_SET_NPC_FLAG: @@ -775,6 +786,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) case SMART_ACTION_ADD_DYNAMIC_FLAG: case SMART_ACTION_REMOVE_DYNAMIC_FLAG: case SMART_ACTION_JUMP_TO_POS: + case SMART_ACTION_SEND_GOSSIP_MENU: break; default: sLog->outErrorDb("SmartAIMgr: Not handled action_type(%u), event_type(%u), Entry %d SourceType %u Event %u, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id); diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 327d03d31ff..ba986ae310d 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -387,7 +387,7 @@ enum SMART_ACTION SMART_ACTION_CALL_GROUPEVENTHAPPENS = 26, // QuestID SMART_ACTION_CALL_CASTEDCREATUREORGO = 27, // CreatureId, SpellId SMART_ACTION_REMOVEAURASFROMSPELL = 28, // Spellid - SMART_ACTION_FOLLOW = 29, // Distance, Angle, EndCreatureEntry, credit, creditType (0monsterkill, 1event) + SMART_ACTION_FOLLOW = 29, // Distance (0 = default), Angle (0 = default), EndCreatureEntry, credit, creditType (0monsterkill, 1event) SMART_ACTION_RANDOM_PHASE = 30, // PhaseId1, PhaseId2, PhaseId3... SMART_ACTION_RANDOM_PHASE_RANGE = 31, // PhaseMin, PhaseMax SMART_ACTION_RESET_GOBJECT = 32, // @@ -439,7 +439,7 @@ enum SMART_ACTION SMART_ACTION_OVERRIDE_SCRIPT_BASE_OBJECT = 76, // WARNING: CAN CRASH CORE, do not use if you dont know what you are doing SMART_ACTION_RESET_SCRIPT_BASE_OBJECT = 77, // none SMART_ACTION_CALL_SCRIPT_RESET = 78, // none - SMART_ACTION_ENTER_VEHICLE = 79, // seatID + // Unused = 79, SMART_ACTION_CALL_TIMED_ACTIONLIST = 80, // ID (overwrites already running actionlist), stop after combat?(0/1), timer update type(0-OOC, 1-IC, 2-ALWAYS) SMART_ACTION_SET_NPC_FLAG = 81, // Flags SMART_ACTION_ADD_NPC_FLAG = 82, // Flags @@ -450,20 +450,17 @@ enum SMART_ACTION SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST = 87, // script9 ids 1-9 SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST = 88, // script9 id min, max SMART_ACTION_RANDOM_MOVE = 89, // maxDist - SMART_ACTION_SET_UNIT_FIELD_BYTES_1 = 90, // bytes, target SMART_ACTION_REMOVE_UNIT_FIELD_BYTES_1 = 91, // bytes, target - SMART_ACTION_INTERRUPT_SPELL = 92, - SMART_ACTION_SEND_GO_CUSTOM_ANIM = 93, // anim id - SMART_ACTION_SET_DYNAMIC_FLAG = 94, // Flags SMART_ACTION_ADD_DYNAMIC_FLAG = 95, // Flags SMART_ACTION_REMOVE_DYNAMIC_FLAG = 96, // Flags SMART_ACTION_JUMP_TO_POS = 97, // speedXY, speedZ, targetX, targetY, targetZ + SMART_ACTION_SEND_GOSSIP_MENU = 98, // menuId, optionId - SMART_ACTION_END = 98, + SMART_ACTION_END = 99, }; struct SmartAction @@ -859,8 +856,14 @@ struct SmartAction struct { - uint32 GoRespawnTime; + uint32 goRespawnTime; } RespawnTarget; + + struct + { + uint32 gossipMenuId; + uint32 gossipOptionId; + } sendGossipMenu; struct { @@ -906,9 +909,9 @@ enum SMARTAI_TARGETS SMART_TARGET_INVOKER_PARTY = 16, // invoker's party members SMART_TARGET_PLAYER_RANGE = 17, // min, max SMART_TARGET_PLAYER_DISTANCE = 18, // maxDist - SMART_TARGET_CLOSEST_CREATURE = 19, // CreatureEntry(0any) - SMART_TARGET_CLOSEST_GAMEOBJECT = 20, // entry(0any) - SMART_TARGET_CLOSEST_PLAYER = 21, // none + SMART_TARGET_CLOSEST_CREATURE = 19, // CreatureEntry(0any), maxDist, dead? + SMART_TARGET_CLOSEST_GAMEOBJECT = 20, // entry(0any), maxDist + SMART_TARGET_CLOSEST_PLAYER = 21, // maxDist SMART_TARGET_ACTION_INVOKER_VEHICLE = 22, // Unit's vehicle who caused this Event to occur SMART_TARGET_OWNER_OR_SUMMONER = 23, // Unit's owner or summoner SMART_TARGET_THREAT_LIST = 24, // All units on creature's threat list @@ -1124,7 +1127,7 @@ const uint32 SmartAIEventMask[SMART_EVENT_END][2] = {SMART_EVENT_JUST_CREATED, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT }, {SMART_EVENT_GOSSIP_HELLO, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT }, {SMART_EVENT_FOLLOW_COMPLETED, SMART_SCRIPT_TYPE_MASK_CREATURE }, - {SMART_EVENT_DUMMY_EFFECT, SMART_SCRIPT_TYPE_MASK_CREATURE }, + {SMART_EVENT_DUMMY_EFFECT, SMART_SCRIPT_TYPE_MASK_SPELL }, {SMART_EVENT_IS_BEHIND_TARGET, SMART_SCRIPT_TYPE_MASK_CREATURE } }; diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index fca4df12587..8967446f199 100755 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -46,8 +46,8 @@ namespace Trinity class AchievementChatBuilder { public: - AchievementChatBuilder(Player const& pl, ChatMsg msgtype, int32 textId, uint32 ach_id) - : i_player(pl), i_msgtype(msgtype), i_textId(textId), i_achievementId(ach_id) {} + AchievementChatBuilder(Player const& player, ChatMsg msgtype, int32 textId, uint32 ach_id) + : i_player(player), i_msgtype(msgtype), i_textId(textId), i_achievementId(ach_id) {} void operator()(WorldPacket& data, LocaleConstant loc_idx) { char const* text = sObjectMgr->GetTrinityString(i_textId, loc_idx); @@ -666,10 +666,9 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) // if player is in world he can tell his friends about new achievement else if (GetPlayer()->IsInWorld()) { - CellPair p = Trinity::ComputeCellPair(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()); + CellCoord p = Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::AchievementChatBuilder say_builder(*GetPlayer(), CHAT_MSG_ACHIEVEMENT, LANG_ACHIEVEMENT_EARNED, achievement->ID); diff --git a/src/server/game/Achievements/AchievementMgr.h b/src/server/game/Achievements/AchievementMgr.h index df5631c5bc6..7f66565622f 100755 --- a/src/server/game/Achievements/AchievementMgr.h +++ b/src/server/game/Achievements/AchievementMgr.h @@ -244,7 +244,7 @@ class WorldPacket; class AchievementMgr { public: - AchievementMgr(Player* pl); + AchievementMgr(Player* player); ~AchievementMgr(); void Reset(); diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index 45f41eebd26..b9fb5a13980 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -391,8 +391,8 @@ void ArenaTeam::Roster(WorldSession* session) data << uint32(itr->PersonalRating); // personal rating if (unk308) { - data << float(0.0); // 308 unk - data << float(0.0); // 308 unk + data << float(0.0f); // 308 unk + data << float(0.0f); // 308 unk } } @@ -433,8 +433,8 @@ void ArenaTeam::NotifyStatsChanged() // This is called after a rated match ended // Updates arena team stats for every member of the team (not only the ones who participated!) for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr) - if (Player* plr = ObjectAccessor::FindPlayer(itr->Guid)) - SendStats(plr->GetSession()); + if (Player* player = ObjectAccessor::FindPlayer(itr->Guid)) + SendStats(player->GetSession()); } void ArenaTeam::Inspect(WorldSession* session, uint64 guid) @@ -455,17 +455,17 @@ void ArenaTeam::Inspect(WorldSession* session, uint64 guid) session->SendPacket(&data); } -void ArenaTeamMember::ModifyPersonalRating(Player* plr, int32 mod, uint32 slot) +void ArenaTeamMember::ModifyPersonalRating(Player* player, int32 mod, uint32 slot) { if (int32(PersonalRating) + mod < 0) PersonalRating = 0; else PersonalRating += mod; - if (plr) + if (player) { - plr->SetArenaTeamInfoField(slot, ARENA_TEAM_PERSONAL_RATING, PersonalRating); - plr->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING, PersonalRating, slot); + player->SetArenaTeamInfoField(slot, ARENA_TEAM_PERSONAL_RATING, PersonalRating); + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING, PersonalRating, slot); } } @@ -716,16 +716,16 @@ int32 ArenaTeam::LostAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int3 return mod; } -void ArenaTeam::MemberLost(Player* plr, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange) +void ArenaTeam::MemberLost(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange) { // Called for each participant of a match after losing for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr) { - if (itr->Guid == plr->GetGUID()) + if (itr->Guid == player->GetGUID()) { // Update personal rating int32 mod = GetRatingMod(itr->PersonalRating, againstMatchmakerRating, false); - itr->ModifyPersonalRating(plr, mod, GetSlot()); + itr->ModifyPersonalRating(player, mod, GetSlot()); // Update matchmaker rating itr->ModifyMatchmakerRating(MatchmakerRatingChange, GetSlot()); @@ -735,8 +735,8 @@ void ArenaTeam::MemberLost(Player* plr, uint32 againstMatchmakerRating, int32 Ma itr->SeasonGames +=1; // update the unit fields - plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK, itr->WeekGames); - plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON, itr->SeasonGames); + player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK, itr->WeekGames); + player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON, itr->SeasonGames); return; } } @@ -764,16 +764,16 @@ void ArenaTeam::OfflineMemberLost(uint64 guid, uint32 againstMatchmakerRating, i } } -void ArenaTeam::MemberWon(Player* plr, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange) +void ArenaTeam::MemberWon(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange) { // called for each participant after winning a match for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr) { - if (itr->Guid == plr->GetGUID()) + if (itr->Guid == player->GetGUID()) { // update personal rating int32 mod = GetRatingMod(itr->PersonalRating, againstMatchmakerRating, true); - itr->ModifyPersonalRating(plr, mod, GetSlot()); + itr->ModifyPersonalRating(player, mod, GetSlot()); // update matchmaker rating itr->ModifyMatchmakerRating(MatchmakerRatingChange, GetSlot()); @@ -784,8 +784,8 @@ void ArenaTeam::MemberWon(Player* plr, uint32 againstMatchmakerRating, int32 Mat itr->SeasonWins += 1; itr->WeekWins += 1; // update unit fields - plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK, itr->WeekGames); - plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON, itr->SeasonGames); + player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK, itr->WeekGames); + player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON, itr->SeasonGames); return; } } @@ -800,7 +800,7 @@ void ArenaTeam::UpdateArenaPointsHelper(std::map<uint32, uint32>& playerPoints) return; // To get points, a player has to participate in at least 30% of the matches - uint32 requiredGames = (uint32) ceil(Stats.WeekGames * 0.3); + uint32 requiredGames = (uint32)ceil(Stats.WeekGames * 0.3f); for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr) { diff --git a/src/server/game/Battlegrounds/ArenaTeam.h b/src/server/game/Battlegrounds/ArenaTeam.h index 4f013f72e5c..dce8c5776b7 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.h +++ b/src/server/game/Battlegrounds/ArenaTeam.h @@ -97,7 +97,7 @@ struct ArenaTeamMember uint16 PersonalRating; uint16 MatchMakerRating; - void ModifyPersonalRating(Player* plr, int32 mod, uint32 slot); + void ModifyPersonalRating(Player* player, int32 mod, uint32 slot); void ModifyMatchmakerRating(int32 mod, uint32 slot); }; @@ -172,9 +172,9 @@ class ArenaTeam int32 GetRatingMod(uint32 ownRating, uint32 opponentRating, bool won); float GetChanceAgainst(uint32 ownRating, uint32 opponentRating); int32 WonAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32& rating_change); - void MemberWon(Player* plr, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange); + void MemberWon(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange); int32 LostAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32& rating_change); - void MemberLost(Player* plr, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange = -12); + void MemberLost(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange = -12); void OfflineMemberLost(uint64 guid, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange = -12); void UpdateArenaPointsHelper(std::map<uint32, uint32> & PlayerPoints); diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index ce555b3c503..b2842025127 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -75,7 +75,7 @@ namespace Trinity data << uint64(target_guid); data << uint32(strlen(text) + 1); data << text; - data << uint8 (_source ? _source->chatTag() : uint8(0)); + data << uint8 (_source ? _source->GetChatTag() : 0); } ChatMsg _msgtype; @@ -108,7 +108,7 @@ namespace Trinity data << uint64(target_guid); data << uint32(strlen(str) + 1); data << str; - data << uint8 (_source ? _source->chatTag() : uint8(0)); + data << uint8 (_source ? _source->GetChatTag() : uint8(0)); } private: @@ -124,8 +124,8 @@ template<class Do> void Battleground::BroadcastWorker(Do& _do) { for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) - if (Player* plr = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER))) - _do(plr); + if (Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER))) + _do(player); } Battleground::Battleground() @@ -333,13 +333,13 @@ inline void Battleground::_ProcessRessurect(uint32 diff) Creature* sh = NULL; for (std::vector<uint64>::const_iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2) { - Player* plr = ObjectAccessor::FindPlayer(*itr2); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(*itr2); + if (!player) continue; - if (!sh && plr->IsInWorld()) + if (!sh && player->IsInWorld()) { - sh = plr->GetMap()->GetCreature(itr->first); + sh = player->GetMap()->GetCreature(itr->first); // only for visual effect if (sh) // Spirit Heal, effect 117 @@ -347,7 +347,7 @@ inline void Battleground::_ProcessRessurect(uint32 diff) } // Resurrection visual - plr->CastSpell(plr, SPELL_RESURRECTION_VISUAL, true); + player->CastSpell(player, SPELL_RESURRECTION_VISUAL, true); m_ResurrectQueue.push_back(*itr2); } (itr->second).clear(); @@ -364,12 +364,12 @@ inline void Battleground::_ProcessRessurect(uint32 diff) { for (std::vector<uint64>::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr) { - Player* plr = ObjectAccessor::FindPlayer(*itr); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(*itr); + if (!player) continue; - plr->ResurrectPlayer(1.0f); - plr->CastSpell(plr, 6962, true); - plr->CastSpell(plr, SPELL_SPIRIT_HEAL_MANA, true); + player->ResurrectPlayer(1.0f); + player->CastSpell(player, 6962, true); + player->CastSpell(player, SPELL_SPIRIT_HEAL_MANA, true); sObjectAccessor->ConvertCorpseForPlayer(*itr); } m_ResurrectQueue.clear(); @@ -429,15 +429,15 @@ inline void Battleground::_ProcessJoin(uint32 diff) { m_ResetStatTimer = 0; for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) - if (Player* plr = ObjectAccessor::FindPlayer(itr->first)) - plr->ResetAllPowers(); + if (Player* player = ObjectAccessor::FindPlayer(itr->first)) + player->ResetAllPowers(); } if (!(m_Events & BG_STARTING_EVENT_1)) { m_Events |= BG_STARTING_EVENT_1; - if(!FindBgMap()) + if (!FindBgMap()) { sLog->outError("Battleground::_ProcessJoin: map (map id: %u, instance id: %u) is not created!", m_MapId, m_InstanceID); EndNow(); @@ -484,19 +484,19 @@ inline void Battleground::_ProcessJoin(uint32 diff) { // TODO : add arena sound PlaySoundToAll(SOUND_ARENA_START); for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) - if (Player* plr = ObjectAccessor::FindPlayer(itr->first)) + if (Player* player = ObjectAccessor::FindPlayer(itr->first)) { // BG Status packet WorldPacket status; BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(m_TypeID, GetArenaType()); - uint32 queueSlot = plr->GetBattlegroundQueueIndex(bgQueueTypeId); + uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId); sBattlegroundMgr->BuildBattlegroundStatusPacket(&status, this, queueSlot, STATUS_IN_PROGRESS, 0, GetStartTime(), GetArenaType()); - plr->GetSession()->SendPacket(&status); + player->GetSession()->SendPacket(&status); - plr->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION); - plr->ResetAllPowers(); + player->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION); + player->ResetAllPowers(); // remove auras with duration lower than 30s - Unit::AuraApplicationMap & auraMap = plr->GetAppliedAuras(); + Unit::AuraApplicationMap & auraMap = player->GetAppliedAuras(); for (Unit::AuraApplicationMap::iterator iter = auraMap.begin(); iter != auraMap.end();) { AuraApplication * aurApp = iter->second; @@ -506,7 +506,7 @@ inline void Battleground::_ProcessJoin(uint32 diff) && aurApp->IsPositive() && (!(aura->GetSpellInfo()->Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)) && (!aura->HasEffectType(SPELL_AURA_MOD_INVISIBILITY))) - plr->RemoveAura(iter); + player->RemoveAura(iter); else ++iter; } @@ -519,10 +519,10 @@ inline void Battleground::_ProcessJoin(uint32 diff) PlaySoundToAll(SOUND_BG_START); for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) - if (Player* plr = ObjectAccessor::FindPlayer(itr->first)) + if (Player* player = ObjectAccessor::FindPlayer(itr->first)) { - plr->RemoveAurasDueToSpell(SPELL_PREPARATION); - plr->ResetAllPowers(); + player->RemoveAurasDueToSpell(SPELL_PREPARATION); + player->ResetAllPowers(); } // Announce BG starting if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE)) @@ -788,28 +788,28 @@ void Battleground::EndBattleground(uint32 winner) continue; } - Player* plr = _GetPlayer(itr, "EndBattleground"); - if (!plr) + Player* player = _GetPlayer(itr, "EndBattleground"); + if (!player) continue; // should remove spirit of redemption - if (plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) - plr->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT); + if (player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) + player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT); - if (!plr->isAlive()) + if (!player->isAlive()) { - plr->ResurrectPlayer(1.0f); - plr->SpawnCorpseBones(); + player->ResurrectPlayer(1.0f); + player->SpawnCorpseBones(); } else { //needed cause else in av some creatures will kill the players at the end - plr->CombatStop(); - plr->getHostileRefManager().deleteReferences(); + player->CombatStop(); + player->getHostileRefManager().deleteReferences(); } //this line is obsolete - team is set ALWAYS - //if (!team) team = plr->GetTeam(); + //if (!team) team = player->GetTeam(); // per player calculation if (isArena() && isRated() && winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team) @@ -817,57 +817,57 @@ void Battleground::EndBattleground(uint32 winner) if (team == winner) { // update achievement BEFORE personal rating update - ArenaTeamMember* member = winner_arena_team->GetMember(plr->GetGUID()); + ArenaTeamMember* member = winner_arena_team->GetMember(player->GetGUID()); if (member) - plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, member->PersonalRating); + player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, member->PersonalRating); - winner_arena_team->MemberWon(plr, loser_matchmaker_rating, winner_matchmaker_change); + winner_arena_team->MemberWon(player, loser_matchmaker_rating, winner_matchmaker_change); } else { - loser_arena_team->MemberLost(plr, winner_matchmaker_rating, loser_matchmaker_change); + loser_arena_team->MemberLost(player, winner_matchmaker_rating, loser_matchmaker_change); // Arena lost => reset the win_rated_arena having the "no_lose" condition - plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE); + player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE); } } - uint32 winner_kills = plr->GetRandomWinner() ? BG_REWARD_WINNER_HONOR_LAST : BG_REWARD_WINNER_HONOR_FIRST; - uint32 loser_kills = plr->GetRandomWinner() ? BG_REWARD_LOSER_HONOR_LAST : BG_REWARD_LOSER_HONOR_FIRST; - uint32 winner_arena = plr->GetRandomWinner() ? BG_REWARD_WINNER_ARENA_LAST : BG_REWARD_WINNER_ARENA_FIRST; + uint32 winner_kills = player->GetRandomWinner() ? BG_REWARD_WINNER_HONOR_LAST : BG_REWARD_WINNER_HONOR_FIRST; + uint32 loser_kills = player->GetRandomWinner() ? BG_REWARD_LOSER_HONOR_LAST : BG_REWARD_LOSER_HONOR_FIRST; + uint32 winner_arena = player->GetRandomWinner() ? BG_REWARD_WINNER_ARENA_LAST : BG_REWARD_WINNER_ARENA_FIRST; // Reward winner team if (team == winner) { if (IsRandom() || BattlegroundMgr::IsBGWeekend(GetTypeID())) { - UpdatePlayerScore(plr, SCORE_BONUS_HONOR, GetBonusHonorFromKill(winner_kills)); + UpdatePlayerScore(player, SCORE_BONUS_HONOR, GetBonusHonorFromKill(winner_kills)); if (CanAwardArenaPoints()) - plr->ModifyArenaPoints(winner_arena); - if (!plr->GetRandomWinner()) - plr->SetRandomWinner(true); + player->ModifyArenaPoints(winner_arena); + if (!player->GetRandomWinner()) + player->SetRandomWinner(true); } - plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, 1); + player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, 1); } else { if (IsRandom() || BattlegroundMgr::IsBGWeekend(GetTypeID())) - UpdatePlayerScore(plr, SCORE_BONUS_HONOR, GetBonusHonorFromKill(loser_kills)); + UpdatePlayerScore(player, SCORE_BONUS_HONOR, GetBonusHonorFromKill(loser_kills)); } - plr->ResetAllPowers(); - plr->CombatStopWithPets(true); + player->ResetAllPowers(); + player->CombatStopWithPets(true); - BlockMovement(plr); + BlockMovement(player); sBattlegroundMgr->BuildPvpLogDataPacket(&data, this); - plr->GetSession()->SendPacket(&data); + player->GetSession()->SendPacket(&data); BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType()); - sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, plr->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType()); - plr->GetSession()->SendPacket(&data); - plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, 1); + sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType()); + player->GetSession()->SendPacket(&data); + player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, 1); } if (isArena() && isRated() && winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team) @@ -908,9 +908,9 @@ uint32 Battleground::GetBattlemasterEntry() const } } -void Battleground::BlockMovement(Player* plr) +void Battleground::BlockMovement(Player* player) { - plr->SetClientControl(plr, 0); // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave() + player->SetClientControl(player, 0); // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave() } void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket) @@ -936,32 +936,32 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac RemovePlayerFromResurrectQueue(guid); - Player* plr = ObjectAccessor::FindPlayer(guid); + Player* player = ObjectAccessor::FindPlayer(guid); // should remove spirit of redemption - if (plr) + if (player) { - if (plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) - plr->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT); + if (player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) + player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT); - if (!plr->isAlive()) // resurrect on exit + if (!player->isAlive()) // resurrect on exit { - plr->ResurrectPlayer(1.0f); - plr->SpawnCorpseBones(); + player->ResurrectPlayer(1.0f); + player->SpawnCorpseBones(); } } - RemovePlayer(plr, guid, team); // BG subclass specific code + RemovePlayer(player, guid, team); // BG subclass specific code if (participant) // if the player was a match participant, remove auras, calc rating, update queue { BattlegroundTypeId bgTypeId = GetTypeID(); BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType()); - if (plr) + if (player) { - plr->ClearAfkReports(); + player->ClearAfkReports(); - if (!team) team = plr->GetTeam(); + if (!team) team = player->GetTeam(); // if arena, remove the specific arena auras if (isArena()) @@ -969,8 +969,8 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac bgTypeId=BATTLEGROUND_AA; // set the bg type to all arenas (it will be used for queue refreshing) // unsummon current and summon old pet if there was one and there isn't a current pet - plr->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT); - plr->ResummonPetTemporaryUnSummonedIfAny(); + player->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT); + player->ResummonPetTemporaryUnSummonedIfAny(); if (isRated() && GetStatus() == STATUS_IN_PROGRESS) { @@ -978,18 +978,18 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac ArenaTeam* winner_arena_team = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(team))); ArenaTeam* loser_arena_team = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(team)); if (winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team) - loser_arena_team->MemberLost(plr, GetArenaMatchmakerRating(GetOtherTeam(team))); + loser_arena_team->MemberLost(player, GetArenaMatchmakerRating(GetOtherTeam(team))); } } if (SendPacket) { WorldPacket data; - sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, plr->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_NONE, 0, 0, 0); - plr->GetSession()->SendPacket(&data); + sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_NONE, 0, 0, 0); + player->GetSession()->SendPacket(&data); } // this call is important, because player, when joins to battleground, this method is not called, so it must be called when leaving bg - plr->RemoveBattlegroundQueueId(bgQueueTypeId); + player->RemoveBattlegroundQueueId(bgQueueTypeId); } else // removing offline participant @@ -1023,20 +1023,20 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac // Let others know WorldPacket data; sBattlegroundMgr->BuildPlayerLeftBattlegroundPacket(&data, guid); - SendPacketToTeam(team, &data, plr, false); + SendPacketToTeam(team, &data, player, false); } - if (plr) + if (player) { // Do next only if found in battleground - plr->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG. + player->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG. // reset destination bg team - plr->SetBGTeam(0); + player->SetBGTeam(0); if (Transport) - plr->TeleportToBGEntryPoint(); + player->TeleportToBGEntryPoint(); - sLog->outDetail("BATTLEGROUND: Removed player %s from Battleground.", plr->GetName()); + sLog->outDetail("BATTLEGROUND: Removed player %s from Battleground.", player->GetName()); } //battleground object will be deleted next Battleground::Update() call @@ -1087,16 +1087,16 @@ void Battleground::StartBattleground() sLog->outArena("Arena match type: %u for Team1Id: %u - Team2Id: %u started.", m_ArenaType, m_ArenaTeamIds[BG_TEAM_ALLIANCE], m_ArenaTeamIds[BG_TEAM_HORDE]); } -void Battleground::AddPlayer(Player* plr) +void Battleground::AddPlayer(Player* player) { // remove afk from player - if (plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK)) - plr->ToggleAFK(); + if (player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK)) + player->ToggleAFK(); // score struct must be created in inherited class - uint64 guid = plr->GetGUID(); - uint32 team = plr->GetBGTeam(); + uint64 guid = player->GetGUID(); + uint32 team = player->GetBGTeam(); BattlegroundPlayer bp; bp.OfflineRemoveTime = 0; @@ -1108,74 +1108,74 @@ void Battleground::AddPlayer(Player* plr) UpdatePlayersCountByTeam(team, false); // +1 player WorldPacket data; - sBattlegroundMgr->BuildPlayerJoinedBattlegroundPacket(&data, plr); - SendPacketToTeam(team, &data, plr, false); + sBattlegroundMgr->BuildPlayerJoinedBattlegroundPacket(&data, player); + SendPacketToTeam(team, &data, player, false); // BG Status packet WorldPacket status; BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(m_TypeID, GetArenaType()); - uint32 queueSlot = plr->GetBattlegroundQueueIndex(bgQueueTypeId); + uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId); sBattlegroundMgr->BuildBattlegroundStatusPacket(&status, this, queueSlot, STATUS_IN_PROGRESS, 0, GetStartTime(), GetArenaType(), isArena() ? 0 : 1); - plr->GetSession()->SendPacket(&status); + player->GetSession()->SendPacket(&status); - plr->RemoveAurasByType(SPELL_AURA_MOUNTED); + player->RemoveAurasByType(SPELL_AURA_MOUNTED); // add arena specific auras if (isArena()) { - plr->RemoveArenaEnchantments(TEMP_ENCHANTMENT_SLOT); + player->RemoveArenaEnchantments(TEMP_ENCHANTMENT_SLOT); if (team == ALLIANCE) // gold { - if (plr->GetTeam() == HORDE) - plr->CastSpell(plr, SPELL_HORDE_GOLD_FLAG, true); + if (player->GetTeam() == HORDE) + player->CastSpell(player, SPELL_HORDE_GOLD_FLAG, true); else - plr->CastSpell(plr, SPELL_ALLIANCE_GOLD_FLAG, true); + player->CastSpell(player, SPELL_ALLIANCE_GOLD_FLAG, true); } else // green { - if (plr->GetTeam() == HORDE) - plr->CastSpell(plr, SPELL_HORDE_GREEN_FLAG, true); + if (player->GetTeam() == HORDE) + player->CastSpell(player, SPELL_HORDE_GREEN_FLAG, true); else - plr->CastSpell(plr, SPELL_ALLIANCE_GREEN_FLAG, true); + player->CastSpell(player, SPELL_ALLIANCE_GREEN_FLAG, true); } - plr->DestroyConjuredItems(true); - plr->UnsummonPetTemporaryIfAny(); + player->DestroyConjuredItems(true); + player->UnsummonPetTemporaryIfAny(); if (GetStatus() == STATUS_WAIT_JOIN) // not started yet { - plr->CastSpell(plr, SPELL_ARENA_PREPARATION, true); - plr->ResetAllPowers(); + player->CastSpell(player, SPELL_ARENA_PREPARATION, true); + player->ResetAllPowers(); } WorldPacket teammate; teammate.Initialize(SMSG_ARENA_OPPONENT_UPDATE, 8); - teammate << uint64(plr->GetGUID()); - SendPacketToTeam(team, &teammate, plr, false); + teammate << uint64(player->GetGUID()); + SendPacketToTeam(team, &teammate, player, false); } else { if (GetStatus() == STATUS_WAIT_JOIN) // not started yet - plr->CastSpell(plr, SPELL_PREPARATION, true); // reduces all mana cost of spells. + player->CastSpell(player, SPELL_PREPARATION, true); // reduces all mana cost of spells. } - plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); - plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); - plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); - plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); - plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); - plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); - plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); - plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); - plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); - plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); - plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); + player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); + player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); + player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); + player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); + player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); + player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); + player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); + player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); + player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); + player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); + player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true); // setup BG group membership - PlayerAddedToBGCheckIfBGIsRunning(plr); - AddOrSetPlayerToCorrectBgGroup(plr, team); + PlayerAddedToBGCheckIfBGIsRunning(player); + AddOrSetPlayerToCorrectBgGroup(player, team); // Log - sLog->outDetail("BATTLEGROUND: Player %s joined the battle.", plr->GetName()); + sLog->outDetail("BATTLEGROUND: Player %s joined the battle.", player->GetName()); } // this method adds player to his team's bg group, or sets his correct group if player is already in bg group @@ -1385,11 +1385,11 @@ void Battleground::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid { m_ReviveQueue[npc_guid].push_back(player_guid); - Player* plr = ObjectAccessor::FindPlayer(player_guid); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(player_guid); + if (!player) return; - plr->CastSpell(plr, SPELL_WAITING_FOR_RESURRECT, true); + player->CastSpell(player, SPELL_WAITING_FOR_RESURRECT, true); } void Battleground::RemovePlayerFromResurrectQueue(uint64 player_guid) @@ -1401,8 +1401,8 @@ void Battleground::RemovePlayerFromResurrectQueue(uint64 player_guid) if (*itr2 == player_guid) { (itr->second).erase(itr2); - if (Player* plr = ObjectAccessor::FindPlayer(player_guid)) - plr->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT); + if (Player* player = ObjectAccessor::FindPlayer(player_guid)) + player->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT); return; } } @@ -1454,7 +1454,7 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float data.go_state = 1; */ // Add to world, so it can be later looked up from HashMapHolder - map->Add(go); + map->AddToMap(go); m_BgObjects[type] = go->GetGUID(); return true; } @@ -1521,7 +1521,7 @@ void Battleground::SpawnBGObject(uint32 type, uint32 respawntime) // Change state from GO_JUST_DEACTIVATED to GO_READY in case battleground is starting again obj->SetLootState(GO_READY); obj->SetRespawnTime(respawntime); - map->Add(obj); + map->AddToMap(obj); } } @@ -1557,7 +1557,7 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, uint32 teamval, f creature->SetSpeed(MOVE_WALK, cinfo->speed_walk); creature->SetSpeed(MOVE_RUN, cinfo->speed_run); - map->Add(creature); + map->AddToMap(creature); m_BgCreatures[type] = creature->GetGUID(); if (respawntime) @@ -1680,9 +1680,9 @@ void Battleground::SendWarningToAll(int32 entry, ...) data << msg.c_str(); data << (uint8)0; for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) - if (Player* plr = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER))) - if (plr->GetSession()) - plr->GetSession()->SendPacket(&data); + if (Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER))) + if (player->GetSession()) + player->GetSession()->SendPacket(&data); } void Battleground::SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 arg1, int32 arg2) @@ -1759,12 +1759,12 @@ void Battleground::HandleKillPlayer(Player* player, Player* killer) for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { - Player* plr = ObjectAccessor::FindPlayer(itr->first); - if (!plr || plr == killer) + Player* player = ObjectAccessor::FindPlayer(itr->first); + if (!player || player == killer) continue; - if (plr->GetTeam() == killer->GetTeam() && plr->IsAtGroupRewardDistance(player)) - UpdatePlayerScore(plr, SCORE_HONORABLE_KILLS, 1); + if (player->GetTeam() == killer->GetTeam() && player->IsAtGroupRewardDistance(player)) + UpdatePlayerScore(player, SCORE_HONORABLE_KILLS, 1); } } @@ -1799,7 +1799,7 @@ bool Battleground::IsPlayerInBattleground(uint64 guid) const return false; } -void Battleground::PlayerAddedToBGCheckIfBGIsRunning(Player* plr) +void Battleground::PlayerAddedToBGCheckIfBGIsRunning(Player* player) { if (GetStatus() != STATUS_WAIT_LEAVE) return; @@ -1807,13 +1807,13 @@ void Battleground::PlayerAddedToBGCheckIfBGIsRunning(Player* plr) WorldPacket data; BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType()); - BlockMovement(plr); + BlockMovement(player); sBattlegroundMgr->BuildPvpLogDataPacket(&data, this); - plr->GetSession()->SendPacket(&data); + player->GetSession()->SendPacket(&data); - sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, plr->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType()); - plr->GetSession()->SendPacket(&data); + sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType()); + player->GetSession()->SendPacket(&data); } uint32 Battleground::GetAlivePlayersCountByTeam(uint32 Team) const @@ -1823,8 +1823,8 @@ uint32 Battleground::GetAlivePlayersCountByTeam(uint32 Team) const { if (itr->second.Team == Team) { - Player* pl = ObjectAccessor::FindPlayer(itr->first); - if (pl && pl->isAlive() && !pl->HasByteFlag(UNIT_FIELD_BYTES_2, 3, FORM_SPIRITOFREDEMPTION)) + Player* player = ObjectAccessor::FindPlayer(itr->first); + if (player && player->isAlive() && !player->HasByteFlag(UNIT_FIELD_BYTES_2, 3, FORM_SPIRITOFREDEMPTION)) ++count; } } diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index d5921e4bf37..9856312c337 100755 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -329,7 +329,7 @@ class Battleground { } - virtual void DestroyGate(Player* /*pl*/, GameObject* /*go*/) {} + virtual void DestroyGate(Player* /*player*/, GameObject* /*go*/) {} /* achievement req. */ virtual bool IsAllNodesConrolledByTeam(uint32 /*team*/) const { return false; } @@ -463,7 +463,7 @@ class Battleground void UpdateWorldState(uint32 Field, uint32 Value); void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player* Source); void EndBattleground(uint32 winner); - void BlockMovement(Player* plr); + void BlockMovement(Player* player); void SendWarningToAll(int32 entry, ...); void SendMessageToAll(int32 entry, ChatMsg type, Player const* source = NULL); @@ -515,7 +515,7 @@ class Battleground virtual void EventPlayerClickedOnFlag(Player* /*player*/, GameObject* /*target_obj*/) {} void EventPlayerLoggedIn(Player* player); void EventPlayerLoggedOut(Player* player); - virtual void EventPlayerDamagedGO(Player* /*plr*/, GameObject* /*go*/, uint32 /*eventType*/) {} + virtual void EventPlayerDamagedGO(Player* /*player*/, GameObject* /*go*/, uint32 /*eventType*/) {} virtual void EventPlayerUsedGO(Player* /*player*/, GameObject* /*go*/){} // this function can be used by spell to interact with the BG map @@ -526,7 +526,7 @@ class Battleground // Death related virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); - virtual void AddPlayer(Player* plr); // must be implemented in BG subclass + virtual void AddPlayer(Player* player); // must be implemented in BG subclass void AddOrSetPlayerToCorrectBgGroup(Player* player, uint32 team); @@ -554,7 +554,7 @@ class Battleground //to be removed const char* GetTrinityString(int32 entry); - virtual bool HandlePlayerUnderMap(Player* /*plr*/) { return false; } + virtual bool HandlePlayerUnderMap(Player* /*player*/) { return false; } // since arenas can be AvA or Hvh, we have to get the "temporary" team of a player uint32 GetPlayerTeam(uint64 guid) const; @@ -575,7 +575,7 @@ class Battleground protected: // this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends Battleground void EndNow(); - void PlayerAddedToBGCheckIfBGIsRunning(Player* plr); + void PlayerAddedToBGCheckIfBGIsRunning(Player* player); Player* _GetPlayer(uint64 guid, bool offlineRemove, const char* context) const; Player* _GetPlayer(BattlegroundPlayerMap::iterator itr, const char* context); diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index e00abb03320..a9acced82ae 100755 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -291,10 +291,10 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg) } else { - Player* plr = ObjectAccessor::FindPlayer(itr2->first); + Player* player = ObjectAccessor::FindPlayer(itr2->first); uint32 team = bg->GetPlayerTeam(itr2->first); - if (!team && plr) - team = plr->GetBGTeam(); + if (!team && player) + team = player->GetBGTeam(); *data << uint8(team == ALLIANCE ? 1 : 0); // green or yellow } *data << uint32(itr2->second->DamageDone); // damage done @@ -422,10 +422,10 @@ void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket(WorldPacket* data, uint6 *data << uint64(guid); } -void BattlegroundMgr::BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, Player* plr) +void BattlegroundMgr::BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, Player* player) { data->Initialize(SMSG_BATTLEGROUND_PLAYER_JOINED, 8); - *data << uint64(plr->GetGUID()); + *data << uint64(player->GetGUID()); } Battleground* BattlegroundMgr::GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId) @@ -804,17 +804,17 @@ void BattlegroundMgr::InitAutomaticArenaPointDistribution() sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Automatic Arena Point Distribution initialized."); } -void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* plr, BattlegroundTypeId bgTypeId, uint8 fromWhere) +void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere) { - if (!plr) + if (!player) return; - uint32 winner_kills = plr->GetRandomWinner() ? BG_REWARD_WINNER_HONOR_LAST : BG_REWARD_WINNER_HONOR_FIRST; - uint32 winner_arena = plr->GetRandomWinner() ? BG_REWARD_WINNER_ARENA_LAST : BG_REWARD_WINNER_ARENA_FIRST; - uint32 loser_kills = plr->GetRandomWinner() ? BG_REWARD_LOSER_HONOR_LAST : BG_REWARD_LOSER_HONOR_FIRST; + uint32 winner_kills = player->GetRandomWinner() ? BG_REWARD_WINNER_HONOR_LAST : BG_REWARD_WINNER_HONOR_FIRST; + uint32 winner_arena = player->GetRandomWinner() ? BG_REWARD_WINNER_ARENA_LAST : BG_REWARD_WINNER_ARENA_FIRST; + uint32 loser_kills = player->GetRandomWinner() ? BG_REWARD_LOSER_HONOR_LAST : BG_REWARD_LOSER_HONOR_FIRST; - winner_kills = Trinity::Honor::hk_honor_at_level(plr->getLevel(), float(winner_kills)); - loser_kills = Trinity::Honor::hk_honor_at_level(plr->getLevel(), float(loser_kills)); + winner_kills = Trinity::Honor::hk_honor_at_level(player->getLevel(), float(winner_kills)); + loser_kills = Trinity::Honor::hk_honor_at_level(player->getLevel(), float(loser_kills)); data->Initialize(SMSG_BATTLEFIELD_LIST); *data << uint64(guid); // battlemaster guid @@ -824,7 +824,7 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid *data << uint8(0); // unk // Rewards - *data << uint8(plr->GetRandomWinner()); // 3.3.3 hasWin + *data << uint8(player->GetRandomWinner()); // 3.3.3 hasWin *data << uint32(winner_kills); // 3.3.3 winHonor *data << uint32(winner_arena); // 3.3.3 winArena *data << uint32(loser_kills); // 3.3.3 lossHonor @@ -835,7 +835,7 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid if (isRandom) { // Rewards (random) - *data << uint8(plr->GetRandomWinner()); // 3.3.3 hasWin_Random + *data << uint8(player->GetRandomWinner()); // 3.3.3 hasWin_Random *data << uint32(winner_kills); // 3.3.3 winHonor_Random *data << uint32(winner_arena); // 3.3.3 winArena_Random *data << uint32(loser_kills); // 3.3.3 lossHonor_Random @@ -853,7 +853,7 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid if (Battleground* bgTemplate = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId)) { // expected bracket entry - if (PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(), plr->getLevel())) + if (PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(), player->getLevel())) { uint32 count = 0; BattlegroundBracketId bracketId = bracketEntry->GetBracketId(); @@ -868,35 +868,35 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid } } -void BattlegroundMgr::SendToBattleground(Player* pl, uint32 instanceId, BattlegroundTypeId bgTypeId) +void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, BattlegroundTypeId bgTypeId) { Battleground* bg = GetBattleground(instanceId, bgTypeId); if (bg) { uint32 mapid = bg->GetMapId(); float x, y, z, O; - uint32 team = pl->GetBGTeam(); + uint32 team = player->GetBGTeam(); if (team == 0) - team = pl->GetTeam(); + team = player->GetTeam(); bg->GetTeamStartLoc(team, x, y, z, O); - sLog->outDetail("BATTLEGROUND: Sending %s to map %u, X %f, Y %f, Z %f, O %f", pl->GetName(), mapid, x, y, z, O); - pl->TeleportTo(mapid, x, y, z, O); + sLog->outDetail("BATTLEGROUND: Sending %s to map %u, X %f, Y %f, Z %f, O %f", player->GetName(), mapid, x, y, z, O); + player->TeleportTo(mapid, x, y, z, O); } else { - sLog->outError("player %u is trying to port to non-existent bg instance %u", pl->GetGUIDLow(), instanceId); + sLog->outError("player %u is trying to port to non-existent bg instance %u", player->GetGUIDLow(), instanceId); } } -void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* pl, Battleground* bg, uint64 guid) +void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid) { WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12); uint32 time_ = 30000 - bg->GetLastResurrectTime(); // resurrect every 30 seconds if (time_ == uint32(-1)) time_ = 0; data << guid << time_; - pl->GetSession()->SendPacket(&data); + player->GetSession()->SendPacket(&data); } bool BattlegroundMgr::IsArenaType(BattlegroundTypeId bgTypeId) diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h index 7f35e5366a5..989509111bb 100755 --- a/src/server/game/Battlegrounds/BattlegroundMgr.h +++ b/src/server/game/Battlegrounds/BattlegroundMgr.h @@ -65,15 +65,15 @@ class BattlegroundMgr void Update(uint32 diff); /* Packet Building */ - void BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, Player* plr); + void BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, Player* player); void BuildPlayerLeftBattlegroundPacket(WorldPacket* data, uint64 guid); - void BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* plr, BattlegroundTypeId bgTypeId, uint8 fromWhere); + void BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere); void BuildGroupJoinedBattlegroundPacket(WorldPacket* data, GroupJoinBattlegroundResult result); void BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value); void BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg); void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, uint8 arenatype, uint8 uiFrame = 1); void BuildPlaySoundPacket(WorldPacket* data, uint32 soundid); - void SendAreaSpiritHealerQueryOpcode(Player* pl, Battleground* bg, uint64 guid); + void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid); /* Battlegrounds */ Battleground* GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId); @@ -91,7 +91,7 @@ class BattlegroundMgr void CreateInitialBattlegrounds(); void DeleteAllBattlegrounds(); - void SendToBattleground(Player* pl, uint32 InstanceID, BattlegroundTypeId bgTypeId); + void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId); /* Battleground queues */ //these queues are instantiated when creating BattlegroundMrg diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 67cea3e7be1..3005f1f2672 100755 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -285,7 +285,7 @@ uint32 BattlegroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, Battleg //remove player from queue and from group info, if group info is empty then remove it too void BattlegroundQueue::RemovePlayer(uint64 guid, bool decreaseInvitedCount) { - //Player* plr = ObjectAccessor::FindPlayer(guid); + //Player* player = ObjectAccessor::FindPlayer(guid); int32 bracket_id = -1; // signed for proper for-loop finish QueuedPlayersMap::iterator itr; @@ -362,8 +362,8 @@ void BattlegroundQueue::RemovePlayer(uint64 guid, bool decreaseInvitedCount) if (ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(group->ArenaTeamId)) { sLog->outDebug(LOG_FILTER_BATTLEGROUND, "UPDATING memberLost's personal arena rating for %u by opponents rating: %u", GUID_LOPART(guid), group->OpponentsTeamRating); - if (Player* plr = ObjectAccessor::FindPlayer(guid)) - at->MemberLost(plr, group->OpponentsMatchmakerRating); + if (Player* player = ObjectAccessor::FindPlayer(guid)) + at->MemberLost(player, group->OpponentsMatchmakerRating); else at->OfflineMemberLost(guid, group->OpponentsMatchmakerRating); at->SaveToDB(); @@ -442,36 +442,36 @@ bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, for (std::map<uint64, PlayerQueueInfo*>::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr) { // get the player - Player* plr = ObjectAccessor::FindPlayer(itr->first); + Player* player = ObjectAccessor::FindPlayer(itr->first); // if offline, skip him, this should not happen - player is removed from queue when he logs out - if (!plr) + if (!player) continue; // invite the player PlayerInvitedToBGUpdateAverageWaitTime(ginfo, bracket_id); - //sBattlegroundMgr->InvitePlayer(plr, bg, ginfo->Team); + //sBattlegroundMgr->InvitePlayer(player, bg, ginfo->Team); // set invited player counters bg->IncreaseInvitedCount(ginfo->Team); - plr->SetInviteForBattlegroundQueueType(bgQueueTypeId, ginfo->IsInvitedToBGInstanceGUID); + player->SetInviteForBattlegroundQueueType(bgQueueTypeId, ginfo->IsInvitedToBGInstanceGUID); // create remind invite events - BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(plr->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, ginfo->ArenaType, ginfo->RemoveInviteTime); + BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(player->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, ginfo->ArenaType, ginfo->RemoveInviteTime); m_events.AddEvent(inviteEvent, m_events.CalculateTime(INVITATION_REMIND_TIME)); // create automatic remove events - BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(plr->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, bgQueueTypeId, ginfo->RemoveInviteTime); + BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(player->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, bgQueueTypeId, ginfo->RemoveInviteTime); m_events.AddEvent(removeEvent, m_events.CalculateTime(INVITE_ACCEPT_WAIT_TIME)); WorldPacket data; - uint32 queueSlot = plr->GetBattlegroundQueueIndex(bgQueueTypeId); + uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId); - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: invited plr %s (%u) to BG instance %u queueindex %u bgtype %u, I can't help it if they don't press the enter battle button.", plr->GetName(), plr->GetGUIDLow(), bg->GetInstanceID(), queueSlot, bg->GetTypeID()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: invited player %s (%u) to BG instance %u queueindex %u bgtype %u, I can't help it if they don't press the enter battle button.", player->GetName(), player->GetGUIDLow(), bg->GetInstanceID(), queueSlot, bg->GetTypeID()); // send status packet sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME, 0, ginfo->ArenaType); - plr->GetSession()->SendPacket(&data); + player->GetSession()->SendPacket(&data); } return true; } @@ -911,104 +911,83 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId uint32 discardTime = getMSTime() - sBattlegroundMgr->GetRatingDiscardTimer(); // we need to find 2 teams which will play next game - - GroupsQueueType::iterator itr_team[BG_TEAMS_COUNT]; - - //optimalization : --- we dont need to use selection_pools - each update we select max 2 groups - for (uint32 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++) + GroupsQueueType::iterator itr_teams[BG_TEAMS_COUNT]; + uint8 found = 0; + uint8 team = 0; + + for (uint8 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++) { // take the group that joined first - itr_team[i] = m_QueuedGroups[bracket_id][i].begin(); - for (; itr_team[i] != m_QueuedGroups[bracket_id][i].end(); ++(itr_team[i])) + GroupsQueueType::iterator itr = m_QueuedGroups[bracket_id][i].begin(); + for (; itr != m_QueuedGroups[bracket_id][i].end(); ++itr) { // if group match conditions, then add it to pool - if (!(*itr_team[i])->IsInvitedToBGInstanceGUID - && (((*itr_team[i])->ArenaMatchmakerRating >= arenaMinRating && (*itr_team[i])->ArenaMatchmakerRating <= arenaMaxRating) - || (*itr_team[i])->JoinTime < discardTime)) + if (!(*itr)->IsInvitedToBGInstanceGUID + && (((*itr)->ArenaMatchmakerRating >= arenaMinRating && (*itr)->ArenaMatchmakerRating <= arenaMaxRating) + || (*itr)->JoinTime < discardTime)) { - m_SelectionPools[i].AddGroup((*itr_team[i]), MaxPlayersPerTeam); - // break for cycle to be able to start selecting another group from same faction queue + itr_teams[found++] = itr; + team = i; break; } } } - - // now we are done if we have 2 groups - ali vs horde! - // if we don't have, we must try to continue search in same queue - // tmp variables are correctly set - // this code isn't much userfriendly - but it is supposed to continue search for mathing group in HORDE queue - if (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() == 0 && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount()) + + if (!found) + return; + + if (found == 1) { - itr_team[BG_TEAM_ALLIANCE] = itr_team[BG_TEAM_HORDE]; - ++itr_team[BG_TEAM_ALLIANCE]; - for (; itr_team[BG_TEAM_ALLIANCE] != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end(); ++(itr_team[BG_TEAM_ALLIANCE])) + for (GroupsQueueType::iterator itr = itr_teams[0]; itr != m_QueuedGroups[bracket_id][team].end(); ++itr) { - if (!(*itr_team[BG_TEAM_ALLIANCE])->IsInvitedToBGInstanceGUID - && (((*itr_team[BG_TEAM_ALLIANCE])->ArenaMatchmakerRating >= arenaMinRating && (*itr_team[BG_TEAM_ALLIANCE])->ArenaMatchmakerRating <= arenaMaxRating) - || (*itr_team[BG_TEAM_ALLIANCE])->JoinTime < discardTime)) + if (!(*itr)->IsInvitedToBGInstanceGUID + && (((*itr)->ArenaMatchmakerRating >= arenaMinRating && (*itr)->ArenaMatchmakerRating <= arenaMaxRating) + || (*itr)->JoinTime < discardTime) + && (*itr_teams[0])->ArenaTeamId != (*itr)->ArenaTeamId) { - m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*itr_team[BG_TEAM_ALLIANCE]), MaxPlayersPerTeam); + itr_teams[found++] = itr; break; } } - } - - // this code isn't much userfriendly - but it is supposed to continue search for mathing group in ALLIANCE queue - if (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() == 0 && m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount()) - { - itr_team[BG_TEAM_HORDE] = itr_team[BG_TEAM_ALLIANCE]; - ++itr_team[BG_TEAM_HORDE]; - for (; itr_team[BG_TEAM_HORDE] != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end(); ++(itr_team[BG_TEAM_HORDE])) - { - if (!(*itr_team[BG_TEAM_HORDE])->IsInvitedToBGInstanceGUID - && (((*itr_team[BG_TEAM_HORDE])->ArenaMatchmakerRating >= arenaMinRating && (*itr_team[BG_TEAM_HORDE])->ArenaMatchmakerRating <= arenaMaxRating) - || (*itr_team[BG_TEAM_HORDE])->JoinTime < discardTime)) - { - m_SelectionPools[BG_TEAM_HORDE].AddGroup((*itr_team[BG_TEAM_HORDE]), MaxPlayersPerTeam); - break; - } - } - } - + } + //if we have 2 teams, then start new arena and invite players! - if (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount()) + if (found == 2) { + GroupQueueInfo* aTeam = *itr_teams[BG_TEAM_ALLIANCE]; + GroupQueueInfo* hTeam = *itr_teams[BG_TEAM_HORDE]; Battleground* arena = sBattlegroundMgr->CreateNewBattleground(bgTypeId, bracketEntry, arenaType, true); if (!arena) { sLog->outError("BattlegroundQueue::Update couldn't create arena instance for rated arena match!"); return; } - - (*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsTeamRating = (*(itr_team[BG_TEAM_HORDE]))->ArenaTeamRating; - (*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsMatchmakerRating = (*(itr_team[BG_TEAM_HORDE]))->ArenaMatchmakerRating; - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaTeamId, (*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsTeamRating); - (*(itr_team[BG_TEAM_HORDE]))->OpponentsTeamRating = (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaTeamRating; - (*(itr_team[BG_TEAM_HORDE]))->OpponentsMatchmakerRating = (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaMatchmakerRating; - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", (*(itr_team[BG_TEAM_HORDE]))->ArenaTeamId, (*(itr_team[BG_TEAM_HORDE]))->OpponentsTeamRating); + + aTeam->OpponentsTeamRating = hTeam->ArenaTeamRating; + hTeam->OpponentsTeamRating = aTeam->ArenaTeamRating; + aTeam->OpponentsMatchmakerRating = hTeam->ArenaMatchmakerRating; + hTeam->OpponentsMatchmakerRating = aTeam->ArenaMatchmakerRating; + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", aTeam->ArenaTeamId, aTeam->OpponentsTeamRating); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", hTeam->ArenaTeamId, hTeam->OpponentsTeamRating); + // now we must move team if we changed its faction to another faction queue, because then we will spam log by errors in Queue::RemovePlayer - if ((*(itr_team[BG_TEAM_ALLIANCE]))->Team != ALLIANCE) + if (aTeam->Team != ALLIANCE) { - // add to alliance queue - m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].push_front(*(itr_team[BG_TEAM_ALLIANCE])); - // erase from horde queue - m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].erase(itr_team[BG_TEAM_ALLIANCE]); - itr_team[BG_TEAM_ALLIANCE] = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].begin(); + m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].push_front(aTeam); + m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].erase(itr_teams[BG_TEAM_ALLIANCE]); } - if ((*(itr_team[BG_TEAM_HORDE]))->Team != HORDE) + if (hTeam->Team != HORDE) { - m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].push_front(*(itr_team[BG_TEAM_HORDE])); - m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_team[BG_TEAM_HORDE]); - itr_team[BG_TEAM_HORDE] = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].begin(); + m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].push_front(hTeam); + m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_teams[BG_TEAM_HORDE]); } - - arena->SetArenaMatchmakerRating(ALLIANCE, (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaMatchmakerRating); - arena->SetArenaMatchmakerRating(HORDE, (*(itr_team[BG_TEAM_HORDE]))->ArenaMatchmakerRating); - InviteGroupToBG(*(itr_team[BG_TEAM_ALLIANCE]), arena, ALLIANCE); - InviteGroupToBG(*(itr_team[BG_TEAM_HORDE]), arena, HORDE); - + + arena->SetArenaMatchmakerRating(ALLIANCE, aTeam->ArenaMatchmakerRating); + arena->SetArenaMatchmakerRating( HORDE, hTeam->ArenaMatchmakerRating); + InviteGroupToBG(aTeam, arena, ALLIANCE); + InviteGroupToBG(hTeam, arena, HORDE); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Starting rated arena match!"); - arena->StartBattleground(); } } @@ -1020,9 +999,9 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) { - Player* plr = ObjectAccessor::FindPlayer(m_PlayerGuid); + Player* player = ObjectAccessor::FindPlayer(m_PlayerGuid); // player logged off (we should do nothing, he is correctly removed from queue in another procedure) - if (!plr) + if (!player) return true; Battleground* bg = sBattlegroundMgr->GetBattleground(m_BgInstanceGUID, m_BgTypeId); @@ -1031,7 +1010,7 @@ bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) return true; BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bg->GetTypeID(), bg->GetArenaType()); - uint32 queueSlot = plr->GetBattlegroundQueueIndex(bgQueueTypeId); + uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId); if (queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES) // player is in queue or in battleground { // check if player is invited to this bg @@ -1041,7 +1020,7 @@ bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) WorldPacket data; //we must send remaining time in queue sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME - INVITATION_REMIND_TIME, 0, m_ArenaType); - plr->GetSession()->SendPacket(&data); + player->GetSession()->SendPacket(&data); } } return true; //event will be deleted @@ -1063,8 +1042,8 @@ void BGQueueInviteEvent::Abort(uint64 /*e_time*/) */ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) { - Player* plr = ObjectAccessor::FindPlayer(m_PlayerGuid); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(m_PlayerGuid); + if (!player) // player logged off (we should do nothing, he is correctly removed from queue in another procedure) return true; @@ -1072,16 +1051,16 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) //battleground can be deleted already when we are removing queue info //bg pointer can be NULL! so use it carefully! - uint32 queueSlot = plr->GetBattlegroundQueueIndex(m_BgQueueTypeId); + uint32 queueSlot = player->GetBattlegroundQueueIndex(m_BgQueueTypeId); if (queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES) // player is in queue, or in Battleground { // check if player is in queue for this BG and if we are removing his invite event BattlegroundQueue &bgQueue = sBattlegroundMgr->m_BattlegroundQueues[m_BgQueueTypeId]; if (bgQueue.IsPlayerInvited(m_PlayerGuid, m_BgInstanceGUID, m_RemoveTime)) { - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: removing player %u from bg queue for instance %u because of not pressing enter battle in time.", plr->GetGUIDLow(), m_BgInstanceGUID); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: removing player %u from bg queue for instance %u because of not pressing enter battle in time.", player->GetGUIDLow(), m_BgInstanceGUID); - plr->RemoveBattlegroundQueueId(m_BgQueueTypeId); + player->RemoveBattlegroundQueueId(m_BgQueueTypeId); bgQueue.RemovePlayer(m_PlayerGuid, true); //update queues if battleground isn't ended if (bg && bg->isBattleground() && bg->GetStatus() != STATUS_WAIT_LEAVE) @@ -1089,7 +1068,7 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) WorldPacket data; sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_NONE, 0, 0, 0); - plr->GetSession()->SendPacket(&data); + player->GetSession()->SendPacket(&data); } } diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h index 10bff57a251..6b19c23ca68 100755 --- a/src/server/game/Battlegrounds/BattlegroundQueue.h +++ b/src/server/game/Battlegrounds/BattlegroundQueue.h @@ -103,6 +103,7 @@ class BattlegroundQueue class SelectionPool { public: + SelectionPool(): PlayerCount(0) {}; void Init(); bool AddGroup(GroupQueueInfo* ginfo, uint32 desiredCount); bool KickGroup(uint32 size); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAA.cpp index 7c7a6262c58..1e8973edf10 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAA.cpp @@ -47,16 +47,16 @@ void BattlegroundAA::StartingEventOpenDoors() { } -void BattlegroundAA::AddPlayer(Player* plr) +void BattlegroundAA::AddPlayer(Player* player) { - Battleground::AddPlayer(plr); + Battleground::AddPlayer(player); //create score and add it to map, default values are set in constructor BattlegroundAAScore* sc = new BattlegroundAAScore; - m_PlayerScores[plr->GetGUID()] = sc; + m_PlayerScores[player->GetGUID()] = sc; } -void BattlegroundAA::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/) +void BattlegroundAA::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/) { } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAA.h b/src/server/game/Battlegrounds/Zones/BattlegroundAA.h index 33e193bd4ef..bdf1ad7eedd 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAA.h @@ -35,11 +35,11 @@ class BattlegroundAA : public Battleground ~BattlegroundAA(); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player* plr); + virtual void AddPlayer(Player* player); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player* plr, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team); void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleground(); void HandleKillPlayer(Player* player, Player* killer); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp index e2a39ff4666..028773c5229 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp @@ -204,16 +204,16 @@ void BattlegroundAB::StartingEventOpenDoors() DoorOpen(BG_AB_OBJECT_GATE_H); } -void BattlegroundAB::AddPlayer(Player* plr) +void BattlegroundAB::AddPlayer(Player* player) { - Battleground::AddPlayer(plr); + Battleground::AddPlayer(player); //create score and add it to map, default values are set in the constructor BattlegroundABScore* sc = new BattlegroundABScore; - m_PlayerScores[plr->GetGUID()] = sc; + m_PlayerScores[player->GetGUID()] = sc; } -void BattlegroundAB::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/) +void BattlegroundAB::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/) { } @@ -409,15 +409,15 @@ void BattlegroundAB::_NodeDeOccupied(uint8 node) WorldSafeLocsEntry const* ClosestGrave = NULL; for (std::vector<uint64>::const_iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr) { - Player* plr = ObjectAccessor::FindPlayer(*itr); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(*itr); + if (!player) continue; if (!ClosestGrave) // cache - ClosestGrave = GetClosestGraveYard(plr); + ClosestGrave = GetClosestGraveYard(player); if (ClosestGrave) - plr->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, plr->GetOrientation()); + player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation()); } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h index c848c5f23f8..39f3727d68e 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h @@ -245,10 +245,10 @@ class BattlegroundAB : public Battleground BattlegroundAB(); ~BattlegroundAB(); - void AddPlayer(Player* plr); + void AddPlayer(Player* player); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player* plr, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team); void HandleAreaTrigger(Player* Source, uint32 Trigger); virtual bool SetupBattleground(); virtual void Reset(); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index a647a3c6299..491584557a3 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -422,14 +422,14 @@ void BattlegroundAV::StartingEventOpenDoors() DoorOpen(BG_AV_OBJECT_DOOR_A); } -void BattlegroundAV::AddPlayer(Player* plr) +void BattlegroundAV::AddPlayer(Player* player) { - Battleground::AddPlayer(plr); + Battleground::AddPlayer(player); //create score and add it to map, default values are set in constructor BattlegroundAVScore* sc = new BattlegroundAVScore; - m_PlayerScores[plr->GetGUID()] = sc; + m_PlayerScores[player->GetGUID()] = sc; if (m_MaxLevel == 0) - m_MaxLevel=(plr->getLevel()%10 == 0)? plr->getLevel() : (plr->getLevel()-(plr->getLevel()%10))+10; //TODO: just look at the code \^_^/ --but queue-info should provide this information.. + m_MaxLevel=(player->getLevel()%10 == 0)? player->getLevel() : (player->getLevel()-(player->getLevel()%10))+10; //TODO: just look at the code \^_^/ --but queue-info should provide this information.. } @@ -473,17 +473,17 @@ void BattlegroundAV::EndBattleground(uint32 winner) Battleground::EndBattleground(winner); } -void BattlegroundAV::RemovePlayer(Player* plr, uint64 /*guid*/, uint32 /*team*/) +void BattlegroundAV::RemovePlayer(Player* player, uint64 /*guid*/, uint32 /*team*/) { - if (!plr) + if (!player) { sLog->outError("bg_AV no player at remove"); return; } //TODO search more buffs - plr->RemoveAurasDueToSpell(AV_BUFF_ARMOR); - plr->RemoveAurasDueToSpell(AV_BUFF_A_CAPTAIN); - plr->RemoveAurasDueToSpell(AV_BUFF_H_CAPTAIN); + player->RemoveAurasDueToSpell(AV_BUFF_ARMOR); + player->RemoveAurasDueToSpell(AV_BUFF_A_CAPTAIN); + player->RemoveAurasDueToSpell(AV_BUFF_H_CAPTAIN); } void BattlegroundAV::HandleAreaTrigger(Player* Source, uint32 Trigger) @@ -1029,17 +1029,17 @@ void BattlegroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object) std::vector<uint64> ghost_list = m_ReviveQueue[m_BgCreatures[node]]; if (!ghost_list.empty()) { - Player* plr; + Player* player; WorldSafeLocsEntry const* ClosestGrave = NULL; for (std::vector<uint64>::iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr) { - plr = ObjectAccessor::FindPlayer(*ghost_list.begin()); - if (!plr) + player = ObjectAccessor::FindPlayer(*ghost_list.begin()); + if (!player) continue; if (!ClosestGrave) - ClosestGrave = GetClosestGraveYard(plr); + ClosestGrave = GetClosestGraveYard(player); else - plr->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, plr->GetOrientation()); + player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation()); } m_ReviveQueue[m_BgCreatures[node]].clear(); } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h index 3ae1f52a4f9..2c8ffc0cf72 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h @@ -1539,11 +1539,11 @@ class BattlegroundAV : public Battleground ~BattlegroundAV(); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player* plr); + virtual void AddPlayer(Player* player); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player* plr, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team); void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleground(); virtual void ResetBGSubclass(); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp index 1db59547d92..88b9aa6184e 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp @@ -62,18 +62,18 @@ void BattlegroundBE::StartingEventOpenDoors() SpawnBGObject(i, 60); } -void BattlegroundBE::AddPlayer(Player* plr) +void BattlegroundBE::AddPlayer(Player* player) { - Battleground::AddPlayer(plr); + Battleground::AddPlayer(player); //create score and add it to map, default values are set in constructor BattlegroundBEScore* sc = new BattlegroundBEScore; - m_PlayerScores[plr->GetGUID()] = sc; + m_PlayerScores[player->GetGUID()] = sc; UpdateArenaWorldState(); } -void BattlegroundBE::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/) +void BattlegroundBE::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/) { if (GetStatus() == STATUS_WAIT_LEAVE) return; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBE.h b/src/server/game/Battlegrounds/Zones/BattlegroundBE.h index 13aef8f561b..1b4fa8ebd64 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBE.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBE.h @@ -55,17 +55,17 @@ class BattlegroundBE : public Battleground ~BattlegroundBE(); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player* plr); + virtual void AddPlayer(Player* player); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player* plr, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team); void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleground(); virtual void Reset(); virtual void FillInitialWorldStates(WorldPacket &d); void HandleKillPlayer(Player* player, Player* killer); - bool HandlePlayerUnderMap(Player* plr); + bool HandlePlayerUnderMap(Player* player); /* Scorekeeping */ void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp index 6fb07ebb678..754005f3f33 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp @@ -88,18 +88,18 @@ void BattlegroundDS::StartingEventOpenDoors() SpawnBGObject(i, getWaterFallTimer()); } -void BattlegroundDS::AddPlayer(Player* plr) +void BattlegroundDS::AddPlayer(Player* player) { - Battleground::AddPlayer(plr); + Battleground::AddPlayer(player); //create score and add it to map, default values are set in constructor BattlegroundDSScore* sc = new BattlegroundDSScore; - m_PlayerScores[plr->GetGUID()] = sc; + m_PlayerScores[player->GetGUID()] = sc; UpdateArenaWorldState(); } -void BattlegroundDS::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/) +void BattlegroundDS::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/) { if (GetStatus() == STATUS_WAIT_LEAVE) return; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h index e5b2d613810..625eb1c7533 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h @@ -64,17 +64,17 @@ class BattlegroundDS : public Battleground ~BattlegroundDS(); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player* plr); + virtual void AddPlayer(Player* player); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player* plr, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team); void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleground(); virtual void Reset(); virtual void FillInitialWorldStates(WorldPacket &d); void HandleKillPlayer(Player* player, Player* killer); - bool HandlePlayerUnderMap(Player* plr); + bool HandlePlayerUnderMap(Player* player); private: uint32 m_waterTimer; bool m_waterfallActive; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index 8c5b0468aca..c790d64e986 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -146,20 +146,20 @@ void BattlegroundEY::CheckSomeoneJoinedPoint() uint8 j = 0; while (j < m_PlayersNearPoint[EY_POINTS_MAX].size()) { - Player* plr = ObjectAccessor::FindPlayer(m_PlayersNearPoint[EY_POINTS_MAX][j]); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[EY_POINTS_MAX][j]); + if (!player) { sLog->outError("BattlegroundEY:CheckSomeoneJoinedPoint: Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[EY_POINTS_MAX][j])); ++j; continue; } - if (plr->CanCaptureTowerPoint() && plr->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS)) + if (player->CanCaptureTowerPoint() && player->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS)) { //player joined point! //show progress bar - UpdateWorldStateForPlayer(PROGRESS_BAR_PERCENT_GREY, BG_EY_PROGRESS_BAR_PERCENT_GREY, plr); - UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[i], plr); - UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_SHOW, plr); + UpdateWorldStateForPlayer(PROGRESS_BAR_PERCENT_GREY, BG_EY_PROGRESS_BAR_PERCENT_GREY, player); + UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[i], player); + UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_SHOW, player); //add player to point m_PlayersNearPoint[i].push_back(m_PlayersNearPoint[EY_POINTS_MAX][j]); //remove player from "free space" @@ -186,8 +186,8 @@ void BattlegroundEY::CheckSomeoneLeftPoint() uint8 j = 0; while (j < m_PlayersNearPoint[i].size()) { - Player* plr = ObjectAccessor::FindPlayer(m_PlayersNearPoint[i][j]); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[i][j]); + if (!player) { sLog->outError("BattlegroundEY:CheckSomeoneLeftPoint Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[i][j])); //move not existed player to "free space" - this will cause many error showing in log, but it is a very important bug @@ -196,17 +196,17 @@ void BattlegroundEY::CheckSomeoneLeftPoint() ++j; continue; } - if (!plr->CanCaptureTowerPoint() || !plr->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS)) + if (!player->CanCaptureTowerPoint() || !player->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS)) //move player out of point (add him to players that are out of points { m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]); m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j); - this->UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_DONT_SHOW, plr); + this->UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_DONT_SHOW, player); } else { //player is neat flag, so update count: - m_CurrentPointPlayersCount[2 * i + GetTeamIndexByTeamId(plr->GetTeam())]++; + m_CurrentPointPlayersCount[2 * i + GetTeamIndexByTeamId(player->GetTeam())]++; ++j; } } @@ -241,20 +241,20 @@ void BattlegroundEY::UpdatePointStatuses() for (uint8 i = 0; i < m_PlayersNearPoint[point].size(); ++i) { - Player* plr = ObjectAccessor::FindPlayer(m_PlayersNearPoint[point][i]); - if (plr) + Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[point][i]); + if (player) { - this->UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[point], plr); + this->UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[point], player); //if point owner changed we must evoke event! if (pointOwnerTeamId != m_PointOwnedByTeam[point]) { //point was uncontrolled and player is from team which captured point - if (m_PointState[point] == EY_POINT_STATE_UNCONTROLLED && plr->GetTeam() == pointOwnerTeamId) - this->EventTeamCapturedPoint(plr, point); + if (m_PointState[point] == EY_POINT_STATE_UNCONTROLLED && player->GetTeam() == pointOwnerTeamId) + this->EventTeamCapturedPoint(player, point); //point was under control and player isn't from team which controlled it - if (m_PointState[point] == EY_POINT_UNDER_CONTROL && plr->GetTeam() != m_PointOwnedByTeam[point]) - this->EventTeamLostPoint(plr, point); + if (m_PointState[point] == EY_POINT_UNDER_CONTROL && player->GetTeam() != m_PointOwnedByTeam[point]) + this->EventTeamLostPoint(player, point); } } } @@ -330,18 +330,18 @@ void BattlegroundEY::UpdatePointsIcons(uint32 Team, uint32 Point) } } -void BattlegroundEY::AddPlayer(Player* plr) +void BattlegroundEY::AddPlayer(Player* player) { - Battleground::AddPlayer(plr); + Battleground::AddPlayer(player); //create score and add it to map BattlegroundEYScore* sc = new BattlegroundEYScore; - m_PlayersNearPoint[EY_POINTS_MAX].push_back(plr->GetGUID()); + m_PlayersNearPoint[EY_POINTS_MAX].push_back(player->GetGUID()); - m_PlayerScores[plr->GetGUID()] = sc; + m_PlayerScores[player->GetGUID()] = sc; } -void BattlegroundEY::RemovePlayer(Player* plr, uint64 guid, uint32 /*team*/) +void BattlegroundEY::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/) { // sometimes flag aura not removed :( for (int j = EY_POINTS_MAX; j >= 0; --j) @@ -354,8 +354,8 @@ void BattlegroundEY::RemovePlayer(Player* plr, uint64 guid, uint32 /*team*/) { if (m_FlagKeeper == guid) { - if (plr) - EventPlayerDroppedFlag(plr); + if (player) + EventPlayerDroppedFlag(player); else { SetFlagPicker(0); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h index fdb81491771..aba5754752a 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h @@ -336,7 +336,7 @@ class BattlegroundEY : public Battleground ~BattlegroundEY(); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player* plr); + virtual void AddPlayer(Player* player); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); @@ -348,7 +348,7 @@ class BattlegroundEY : public Battleground void RespawnFlag(bool send_message); void RespawnFlagAfterDrop(); - void RemovePlayer(Player* plr, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team); void HandleBuffUse(uint64 buff_guid); void HandleAreaTrigger(Player* Source, uint32 Trigger); void HandleKillPlayer(Player* player, Player* killer); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp index b00e8dac1d8..f17df3aaf67 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp @@ -90,22 +90,22 @@ void BattlegroundIC::DoAction(uint32 action, uint64 var) if (action != ACTION_TELEPORT_PLAYER_TO_TRANSPORT) return; - Player* plr = ObjectAccessor::FindPlayer(var); + Player* player = ObjectAccessor::FindPlayer(var); - if (!plr || !gunshipAlliance || !gunshipHorde) + if (!player || !gunshipAlliance || !gunshipHorde) return; - plr->CastSpell(plr, SPELL_PARACHUTE, true); // this must be changed, there is a trigger in each transport that casts the spell. - plr->CastSpell(plr, SPELL_SLOW_FALL, true); + player->CastSpell(player, SPELL_PARACHUTE, true); // this must be changed, there is a trigger in each transport that casts the spell. + player->CastSpell(player, SPELL_SLOW_FALL, true); - plr->SetTransport(plr->GetTeamId() == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde); + player->SetTransport(player->GetTeamId() == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde); - plr->m_movementInfo.t_pos.m_positionX = TransportMovementInfo.GetPositionX(); - plr->m_movementInfo.t_pos.m_positionY = TransportMovementInfo.GetPositionY(); - plr->m_movementInfo.t_pos.m_positionZ = TransportMovementInfo.GetPositionZ(); - plr->m_movementInfo.t_guid = (plr->GetTeamId() == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde)->GetGUID(); + player->m_movementInfo.t_pos.m_positionX = TransportMovementInfo.GetPositionX(); + player->m_movementInfo.t_pos.m_positionY = TransportMovementInfo.GetPositionY(); + player->m_movementInfo.t_pos.m_positionZ = TransportMovementInfo.GetPositionZ(); + player->m_movementInfo.t_guid = (player->GetTeamId() == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde)->GetGUID(); - plr->TeleportTo(GetMapId(), TeleportToTransportPosition.GetPositionX(), TeleportToTransportPosition.GetPositionY(), TeleportToTransportPosition.GetPositionZ(), TeleportToTransportPosition.GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT); + player->TeleportTo(GetMapId(), TeleportToTransportPosition.GetPositionX(), TeleportToTransportPosition.GetPositionY(), TeleportToTransportPosition.GetPositionZ(), TeleportToTransportPosition.GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT); } void BattlegroundIC::PostUpdateImpl(uint32 diff) @@ -135,7 +135,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff) if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A || nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H) { - if (nodePoint[i].timer <= diff) + if (docksTimer <= diff) { // we need to confirm this, i am not sure if this every 3 minutes for (uint8 u = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_A : BG_IC_NPC_CATAPULT_1_H); u < (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_4_A : BG_IC_NPC_CATAPULT_4_H); u++) @@ -158,7 +158,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff) } docksTimer = DOCKS_UPDATE_TIME; - } else nodePoint[i].timer -= diff; + } else docksTimer -= diff; } } @@ -292,29 +292,29 @@ bool BattlegroundIC::IsAllNodesConrolledByTeam(uint32 team) const return count == NODE_TYPE_WORKSHOP; } -void BattlegroundIC::AddPlayer(Player* plr) +void BattlegroundIC::AddPlayer(Player* player) { - Battleground::AddPlayer(plr); + Battleground::AddPlayer(player); //create score and add it to map, default values are set in constructor BattlegroundICScore* sc = new BattlegroundICScore; - m_PlayerScores[plr->GetGUID()] = sc; + m_PlayerScores[player->GetGUID()] = sc; - if (nodePoint[NODE_TYPE_QUARRY].nodeState == (plr->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H)) - plr->CastSpell(plr, SPELL_QUARRY, true); + if (nodePoint[NODE_TYPE_QUARRY].nodeState == (player->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H)) + player->CastSpell(player, SPELL_QUARRY, true); - if (nodePoint[NODE_TYPE_REFINERY].nodeState == (plr->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H)) - plr->CastSpell(plr, SPELL_OIL_REFINERY, true); + if (nodePoint[NODE_TYPE_REFINERY].nodeState == (player->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H)) + player->CastSpell(player, SPELL_OIL_REFINERY, true); - SendTransportInit(plr); + SendTransportInit(player); } -void BattlegroundIC::RemovePlayer(Player* plr, uint64 /*guid*/, uint32 /*team*/) +void BattlegroundIC::RemovePlayer(Player* player, uint64 /*guid*/, uint32 /*team*/) { - if (plr) + if (player) { - plr->RemoveAura(SPELL_QUARRY); - plr->RemoveAura(SPELL_OIL_REFINERY); + player->RemoveAura(SPELL_QUARRY); + player->RemoveAura(SPELL_OIL_REFINERY); } } @@ -482,15 +482,15 @@ void BattlegroundIC::RealocatePlayers(ICNodePointType nodeType) WorldSafeLocsEntry const* ClosestGrave = NULL; for (std::vector<uint64>::const_iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr) { - Player* plr = ObjectAccessor::FindPlayer(*itr); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(*itr); + if (!player) continue; if (!ClosestGrave) // cache - ClosestGrave = GetClosestGraveYard(plr); + ClosestGrave = GetClosestGraveYard(player); if (ClosestGrave) - plr->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, plr->GetOrientation()); + player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation()); } } } @@ -644,178 +644,178 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* nodePoint, bool recapture) switch (nodePoint->gameobject_type) { - case BG_IC_GO_HANGAR_BANNER: - // all the players on the stopped transport should be teleported out - if (!gunshipAlliance || !gunshipHorde) - break; + case BG_IC_GO_HANGAR_BANNER: + // all the players on the stopped transport should be teleported out + if (!gunshipAlliance || !gunshipHorde) + break; - for (uint8 u = 0; u < MAX_HANGAR_TELEPORTERS_SPAWNS; u++) - { - uint8 type = BG_IC_GO_HANGAR_TELEPORTER_1+u; - AddObject(type, (nodePoint->faction == TEAM_ALLIANCE ? GO_ALLIANCE_GUNSHIP_PORTAL : GO_HORDE_GUNSHIP_PORTAL), - BG_IC_HangarTeleporters[u].GetPositionX(), BG_IC_HangarTeleporters[u].GetPositionY(), - BG_IC_HangarTeleporters[u].GetPositionZ(), BG_IC_HangarTeleporters[u].GetOrientation(), - 0, 0, 0, 0, RESPAWN_ONE_DAY); - } - - //sLog->outError("BG_IC_GO_HANGAR_BANNER CAPTURED Faction: %u", nodePoint->faction); + for (uint8 u = 0; u < MAX_HANGAR_TELEPORTERS_SPAWNS; u++) + { + uint8 type = BG_IC_GO_HANGAR_TELEPORTER_1+u; + AddObject(type, (nodePoint->faction == TEAM_ALLIANCE ? GO_ALLIANCE_GUNSHIP_PORTAL : GO_HORDE_GUNSHIP_PORTAL), + BG_IC_HangarTeleporters[u].GetPositionX(), BG_IC_HangarTeleporters[u].GetPositionY(), + BG_IC_HangarTeleporters[u].GetPositionZ(), BG_IC_HangarTeleporters[u].GetOrientation(), + 0, 0, 0, 0, RESPAWN_ONE_DAY); + } - (nodePoint->faction == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde)->BuildStartMovePacket(GetBgMap()); - (nodePoint->faction == TEAM_ALLIANCE ? gunshipHorde : gunshipAlliance)->BuildStopMovePacket(GetBgMap()); - // we should spawn teleporters - break; - case BG_IC_GO_QUARRY_BANNER: - RemoveAuraOnTeam(SPELL_QUARRY, (nodePoint->faction == TEAM_ALLIANCE ? HORDE : ALLIANCE)); - CastSpellOnTeam(SPELL_QUARRY, (nodePoint->faction == TEAM_ALLIANCE ? ALLIANCE : HORDE)); - break; - case BG_IC_GO_REFINERY_BANNER: - RemoveAuraOnTeam(SPELL_OIL_REFINERY, (nodePoint->faction == TEAM_ALLIANCE ? HORDE : ALLIANCE)); - CastSpellOnTeam(SPELL_OIL_REFINERY, (nodePoint->faction == TEAM_ALLIANCE ? ALLIANCE : HORDE)); - break; - case BG_IC_GO_DOCKS_BANNER: + //sLog->outError("BG_IC_GO_HANGAR_BANNER CAPTURED Faction: %u", nodePoint->faction); - if (recapture) + (nodePoint->faction == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde)->BuildStartMovePacket(GetBgMap()); + (nodePoint->faction == TEAM_ALLIANCE ? gunshipHorde : gunshipAlliance)->BuildStopMovePacket(GetBgMap()); + // we should spawn teleporters break; + case BG_IC_GO_QUARRY_BANNER: + RemoveAuraOnTeam(SPELL_QUARRY, (nodePoint->faction == TEAM_ALLIANCE ? HORDE : ALLIANCE)); + CastSpellOnTeam(SPELL_QUARRY, (nodePoint->faction == TEAM_ALLIANCE ? ALLIANCE : HORDE)); + break; + case BG_IC_GO_REFINERY_BANNER: + RemoveAuraOnTeam(SPELL_OIL_REFINERY, (nodePoint->faction == TEAM_ALLIANCE ? HORDE : ALLIANCE)); + CastSpellOnTeam(SPELL_OIL_REFINERY, (nodePoint->faction == TEAM_ALLIANCE ? ALLIANCE : HORDE)); + break; + case BG_IC_GO_DOCKS_BANNER: - if (docksTimer < DOCKS_UPDATE_TIME) - docksTimer = DOCKS_UPDATE_TIME; + if (recapture) + break; - // we must del opposing faction vehicles when the node is captured (unused ones) - for (uint8 i = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_H : BG_IC_NPC_GLAIVE_THROWER_1_A); i < (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_2_H : BG_IC_NPC_GLAIVE_THROWER_2_A); i++) - { - if (Creature* glaiveThrower = GetBGCreature(i)) + if (docksTimer < DOCKS_UPDATE_TIME) + docksTimer = DOCKS_UPDATE_TIME; + + // we must del opposing faction vehicles when the node is captured (unused ones) + for (uint8 i = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_H : BG_IC_NPC_GLAIVE_THROWER_1_A); i < (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_2_H : BG_IC_NPC_GLAIVE_THROWER_2_A); i++) { - if (Vehicle* vehicleGlaive = glaiveThrower->GetVehicleKit()) + if (Creature* glaiveThrower = GetBGCreature(i)) { - if (!vehicleGlaive->GetPassenger(0)) - DelCreature(i); + if (Vehicle* vehicleGlaive = glaiveThrower->GetVehicleKit()) + { + if (!vehicleGlaive->GetPassenger(0)) + DelCreature(i); + } } } - } - for (uint8 i = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_H : BG_IC_NPC_CATAPULT_1_A); i < (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_4_H : BG_IC_NPC_CATAPULT_4_A); i++) - { - if (Creature* catapult = GetBGCreature(i)) + for (uint8 i = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_H : BG_IC_NPC_CATAPULT_1_A); i < (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_4_H : BG_IC_NPC_CATAPULT_4_A); i++) { - if (Vehicle* vehicleGlaive = catapult->GetVehicleKit()) + if (Creature* catapult = GetBGCreature(i)) { - if (!vehicleGlaive->GetPassenger(0)) - DelCreature(i); + if (Vehicle* vehicleGlaive = catapult->GetVehicleKit()) + { + if (!vehicleGlaive->GetPassenger(0)) + DelCreature(i); + } } } - } - // spawning glaive throwers - for (uint8 i = 0; i < MAX_GLAIVE_THROWERS_SPAWNS_PER_FACTION; i++) - { - uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_A : BG_IC_NPC_GLAIVE_THROWER_1_H)+i; + // spawning glaive throwers + for (uint8 i = 0; i < MAX_GLAIVE_THROWERS_SPAWNS_PER_FACTION; i++) + { + uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_A : BG_IC_NPC_GLAIVE_THROWER_1_H)+i; - if (GetBGCreature(type) && GetBGCreature(type)->isAlive()) - continue; + if (GetBGCreature(type) && GetBGCreature(type)->isAlive()) + continue; - if (AddCreature(nodePoint->faction == TEAM_ALLIANCE ? NPC_GLAIVE_THROWER_A : NPC_GLAIVE_THROWER_H, type, nodePoint->faction, - BG_IC_DocksVehiclesGlaives[i].GetPositionX(), BG_IC_DocksVehiclesGlaives[i].GetPositionY(), - BG_IC_DocksVehiclesGlaives[i].GetPositionZ(), BG_IC_DocksVehiclesGlaives[i].GetOrientation(), - RESPAWN_ONE_DAY)) - GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]); - } + if (AddCreature(nodePoint->faction == TEAM_ALLIANCE ? NPC_GLAIVE_THROWER_A : NPC_GLAIVE_THROWER_H, type, nodePoint->faction, + BG_IC_DocksVehiclesGlaives[i].GetPositionX(), BG_IC_DocksVehiclesGlaives[i].GetPositionY(), + BG_IC_DocksVehiclesGlaives[i].GetPositionZ(), BG_IC_DocksVehiclesGlaives[i].GetOrientation(), + RESPAWN_ONE_DAY)) + GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]); + } - // spawning catapults - for (uint8 i = 0; i < MAX_CATAPULTS_SPAWNS_PER_FACTION; i++) - { - uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_A : BG_IC_NPC_CATAPULT_1_H)+i; + // spawning catapults + for (uint8 i = 0; i < MAX_CATAPULTS_SPAWNS_PER_FACTION; i++) + { + uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_A : BG_IC_NPC_CATAPULT_1_H)+i; - if (GetBGCreature(type) && GetBGCreature(type)->isAlive()) - continue; + if (GetBGCreature(type) && GetBGCreature(type)->isAlive()) + continue; - if (AddCreature(NPC_CATAPULT, type, nodePoint->faction, - BG_IC_DocksVehiclesCatapults[i].GetPositionX(), BG_IC_DocksVehiclesCatapults[i].GetPositionY(), - BG_IC_DocksVehiclesCatapults[i].GetPositionZ(), BG_IC_DocksVehiclesCatapults[i].GetOrientation(), - RESPAWN_ONE_DAY)) - GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]); - } - break; - case BG_IC_GO_WORKSHOP_BANNER: - { - if (siegeEngineWorkshopTimer < WORKSHOP_UPDATE_TIME) - siegeEngineWorkshopTimer = WORKSHOP_UPDATE_TIME; - - if (!recapture) + if (AddCreature(NPC_CATAPULT, type, nodePoint->faction, + BG_IC_DocksVehiclesCatapults[i].GetPositionX(), BG_IC_DocksVehiclesCatapults[i].GetPositionY(), + BG_IC_DocksVehiclesCatapults[i].GetPositionZ(), BG_IC_DocksVehiclesCatapults[i].GetOrientation(), + RESPAWN_ONE_DAY)) + GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]); + } + break; + case BG_IC_GO_WORKSHOP_BANNER: { - // we must del opposing faction vehicles when the node is captured (unused ones) - for (uint8 i = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_1_H : BG_IC_NPC_DEMOLISHER_1_A); i < (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_4_H : BG_IC_NPC_DEMOLISHER_4_A); i++) + if (siegeEngineWorkshopTimer < WORKSHOP_UPDATE_TIME) + siegeEngineWorkshopTimer = WORKSHOP_UPDATE_TIME; + + if (!recapture) { - if (Creature* demolisher = GetBGCreature(i)) + // we must del opposing faction vehicles when the node is captured (unused ones) + for (uint8 i = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_1_H : BG_IC_NPC_DEMOLISHER_1_A); i < (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_4_H : BG_IC_NPC_DEMOLISHER_4_A); i++) { - if (Vehicle* vehicleDemolisher = demolisher->GetVehicleKit()) + if (Creature* demolisher = GetBGCreature(i)) { - // is IsVehicleInUse working as expected? - if (!vehicleDemolisher->IsVehicleInUse()) - DelCreature(i); + if (Vehicle* vehicleDemolisher = demolisher->GetVehicleKit()) + { + // is IsVehicleInUse working as expected? + if (!vehicleDemolisher->IsVehicleInUse()) + DelCreature(i); + } } } - } - for (uint8 i = 0; i < MAX_DEMOLISHERS_SPAWNS_PER_FACTION; i++) - { - uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_1_A : BG_IC_NPC_DEMOLISHER_1_H)+i; + for (uint8 i = 0; i < MAX_DEMOLISHERS_SPAWNS_PER_FACTION; i++) + { + uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_1_A : BG_IC_NPC_DEMOLISHER_1_H)+i; - if (GetBGCreature(type) && GetBGCreature(type)->isAlive()) - continue; + if (GetBGCreature(type) && GetBGCreature(type)->isAlive()) + continue; - if (AddCreature(NPC_DEMOLISHER, type, nodePoint->faction, - BG_IC_WorkshopVehicles[i].GetPositionX(), BG_IC_WorkshopVehicles[i].GetPositionY(), - BG_IC_WorkshopVehicles[i].GetPositionZ(), BG_IC_WorkshopVehicles[i].GetOrientation(), - RESPAWN_ONE_DAY)) - GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]); - } + if (AddCreature(NPC_DEMOLISHER, type, nodePoint->faction, + BG_IC_WorkshopVehicles[i].GetPositionX(), BG_IC_WorkshopVehicles[i].GetPositionY(), + BG_IC_WorkshopVehicles[i].GetPositionZ(), BG_IC_WorkshopVehicles[i].GetOrientation(), + RESPAWN_ONE_DAY)) + GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]); + } - // we check if the opossing siege engine is in use - int8 enemySiege = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_SIEGE_ENGINE_H : BG_IC_NPC_SIEGE_ENGINE_A); + // we check if the opossing siege engine is in use + int8 enemySiege = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_SIEGE_ENGINE_H : BG_IC_NPC_SIEGE_ENGINE_A); - if (Creature* siegeEngine = GetBGCreature(enemySiege)) - { - if (Vehicle* vehicleSiege = siegeEngine->GetVehicleKit()) + if (Creature* siegeEngine = GetBGCreature(enemySiege)) { - // is VehicleInUse working as expected ? - if (!vehicleSiege->IsVehicleInUse()) - DelCreature(enemySiege); + if (Vehicle* vehicleSiege = siegeEngine->GetVehicleKit()) + { + // is VehicleInUse working as expected ? + if (!vehicleSiege->IsVehicleInUse()) + DelCreature(enemySiege); + } } - } - uint8 siegeType = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_SIEGE_ENGINE_A : BG_IC_NPC_SIEGE_ENGINE_H); - if (!GetBGCreature(siegeType) || !GetBGCreature(siegeType)->isAlive()) - { - AddCreature((nodePoint->faction == TEAM_ALLIANCE ? NPC_SIEGE_ENGINE_A : NPC_SIEGE_ENGINE_H), siegeType, nodePoint->faction, - BG_IC_WorkshopVehicles[4].GetPositionX(), BG_IC_WorkshopVehicles[4].GetPositionY(), - BG_IC_WorkshopVehicles[4].GetPositionZ(), BG_IC_WorkshopVehicles[4].GetOrientation(), - RESPAWN_ONE_DAY); - - if (Creature* siegeEngine = GetBGCreature(siegeType)) + uint8 siegeType = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_SIEGE_ENGINE_A : BG_IC_NPC_SIEGE_ENGINE_H); + if (!GetBGCreature(siegeType) || !GetBGCreature(siegeType)->isAlive()) { - siegeEngine->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_UNK_14|UNIT_FLAG_OOC_NOT_ATTACKABLE); - siegeEngine->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]); + AddCreature((nodePoint->faction == TEAM_ALLIANCE ? NPC_SIEGE_ENGINE_A : NPC_SIEGE_ENGINE_H), siegeType, nodePoint->faction, + BG_IC_WorkshopVehicles[4].GetPositionX(), BG_IC_WorkshopVehicles[4].GetPositionY(), + BG_IC_WorkshopVehicles[4].GetPositionZ(), BG_IC_WorkshopVehicles[4].GetOrientation(), + RESPAWN_ONE_DAY); + + if (Creature* siegeEngine = GetBGCreature(siegeType)) + { + siegeEngine->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_UNK_14|UNIT_FLAG_OOC_NOT_ATTACKABLE); + siegeEngine->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]); + } } } - } - for (uint8 i = 0; i < MAX_WORKSHOP_BOMBS_SPAWNS_PER_FACTION; i++) - { - AddObject(BG_IC_GO_SEAFORIUM_BOMBS_1+i, GO_SEAFORIUM_BOMBS, - workshopBombs[i].GetPositionX(), workshopBombs[i].GetPositionY(), - workshopBombs[i].GetPositionZ(), workshopBombs[i].GetOrientation(), - 0, 0, 0, 0, 10); - - if (GameObject* seaforiumBombs = GetBGObject(BG_IC_GO_SEAFORIUM_BOMBS_1+i)) + for (uint8 i = 0; i < MAX_WORKSHOP_BOMBS_SPAWNS_PER_FACTION; i++) { - seaforiumBombs->SetRespawnTime(10); - seaforiumBombs->SetUInt32Value(GAMEOBJECT_FACTION, BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]); + AddObject(BG_IC_GO_SEAFORIUM_BOMBS_1+i, GO_SEAFORIUM_BOMBS, + workshopBombs[i].GetPositionX(), workshopBombs[i].GetPositionY(), + workshopBombs[i].GetPositionZ(), workshopBombs[i].GetOrientation(), + 0, 0, 0, 0, 10); + + if (GameObject* seaforiumBombs = GetBGObject(BG_IC_GO_SEAFORIUM_BOMBS_1+i)) + { + seaforiumBombs->SetRespawnTime(10); + seaforiumBombs->SetUInt32Value(GAMEOBJECT_FACTION, BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]); + } } + break; } + default: break; - } - default: - break; } } @@ -855,7 +855,7 @@ void BattlegroundIC::DestroyGate(Player* player, GameObject* go) SendMessage2ToAll(lang_entry, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL, (player->GetTeamId() == TEAM_ALLIANCE ? LANG_BG_IC_HORDE_KEEP : LANG_BG_IC_ALLIANCE_KEEP)); } -void BattlegroundIC::EventPlayerDamagedGO(Player* /*plr*/, GameObject* /*go*/, uint32 /*eventType*/) +void BattlegroundIC::EventPlayerDamagedGO(Player* /*player*/, GameObject* /*go*/, uint32 /*eventType*/) { } @@ -903,7 +903,7 @@ Transport* BattlegroundIC::CreateTransport(uint32 goEntry, uint32 period) { Transport* t = new Transport(period, 0); - const GameObjectTemplate* goinfo = sObjectMgr->GetGameObjectTemplate(goEntry); + GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(goEntry); if (!goinfo) { diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h index efa91559ca6..552b79ce608 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h @@ -93,7 +93,6 @@ enum gameobjectsIC GO_FLAGPOLE_1 = 195131, GO_FLAGPOLE_2 = 195439, - GO_FLAGPOLE_3 = 195131, GO_GUNSHIP_PORTAL_1 = 195371, GO_GUNSHIP_PORTAL_2 = 196413, @@ -270,6 +269,7 @@ enum BG_IC_GOs BG_IC_GO_FLAGPOLE_1_3, BG_IC_GO_FLAGPOLE_1_4, BG_IC_GO_FLAGPOLE_1_5, + BG_IC_GO_FLAGPOLE_1_6, BG_IC_GO_HANGAR_BANNER, @@ -624,6 +624,7 @@ const ICGo BG_IC_ObjSpawnlocs[MAX_NORMAL_GAMEOBJECTS_SPAWNS] = {BG_IC_GO_FLAGPOLE_1_3, GO_FLAGPOLE_1, 807.78f, -1000.07f, 132.381f, -1.91986f}, // Flagpole {BG_IC_GO_FLAGPOLE_1_4, GO_FLAGPOLE_1, 776.229f, -804.283f, 6.45052f, 1.6057f}, // Flagpole {BG_IC_GO_FLAGPOLE_1_5, GO_FLAGPOLE_1, 251.016f, -1159.32f, 17.2376f, -2.25147f}, // Flagpole + {BG_IC_GO_FLAGPOLE_1_6, GO_FLAGPOLE_1, 1269.502f, -400.809f, 37.62525f, -1.762782f}, // Flagpole {BG_IC_GO_HORDE_KEEP_PORTCULLIS, GO_HORDE_KEEP_PORTCULLIS, 1283.05f, -765.878f, 50.8297f, -3.13286f}, // Horde Keep Portcullis @@ -862,12 +863,12 @@ class BattlegroundIC : public Battleground ~BattlegroundIC(); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player* plr); + virtual void AddPlayer(Player* player); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); virtual void PostUpdateImpl(uint32 diff); - void RemovePlayer(Player* plr, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team); void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleground(); void SpawnLeader(uint32 teamid); @@ -876,7 +877,7 @@ class BattlegroundIC : public Battleground void EndBattleground(uint32 winner); void EventPlayerClickedOnFlag(Player* source, GameObject* /*target_obj*/); - void EventPlayerDamagedGO(Player* /*plr*/, GameObject* go, uint32 eventType); + void EventPlayerDamagedGO(Player* /*player*/, GameObject* go, uint32 eventType); void DestroyGate(Player* player, GameObject* go); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp index 58dc20c30cb..37fdd2559c4 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp @@ -59,18 +59,18 @@ void BattlegroundNA::StartingEventOpenDoors() SpawnBGObject(i, 60); } -void BattlegroundNA::AddPlayer(Player* plr) +void BattlegroundNA::AddPlayer(Player* player) { - Battleground::AddPlayer(plr); + Battleground::AddPlayer(player); //create score and add it to map, default values are set in constructor BattlegroundNAScore* sc = new BattlegroundNAScore; - m_PlayerScores[plr->GetGUID()] = sc; + m_PlayerScores[player->GetGUID()] = sc; UpdateArenaWorldState(); } -void BattlegroundNA::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/) +void BattlegroundNA::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/) { if (GetStatus() == STATUS_WAIT_LEAVE) return; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundNA.h b/src/server/game/Battlegrounds/Zones/BattlegroundNA.h index beddbaaeedf..e7fe08063a4 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundNA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundNA.h @@ -56,16 +56,16 @@ class BattlegroundNA : public Battleground ~BattlegroundNA(); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player* plr); + virtual void AddPlayer(Player* player); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player* plr, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team); void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleground(); virtual void Reset(); virtual void FillInitialWorldStates(WorldPacket &d); void HandleKillPlayer(Player* player, Player* killer); - bool HandlePlayerUnderMap(Player* plr); + bool HandlePlayerUnderMap(Player* player); }; #endif diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRB.cpp index e2d64aa39f7..ba4d787b215 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRB.cpp @@ -43,16 +43,16 @@ void BattlegroundRB::StartingEventOpenDoors() { } -void BattlegroundRB::AddPlayer(Player* plr) +void BattlegroundRB::AddPlayer(Player* player) { - Battleground::AddPlayer(plr); + Battleground::AddPlayer(player); //create score and add it to map, default values are set in constructor BattlegroundRBScore* sc = new BattlegroundRBScore; - m_PlayerScores[plr->GetGUID()] = sc; + m_PlayerScores[player->GetGUID()] = sc; } -void BattlegroundRB::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/) +void BattlegroundRB::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/) { } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRB.h b/src/server/game/Battlegrounds/Zones/BattlegroundRB.h index 0878654d7dd..ef6283ed96a 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRB.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRB.h @@ -34,11 +34,11 @@ class BattlegroundRB : public Battleground BattlegroundRB(); ~BattlegroundRB(); - virtual void AddPlayer(Player* plr); + virtual void AddPlayer(Player* player); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player* plr, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team); void HandleAreaTrigger(Player* Source, uint32 Trigger); /* Scorekeeping */ diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp index 8ede4a6329c..3d1ebe8fec9 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp @@ -59,18 +59,18 @@ void BattlegroundRL::StartingEventOpenDoors() SpawnBGObject(i, 60); } -void BattlegroundRL::AddPlayer(Player* plr) +void BattlegroundRL::AddPlayer(Player* player) { - Battleground::AddPlayer(plr); + Battleground::AddPlayer(player); //create score and add it to map, default values are set in constructor BattlegroundRLScore* sc = new BattlegroundRLScore; - m_PlayerScores[plr->GetGUID()] = sc; + m_PlayerScores[player->GetGUID()] = sc; UpdateArenaWorldState(); } -void BattlegroundRL::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/) +void BattlegroundRL::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/) { if (GetStatus() == STATUS_WAIT_LEAVE) return; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRL.h b/src/server/game/Battlegrounds/Zones/BattlegroundRL.h index 52ce7d3ca40..5528d0ccf9e 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRL.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRL.h @@ -52,16 +52,16 @@ class BattlegroundRL : public Battleground ~BattlegroundRL(); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player* plr); + virtual void AddPlayer(Player* player); virtual void Reset(); virtual void FillInitialWorldStates(WorldPacket &d); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player* plr, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team); void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleground(); void HandleKillPlayer(Player* player, Player* killer); - bool HandlePlayerUnderMap(Player* plr); + bool HandlePlayerUnderMap(Player* player); }; #endif diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp index 81a75c23cb5..0c44c5d3d96 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp @@ -102,19 +102,19 @@ void BattlegroundRV::StartingEventOpenDoors() setTimer(BG_RV_FIRST_TIMER); } -void BattlegroundRV::AddPlayer(Player* plr) +void BattlegroundRV::AddPlayer(Player* player) { - Battleground::AddPlayer(plr); + Battleground::AddPlayer(player); //create score and add it to map, default values are set in constructor BattlegroundRVScore* sc = new BattlegroundRVScore; - m_PlayerScores[plr->GetGUID()] = sc; + m_PlayerScores[player->GetGUID()] = sc; UpdateWorldState(BG_RV_WORLD_STATE_A, GetAlivePlayersCountByTeam(ALLIANCE)); UpdateWorldState(BG_RV_WORLD_STATE_H, GetAlivePlayersCountByTeam(HORDE)); } -void BattlegroundRV::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/) +void BattlegroundRV::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/) { if (GetStatus() == STATUS_WAIT_LEAVE) return; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRV.h b/src/server/game/Battlegrounds/Zones/BattlegroundRV.h index 9a6efe64524..70417c1dfce 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRV.h @@ -105,17 +105,17 @@ class BattlegroundRV : public Battleground ~BattlegroundRV(); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player* plr); + virtual void AddPlayer(Player* player); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); virtual void Reset(); virtual void FillInitialWorldStates(WorldPacket &d); - void RemovePlayer(Player* plr, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team); void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleground(); void HandleKillPlayer(Player* player, Player* killer); - bool HandlePlayerUnderMap(Player* plr); + bool HandlePlayerUnderMap(Player* player); private: uint32 Timer; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index c214ac21068..aaa29e1ca20 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -62,8 +62,8 @@ bool BattlegroundSA::SetupBattleground() bool BattlegroundSA::ResetObjs() { for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) - if (Player* plr = ObjectAccessor::FindPlayer(itr->first)) - SendTransportsRemove(plr); + if (Player* player = ObjectAccessor::FindPlayer(itr->first)) + SendTransportsRemove(player); uint32 atF = BG_SA_Factions[Attackers]; uint32 defF = BG_SA_Factions[Attackers ? TEAM_ALLIANCE : TEAM_HORDE]; @@ -245,8 +245,8 @@ bool BattlegroundSA::ResetObjs() for (int i = BG_SA_BOAT_ONE; i <= BG_SA_BOAT_TWO; i++) for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) - if (Player* plr = ObjectAccessor::FindPlayer(itr->first)) - SendTransportInit(plr); + if (Player* player = ObjectAccessor::FindPlayer(itr->first)) + SendTransportInit(player); TeleportPlayers(); return true; @@ -431,39 +431,39 @@ void BattlegroundSA::FillInitialWorldStates(WorldPacket& data) data << uint32(BG_SA_LEFT_ATT_TOKEN_ALL) << ally_attacks; } -void BattlegroundSA::AddPlayer(Player* plr) +void BattlegroundSA::AddPlayer(Player* player) { - Battleground::AddPlayer(plr); + Battleground::AddPlayer(player); //create score and add it to map, default values are set in constructor BattlegroundSAScore* sc = new BattlegroundSAScore; if (!ShipsStarted) { - if (plr->GetTeamId() == Attackers) + if (player->GetTeamId() == Attackers) { - plr->CastSpell(plr, 12438, true);//Without this player falls before boat loads... + player->CastSpell(player, 12438, true);//Without this player falls before boat loads... if (urand(0, 1)) - plr->TeleportTo(607, 2682.936f, -830.368f, 50.0f, 2.895f, 0); + player->TeleportTo(607, 2682.936f, -830.368f, 50.0f, 2.895f, 0); else - plr->TeleportTo(607, 2577.003f, 980.261f, 50.0f, 0.807f, 0); + player->TeleportTo(607, 2577.003f, 980.261f, 50.0f, 0.807f, 0); } else - plr->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0); + player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0); } else { - if (plr->GetTeamId() == Attackers) - plr->TeleportTo(607, 1600.381f, -106.263f, 8.8745f, 3.78f, 0); + if (player->GetTeamId() == Attackers) + player->TeleportTo(607, 1600.381f, -106.263f, 8.8745f, 3.78f, 0); else - plr->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0); + player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0); } - SendTransportInit(plr); - m_PlayerScores[plr->GetGUID()] = sc; + SendTransportInit(player); + m_PlayerScores[player->GetGUID()] = sc; } -void BattlegroundSA::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/) +void BattlegroundSA::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/) { } @@ -492,37 +492,37 @@ void BattlegroundSA::TeleportPlayers() { for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) { - if (Player* plr = ObjectAccessor::FindPlayer(itr->first)) + if (Player* player = ObjectAccessor::FindPlayer(itr->first)) { // should remove spirit of redemption - if (plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) - plr->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT); + if (player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) + player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT); - if (!plr->isAlive()) + if (!player->isAlive()) { - plr->ResurrectPlayer(1.0f); - plr->SpawnCorpseBones(); + player->ResurrectPlayer(1.0f); + player->SpawnCorpseBones(); } - plr->ResetAllPowers(); - plr->CombatStopWithPets(true); + player->ResetAllPowers(); + player->CombatStopWithPets(true); - if (plr->GetTeamId() == Attackers) + if (player->GetTeamId() == Attackers) { - plr->CastSpell(plr, 12438, true); //Without this player falls before boat loads... + player->CastSpell(player, 12438, true); //Without this player falls before boat loads... if (urand(0, 1)) - plr->TeleportTo(607, 2682.936f, -830.368f, 50.0f, 2.895f, 0); + player->TeleportTo(607, 2682.936f, -830.368f, 50.0f, 2.895f, 0); else - plr->TeleportTo(607, 2577.003f, 980.261f, 50.0f, 0.807f, 0); + player->TeleportTo(607, 2577.003f, 980.261f, 50.0f, 0.807f, 0); } else - plr->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0); + player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0); } } } -void BattlegroundSA::EventPlayerDamagedGO(Player* /*plr*/, GameObject* go, uint32 eventType) +void BattlegroundSA::EventPlayerDamagedGO(Player* /*player*/, GameObject* go, uint32 eventType) { if (!go || !go->GetGOInfo()) return; @@ -798,9 +798,9 @@ void BattlegroundSA::EventPlayerUsedGO(Player* Source, GameObject* object) //Achievement Storm the Beach (1310) for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) { - if (Player* plr = ObjectAccessor::FindPlayer(itr->first)) - if (plr->GetTeamId() == Attackers) - plr->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 65246); + if (Player* player = ObjectAccessor::FindPlayer(itr->first)) + if (player->GetTeamId() == Attackers) + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 65246); } Attackers = (Attackers == TEAM_ALLIANCE) ? TEAM_HORDE : TEAM_ALLIANCE; @@ -822,9 +822,9 @@ void BattlegroundSA::EventPlayerUsedGO(Player* Source, GameObject* object) //Achievement Storm the Beach (1310) for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) { - if (Player* plr = ObjectAccessor::FindPlayer(itr->first)) - if (plr->GetTeamId() == Attackers && RoundScores[1].winner == Attackers) - plr->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 65246); + if (Player* player = ObjectAccessor::FindPlayer(itr->first)) + if (player->GetTeamId() == Attackers && RoundScores[1].winner == Attackers) + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 65246); } if (RoundScores[0].time == RoundScores[1].time) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h index 5f01d0fac4d..8b446fccb9e 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h @@ -423,7 +423,7 @@ class BattlegroundSA : public Battleground /* inherited from BattlegroundClass */ /// Called when a player join battle - virtual void AddPlayer(Player* plr); + virtual void AddPlayer(Player* player); /// Called when battle start virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); @@ -433,7 +433,7 @@ class BattlegroundSA : public Battleground /// Called for generate packet contain worldstate data virtual void FillInitialWorldStates(WorldPacket& data); /// Called when a player deal damage to building (door) - virtual void EventPlayerDamagedGO(Player* plr, GameObject* go, uint32 eventType); + virtual void EventPlayerDamagedGO(Player* player, GameObject* go, uint32 eventType); /// Called when a player kill a unit in bg virtual void HandleKillUnit(Creature* unit, Player* killer); /// Return the nearest graveyard where player can respawn @@ -477,7 +477,7 @@ class BattlegroundSA : public Battleground void EndBattleground(uint32 winner); /// CAlled when a player leave battleground - void RemovePlayer(Player* plr, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team); void HandleAreaTrigger(Player* Source, uint32 Trigger); /* Scorekeeping */ diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp index 951fe8f6b51..a6aa6f41db2 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp @@ -140,23 +140,23 @@ void BattlegroundWS::PostUpdateImpl(uint32 diff) m_FlagSpellForceTimer += diff; if (m_FlagDebuffState == 0 && m_FlagSpellForceTimer >= 600000) //10 minutes { - if (Player* plr = ObjectAccessor::FindPlayer(m_FlagKeepers[0])) - plr->CastSpell(plr, WS_SPELL_FOCUSED_ASSAULT, true); - if (Player* plr = ObjectAccessor::FindPlayer(m_FlagKeepers[1])) - plr->CastSpell(plr, WS_SPELL_FOCUSED_ASSAULT, true); + if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[0])) + player->CastSpell(player, WS_SPELL_FOCUSED_ASSAULT, true); + if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[1])) + player->CastSpell(player, WS_SPELL_FOCUSED_ASSAULT, true); m_FlagDebuffState = 1; } else if (m_FlagDebuffState == 1 && m_FlagSpellForceTimer >= 900000) //15 minutes { - if (Player* plr = ObjectAccessor::FindPlayer(m_FlagKeepers[0])) + if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[0])) { - plr->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); - plr->CastSpell(plr, WS_SPELL_BRUTAL_ASSAULT, true); + player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); + player->CastSpell(player, WS_SPELL_BRUTAL_ASSAULT, true); } - if (Player* plr = ObjectAccessor::FindPlayer(m_FlagKeepers[1])) + if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[1])) { - plr->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); - plr->CastSpell(plr, WS_SPELL_BRUTAL_ASSAULT, true); + player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); + player->CastSpell(player, WS_SPELL_BRUTAL_ASSAULT, true); } m_FlagDebuffState = 2; } @@ -202,13 +202,13 @@ void BattlegroundWS::StartingEventOpenDoors() StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, WS_EVENT_START_BATTLE); } -void BattlegroundWS::AddPlayer(Player* plr) +void BattlegroundWS::AddPlayer(Player* player) { - Battleground::AddPlayer(plr); + Battleground::AddPlayer(player); //create score and add it to map, default values are set in constructor BattlegroundWGScore* sc = new BattlegroundWGScore; - m_PlayerScores[plr->GetGUID()] = sc; + m_PlayerScores[player->GetGUID()] = sc; } void BattlegroundWS::RespawnFlag(uint32 Team, bool captured) @@ -556,30 +556,30 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); } -void BattlegroundWS::RemovePlayer(Player* plr, uint64 guid, uint32 /*team*/) +void BattlegroundWS::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/) { // sometimes flag aura not removed :( if (IsAllianceFlagPickedup() && m_FlagKeepers[BG_TEAM_ALLIANCE] == guid) { - if (!plr) + if (!player) { sLog->outError("BattlegroundWS: Removing offline player who has the FLAG!!"); this->SetAllianceFlagPicker(0); this->RespawnFlag(ALLIANCE, false); } else - this->EventPlayerDroppedFlag(plr); + this->EventPlayerDroppedFlag(player); } if (IsHordeFlagPickedup() && m_FlagKeepers[BG_TEAM_HORDE] == guid) { - if (!plr) + if (!player) { sLog->outError("BattlegroundWS: Removing offline player who has the FLAG!!"); this->SetHordeFlagPicker(0); this->RespawnFlag(HORDE, false); } else - this->EventPlayerDroppedFlag(plr); + this->EventPlayerDroppedFlag(player); } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h index 386cc6945e8..b3c2c88c306 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h @@ -163,7 +163,7 @@ class BattlegroundWS : public Battleground ~BattlegroundWS(); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player* plr); + virtual void AddPlayer(Player* player); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); @@ -187,7 +187,7 @@ class BattlegroundWS : public Battleground virtual void EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj); virtual void EventPlayerCapturedFlag(Player* Source); - void RemovePlayer(Player* plr, uint64 guid, uint32 team); + void RemovePlayer(Player* player, uint64 guid, uint32 team); void HandleAreaTrigger(Player* Source, uint32 Trigger); void HandleKillPlayer(Player* player, Player* killer); bool SetupBattleground(); diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index 413070ca1de..7717d319bb0 100755 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -169,22 +169,22 @@ void Channel::Join(uint64 p, const char *pass) return; } - Player* plr = ObjectAccessor::FindPlayer(p); + Player* player = ObjectAccessor::FindPlayer(p); - if (plr) + if (player) { if (HasFlag(CHANNEL_FLAG_LFG) && - sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(plr->GetSession()->GetSecurity()) && plr->GetGroup()) + sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && player->GetGroup()) { MakeNotInLfg(&data); SendToOne(&data, p); return; } - plr->JoinedChannel(this); + player->JoinedChannel(this); } - if (m_announce && (!plr || !AccountMgr::IsGMAccount(plr->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) + if (m_announce && (!player || !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { MakeJoined(&data, p); SendToAll(&data); @@ -231,22 +231,22 @@ void Channel::Leave(uint64 p, bool send) } else { - Player* plr = ObjectAccessor::FindPlayer(p); + Player* player = ObjectAccessor::FindPlayer(p); if (send) { WorldPacket data; MakeYouLeft(&data); SendToOne(&data, p); - if (plr) - plr->LeftChannel(this); + if (player) + player->LeftChannel(this); data.clear(); } bool changeowner = players[p].IsOwner(); players.erase(p); - if (m_announce && (!plr || !AccountMgr::IsGMAccount(plr->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) + if (m_announce && (!player || !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { WorldPacket data; MakeLeft(&data, p); @@ -379,11 +379,11 @@ void Channel::UnBan(uint64 good, const char *badname) void Channel::Password(uint64 p, const char *pass) { uint32 sec = 0; - Player* plr = ObjectAccessor::FindPlayer(p); - if (plr) - sec = plr->GetSession()->GetSecurity(); + Player* player = ObjectAccessor::FindPlayer(p); + if (player) + sec = player->GetSession()->GetSecurity(); - ChatHandler chat(plr); + ChatHandler chat(player); if (!IsOn(p)) { @@ -411,11 +411,11 @@ void Channel::Password(uint64 p, const char *pass) void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) { - Player* plr = ObjectAccessor::FindPlayer(p); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(p); + if (!player) return; - uint32 sec = plr->GetSession()->GetSecurity(); + uint32 sec = player->GetSession()->GetSecurity(); if (!IsOn(p)) { @@ -453,8 +453,8 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) // allow make moderator from another team only if both is GMs // at this moment this only way to show channel post for GM from another team - if ((!AccountMgr::IsGMAccount(plr->GetSession()->GetSecurity()) || !AccountMgr::IsGMAccount(newp->GetSession()->GetSecurity())) && - plr->GetTeam() != newp->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) + if ((!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !AccountMgr::IsGMAccount(newp->GetSession()->GetSecurity())) && + player->GetTeam() != newp->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) { WorldPacket data; MakePlayerNotFound(&data, p2n); @@ -479,11 +479,11 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) void Channel::SetOwner(uint64 p, const char *newname) { - Player* plr = ObjectAccessor::FindPlayer(p); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(p); + if (!player) return; - uint32 sec = plr->GetSession()->GetSecurity(); + uint32 sec = player->GetSession()->GetSecurity(); if (!IsOn(p)) { @@ -510,7 +510,7 @@ void Channel::SetOwner(uint64 p, const char *newname) return; } - if (newp->GetTeam() != plr->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) + if (newp->GetTeam() != player->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) { WorldPacket data; MakePlayerNotFound(&data, newname); @@ -563,12 +563,12 @@ void Channel::List(Player* player) uint32 count = 0; for (PlayerList::const_iterator i = players.begin(); i != players.end(); ++i) { - Player* plr = ObjectAccessor::FindPlayer(i->first); + Player* player = ObjectAccessor::FindPlayer(i->first); // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // MODERATOR, GAME MASTER, ADMINISTRATOR can see all - if (plr && (!AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) || plr->GetSession()->GetSecurity() <= AccountTypes(gmLevelInWhoList)) && - plr->IsVisibleGloballyFor(player)) + if (player && (!AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) || player->GetSession()->GetSecurity() <= AccountTypes(gmLevelInWhoList)) && + player->IsVisibleGloballyFor(player)) { data << uint64(i->first); data << uint8(i->second.flags); // flags seems to be changed... @@ -585,9 +585,9 @@ void Channel::List(Player* player) void Channel::Announce(uint64 p) { uint32 sec = 0; - Player* plr = ObjectAccessor::FindPlayer(p); - if (plr) - sec = plr->GetSession()->GetSecurity(); + Player* player = ObjectAccessor::FindPlayer(p); + if (player) + sec = player->GetSession()->GetSecurity(); if (!IsOn(p)) { @@ -623,7 +623,7 @@ void Channel::Say(uint64 p, const char *what, uint32 lang) if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) lang = LANG_UNIVERSAL; - Player* plr = ObjectAccessor::FindPlayer(p); + Player* player = ObjectAccessor::FindPlayer(p); if (!IsOn(p)) { @@ -650,7 +650,7 @@ void Channel::Say(uint64 p, const char *what, uint32 lang) data << p; data << messageLength; data << what; - data << uint8(plr ? plr->chatTag() : 0); + data << uint8(player ? player->GetChatTag() : 0); SendToAll(&data, !players[p].IsModerator() ? p : false); } @@ -683,11 +683,11 @@ void Channel::Invite(uint64 p, const char *newname) return; } - Player* plr = ObjectAccessor::FindPlayer(p); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(p); + if (!player) return; - if (newp->GetTeam() != plr->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) + if (newp->GetTeam() != player->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) { WorldPacket data; MakeInviteWrongFaction(&data); @@ -749,11 +749,11 @@ void Channel::SendToAll(WorldPacket* data, uint64 p) { for (PlayerList::const_iterator i = players.begin(); i != players.end(); ++i) { - Player* plr = ObjectAccessor::FindPlayer(i->first); - if (plr) + Player* player = ObjectAccessor::FindPlayer(i->first); + if (player) { - if (!p || !plr->GetSocial()->HasIgnore(GUID_LOPART(p))) - plr->GetSession()->SendPacket(data); + if (!p || !player->GetSocial()->HasIgnore(GUID_LOPART(p))) + player->GetSession()->SendPacket(data); } } } @@ -764,18 +764,18 @@ void Channel::SendToAllButOne(WorldPacket* data, uint64 who) { if (i->first != who) { - Player* plr = ObjectAccessor::FindPlayer(i->first); - if (plr) - plr->GetSession()->SendPacket(data); + Player* player = ObjectAccessor::FindPlayer(i->first); + if (player) + player->GetSession()->SendPacket(data); } } } void Channel::SendToOne(WorldPacket* data, uint64 who) { - Player* plr = ObjectAccessor::FindPlayer(who); - if (plr) - plr->GetSession()->SendPacket(data); + Player* player = ObjectAccessor::FindPlayer(who); + if (player) + player->GetSession()->SendPacket(data); } void Channel::Voice(uint64 /*guid1*/, uint64 /*guid2*/) diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 8d03530c7f9..be43862eaea 100755 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -1051,7 +1051,7 @@ void ChatHandler::FillMessageData(WorldPacket* data, WorldSession* session, uint *data << uint32(messageLength); *data << message; if (session != 0 && type != CHAT_MSG_WHISPER_INFORM && type != CHAT_MSG_DND && type != CHAT_MSG_AFK) - *data << uint8(session->GetPlayer()->chatTag()); + *data << uint8(session->GetPlayer()->GetChatTag()); else *data << uint8(0); } @@ -1224,7 +1224,7 @@ GameObject* ChatHandler::GetNearbyGameObject() GameObject* obj = NULL; Trinity::NearestGameObjectCheck check(*pl); Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectCheck> searcher(pl, obj, check); - pl->VisitNearbyGridObject(999, searcher); + pl->VisitNearbyGridObject(SIZE_OF_GRIDS, searcher); return obj; } @@ -1240,15 +1240,14 @@ GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid if (!obj && sObjectMgr->GetGOData(lowguid)) // guid is DB guid of object { // search near player then - CellPair p(Trinity::ComputeCellPair(pl->GetPositionX(), pl->GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(pl->GetPositionX(), pl->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; Trinity::GameObjectWithDbGUIDCheck go_check(*pl, lowguid); Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(pl, obj, go_check); TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker); - cell.Visit(p, object_checker, *pl->GetMap()); + cell.Visit(p, object_checker, *pl->GetMap(), *pl, pl->GetGridActivationRange()); } return obj; @@ -1552,9 +1551,9 @@ bool CliHandler::needReportToTarget(Player* /*chr*/) const return true; } -bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &plr, Group* &group, uint64 &guid, bool offline) +bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &player, Group* &group, uint64 &guid, bool offline) { - plr = NULL; + player = NULL; guid = 0; if (cname) @@ -1569,28 +1568,28 @@ bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &plr, G return false; } - plr = sObjectAccessor->FindPlayerByName(name.c_str()); + player = sObjectAccessor->FindPlayerByName(name.c_str()); if (offline) guid = sObjectMgr->GetPlayerGUIDByName(name.c_str()); } } - if (plr) + if (player) { - group = plr->GetGroup(); + group = player->GetGroup(); if (!guid || !offline) - guid = plr->GetGUID(); + guid = player->GetGUID(); } else { if (getSelectedPlayer()) - plr = getSelectedPlayer(); + player = getSelectedPlayer(); else - plr = m_session->GetPlayer(); + player = m_session->GetPlayer(); if (!guid || !offline) - guid = plr->GetGUID(); - group = plr->GetGroup(); + guid = player->GetGUID(); + group = player->GetGroup(); } return true; diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index 6e34e39af5a..24652fcc6d5 100755 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -109,7 +109,7 @@ class ChatHandler uint32 extractSpellIdFromLink(char* text); uint64 extractGuidFromLink(char* text); GameTele const* extractGameTeleFromLink(char* text); - bool GetPlayerGroupAndGUIDByName(const char* cname, Player* &plr, Group* &group, uint64 &guid, bool offline = false); + bool GetPlayerGroupAndGUIDByName(const char* cname, Player* &player, Group* &group, uint64 &guid, bool offline = false); std::string extractPlayerNameFromLink(char* text); // select by arg (name/link) or in-game selection online/offline player bool extractPlayerTarget(char* args, Player** player, uint64* player_guid = NULL, std::string* player_name = NULL); diff --git a/src/server/game/Chat/Commands/Level1.cpp b/src/server/game/Chat/Commands/Level1.cpp index c737e2b0b54..f06f8a7e89c 100755 --- a/src/server/game/Chat/Commands/Level1.cpp +++ b/src/server/game/Chat/Commands/Level1.cpp @@ -713,18 +713,18 @@ bool ChatHandler::HandleGroupSummonCommand(const char* args) for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* pl = itr->getSource(); + Player* player = itr->getSource(); - if (!pl || pl == m_session->GetPlayer() || !pl->GetSession()) + if (!player || player == m_session->GetPlayer() || !player->GetSession()) continue; // check online security - if (HasLowerSecurity(pl, 0)) + if (HasLowerSecurity(player, 0)) return false; - std::string plNameLink = GetNameLink(pl); + std::string plNameLink = GetNameLink(player); - if (pl->IsBeingTeleported() == true) + if (player->IsBeingTeleported() == true) { PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str()); SetSentErrorMessage(true); @@ -733,7 +733,7 @@ bool ChatHandler::HandleGroupSummonCommand(const char* args) if (to_instance) { - Map* plMap = pl->GetMap(); + Map* plMap = player->GetMap(); if (plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId()) { @@ -745,23 +745,23 @@ bool ChatHandler::HandleGroupSummonCommand(const char* args) } PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), ""); - if (needReportToTarget(pl)) - ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, GetNameLink().c_str()); + if (needReportToTarget(player)) + ChatHandler(player).PSendSysMessage(LANG_SUMMONED_BY, GetNameLink().c_str()); // stop flight if need - if (pl->isInFlight()) + if (player->isInFlight()) { - pl->GetMotionMaster()->MovementExpired(); - pl->CleanupAfterTaxiFlight(); + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); } // save only in non-flight case else - pl->SaveRecallPosition(); + player->SaveRecallPosition(); // before GM float x, y, z; - m_session->GetPlayer()->GetClosePoint(x, y, z, pl->GetObjectSize()); - pl->TeleportTo(m_session->GetPlayer()->GetMapId(), x, y, z, pl->GetOrientation()); + m_session->GetPlayer()->GetClosePoint(x, y, z, player->GetObjectSize()); + player->TeleportTo(m_session->GetPlayer()->GetMapId(), x, y, z, player->GetOrientation()); } return true; diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp index 9e772e2cde7..763f3654860 100755 --- a/src/server/game/Chat/Commands/Level2.cpp +++ b/src/server/game/Chat/Commands/Level2.cpp @@ -895,7 +895,7 @@ bool ChatHandler::HandleCreatePetCommand(const char* /*args*/) pet->InitPetCreateSpells(); pet->SetFullHealth(); - pet->GetMap()->Add(pet->ToCreature()); + pet->GetMap()->AddToMap(pet->ToCreature()); // visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel()); @@ -912,8 +912,8 @@ bool ChatHandler::HandlePetLearnCommand(const char* args) if (!*args) return false; - Player* plr = m_session->GetPlayer(); - Pet* pet = plr->GetPet(); + Player* player = m_session->GetPlayer(); + Pet* pet = player->GetPet(); if (!pet) { @@ -955,8 +955,8 @@ bool ChatHandler::HandlePetUnlearnCommand(const char *args) if (!*args) return false; - Player* plr = m_session->GetPlayer(); - Pet* pet = plr->GetPet(); + Player* player = m_session->GetPlayer(); + Pet* pet = player->GetPet(); if (!pet) { diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp index e76cbfcc76b..f4f5892b587 100755 --- a/src/server/game/Chat/Commands/Level3.cpp +++ b/src/server/game/Chat/Commands/Level3.cpp @@ -256,10 +256,10 @@ bool ChatHandler::HandleAddItemCommand(const char *args) if (count == 0) count = 1; - Player* pl = m_session->GetPlayer(); + Player* player = m_session->GetPlayer(); Player* plTarget = getSelectedPlayer(); if (!plTarget) - plTarget = pl; + plTarget = player; sLog->outDetail(GetTrinityString(LANG_ADDITEM), itemId, count); @@ -298,15 +298,15 @@ bool ChatHandler::HandleAddItemCommand(const char *args) Item* item = plTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); // remove binding (let GM give it to another player later) - if (pl == plTarget) + if (player == plTarget) for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) - if (Item* item1 = pl->GetItemByPos(itr->pos)) + if (Item* item1 = player->GetItemByPos(itr->pos)) item1->SetBinding(false); if (count > 0 && item) { - pl->SendNewItem(item, count, false, true); - if (pl != plTarget) + player->SendNewItem(item, count, false, true); + if (player != plTarget) plTarget->SendNewItem(item, count, true, false); } @@ -526,7 +526,7 @@ bool ChatHandler::HandleListItemCommand(const char *args) "SELECT ah.itemguid, ah.itemowner, c.account, c.name FROM auctionhouse ah " "INNER JOIN characters c ON c.guid = ah.itemowner " "INNER JOIN item_instance ii ON ii.guid = ah.itemguid " - "WHERE ii.itemEntry = '%u' AND LIMIT %u", item_id, count); + "WHERE ii.itemEntry = '%u' LIMIT %u", item_id, count); } else result = QueryResult(NULL); @@ -637,9 +637,9 @@ bool ChatHandler::HandleListObjectCommand(const char *args) if (m_session) { - Player* pl = m_session->GetPlayer(); + Player* player = m_session->GetPlayer(); result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, id, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), go_id, uint32(count)); + player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), go_id, uint32(count)); } else result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, id FROM gameobject WHERE id = '%u' LIMIT %u", @@ -709,9 +709,9 @@ bool ChatHandler::HandleListCreatureCommand(const char *args) if (m_session) { - Player* pl = m_session->GetPlayer(); + Player* player = m_session->GetPlayer(); result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id, uint32(count)); + player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), cr_id, uint32(count)); } else result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u", @@ -1859,6 +1859,12 @@ bool ChatHandler::HandleDamageCommand(const char * args) return false; } + if (target->GetTypeId() == TYPEID_PLAYER) + { + if (HasLowerSecurity((Player*)target, 0, false)) + return false; + } + if (!target->isAlive()) return true; @@ -2671,7 +2677,7 @@ bool ChatHandler::HandleResetAllCommand(const char * args) CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE (at_login & '%u') = '0'", atLogin, atLogin); - ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true); + TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock()); HashMapHolder<Player>::MapType const& plist = sObjectAccessor->GetPlayers(); for (HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr) itr->second->SetAtLoginFlag(atLogin); @@ -3452,11 +3458,11 @@ bool ChatHandler::HandleBanListIPCommand(const char *args) bool ChatHandler::HandleRespawnCommand(const char* /*args*/) { - Player* pl = m_session->GetPlayer(); + Player* player = m_session->GetPlayer(); // accept only explicitly selected target (not implicitly self targeting case) Unit* target = getSelectedUnit(); - if (pl->GetSelection() && target) + if (player->GetSelection() && target) { if (target->GetTypeId() != TYPEID_UNIT || target->isPet()) { @@ -3470,16 +3476,15 @@ bool ChatHandler::HandleRespawnCommand(const char* /*args*/) return true; } - CellPair p(Trinity::ComputeCellPair(pl->GetPositionX(), pl->GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::RespawnDo u_do; - Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(pl, u_do); + Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(player, u_do); TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker); - cell.Visit(p, obj_worker, *pl->GetMap()); + cell.Visit(p, obj_worker, *player->GetMap(), *player, player->GetGridActivationRange()); return true; } @@ -4026,9 +4031,9 @@ bool ChatHandler::HandleComeToMeCommand(const char *args) caster->SetUnitMovementFlags(newFlags); - Player* pl = m_session->GetPlayer(); + Player* player = m_session->GetPlayer(); - caster->GetMotionMaster()->MovePoint(0, pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ()); + caster->GetMotionMaster()->MovePoint(0, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); return true; } @@ -4172,9 +4177,9 @@ bool ChatHandler::HandleInstanceStatsCommand(const char* /*args*/) bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/) { - Player* pl = m_session->GetPlayer(); + Player* player = m_session->GetPlayer(); - Map* map = pl->GetMap(); + Map* map = player->GetMap(); if (!map->IsDungeon()) { PSendSysMessage("Map is not a dungeon."); @@ -4644,12 +4649,12 @@ bool ChatHandler::HandleListFreezeCommand(const char * /*args*/) bool ChatHandler::HandleGroupLeaderCommand(const char *args) { - Player* plr = NULL; + Player* player = NULL; Group* group = NULL; uint64 guid = 0; char* cname = strtok((char*)args, " "); - if (GetPlayerGroupAndGUIDByName(cname, plr, group, guid)) + if (GetPlayerGroupAndGUIDByName(cname, player, group, guid)) if (group && group->GetLeaderGUID() != guid) { group->ChangeLeader(guid); @@ -4661,12 +4666,12 @@ bool ChatHandler::HandleGroupLeaderCommand(const char *args) bool ChatHandler::HandleGroupDisbandCommand(const char *args) { - Player* plr = NULL; + Player* player = NULL; Group* group = NULL; uint64 guid = 0; char* cname = strtok((char*)args, " "); - if (GetPlayerGroupAndGUIDByName(cname, plr, group, guid)) + if (GetPlayerGroupAndGUIDByName(cname, player, group, guid)) if (group) group->Disband(); @@ -4675,12 +4680,12 @@ bool ChatHandler::HandleGroupDisbandCommand(const char *args) bool ChatHandler::HandleGroupRemoveCommand(const char *args) { - Player* plr = NULL; + Player* player = NULL; Group* group = NULL; uint64 guid = 0; char* cname = strtok((char*)args, " "); - if (GetPlayerGroupAndGUIDByName(cname, plr, group, guid, true)) + if (GetPlayerGroupAndGUIDByName(cname, player, group, guid, true)) if (group) group->RemoveMember(guid); diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp index faa73cefb11..6815d73d1b3 100755 --- a/src/server/game/DataStores/DBCStores.cpp +++ b/src/server/game/DataStores/DBCStores.cpp @@ -71,6 +71,7 @@ DBCStorage <ChrRacesEntry> sChrRacesStore(ChrRacesEntryfmt); DBCStorage <CinematicSequencesEntry> sCinematicSequencesStore(CinematicSequencesEntryfmt); DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore(CreatureDisplayInfofmt); DBCStorage <CreatureFamilyEntry> sCreatureFamilyStore(CreatureFamilyfmt); +DBCStorage <CreatureModelDataEntry> sCreatureModelDataStore(CreatureModelDatafmt); DBCStorage <CreatureSpellDataEntry> sCreatureSpellDataStore(CreatureSpellDatafmt); DBCStorage <CreatureTypeEntry> sCreatureTypeStore(CreatureTypefmt); DBCStorage <CurrencyTypesEntry> sCurrencyTypesStore(CurrencyTypesfmt); @@ -292,6 +293,7 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales, bad_dbc_files, sCinematicSequencesStore, dbcPath, "CinematicSequences.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureDisplayInfoStore, dbcPath, "CreatureDisplayInfo.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureFamilyStore, dbcPath, "CreatureFamily.dbc"); + LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureModelDataStore, dbcPath, "CreatureModelData.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureSpellDataStore, dbcPath, "CreatureSpellData.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureTypeStore, dbcPath, "CreatureType.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sCurrencyTypesStore, dbcPath, "CurrencyTypes.dbc"); diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h index 367746616d1..7edfaad03f1 100755 --- a/src/server/game/DataStores/DBCStores.h +++ b/src/server/game/DataStores/DBCStores.h @@ -81,6 +81,7 @@ extern DBCStorage <ChrRacesEntry> sChrRacesStore; extern DBCStorage <CinematicSequencesEntry> sCinematicSequencesStore; extern DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore; extern DBCStorage <CreatureFamilyEntry> sCreatureFamilyStore; +extern DBCStorage <CreatureModelDataEntry> sCreatureModelDataStore; extern DBCStorage <CreatureSpellDataEntry> sCreatureSpellDataStore; extern DBCStorage <CreatureTypeEntry> sCreatureTypeStore; extern DBCStorage <CurrencyTypesEntry> sCurrencyTypesStore; diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h index e01acd2e03d..32510da70d3 100755 --- a/src/server/game/DataStores/DBCStructure.h +++ b/src/server/game/DataStores/DBCStructure.h @@ -723,7 +723,7 @@ struct CinematicSequencesEntry struct CreatureDisplayInfoEntry { uint32 Displayid; // 0 m_ID - // 1 m_modelID + uint32 ModelId; // 1 m_modelID // 2 m_soundID // 3 m_extendedDisplayInfoID float scale; // 4 m_creatureModelScale @@ -754,6 +754,28 @@ struct CreatureFamilyEntry // 27 m_iconFile }; +struct CreatureModelDataEntry +{ + uint32 Id; + //uint32 Flags; + //char* ModelPath[16] + //uint32 Unk1; + //float Scale; // Used in calculation of unit collision data + //int32 Unk2 + //int32 Unk3 + //uint32 Unk4 + //uint32 Unk5 + //float Unk6 + //uint32 Unk7 + //float Unk8 + //uint32 Unk9 + //uint32 Unk10 + float CollisionWidth; + float CollisionHeight; + //float Unk11; // Used in calculation of unit collision data when mounted + //float Unks[11] +}; + #define MAX_CREATURE_SPELL_DATA_SLOT 4 struct CreatureSpellDataEntry diff --git a/src/server/game/DataStores/DBCfmt.h b/src/server/game/DataStores/DBCfmt.h index 5d33a3011ab..d71565d8a39 100755 --- a/src/server/game/DataStores/DBCfmt.h +++ b/src/server/game/DataStores/DBCfmt.h @@ -38,8 +38,9 @@ const char ChatChannelsEntryfmt[]="nixssssssssssssssssxxxxxxxxxxxxxxxxxx"; const char ChrClassesEntryfmt[]="nxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixii"; const char ChrRacesEntryfmt[]="nxixiixixxxxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi"; const char CinematicSequencesEntryfmt[]="nxxxxxxxxx"; -const char CreatureDisplayInfofmt[]="nxxxfxxxxxxxxxxx"; +const char CreatureDisplayInfofmt[]="nixxfxxxxxxxxxxx"; const char CreatureFamilyfmt[]="nfifiiiiixssssssssssssssssxx"; +const char CreatureModelDatafmt[]="nxxxxxxxxxxxxxffxxxxxxxxxxxx"; const char CreatureSpellDatafmt[]="niiiixxxx"; const char CreatureTypefmt[]="nxxxxxxxxxxxxxxxxxx"; const char CurrencyTypesfmt[]="xnxi"; diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 52b41c0a0f7..1364f739663 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -159,12 +159,12 @@ void LFGMgr::Update(uint32 diff) { uint64 guid = itRoles->first; ClearState(guid); - if (Player* plr = ObjectAccessor::FindPlayer(guid)) + if (Player* player = ObjectAccessor::FindPlayer(guid)) { - plr->GetSession()->SendLfgRoleCheckUpdate(roleCheck); + player->GetSession()->SendLfgRoleCheckUpdate(roleCheck); if (itRoles->first == roleCheck->leader) - plr->GetSession()->SendLfgJoinResult(LfgJoinResultData(LFG_JOIN_FAILED, LFG_ROLECHECK_MISSING_ROLE)); + player->GetSession()->SendLfgJoinResult(LfgJoinResultData(LFG_JOIN_FAILED, LFG_ROLECHECK_MISSING_ROLE)); } } delete roleCheck; @@ -226,18 +226,18 @@ void LFGMgr::Update(uint32 diff) { guid = itPlayers->first; SetState(guid, LFG_STATE_PROPOSAL); - if (Player* plr = ObjectAccessor::FindPlayer(itPlayers->first)) + if (Player* player = ObjectAccessor::FindPlayer(itPlayers->first)) { - Group* grp = plr->GetGroup(); + Group* grp = player->GetGroup(); if (grp) { uint64 gguid = grp->GetGUID(); SetState(gguid, LFG_STATE_PROPOSAL); - plr->GetSession()->SendLfgUpdateParty(LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, GetSelectedDungeons(guid), GetComment(guid))); + player->GetSession()->SendLfgUpdateParty(LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, GetSelectedDungeons(guid), GetComment(guid))); } else - plr->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, GetSelectedDungeons(guid), GetComment(guid))); - plr->GetSession()->SendLfgUpdateProposal(m_lfgProposalId, pProposal); + player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, GetSelectedDungeons(guid), GetComment(guid))); + player->GetSession()->SendLfgUpdateProposal(m_lfgProposalId, pProposal); } } @@ -291,8 +291,8 @@ void LFGMgr::Update(uint32 diff) } for (LfgRolesMap::const_iterator itPlayer = queue->roles.begin(); itPlayer != queue->roles.end(); ++itPlayer) - if (Player* plr = ObjectAccessor::FindPlayer(itPlayer->first)) - plr->GetSession()->SendLfgQueueStatus(dungeonId, waitTime, m_WaitTimeAvg, m_WaitTimeTank, m_WaitTimeHealer, m_WaitTimeDps, queuedTime, queue->tanks, queue->healers, queue->dps); + if (Player* player = ObjectAccessor::FindPlayer(itPlayer->first)) + player->GetSession()->SendLfgQueueStatus(dungeonId, waitTime, m_WaitTimeAvg, m_WaitTimeTank, m_WaitTimeHealer, m_WaitTimeDps, queuedTime, queue->tanks, queue->healers, queue->dps); } } else @@ -358,13 +358,13 @@ bool LFGMgr::RemoveFromQueue(uint64 guid) /** Generate the dungeon lock map for a given player - @param[in] plr Player we need to initialize the lock status map + @param[in] player Player we need to initialize the lock status map */ -void LFGMgr::InitializeLockedDungeons(Player* plr) +void LFGMgr::InitializeLockedDungeons(Player* player) { - uint64 guid = plr->GetGUID(); - uint8 level = plr->getLevel(); - uint8 expansion = plr->GetSession()->Expansion(); + uint64 guid = player->GetGUID(); + uint8 level = player->getLevel(); + uint8 expansion = player->GetSession()->Expansion(); LfgDungeonSet dungeons = GetDungeonsByRandom(0); LfgLockMap lock; @@ -379,9 +379,9 @@ void LFGMgr::InitializeLockedDungeons(Player* plr) LfgLockStatusType locktype = LFG_LOCKSTATUS_OK; if (dungeon->expansion > expansion) locktype = LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION; - else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, plr)) + else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, player)) locktype = LFG_LOCKSTATUS_RAID_LOCKED; - else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && plr->GetBoundInstance(dungeon->map, Difficulty(dungeon->difficulty))) + else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && player->GetBoundInstance(dungeon->map, Difficulty(dungeon->difficulty))) locktype = LFG_LOCKSTATUS_RAID_LOCKED; else if (dungeon->minlevel > level) locktype = LFG_LOCKSTATUS_TOO_LOW_LEVEL; @@ -389,19 +389,19 @@ void LFGMgr::InitializeLockedDungeons(Player* plr) locktype = LFG_LOCKSTATUS_TOO_HIGH_LEVEL; else if (locktype == LFG_LOCKSTATUS_OK && ar) { - if (ar->achievement && !plr->GetAchievementMgr().HasAchieved(sAchievementStore.LookupEntry(ar->achievement))) + if (ar->achievement && !player->GetAchievementMgr().HasAchieved(sAchievementStore.LookupEntry(ar->achievement))) locktype = LFG_LOCKSTATUS_RAID_LOCKED; // FIXME: Check the correct lock value - else if (plr->GetTeam() == ALLIANCE && ar->quest_A && !plr->GetQuestRewardStatus(ar->quest_A)) + else if (player->GetTeam() == ALLIANCE && ar->quest_A && !player->GetQuestRewardStatus(ar->quest_A)) locktype = LFG_LOCKSTATUS_QUEST_NOT_COMPLETED; - else if (plr->GetTeam() == HORDE && ar->quest_H && !plr->GetQuestRewardStatus(ar->quest_H)) + else if (player->GetTeam() == HORDE && ar->quest_H && !player->GetQuestRewardStatus(ar->quest_H)) locktype = LFG_LOCKSTATUS_QUEST_NOT_COMPLETED; else if (ar->item) { - if (!plr->HasItemCount(ar->item, 1) && (!ar->item2 || !plr->HasItemCount(ar->item2, 1))) + if (!player->HasItemCount(ar->item, 1) && (!ar->item2 || !player->HasItemCount(ar->item2, 1))) locktype = LFG_LOCKSTATUS_MISSING_ITEM; } - else if (ar->item2 && !plr->HasItemCount(ar->item2, 1)) + else if (ar->item2 && !player->HasItemCount(ar->item2, 1)) locktype = LFG_LOCKSTATUS_MISSING_ITEM; } /* TODO VoA closed if WG is not under team control (LFG_LOCKSTATUS_RAID_LOCKED) @@ -423,18 +423,18 @@ void LFGMgr::InitializeLockedDungeons(Player* plr) of the group tying to join the group. Join conditions are checked before adding to the new queue. - @param[in] plr Player trying to join (or leader of group trying to join) + @param[in] player Player trying to join (or leader of group trying to join) @param[in] roles Player selected roles @param[in] dungeons Dungeons the player/group is applying for @param[in] comment Player selected comment */ -void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeons, const std::string& comment) +void LFGMgr::Join(Player* player, uint8 roles, const LfgDungeonSet& selectedDungeons, const std::string& comment) { - if (!plr || !plr->GetSession() || selectedDungeons.empty()) + if (!player || !player->GetSession() || selectedDungeons.empty()) return; - Group* grp = plr->GetGroup(); - uint64 guid = plr->GetGUID(); + Group* grp = player->GetGroup(); + uint64 guid = player->GetGUID(); uint64 gguid = grp ? grp->GetGUID() : guid; LfgJoinResultData joinData; PlayerSet players; @@ -457,7 +457,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon if (playerDungeons == dungeons) // Joining the same dungeons -- Send OK { LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, dungeons, comment); - plr->GetSession()->SendLfgJoinResult(joinData); // Default value of joinData.result = LFG_JOIN_OK + player->GetSession()->SendLfgJoinResult(joinData); // Default value of joinData.result = LFG_JOIN_OK if (grp) { for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) @@ -471,11 +471,11 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon } // Check player or group member restrictions - if (plr->InBattleground() || plr->InArena() || plr->InBattlegroundQueue()) + if (player->InBattleground() || player->InArena() || player->InBattlegroundQueue()) joinData.result = LFG_JOIN_USING_BG_SYSTEM; - else if (plr->HasAura(LFG_SPELL_DUNGEON_DESERTER)) + else if (player->HasAura(LFG_SPELL_DUNGEON_DESERTER)) joinData.result = LFG_JOIN_DESERTER; - else if (plr->HasAura(LFG_SPELL_DUNGEON_COOLDOWN)) + else if (player->HasAura(LFG_SPELL_DUNGEON_COOLDOWN)) joinData.result = LFG_JOIN_RANDOM_COOLDOWN; else if (dungeons.empty()) joinData.result = LFG_JOIN_NOT_MEET_REQS; @@ -505,7 +505,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon } } else - players.insert(plr); + players.insert(player); // Check if all dungeons are valid bool isRaid = false; @@ -559,7 +559,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: %u", guid, grp ? grp->GetMembersCount() : 1, joinData.result); if (!dungeons.empty()) // Only should show lockmap when have no dungeons available joinData.lockmap.clear(); - plr->GetSession()->SendLfgJoinResult(joinData); + player->GetSession()->SendLfgJoinResult(joinData); return; } @@ -612,7 +612,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon // Queue player LfgQueueInfo* pqInfo = new LfgQueueInfo(); pqInfo->joinTime = time_t(time(NULL)); - pqInfo->roles[plr->GetGUID()] = roles; + pqInfo->roles[player->GetGUID()] = roles; pqInfo->dungeons = dungeons; if (roles & ROLE_TANK) --pqInfo->tanks; @@ -623,8 +623,8 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon m_QueueInfoMap[guid] = pqInfo; // Send update to player - plr->GetSession()->SendLfgJoinResult(joinData); - plr->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_JOIN_PROPOSAL, dungeons, comment)); + player->GetSession()->SendLfgJoinResult(joinData); + player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_JOIN_PROPOSAL, dungeons, comment)); SetState(gguid, LFG_STATE_QUEUED); SetRoles(guid, roles); if (!isContinue) @@ -636,7 +636,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon } SetSelectedDungeons(guid, dungeons); } - AddToQueue(guid, uint8(plr->GetTeam())); + AddToQueue(guid, uint8(player->GetTeam())); } sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::Join: [" UI64FMTD "] joined with %u members. dungeons: %u", guid, grp ? grp->GetMembersCount() : 1, uint8(dungeons.size())); } @@ -645,15 +645,15 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon Leaves Dungeon System. Player/Group is removed from queue, rolechecks, proposals or votekicks. Player or group needs to be not NULL and using Dungeon System - @param[in] plr Player trying to leave (can be NULL) + @param[in] player Player trying to leave (can be NULL) @param[in] grp Group trying to leave (default NULL) */ -void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/) +void LFGMgr::Leave(Player* player, Group* grp /* = NULL*/) { - if (!plr && !grp) + if (!player && !grp) return; - uint64 guid = grp ? grp->GetGUID() : plr->GetGUID(); + uint64 guid = grp ? grp->GetGUID() : player->GetGUID(); LfgState state = GetState(guid); sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::Leave: [" UI64FMTD "]", guid); @@ -676,7 +676,7 @@ void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/) } else { - plr->GetSession()->SendLfgUpdatePlayer(updateData); + player->GetSession()->SendLfgUpdatePlayer(updateData); ClearState(guid); } } @@ -689,7 +689,7 @@ void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/) { // Remove from Proposals LfgProposalMap::iterator it = m_Proposals.begin(); - uint64 guid = plr ? plr->GetGUID() : grp->GetLeaderGUID(); + uint64 guid = player ? player->GetGUID() : grp->GetLeaderGUID(); while (it != m_Proposals.end()) { LfgProposalPlayerMap::iterator itPlayer = it->second->players.find(guid); @@ -866,22 +866,22 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal) PlayerSet players; for (LfgRolesMap::const_iterator it = rolesMap.begin(); it != rolesMap.end(); ++it) { - Player* plr = ObjectAccessor::FindPlayer(it->first); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(it->first); + if (!player) sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::CheckCompatibility: (%s) Warning! [" UI64FMTD "] offline! Marking as not compatibles!", strGuids.c_str(), it->first); else { - for (PlayerSet::const_iterator itPlayer = players.begin(); itPlayer != players.end() && plr; ++itPlayer) + for (PlayerSet::const_iterator itPlayer = players.begin(); itPlayer != players.end() && player; ++itPlayer) { // Do not form a group with ignoring candidates - if (plr->GetSocial()->HasIgnore((*itPlayer)->GetGUIDLow()) || (*itPlayer)->GetSocial()->HasIgnore(plr->GetGUIDLow())) + if (player->GetSocial()->HasIgnore((*itPlayer)->GetGUIDLow()) || (*itPlayer)->GetSocial()->HasIgnore(player->GetGUIDLow())) { - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::CheckCompatibility: (%s) Players [" UI64FMTD "] and [" UI64FMTD "] ignoring", strGuids.c_str(), (*itPlayer)->GetGUID(), plr->GetGUID()); - plr = NULL; + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::CheckCompatibility: (%s) Players [" UI64FMTD "] and [" UI64FMTD "] ignoring", strGuids.c_str(), (*itPlayer)->GetGUID(), player->GetGUID()); + player = NULL; } } - if (plr) - players.insert(plr); + if (player) + players.insert(player); } } @@ -1276,18 +1276,18 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) bool allAnswered = true; for (LfgProposalPlayerMap::const_iterator itPlayers = pProposal->players.begin(); itPlayers != pProposal->players.end(); ++itPlayers) { - if (Player* plr = ObjectAccessor::FindPlayer(itPlayers->first)) + if (Player* player = ObjectAccessor::FindPlayer(itPlayers->first)) { if (itPlayers->first == pProposal->leader) - players.push_front(plr); + players.push_front(player); else - players.push_back(plr); + players.push_back(player); // Only teleport new players - Group* grp = plr->GetGroup(); + Group* grp = player->GetGroup(); uint64 gguid = grp ? grp->GetGUID() : 0; if (!gguid || !grp->isLFGGroup() || GetState(gguid) == LFG_STATE_FINISHED_DUNGEON) - playersToTeleport.push_back(plr); + playersToTeleport.push_back(player); } if (itPlayers->second->accept != LFG_ANSWER_AGREE) // No answer (-1) or not accepted (0) @@ -1329,31 +1329,31 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) Group* grp = pProposal->groupLowGuid ? sGroupMgr->GetGroupByGUID(pProposal->groupLowGuid) : NULL; for (LfgPlayerList::const_iterator it = players.begin(); it != players.end(); ++it) { - Player* plr = (*it); - uint64 pguid = plr->GetGUID(); - Group* group = plr->GetGroup(); + Player* player = (*it); + uint64 pguid = player->GetGUID(); + Group* group = player->GetGroup(); if (sendUpdate) - plr->GetSession()->SendLfgUpdateProposal(proposalId, pProposal); + player->GetSession()->SendLfgUpdateProposal(proposalId, pProposal); if (group) { - plr->GetSession()->SendLfgUpdateParty(updateData); + player->GetSession()->SendLfgUpdateParty(updateData); if (group != grp) - plr->RemoveFromGroup(); + player->RemoveFromGroup(); } else - plr->GetSession()->SendLfgUpdatePlayer(updateData); + player->GetSession()->SendLfgUpdatePlayer(updateData); if (!grp) { grp = new Group(); - grp->Create(plr); + grp->Create(player); grp->ConvertToLFG(); uint64 gguid = grp->GetGUID(); SetState(gguid, LFG_STATE_PROPOSAL); sGroupMgr->AddGroup(grp); } else if (group != grp) - grp->AddMember(plr); + grp->AddMember(player); // Update timers uint8 role = GetRoles(pguid); @@ -1363,25 +1363,25 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) case ROLE_DAMAGE: { uint32 old_number = m_NumWaitTimeDps++; - m_WaitTimeDps = int32((m_WaitTimeDps * old_number + waitTimesMap[plr->GetGUID()]) / m_NumWaitTimeDps); + m_WaitTimeDps = int32((m_WaitTimeDps * old_number + waitTimesMap[player->GetGUID()]) / m_NumWaitTimeDps); break; } case ROLE_HEALER: { uint32 old_number = m_NumWaitTimeHealer++; - m_WaitTimeHealer = int32((m_WaitTimeHealer * old_number + waitTimesMap[plr->GetGUID()]) / m_NumWaitTimeHealer); + m_WaitTimeHealer = int32((m_WaitTimeHealer * old_number + waitTimesMap[player->GetGUID()]) / m_NumWaitTimeHealer); break; } case ROLE_TANK: { uint32 old_number = m_NumWaitTimeTank++; - m_WaitTimeTank = int32((m_WaitTimeTank * old_number + waitTimesMap[plr->GetGUID()]) / m_NumWaitTimeTank); + m_WaitTimeTank = int32((m_WaitTimeTank * old_number + waitTimesMap[player->GetGUID()]) / m_NumWaitTimeTank); break; } default: { uint32 old_number = m_NumWaitTimeAvg++; - m_WaitTimeAvg = int32((m_WaitTimeAvg * old_number + waitTimesMap[plr->GetGUID()]) / m_NumWaitTimeAvg); + m_WaitTimeAvg = int32((m_WaitTimeAvg * old_number + waitTimesMap[player->GetGUID()]) / m_NumWaitTimeAvg); break; } } @@ -1454,15 +1454,15 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t // Notify players for (LfgProposalPlayerMap::const_iterator it = pProposal->players.begin(); it != pProposal->players.end(); ++it) { - Player* plr = ObjectAccessor::FindPlayer(it->first); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(it->first); + if (!player) continue; - team = uint8(plr->GetTeam()); - plr->GetSession()->SendLfgUpdateProposal(itProposal->first, pProposal); + team = uint8(player->GetTeam()); + player->GetSession()->SendLfgUpdateProposal(itProposal->first, pProposal); - Group* grp = plr->GetGroup(); - uint64 guid = plr->GetGUID(); + Group* grp = player->GetGroup(); + uint64 guid = player->GetGUID(); uint64 gguid = it->second->groupLowGuid ? MAKE_NEW_GUID(it->second->groupLowGuid, 0, HIGHGUID_GROUP) : guid; if (toRemove.find(gguid) != toRemove.end()) // Didn't accept or in same group that someone that didn't accept @@ -1482,10 +1482,10 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t if (grp) { RestoreState(gguid); - plr->GetSession()->SendLfgUpdateParty(updateData); + player->GetSession()->SendLfgUpdateParty(updateData); } else - plr->GetSession()->SendLfgUpdatePlayer(updateData); + player->GetSession()->SendLfgUpdatePlayer(updateData); } else { @@ -1494,10 +1494,10 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t if (grp) { SetState(gguid, LFG_STATE_QUEUED); - plr->GetSession()->SendLfgUpdateParty(LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, GetSelectedDungeons(guid), GetComment(guid))); + player->GetSession()->SendLfgUpdateParty(LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, GetSelectedDungeons(guid), GetComment(guid))); } else - plr->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, GetSelectedDungeons(guid), GetComment(guid))); + player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, GetSelectedDungeons(guid), GetComment(guid))); } } @@ -1572,17 +1572,17 @@ void LFGMgr::InitBoot(Group* grp, uint64 kicker, uint64 victim, std::string reas /** Update Boot info with player answer - @param[in] plr Player who has answered + @param[in] player Player who has answered @param[in] accept player answer */ -void LFGMgr::UpdateBoot(Player* plr, bool accept) +void LFGMgr::UpdateBoot(Player* player, bool accept) { - Group* grp = plr ? plr->GetGroup() : NULL; + Group* grp = player ? player->GetGroup() : NULL; if (!grp) return; uint32 bootId = grp->GetLowGUID(); - uint64 guid = plr->GetGUID(); + uint64 guid = player->GetGUID(); LfgPlayerBootMap::iterator itBoot = m_Boots.find(bootId); if (itBoot == m_Boots.end()) @@ -1647,29 +1647,29 @@ void LFGMgr::UpdateBoot(Player* plr, bool accept) /** Teleports the player in or out the dungeon - @param[in] plr Player to teleport + @param[in] player Player to teleport @param[in] out Teleport out (true) or in (false) @param[in] fromOpcode Function called from opcode handlers? (Default false) */ -void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/) +void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*/) { - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::TeleportPlayer: [" UI64FMTD "] is being teleported %s", plr->GetGUID(), out ? "out" : "in"); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::TeleportPlayer: [" UI64FMTD "] is being teleported %s", player->GetGUID(), out ? "out" : "in"); if (out) { - plr->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW); - plr->TeleportToBGEntryPoint(); + player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW); + player->TeleportToBGEntryPoint(); return; } // TODO Add support for LFG_TELEPORTERROR_FATIGUE LfgTeleportError error = LFG_TELEPORTERROR_OK; - Group* grp = plr->GetGroup(); + Group* grp = player->GetGroup(); if (!grp || !grp->isLFGGroup()) // should never happen, but just in case... error = LFG_TELEPORTERROR_INVALID_LOCATION; - else if (!plr->isAlive()) + else if (!player->isAlive()) error = LFG_TELEPORTERROR_PLAYER_DEAD; - else if (plr->IsFalling() || plr->HasUnitState(UNIT_STAT_JUMPING)) + else if (player->IsFalling() || player->HasUnitState(UNIT_STAT_JUMPING)) error = LFG_TELEPORTERROR_FALLING; else { @@ -1678,7 +1678,7 @@ void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/) if (!dungeon) error = LFG_TELEPORTERROR_INVALID_LOCATION; - else if (plr->GetMapId() != uint32(dungeon->map)) // Do not teleport players in dungeon to the entrance + else if (player->GetMapId() != uint32(dungeon->map)) // Do not teleport players in dungeon to the entrance { uint32 mapid = 0; float x = 0; @@ -1692,7 +1692,7 @@ void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/) for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && !mapid; itr = itr->next()) { Player* plrg = itr->getSource(); - if (plrg && plrg != plr && plrg->GetMapId() == uint32(dungeon->map)) + if (plrg && plrg != player && plrg->GetMapId() == uint32(dungeon->map)) { mapid = plrg->GetMapId(); x = plrg->GetPositionX(); @@ -1708,7 +1708,7 @@ void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/) AreaTrigger const* at = sObjectMgr->GetMapEntranceTrigger(dungeon->map); if (!at) { - sLog->outError("LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "]: No areatrigger found for map: %u difficulty: %u", plr->GetGUID(), dungeon->map, dungeon->difficulty); + sLog->outError("LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "]: No areatrigger found for map: %u difficulty: %u", player->GetGUID(), dungeon->map, dungeon->difficulty); error = LFG_TELEPORTERROR_INVALID_LOCATION; } else @@ -1723,36 +1723,36 @@ void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/) if (error == LFG_TELEPORTERROR_OK) { - if (!plr->GetMap()->IsDungeon() && !plr->GetMap()->IsRaid()) - plr->SetBattlegroundEntryPoint(); + if (!player->GetMap()->IsDungeon() && !player->GetMap()->IsRaid()) + player->SetBattlegroundEntryPoint(); - if (plr->isInFlight()) + if (player->isInFlight()) { - plr->GetMotionMaster()->MovementExpired(); - plr->CleanupAfterTaxiFlight(); + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); } - if (plr->TeleportTo(mapid, x, y, z, orientation)) + if (player->TeleportTo(mapid, x, y, z, orientation)) // FIXME - HACK - this should be done by teleport, when teleporting far - plr->RemoveAurasByType(SPELL_AURA_MOUNTED); + player->RemoveAurasByType(SPELL_AURA_MOUNTED); else { error = LFG_TELEPORTERROR_INVALID_LOCATION; - sLog->outError("LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "] to map %u: ", plr->GetGUID(), mapid); + sLog->outError("LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "] to map %u: ", player->GetGUID(), mapid); } } } } if (error != LFG_TELEPORTERROR_OK) - plr->GetSession()->SendLfgTeleportError(uint8(error)); + player->GetSession()->SendLfgTeleportError(uint8(error)); } /** Give completion reward to player @param[in] dungeonId Id of the dungeon finished - @param[in] plr Player to reward + @param[in] player Player to reward */ void LFGMgr::RewardDungeonDoneFor(const uint32 dungeonId, Player* player) { diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index 300268ed7c8..95cb2e81869 100755 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -268,8 +268,8 @@ class LFGMgr LfgReward const* GetRandomDungeonReward(uint32 dungeon, uint8 level); // Queue - void Join(Player* plr, uint8 roles, const LfgDungeonSet& dungeons, const std::string& comment); - void Leave(Player* plr, Group* grp = NULL); + void Join(Player* player, uint8 roles, const LfgDungeonSet& dungeons, const std::string& comment); + void Leave(Player* player, Group* grp = NULL); // Role Check void UpdateRoleCheck(uint64 gguid, uint64 guid = 0, uint8 roles = ROLE_NONE); @@ -278,20 +278,21 @@ class LFGMgr void UpdateProposal(uint32 proposalId, uint64 guid, bool accept); // Teleportation - void TeleportPlayer(Player* plr, bool out, bool fromOpcode = false); + void TeleportPlayer(Player* player, bool out, bool fromOpcode = false); // Vote kick void InitBoot(Group* grp, uint64 kguid, uint64 vguid, std::string reason); - void UpdateBoot(Player* plr, bool accept); + void UpdateBoot(Player* player, bool accept); void OfferContinue(Group* grp); - void InitializeLockedDungeons(Player* plr); + void InitializeLockedDungeons(Player* player); void SetComment(uint64 guid, const std::string& comment); const LfgLockMap& GetLockedDungeons(uint64 guid); LfgState GetState(uint64 guid); const LfgDungeonSet& GetSelectedDungeons(uint64 guid); uint32 GetDungeon(uint64 guid, bool asId = true); + void SetState(uint64 guid, LfgState state); void ClearState(uint64 guid); void RemovePlayerData(uint64 guid); void RemoveGroupData(uint64 guid); @@ -304,7 +305,6 @@ class LFGMgr uint8 GetRoles(uint64 guid); const std::string& GetComment(uint64 gguid); void RestoreState(uint64 guid); - void SetState(uint64 guid, LfgState state); void SetDungeon(uint64 guid, uint32 dungeon); void SetSelectedDungeons(uint64 guid, const LfgDungeonSet& dungeons); void SetLockedDungeons(uint64 guid, const LfgLockMap& lock); diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp index 23eb10a98ae..42119a02ef8 100644 --- a/src/server/game/DungeonFinding/LFGScripts.cpp +++ b/src/server/game/DungeonFinding/LFGScripts.cpp @@ -51,8 +51,8 @@ void LFGScripts::OnAddMember(Group* group, uint64 guid) sLFGMgr->Leave(NULL, group); if (sLFGMgr->GetState(guid) == LFG_STATE_QUEUED) - if (Player* plr = ObjectAccessor::FindPlayer(guid)) - sLFGMgr->Leave(plr); + if (Player* player = ObjectAccessor::FindPlayer(guid)) + sLFGMgr->Leave(player); } void LFGScripts::OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, const char* reason) @@ -82,7 +82,8 @@ void LFGScripts::OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, } sLFGMgr->ClearState(guid); - if (Player* plr = ObjectAccessor::FindPlayer(guid)) + sLFGMgr->SetState(guid, LFG_STATE_NONE); + if (Player* player = ObjectAccessor::FindPlayer(guid)) { /* if (method == GROUP_REMOVEMETHOD_LEAVE) @@ -92,9 +93,9 @@ void LFGScripts::OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, */ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_LEADER); - plr->GetSession()->SendLfgUpdateParty(updateData); - if (plr->GetMap()->IsDungeon()) // Teleport player out the dungeon - sLFGMgr->TeleportPlayer(plr, true); + player->GetSession()->SendLfgUpdateParty(updateData); + if (player->GetMap()->IsDungeon()) // Teleport player out the dungeon + sLFGMgr->TeleportPlayer(player, true); } if (sLFGMgr->GetState(gguid) != LFG_STATE_FINISHED_DUNGEON)// Need more players to finish the dungeon @@ -116,17 +117,17 @@ void LFGScripts::OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLe return; sLog->outDebug(LOG_FILTER_LFG, "LFGScripts::OnChangeLeader [" UI64FMTD "]: old [" UI64FMTD "] new [" UI64FMTD "]", gguid, newLeaderGuid, oldLeaderGuid); - Player* plr = ObjectAccessor::FindPlayer(newLeaderGuid); + Player* player = ObjectAccessor::FindPlayer(newLeaderGuid); LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_LEADER); - if (plr) - plr->GetSession()->SendLfgUpdateParty(updateData); + if (player) + player->GetSession()->SendLfgUpdateParty(updateData); - plr = ObjectAccessor::FindPlayer(oldLeaderGuid); - if (plr) + player = ObjectAccessor::FindPlayer(oldLeaderGuid); + if (player) { updateData.updateType = LFG_UPDATETYPE_GROUP_DISBAND; - plr->GetSession()->SendLfgUpdateParty(updateData); + player->GetSession()->SendLfgUpdateParty(updateData); } } diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp index cdd5d61b1c9..31cc21659c9 100755 --- a/src/server/game/Entities/Corpse/Corpse.cpp +++ b/src/server/game/Entities/Corpse/Corpse.cpp @@ -95,7 +95,7 @@ bool Corpse::Create(uint32 guidlow, Player* owner) SetFloatValue(OBJECT_FIELD_SCALE_X, 1); SetUInt64Value(CORPSE_FIELD_OWNER, owner->GetGUID()); - m_grid = Trinity::ComputeGridPair(GetPositionX(), GetPositionY()); + _gridCoord = Trinity::ComputeGridCoord(GetPositionX(), GetPositionY()); return true; } @@ -211,7 +211,7 @@ bool Corpse::LoadFromDB(uint32 guid, Field* fields) return false; } - m_grid = Trinity::ComputeGridPair(GetPositionX(), GetPositionY()); + _gridCoord = Trinity::ComputeGridCoord(GetPositionX(), GetPositionY()); return true; } diff --git a/src/server/game/Entities/Corpse/Corpse.h b/src/server/game/Entities/Corpse/Corpse.h index bd68eb688f5..2e45606b88f 100755 --- a/src/server/game/Entities/Corpse/Corpse.h +++ b/src/server/game/Entities/Corpse/Corpse.h @@ -70,8 +70,8 @@ class Corpse : public WorldObject, public GridObject<Corpse> void ResetGhostTime() { m_time = time(NULL); } CorpseType GetType() const { return m_type; } - GridPair const& GetGrid() const { return m_grid; } - void SetGrid(GridPair const& grid) { m_grid = grid; } + GridCoord const& GetGridCoord() const { return _gridCoord; } + void SetGridCoord(GridCoord const& gridCoord) { _gridCoord = gridCoord; } Loot loot; // remove insignia ONLY at BG Player* lootRecipient; @@ -88,7 +88,7 @@ class Corpse : public WorldObject, public GridObject<Corpse> private: CorpseType m_type; time_t m_time; - GridPair m_grid; // gride for corpse position for fast search + GridCoord _gridCoord; // gride for corpse position for fast search }; #endif diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index a8e219f4f6b..922db88bcd0 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -137,7 +137,7 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) return true; } -Creature::Creature(): Unit(), +Creature::Creature(): Unit(), MapCreature(), lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootMoney(0), m_lootRecipient(0), m_lootRecipientGroup(0), m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_reactState(REACT_AGGRESSIVE), @@ -245,7 +245,7 @@ void Creature::RemoveCorpse(bool setSpawnTime) m_respawnTime = time(NULL) + respawnDelay; float x, y, z, o; - GetRespawnCoord(x, y, z, &o); + GetRespawnPosition(x, y, z, &o); SetHomePosition(x, y, z, o); GetMap()->CreatureRelocation(this, x, y, z, o); } @@ -659,9 +659,8 @@ void Creature::DoFleeToGetAssistance() { Creature* creature = NULL; - CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::NearestAssistCreatureInCreatureRangeCheck u_check(this, getVictim(), radius); Trinity::CreatureLastSearcher<Trinity::NearestAssistCreatureInCreatureRangeCheck> searcher(this, creature, u_check); @@ -788,16 +787,11 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, LastUsedScriptID = GetCreatureInfo()->ScriptID; // TODO: Replace with spell, handle from DB - if (isSpiritHealer()) + if (isSpiritHealer() || isSpiritGuide()) { m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST); m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST); } - else if (isSpiritGuide()) - { - m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST | GHOST_VISIBILITY_ALIVE); - m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST | GHOST_VISIBILITY_ALIVE); - } if (Entry == VISUAL_WAYPOINT) SetVisible(false); @@ -1285,7 +1279,7 @@ bool Creature::LoadFromDB(uint32 guid, Map* map) if (canFly()) { float tz = map->GetHeight(data->posX, data->posY, data->posZ, false); - if (data->posZ - tz > 0.1) + if (data->posZ - tz > 0.1f) Relocate(data->posX, data->posY, tz); } } @@ -1382,22 +1376,19 @@ void Creature::DeleteFromDB() WorldDatabase.CommitTransaction(trans); } -bool Creature::isVisibleForInState(WorldObject const* seer) const +bool Creature::IsInvisibleDueToDespawn() const { - if (!Unit::isVisibleForInState(seer)) - return false; + if (Unit::IsInvisibleDueToDespawn()) + return true; if (isAlive() || m_corpseRemoveTime > time(NULL)) - return true; + return false; - return false; + return true; } -bool Creature::canSeeAlways(WorldObject const* obj) const +bool Creature::CanAlwaysSee(WorldObject const* obj) const { - if (Unit::canSeeAlways(obj)) - return true; - if (IsAIEnabled && AI()->CanSeeAlways(obj)) return true; @@ -1442,14 +1433,14 @@ bool Creature::canStartAttack(Unit const* who, bool force) const return IsWithinLOSInMap(who); } -float Creature::GetAttackDistance(Unit const* pl) const +float Creature::GetAttackDistance(Unit const* player) const { float aggroRate = sWorld->getRate(RATE_CREATURE_AGGRO); if (aggroRate == 0) return 0.0f; - uint32 playerlevel = pl->getLevelForTarget(this); - uint32 creaturelevel = getLevelForTarget(pl); + uint32 playerlevel = player->getLevelForTarget(this); + uint32 creaturelevel = getLevelForTarget(player); int32 leveldif = int32(playerlevel) - int32(creaturelevel); @@ -1470,7 +1461,7 @@ float Creature::GetAttackDistance(Unit const* pl) const RetDistance += GetTotalAuraModifier(SPELL_AURA_MOD_DETECT_RANGE); // detected range auras - RetDistance += pl->GetTotalAuraModifier(SPELL_AURA_MOD_DETECTED_RANGE); + RetDistance += player->GetTotalAuraModifier(SPELL_AURA_MOD_DETECTED_RANGE); } // "Minimum Aggro Radius for a mob seems to be combat range (5 yards)" @@ -1763,9 +1754,8 @@ SpellInfo const* Creature::reachWithSpellCure(Unit* pVictim) // select nearest hostile unit within the given distance (regardless of threat list). Unit* Creature::SelectNearestTarget(float dist) const { - CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Unit* target = NULL; @@ -1790,9 +1780,8 @@ Unit* Creature::SelectNearestTarget(float dist) const // select nearest hostile unit within the given attack distance (i.e. distance is ignored if > than ATTACK_DISTANCE), regardless of threat list. Unit* Creature::SelectNearestTargetInAttackDistance(float dist) const { - CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Unit* target = NULL; @@ -1853,9 +1842,8 @@ void Creature::CallAssistance() std::list<Creature*> assistList; { - CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::AnyAssistCreatureInRangeCheck u_check(this, getVictim(), radius); @@ -1881,22 +1869,21 @@ void Creature::CallAssistance() } } -void Creature::CallForHelp(float fRadius) +void Creature::CallForHelp(float radius) { - if (fRadius <= 0.0f || !getVictim() || isPet() || isCharmed()) + if (radius <= 0.0f || !getVictim() || isPet() || isCharmed()) return; - CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - Trinity::CallOfHelpCreatureInRangeDo u_do(this, getVictim(), fRadius); + Trinity::CallOfHelpCreatureInRangeDo u_do(this, getVictim(), radius); Trinity::CreatureWorker<Trinity::CallOfHelpCreatureInRangeDo> worker(this, u_do); TypeContainerVisitor<Trinity::CreatureWorker<Trinity::CallOfHelpCreatureInRangeDo>, GridTypeMapContainer > grid_creature_searcher(worker); - cell.Visit(p, grid_creature_searcher, *GetMap(), *this, fRadius); + cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius); } bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const @@ -2208,7 +2195,7 @@ time_t Creature::GetRespawnTimeEx() const return now; } -void Creature::GetRespawnCoord(float &x, float &y, float &z, float* ori, float* dist) const +void Creature::GetRespawnPosition(float &x, float &y, float &z, float* ori, float* dist) const { if (m_DBTableGuid) { @@ -2386,21 +2373,28 @@ const char* Creature::GetNameForLocaleIdx(LocaleConstant loc_idx) const return GetName(); } +//Do not if this works or not, moving creature to another map is very dangerous void Creature::FarTeleportTo(Map* map, float X, float Y, float Z, float O) { - InterruptNonMeleeSpells(true); - CombatStop(); - ClearComboPointHolders(); - DeleteThreatList(); - GetMotionMaster()->Clear(false); - DestroyForNearbyPlayers(); - - RemoveFromWorld(); - ResetMap(); + CleanupBeforeRemoveFromMap(false); + GetMap()->RemoveFromMap(this, false); + Relocate(X, Y, Z, O); SetMap(map); - AddToWorld(); + GetMap()->AddToMap(this); +} + +void Creature::SetPosition(float x, float y, float z, float o) +{ + // prevent crash when a bad coord is sent by the client + if (!Trinity::IsValidMapCoord(x, y, z, o)) + { + sLog->outDebug(LOG_FILTER_UNITS, "Creature::SetPosition(%f, %f, %f) .. bad coordinates!", x, y, z); + return; + } - SetPosition(X, Y, Z, O, true); + GetMap()->CreatureRelocation(ToCreature(), x, y, z, o); + if (IsVehicle()) + GetVehicleKit()->RelocatePassengers(x, y, z, o); } bool Creature::IsDungeonBoss() const diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 3d5b86a106a..665942e134a 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -156,7 +156,7 @@ struct CreatureTemplate else if (type_flags & CREATURE_TYPEFLAGS_MININGLOOT) return SKILL_MINING; else if (type_flags & CREATURE_TYPEFLAGS_ENGINEERLOOT) - return SKILL_ENGINERING; + return SKILL_ENGINEERING; else return SKILL_SKINNING; // normal case } @@ -407,7 +407,36 @@ typedef std::map<uint32, time_t> CreatureSpellCooldowns; #define MAX_VENDOR_ITEMS 150 // Limitation in 3.x.x item count in SMSG_LIST_INVENTORY -class Creature : public Unit, public GridObject<Creature> +enum CreatureCellMoveState +{ + CREATURE_CELL_MOVE_NONE, //not in move list + CREATURE_CELL_MOVE_ACTIVE, //in move list + CREATURE_CELL_MOVE_INACTIVE, //in move list but should not move +}; + +class MapCreature +{ + friend class Map; //map for moving creatures + friend class ObjectGridLoader; //grid loader for loading creatures + +protected: + MapCreature() : _moveState(CREATURE_CELL_MOVE_NONE) {} + +private: + Cell _currentCell; + Cell const& GetCurrentCell() const { return _currentCell; } + void SetCurrentCell(Cell const& cell) { _currentCell = cell; } + + CreatureCellMoveState _moveState; + Position _newPosition; + void SetNewCellPosition(float x, float y, float z, float o) + { + _moveState = CREATURE_CELL_MOVE_ACTIVE; + _newPosition.Relocate(x, y, z, o); + } +}; + +class Creature : public Unit, public GridObject<Creature>, public MapCreature { public: @@ -427,7 +456,7 @@ class Creature : public Unit, public GridObject<Creature> uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; } void Update(uint32 time); // overwrited Unit::Update - void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const; + void GetRespawnPosition(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const; uint32 GetEquipmentId() const { return GetCreatureInfo()->equipmentId; } void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } @@ -578,7 +607,7 @@ class Creature : public Unit, public GridObject<Creature> CreatureSpellCooldowns m_CreatureCategoryCooldowns; bool canStartAttack(Unit const* u, bool force) const; - float GetAttackDistance(Unit const* pl) const; + float GetAttackDistance(Unit const* player) const; void SendAIReaction(AiReaction reactionType); @@ -598,10 +627,6 @@ class Creature : public Unit, public GridObject<Creature> MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; } void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; } - // for use only in LoadHelper, Map::Add Map::CreatureCellRelocation - Cell const& GetCurrentCell() const { return m_currentCell; } - void SetCurrentCell(Cell const& cell) { m_currentCell = cell; } - void RemoveCorpse(bool setSpawnTime = true); void ForcedDespawn(uint32 timeMSToDespawn = 0); @@ -639,6 +664,9 @@ class Creature : public Unit, public GridObject<Creature> return m_charmInfo->GetCharmSpell(pos)->GetAction(); } + void SetPosition(float x, float y, float z, float o); + void SetPosition(const Position &pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); } + void SetHomePosition(float x, float y, float z, float o) { m_homePosition.Relocate(x, y, z, o); } void SetHomePosition(const Position &pos) { m_homePosition.Relocate(pos); } void GetHomePosition(float &x, float &y, float &z, float &ori) { m_homePosition.GetPosition(x, y, z, ori); } @@ -703,7 +731,6 @@ class Creature : public Unit, public GridObject<Creature> void RegenerateHealth(); void Regenerate(Powers power); MovementGeneratorType m_defaultMovementType; - Cell m_currentCell; // store current cell where creature listed uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid uint32 m_equipmentId; @@ -725,8 +752,8 @@ class Creature : public Unit, public GridObject<Creature> uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable uint32 guid_transport; - bool isVisibleForInState(WorldObject const* seer) const; - bool canSeeAlways(WorldObject const* obj) const; + bool IsInvisibleDueToDespawn() const; + bool CanAlwaysSee(WorldObject const* obj) const; private: //WaypointMovementGenerator vars uint32 m_waypointID; diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index 3ff21645a27..90011dbae22 100755 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -371,7 +371,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, // rewarded honor points. Multiply with 10 to satisfy client data << 10 * Trinity::Honor::hk_honor_at_level(_session->GetPlayer()->getLevel(), quest->GetRewHonorMultiplier()); - data << float(0); // new 3.3.0, honor multiplier? + data << float(0.0f); // new 3.3.0, honor multiplier? data << uint32(quest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast == 0) data << int32(quest->GetRewSpellCast()); // casted spell data << uint32(quest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles) diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 03da98d5624..9e514ad34bb 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -16,26 +16,14 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Common.h" -#include "QuestDef.h" #include "GameObjectAI.h" #include "ObjectMgr.h" #include "GroupMgr.h" #include "PoolMgr.h" #include "SpellMgr.h" -#include "Spell.h" -#include "UpdateMask.h" -#include "Opcodes.h" -#include "WorldPacket.h" #include "World.h" -#include "DatabaseEnv.h" -#include "LootMgr.h" -#include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "CellImpl.h" -#include "InstanceScript.h" -#include "Battleground.h" -#include "Util.h" #include "OutdoorPvPMgr.h" #include "BattlegroundAV.h" #include "ScriptMgr.h" @@ -73,15 +61,21 @@ GameObject::GameObject() : WorldObject(), m_goValue(new GameObjectValue), m_AI(N GameObject::~GameObject() { delete m_goValue; + delete m_AI; //if (m_uint32Values) // field array can be not exist if GameOBject not loaded // CleanupsBeforeDelete(); } bool GameObject::AIM_Initialize() { + if (m_AI) + delete m_AI; m_AI = FactorySelector::SelectGameObjectAI(this); - if (!m_AI) return false; + + if (!m_AI) + return false; + m_AI->InitializeAI(); return true; } @@ -97,27 +91,31 @@ void GameObject::CleanupsBeforeDelete(bool /*finalCleanup*/) RemoveFromWorld(); if (m_uint32Values) // field array can be not exist if GameOBject not loaded - { - // Possible crash at access to deleted GO in Unit::m_gameobj - if (uint64 owner_guid = GetOwnerGUID()) - { - Unit* owner = ObjectAccessor::GetUnit(*this, owner_guid); + RemoveFromOwner(); +} - if (owner) - owner->RemoveGameObject(this, false); - else - { - const char * ownerType = "creature"; - if (IS_PLAYER_GUID(owner_guid)) - ownerType = "player"; - else if (IS_PET_GUID(owner_guid)) - ownerType = "pet"; - - sLog->outError("Delete GameObject (GUID: %u Entry: %u SpellId %u LinkedGO %u) that lost references to owner (GUID %u Type '%s') GO list. Crash possible later.", - GetGUIDLow(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), GUID_LOPART(owner_guid), ownerType); - } - } +void GameObject::RemoveFromOwner() +{ + uint64 ownerGUID = GetOwnerGUID(); + if (!ownerGUID) + return; + + if (Unit* owner = ObjectAccessor::GetUnit(*this, ownerGUID)) + { + owner->RemoveGameObject(this, false); + ASSERT(!GetOwnerGUID()); + return; } + + const char * ownerType = "creature"; + if (IS_PLAYER_GUID(ownerGUID)) + ownerType = "player"; + else if (IS_PET_GUID(ownerGUID)) + ownerType = "pet"; + + sLog->outCrash("Delete GameObject (GUID: %u Entry: %u SpellId %u LinkedGO %u) that lost references to owner (GUID %u Type '%s') GO list. Crash possible later.", + GetGUIDLow(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), GUID_LOPART(ownerGUID), ownerType); + SetOwnerGUID(0); } void GameObject::AddToWorld() @@ -141,14 +139,7 @@ void GameObject::RemoveFromWorld() if (m_zoneScript) m_zoneScript->OnGameObjectRemove(this); - // Possible crash at access to deleted GO in Unit::m_gameobj - if (uint64 owner_guid = GetOwnerGUID()) - { - if (Unit* owner = GetOwner()) - owner->RemoveGameObject(this, false); - else - sLog->outError("Delete GameObject (GUID: %u Entry: %u, Name: %s) that have references in not found creature %u GO list. Crash possible later.", GetGUIDLow(), GetGOInfo()->entry, GetGOInfo()->name.c_str(), GUID_LOPART(owner_guid)); - } + RemoveFromOwner(); WorldObject::RemoveFromWorld(); sObjectAccessor->RemoveObject(this); } @@ -382,7 +373,7 @@ void GameObject::Update(uint32 diff) if (poolid) sPoolMgr->UpdatePool<GameObject>(poolid, GetDBTableGUIDLow()); else - GetMap()->Add(this); + GetMap()->AddToMap(this); break; } } @@ -595,7 +586,7 @@ void GameObject::Refresh() return; if (isSpawned()) - GetMap()->Add(this); + GetMap()->AddToMap(this); } void GameObject::AddUniqueUse(Player* player) @@ -607,13 +598,8 @@ void GameObject::AddUniqueUse(Player* player) void GameObject::Delete() { SetLootState(GO_NOT_READY); - if (GetOwnerGUID()) - if (Unit* owner = GetOwner()) - owner->RemoveGameObject(this, false); - else //! Owner not in world anymore - SetOwnerGUID(0); + RemoveFromOwner(); - ASSERT (!GetOwnerGUID()); SendObjectDeSpawnAnim(GetGUID()); SetGoState(GO_STATE_READY); @@ -843,9 +829,9 @@ void GameObject::SaveRespawnTime() sObjectMgr->SaveGORespawnTime(m_DBTableGuid, GetInstanceId(), m_respawnTime); } -bool GameObject::isAlwaysVisibleFor(WorldObject const* seer) const +bool GameObject::IsAlwaysVisibleFor(WorldObject const* seer) const { - if (WorldObject::isAlwaysVisibleFor(seer)) + if (WorldObject::IsAlwaysVisibleFor(seer)) return true; if (IsTransport()) @@ -854,16 +840,16 @@ bool GameObject::isAlwaysVisibleFor(WorldObject const* seer) const return false; } -bool GameObject::isVisibleForInState(WorldObject const* seer) const +bool GameObject::IsInvisibleDueToDespawn() const { - if (!WorldObject::isVisibleForInState(seer)) - return false; + if (WorldObject::IsInvisibleDueToDespawn()) + return true; // Despawned if (!isSpawned()) - return false; + return true; - return true; + return false; } void GameObject::Respawn() @@ -935,9 +921,8 @@ void GameObject::TriggeringLinkedGameObject(uint32 trapEntry, Unit* target) GameObject* trapGO = NULL; { // using original GO distance - CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; Trinity::NearestGameObjectEntryInObjectRangeCheck go_check(*target, trapEntry, range); Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> checker(this, trapGO, go_check); @@ -955,9 +940,8 @@ GameObject* GameObject::LookupFishingHoleAround(float range) { GameObject* ok = NULL; - CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; Trinity::NearestGameObjectFishingHole u_check(*this, range); Trinity::GameObjectSearcher<Trinity::NearestGameObjectFishingHole> checker(this, ok, u_check); @@ -1290,8 +1274,9 @@ void GameObject::Use(Unit* user) { player->UpdateFishingSkill(); + //TODO: I do not understand this hack. Need some explanation. // prevent removing GO at spell cancel - player->RemoveGameObject(this, false); + RemoveFromOwner(); SetOwnerGUID(player->GetGUID()); //TODO: find reasonable value for fishing hole search @@ -1539,12 +1524,11 @@ void GameObject::Use(Unit* user) { case 179785: // Silverwing Flag case 179786: // Warsong Flag - // check if it's correct bg - if (bg->IsRandom() ? bg->GetTypeID(true) : bg->GetTypeID(false) == BATTLEGROUND_WS) + if (bg->GetTypeID(true) == BATTLEGROUND_WS) bg->EventPlayerClickedOnFlag(player, this); break; case 184142: // Netherstorm Flag - if (bg->IsRandom() ? bg->GetTypeID(true) : bg->GetTypeID(false) == BATTLEGROUND_EY) + if (bg->GetTypeID(true) == BATTLEGROUND_EY) bg->EventPlayerClickedOnFlag(player, this); break; } diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 3402eaa64bc..9167b40d285 100755 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -752,8 +752,8 @@ class GameObject : public WorldObject, public GridObject<GameObject> void TriggeringLinkedGameObject(uint32 trapEntry, Unit* target); - bool isAlwaysVisibleFor(WorldObject const* seer) const; - bool isVisibleForInState(WorldObject const* seer) const; + bool IsAlwaysVisibleFor(WorldObject const* seer) const; + bool IsInvisibleDueToDespawn() const; uint8 getLevelForTarget(WorldObject const* target) const { @@ -815,6 +815,7 @@ class GameObject : public WorldObject, public GridObject<GameObject> uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable private: + void RemoveFromOwner(); void SwitchDoorOrButton(bool activate, bool alternative = false); //! Object distance/size - overridden from Object::_IsWithinDist. Needs to take in account proper GO size. diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index d3832ad9151..07275166130 100755 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -1194,25 +1194,23 @@ bool Item::IsRefundExpired() return (GetPlayedTime() > 2*HOUR); } -void Item::SetSoulboundTradeable(AllowedLooterSet* allowedLooters, Player* currentOwner, bool apply) +void Item::SetSoulboundTradeable(AllowedLooterSet& allowedLooters) { - if (apply) - { - SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE); - allowedGUIDs = *allowedLooters; - } - else - { - RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE); - if (allowedGUIDs.empty()) - return; + SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE); + allowedGUIDs = allowedLooters; +} - allowedGUIDs.clear(); - SetState(ITEM_CHANGED, currentOwner); - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_BOP_TRADE); - stmt->setUInt32(0, GetGUIDLow()); - CharacterDatabase.Execute(stmt); - } +void Item::ClearSoulboundTradeable(Player* currentOwner) +{ + RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE); + if (allowedGUIDs.empty()) + return; + + allowedGUIDs.clear(); + SetState(ITEM_CHANGED, currentOwner); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_BOP_TRADE); + stmt->setUInt32(0, GetGUIDLow()); + CharacterDatabase.Execute(stmt); } bool Item::CheckSoulboundTradeExpire() @@ -1220,7 +1218,7 @@ bool Item::CheckSoulboundTradeExpire() // called from owner's update - GetOwner() MUST be valid if (GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + 2*HOUR < GetOwner()->GetTotalPlayedTime()) { - SetSoulboundTradeable(NULL, GetOwner(), false); + ClearSoulboundTradeable(GetOwner()); return true; // remove from tradeable list } diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index b872b354ea7..4a72e7fea2b 100755 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -352,7 +352,8 @@ class Item : public Object bool IsRefundExpired(); // Soulbound trade system - void SetSoulboundTradeable(AllowedLooterSet* allowedLooters, Player* currentOwner, bool apply); + void SetSoulboundTradeable(AllowedLooterSet& allowedLooters); + void ClearSoulboundTradeable(Player* currentOwner); bool CheckSoulboundTradeExpire(); void BuildUpdate(UpdateDataMapType&); diff --git a/src/server/game/Entities/Item/ItemPrototype.h b/src/server/game/Entities/Item/ItemPrototype.h index 155673edbaa..03212c129fd 100755 --- a/src/server/game/Entities/Item/ItemPrototype.h +++ b/src/server/game/Entities/Item/ItemPrototype.h @@ -729,7 +729,6 @@ struct ItemTemplate bool IsWeaponVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_WEAPON_ENCHANTMENT; } bool IsArmorVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_ARMOR_ENCHANTMENT; } bool IsConjuredConsumable() const { return Class == ITEM_CLASS_CONSUMABLE && (Flags & ITEM_PROTO_FLAG_CONJURED); } - }; // Benchmarked: Faster than std::map (insert/find) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 0b275f833e6..978d9accb64 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -780,13 +780,13 @@ void Object::ClearUpdateMask(bool remove) } } -void Object::BuildFieldsUpdate(Player* pl, UpdateDataMapType& data_map) const +void Object::BuildFieldsUpdate(Player* player, UpdateDataMapType& data_map) const { - UpdateDataMapType::iterator iter = data_map.find(pl); + UpdateDataMapType::iterator iter = data_map.find(player); if (iter == data_map.end()) { - std::pair<UpdateDataMapType::iterator, bool> p = data_map.insert(UpdateDataMapType::value_type(pl, UpdateData())); + std::pair<UpdateDataMapType::iterator, bool> p = data_map.insert(UpdateDataMapType::value_type(player, UpdateData())); ASSERT(p.second); iter = p.first; } @@ -1273,6 +1273,8 @@ void WorldObject::setActive(bool on) void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/) { + if (IsInWorld()) + RemoveFromWorld(); } void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask) @@ -1587,14 +1589,6 @@ bool Position::IsPositionValid() const return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, m_orientation); } -bool WorldObject::isValid() const -{ - if (!IsInWorld()) - return false; - - return true; -} - float WorldObject::GetGridActivationRange() const { if (ToPlayer()) @@ -1638,19 +1632,10 @@ bool WorldObject::canSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo if (this == obj) return true; - if (!obj->isValid()) - return false; - - if (GetMap() != obj->GetMap()) + if (obj->IsNeverVisible() || CanNeverSee(obj)) return false; - if (!InSamePhase(obj)) - return false; - - if (obj->isAlwaysVisibleFor(this)) - return true; - - if (canSeeAlways(obj)) + if (obj->IsAlwaysVisibleFor(this) || CanAlwaysSee(obj)) return true; bool corpseCheck = false; @@ -1704,16 +1689,16 @@ bool WorldObject::canSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo return false; } - if (!obj->isVisibleForInState(this)) + if (obj->IsInvisibleDueToDespawn()) return false; - if (!canDetect(obj, ignoreStealth)) + if (!CanDetect(obj, ignoreStealth)) return false; return true; } -bool WorldObject::canDetect(WorldObject const* obj, bool ignoreStealth) const +bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth) const { const WorldObject* seer = this; @@ -1722,19 +1707,19 @@ bool WorldObject::canDetect(WorldObject const* obj, bool ignoreStealth) const if (Unit* controller = thisUnit->GetCharmerOrOwner()) seer = controller; - if (obj->isAlwaysDetectableFor(seer)) + if (obj->IsAlwaysDetectableFor(seer)) return true; - if (!seer->canDetectInvisibilityOf(obj)) + if (!seer->CanDetectInvisibilityOf(obj)) return false; - if (!ignoreStealth && !seer->canDetectStealthOf(obj)) + if (!ignoreStealth && !seer->CanDetectStealthOf(obj)) return false; return true; } -bool WorldObject::canDetectInvisibilityOf(WorldObject const* obj) const +bool WorldObject::CanDetectInvisibilityOf(WorldObject const* obj) const { uint32 mask = obj->m_invisibility.GetFlags() & m_invisibilityDetect.GetFlags(); @@ -1765,7 +1750,7 @@ bool WorldObject::canDetectInvisibilityOf(WorldObject const* obj) const return true; } -bool WorldObject::canDetectStealthOf(WorldObject const* obj) const +bool WorldObject::CanDetectStealthOf(WorldObject const* obj) const { // Combat reach is the minimal distance (both in front and behind), // and it is also used in the range calculation. @@ -1885,10 +1870,9 @@ namespace Trinity void WorldObject::MonsterSay(const char* text, uint32 language, uint64 TargetGuid) { - CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY()); + CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::MonsterCustomChatBuilder say_build(*this, CHAT_MSG_MONSTER_SAY, text, language, TargetGuid); @@ -1900,10 +1884,9 @@ void WorldObject::MonsterSay(const char* text, uint32 language, uint64 TargetGui void WorldObject::MonsterSay(int32 textId, uint32 language, uint64 TargetGuid) { - CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY()); + CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_SAY, textId, language, TargetGuid); @@ -1915,10 +1898,9 @@ void WorldObject::MonsterSay(int32 textId, uint32 language, uint64 TargetGuid) void WorldObject::MonsterYell(const char* text, uint32 language, uint64 TargetGuid) { - CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY()); + CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::MonsterCustomChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, text, language, TargetGuid); @@ -1930,10 +1912,9 @@ void WorldObject::MonsterYell(const char* text, uint32 language, uint64 TargetGu void WorldObject::MonsterYell(int32 textId, uint32 language, uint64 TargetGuid) { - CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY()); + CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, textId, language, TargetGuid); @@ -1965,10 +1946,9 @@ void WorldObject::MonsterTextEmote(const char* text, uint64 TargetGuid, bool IsB void WorldObject::MonsterTextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote) { - CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY()); + CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::MonsterChatBuilder say_build(*this, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, textId, LANG_UNIVERSAL, TargetGuid); @@ -2199,7 +2179,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert summon->SetHomePosition(pos); summon->InitStats(duration); - Add(summon->ToCreature()); + AddToMap(summon->ToCreature()); summon->InitSummon(); //ObjectAccessor::UpdateObjectVisibility(summon); @@ -2307,7 +2287,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy break; } - map->Add(pet->ToCreature()); + map->AddToMap(pet->ToCreature()); switch (petType) { @@ -2368,7 +2348,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float ((Unit*)this)->AddGameObject(go); else go->SetSpawnedByDefault(false); - map->Add(go); + map->AddToMap(go); return go; } @@ -2410,32 +2390,30 @@ GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) const return go; } -void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange) const +void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& gameobjectList, uint32 entry, float maxSearchRange) const { - CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY())); + CellCoord pair(Trinity::ComputeCellCoord(this->GetPositionX(), this->GetPositionY())); Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - Trinity::AllGameObjectsWithEntryInRange check(this, uiEntry, fMaxSearchRange); - Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, lList, check); + Trinity::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange); + Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, gameobjectList, check); TypeContainerVisitor<Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher); - cell.Visit(pair, visitor, *(this->GetMap())); + cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange); } -void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange) const +void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& creatureList, uint32 entry, float maxSearchRange) const { - CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY())); + CellCoord pair(Trinity::ComputeCellCoord(this->GetPositionX(), this->GetPositionY())); Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - Trinity::AllCreaturesOfEntryInRange check(this, uiEntry, fMaxSearchRange); - Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(this, lList, check); + Trinity::AllCreaturesOfEntryInRange check(this, entry, maxSearchRange); + Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(this, creatureList, check); TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher); - cell.Visit(pair, visitor, *(this->GetMap())); + cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange); } /* @@ -2546,9 +2524,8 @@ void WorldObject::GetNearPoint(WorldObject const* /*searcher*/, float &x, float // adding used positions around object { - CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::NearUsedPosDo u_do(*this, searcher, absAngle, selector); @@ -2748,19 +2725,19 @@ void WorldObject::DestroyForNearbyPlayers() VisitNearbyWorldObject(GetVisibilityRange(), searcher); for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) { - Player* plr = (*iter); + Player* player = (*iter); - if (plr == this) + if (player == this) continue; - if (!plr->HaveAtClient(this)) + if (!player->HaveAtClient(this)) continue; - if (isType(TYPEMASK_UNIT) && ((Unit*)this)->GetCharmerGUID() == plr->GetGUID()) // TODO: this is for puppet + if (isType(TYPEMASK_UNIT) && ((Unit*)this)->GetCharmerGUID() == player->GetGUID()) // TODO: this is for puppet continue; - DestroyForPlayer(plr); - plr->m_clientGUIDs.erase(GetGUID()); + DestroyForPlayer(player); + player->m_clientGUIDs.erase(GetGUID()); } } @@ -2828,13 +2805,13 @@ struct WorldObjectChangeAccumulator } } - void BuildPacket(Player* plr) + void BuildPacket(Player* player) { // Only send update once to a player - if (plr_list.find(plr->GetGUID()) == plr_list.end() && plr->HaveAtClient(&i_object)) + if (plr_list.find(player->GetGUID()) == plr_list.end() && player->HaveAtClient(&i_object)) { - i_object.BuildFieldsUpdate(plr, i_updateDatas); - plr_list.insert(plr->GetGUID()); + i_object.BuildFieldsUpdate(player, i_updateDatas); + plr_list.insert(player->GetGUID()); } } @@ -2843,9 +2820,8 @@ struct WorldObjectChangeAccumulator void WorldObject::BuildUpdate(UpdateDataMapType& data_map) { - CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY()); + CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); WorldObjectChangeAccumulator notifier(*this, data_map); TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier); diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index d27ea23ba7e..eab4dbeba99 100755 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -527,9 +527,11 @@ template<class T> class GridObject { public: - GridReference<T> &GetGridRef() { return m_gridRef; } - protected: - GridReference<T> m_gridRef; + bool IsInGrid() const { return _gridRef.isValid(); } + void AddToGrid(GridRefManager<T>& m) { ASSERT(!IsInGrid()); _gridRef.link(&m, (T*)this); } + void RemoveFromGrid() { ASSERT(IsInGrid()); _gridRef.unlink(); } + private: + GridReference<T> _gridRef; }; template <class T_VALUES, class T_FLAGS, class FLAG_TYPE, uint8 ARRAY_SIZE> @@ -667,12 +669,17 @@ class WorldObject : public Object, public WorldLocation } float GetDistanceZ(const WorldObject* obj) const; + bool IsSelfOrInSameMap(const WorldObject* obj) const + { + if (this == obj) + return true; + return IsInMap(obj); + } bool IsInMap(const WorldObject* obj) const { if (obj) return IsInWorld() && obj->IsInWorld() && (GetMap() == obj->GetMap()) && InSamePhase(obj); - else - return false; + return false; } bool IsWithinDist3d(float x, float y, float z, float dist) const { return IsInDist(x, y, z, dist + GetObjectSize()); } @@ -682,7 +689,6 @@ class WorldObject : public Object, public WorldLocation { return IsInDist2d(x, y, dist + GetObjectSize()); } bool IsWithinDist2d(const Position* pos, float dist) const { return IsInDist2d(pos, dist + GetObjectSize()); } - virtual bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) const; // use only if you will sure about placing both object at same map bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true) const { @@ -730,19 +736,6 @@ class WorldObject : public Object, public WorldLocation virtual void SaveRespawnTime() {} void AddObjectToRemoveList(); - virtual bool isValid() const; - - virtual bool isAlwaysVisibleFor(WorldObject const* /*seer*/) const { return false; } - virtual bool canSeeAlways(WorldObject const* /*obj*/) const { return false; } - bool canDetect(WorldObject const* obj, bool ignoreStealth) const; - - virtual bool isVisibleForInState(WorldObject const* /*seer*/) const { return true; } - - bool canDetectInvisibilityOf(WorldObject const* obj) const; - bool canDetectStealthOf(WorldObject const* obj) const; - - virtual bool isAlwaysDetectableFor(WorldObject const* /*seer*/) const { return false; } - float GetGridActivationRange() const; float GetVisibilityRange() const; float GetSightRange(const WorldObject* target = NULL) const; @@ -807,9 +800,9 @@ class WorldObject : public Object, public WorldLocation bool isActiveObject() const { return m_isActive; } void setActive(bool isActiveObject); void SetWorldObject(bool apply); - template<class NOTIFIER> void VisitNearbyObject(const float &radius, NOTIFIER ¬ifier) const { if (IsInWorld()) GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); } - template<class NOTIFIER> void VisitNearbyGridObject(const float &radius, NOTIFIER ¬ifier) const { if (IsInWorld()) GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); } - template<class NOTIFIER> void VisitNearbyWorldObject(const float &radius, NOTIFIER ¬ifier) const { if (IsInWorld()) GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); } + template<class NOTIFIER> void VisitNearbyObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); } + template<class NOTIFIER> void VisitNearbyGridObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); } + template<class NOTIFIER> void VisitNearbyWorldObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); } #ifdef MAP_BASED_RAND_GEN int32 irand(int32 min, int32 max) const { return int32 (GetMap()->mtRand.randInt(max - min)) + min; } @@ -848,6 +841,11 @@ class WorldObject : public Object, public WorldLocation void SetLocationMapId(uint32 _mapId) { m_mapId = _mapId; } void SetLocationInstanceId(uint32 _instanceId) { m_InstanceId = _instanceId; } + virtual bool IsNeverVisible() const { return !IsInWorld(); } + virtual bool IsAlwaysVisibleFor(WorldObject const* /*seer*/) const { return false; } + virtual bool IsInvisibleDueToDespawn() const { return false; } + //difference from IsAlwaysVisibleFor: 1. after distance check; 2. use owner or charmer as seer + virtual bool IsAlwaysDetectableFor(WorldObject const* /*seer*/) const { return false; } private: Map* m_currMap; //current object's Map location @@ -857,6 +855,14 @@ class WorldObject : public Object, public WorldLocation uint16 m_notifyflags; uint16 m_executed_notifies; + + virtual bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) const; + + bool CanNeverSee(WorldObject const* obj) const { return GetMap() != obj->GetMap() || !InSamePhase(obj); } + virtual bool CanAlwaysSee(WorldObject const* /*obj*/) const { return false; } + bool CanDetect(WorldObject const* obj, bool ignoreStealth) const; + bool CanDetectInvisibilityOf(WorldObject const* obj) const; + bool CanDetectStealthOf(WorldObject const* obj) const; }; namespace Trinity diff --git a/src/server/game/Entities/Object/ObjectPosSelector.cpp b/src/server/game/Entities/Object/ObjectPosSelector.cpp index c322c35ef81..fd32e531ed7 100755 --- a/src/server/game/Entities/Object/ObjectPosSelector.cpp +++ b/src/server/game/Entities/Object/ObjectPosSelector.cpp @@ -55,10 +55,10 @@ ObjectPosSelector::UsedPosList::value_type const* ObjectPosSelector::nextUsedPos void ObjectPosSelector::AddUsedPos(float size, float angle, float dist) { - if (angle>=0) - m_UsedPosLists[USED_POS_PLUS].insert(UsedPosList::value_type(angle, UsedPos(1.0, size, dist))); + if (angle >= 0) + m_UsedPosLists[USED_POS_PLUS].insert(UsedPosList::value_type(angle, UsedPos(1.0f, size, dist))); else - m_UsedPosLists[USED_POS_MINUS].insert(UsedPosList::value_type(-angle, UsedPos(-1.0, size, dist))); + m_UsedPosLists[USED_POS_MINUS].insert(UsedPosList::value_type(-angle, UsedPos(-1.0f, size, dist))); } void ObjectPosSelector::InitializeAngle() @@ -76,9 +76,9 @@ void ObjectPosSelector::InitializeAngle() bool ObjectPosSelector::FirstAngle(float& angle) { if (m_UsedPosLists[USED_POS_PLUS].empty() && !m_UsedPosLists[USED_POS_MINUS].empty() ) - return NextAngleFor(*m_UsedPosLists[USED_POS_MINUS].begin(), 1.0, USED_POS_PLUS, angle); + return NextAngleFor(*m_UsedPosLists[USED_POS_MINUS].begin(), 1.0f, USED_POS_PLUS, angle); else if (m_UsedPosLists[USED_POS_MINUS].empty() && !m_UsedPosLists[USED_POS_PLUS].empty() ) - return NextAngleFor(*m_UsedPosLists[USED_POS_PLUS].begin(), -1.0, USED_POS_MINUS, angle); + return NextAngleFor(*m_UsedPosLists[USED_POS_PLUS].begin(), -1.0f, USED_POS_MINUS, angle); return false; } @@ -118,9 +118,9 @@ bool ObjectPosSelector::NextPosibleAngle(float& angle) { bool ok; if (m_smallStepOk[USED_POS_PLUS]) - ok = NextSmallStepAngle(1.0, USED_POS_PLUS, angle); + ok = NextSmallStepAngle(1.0f, USED_POS_PLUS, angle); else - ok = NextAngleFor(*m_nextUsedPos[USED_POS_PLUS], 1.0, USED_POS_PLUS, angle); + ok = NextAngleFor(*m_nextUsedPos[USED_POS_PLUS], 1.0f, USED_POS_PLUS, angle); if (!ok) ++m_nextUsedPos[USED_POS_PLUS]; // increase. only at fail (original or checked) @@ -131,9 +131,9 @@ bool ObjectPosSelector::NextPosibleAngle(float& angle) { bool ok; if (m_smallStepOk[USED_POS_MINUS]) - ok = NextSmallStepAngle(-1.0, USED_POS_MINUS, angle); + ok = NextSmallStepAngle(-1.0f, USED_POS_MINUS, angle); else - ok = NextAngleFor(*m_nextUsedPos[USED_POS_MINUS], -1.0, USED_POS_MINUS, angle); + ok = NextAngleFor(*m_nextUsedPos[USED_POS_MINUS], -1.0f, USED_POS_MINUS, angle); if (!ok) ++m_nextUsedPos[USED_POS_MINUS]; @@ -142,10 +142,10 @@ bool ObjectPosSelector::NextPosibleAngle(float& angle) else // both list empty { if (m_smallStepOk[USED_POS_PLUS] && (!m_smallStepOk[USED_POS_MINUS] || m_smallStepAngle[USED_POS_PLUS] <= m_smallStepAngle[USED_POS_MINUS])) - return NextSmallStepAngle(1.0, USED_POS_PLUS, angle); + return NextSmallStepAngle(1.0f, USED_POS_PLUS, angle); // -- direction less updated else if (m_smallStepOk[USED_POS_MINUS]) - return NextSmallStepAngle(-1.0, USED_POS_MINUS, angle); + return NextSmallStepAngle(-1.0f, USED_POS_MINUS, angle); } // no angles diff --git a/src/server/game/Entities/Object/ObjectPosSelector.h b/src/server/game/Entities/Object/ObjectPosSelector.h index efb655ca1f7..df879c4dd19 100755 --- a/src/server/game/Entities/Object/ObjectPosSelector.h +++ b/src/server/game/Entities/Object/ObjectPosSelector.h @@ -68,8 +68,8 @@ struct ObjectPosSelector bool CheckOriginal() const { - return (m_UsedPosLists[USED_POS_PLUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_PLUS].begin(), 1.0, 0)) && - (m_UsedPosLists[USED_POS_MINUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_MINUS].begin(), -1.0, 0)); + return (m_UsedPosLists[USED_POS_PLUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_PLUS].begin(), 1.0f, 0)) && + (m_UsedPosLists[USED_POS_MINUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_MINUS].begin(), -1.0f, 0)); } bool IsNonBalanced() const { return m_UsedPosLists[USED_POS_PLUS].empty() != m_UsedPosLists[USED_POS_MINUS].empty(); } diff --git a/src/server/game/Entities/Object/Updates/UpdateMask.h b/src/server/game/Entities/Object/Updates/UpdateMask.h index 09bc0b4cc80..abe3c299062 100755 --- a/src/server/game/Entities/Object/Updates/UpdateMask.h +++ b/src/server/game/Entities/Object/Updates/UpdateMask.h @@ -72,6 +72,9 @@ class UpdateMask UpdateMask& operator = (const UpdateMask& mask) { + if (this == &mask) + return *this; + SetCount(mask.mCount); memcpy(mUpdateMask, mask.mUpdateMask, mBlocks << 2); diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 4150810a4ab..82c551c2374 100755 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -185,7 +185,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c CreatureTemplate const* cinfo = GetCreatureInfo(); if (cinfo->type == CREATURE_TYPE_CRITTER) { - map->Add(this->ToCreature()); + map->AddToMap(this->ToCreature()); return true; } @@ -279,7 +279,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c } owner->SetMinion(this, true); - map->Add(this->ToCreature()); + map->AddToMap(this->ToCreature()); InitTalentForLevel(); // set original talents points before spell loading @@ -618,7 +618,7 @@ void Pet::LoseHappiness() return; int32 addvalue = 670; //value is 70/35/17/8/4 (per min) * 1000 / 8 (timer 7.5 secs) if (isInCombat()) //we know in combat happiness fades faster, multiplier guess - addvalue = int32(addvalue * 1.5); + addvalue = int32(addvalue * 1.5f); ModifyPower(POWER_HAPPINESS, -addvalue); } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 0aa47b38412..9b1b2c34aaa 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -1148,7 +1148,7 @@ bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo) } } - for (PlayerCreateInfoItems::const_iterator item_id_itr = info->item.begin(); item_id_itr != info->item.end(); ++item_id_itr++) + for (PlayerCreateInfoItems::const_iterator item_id_itr = info->item.begin(); item_id_itr != info->item.end(); ++item_id_itr) StoreNewItemInBestSlots(item_id_itr->item_id, item_id_itr->item_amount); // bags and main-hand weapon must equipped at this moment @@ -2020,21 +2020,20 @@ bool Player::ToggleDND() return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); } -uint8 Player::chatTag() const +uint8 Player::GetChatTag() const { - // it's bitmask - // 0x8 - ?? - // 0x4 - gm - // 0x2 - dnd - // 0x1 - afk + uint8 tag = CHAT_TAG_NONE; + if (isGMChat()) - return 4; - else if (isDND()) - return 3; + tag |= CHAT_TAG_GM; + if (isDND()) + tag |= CHAT_TAG_DND; if (isAFK()) - return 1; - else - return 0; + tag |= CHAT_TAG_AFK; + if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER)) + tag |= CHAT_TAG_DEV; + + return tag; } void Player::SendTeleportPacket(Position &oldPos) @@ -2278,7 +2277,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // remove from old map now if (oldmap) - oldmap->Remove(this, false); + oldmap->RemovePlayerFromMap(this, false); // new final coordinates float final_x = x; @@ -2456,7 +2455,7 @@ void Player::RegenerateAll() // Runes act as cooldowns, and they don't need to send any data if (getClass() == CLASS_DEATH_KNIGHT) - for (uint32 i = 0; i < MAX_RUNES; ++i) + for (uint8 i = 0; i < MAX_RUNES; ++i) if (uint32 cd = GetRuneCooldown(i)) SetRuneCooldown(i, (cd > m_regenTimer) ? cd - m_regenTimer : 0); @@ -2631,7 +2630,7 @@ void Player::RegenerateHealth() ApplyPctN(addvalue, GetTotalAuraModifier(SPELL_AURA_MOD_REGEN_DURING_COMBAT)); if (!IsStandState()) - addvalue *= 1.5; + addvalue *= 1.5f; } // always regeneration bonus (including combat) @@ -2860,7 +2859,6 @@ void Player::SetGMVisible(bool on) if (on) { m_ExtraFlags &= ~PLAYER_EXTRA_GM_INVISIBLE; //remove flag - m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GM, SEC_PLAYER); } else @@ -5044,7 +5042,7 @@ void Player::BuildPlayerRepop() sLog->outError("Error creating corpse for Player %s [%u]", GetName(), GetGUIDLow()); return; } - GetMap()->Add(corpse); + GetMap()->AddToMap(corpse); // convert player body to ghost SetHealth(1); @@ -5063,7 +5061,7 @@ void Player::BuildPlayerRepop() StopMirrorTimers(); //disable timers(bars) - SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, (float)1.0); //see radius of death player? + SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, float(1.0f)); //see radius of death player? // set and clear other SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND); @@ -6176,13 +6174,13 @@ static uint32 bonusSkillLevels[] = {75, 150, 225, 300, 375, 450}; bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) { - sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "UpdateSkillPro(SkillId %d, Chance %3.1f%%)", SkillId, Chance/10.0); + sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "UpdateSkillPro(SkillId %d, Chance %3.1f%%)", SkillId, Chance / 10.0f); if (!SkillId) return false; if (Chance <= 0) // speedup in 0 chance case { - sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "Player::UpdateSkillPro Chance=%3.1f%% missed", Chance/10.0); + sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "Player::UpdateSkillPro Chance=%3.1f%% missed", Chance / 10.0f); return false; } @@ -6220,19 +6218,19 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) } UpdateSkillEnchantments(SkillId, SkillValue, new_value); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, SkillId); - sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "Player::UpdateSkillPro Chance=%3.1f%% taken", Chance/10.0); + sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "Player::UpdateSkillPro Chance=%3.1f%% taken", Chance / 10.0f); return true; } - sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "Player::UpdateSkillPro Chance=%3.1f%% missed", Chance/10.0); + sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "Player::UpdateSkillPro Chance=%3.1f%% missed", Chance / 10.0f); return false; } -void Player::UpdateWeaponSkill (WeaponAttackType attType) +void Player::UpdateWeaponSkill(WeaponAttackType attType) { // no skill gain in pvp - Unit* pVictim = getVictim(); - if (pVictim && pVictim->GetTypeId() == TYPEID_PLAYER) + Unit* victim = getVictim(); + if (victim && victim->GetTypeId() == TYPEID_PLAYER) return; if (IsInFeralForm()) @@ -6241,42 +6239,25 @@ void Player::UpdateWeaponSkill (WeaponAttackType attType) if (GetShapeshiftForm() == FORM_TREE) return; // use weapon but not skill up - if (pVictim && pVictim->GetTypeId() == TYPEID_UNIT && (pVictim->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_SKILLGAIN)) + if (victim && victim->GetTypeId() == TYPEID_UNIT && (victim->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_SKILLGAIN)) return; uint32 weapon_skill_gain = sWorld->getIntConfig(CONFIG_SKILL_GAIN_WEAPON); - switch (attType) - { - case BASE_ATTACK: - { - Item* tmpitem = GetWeaponForAttack(attType, true); + Item* tmpitem = GetWeaponForAttack(attType, true); + if (!tmpitem && attType == BASE_ATTACK) + UpdateSkill(SKILL_UNARMED, weapon_skill_gain); + else if (tmpitem && tmpitem->GetTemplate()->SubClass != ITEM_SUBCLASS_WEAPON_FISHING_POLE) + UpdateSkill(tmpitem->GetSkill(), weapon_skill_gain); - if (!tmpitem) - UpdateSkill(SKILL_UNARMED, weapon_skill_gain); - else if (tmpitem->GetTemplate()->SubClass != ITEM_SUBCLASS_WEAPON_FISHING_POLE) - UpdateSkill(tmpitem->GetSkill(), weapon_skill_gain); - break; - } - case OFF_ATTACK: - case RANGED_ATTACK: - { - Item* tmpitem = GetWeaponForAttack(attType, true); - if (tmpitem) - UpdateSkill(tmpitem->GetSkill(), weapon_skill_gain); - break; - } - default: - break; - } UpdateAllCritPercentages(); } -void Player::UpdateCombatSkills(Unit* pVictim, WeaponAttackType attType, bool defence) +void Player::UpdateCombatSkills(Unit* victim, WeaponAttackType attType, bool defence) { - uint8 plevel = getLevel(); // if defense than pVictim == attacker + uint8 plevel = getLevel(); // if defense than victim == attacker uint8 greylevel = Trinity::XP::GetGrayLevel(plevel); - uint8 moblevel = pVictim->getLevelForTarget(this); + uint8 moblevel = victim->getLevelForTarget(this); if (moblevel < greylevel) return; @@ -6727,9 +6708,9 @@ ActionButton const* Player::GetActionButton(uint8 button) return &buttonItr->second; } -bool Player::SetPosition(float x, float y, float z, float orientation, bool teleport) +bool Player::UpdatePosition(float x, float y, float z, float orientation, bool teleport) { - if (!Unit::SetPosition(x, y, z, orientation, teleport)) + if (!Unit::UpdatePosition(x, y, z, orientation, teleport)) return false; //if (movementInfo.flags & MOVEMENTFLAG_MOVING) @@ -6743,7 +6724,7 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION); // code block for underwater state update - // Unit::SetPosition() checks for validity and updates our coordinates + // Unit::UpdatePosition() checks for validity and updates our coordinates // so we re-fetch them instead of using "raw" coordinates from function params UpdateUnderwaterState(GetMap(), GetPositionX(), GetPositionY(), GetPositionZ()); @@ -9533,7 +9514,7 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid) // End Round (timer), better explain this by example, eg. ends in 19:59 -> A:BC data << uint32(0xde9) << uint32(0x0); // 16 3561 C data << uint32(0xde8) << uint32(0x0); // 17 3560 B - data << uint32(0xde7) << uint32(0x0); // 18 3559 A + data << uint32(0xde7) << uint32(0x0); // 18 3559 A data << uint32(0xe35) << uint32(0x0); // 19 3637 East g - Horde control data << uint32(0xe34) << uint32(0x0); // 20 3636 West g - Horde control data << uint32(0xe33) << uint32(0x0); // 21 3635 South g - Horde control @@ -10408,7 +10389,7 @@ bool Player::HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 return false; } -InventoryResult Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count) const +InventoryResult Player::CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count) const { ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(entry); if (!pProto) @@ -10492,7 +10473,7 @@ bool Player::HasItemTotemCategory(uint32 TotemCategory) const return false; } -InventoryResult Player::_CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec &dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const +InventoryResult Player::CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec &dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const { Item* pItem2 = GetItemByPos(bag, slot); @@ -10566,9 +10547,9 @@ InventoryResult Player::_CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, Item return EQUIP_ERR_OK; } -InventoryResult Player::_CanStoreItem_InBag(uint8 bag, ItemPosCountVec &dest, ItemTemplate const* pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const +InventoryResult Player::CanStoreItem_InBag(uint8 bag, ItemPosCountVec &dest, ItemTemplate const* pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const { - // skip specific bag already processed in first called _CanStoreItem_InBag + // skip specific bag already processed in first called CanStoreItem_InBag if (bag == skip_bag) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; @@ -10593,7 +10574,7 @@ InventoryResult Player::_CanStoreItem_InBag(uint8 bag, ItemPosCountVec &dest, It for (uint32 j = 0; j < pBag->GetBagSize(); j++) { - // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot + // skip specific slot already processed in first called CanStoreItem_InSpecificSlot if (j == skip_slot) continue; @@ -10636,7 +10617,7 @@ InventoryResult Player::_CanStoreItem_InBag(uint8 bag, ItemPosCountVec &dest, It return EQUIP_ERR_OK; } -InventoryResult Player::_CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec &dest, ItemTemplate const* pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const +InventoryResult Player::CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec &dest, ItemTemplate const* pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const { //this is never called for non-bag slots so we can do this if (pSrcItem && pSrcItem->IsNotEmptyBag()) @@ -10644,7 +10625,7 @@ InventoryResult Player::_CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 s for (uint32 j = slot_begin; j < slot_end; j++) { - // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot + // skip specific slot already processed in first called CanStoreItem_InSpecificSlot if (INVENTORY_SLOT_BAG_0 == skip_bag && j == skip_slot) continue; @@ -10687,7 +10668,7 @@ InventoryResult Player::_CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 s return EQUIP_ERR_OK; } -InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 entry, uint32 count, Item* pItem, bool swap, uint32* no_space_count) const +InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 entry, uint32 count, Item* pItem, bool swap, uint32* no_space_count) const { sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "STORAGE: CanStoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, entry, count); @@ -10719,7 +10700,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de // check count of items (skip for auto move for same player from bank) uint32 no_similar_count = 0; // can't store this amount similar items - InventoryResult res = _CanTakeMoreSimilarItems(entry, count, pItem, &no_similar_count); + InventoryResult res = CanTakeMoreSimilarItems(entry, count, pItem, &no_similar_count); if (res != EQUIP_ERR_OK) { if (count == no_similar_count) @@ -10734,7 +10715,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de // in specific slot if (bag != NULL_BAG && slot != NULL_SLOT) { - res = _CanStoreItem_InSpecificSlot(bag, slot, dest, pProto, count, swap, pItem); + res = CanStoreItem_InSpecificSlot(bag, slot, dest, pProto, count, swap, pItem); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10763,7 +10744,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de { if (bag == INVENTORY_SLOT_BAG_0) // inventory { - res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, true, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(KEYRING_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10781,7 +10762,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; } - res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10802,9 +10783,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de else // equipped bag { // we need check 2 time (specialized/non_specialized), use NULL_BAG to prevent skipping bag - res = _CanStoreItem_InBag(bag, dest, pProto, count, true, false, pItem, NULL_BAG, slot); + res = CanStoreItem_InBag(bag, dest, pProto, count, true, false, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) - res = _CanStoreItem_InBag(bag, dest, pProto, count, true, true, pItem, NULL_BAG, slot); + res = CanStoreItem_InBag(bag, dest, pProto, count, true, true, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) { @@ -10832,7 +10813,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de if (pProto->BagFamily & BAG_FAMILY_MASK_KEYS) { uint32 keyringSize = GetMaxKeyringSize(); - res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START, KEYRING_SLOT_START+keyringSize, dest, pProto, count, false, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(KEYRING_SLOT_START, KEYRING_SLOT_START+keyringSize, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10850,7 +10831,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; } - res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, false, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10870,7 +10851,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de } else if (pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS) { - res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, false, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10889,7 +10870,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de } } - res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10909,9 +10890,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de } else // equipped bag { - res = _CanStoreItem_InBag(bag, dest, pProto, count, false, false, pItem, NULL_BAG, slot); + res = CanStoreItem_InBag(bag, dest, pProto, count, false, false, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) - res = _CanStoreItem_InBag(bag, dest, pProto, count, false, true, pItem, NULL_BAG, slot); + res = CanStoreItem_InBag(bag, dest, pProto, count, false, true, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) { @@ -10937,7 +10918,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de // search stack for merge to if (pProto->Stackable != 1) { - res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, true, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(KEYRING_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10955,7 +10936,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; } - res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10977,7 +10958,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de { for (uint32 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) { - res = _CanStoreItem_InBag(i, dest, pProto, count, true, false, pItem, bag, slot); + res = CanStoreItem_InBag(i, dest, pProto, count, true, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) continue; @@ -10995,7 +10976,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de for (uint32 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) { - res = _CanStoreItem_InBag(i, dest, pProto, count, true, true, pItem, bag, slot); + res = CanStoreItem_InBag(i, dest, pProto, count, true, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) continue; @@ -11017,7 +10998,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de if (pProto->BagFamily & BAG_FAMILY_MASK_KEYS) { uint32 keyringSize = GetMaxKeyringSize(); - res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START, KEYRING_SLOT_START+keyringSize, dest, pProto, count, false, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(KEYRING_SLOT_START, KEYRING_SLOT_START+keyringSize, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -11037,7 +11018,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de } else if (pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS) { - res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, false, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -11058,7 +11039,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de for (uint32 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) { - res = _CanStoreItem_InBag(i, dest, pProto, count, false, false, pItem, bag, slot); + res = CanStoreItem_InBag(i, dest, pProto, count, false, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) continue; @@ -11078,7 +11059,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de return EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG; // search free slot - res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -11098,7 +11079,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) { - res = _CanStoreItem_InBag(i, dest, pProto, count, false, true, pItem, bag, slot); + res = CanStoreItem_InBag(i, dest, pProto, count, false, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) continue; @@ -11597,7 +11578,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest return res; } - res = _CanStoreItem_InSpecificSlot(bag, slot, dest, pProto, count, swap, pItem); + res = CanStoreItem_InSpecificSlot(bag, slot, dest, pProto, count, swap, pItem); if (res != EQUIP_ERR_OK) return res; @@ -11618,7 +11599,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest { if (bag == INVENTORY_SLOT_BAG_0) { - res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) return res; @@ -11627,9 +11608,9 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest } else { - res = _CanStoreItem_InBag(bag, dest, pProto, count, true, false, pItem, NULL_BAG, slot); + res = CanStoreItem_InBag(bag, dest, pProto, count, true, false, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) - res = _CanStoreItem_InBag(bag, dest, pProto, count, true, true, pItem, NULL_BAG, slot); + res = CanStoreItem_InBag(bag, dest, pProto, count, true, true, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) return res; @@ -11642,7 +11623,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest // search free slot in bag if (bag == INVENTORY_SLOT_BAG_0) { - res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) return res; @@ -11651,9 +11632,9 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest } else { - res = _CanStoreItem_InBag(bag, dest, pProto, count, false, false, pItem, NULL_BAG, slot); + res = CanStoreItem_InBag(bag, dest, pProto, count, false, false, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) - res = _CanStoreItem_InBag(bag, dest, pProto, count, false, true, pItem, NULL_BAG, slot); + res = CanStoreItem_InBag(bag, dest, pProto, count, false, true, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) return res; @@ -11669,7 +11650,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest if (pProto->Stackable != 1) { // in slots - res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) return res; @@ -11681,7 +11662,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest { for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) { - res = _CanStoreItem_InBag(i, dest, pProto, count, true, false, pItem, bag, slot); + res = CanStoreItem_InBag(i, dest, pProto, count, true, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) continue; @@ -11692,7 +11673,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) { - res = _CanStoreItem_InBag(i, dest, pProto, count, true, true, pItem, bag, slot); + res = CanStoreItem_InBag(i, dest, pProto, count, true, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) continue; @@ -11706,7 +11687,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest { for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) { - res = _CanStoreItem_InBag(i, dest, pProto, count, false, false, pItem, bag, slot); + res = CanStoreItem_InBag(i, dest, pProto, count, false, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) continue; @@ -11716,7 +11697,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest } // search free space - res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) return res; @@ -11725,7 +11706,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) { - res = _CanStoreItem_InBag(i, dest, pProto, count, false, true, pItem, bag, slot); + res = CanStoreItem_InBag(i, dest, pProto, count, false, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) continue; @@ -11898,8 +11879,14 @@ void Player::RemoveAmmo() UpdateDamagePhysical(RANGED_ATTACK); } +Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId) +{ + AllowedLooterSet allowedLooters; + return StoreNewItem(dest, item, update, randomPropertyId, allowedLooters); +} + // Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case. -Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet* allowedLooters) +Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet& allowedLooters) { uint32 count = 0; for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) @@ -11919,16 +11906,18 @@ Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update if (proto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE && proto->Spells[i].SpellId > 0) // On obtain trigger CastSpell(this, proto->Spells[i].SpellId, true, pItem); - if (allowedLooters && pItem->GetTemplate()->GetMaxStackSize() == 1 && pItem->IsSoulBound()) + if (allowedLooters.size() > 1 && pItem->GetTemplate()->GetMaxStackSize() == 1 && pItem->IsSoulBound()) { - pItem->SetSoulboundTradeable(allowedLooters, this, true); + pItem->SetSoulboundTradeable(allowedLooters); pItem->SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, GetTotalPlayedTime()); m_itemSoulboundTradeable.push_back(pItem); // save data std::ostringstream ss; - for (AllowedLooterSet::iterator itr = allowedLooters->begin(); itr != allowedLooters->end(); ++itr) - ss << *itr << ' '; + AllowedLooterSet::const_iterator itr = allowedLooters.begin(); + ss << *itr; + for (++itr; itr != allowedLooters.end(); ++itr) + ss << ' ' << *itr; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_ITEM_BOP_TRADE); stmt->setUInt32(0, pItem->GetGUIDLow()); @@ -12051,7 +12040,7 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor pItem->SetNotRefundable(this); - pItem->SetSoulboundTradeable(NULL, this, false); + pItem->ClearSoulboundTradeable(this); RemoveTradeableItem(pItem); pItem->SetState(ITEM_REMOVED, this); } @@ -12168,7 +12157,7 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor pItem->SetNotRefundable(this); - pItem->SetSoulboundTradeable(NULL, this, false); + pItem->ClearSoulboundTradeable(this); RemoveTradeableItem(pItem); pItem->SetState(ITEM_REMOVED, this); pItem2->SetState(ITEM_CHANGED, this); @@ -12388,7 +12377,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) RemoveItemDurations(pItem); pItem->SetNotRefundable(this); - pItem->SetSoulboundTradeable(NULL, this, false); + pItem->ClearSoulboundTradeable(this); RemoveTradeableItem(pItem); const ItemTemplate* proto = pItem->GetTemplate(); @@ -13335,17 +13324,17 @@ void Player::UpdateSoulboundTradeItems() { if (!*itr) { - itr = m_itemSoulboundTradeable.erase(itr++); + m_itemSoulboundTradeable.erase(itr++); continue; } if ((*itr)->GetOwnerGUID() != GetGUID()) { - itr = m_itemSoulboundTradeable.erase(itr++); + m_itemSoulboundTradeable.erase(itr++); continue; } if ((*itr)->CheckSoulboundTradeExpire()) { - itr = m_itemSoulboundTradeable.erase(itr++); + m_itemSoulboundTradeable.erase(itr++); continue; } ++itr; @@ -13591,7 +13580,7 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool } } } - // Cast custom spell vs all equal basepoints getted from enchant_amount + // Cast custom spell vs all equal basepoints got from enchant_amount if (basepoints) CastCustomSpell(this, enchant_spell_id, &basepoints, &basepoints, &basepoints, true, item); else @@ -14581,8 +14570,7 @@ bool Player::CanCompleteQuest(uint32 quest_id) if (!qInfo) return false; - RewardedQuestSet::iterator rewItr = m_RewardedQuests.find(quest_id); - if (!qInfo->IsRepeatable() && rewItr != m_RewardedQuests.end()) + if (!qInfo->IsRepeatable() && m_RewardedQuests.find(quest_id) != m_RewardedQuests.end()) return false; // not allow re-complete quest // auto complete quest @@ -14911,8 +14899,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, if (log_slot < MAX_QUEST_LOG_SIZE) SetQuestSlot(log_slot, 0); - RewardedQuestSet::const_iterator rewItr = m_RewardedQuests.find(quest_id); - bool rewarded = (rewItr != m_RewardedQuests.end()); + bool rewarded = (m_RewardedQuests.find(quest_id) != m_RewardedQuests.end()); // Not give XP in case already completed once repeatable quest uint32 XP = rewarded ? 0 : uint32(quest->XPValue(this)*sWorld->getRate(RATE_XP_QUEST)); @@ -15661,11 +15648,11 @@ void Player::GroupEventHappens(uint32 questId, WorldObject const* pEventObject) { for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* pGroupGuy = itr->getSource(); + Player* player = itr->getSource(); // for any leave or dead (with not released body) group member at appropriate distance - if (pGroupGuy && pGroupGuy->IsAtGroupRewardDistance(pEventObject) && !pGroupGuy->GetCorpse()) - pGroupGuy->AreaExploredOrEventHappens(questId); + if (player && player->IsAtGroupRewardDistance(pEventObject) && !player->GetCorpse()) + player->AreaExploredOrEventHappens(questId); } } else @@ -17474,7 +17461,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F AllowedLooterSet looters; for (Tokens::iterator itr = GUIDlist.begin(); itr != GUIDlist.end(); ++itr) looters.insert(atol(*itr)); - item->SetSoulboundTradeable(&looters, this, true); + item->SetSoulboundTradeable(looters); m_itemSoulboundTradeable.push_back(item); } else @@ -19029,7 +19016,6 @@ void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 player_bytes2 |= facialHair; CharacterDatabase.PExecute("UPDATE characters SET gender = '%u', playerBytes = '%u', playerBytes2 = '%u' WHERE guid = '%u'", gender, skin | (face << 8) | (hairStyle << 16) | (hairColor << 24), player_bytes2, GUID_LOPART(guid)); - sWorld->ReloadSingleCharacterNameData(GUID_LOPART(guid)); } void Player::SendAttackSwingDeadTarget() @@ -19353,7 +19339,7 @@ inline void Player::BuildPlayerChat(WorldPacket* data, uint8 msgtype, const std: *data << uint64(GetGUID()); *data << uint32(text.length() + 1); *data << text; - *data << uint8(chatTag()); + *data << uint8(GetChatTag()); } void Player::Say(const std::string& text, const uint32 language) @@ -19796,7 +19782,7 @@ void Player::RemoveSpellMods(Spell* spell) for (uint8 i=0; i<MAX_SPELLMOD; ++i) { - for (SpellModList::iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end();) + for (SpellModList::const_iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end();) { SpellModifier* mod = *itr; ++itr; @@ -19828,8 +19814,7 @@ void Player::DropModCharge(SpellModifier* mod, Spell* spell) if (spell && mod->ownerAura && mod->charges > 0) { - --mod->charges; - if (mod->charges == 0) + if (--mod->charges == 0) mod->charges = -1; spell->m_appliedMods.insert(mod->ownerAura); @@ -21078,22 +21063,19 @@ WorldLocation Player::GetStartPosition() const return WorldLocation(mapId, info->positionX, info->positionY, info->positionZ, 0); } -bool Player::isValid() const +bool Player::IsNeverVisible() const { - if (!Unit::isValid()) - return false; + if (Unit::IsNeverVisible()) + return true; if (GetSession()->PlayerLogout() || GetSession()->PlayerLoading()) - return false; + return true; - return true; + return false; } -bool Player::canSeeAlways(WorldObject const* obj) const +bool Player::CanAlwaysSee(WorldObject const* obj) const { - if (Unit::canSeeAlways(obj)) - return true; - // Always can see self if (m_mover == obj) return true; @@ -21105,9 +21087,9 @@ bool Player::canSeeAlways(WorldObject const* obj) const return false; } -bool Player::isAlwaysDetectableFor(WorldObject const* seer) const +bool Player::IsAlwaysDetectableFor(WorldObject const* seer) const { - if (Unit::isAlwaysDetectableFor(seer)) + if (Unit::IsAlwaysDetectableFor(seer)) return true; if (const Player* seerPlayer = seer->ToPlayer()) @@ -21500,7 +21482,7 @@ void Player::SendInitialPacketsBeforeAddToMap() data.Initialize(SMSG_LOGIN_SETTIMESPEED, 4 + 4 + 4); data << uint32(secsToTimeBitFields(sWorld->GetGameTime())); - data << (float)0.01666667f; // game speed + data << float(0.01666667f); // game speed data << uint32(0); // added in 3.1.2 GetSession()->SendPacket(&data); @@ -21545,7 +21527,7 @@ void Player::SendInitialPacketsAfterAddToMap() if (HasAuraType(SPELL_AURA_MOD_STUN)) SetMovement(MOVE_ROOT); - // manual send package (have code in HandleEffect(this, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT, true); that don't must be re-applied. + // manual send package (have code in HandleEffect(this, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT, true); that must not be re-applied. if (HasAuraType(SPELL_AURA_MOD_ROOT)) { WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10); @@ -22324,27 +22306,27 @@ bool Player::GetsRecruitAFriendBonus(bool forXP) { for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* pGroupGuy = itr->getSource(); - if (!pGroupGuy) + Player* player = itr->getSource(); + if (!player) continue; - if (!pGroupGuy->IsAtRecruitAFriendDistance(this)) + if (!player->IsAtRecruitAFriendDistance(this)) continue; // member (alive or dead) or his corpse at req. distance if (forXP) { // level must be allowed to get RaF bonus - if (pGroupGuy->getLevel() > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL)) + if (player->getLevel() > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL)) continue; // level difference must be small enough to get RaF bonus, UNLESS we are lower level - if (pGroupGuy->getLevel() < getLevel()) - if (uint8(getLevel() - pGroupGuy->getLevel()) > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE)) + if (player->getLevel() < getLevel()) + if (uint8(getLevel() - player->getLevel()) > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE)) continue; } - bool ARecruitedB = (pGroupGuy->GetSession()->GetRecruiterId() == GetSession()->GetAccountId()); - bool BRecruitedA = (GetSession()->GetRecruiterId() == pGroupGuy->GetSession()->GetAccountId()); + bool ARecruitedB = (player->GetSession()->GetRecruiterId() == GetSession()->GetAccountId()); + bool BRecruitedA = (GetSession()->GetRecruiterId() == player->GetSession()->GetAccountId()); if (ARecruitedB || BRecruitedA) { recruitAFriend = true; @@ -22372,16 +22354,16 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar { for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* pGroupGuy = itr->getSource(); - if (!pGroupGuy) + Player* player = itr->getSource(); + if (!player) continue; - if (!pGroupGuy->IsAtGroupRewardDistance(pRewardSource)) + if (!player->IsAtGroupRewardDistance(pRewardSource)) continue; // member (alive or dead) or his corpse at req. distance // quest objectives updated only for alive group member or dead but with not released body - if (pGroupGuy->isAlive()|| !pGroupGuy->GetCorpse()) - pGroupGuy->KilledMonsterCredit(creature_id, creature_guid); + if (player->isAlive()|| !player->GetCorpse()) + player->KilledMonsterCredit(creature_id, creature_guid); } } else // if (!group) @@ -22783,10 +22765,6 @@ bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const return false; } -// *********************************** -// -------------TRINITY--------------- -// *********************************** - void Player::StopCastingBindSight() { if (WorldObject* target = GetViewpoint()) @@ -23132,7 +23110,7 @@ void Player::InitRunes() m_runes->runeState = 0; m_runes->lastUsedRune = RUNE_BLOOD; - for (uint32 i = 0; i < MAX_RUNES; ++i) + for (uint8 i = 0; i < MAX_RUNES; ++i) { SetBaseRune(i, runeSlotTypes[i]); // init base types SetCurrentRune(i, runeSlotTypes[i]); // init current types @@ -23141,13 +23119,13 @@ void Player::InitRunes() m_runes->SetRuneState(i); } - for (uint32 i = 0; i < NUM_RUNE_TYPES; ++i) + for (uint8 i = 0; i < NUM_RUNE_TYPES; ++i) SetFloatValue(PLAYER_RUNE_REGEN_1 + i, 0.1f); } bool Player::IsBaseRuneSlotsOnCooldown(RuneType runeType) const { - for (uint32 i = 0; i < MAX_RUNES; ++i) + for (uint8 i = 0; i < MAX_RUNES; ++i) if (GetBaseRune(i) == runeType && GetRuneCooldown(i) == 0) return false; @@ -23206,8 +23184,8 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot) InventoryResult msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item->itemid, item->count); if (msg == EQUIP_ERR_OK) { - AllowedLooterSet* looters = item->GetAllowedLooters(); - Item* newitem = StoreNewItem(dest, item->itemid, true, item->randomPropertyId, (looters->size() > 1) ? looters : NULL); + AllowedLooterSet looters = item->GetAllowedLooters(); + Item* newitem = StoreNewItem(dest, item->itemid, true, item->randomPropertyId, looters); if (qitem) { @@ -24720,7 +24698,7 @@ float Player::GetAverageItemLevel() if (m_items[i] && m_items[i]->GetTemplate()) sum += m_items[i]->GetTemplate()->GetItemLevelIncludingQuality(); - count++; + ++count; } return ((float)sum) / count; diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 862b271c464..ddafefc087e 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -743,8 +743,8 @@ enum RestType enum DuelCompleteType { DUEL_INTERRUPTED = 0, - DUEL_WON = 1, - DUEL_FLED = 2 + DUEL_WON = 1, + DUEL_FLED = 2 }; enum TeleportToOptions @@ -768,6 +768,16 @@ enum EnviromentalDamage DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss }; +enum PlayerChatTag +{ + CHAT_TAG_NONE = 0x00, + CHAT_TAG_AFK = 0x01, + CHAT_TAG_DND = 0x02, + CHAT_TAG_GM = 0x04, + CHAT_TAG_UNK = 0x08, // Probably battleground commentator + CHAT_TAG_DEV = 0x10, +}; + enum PlayedTimeIndex { PLAYED_TIME_TOTAL = 0, @@ -1125,7 +1135,7 @@ class Player : public Unit, public GridObject<Player> bool ToggleDND(); bool isAFK() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); } bool isDND() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); } - uint8 chatTag() const; + uint8 GetChatTag() const; std::string afkMsg; std::string dndMsg; @@ -1242,18 +1252,18 @@ class Player : public Unit, public GridObject<Player> bool CanNoReagentCast(SpellInfo const* spellInfo) const; bool HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const; bool HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const; - InventoryResult CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(), pItem->GetCount(), pItem); } - InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return _CanTakeMoreSimilarItems(entry, count, NULL); } + InventoryResult CanTakeMoreSimilarItems(Item* pItem) const { return CanTakeMoreSimilarItems(pItem->GetEntry(), pItem->GetCount(), pItem); } + InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return CanTakeMoreSimilarItems(entry, count, NULL); } InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL) const { - return _CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count); + return CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count); } InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap = false) const { if (!pItem) return EQUIP_ERR_ITEM_NOT_FOUND; uint32 count = pItem->GetCount(); - return _CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL); + return CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL); } InventoryResult CanStoreItems(Item** pItem, int count) const; @@ -1269,8 +1279,8 @@ class Player : public Unit, public GridObject<Player> bool HasItemTotemCategory(uint32 TotemCategory) const; InventoryResult CanUseItem(ItemTemplate const* pItem) const; InventoryResult CanUseAmmo(uint32 item) const; - - Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0, AllowedLooterSet* allowedLooters = NULL); + Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0); + Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet &allowedLooters); Item* StoreItem(ItemPosCountVec const& pos, Item* pItem, bool update); Item* EquipNewItem(uint16 pos, uint32 item, bool update); Item* EquipItem(uint16 pos, Item* pItem, bool update); @@ -1280,8 +1290,8 @@ class Player : public Unit, public GridObject<Player> void AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast = false) { AutoStoreLoot(NULL_BAG, NULL_SLOT, loot_id, store, broadcast); } void StoreLootItem(uint8 lootSlot, Loot* loot); - InventoryResult _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const; - InventoryResult _CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem = NULL, bool swap = false, uint32* no_space_count = NULL) const; + InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const; + InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem = NULL, bool swap = false, uint32* no_space_count = NULL) const; void AddRefundReference(uint32 it); void DeleteRefundReference(uint32 it); @@ -1937,8 +1947,8 @@ class Player : public Unit, public GridObject<Player> void SendResetInstanceFailed(uint32 reason, uint32 MapId); void SendResetFailedNotify(uint32 mapid); - virtual bool SetPosition(float x, float y, float z, float orientation, bool teleport = false); - bool SetPosition(const Position &pos, bool teleport = false) { return SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } + virtual bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false); + bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } void UpdateUnderwaterState(Map* m, float x, float y, float z); void SendMessageToSet(WorldPacket* data, bool self) {SendMessageToSetInRange(data, GetVisibilityRange(), self); };// overwrite Object::SendMessageToSet @@ -2326,9 +2336,9 @@ class Player : public Unit, public GridObject<Player> bool HaveAtClient(WorldObject const* u) const { return u == this || m_clientGUIDs.find(u->GetGUID()) != m_clientGUIDs.end(); } - bool isValid() const; + bool IsNeverVisible() const; - bool IsVisibleGloballyFor(Player* pl) const; + bool IsVisibleGloballyFor(Player* player) const; void SendInitialVisiblePackets(Unit* target); void UpdateObjectVisibility(bool forced = true); @@ -2483,6 +2493,20 @@ class Player : public Unit, public GridObject<Player> void AddWhisperWhiteList(uint64 guid) { WhisperList.push_back(guid); } bool IsInWhisperWhiteList(uint64 guid); + //! Return collision height sent to client + //! we currently only send this on dismount + float GetCollisionHeight() + { + CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId()); + ASSERT(displayInfo); + CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId); + ASSERT(modelData); + + return modelData->CollisionHeight; + + //! TODO: Need a proper calculation for collision height when mounted + } + protected: // Gamemaster whisper whitelist WhisperListContainer WhisperList; @@ -2734,17 +2758,17 @@ class Player : public Unit, public GridObject<Player> Runes *m_runes; EquipmentSets m_EquipmentSets; - bool canSeeAlways(WorldObject const* obj) const; + bool CanAlwaysSee(WorldObject const* obj) const; - bool isAlwaysDetectableFor(WorldObject const* seer) const; + bool IsAlwaysDetectableFor(WorldObject const* seer) const; uint8 m_grantableLevels; private: // internal common parts for CanStore/StoreItem functions - InventoryResult _CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const; - InventoryResult _CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const; - InventoryResult _CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const; + InventoryResult CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const; + InventoryResult CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const; + InventoryResult CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const; Item* _StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool update); Item* _LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, Field* fields); diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp index 4d343d02146..e9798b61a60 100755 --- a/src/server/game/Entities/Player/SocialMgr.cpp +++ b/src/server/game/Entities/Player/SocialMgr.cpp @@ -114,20 +114,20 @@ void PlayerSocial::SetFriendNote(uint32 friend_guid, std::string note) m_playerSocialMap[friend_guid].Note = note; } -void PlayerSocial::SendSocialList(Player* plr) +void PlayerSocial::SendSocialList(Player* player) { - if (!plr) + if (!player) return; uint32 size = m_playerSocialMap.size(); WorldPacket data(SMSG_CONTACT_LIST, (4+4+size*25)); // just can guess size - data << uint32(7); // unk flag (0x1, 0x2, 0x4), 0x7 if it include ignore list + data << uint32(7); // 0x1 = Friendlist update. 0x2 = Ignorelist update. 0x4 = Mutelist update. data << uint32(size); // friends count for (PlayerSocialMap::iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr) { - sSocialMgr->GetFriendInfo(plr, itr->first, itr->second); + sSocialMgr->GetFriendInfo(player, itr->first, itr->second); data << uint64(itr->first); // player guid data << uint32(itr->second.Flags); // player flag (0x1-friend?, 0x2-ignored?, 0x4-muted?) @@ -144,7 +144,7 @@ void PlayerSocial::SendSocialList(Player* plr) } } - plr->GetSession()->SendPacket(&data); + player->GetSession()->SendPacket(&data); sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_CONTACT_LIST"); } diff --git a/src/server/game/Entities/Player/SocialMgr.h b/src/server/game/Entities/Player/SocialMgr.h index 5faa8f1987c..78965c13948 100755 --- a/src/server/game/Entities/Player/SocialMgr.h +++ b/src/server/game/Entities/Player/SocialMgr.h @@ -124,7 +124,7 @@ class PlayerSocial void RemoveFromSocialList(uint32 friend_guid, bool ignore); void SetFriendNote(uint32 friend_guid, std::string note); // Packet send's - void SendSocialList(Player* plr); + void SendSocialList(Player* player); // Misc bool HasFriend(uint32 friend_guid); bool HasIgnore(uint32 ignore_guid); diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp index 10c54720350..97629e802d4 100755 --- a/src/server/game/Entities/Totem/Totem.cpp +++ b/src/server/game/Entities/Totem/Totem.cpp @@ -86,9 +86,10 @@ void Totem::InitStats(uint32 duration) void Totem::InitSummon() { - // use AddAura instead of CastSpell - this in fact should be an AddSpell equivalent for creatures, but nothing like that exists so far. if (m_type == TOTEM_PASSIVE) - AddAura(GetSpell(), this); + { + CastSpell(this, GetSpell(), true); + } // Some totems can have both instant effect and passive spell if (GetSpell(1)) diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index dbe9697bcaf..28895cff35e 100755 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -489,13 +489,13 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z) for (PlayerSet::const_iterator itr = m_passengers.begin(); itr != m_passengers.end();) { - Player* plr = *itr; + Player* player = *itr; ++itr; - if (plr->isDead() && !plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) - plr->ResurrectPlayer(1.0f); + if (player->isDead() && !player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + player->ResurrectPlayer(1.0f); - plr->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT); + player->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT); } //we need to create and save new Map object with 'newMapid' because if not done -> lead to invalid Map object reference... @@ -584,13 +584,13 @@ void Transport::Update(uint32 p_diff) void Transport::UpdateForMap(Map const* targetMap) { - Map::PlayerList const& pl = targetMap->GetPlayers(); - if (pl.isEmpty()) + Map::PlayerList const& player = targetMap->GetPlayers(); + if (player.isEmpty()) return; if (GetMapId() == targetMap->GetId()) { - for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr) + for (Map::PlayerList::const_iterator itr = player.begin(); itr != player.end(); ++itr) { if (this != itr->getSource()->GetTransport()) { @@ -609,7 +609,7 @@ 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) + for (Map::PlayerList::const_iterator itr = player.begin(); itr != player.end(); ++itr) if (this != itr->getSource()->GetTransport()) itr->getSource()->SendDirectMessage(&out_packet); } @@ -673,7 +673,7 @@ uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y, return 0; } - map->Add(creature); + map->AddToMap(creature); m_NPCPassengerSet.insert(creature); if (tguid == 0) diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index 594203e0c46..3ab2f786086 100755 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -641,20 +641,21 @@ const float m_diminishing_k[MAX_CLASSES] = float Player::GetMissPercentageFromDefence() const { - const float miss_cap[MAX_CLASSES] = + float const miss_cap[MAX_CLASSES] = { - 16.00f, // Warrior //correct - 16.00f, // Paladin //correct - 16.00f, // Hunter //? - 16.00f, // Rogue //? - 16.00f, // Priest //? - 16.00f, // DK //correct - 16.00f, // Shaman //? - 16.00f, // Mage //? - 16.00f, // Warlock //? - 0.0f, // ?? - 16.00f // Druid //? + 16.00f, // Warrior //correct + 16.00f, // Paladin //correct + 16.00f, // Hunter //? + 16.00f, // Rogue //? + 16.00f, // Priest //? + 16.00f, // DK //correct + 16.00f, // Shaman //? + 16.00f, // Mage //? + 16.00f, // Warlock //? + 0.0f, // ?? + 16.00f // Druid //? }; + float diminishing = 0.0f, nondiminishing = 0.0f; // Modify value from defense skill (only bonus from defense rating diminishes) nondiminishing += (GetSkillValue(SKILL_DEFENSE) - GetMaxSkillValueForLevel()) * 0.04f; @@ -669,17 +670,17 @@ void Player::UpdateParryPercentage() { const float parry_cap[MAX_CLASSES] = { - 47.003525f, // Warrior - 47.003525f, // Paladin - 145.560408f, // Hunter - 145.560408f, // Rogue - 0.0f, // Priest - 47.003525f, // DK - 145.560408f, // Shaman - 0.0f, // Mage - 0.0f, // Warlock - 0.0f, // ?? - 0.0f // Druid + 47.003525f, // Warrior + 47.003525f, // Paladin + 145.560408f, // Hunter + 145.560408f, // Rogue + 0.0f, // Priest + 47.003525f, // DK + 145.560408f, // Shaman + 0.0f, // Mage + 0.0f, // Warlock + 0.0f, // ?? + 0.0f // Druid }; // No parry @@ -706,17 +707,17 @@ void Player::UpdateDodgePercentage() { const float dodge_cap[MAX_CLASSES] = { - 88.129021f, // Warrior - 88.129021f, // Paladin - 145.560408f, // Hunter - 145.560408f, // Rogue - 150.375940f, // Priest - 88.129021f, // DK - 145.560408f, // Shaman - 150.375940f, // Mage - 150.375940f, // Warlock - 0.0f, // ?? - 116.890707f // Druid + 88.129021f, // Warrior + 88.129021f, // Paladin + 145.560408f, // Hunter + 145.560408f, // Rogue + 150.375940f, // Priest + 88.129021f, // DK + 145.560408f, // Shaman + 150.375940f, // Mage + 150.375940f, // Warlock + 0.0f, // ?? + 116.890707f // Druid }; float diminishing = 0.0f, nondiminishing = 0.0f; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index efddb25eff8..6d8f7866657 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -181,7 +181,8 @@ m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE), m_HostileRefManager(this) for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i) m_SummonSlot[i] = 0; - m_ObjectSlot[0] = m_ObjectSlot[1] = m_ObjectSlot[2] = m_ObjectSlot[3] = 0; + for (uint8 i = 0; i < MAX_GAMEOBJECT_SLOT; ++i) + m_ObjectSlot[i] = 0; m_auraUpdateIterator = m_ownedAuras.end(); @@ -585,7 +586,7 @@ bool Unit::IsWithinMeleeRange(const Unit* obj, float dist) const void Unit::GetRandomContactPoint(const Unit* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const { float combat_reach = GetCombatReach(); - if (combat_reach < 0.1) // sometimes bugged for players + if (combat_reach < 0.1f) // sometimes bugged for players combat_reach = DEFAULT_COMBAT_REACH; uint32 attacker_number = getAttackers().size(); @@ -1573,7 +1574,7 @@ uint32 Unit::CalcArmorReducedDamage(Unit* victim, const uint32 damage, SpellInfo return (newdamage > 1) ? newdamage : 1; } -void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist, SpellInfo const* spellInfo) +void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, uint32 const damage, uint32 *absorb, uint32 *resist, SpellInfo const* spellInfo) { if (!victim || !victim->isAlive() || !damage) return; @@ -1583,15 +1584,19 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe // Magic damage, check for resists if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0) { - float baseVictimResistance = float(victim->GetResistance(GetFirstSchoolInMask(schoolMask))); - float ignoredResistance = float(GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask)); + float victimResistance = float(victim->GetResistance(schoolMask)); + victimResistance += float(GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask)); + if (Player* player = ToPlayer()) - ignoredResistance += float(player->GetSpellPenetrationItemMod()); - float victimResistance = baseVictimResistance + ignoredResistance; + victimResistance -= float(player->GetSpellPenetrationItemMod()); + + // Resistance can't be lower then 0. + if (victimResistance < 0.0f) + victimResistance = 0.0f; - static const uint32 BOSS_LEVEL = 83; - static const float BOSS_RESISTANCE_CONSTANT = 510.0; - uint32 level = getLevel(); + static uint32 const BOSS_LEVEL = 83; + static float const BOSS_RESISTANCE_CONSTANT = 510.0f; + uint32 level = victim->getLevel(); float resistanceConstant = 0.0f; if (level == BOSS_LEVEL) @@ -2215,22 +2220,23 @@ void Unit::SendMeleeAttackStart(Unit* victim) WorldPacket data(SMSG_ATTACKSTART, 8 + 8); data << uint64(GetGUID()); data << uint64(victim->GetGUID()); - SendMessageToSet(&data, true); sLog->outStaticDebug("WORLD: Sent SMSG_ATTACKSTART"); } void Unit::SendMeleeAttackStop(Unit* victim) { - if (!victim) - return; - WorldPacket data(SMSG_ATTACKSTOP, (8+8+4)); // we guess size data.append(GetPackGUID()); - data.append(victim->GetPackGUID()); // can be 0x00... - data << uint32(0); // can be 0x1 + data.append(victim ? victim->GetPackGUID() : 0); // can be 0x00... + data << uint32(0); // can be 0x1 SendMessageToSet(&data, true); - sLog->outDetail("%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow()); + sLog->outStaticDebug("WORLD: Sent SMSG_ATTACKSTART"); + + if (victim) + sLog->outDetail("%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow()); + else + sLog->outDetail("%s %u stopped attacking", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow()); } bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttackType attackType) @@ -3007,7 +3013,7 @@ void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool wi Spell* spell = m_currentSpells[spellType]; if (spell && (withDelayed || spell->getState() != SPELL_STATE_DELAYED) - && (withInstant || spell->CalcCastTime() > 0)) + && (withInstant || spell->GetCastTime() > 0)) { // for example, do not let self-stun aura interrupt itself if (!spell->IsInterruptable()) @@ -3044,7 +3050,7 @@ bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skip // Maybe later some special spells will be excluded too. // if skipInstant then instant spells shouldn't count as being casted - if (skipInstant && m_currentSpells[CURRENT_GENERIC_SPELL] && !m_currentSpells[CURRENT_GENERIC_SPELL]->CalcCastTime()) + if (skipInstant && m_currentSpells[CURRENT_GENERIC_SPELL] && !m_currentSpells[CURRENT_GENERIC_SPELL]->GetCastTime()) return false; // generic spells are casted when they are not finished and not delayed @@ -3095,7 +3101,7 @@ Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const int32 Unit::GetCurrentSpellCastTime(uint32 spell_id) const { if (Spell const* spell = FindCurrentSpellBySpellId(spell_id)) - return spell->CalcCastTime(); + return spell->GetCastTime(); return 0; } @@ -3471,10 +3477,10 @@ void Unit::RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode) i = m_ownedAuras.begin(); } -void Unit::RemoveOwnedAura(uint32 spellId, uint64 caster, uint8 reqEffMask, AuraRemoveMode removeMode) +void Unit::RemoveOwnedAura(uint32 spellId, uint64 casterGUID, uint8 reqEffMask, AuraRemoveMode removeMode) { for (AuraMap::iterator itr = m_ownedAuras.lower_bound(spellId); itr != m_ownedAuras.upper_bound(spellId);) - if (((itr->second->GetEffectMask() & reqEffMask) == reqEffMask) && (!caster || itr->second->GetCasterGUID() == caster)) + if (((itr->second->GetEffectMask() & reqEffMask) == reqEffMask) && (!casterGUID || itr->second->GetCasterGUID() == casterGUID)) { RemoveOwnedAura(itr, removeMode); itr = m_ownedAuras.lower_bound(spellId); @@ -3577,13 +3583,13 @@ void Unit::RemoveAura(Aura* aura, AuraRemoveMode mode) RemoveAura(aurApp, mode); } -void Unit::RemoveAurasDueToSpell(uint32 spellId, uint64 caster, uint8 reqEffMask, AuraRemoveMode removeMode) +void Unit::RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID, uint8 reqEffMask, AuraRemoveMode removeMode) { for (AuraApplicationMap::iterator iter = m_appliedAuras.lower_bound(spellId); iter != m_appliedAuras.upper_bound(spellId);) { Aura const* aura = iter->second->GetBase(); if (((aura->GetEffectMask() & reqEffMask) == reqEffMask) - && (!caster || aura->GetCasterGUID() == caster)) + && (!casterGUID || aura->GetCasterGUID() == casterGUID)) { RemoveAura(iter, removeMode); iter = m_appliedAuras.lower_bound(spellId); @@ -3593,13 +3599,13 @@ void Unit::RemoveAurasDueToSpell(uint32 spellId, uint64 caster, uint8 reqEffMask } } -void Unit::RemoveAuraFromStack(uint32 spellId, uint64 caster, AuraRemoveMode removeMode) +void Unit::RemoveAuraFromStack(uint32 spellId, uint64 casterGUID, AuraRemoveMode removeMode) { for (AuraMap::iterator iter = m_ownedAuras.lower_bound(spellId); iter != m_ownedAuras.upper_bound(spellId);) { Aura* aura = iter->second; if ((aura->GetType() == UNIT_AURA_TYPE) - && (!caster || aura->GetCasterGUID() == caster)) + && (!casterGUID || aura->GetCasterGUID() == casterGUID)) { aura->ModStackAmount(-1, removeMode); return; @@ -4421,14 +4427,26 @@ int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const { + std::map<SpellGroup, int32> SameEffectSpellGroup; float multiplier = 1.0f; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { - if ((*i)->GetMiscValue()& misc_mask) - AddPctN(multiplier, (*i)->GetAmount()); + if (((*i)->GetMiscValue() & misc_mask)) + { + // Check if the Aura Effect has a the Same Effect Stack Rule and if so, use the highest amount of that SpellGroup + // If the Aura Effect does not have this Stack Rule, it returns false so we can add to the multiplier as usual + if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup)) + AddPctN(multiplier, (*i)->GetAmount()); + } + } + // Add the highest of the Same Effect Stack Rule SpellGroups to the multiplier + for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr) + { + AddPctN(multiplier, itr->second); } + return multiplier; } @@ -4645,7 +4663,7 @@ void Unit::RemoveGameObject(GameObject* gameObj, bool del) gameObj->SetOwnerGUID(0); - for (uint32 i = 0; i < 4; ++i) + for (uint8 i = 0; i < MAX_GAMEOBJECT_SLOT; ++i) { if (m_ObjectSlot[i] == gameObj->GetGUID()) { @@ -4705,12 +4723,13 @@ void Unit::RemoveGameObject(uint32 spellid, bool del) void Unit::RemoveAllGameObjects() { // remove references to unit - for (GameObjectList::iterator i = m_gameObj.begin(); i != m_gameObj.end();) + while (!m_gameObj.empty()) { + GameObjectList::iterator i = m_gameObj.begin(); (*i)->SetOwnerGUID(0); (*i)->SetRespawnTime(0); (*i)->Delete(); - i = m_gameObj.erase(i); + m_gameObj.erase(i); } } @@ -5271,7 +5290,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere if (ToPlayer()->GetReputationRank(934) == REP_EXALTED) { // triggered at positive/self casts also, current attack target used then - if (IsFriendlyTo(target)) + if (target && IsFriendlyTo(target)) { target = getVictim(); if (!target) @@ -5748,11 +5767,11 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // Glyph of Ice Block case 56372: { - Player* plr = ToPlayer(); - if (!plr) + Player* player = ToPlayer(); + if (!player) return false; - SpellCooldowns const cooldowns = plr->GetSpellCooldowns(); + SpellCooldowns const cooldowns = player->GetSpellCooldowns(); // remove cooldowns on all ranks of Frost Nova for (SpellCooldowns::const_iterator itr = cooldowns.begin(); itr != cooldowns.end(); ++itr) { @@ -5760,7 +5779,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // Frost Nova if (cdSpell && cdSpell->SpellFamilyName == SPELLFAMILY_MAGE && cdSpell->SpellFamilyFlags[0] & 0x00000040) - plr->RemoveSpellCooldown(cdSpell->Id, true); + player->RemoveSpellCooldown(cdSpell->Id, true); } break; } @@ -6272,7 +6291,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere { if (procSpell->SpellVisual[0] == 750 && procSpell->Effects[1].ApplyAuraName == 3) { - if (target->GetTypeId() == TYPEID_UNIT) + if (target && target->GetTypeId() == TYPEID_UNIT) { triggered_spell_id = 54820; break; @@ -7042,26 +7061,26 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // Windfury Weapon (Passive) 1-5 Ranks case 33757: { - Player* plr = ToPlayer(); - if (!plr || !castItem || !castItem->IsEquipped() || !victim || !victim->isAlive()) + Player* player = ToPlayer(); + if (!player || !castItem || !castItem->IsEquipped() || !victim || !victim->isAlive()) return false; // custom cooldown processing case - if (cooldown && plr->HasSpellCooldown(dummySpell->Id)) + if (cooldown && player->HasSpellCooldown(dummySpell->Id)) return false; if (triggeredByAura->GetBase() && castItem->GetGUID() != triggeredByAura->GetBase()->GetCastItemGUID()) return false; - WeaponAttackType attType = WeaponAttackType(plr->GetAttackBySlot(castItem->GetSlot())); + WeaponAttackType attType = WeaponAttackType(player->GetAttackBySlot(castItem->GetSlot())); if ((attType != BASE_ATTACK && attType != OFF_ATTACK) || !isAttackReady(attType)) return false; // Now compute real proc chance... uint32 chance = 20; - plr->ApplySpellMod(dummySpell->Id, SPELLMOD_CHANCE_OF_SUCCESS, chance); + player->ApplySpellMod(dummySpell->Id, SPELLMOD_CHANCE_OF_SUCCESS, chance); - Item* addWeapon = plr->GetWeaponForAttack(attType == BASE_ATTACK ? OFF_ATTACK : BASE_ATTACK, true); + Item* addWeapon = player->GetWeaponForAttack(attType == BASE_ATTACK ? OFF_ATTACK : BASE_ATTACK, true); uint32 enchant_id_add = addWeapon ? addWeapon->GetEnchantmentId(EnchantmentSlot(TEMP_ENCHANTMENT_SLOT)) : 0; SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id_add); if (pEnchant && pEnchant->spellid[0] == dummySpell->Id) @@ -7106,7 +7125,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // apply cooldown before cast to prevent processing itself if (cooldown) - plr->AddSpellCooldown(dummySpell->Id, 0, time(NULL) + cooldown); + player->AddSpellCooldown(dummySpell->Id, 0, time(NULL) + cooldown); // Attack Twice for (uint32 i = 0; i < 2; ++i) @@ -7232,7 +7251,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // Item - Shaman T10 Elemental 4P Bonus case 70817: { - if(!target) + if (!target) return false; // try to find spell Flame Shock on the target if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, 0x10000000, 0x0, 0x0, GetGUID())) @@ -7732,6 +7751,9 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // Guard Dog case 201: { + if (!victim) + return false; + triggered_spell_id = 54445; target = this; float addThreat = float(CalculatePctN(procSpell->Effects[0].CalcValue(this), triggerAmount)); @@ -7980,11 +8002,8 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp else if (dummySpell->SpellIconID == 3015) { *handled = true; - if (procSpell->Category == SPELLCATEGORY_JUDGEMENT) - { - CastSpell(victim, 68055, true); - return true; - } + CastSpell(victim, 68055, true); + return true; } // Glyph of Divinity else if (dummySpell->Id == 54939) @@ -8054,9 +8073,9 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp { *handled = true; // Convert recently used Blood Rune to Death Rune - if (Player* plr = ToPlayer()) + if (Player* player = ToPlayer()) { - if (plr->getClass() != CLASS_DEATH_KNIGHT) + if (player->getClass() != CLASS_DEATH_KNIGHT) return false; RuneType rune = ToPlayer()->GetLastUsedRune(); @@ -8080,22 +8099,22 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp { if (dummySpell->SpellIconID == 2622) { - if (plr->GetCurrentRune(i) == RUNE_DEATH || - plr->GetBaseRune(i) == RUNE_BLOOD) + if (player->GetCurrentRune(i) == RUNE_DEATH || + player->GetBaseRune(i) == RUNE_BLOOD) continue; } else { - if (plr->GetCurrentRune(i) == RUNE_DEATH || - plr->GetBaseRune(i) != RUNE_BLOOD) + if (player->GetCurrentRune(i) == RUNE_DEATH || + player->GetBaseRune(i) != RUNE_BLOOD) continue; } - if (plr->GetRuneCooldown(i) != plr->GetRuneBaseCooldown(i)) + if (player->GetRuneCooldown(i) != player->GetRuneBaseCooldown(i)) continue; --runesLeft; // Mark aura as used - plr->AddRuneByAuraEffect(i, RUNE_DEATH, aurEff); + player->AddRuneByAuraEffect(i, RUNE_DEATH, aurEff); } return true; } @@ -8389,6 +8408,13 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg basepoints0 += victim->GetRemainingPeriodicAmount(GetGUID(), trigger_spell_id, SPELL_AURA_PERIODIC_DAMAGE); break; } + // Item - Hunter T9 4P Bonus + if (auraSpellInfo->Id == 67151) + { + trigger_spell_id = 68130; + target = this; + break; + } break; } case SPELLFAMILY_PALADIN: @@ -8731,7 +8757,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg case 63156: case 63158: // Can proc only if target has hp below 35% - if (!victim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, procSpell, this)) + if (!victim || !victim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, procSpell, this)) return false; break; // Deathbringer Saurfang - Blood Beast's Blood Link @@ -8771,11 +8797,11 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg // Blade Barrier if (auraSpellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && auraSpellInfo->SpellIconID == 85) { - Player* plr = ToPlayer(); - if (!plr || plr->getClass() != CLASS_DEATH_KNIGHT) + Player* player = ToPlayer(); + if (!player || player->getClass() != CLASS_DEATH_KNIGHT) return false; - if (!plr->IsBaseRuneSlotsOnCooldown(RUNE_BLOOD)) + if (!player->IsBaseRuneSlotsOnCooldown(RUNE_BLOOD)) return false; } @@ -10124,20 +10150,20 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius) // only called in Player::SetSeer // so move it to Player? -void Unit::AddPlayerToVision(Player* plr) +void Unit::AddPlayerToVision(Player* player) { if (m_sharedVision.empty()) { setActive(true); SetWorldObject(true); } - m_sharedVision.push_back(plr); + m_sharedVision.push_back(player); } // only called in Player::SetSeer -void Unit::RemovePlayerFromVision(Player* plr) +void Unit::RemovePlayerFromVision(Player* player) { - m_sharedVision.remove(plr); + m_sharedVision.remove(player); if (m_sharedVision.empty()) { setActive(false); @@ -10593,11 +10619,6 @@ uint32 Unit::SpellDamageBonus(Unit* victim, SpellInfo const* spellProto, uint32 AddPctF(TakenTotalMod, std::max(mod, float((*i)->GetAmount()))); } break; - // Ebon Plague - case 1933: - if ((*i)->GetMiscValue() & (spellProto ? spellProto->GetSchoolMask() : 0)) - AddPctN(TakenTotalMod, (*i)->GetAmount()); - break; } } @@ -11879,7 +11900,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT); - if (Player* plr = ToPlayer()) + if (Player* player = ToPlayer()) { // mount as a vehicle if (VehicleId) @@ -11895,7 +11916,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry) SendMessageToSet(&data, true); data.Initialize(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0); - plr->GetSession()->SendPacket(&data); + player->GetSession()->SendPacket(&data); // mounts can also have accessories GetVehicleKit()->InstallAllAccessories(false); @@ -11903,7 +11924,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry) } // unsummon pet - Pet* pet = plr->GetPet(); + Pet* pet = player->GetPet(); if (pet) { Battleground* bg = ToPlayer()->GetBattleground(); @@ -11911,7 +11932,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry) if (bg && bg->isArena()) pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); else - plr->UnsummonPetTemporaryIfAny(); + player->UnsummonPetTemporaryIfAny(); } } @@ -11926,6 +11947,15 @@ void Unit::Unmount() SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT); + if (Player* thisPlayer = ToPlayer()) + { + WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4); + data.append(GetPackGUID()); + data << uint32(sWorld->GetGameTime()); // Packet counter + data << thisPlayer->GetCollisionHeight(); + thisPlayer->GetSession()->SendPacket(&data); + } + WorldPacket data(SMSG_DISMOUNT, 8); data.appendPackGUID(GetGUID()); SendMessageToSet(&data, true); @@ -11947,15 +11977,15 @@ void Unit::Unmount() // 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 (Player* plr = ToPlayer()) + if (Player* player = ToPlayer()) { - if (Pet* pPet = plr->GetPet()) + if (Pet* pPet = player->GetPet()) { if (pPet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && !pPet->HasUnitState(UNIT_STAT_STUNNED)) pPet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } else - plr->ResummonPetTemporaryUnSummonedIfAny(); + player->ResummonPetTemporaryUnSummonedIfAny(); } } @@ -12385,9 +12415,18 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) return gain; } -bool Unit::isAlwaysVisibleFor(WorldObject const* seer) const +// returns negative amount on power reduction +int32 Unit::ModifyPowerPct(Powers power, float pct, bool apply) +{ + float amount = (float)GetMaxPower(power); + ApplyPercentModFloatVar(amount, pct, apply); + + return ModifyPower(power, (int32)amount - (int32)GetMaxPower(power)); +} + +bool Unit::IsAlwaysVisibleFor(WorldObject const* seer) const { - if (WorldObject::isAlwaysVisibleFor(seer)) + if (WorldObject::IsAlwaysVisibleFor(seer)) return true; // Always seen by owner @@ -12398,9 +12437,9 @@ bool Unit::isAlwaysVisibleFor(WorldObject const* seer) const return false; } -bool Unit::isAlwaysDetectableFor(WorldObject const* seer) const +bool Unit::IsAlwaysDetectableFor(WorldObject const* seer) const { - if (WorldObject::isAlwaysDetectableFor(seer)) + if (WorldObject::IsAlwaysDetectableFor(seer)) return true; if (HasAuraTypeWithCaster(SPELL_AURA_MOD_STALKED, seer->GetGUID())) @@ -13020,16 +13059,16 @@ int32 Unit::CalcSpellDuration(SpellInfo const* spellProto) return duration; } -int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive) +int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive, uint32 effectMask) { - // don't mod permament auras duration + // don't mod permanent auras duration if (duration < 0) return duration; // cut duration only of negative effects if (!positive) { - int32 mechanic = spellProto->GetAllEffectsMechanicMask(); + int32 mechanic = spellProto->GetSpellMechanicMaskByEffectMask(effectMask); int32 durationMod; int32 durationMod_always = 0; @@ -13532,10 +13571,10 @@ void Unit::SetHealth(uint32 val) SetUInt32Value(UNIT_FIELD_HEALTH, val); // group update - if (Player* plr = ToPlayer()) + if (Player* player = ToPlayer()) { - if (plr->GetGroup()) - plr->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_HP); + if (player->GetGroup()) + player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_HP); } else if (Pet* pet = ToCreature()->ToPet()) { @@ -13711,7 +13750,7 @@ void Unit::RemoveFromWorld() } } -void Unit::CleanupsBeforeDelete(bool finalCleanup) +void Unit::CleanupBeforeRemoveFromMap(bool finalCleanup) { // This needs to be before RemoveFromWorld to make GetCaster() return a valid pointer on aura removal InterruptNonMeleeSpells(true); @@ -13735,6 +13774,11 @@ void Unit::CleanupsBeforeDelete(bool finalCleanup) DeleteThreatList(); getHostileRefManager().setOnlineOfflineState(false); GetMotionMaster()->Clear(false); // remove different non-standard movement generators. +} + +void Unit::CleanupsBeforeDelete(bool finalCleanup) +{ + CleanupBeforeRemoveFromMap(finalCleanup); if (Creature* thisCreature = ToCreature()) if (GetTransport()) @@ -14302,7 +14346,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u } if (!handled) - for (uint8 effIndex = 0; effIndex<MAX_SPELL_EFFECTS; ++effIndex) + for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex) { if (!(i->effMask & (1<<effIndex))) continue; @@ -14322,6 +14366,10 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u } case SPELL_AURA_PROC_TRIGGER_DAMAGE: { + // target has to be valid + if (!target) + return; + sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "ProcDamageAndSpell: doing %u damage from spell id %u (triggered by %s aura of spell %u)", triggeredByAura->GetAmount(), spellInfo->Id, (isVictim?"a victim's":"an attacker's"), triggeredByAura->GetId()); SpellNonMeleeDamage damageInfo(this, target, spellInfo->Id, spellInfo->SchoolMask); uint32 damage = SpellDamageBonus(target, spellInfo, triggeredByAura->GetAmount(), SPELL_DIRECT_DAMAGE); @@ -14739,9 +14787,9 @@ void Unit::ClearComboPointHolders() { uint32 lowguid = *m_ComboPointHolders.begin(); - Player* plr = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER)); - if (plr && plr->GetComboTarget() == GetGUID()) // recheck for safe - plr->ClearComboPoints(); // remove also guid from m_ComboPointHolders; + Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER)); + if (player && player->GetComboTarget() == GetGUID()) // recheck for safe + player->ClearComboPoints(); // remove also guid from m_ComboPointHolders; else m_ComboPointHolders.erase(lowguid); // or remove manually } @@ -15308,9 +15356,9 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) return; // Inform pets (if any) when player kills target) - if (Player* plr = ToPlayer()) + if (Player* player = ToPlayer()) { - Pet* pet = plr->GetPet(); + Pet* pet = player->GetPet(); if (pet && pet->isAlive() && pet->isControlled()) pet->AI()->KilledUnit(victim); } @@ -15605,6 +15653,9 @@ void Unit::SetControlled(bool apply, UnitState state) case UNIT_STAT_CONFUSED: if (!HasUnitState(UNIT_STAT_STUNNED)) { + ClearUnitState(UNIT_STAT_MELEE_ATTACKING); + SendMeleeAttackStop(); + // SendAutoRepeatCancel ? SetConfused(true); CastStop(); } @@ -15612,6 +15663,9 @@ void Unit::SetControlled(bool apply, UnitState state) case UNIT_STAT_FLEEING: if (!HasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CONFUSED)) { + ClearUnitState(UNIT_STAT_MELEE_ATTACKING); + SendMeleeAttackStop(); + // SendAutoRepeatCancel ? SetFeared(true); CastStop(); } @@ -15882,10 +15936,10 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au } else { - Player* plr = ToPlayer(); - if (plr->isAFK()) - plr->ToggleAFK(); - plr->SetClientControl(this, 0); + Player* player = ToPlayer(); + if (player->isAFK()) + player->ToggleAFK(); + player->SetClientControl(this, 0); } // charm is set by aura, and aura effect remove handler was called during apply handler execution @@ -16948,25 +17002,25 @@ void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* a if (aurApp && aurApp->GetRemoveMode()) return; - if (Player* plr = ToPlayer()) + if (Player* player = ToPlayer()) { - if (vehicle->GetBase()->GetTypeId() == TYPEID_PLAYER && plr->isInCombat()) + if (vehicle->GetBase()->GetTypeId() == TYPEID_PLAYER && player->isInCombat()) return; InterruptNonMeleeSpells(false); - plr->StopCastingCharm(); - plr->StopCastingBindSight(); + player->StopCastingCharm(); + player->StopCastingBindSight(); Unmount(); RemoveAurasByType(SPELL_AURA_MOUNTED); // drop flag at invisible in bg - if (Battleground* bg = plr->GetBattleground()) - bg->EventPlayerDroppedFlag(plr); + if (Battleground* bg = player->GetBattleground()) + bg->EventPlayerDroppedFlag(player); WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0); - plr->GetSession()->SendPacket(&data); + player->GetSession()->SendPacket(&data); - plr->UnsummonPetTemporaryIfAny(); + player->UnsummonPetTemporaryIfAny(); } ASSERT(!m_vehicle); @@ -17040,8 +17094,8 @@ void Unit::_ExitVehicle(Position const* exitPosition) SendMonsterMoveExitVehicle(&pos); Relocate(&pos); - if (Player* plr = ToPlayer()) - plr->ResummonPetTemporaryUnSummonedIfAny(); + if (Player* player = ToPlayer()) + player->ResummonPetTemporaryUnSummonedIfAny(); WorldPacket data2; BuildHeartBeatMsg(&data2); @@ -17152,16 +17206,16 @@ void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool cas { // FIXME: this interrupts spell visual DestroyForNearbyPlayers(); - SetPosition(x, y, z, orientation, true); + UpdatePosition(x, y, z, orientation, true); } } -bool Unit::SetPosition(float x, float y, float z, float orientation, bool teleport) +bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool teleport) { // prevent crash when a bad coord is sent by the client if (!Trinity::IsValidMapCoord(x, y, z, orientation)) { - sLog->outDebug(LOG_FILTER_UNITS, "Unit::SetPosition(%f, %f, %f) .. bad coordinates!", x, y, z); + sLog->outDebug(LOG_FILTER_UNITS, "Unit::UpdatePosition(%f, %f, %f) .. bad coordinates!", x, y, z); return false; } @@ -17356,7 +17410,7 @@ uint32 Unit::GetRemainingPeriodicAmount(uint64 caster, uint32 spellId, AuraType AuraEffectList const& periodicAuras = GetAuraEffectsByType(auraType); for (AuraEffectList::const_iterator i = periodicAuras.begin(); i != periodicAuras.end(); ++i) { - if ((*i)->GetCasterGUID() != caster || (*i)->GetId() != spellId || (*i)->GetEffIndex() != effectIndex || (*i)->GetTotalTicks() == 0) + if ((*i)->GetCasterGUID() != caster || (*i)->GetId() != spellId || (*i)->GetEffIndex() != effectIndex || !(*i)->GetTotalTicks()) continue; amount += uint32(((*i)->GetAmount() * std::max<int32>((*i)->GetTotalTicks() - int32((*i)->GetTickNumber()), 0)) / (*i)->GetTotalTicks()); break; @@ -17372,6 +17426,17 @@ void Unit::SendClearTarget() SendMessageToSet(&data, false); } +uint32 Unit::GetResistance(SpellSchoolMask mask) const +{ + int32 resist = -1; + for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) + if (mask & (1 << i) && (resist < 0 || resist > int32(GetResistance(SpellSchools(i))))) + resist = int32(GetResistance(SpellSchools(i))); + + // resist value will never be negative here + return uint32(resist); +} + void CharmInfo::SetIsCommandAttack(bool val) { m_isCommandAttack = val; diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 8f052ab41ae..5906a7f3a2b 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -44,8 +44,8 @@ enum SpellInterruptFlags { SPELL_INTERRUPT_FLAG_MOVEMENT = 0x01, // why need this for instant? SPELL_INTERRUPT_FLAG_PUSH_BACK = 0x02, // push back - SPELL_INTERRUPT_FLAG_INTERRUPT = 0x04, // interrupt - SPELL_INTERRUPT_FLAG_AUTOATTACK = 0x08, // enter combat + SPELL_INTERRUPT_FLAG_UNK3 = 0x04, // any info? + SPELL_INTERRUPT_FLAG_INTERRUPT = 0x08, // interrupt SPELL_INTERRUPT_FLAG_ABORT_ON_DMG = 0x10, // _complete_ interrupt on direct damage //SPELL_INTERRUPT_UNK = 0x20 // unk, 564 of 727 spells having this spell start with "Glyph" }; @@ -53,7 +53,8 @@ enum SpellInterruptFlags // See SpellAuraInterruptFlags for other values definitions enum SpellChannelInterruptFlags { - CHANNEL_FLAG_DELAY = 0x4000 + CHANNEL_INTERRUPT_FLAG_INTERRUPT = 0x08, // interrupt + CHANNEL_FLAG_DELAY = 0x4000 }; enum SpellAuraInterruptFlags @@ -1007,8 +1008,8 @@ enum CurrentSpellTypes { CURRENT_MELEE_SPELL = 0, CURRENT_GENERIC_SPELL = 1, - CURRENT_AUTOREPEAT_SPELL = 2, - CURRENT_CHANNELED_SPELL = 3 + CURRENT_CHANNELED_SPELL = 2, + CURRENT_AUTOREPEAT_SPELL = 3 }; #define CURRENT_FIRST_NON_MELEE_SPELL 1 @@ -1208,6 +1209,8 @@ enum ReactiveType #define SUMMON_SLOT_QUEST 6 #define MAX_SUMMON_SLOT 7 +#define MAX_GAMEOBJECT_SLOT 4 + enum PlayerTotemType { SUMMON_TYPE_TOTEM_FIRE = 63, @@ -1247,6 +1250,7 @@ class Unit : public WorldObject void AddToWorld(); void RemoveFromWorld(); + void CleanupBeforeRemoveFromMap(bool finalCleanup); void CleanupsBeforeDelete(bool finalCleanup = true); // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units) DiminishingLevels GetDiminishing(DiminishingGroup group); @@ -1306,7 +1310,7 @@ class Unit : public WorldObject void CombatStopWithPets(bool includingCast = false); void StopAttackFaction(uint32 faction_id); Unit* SelectNearbyTarget(float dist = NOMINAL_MELEE_RANGE) const; - void SendMeleeAttackStop(Unit* victim); + void SendMeleeAttackStop(Unit* victim = NULL); void SendMeleeAttackStart(Unit* pVictim); void AddUnitState(uint32 f) { m_state |= f; } @@ -1342,6 +1346,7 @@ class Unit : public WorldObject void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); } uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); } + uint32 GetResistance(SpellSchoolMask mask) const; void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school, val); } uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); } @@ -1370,6 +1375,7 @@ class Unit : public WorldObject void SetMaxPower(Powers power, uint32 val); // returns the change in power int32 ModifyPower(Powers power, int32 val); + int32 ModifyPowerPct(Powers power, float pct, bool apply = true); uint32 GetAttackTime(WeaponAttackType att) const { @@ -1501,6 +1507,20 @@ class Unit : public WorldObject } virtual uint32 GetShieldBlockValue() const =0; + uint32 GetShieldBlockValue(uint32 soft_cap, uint32 hard_cap) const + { + uint32 value = GetShieldBlockValue(); + if (value >= hard_cap) + { + value = (soft_cap + hard_cap) / 2; + } + else if (value > soft_cap) + { + value = soft_cap + ((value - soft_cap) / 2); + } + + return value; + } uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; } uint32 GetDefenseSkillValue(Unit const* target = NULL) const; uint32 GetWeaponSkillValue(WeaponAttackType attType, Unit const* target = NULL) const; @@ -1600,9 +1620,9 @@ class Unit : public WorldObject void SendSpellDamageImmune(Unit* target, uint32 spellId); void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false); - virtual bool SetPosition(float x, float y, float z, float ang, bool teleport = false); + virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport = false); // returns true if unit's position really changed - bool SetPosition(const Position &pos, bool teleport = false) { return SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } + bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } void KnockbackFrom(float x, float y, float speedXY, float speedZ); void JumpTo(float speedXY, float speedZ, bool forward = true); @@ -1711,8 +1731,8 @@ class Unit : public WorldObject //Player* GetMoverSource() const; Player* m_movedPlayer; SharedVisionList const& GetSharedVisionList() { return m_sharedVision; } - void AddPlayerToVision(Player* plr); - void RemovePlayerFromVision(Player* plr); + void AddPlayerToVision(Player* player); + void RemovePlayerFromVision(Player* player); bool HasSharedVision() const { return !m_sharedVision.empty(); } void RemoveBindSightAuras(); void RemoveCharmAuras(); @@ -1739,7 +1759,7 @@ class Unit : public WorldObject AuraMap const& GetOwnedAuras() const { return m_ownedAuras; } void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); - void RemoveOwnedAura(uint32 spellId, uint64 caster = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); + void RemoveOwnedAura(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); void RemoveOwnedAura(Aura* aura, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); Aura* GetOwnedAura(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0, Aura* except = NULL) const; @@ -1749,12 +1769,12 @@ class Unit : public WorldObject AuraApplicationMap const& GetAppliedAuras() const { return m_appliedAuras; } void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); - void RemoveAura(uint32 spellId, uint64 caster = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); + void RemoveAura(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); void RemoveAura(AuraApplication * aurApp, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveAura(Aura* aur, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); - void RemoveAurasDueToSpell(uint32 spellId, uint64 caster = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); - void RemoveAuraFromStack(uint32 spellId, uint64 caster = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); + void RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); + void RemoveAuraFromStack(uint32 spellId, uint64 casterGUID = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT); void RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit* dispeller, uint8 chargesRemoved = 1); void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit* stealer); void RemoveAurasDueToItemSpell(Item* castItem, uint32 spellId); @@ -1875,7 +1895,7 @@ class Unit : public WorldObject uint32 m_addDmgOnce; uint64 m_SummonSlot[MAX_SUMMON_SLOT]; - uint64 m_ObjectSlot[4]; + uint64 m_ObjectSlot[MAX_GAMEOBJECT_SLOT]; ShapeshiftForm GetShapeshiftForm() const { return ShapeshiftForm(GetByteValue(UNIT_FIELD_BYTES_2, 3)); } void SetShapeshiftForm(ShapeshiftForm form) @@ -1944,9 +1964,6 @@ class Unit : public WorldObject void SetVisible(bool x); // common function for visibility checks for player/creatures with detection code - - bool isValid() const { return WorldObject::isValid(); } - void SetPhaseMask(uint32 newPhaseMask, bool update);// overwrite WorldObject::SetPhaseMask void UpdateObjectVisibility(bool forced = true); @@ -2055,7 +2072,7 @@ class Unit : public WorldObject float ApplyEffectModifiers(SpellInfo const* spellProto, uint8 effect_index, float value) const; int32 CalculateSpellDamage(Unit const* target, SpellInfo const* spellProto, uint8 effect_index, int32 const* basePoints = NULL) const; int32 CalcSpellDuration(SpellInfo const* spellProto); - int32 ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive); + int32 ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive, uint32 effectMask); void ModSpellCastTime(SpellInfo const* spellProto, int32 & castTime, Spell* spell=NULL); float CalculateLevelPenalty(SpellInfo const* spellProto) const; @@ -2284,12 +2301,8 @@ class Unit : public WorldObject uint32 m_unitTypeMask; - bool isAlwaysVisibleFor(WorldObject const* seer) const; - bool canSeeAlways(WorldObject const* obj) const { return WorldObject::canSeeAlways(obj); } - - bool isVisibleForInState(WorldObject const* seer) const { return WorldObject::isVisibleForInState(seer); }; - - bool isAlwaysDetectableFor(WorldObject const* seer) const; + bool IsAlwaysVisibleFor(WorldObject const* seer) const; + bool IsAlwaysDetectableFor(WorldObject const* seer) const; private: bool IsTriggeredAtSpellProcEvent(Unit* pVictim, Aura* aura, SpellInfo const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const* & spellProcEvent); bool HandleDummyAuraProc(Unit* pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown); diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index effd43cd320..fe018ec78ce 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -172,8 +172,12 @@ void Vehicle::ApplyAllImmunities() // Different immunities for vehicles goes below switch (GetVehicleInfo()->m_ID) { - case 160: + // code below prevents a bug with movable cannons + case 160: // Strand of the Ancients + case 244: // Wintergrasp + case 510: // Isle of Conquest _me->SetControlled(true, UNIT_STAT_ROOT); + // why we need to apply this? we can simple add immunities to slow mechanic in DB _me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_DECREASE_SPEED, true); break; default: @@ -445,7 +449,7 @@ void Vehicle::RelocatePassengers(float x, float y, float z, float ang) float pz = z + passenger->m_movementInfo.t_pos.m_positionZ; float po = ang + passenger->m_movementInfo.t_pos.m_orientation; - passenger->SetPosition(px, py, pz, po); + passenger->UpdatePosition(px, py, pz, po); } } diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index e81cd053003..4cc735a98d7 100755 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -1172,14 +1172,14 @@ void GameEventMgr::GameEventSpawn(int16 event_id) // Spawn if necessary (loaded grids only) Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(data->mapid)); // We use spawn coords to spawn - if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY)) + if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY)) { Creature* creature = new Creature; //sLog->outDebug("Spawning creature %u", *itr); if (!creature->LoadFromDB(*itr, map)) delete creature; else - map->Add(creature); + map->AddToMap(creature); } } } @@ -1201,7 +1201,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id) // this base map checked as non-instanced and then only existed Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(data->mapid)); // We use current coords to unspawn, not spawn coords since creature can have changed grid - if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY)) + if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY)) { GameObject* pGameobject = new GameObject; //sLog->outDebug("Spawning gameobject %u", *itr); @@ -1210,7 +1210,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id) else { if (pGameobject->isSpawnedByDefault()) - map->Add(pGameobject); + map->AddToMap(pGameobject); } } } @@ -1590,15 +1590,15 @@ void GameEventMgr::SaveWorldEventStateToDB(uint16 event_id) CharacterDatabase.CommitTransaction(trans); } -void GameEventMgr::SendWorldStateUpdate(Player* plr, uint16 event_id) +void GameEventMgr::SendWorldStateUpdate(Player* player, uint16 event_id) { GameEventConditionMap::const_iterator itr; for (itr = mGameEvent[event_id].conditions.begin(); itr !=mGameEvent[event_id].conditions.end(); ++itr) { if (itr->second.done_world_state) - plr->SendUpdateWorldState(itr->second.done_world_state, (uint32)(itr->second.done)); + player->SendUpdateWorldState(itr->second.done_world_state, (uint32)(itr->second.done)); if (itr->second.max_world_state) - plr->SendUpdateWorldState(itr->second.max_world_state, (uint32)(itr->second.reqNum)); + player->SendUpdateWorldState(itr->second.max_world_state, (uint32)(itr->second.reqNum)); } } diff --git a/src/server/game/Events/GameEventMgr.h b/src/server/game/Events/GameEventMgr.h index 7337110fd65..a2a35a85098 100755 --- a/src/server/game/Events/GameEventMgr.h +++ b/src/server/game/Events/GameEventMgr.h @@ -115,11 +115,11 @@ class GameEventMgr bool StartEvent(uint16 event_id, bool overwrite = false); void StopEvent(uint16 event_id, bool overwrite = false); void HandleQuestComplete(uint32 quest_id); // called on world event type quest completions - void HandleWorldEventGossip(Player* plr, Creature* c); + void HandleWorldEventGossip(Player* player, Creature* c); uint32 GetNPCFlag(Creature* cr); uint32 GetNpcTextId(uint32 guid); private: - void SendWorldStateUpdate(Player* plr, uint16 event_id); + void SendWorldStateUpdate(Player* player, uint16 event_id); void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); } void RemoveActiveEvent(uint16 event_id) { m_ActiveEvents.erase(event_id); } void ApplyNewEvent(uint16 event_id); diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp index c351efb334f..3a1b81b044d 100755 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -165,9 +165,9 @@ Unit* ObjectAccessor::FindUnit(uint64 guid) Player* ObjectAccessor::FindPlayerByName(const char* name) { - ACE_GUARD_RETURN(LockType, g, *HashMapHolder<Player>::GetLock(), NULL); - HashMapHolder<Player>::MapType& m = HashMapHolder<Player>::GetContainer(); - for (HashMapHolder<Player>::MapType::iterator iter = m.begin(); iter != m.end(); ++iter) + TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock()); + HashMapHolder<Player>::MapType const& m = GetPlayers(); + for (HashMapHolder<Player>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter) if (iter->second->IsInWorld() && strcmp(name, iter->second->GetName()) == 0) return iter->second; @@ -176,15 +176,15 @@ Player* ObjectAccessor::FindPlayerByName(const char* name) void ObjectAccessor::SaveAllPlayers() { - ACE_GUARD(LockType, g, *HashMapHolder<Player>::GetLock()); - HashMapHolder<Player>::MapType& m = HashMapHolder<Player>::GetContainer(); - for (HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr) + TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock()); + HashMapHolder<Player>::MapType const& m = GetPlayers(); + for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) itr->second->SaveToDB(); } Corpse* ObjectAccessor::GetCorpseForPlayerGUID(uint64 guid) { - ACE_GUARD_RETURN(LockType, guard, i_corpseGuard, NULL); + TRINITY_READ_GUARD(ACE_RW_Thread_Mutex, i_corpseLock); Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid); if (iter == i_player2corpse.end()) @@ -199,25 +199,32 @@ void ObjectAccessor::RemoveCorpse(Corpse* corpse) { ASSERT(corpse && corpse->GetType() != CORPSE_BONES); - if (corpse->FindMap()) + //TODO: more works need to be done for corpse and other world object + if (Map* map = corpse->FindMap()) { corpse->DestroyForNearbyPlayers(); - corpse->FindMap()->Remove(corpse, false); + if (corpse->IsInGrid()) + map->RemoveFromMap(corpse, false); + else + { + corpse->RemoveFromWorld(); + corpse->ResetMap(); + } } else corpse->RemoveFromWorld(); // Critical section { - ACE_GUARD(LockType, g, i_corpseGuard); + TRINITY_WRITE_GUARD(ACE_RW_Thread_Mutex, i_corpseLock); Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGUID()); if (iter == i_player2corpse.end()) // TODO: Fix this return; // build mapid*cellid -> guid_set map - CellPair cell_pair = Trinity::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY()); - uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + CellCoord cellCoord = Trinity::ComputeCellCoord(corpse->GetPositionX(), corpse->GetPositionY()); + uint32 cell_id = (cellCoord.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord; sObjectMgr->DeleteCorpseCellData(corpse->GetMapId(), cell_id, GUID_LOPART(corpse->GetOwnerGUID())); @@ -231,26 +238,30 @@ void ObjectAccessor::AddCorpse(Corpse* corpse) // Critical section { - ACE_GUARD(LockType, g, i_corpseGuard); + TRINITY_WRITE_GUARD(ACE_RW_Thread_Mutex, i_corpseLock); ASSERT(i_player2corpse.find(corpse->GetOwnerGUID()) == i_player2corpse.end()); i_player2corpse[corpse->GetOwnerGUID()] = corpse; // build mapid*cellid -> guid_set map - CellPair cell_pair = Trinity::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY()); - uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + CellCoord cellCoord = Trinity::ComputeCellCoord(corpse->GetPositionX(), corpse->GetPositionY()); + uint32 cell_id = (cellCoord.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord; sObjectMgr->AddCorpseCellData(corpse->GetMapId(), cell_id, GUID_LOPART(corpse->GetOwnerGUID()), corpse->GetInstanceId()); } } -void ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair, GridType& grid, Map* map) +void ObjectAccessor::AddCorpsesToGrid(GridCoord const& gridpair, GridType& grid, Map* map) { - ACE_GUARD(LockType, g, i_corpseGuard); + TRINITY_READ_GUARD(ACE_RW_Thread_Mutex, i_corpseLock); for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter) { - if (iter->second->GetGrid() == gridpair) + // We need this check otherwise a corpose may be added to a grid twice + if (iter->second->IsInGrid()) + continue; + + if (iter->second->GetGridCoord() == gridpair) { // verify, if the corpse in our instance (add only corpses which are) if (map->Instanceable()) @@ -301,7 +312,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia for (uint8 i = OBJECT_FIELD_TYPE + 1; i < CORPSE_END; ++i) // don't overwrite guid and object type bones->SetUInt32Value(i, corpse->GetUInt32Value(i)); - bones->SetGrid(corpse->GetGrid()); + bones->SetGridCoord(corpse->GetGridCoord()); // bones->m_time = m_time; // don't overwrite time // bones->m_type = m_type; // don't overwrite type bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation()); @@ -317,7 +328,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia } // add bones in grid store if grid loaded where corpse placed - map->Add(bones); + map->AddToMap(bones); } // all references to the corpse should be removed at this point @@ -346,17 +357,12 @@ void ObjectAccessor::Update(uint32 /*diff*/) { UpdateDataMapType update_players; - // Critical section + while (!i_objects.empty()) { - ACE_GUARD(LockType, g, i_updateGuard); - - while (!i_objects.empty()) - { - Object* obj = *i_objects.begin(); - ASSERT(obj && obj->IsInWorld()); - i_objects.erase(i_objects.begin()); - obj->BuildUpdate(update_players); - } + Object* obj = *i_objects.begin(); + ASSERT(obj && obj->IsInWorld()); + i_objects.erase(i_objects.begin()); + obj->BuildUpdate(update_players); } WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 @@ -380,7 +386,7 @@ void ObjectAccessor::UnloadAll() /// Define the static members of HashMapHolder template <class T> UNORDERED_MAP< uint64, T* > HashMapHolder<T>::m_objectMap; -template <class T> ACE_Thread_Mutex HashMapHolder<T>::i_lock; +template <class T> typename HashMapHolder<T>::LockType HashMapHolder<T>::i_lock; /// Global definitions for the hashmap storage diff --git a/src/server/game/Globals/ObjectAccessor.h b/src/server/game/Globals/ObjectAccessor.h index a9be8b4971f..25fa20dce70 100755 --- a/src/server/game/Globals/ObjectAccessor.h +++ b/src/server/game/Globals/ObjectAccessor.h @@ -48,23 +48,23 @@ class HashMapHolder public: typedef UNORDERED_MAP<uint64, T*> MapType; - typedef ACE_Thread_Mutex LockType; + typedef ACE_RW_Thread_Mutex LockType; static void Insert(T* o) { - ACE_GUARD(LockType, Guard, i_lock); + TRINITY_WRITE_GUARD(LockType, i_lock); m_objectMap[o->GetGUID()] = o; } static void Remove(T* o) { - ACE_GUARD(LockType, Guard, i_lock); + TRINITY_WRITE_GUARD(LockType, i_lock); m_objectMap.erase(o->GetGUID()); } static T* Find(uint64 guid) { - ACE_GUARD_RETURN(LockType, Guard, i_lock, NULL); + TRINITY_READ_GUARD(LockType, i_lock); typename MapType::iterator itr = m_objectMap.find(guid); return (itr != m_objectMap.end()) ? itr->second : NULL; } @@ -84,8 +84,7 @@ class HashMapHolder class ObjectAccessor { - friend class ACE_Singleton<ObjectAccessor, ACE_Thread_Mutex>; - friend class WorldRunnable; + friend class ACE_Singleton<ObjectAccessor, ACE_Null_Mutex>; private: ObjectAccessor(); ~ObjectAccessor(); @@ -93,15 +92,13 @@ class ObjectAccessor ObjectAccessor& operator=(const ObjectAccessor&); public: - typedef UNORDERED_MAP<uint64, Corpse*> Player2CorpsesMapType; - typedef UNORDERED_MAP<Player*, UpdateData>::value_type UpdateDataValueType; - // TODO: override these template functions for each holder type and add assertions template<class T> static T* GetObjectInOrOutOfWorld(uint64 guid, T* /*typeSpecifier*/) { return HashMapHolder<T>::Find(guid); } + static Unit* GetObjectInOrOutOfWorld(uint64 guid, Unit* /*typeSpecifier*/) { if (IS_PLAYER_GUID(guid)) @@ -155,15 +152,15 @@ class ObjectAccessor if (!obj || obj->GetMapId() != mapid) return NULL; - CellPair p = Trinity::ComputeCellPair(x, y); - if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) + CellCoord p = Trinity::ComputeCellCoord(x, y); + if (!p.IsCoordValid()) { sLog->outError("ObjectAccessor::GetObjectInWorld: invalid coordinates supplied X:%f Y:%f grid cell [%u:%u]", x, y, p.x_coord, p.y_coord); return NULL; } - CellPair q = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - if (q.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || q.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) + CellCoord q = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); + if (!q.IsCoordValid()) { sLog->outError("ObjectAccessor::GetObjecInWorld: object (GUID: %u TypeId: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), q.x_coord, q.y_coord); return NULL; @@ -195,83 +192,77 @@ class ObjectAccessor static Pet* FindPet(uint64); static Player* FindPlayer(uint64); static Unit* FindUnit(uint64); - Player* FindPlayerByName(const char* name); + static Player* FindPlayerByName(const char* name); // when using this, you must use the hashmapholder's lock - HashMapHolder<Player>::MapType& GetPlayers() + static HashMapHolder<Player>::MapType const& GetPlayers() { return HashMapHolder<Player>::GetContainer(); } // when using this, you must use the hashmapholder's lock - HashMapHolder<Creature>::MapType& GetCreatures() - { - return HashMapHolder<Creature>::GetContainer(); - } - - // when using this, you must use the hashmapholder's lock - HashMapHolder<GameObject>::MapType& GetGameObjects() - { - return HashMapHolder<GameObject>::GetContainer(); - } - - template<class T> void AddObject(T* object) + //HashMapHolder<Creature>::MapType& GetCreatures() + //{ + // return HashMapHolder<Creature>::GetContainer(); + //} + + //// when using this, you must use the hashmapholder's lock + //HashMapHolder<GameObject>::MapType& GetGameObjects() + //{ + // return HashMapHolder<GameObject>::GetContainer(); + //} + + template<class T> static void AddObject(T* object) { HashMapHolder<T>::Insert(object); } - template<class T> void RemoveObject(T* object) + template<class T> static void RemoveObject(T* object) { HashMapHolder<T>::Remove(object); } - void RemoveObject(Player* pl) - { - HashMapHolder<Player>::Remove(pl); - RemoveUpdateObject((Object*)pl); - } - - void SaveAllPlayers(); + static void SaveAllPlayers(); + //non-static functions void AddUpdateObject(Object* obj) { - ACE_GUARD(LockType, Guard, i_updateGuard); + TRINITY_GUARD(ACE_Thread_Mutex, i_objectLock); i_objects.insert(obj); } void RemoveUpdateObject(Object* obj) { - ACE_GUARD(LockType, Guard, i_updateGuard); + TRINITY_GUARD(ACE_Thread_Mutex, i_objectLock); i_objects.erase(obj); } - void Update(uint32 diff); - + //Thread safe Corpse* GetCorpseForPlayerGUID(uint64 guid); void RemoveCorpse(Corpse* corpse); void AddCorpse(Corpse* corpse); - void AddCorpsesToGrid(GridPair const& gridpair, GridType& grid, Map* map); + void AddCorpsesToGrid(GridCoord const& gridpair, GridType& grid, Map* map); Corpse* ConvertCorpseForPlayer(uint64 player_guid, bool insignia = false); - void RemoveOldCorpses(); - - typedef ACE_Thread_Mutex LockType; - protected: + //Thread unsafe + void Update(uint32 diff); + void RemoveOldCorpses(); void UnloadAll(); private: - - Player2CorpsesMapType i_player2corpse; - static void _buildChangeObjectForPlayer(WorldObject*, UpdateDataMapType&); static void _buildPacket(Player*, Object*, UpdateDataMapType&); void _update(); + typedef UNORDERED_MAP<uint64, Corpse*> Player2CorpsesMapType; + typedef UNORDERED_MAP<Player*, UpdateData>::value_type UpdateDataValueType; + std::set<Object*> i_objects; + Player2CorpsesMapType i_player2corpse; - LockType i_updateGuard; - LockType i_corpseGuard; + ACE_Thread_Mutex i_objectLock; + ACE_RW_Thread_Mutex i_corpseLock; }; -#define sObjectAccessor ACE_Singleton<ObjectAccessor, ACE_Thread_Mutex>::instance() +#define sObjectAccessor ACE_Singleton<ObjectAccessor, ACE_Null_Mutex>::instance() #endif diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 3c3fc36da05..287ce288a88 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1568,8 +1568,8 @@ void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data) { if (mask & 1) { - CellPair cell_pair = Trinity::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + CellCoord cellCoord = Trinity::ComputeCellCoord(data->posX, data->posY); + uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord; CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid, i)][cell_id]; cell_guids.creatures.insert(guid); @@ -1584,8 +1584,8 @@ void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) { if (mask & 1) { - CellPair cell_pair = Trinity::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + CellCoord cellCoord = Trinity::ComputeCellCoord(data->posX, data->posY); + uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord; CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid, i)][cell_id]; cell_guids.creatures.erase(guid); @@ -1627,7 +1627,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float // Spawn if necessary (loaded grids only) // We use spawn coords to spawn - if (!map->Instanceable() && map->IsLoaded(x, y)) + if (!map->Instanceable() && map->IsGridLoaded(x, y)) { GameObject* go = new GameObject; if (!go->LoadFromDB(guid, map)) @@ -1636,7 +1636,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float delete go; return 0; } - map->Add(go); + map->AddToMap(go); } sLog->outDebug(LOG_FILTER_MAPS, "AddGOData: dbguid %u entry %u map %u x %f y %f z %f o %f", guid, entry, mapId, x, y, z, o); @@ -1663,7 +1663,7 @@ bool ObjectMgr::MoveCreData(uint32 guid, uint32 mapId, Position pos) if (Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(mapId))) { // We use spawn coords to spawn - if (!map->Instanceable() && map->IsLoaded(data.posX, data.posY)) + if (!map->Instanceable() && map->IsGridLoaded(data.posX, data.posY)) { Creature* creature = new Creature; if (!creature->LoadFromDB(guid, map)) @@ -1672,7 +1672,7 @@ bool ObjectMgr::MoveCreData(uint32 guid, uint32 mapId, Position pos) delete creature; return false; } - map->Add(creature); + map->AddToMap(creature); } } return true; @@ -1725,7 +1725,7 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 /*team*/, uint32 mapId, float delete creature; return 0; } - map->Add(creature); + map->AddToMap(creature); } } @@ -1880,8 +1880,8 @@ void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) { if (mask & 1) { - CellPair cell_pair = Trinity::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + CellCoord cellCoord = Trinity::ComputeCellCoord(data->posX, data->posY); + uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord; CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid, i)][cell_id]; cell_guids.gameobjects.insert(guid); @@ -1896,8 +1896,8 @@ void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data { if (mask & 1) { - CellPair cell_pair = Trinity::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + CellCoord cellCoord = Trinity::ComputeCellCoord(data->posX, data->posY); + uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord; CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid, i)][cell_id]; cell_guids.gameobjects.erase(guid); @@ -5369,11 +5369,11 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) m->checked = fields[7].GetUInt32(); m->mailTemplateId = fields[8].GetInt16(); - Player* pl = NULL; + Player* player = NULL; if (serverUp) - pl = ObjectAccessor::FindPlayer((uint64)m->receiver); + player = ObjectAccessor::FindPlayer((uint64)m->receiver); - if (pl && pl->m_mailsLoaded) + if (player && player->m_mailsLoaded) { // this code will run very improbably (the time is between 4 and 5 am, in game is online a player, who has old mail // his in mailbox and he has already listed his mails) delete m; @@ -8490,13 +8490,13 @@ bool ObjectMgr::RemoveVendorItem(uint32 entry, uint32 item, bool savetodb) return true; } -bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* pl, std::set<uint32>* skip_vendors, uint32 ORnpcflag) const +bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* player, std::set<uint32>* skip_vendors, uint32 ORnpcflag) const { CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(vendor_entry); if (!cInfo) { - if (pl) - ChatHandler(pl).SendSysMessage(LANG_COMMAND_VENDORSELECTION); + if (player) + ChatHandler(player).SendSysMessage(LANG_COMMAND_VENDORSELECTION); else sLog->outErrorDb("Table `(game_event_)npc_vendor` have data for not existed creature template (Entry: %u), ignore", vendor_entry); return false; @@ -8506,8 +8506,8 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max { if (!skip_vendors || skip_vendors->count(vendor_entry) == 0) { - if (pl) - ChatHandler(pl).SendSysMessage(LANG_COMMAND_VENDORSELECTION); + if (player) + ChatHandler(player).SendSysMessage(LANG_COMMAND_VENDORSELECTION); else sLog->outErrorDb("Table `(game_event_)npc_vendor` have data for not creature template (Entry: %u) without vendor flag, ignore", vendor_entry); @@ -8519,8 +8519,8 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max if (!sObjectMgr->GetItemTemplate(item_id)) { - if (pl) - ChatHandler(pl).PSendSysMessage(LANG_ITEM_NOT_FOUND, item_id); + if (player) + ChatHandler(player).PSendSysMessage(LANG_ITEM_NOT_FOUND, item_id); else sLog->outErrorDb("Table `(game_event_)npc_vendor` for Vendor (Entry: %u) have in item list non-existed item (%u), ignore", vendor_entry, item_id); return false; @@ -8528,8 +8528,8 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost)) { - if (pl) - ChatHandler(pl).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST, ExtendedCost); + if (player) + ChatHandler(player).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST, ExtendedCost); else sLog->outErrorDb("Table `(game_event_)npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore", item_id, ExtendedCost, vendor_entry); return false; @@ -8537,16 +8537,16 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max if (maxcount > 0 && incrtime == 0) { - if (pl) - ChatHandler(pl).PSendSysMessage("MaxCount != 0 (%u) but IncrTime == 0", maxcount); + if (player) + ChatHandler(player).PSendSysMessage("MaxCount != 0 (%u) but IncrTime == 0", maxcount); else sLog->outErrorDb("Table `(game_event_)npc_vendor` has `maxcount` (%u) for item %u of vendor (Entry: %u) but `incrtime`=0, ignore", maxcount, item_id, vendor_entry); return false; } else if (maxcount == 0 && incrtime > 0) { - if (pl) - ChatHandler(pl).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0"); + if (player) + ChatHandler(player).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0"); else sLog->outErrorDb("Table `(game_event_)npc_vendor` has `maxcount`=0 for item %u of vendor (Entry: %u) but `incrtime`<>0, ignore", item_id, vendor_entry); return false; @@ -8558,8 +8558,8 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max if (vItems->FindItemCostPair(item_id, ExtendedCost)) { - if (pl) - ChatHandler(pl).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost); + if (player) + ChatHandler(player).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost); else sLog->outErrorDb("Table `npc_vendor` has duplicate items %u (with extended cost %u) for vendor (Entry: %u), ignoring", item_id, ExtendedCost, vendor_entry); return false; @@ -8567,8 +8567,8 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max if (vItems->GetItemCount() >= MAX_VENDOR_ITEMS) { - if (pl) - ChatHandler(pl).SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS); + if (player) + ChatHandler(player).SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS); else sLog->outErrorDb("Table `npc_vendor` has too many items (%u >= %i) for vendor (Entry: %u), ignore", vItems->GetItemCount(), MAX_VENDOR_ITEMS, vendor_entry); return false; diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index c557af1c2b2..88c593a009d 100755 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -1076,14 +1076,14 @@ class ObjectMgr time_t GetCreatureRespawnTime(uint32 loguid, uint32 instance) { - ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, m_CreatureRespawnTimesMtx, 0); + TRINITY_GUARD(ACE_Thread_Mutex, m_CreatureRespawnTimesMtx); return mCreatureRespawnTimes[MAKE_PAIR64(loguid, instance)]; } void SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t); void RemoveCreatureRespawnTime(uint32 loguid, uint32 instance); time_t GetGORespawnTime(uint32 loguid, uint32 instance) { - ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, m_GORespawnTimesMtx, 0); + TRINITY_GUARD(ACE_Thread_Mutex, m_GORespawnTimesMtx); return mGORespawnTimes[MAKE_PAIR64(loguid, instance)]; } void SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t); @@ -1140,7 +1140,7 @@ class ObjectMgr } void AddVendorItem(uint32 entry, uint32 item, int32 maxcount, uint32 incrtime, uint32 ExtendedCost, bool savetodb = true); // for event bool RemoveVendorItem(uint32 entry, uint32 item, bool savetodb = true); // for event - bool IsVendorItemValid(uint32 vendor_entry, uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0) const; + bool IsVendorItemValid(uint32 vendor_entry, uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* player = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0) const; void LoadScriptNames(); ScriptNameMap &GetScriptNames() { return m_scriptNames; } diff --git a/src/server/game/Grids/Cells/Cell.h b/src/server/game/Grids/Cells/Cell.h index a7fd879358e..13bb0afc494 100755 --- a/src/server/game/Grids/Cells/Cell.h +++ b/src/server/game/Grids/Cells/Cell.h @@ -29,87 +29,34 @@ class Map; class WorldObject; -enum District -{ - UPPER_DISTRICT = 1, - LOWER_DISTRICT = 1 << 1, - LEFT_DISTRICT = 1 << 2, - RIGHT_DISTRICT = 1 << 3, - CENTER_DISTRICT = 1 << 4, - UPPER_LEFT_DISTRICT = (UPPER_DISTRICT | LEFT_DISTRICT), - UPPER_RIGHT_DISTRICT = (UPPER_DISTRICT | RIGHT_DISTRICT), - LOWER_LEFT_DISTRICT = (LOWER_DISTRICT | LEFT_DISTRICT), - LOWER_RIGHT_DISTRICT = (LOWER_DISTRICT | RIGHT_DISTRICT), - ALL_DISTRICT = (UPPER_DISTRICT | LOWER_DISTRICT | LEFT_DISTRICT | RIGHT_DISTRICT | CENTER_DISTRICT) -}; - struct CellArea { - CellArea() : right_offset(0), left_offset(0), upper_offset(0), lower_offset(0) {} - CellArea(int right, int left, int upper, int lower) : right_offset(right), left_offset(left), upper_offset(upper), lower_offset(lower) {} - bool operator!() const { return !right_offset && !left_offset && !upper_offset && !lower_offset; } + CellArea() {} + CellArea(CellCoord low, CellCoord high) : low_bound(low), high_bound(high) {} + + bool operator!() const { return low_bound == high_bound; } - void ResizeBorders(CellPair& begin_cell, CellPair& end_cell) const + void ResizeBorders(CellCoord& begin_cell, CellCoord& end_cell) const { - begin_cell << left_offset; - begin_cell -= lower_offset; - end_cell >> right_offset; - end_cell += upper_offset; + begin_cell = low_bound; + end_cell = high_bound; } - int right_offset; - int left_offset; - int upper_offset; - int lower_offset; + CellCoord low_bound; + CellCoord high_bound; }; struct Cell { Cell() { data.All = 0; } - Cell(const Cell &cell) { data.All = cell.data.All; } - explicit Cell(CellPair const& p); - - void operator|=(Cell &cell) - { - data.Part.reserved = 0; - cell.data.Part.reserved = 0; - uint32 x, y, old_x, old_y; - Compute(x, y); - cell.Compute(old_x, old_y); - - if (std::abs(int(x-old_x)) > 1 || std::abs(int(y-old_y)) > 1) - { - data.Part.reserved = ALL_DISTRICT; - cell.data.Part.reserved = ALL_DISTRICT; - return; - } - - if (x < old_x) - { - data.Part.reserved |= LEFT_DISTRICT; - cell.data.Part.reserved |= RIGHT_DISTRICT; - } - else if (old_x < x) - { - data.Part.reserved |= RIGHT_DISTRICT; - cell.data.Part.reserved |= LEFT_DISTRICT; - } - if (y < old_y) - { - data.Part.reserved |= UPPER_DISTRICT; - cell.data.Part.reserved |= LOWER_DISTRICT; - } - else if (old_y < y) - { - data.Part.reserved |= LOWER_DISTRICT; - cell.data.Part.reserved |= UPPER_DISTRICT; - } - } + Cell(Cell const& cell) { data.All = cell.data.All; } + explicit Cell(CellCoord const& p); + explicit Cell(float x, float y); void Compute(uint32 &x, uint32 &y) const { - x = data.Part.grid_x*MAX_NUMBER_OF_CELLS + data.Part.cell_x; - y = data.Part.grid_y*MAX_NUMBER_OF_CELLS + data.Part.cell_y; + x = data.Part.grid_x * MAX_NUMBER_OF_CELLS + data.Part.cell_x; + y = data.Part.grid_y * MAX_NUMBER_OF_CELLS + data.Part.cell_y; } bool DiffCell(const Cell &cell) const @@ -131,21 +78,21 @@ struct Cell bool NoCreate() const { return data.Part.nocreate; } void SetNoCreate() { data.Part.nocreate = 1; } - CellPair cellPair() const + CellCoord GetCellCoord() const { - return CellPair( - data.Part.grid_x*MAX_NUMBER_OF_CELLS+data.Part.cell_x, - data.Part.grid_y*MAX_NUMBER_OF_CELLS+data.Part.cell_y); + return CellCoord( + data.Part.grid_x * MAX_NUMBER_OF_CELLS+data.Part.cell_x, + data.Part.grid_y * MAX_NUMBER_OF_CELLS+data.Part.cell_y); } - Cell& operator=(const Cell &cell) + Cell& operator=(Cell const& cell) { this->data.All = cell.data.All; return *this; } - bool operator == (const Cell &cell) const { return (data.All == cell.data.All); } - bool operator != (const Cell &cell) const { return !operator == (cell); } + bool operator == (Cell const& cell) const { return (data.All == cell.data.All); } + bool operator != (Cell const& cell) const { return !operator == (cell); } union { struct @@ -160,15 +107,13 @@ struct Cell uint32 All; } data; - template<class T, class CONTAINER> void Visit(const CellPair&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &) const; - template<class T, class CONTAINER> void Visit(const CellPair&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &, const WorldObject&, float) const; - template<class T, class CONTAINER> void Visit(const CellPair&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &, float, float, float) const; + template<class T, class CONTAINER> void Visit(CellCoord const&, TypeContainerVisitor<T, CONTAINER>& visitor, Map &, WorldObject const&, float) const; + template<class T, class CONTAINER> void Visit(CellCoord const&, TypeContainerVisitor<T, CONTAINER>& visitor, Map &, float, float, float) const; - static CellArea CalculateCellArea(const WorldObject &obj, float radius); static CellArea CalculateCellArea(float x, float y, float radius); private: - template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER> &, Map &, const CellPair&, const CellPair&) const; + template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER> &, Map &, CellCoord const&, CellCoord const&) const; }; #endif diff --git a/src/server/game/Grids/Cells/CellImpl.h b/src/server/game/Grids/Cells/CellImpl.h index d36892ffcb0..af697b9f21d 100755..100644 --- a/src/server/game/Grids/Cells/CellImpl.h +++ b/src/server/game/Grids/Cells/CellImpl.h @@ -25,7 +25,7 @@ #include "Map.h" #include "Object.h" -inline Cell::Cell(CellPair const& p) +inline Cell::Cell(CellCoord const& p) { data.Part.grid_x = p.x_coord / MAX_NUMBER_OF_CELLS; data.Part.grid_y = p.y_coord / MAX_NUMBER_OF_CELLS; @@ -35,143 +35,35 @@ inline Cell::Cell(CellPair const& p) data.Part.reserved = 0; } -template<class T, class CONTAINER> -inline void -Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m) const -{ - if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) - return; - - uint16 district = (District)this->data.Part.reserved; - if (district == CENTER_DISTRICT) - { - m.Visit(*this, visitor); - return; - } - - // set up the cell range based on the district - // the overloaded operators handle range checking - CellPair begin_cell = standing_cell; - CellPair end_cell = standing_cell; - - switch (district) - { - case ALL_DISTRICT: - { - begin_cell << 1; begin_cell -= 1; // upper left - end_cell >> 1; end_cell += 1; // lower right - break; - } - case UPPER_LEFT_DISTRICT: - { - begin_cell << 1; begin_cell -= 1; // upper left - break; - } - case UPPER_RIGHT_DISTRICT: - { - begin_cell -= 1; // up - end_cell >> 1; // right - break; - } - case LOWER_LEFT_DISTRICT: - { - begin_cell << 1; // left - end_cell += 1; // down - break; - } - case LOWER_RIGHT_DISTRICT: - { - end_cell >> 1; end_cell += 1; // lower right - break; - } - case LEFT_DISTRICT: - { - begin_cell -= 1; // up - end_cell >> 1; end_cell += 1; // lower right - break; - } - case RIGHT_DISTRICT: - { - begin_cell << 1; begin_cell -= 1; // upper left - end_cell += 1; // down - break; - } - case UPPER_DISTRICT: - { - begin_cell << 1; begin_cell -= 1; // upper left - end_cell >> 1; // right - break; - } - case LOWER_DISTRICT: - { - begin_cell << 1; // left - end_cell >> 1; end_cell += 1; // lower right - break; - } - default: - { - ASSERT(false); - break; - } - } - - // loop the cell range - for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++) - { - for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; y++) - { - CellPair cell_pair(x, y); - Cell r_zone(cell_pair); - r_zone.data.Part.nocreate = this->data.Part.nocreate; - m.Visit(r_zone, visitor); - } - } -} - -inline int CellHelper(const float radius) -{ - if (radius < 1.0f) - return 0; - - return (int)ceilf(radius/SIZE_OF_GRID_CELL); -} - -inline CellArea Cell::CalculateCellArea(const WorldObject &obj, float radius) +inline Cell::Cell(float x, float y) { - return Cell::CalculateCellArea(obj.GetPositionX(), obj.GetPositionY(), radius); + CellCoord p = Trinity::ComputeCellCoord(x, y); + data.Part.grid_x = p.x_coord / MAX_NUMBER_OF_CELLS; + data.Part.grid_y = p.y_coord / MAX_NUMBER_OF_CELLS; + data.Part.cell_x = p.x_coord % MAX_NUMBER_OF_CELLS; + data.Part.cell_y = p.y_coord % MAX_NUMBER_OF_CELLS; + data.Part.nocreate = 0; + data.Part.reserved = 0; } inline CellArea Cell::CalculateCellArea(float x, float y, float radius) { if (radius <= 0.0f) - return CellArea(); - - //lets calculate object coord offsets from cell borders. - //TODO: add more correct/generic method for this task - const float x_offset = (x - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL; - const float y_offset = (y - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL; - - const float x_val = floor(x_offset + CENTER_GRID_CELL_ID + 0.5f); - const float y_val = floor(y_offset + CENTER_GRID_CELL_ID + 0.5f); - - const float x_off = (x_offset - x_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL; - const float y_off = (y_offset - y_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL; + { + CellCoord center = Trinity::ComputeCellCoord(x, y).normalize(); + return CellArea(center, center); + } - const float tmp_diff = radius - CENTER_GRID_CELL_OFFSET; - //lets calculate upper/lower/right/left corners for cell search - int right = CellHelper(tmp_diff + x_off); - int left = CellHelper(tmp_diff - x_off); - int upper = CellHelper(tmp_diff + y_off); - int lower = CellHelper(tmp_diff - y_off); + CellCoord centerX = Trinity::ComputeCellCoord(x - radius, y - radius).normalize(); + CellCoord centerY = Trinity::ComputeCellCoord(x + radius, y + radius).normalize(); - return CellArea(right, left, upper, lower); + return CellArea(centerX, centerY); } template<class T, class CONTAINER> -inline void -Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, float radius, float x_off, float y_off) const +inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor<T, CONTAINER>& visitor, Map& map, float radius, float x_off, float y_off) const { - if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) + if (!standing_cell.IsCoordValid()) return; //no jokes here... Actually placing ASSERT() here was good idea, but @@ -179,7 +71,7 @@ Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &v //maybe it is better to just return when radius <= 0.0f? if (radius <= 0.0f) { - m.Visit(*this, visitor); + map.Visit(*this, visitor); return; } //lets limit the upper value for search radius @@ -191,57 +83,51 @@ Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &v //if radius fits inside standing cell if (!area) { - m.Visit(*this, visitor); + map.Visit(*this, visitor); return; } - CellPair begin_cell = standing_cell; - CellPair end_cell = standing_cell; - - area.ResizeBorders(begin_cell, end_cell); //visit all cells, found in CalculateCellArea() //if radius is known to reach cell area more than 4x4 then we should call optimized VisitCircle //currently this technique works with MAX_NUMBER_OF_CELLS 16 and higher, with lower values //there are nothing to optimize because SIZE_OF_GRID_CELL is too big... - if (((end_cell.x_coord - begin_cell.x_coord) > 4) && ((end_cell.y_coord - begin_cell.y_coord) > 4)) + if (((area.high_bound.x_coord - area.low_bound.x_coord) > 4) && ((area.high_bound.y_coord - area.low_bound.y_coord) > 4)) { - VisitCircle(visitor, m, begin_cell, end_cell); + VisitCircle(visitor, map, area.low_bound, area.high_bound); return; } //ALWAYS visit standing cell first!!! Since we deal with small radiuses //it is very essential to call visitor for standing cell firstly... - m.Visit(*this, visitor); + map.Visit(*this, visitor); // loop the cell range - for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x) + for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x) { - for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y) + for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y) { - CellPair cell_pair(x, y); + CellCoord cellCoord(x, y); //lets skip standing cell since we already visited it - if (cell_pair != standing_cell) + if (cellCoord != standing_cell) { - Cell r_zone(cell_pair); + Cell r_zone(cellCoord); r_zone.data.Part.nocreate = this->data.Part.nocreate; - m.Visit(r_zone, visitor); + map.Visit(r_zone, visitor); } } } } template<class T, class CONTAINER> -inline void -Cell::Visit(const CellPair& l, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const WorldObject &obj, float radius) const +inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor<T, CONTAINER>& visitor, Map& map, WorldObject const& obj, float radius) const { //we should increase search radius by object's radius, otherwise //we could have problems with huge creatures, which won't attack nearest players etc - Visit(l, visitor, m, radius + obj.GetObjectSize(), obj.GetPositionX(), obj.GetPositionY()); + Visit(standing_cell, visitor, map, radius + obj.GetObjectSize(), obj.GetPositionX(), obj.GetPositionY()); } template<class T, class CONTAINER> -inline void -Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const CellPair& begin_cell, const CellPair& end_cell) const +inline void Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER>& visitor, Map& map, CellCoord const& begin_cell, CellCoord const& end_cell) const { //here is an algorithm for 'filling' circum-squared octagon uint32 x_shift = (uint32)ceilf((end_cell.x_coord - begin_cell.x_coord) * 0.3f - 0.5f); @@ -254,10 +140,10 @@ Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const Cel { for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y) { - CellPair cell_pair(x, y); - Cell r_zone(cell_pair); + CellCoord cellCoord(x, y); + Cell r_zone(cellCoord); r_zone.data.Part.nocreate = this->data.Part.nocreate; - m.Visit(r_zone, visitor); + map.Visit(r_zone, visitor); } } @@ -278,16 +164,16 @@ Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const Cel { //we visit cells symmetrically from both sides, heading from center to sides and from up to bottom //e.g. filling 2 trapezoids after filling central cell strip... - CellPair cell_pair_left(x_start - step, y); - Cell r_zone_left(cell_pair_left); + CellCoord cellCoord_left(x_start - step, y); + Cell r_zone_left(cellCoord_left); r_zone_left.data.Part.nocreate = this->data.Part.nocreate; - m.Visit(r_zone_left, visitor); + map.Visit(r_zone_left, visitor); //right trapezoid cell visit - CellPair cell_pair_right(x_end + step, y); - Cell r_zone_right(cell_pair_right); + CellCoord cellCoord_right(x_end + step, y); + Cell r_zone_right(cellCoord_right); r_zone_right.data.Part.nocreate = this->data.Part.nocreate; - m.Visit(r_zone_right, visitor); + map.Visit(r_zone_right, visitor); } } } diff --git a/src/server/game/Grids/Grid.h b/src/server/game/Grids/Grid.h index a6e1316718e..448c4cb35fd 100755 --- a/src/server/game/Grids/Grid.h +++ b/src/server/game/Grids/Grid.h @@ -58,40 +58,42 @@ class Grid */ template<class SPECIFIC_OBJECT> void AddWorldObject(SPECIFIC_OBJECT *obj) { - if (!i_objects.template insert<SPECIFIC_OBJECT>(obj)) - ASSERT(false); + i_objects.template insert<SPECIFIC_OBJECT>(obj); + ASSERT(obj->IsInGrid()); } /** an object of interested exits the grid */ - template<class SPECIFIC_OBJECT> void RemoveWorldObject(SPECIFIC_OBJECT *obj) - { - if (!i_objects.template remove<SPECIFIC_OBJECT>(obj)) - ASSERT(false); - } + //Actually an unlink is enough, no need to go through the container + //template<class SPECIFIC_OBJECT> void RemoveWorldObject(SPECIFIC_OBJECT *obj) + //{ + // ASSERT(obj->GetGridRef().isValid()); + // i_objects.template remove<SPECIFIC_OBJECT>(obj); + // ASSERT(!obj->GetGridRef().isValid()); + //} /** Refreshes/update the grid. This required for remote grids. */ - void RefreshGrid(void) { /* TBI */} + //void RefreshGrid(void) { /* TBI */} /** Locks a grid. Any object enters must wait until the grid is unlock. */ - void LockGrid(void) { /* TBI */ } + //void LockGrid(void) { /* TBI */ } /** Unlocks the grid. */ - void UnlockGrid(void) { /* TBI */ } + //void UnlockGrid(void) { /* TBI */ } - /** Grid visitor for grid objects - */ - template<class T> void Visit(TypeContainerVisitor<T, TypeMapContainer<GRID_OBJECT_TYPES> > &visitor) + // Visit grid objects + template<class T> + void Visit(TypeContainerVisitor<T, TypeMapContainer<GRID_OBJECT_TYPES> > &visitor) { visitor.Visit(i_container); } - /** Grid visitor for world objects - */ - template<class T> void Visit(TypeContainerVisitor<T, TypeMapContainer<WORLD_OBJECT_TYPES> > &visitor) + // Visit world objects + template<class T> + void Visit(TypeContainerVisitor<T, TypeMapContainer<WORLD_OBJECT_TYPES> > &visitor) { visitor.Visit(i_objects); } @@ -104,17 +106,18 @@ class Grid */ template<class SPECIFIC_OBJECT> void AddGridObject(SPECIFIC_OBJECT *obj) { - if (!i_container.template insert<SPECIFIC_OBJECT>(obj)) - ASSERT(false); + i_container.template insert<SPECIFIC_OBJECT>(obj); + ASSERT(obj->IsInGrid()); } /** Removes a containter type object from the grid */ - template<class SPECIFIC_OBJECT> void RemoveGridObject(SPECIFIC_OBJECT *obj) - { - if (!i_container.template remove<SPECIFIC_OBJECT>(obj)) - ASSERT(false); - } + //template<class SPECIFIC_OBJECT> void RemoveGridObject(SPECIFIC_OBJECT *obj) + //{ + // ASSERT(obj->GetGridRef().isValid()); + // i_container.template remove<SPECIFIC_OBJECT>(obj); + // ASSERT(!obj->GetGridRef().isValid()); + //} /*bool NoWorldObjectInGrid() const { diff --git a/src/server/game/Grids/GridDefines.h b/src/server/game/Grids/GridDefines.h index a284e342ca9..44e2588ef81 100755..100644 --- a/src/server/game/Grids/GridDefines.h +++ b/src/server/game/Grids/GridDefines.h @@ -71,21 +71,27 @@ typedef NGrid<MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTyp typedef TypeMapContainer<AllGridObjectTypes> GridTypeMapContainer; typedef TypeMapContainer<AllWorldObjectTypes> WorldTypeMapContainer; -template<const unsigned int LIMIT> +template<uint32 LIMIT> struct CoordPair { - CoordPair(uint32 x=0, uint32 y=0) : x_coord(x), y_coord(y) {} - CoordPair(const CoordPair<LIMIT> &obj) : x_coord(obj.x_coord), y_coord(obj.y_coord) {} - bool operator == (const CoordPair<LIMIT> &obj) const { return (obj.x_coord == x_coord && obj.y_coord == y_coord); } - bool operator != (const CoordPair<LIMIT> &obj) const { return !operator == (obj); } - CoordPair<LIMIT>& operator=(const CoordPair<LIMIT> &obj) + CoordPair(uint32 x=0, uint32 y=0) + : x_coord(x) + , y_coord(y) + {} + + CoordPair(const CoordPair<LIMIT> &obj) + : x_coord(obj.x_coord) + , y_coord(obj.y_coord) + {} + + CoordPair<LIMIT> & operator=(const CoordPair<LIMIT> &obj) { x_coord = obj.x_coord; y_coord = obj.y_coord; return *this; } - void operator<<(const uint32 val) + void dec_x(uint32 val) { if (x_coord > val) x_coord -= val; @@ -93,15 +99,15 @@ struct CoordPair x_coord = 0; } - void operator>>(const uint32 val) + void inc_x(uint32 val) { - if (x_coord+val < LIMIT) + if (x_coord + val < LIMIT) x_coord += val; else x_coord = LIMIT - 1; } - void operator-=(const uint32 val) + void dec_y(uint32 val) { if (y_coord > val) y_coord -= val; @@ -109,20 +115,44 @@ struct CoordPair y_coord = 0; } - void operator+=(const uint32 val) + void inc_y(uint32 val) { - if (y_coord+val < LIMIT) + if (y_coord + val < LIMIT) y_coord += val; else y_coord = LIMIT - 1; } + bool IsCoordValid() const + { + return x_coord < LIMIT && y_coord < LIMIT; + } + + CoordPair& normalize() + { + x_coord = std::min(x_coord, LIMIT - 1); + y_coord = std::min(y_coord, LIMIT - 1); + return *this; + } + uint32 x_coord; uint32 y_coord; }; -typedef CoordPair<MAX_NUMBER_OF_GRIDS> GridPair; -typedef CoordPair<TOTAL_NUMBER_OF_CELLS_PER_MAP> CellPair; +template<uint32 LIMIT> +bool operator==(const CoordPair<LIMIT> &p1, const CoordPair<LIMIT> &p2) +{ + return (p1.x_coord == p2.x_coord && p1.y_coord == p2.y_coord); +} + +template<uint32 LIMIT> +bool operator!=(const CoordPair<LIMIT> &p1, const CoordPair<LIMIT> &p2) +{ + return !(p1 == p2); +} + +typedef CoordPair<MAX_NUMBER_OF_GRIDS> GridCoord; +typedef CoordPair<TOTAL_NUMBER_OF_CELLS_PER_MAP> CellCoord; namespace Trinity { @@ -133,44 +163,44 @@ namespace Trinity double x_offset = (double(x) - center_offset)/size; double y_offset = (double(y) - center_offset)/size; - int x_val = int(x_offset+CENTER_VAL + 0.5); - int y_val = int(y_offset+CENTER_VAL + 0.5); + int x_val = int(x_offset+CENTER_VAL + 0.5f); + int y_val = int(y_offset+CENTER_VAL + 0.5f); return RET_TYPE(x_val, y_val); } - inline GridPair ComputeGridPair(float x, float y) + inline GridCoord ComputeGridCoord(float x, float y) { - return Compute<GridPair, CENTER_GRID_ID>(x, y, CENTER_GRID_OFFSET, SIZE_OF_GRIDS); + return Compute<GridCoord, CENTER_GRID_ID>(x, y, CENTER_GRID_OFFSET, SIZE_OF_GRIDS); } - inline CellPair ComputeCellPair(float x, float y) + inline CellCoord ComputeCellCoord(float x, float y) { - return Compute<CellPair, CENTER_GRID_CELL_ID>(x, y, CENTER_GRID_CELL_OFFSET, SIZE_OF_GRID_CELL); + return Compute<CellCoord, CENTER_GRID_CELL_ID>(x, y, CENTER_GRID_CELL_OFFSET, SIZE_OF_GRID_CELL); } - inline CellPair ComputeCellPair(float x, float y, float &x_off, float &y_off) + inline CellCoord ComputeCellCoord(float x, float y, float &x_off, float &y_off) { double x_offset = (double(x) - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL; double y_offset = (double(y) - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL; - int x_val = int(x_offset + CENTER_GRID_CELL_ID + 0.5); - int y_val = int(y_offset + CENTER_GRID_CELL_ID + 0.5); + int x_val = int(x_offset + CENTER_GRID_CELL_ID + 0.5f); + int y_val = int(y_offset + CENTER_GRID_CELL_ID + 0.5f); x_off = (float(x_offset) - x_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL; y_off = (float(y_offset) - y_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL; - return CellPair(x_val, y_val); + return CellCoord(x_val, y_val); } inline void NormalizeMapCoord(float &c) { - if (c > MAP_HALFSIZE - 0.5) - c = MAP_HALFSIZE - 0.5; - else if (c < -(MAP_HALFSIZE - 0.5)) - c = -(MAP_HALFSIZE - 0.5); + if (c > MAP_HALFSIZE - 0.5f) + c = MAP_HALFSIZE - 0.5f; + else if (c < -(MAP_HALFSIZE - 0.5f)) + c = -(MAP_HALFSIZE - 0.5f); } inline bool IsValidMapCoord(float c) { - return finite(c) && (std::fabs(c) <= MAP_HALFSIZE - 0.5); + return finite(c) && (std::fabs(c) <= MAP_HALFSIZE - 0.5f); } inline bool IsValidMapCoord(float x, float y) diff --git a/src/server/game/Grids/GridLoader.h b/src/server/game/Grids/GridLoader.h index 0e762d3a07e..43564c920e2 100755 --- a/src/server/game/Grids/GridLoader.h +++ b/src/server/game/Grids/GridLoader.h @@ -30,6 +30,8 @@ GridLoader manages the grid (both local and remote). */ +//I cannot see why this cannot be replaced by a Grid::Visit +/* #include "Define.h" #include "Grid.h" #include "TypeContainerVisitor.h" @@ -44,8 +46,7 @@ class GridLoader { public: - /** Loads the grid - */ + // Loads the grid template<class LOADER> void Load(Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> &grid, LOADER &loader) { @@ -54,8 +55,7 @@ class GridLoader grid.UnlockGrid(); } - /** Stop the grid - */ + // Stop the grid template<class STOPER> void Stop(Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> &grid, STOPER &stoper) { @@ -63,8 +63,8 @@ class GridLoader stoper.Stop(grid); grid.UnlockGrid(); } - /** Unloads the grid - */ + + // Unloads the grid template<class UNLOADER> void Unload(Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> &grid, UNLOADER &unloader) { @@ -73,5 +73,6 @@ class GridLoader grid.UnlockGrid(); } }; +*/ #endif diff --git a/src/server/game/Grids/GridStates.cpp b/src/server/game/Grids/GridStates.cpp index 91bb926fd02..5f88516c9ac 100755 --- a/src/server/game/Grids/GridStates.cpp +++ b/src/server/game/Grids/GridStates.cpp @@ -21,24 +21,23 @@ #include "Grid.h" #include "Log.h" -void -InvalidState::Update(Map &, NGridType &, GridInfo &, const uint32 /*x*/, const uint32 /*y*/, const uint32) const +void InvalidState::Update(Map &, NGridType &, GridInfo &, const uint32) const { } -void -ActiveState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32 x, const uint32 y, const uint32 t_diff) const +void ActiveState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32 t_diff) const { // Only check grid activity every (grid_expiry/10) ms, because it's really useless to do it every cycle info.UpdateTimeTracker(t_diff); if (info.getTimeTracker().Passed()) { - if (grid.ActiveObjectsInGrid() == 0 && !m.ActiveObjectsNearGrid(x, y)) + if (grid.ActiveObjectsInGrid() == 0 && !m.ActiveObjectsNearGrid(grid)) { - ObjectGridStoper stoper(grid); - stoper.StopN(); + ObjectGridStoper worker; + TypeContainerVisitor<ObjectGridStoper, GridTypeMapContainer> visitor(worker); + grid.VisitAllGrids(visitor); grid.SetGridState(GRID_STATE_IDLE); - sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] on map %u moved to IDLE state", x, y, m.GetId()); + sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] on map %u moved to IDLE state", grid.getX(), grid.getY(), m.GetId()); } else { @@ -47,25 +46,23 @@ ActiveState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32 x, co } } -void -IdleState::Update(Map &m, NGridType &grid, GridInfo &, const uint32 x, const uint32 y, const uint32) const +void IdleState::Update(Map &m, NGridType &grid, GridInfo &, const uint32) const { m.ResetGridExpiry(grid); grid.SetGridState(GRID_STATE_REMOVAL); - sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] on map %u moved to REMOVAL state", x, y, m.GetId()); + sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] on map %u moved to REMOVAL state", grid.getX(), grid.getY(), m.GetId()); } -void -RemovalState::Update(Map &m, NGridType &grid, GridInfo &info, const uint32 x, const uint32 y, const uint32 t_diff) const +void RemovalState::Update(Map &m, NGridType &grid, GridInfo &info, const uint32 t_diff) const { if (!info.getUnloadLock()) { info.UpdateTimeTracker(t_diff); if (info.getTimeTracker().Passed()) { - if (!m.UnloadGrid(x, y, false)) + if (!m.UnloadGrid(grid, false)) { - sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] for map %u differed unloading due to players or active objects nearby", x, y, m.GetId()); + sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] for map %u differed unloading due to players or active objects nearby", grid.getX(), grid.getY(), m.GetId()); m.ResetGridExpiry(grid); } } diff --git a/src/server/game/Grids/GridStates.h b/src/server/game/Grids/GridStates.h index 81bf749b63f..78f70356608 100755 --- a/src/server/game/Grids/GridStates.h +++ b/src/server/game/Grids/GridStates.h @@ -40,35 +40,31 @@ class GridState void setMagic() { i_Magic = MAGIC_TESTVAL; } unsigned int i_Magic; #endif - virtual void Update(Map &, NGridType&, GridInfo &, const uint32 x, const uint32 y, const uint32 t_diff) const = 0; + virtual void Update(Map &, NGridType&, GridInfo &, const uint32 t_diff) const = 0; }; class InvalidState : public GridState { public: - - void Update(Map &, NGridType &, GridInfo &, const uint32 x, const uint32 y, const uint32 t_diff) const; + void Update(Map &, NGridType &, GridInfo &, const uint32 t_diff) const; }; class ActiveState : public GridState { public: - - void Update(Map &, NGridType &, GridInfo &, const uint32 x, const uint32 y, const uint32 t_diff) const; + void Update(Map &, NGridType &, GridInfo &, const uint32 t_diff) const; }; class IdleState : public GridState { public: - - void Update(Map &, NGridType &, GridInfo &, const uint32 x, const uint32 y, const uint32 t_diff) const; + void Update(Map &, NGridType &, GridInfo &, const uint32 t_diff) const; }; class RemovalState : public GridState { public: - - void Update(Map &, NGridType &, GridInfo &, const uint32 x, const uint32 y, const uint32 t_diff) const; + void Update(Map &, NGridType &, GridInfo &, const uint32 t_diff) const; }; #endif diff --git a/src/server/game/Grids/NGrid.h b/src/server/game/Grids/NGrid.h index cd2345e439d..97a47f7d272 100755 --- a/src/server/game/Grids/NGrid.h +++ b/src/server/game/Grids/NGrid.h @@ -69,7 +69,7 @@ typedef enum template < -unsigned int N, +uint32 N, class ACTIVE_OBJECT, class WORLD_OBJECT_TYPES, class GRID_OBJECT_TYPES @@ -77,7 +77,6 @@ class GRID_OBJECT_TYPES class NGrid { public: - typedef Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> GridType; NGrid(uint32 id, int32 x, int32 y, time_t expiry, bool unload = true) : i_gridId(id), i_x(x), i_y(y), i_cellstate(GRID_STATE_INVALID), i_GridObjectDataLoaded(false) @@ -85,17 +84,15 @@ class NGrid i_GridInfo = GridInfo(expiry, unload); } - const GridType& operator()(unsigned short x, unsigned short y) const + GridType& GetGridType(const uint32 x, const uint32 y) { - ASSERT(x < N); - ASSERT(y < N); + ASSERT(x < N && y < N); return i_cells[x][y]; } - GridType& operator()(unsigned short x, unsigned short y) + GridType const& GetGridType(const uint32 x, const uint32 y) const { - ASSERT(x < N); - ASSERT(y < N); + ASSERT(x < N && y < N); return i_cells[x][y]; } @@ -123,56 +120,54 @@ class NGrid void ResetTimeTracker(time_t interval) { i_GridInfo.ResetTimeTracker(interval); } void UpdateTimeTracker(time_t diff) { i_GridInfo.UpdateTimeTracker(diff); } + /* template<class SPECIFIC_OBJECT> void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) { - getGridType(x, y).AddWorldObject(obj); + GetGridType(x, y).AddWorldObject(obj); } template<class SPECIFIC_OBJECT> void RemoveWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) { - getGridType(x, y).RemoveWorldObject(obj); + GetGridType(x, y).RemoveWorldObject(obj); } - template<class T, class TT> void Visit(TypeContainerVisitor<T, TypeMapContainer<TT> > &visitor) + template<class SPECIFIC_OBJECT> void AddGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) { - for (unsigned int x=0; x < N; ++x) - for (unsigned int y=0; y < N; ++y) - getGridType(x, y).Visit(visitor); + GetGridType(x, y).AddGridObject(obj); } - template<class T, class TT> void Visit(const uint32 x, const uint32 y, TypeContainerVisitor<T, TypeMapContainer<TT> > &visitor) + template<class SPECIFIC_OBJECT> void RemoveGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) { - getGridType(x, y).Visit(visitor); + GetGridType(x, y).RemoveGridObject(obj); } + */ - unsigned int ActiveObjectsInGrid(void) const + // Visit all Grids (cells) in NGrid (grid) + template<class T, class TT> + void VisitAllGrids(TypeContainerVisitor<T, TypeMapContainer<TT> > &visitor) { - unsigned int count=0; - for (unsigned int x=0; x < N; ++x) - for (unsigned int y=0; y < N; ++y) - count += i_cells[x][y].ActiveObjectsInGrid(); - return count; + for (uint32 x = 0; x < N; ++x) + for (uint32 y = 0; y < N; ++y) + GetGridType(x, y).Visit(visitor); } - template<class SPECIFIC_OBJECT> bool AddGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) + // Visit a single Grid (cell) in NGrid (grid) + template<class T, class TT> + void VisitGrid(const uint32 x, const uint32 y, TypeContainerVisitor<T, TypeMapContainer<TT> > &visitor) { - return getGridType(x, y).AddGridObject(obj); + GetGridType(x, y).Visit(visitor); } - template<class SPECIFIC_OBJECT> bool RemoveGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) + unsigned int ActiveObjectsInGrid(void) const { - return getGridType(x, y).RemoveGridObject(obj); + unsigned int count=0; + for (unsigned int x=0; x < N; ++x) + for (unsigned int y=0; y < N; ++y) + count += i_cells[x][y].ActiveObjectsInGrid(); + return count; } private: - - GridType& getGridType(const uint32 x, const uint32 y) - { - ASSERT(x < N); - ASSERT(y < N); - return i_cells[x][y]; - } - uint32 i_gridId; GridInfo i_GridInfo; GridReference<NGrid<N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> > i_Reference; diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp index dc938859e92..ca61a82e840 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp +++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp @@ -30,8 +30,7 @@ using namespace Trinity; -void -VisibleNotifier::SendToSelf() +void VisibleNotifier::SendToSelf() { // at this moment i_clientGUIDs have guids that not iterate at grid level checks // but exist one case when this possible and object not out of range: transports @@ -56,9 +55,9 @@ VisibleNotifier::SendToSelf() if (IS_PLAYER_GUID(*it)) { - Player* plr = ObjectAccessor::FindPlayer(*it); - if (plr && plr->IsInWorld() && !plr->isNeedNotify(NOTIFY_VISIBILITY_CHANGED)) - plr->UpdateVisibilityOf(&i_player); + Player* player = ObjectAccessor::FindPlayer(*it); + if (player && player->IsInWorld() && !player->isNeedNotify(NOTIFY_VISIBILITY_CHANGED)) + player->UpdateVisibilityOf(&i_player); } } @@ -73,10 +72,9 @@ VisibleNotifier::SendToSelf() i_player.SendInitialVisiblePackets(*it); } -void -VisibleChangesNotifier::Visit(PlayerMapType &m) +void VisibleChangesNotifier::Visit(PlayerMapType &m) { - for (PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) + for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { if (iter->getSource() == &i_object) continue; @@ -91,8 +89,7 @@ VisibleChangesNotifier::Visit(PlayerMapType &m) } } -void -VisibleChangesNotifier::Visit(CreatureMapType &m) +void VisibleChangesNotifier::Visit(CreatureMapType &m) { for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) if (!iter->getSource()->GetSharedVisionList().empty()) @@ -102,8 +99,7 @@ VisibleChangesNotifier::Visit(CreatureMapType &m) (*i)->UpdateVisibilityOf(&i_object); } -void -VisibleChangesNotifier::Visit(DynamicObjectMapType &m) +void VisibleChangesNotifier::Visit(DynamicObjectMapType &m) { for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter) if (IS_PLAYER_GUID(iter->getSource()->GetCasterGUID())) @@ -126,16 +122,16 @@ void PlayerRelocationNotifier::Visit(PlayerMapType &m) { for (PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) { - Player* plr = iter->getSource(); + Player* player = iter->getSource(); - vis_guids.erase(plr->GetGUID()); + vis_guids.erase(player->GetGUID()); - i_player.UpdateVisibilityOf(plr, i_data, i_visibleNow); + i_player.UpdateVisibilityOf(player, i_data, i_visibleNow); - if (plr->m_seer->isNeedNotify(NOTIFY_VISIBILITY_CHANGED)) + if (player->m_seer->isNeedNotify(NOTIFY_VISIBILITY_CHANGED)) continue; - plr->UpdateVisibilityOf(&i_player); + player->UpdateVisibilityOf(&i_player); } } @@ -160,12 +156,12 @@ void CreatureRelocationNotifier::Visit(PlayerMapType &m) { for (PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) { - Player* pl = iter->getSource(); + Player* player = iter->getSource(); - if (!pl->m_seer->isNeedNotify(NOTIFY_VISIBILITY_CHANGED)) - pl->UpdateVisibilityOf(&i_creature); + if (!player->m_seer->isNeedNotify(NOTIFY_VISIBILITY_CHANGED)) + player->UpdateVisibilityOf(&i_creature); - CreatureUnitRelocationWorker(&i_creature, pl); + CreatureUnitRelocationWorker(&i_creature, player); } } @@ -215,7 +211,7 @@ void DelayedUnitRelocation::Visit(PlayerMapType &m) if (player != viewPoint && !viewPoint->IsPositionValid()) continue; - CellPair pair2(Trinity::ComputeCellPair(viewPoint->GetPositionX(), viewPoint->GetPositionY())); + CellCoord pair2(Trinity::ComputeCellCoord(viewPoint->GetPositionX(), viewPoint->GetPositionY())); Cell cell2(pair2); //cell.SetNoCreate(); need load cells around viewPoint or player, that's why its commented @@ -241,8 +237,7 @@ void AIRelocationNotifier::Visit(CreatureMapType &m) } } -void -MessageDistDeliverer::Visit(PlayerMapType &m) +void MessageDistDeliverer::Visit(PlayerMapType &m) { for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { @@ -312,17 +307,17 @@ void MessageDistDeliverer::Visit(DynamicObjectMapType &m) /* void -MessageDistDeliverer::VisitObject(Player* plr) +MessageDistDeliverer::VisitObject(Player* player) { - if (!i_ownTeamOnly || (i_source.GetTypeId() == TYPEID_PLAYER && plr->GetTeam() == ((Player&)i_source).GetTeam())) + if (!i_ownTeamOnly || (i_source.GetTypeId() == TYPEID_PLAYER && player->GetTeam() == ((Player&)i_source).GetTeam())) { - SendPacket(plr); + SendPacket(player); } } */ -template<class T> void -ObjectUpdater::Visit(GridRefManager<T> &m) +template<class T> +void ObjectUpdater::Visit(GridRefManager<T> &m) { for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter) { diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index a5bce96f653..239c3710b5b 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -61,7 +61,7 @@ namespace Trinity struct PlayerRelocationNotifier : public VisibleNotifier { - PlayerRelocationNotifier(Player &pl) : VisibleNotifier(pl) {} + PlayerRelocationNotifier(Player &player) : VisibleNotifier(player) {} template<class T> void Visit(GridRefManager<T> &m) { VisibleNotifier::Visit(m); } void Visit(CreatureMapType &); @@ -81,9 +81,9 @@ namespace Trinity { Map &i_map; Cell &cell; - CellPair &p; + CellCoord &p; const float i_radius; - DelayedUnitRelocation(Cell &c, CellPair &pair, Map &map, float radius) : + DelayedUnitRelocation(Cell &c, CellCoord &pair, Map &map, float radius) : i_map(map), cell(c), p(pair), i_radius(radius) {} template<class T> void Visit(GridRefManager<T> &) {} void Visit(CreatureMapType &); @@ -137,16 +137,16 @@ namespace Trinity void Visit(DynamicObjectMapType &m); template<class SKIP> void Visit(GridRefManager<SKIP> &) {} - void SendPacket(Player* plr) + void SendPacket(Player* player) { // never send packet to self - if (plr == i_source || (team && plr->GetTeam() != team) || skipped_receiver == plr) + if (player == i_source || (team && player->GetTeam() != team) || skipped_receiver == player) return; - if (!plr->HaveAtClient(i_source)) + if (!player->HaveAtClient(i_source)) return; - if (WorldSession* session = plr->GetSession()) + if (WorldSession* session = player->GetSession()) session->SendPacket(i_message); } }; @@ -808,6 +808,9 @@ namespace Trinity if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->isTotem()) return false; + if(!u->isTargetableForAttack(false)) + return false; + return i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u); } private: diff --git a/src/server/game/Grids/Notifiers/GridNotifiersImpl.h b/src/server/game/Grids/Notifiers/GridNotifiersImpl.h index dcd4207e3e1..543a1d1e280 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiersImpl.h +++ b/src/server/game/Grids/Notifiers/GridNotifiersImpl.h @@ -28,8 +28,7 @@ #include "SpellAuras.h" template<class T> -inline void -Trinity::VisibleNotifier::Visit(GridRefManager<T> &m) +inline void Trinity::VisibleNotifier::Visit(GridRefManager<T> &m) { for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter) { @@ -38,8 +37,7 @@ Trinity::VisibleNotifier::Visit(GridRefManager<T> &m) } } -inline void -Trinity::ObjectUpdater::Visit(CreatureMapType &m) +inline void Trinity::ObjectUpdater::Visit(CreatureMapType &m) { for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) if (iter->getSource()->IsInWorld()) diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp index 58521b76bff..56c6410e6d7 100755 --- a/src/server/game/Grids/ObjectGridLoader.cpp +++ b/src/server/game/Grids/ObjectGridLoader.cpp @@ -28,26 +28,7 @@ #include "CellImpl.h" #include "CreatureAI.h" -class ObjectGridRespawnMover -{ - public: - ObjectGridRespawnMover() {} - - void Move(GridType &grid); - - template<class T> void Visit(GridRefManager<T> &) {} - void Visit(CreatureMapType &m); -}; - -void -ObjectGridRespawnMover::Move(GridType &grid) -{ - TypeContainerVisitor<ObjectGridRespawnMover, GridTypeMapContainer > mover(*this); - grid.Visit(mover); -} - -void -ObjectGridRespawnMover::Visit(CreatureMapType &m) +void ObjectGridEvacuator::Visit(CreatureMapType &m) { // creature in unloading grid can have respawn point in another grid // if it will be unloaded then it will not respawn in original grid until unload/load original grid @@ -57,20 +38,8 @@ ObjectGridRespawnMover::Visit(CreatureMapType &m) Creature* c = iter->getSource(); ++iter; - ASSERT(!c->isPet() && "ObjectGridRespawnMover don't must be called for pets"); - - Cell const& cur_cell = c->GetCurrentCell(); - - float resp_x, resp_y, resp_z; - c->GetRespawnCoord(resp_x, resp_y, resp_z); - CellPair resp_val = Trinity::ComputeCellPair(resp_x, resp_y); - Cell resp_cell(resp_val); - - if (cur_cell.DiffGrid(resp_cell)) - { - c->GetMap()->CreatureRespawnRelocation(c); - // false result ignored: will be unload with other creatures at grid - } + ASSERT(!c->isPet() && "ObjectGridRespawnMover must not be called for pets"); + c->GetMap()->CreatureRespawnRelocation(c, true); } } @@ -94,22 +63,22 @@ class ObjectWorldLoader uint32 i_corpses; }; -template<class T> void AddUnitState(T* /*obj*/, CellPair const& /*cell_pair*/) +template<class T> void ObjectGridLoader::SetObjectCell(T* /*obj*/, CellCoord const& /*cellCoord*/) { } -template<> void AddUnitState(Creature* obj, CellPair const& cell_pair) +template<> void ObjectGridLoader::SetObjectCell(Creature* obj, CellCoord const& cellCoord) { - Cell cell(cell_pair); + Cell cell(cellCoord); obj->SetCurrentCell(cell); } template <class T> -void AddObjectHelper(CellPair &cell, GridRefManager<T> &m, uint32 &count, Map* map, T *obj) +void AddObjectHelper(CellCoord &cell, GridRefManager<T> &m, uint32 &count, Map* map, T *obj) { - obj->GetGridRef().link(&m, obj); - AddUnitState(obj, cell); + obj->AddToGrid(m); + ObjectGridLoader::SetObjectCell(obj, cell); obj->AddToWorld(); if (obj->isActiveObject()) map->AddToActive(obj); @@ -118,7 +87,7 @@ void AddObjectHelper(CellPair &cell, GridRefManager<T> &m, uint32 &count, Map* m } template <class T> -void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager<T> &m, uint32 &count, Map* map) +void LoadHelper(CellGuidSet const& guid_set, CellCoord &cell, GridRefManager<T> &m, uint32 &count, Map* map) { for (CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid) { @@ -135,7 +104,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager<T> & } } -void LoadHelper(CellCorpseSet const& cell_corpses, CellPair &cell, CorpseMapType &m, uint32 &count, Map* map) +void LoadHelper(CellCorpseSet const& cell_corpses, CellCoord &cell, CorpseMapType &m, uint32 &count, Map* map) { if (cell_corpses.empty()) return; @@ -157,21 +126,26 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellPair &cell, CorpseMapType // in that case map == currMap obj->SetMap(map); + if (obj->IsInGrid()) + { + obj->AddToWorld(); + continue; + } + AddObjectHelper(cell, m, count, map, obj); } } -void -ObjectGridLoader::Visit(GameObjectMapType &m) +void ObjectGridLoader::Visit(GameObjectMapType &m) { uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY(); - CellPair cell_pair(x, y); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + CellCoord cellCoord(x, y); + uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord; CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cell_id); - LoadHelper(cell_guids.gameobjects, cell_pair, m, i_gameObjects, i_map); + LoadHelper(cell_guids.gameobjects, cellCoord, m, i_gameObjects, i_map); } void @@ -179,41 +153,24 @@ ObjectGridLoader::Visit(CreatureMapType &m) { uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY(); - CellPair cell_pair(x, y); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + CellCoord cellCoord(x, y); + uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord; CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cell_id); - LoadHelper(cell_guids.creatures, cell_pair, m, i_creatures, i_map); + LoadHelper(cell_guids.creatures, cellCoord, m, i_creatures, i_map); } -void -ObjectWorldLoader::Visit(CorpseMapType &m) +void ObjectWorldLoader::Visit(CorpseMapType &m) { uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY(); - CellPair cell_pair(x, y); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + CellCoord cellCoord(x, y); + uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord; // corpses are always added to spawn mode 0 and they are spawned by their instance id CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), 0, cell_id); - LoadHelper(cell_guids.corpses, cell_pair, m, i_corpses, i_map); -} - -void -ObjectGridLoader::Load(GridType &grid) -{ - { - TypeContainerVisitor<ObjectGridLoader, GridTypeMapContainer > loader(*this); - grid.Visit(loader); - } - - { - ObjectWorldLoader wloader(*this); - TypeContainerVisitor<ObjectWorldLoader, WorldTypeMapContainer > loader(wloader); - grid.Visit(loader); - i_corpses = wloader.i_corpses; - } + LoadHelper(cell_guids.corpses, cellCoord, m, i_corpses, i_map); } void ObjectGridLoader::LoadN(void) @@ -226,35 +183,27 @@ void ObjectGridLoader::LoadN(void) for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) { i_cell.data.Part.cell_y = y; - GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader; - loader.Load(i_grid(x, y), *this); - } - } - sLog->outDebug(LOG_FILTER_MAPS, "%u GameObjects, %u Creatures, and %u Corpses/Bones loaded for grid %u on map %u", i_gameObjects, i_creatures, i_corpses, i_grid.GetGridId(), i_map->GetId()); -} -void ObjectGridUnloader::MoveToRespawnN() -{ - for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) - { - for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) - { - ObjectGridRespawnMover mover; - mover.Move(i_grid(x, y)); + //Load creatures and game objects + { + TypeContainerVisitor<ObjectGridLoader, GridTypeMapContainer> visitor(*this); + i_grid.VisitGrid(x, y, visitor); + } + + //Load corpses (not bones) + { + ObjectWorldLoader worker(*this); + TypeContainerVisitor<ObjectWorldLoader, WorldTypeMapContainer> visitor(worker); + i_grid.VisitGrid(x, y, visitor); + i_corpses += worker.i_corpses; + } } } -} - -void -ObjectGridUnloader::Unload(GridType &grid) -{ - TypeContainerVisitor<ObjectGridUnloader, GridTypeMapContainer > unloader(*this); - grid.Visit(unloader); + sLog->outDebug(LOG_FILTER_MAPS, "%u GameObjects, %u Creatures, and %u Corpses/Bones loaded for grid %u on map %u", i_gameObjects, i_creatures, i_corpses, i_grid.GetGridId(), i_map->GetId()); } template<class T> -void -ObjectGridUnloader::Visit(GridRefManager<T> &m) +void ObjectGridUnloader::Visit(GridRefManager<T> &m) { while (!m.isEmpty()) { @@ -262,20 +211,17 @@ ObjectGridUnloader::Visit(GridRefManager<T> &m) // if option set then object already saved at this moment if (!sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY)) obj->SaveRespawnTime(); + //Some creatures may summon other temp summons in CleanupsBeforeDelete() + //So we need this even after cleaner (maybe we can remove cleaner) + //Example: Flame Leviathan Turret 33139 is summoned when a creature is deleted + //TODO: Check if that script has the correct logic. Do we really need to summons something before deleting? + obj->CleanupsBeforeDelete(); ///- object will get delinked from the manager when deleted delete obj; } } -void -ObjectGridStoper::Stop(GridType &grid) -{ - TypeContainerVisitor<ObjectGridStoper, GridTypeMapContainer > stoper(*this); - grid.Visit(stoper); -} - -void -ObjectGridStoper::Visit(CreatureMapType &m) +void ObjectGridStoper::Visit(CreatureMapType &m) { // stop any fights at grid de-activation and remove dynobjects created at cast by creatures for (CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter) @@ -290,32 +236,18 @@ ObjectGridStoper::Visit(CreatureMapType &m) } } -void -ObjectGridCleaner::Stop(GridType &grid) -{ - TypeContainerVisitor<ObjectGridCleaner, GridTypeMapContainer > stoper(*this); - grid.Visit(stoper); -} - -void -ObjectGridCleaner::Visit(CreatureMapType &m) -{ - for (CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter) - iter->getSource()->CleanupsBeforeDelete(); -} - template<class T> -void -ObjectGridCleaner::Visit(GridRefManager<T> &m) +void ObjectGridCleaner::Visit(GridRefManager<T> &m) { for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter) - iter->getSource()->RemoveFromWorld(); + iter->getSource()->CleanupsBeforeDelete(); } template void ObjectGridUnloader::Visit(CreatureMapType &); template void ObjectGridUnloader::Visit(GameObjectMapType &); template void ObjectGridUnloader::Visit(DynamicObjectMapType &); template void ObjectGridUnloader::Visit(CorpseMapType &); +template void ObjectGridCleaner::Visit(CreatureMapType &); template void ObjectGridCleaner::Visit<GameObject>(GameObjectMapType &); template void ObjectGridCleaner::Visit<DynamicObject>(DynamicObjectMapType &); template void ObjectGridCleaner::Visit<Corpse>(CorpseMapType &); diff --git a/src/server/game/Grids/ObjectGridLoader.h b/src/server/game/Grids/ObjectGridLoader.h index 901080293a4..09a8fb2af9c 100755 --- a/src/server/game/Grids/ObjectGridLoader.h +++ b/src/server/game/Grids/ObjectGridLoader.h @@ -36,15 +36,15 @@ class ObjectGridLoader : i_cell(cell), i_grid(grid), i_map(map), i_gameObjects(0), i_creatures(0), i_corpses (0) {} - void Load(GridType &grid); void Visit(GameObjectMapType &m); void Visit(CreatureMapType &m); void Visit(CorpseMapType &) const {} - void Visit(DynamicObjectMapType&) const {} void LoadN(void); + template<class T> static void SetObjectCell(T* obj, CellCoord const& cellCoord); + private: Cell i_cell; NGridType &i_grid; @@ -54,79 +54,33 @@ class ObjectGridLoader uint32 i_corpses; }; -class ObjectGridUnloader +//Stop the creatures before unloading the NGrid +class ObjectGridStoper { public: - ObjectGridUnloader(NGridType &grid) : i_grid(grid) {} - - void MoveToRespawnN(); - void UnloadN() - { - for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) - { - for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) - { - GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader; - loader.Unload(i_grid(x, y), *this); - } - } - } - - void Unload(GridType &grid); - template<class T> void Visit(GridRefManager<T> &m); - private: - NGridType &i_grid; + void Visit(CreatureMapType &m); + template<class T> void Visit(GridRefManager<T> &) {} }; -class ObjectGridStoper +//Move the foreign creatures back to respawn positions before unloading the NGrid +class ObjectGridEvacuator { public: - ObjectGridStoper(NGridType &grid) : i_grid(grid) {} - - void StopN() - { - for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) - { - for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) - { - GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader; - loader.Stop(i_grid(x, y), *this); - } - } - } - - void Stop(GridType &grid); void Visit(CreatureMapType &m); - - template<class NONACTIVE> void Visit(GridRefManager<NONACTIVE> &) {} - private: - NGridType &i_grid; + template<class T> void Visit(GridRefManager<T> &) {} }; +//Clean up and remove from world class ObjectGridCleaner { public: - ObjectGridCleaner(NGridType &grid) : i_grid(grid) {} - - void CleanN() - { - for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) - { - for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) - { - GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader; - loader.Stop(i_grid(x, y), *this); - } - } - } - - void Stop(GridType &grid); - void Visit(CreatureMapType &m); template<class T> void Visit(GridRefManager<T> &); - private: - NGridType &i_grid; }; -typedef GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> GridLoaderType; +//Delete objects before deleting NGrid +class ObjectGridUnloader +{ + public: + template<class T> void Visit(GridRefManager<T> &m); +}; #endif - diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 44d7f62305f..6311066f597 100755 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -1052,8 +1052,8 @@ void Group::CountTheRoll(Rolls::iterator rollI, uint32 NumberOfPlayers) item->is_looted = true; roll->getLoot()->NotifyItemRemoved(roll->itemSlot); roll->getLoot()->unlootedCount--; - AllowedLooterSet* looters = item->GetAllowedLooters(); - player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, (looters->size() > 1) ? looters : NULL); + AllowedLooterSet looters = item->GetAllowedLooters(); + player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters); } else { @@ -1105,8 +1105,8 @@ void Group::CountTheRoll(Rolls::iterator rollI, uint32 NumberOfPlayers) item->is_looted = true; roll->getLoot()->NotifyItemRemoved(roll->itemSlot); roll->getLoot()->unlootedCount--; - AllowedLooterSet* looters = item->GetAllowedLooters(); - player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, (looters->size() > 1) ? looters : NULL); + AllowedLooterSet looters = item->GetAllowedLooters(); + player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters); } else { @@ -1261,11 +1261,12 @@ void Group::UpdatePlayerOutOfRange(Player* player) WorldPacket data; player->GetSession()->BuildPartyMemberStatsChangedPacket(player, &data); + Player* member; for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) { - player = itr->getSource(); - if (player && !player->IsWithinDist(player, player->GetSightRange(), false)) - player->GetSession()->SendPacket(&data); + member = itr->getSource(); + if (member && !member->IsWithinDist(player, member->GetSightRange(), false)) + member->GetSession()->SendPacket(&data); } } @@ -1273,12 +1274,12 @@ void Group::BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int { for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* pl = itr->getSource(); - if (!pl || (ignore != 0 && pl->GetGUID() == ignore) || (ignorePlayersInBGRaid && pl->GetGroup() != this)) + Player* player = itr->getSource(); + if (!player || (ignore != 0 && player->GetGUID() == ignore) || (ignorePlayersInBGRaid && player->GetGroup() != this)) continue; - if (pl->GetSession() && (group == -1 || itr->getSubGroup() == group)) - pl->GetSession()->SendPacket(packet); + if (player->GetSession() && (group == -1 || itr->getSubGroup() == group)) + player->GetSession()->SendPacket(packet); } } @@ -1286,10 +1287,10 @@ void Group::BroadcastReadyCheck(WorldPacket* packet) { for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* pl = itr->getSource(); - if (pl && pl->GetSession()) - if (IsLeader(pl->GetGUID()) || IsAssistant(pl->GetGUID())) - pl->GetSession()->SendPacket(packet); + Player* player = itr->getSource(); + if (player && player->GetSession()) + if (IsLeader(player->GetGUID()) || IsAssistant(player->GetGUID())) + player->GetSession()->SendPacket(packet); } } @@ -1297,8 +1298,8 @@ void Group::OfflineReadyCheck() { for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr) { - Player* pl = ObjectAccessor::FindPlayer(citr->guid); - if (!pl || !pl->GetSession()) + Player* player = ObjectAccessor::FindPlayer(citr->guid); + if (!player || !player->GetSession()) { WorldPacket data(MSG_RAID_READY_CHECK_CONFIRM, 9); data << uint64(citr->guid); @@ -1328,6 +1329,7 @@ bool Group::SameSubGroup(Player const* member1, Player const* member2) const { if (!member1 || !member2) return false; + if (member1->GetGroup() != this || member2->GetGroup() != this) return false; else @@ -1364,10 +1366,8 @@ void Group::ChangeMembersGroup(uint64 guid, uint8 group) if (!isBGGroup()) CharacterDatabase.PExecute("UPDATE group_member SET subgroup='%u' WHERE memberGuid='%u'", group, GUID_LOPART(guid)); - Player* player = ObjectAccessor::FindPlayer(guid); - // In case the moved player is online, update the player object with the new sub group references - if (player) + if (Player* player = ObjectAccessor::FindPlayer(guid)) { if (player->GetGroup() == this) player->GetGroupRef().setSubGroup(group); @@ -1425,10 +1425,10 @@ void Group::UpdateLooterGuid(WorldObject* pLootedObject, bool ifneed) Player* pNewLooter = NULL; for (member_citerator itr = guid_itr; itr != m_memberSlots.end(); ++itr) { - if (Player* pl = ObjectAccessor::FindPlayer(itr->guid)) - if (pl->IsWithinDistInMap(pLootedObject, sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE), false)) + if (Player* player = ObjectAccessor::FindPlayer(itr->guid)) + if (player->IsWithinDistInMap(pLootedObject, sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE), false)) { - pNewLooter = pl; + pNewLooter = player; break; } } @@ -1438,10 +1438,10 @@ void Group::UpdateLooterGuid(WorldObject* pLootedObject, bool ifneed) // search from start for (member_citerator itr = m_memberSlots.begin(); itr != guid_itr; ++itr) { - if (Player* pl = ObjectAccessor::FindPlayer(itr->guid)) - if (pl->IsWithinDistInMap(pLootedObject, sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE), false)) + if (Player* player = ObjectAccessor::FindPlayer(itr->guid)) + if (player->IsWithinDistInMap(pLootedObject, sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE), false)) { - pNewLooter = pl; + pNewLooter = player; break; } } @@ -2065,4 +2065,5 @@ void Group::ToggleGroupMemberFlag(member_witerator slot, uint8 flag, bool apply) slot->flags |= flag; else slot->flags &= ~flag; -}
\ No newline at end of file +} + diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index ed1fc80fd20..c51aa6dd7bf 100755 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -57,14 +57,14 @@ enum RollVote enum GroupMemberOnlineStatus { MEMBER_STATUS_OFFLINE = 0x0000, - MEMBER_STATUS_ONLINE = 0x0001, - MEMBER_STATUS_PVP = 0x0002, - MEMBER_STATUS_UNK0 = 0x0004, // dead? (health=0) - MEMBER_STATUS_UNK1 = 0x0008, // ghost? (health=1) - MEMBER_STATUS_UNK2 = 0x0010, // never seen - MEMBER_STATUS_UNK3 = 0x0020, // never seen - MEMBER_STATUS_UNK4 = 0x0040, // appears with dead and ghost flags - MEMBER_STATUS_UNK5 = 0x0080, // never seen + MEMBER_STATUS_ONLINE = 0x0001, // Lua_UnitIsConnected + MEMBER_STATUS_PVP = 0x0002, // Lua_UnitIsPVP + MEMBER_STATUS_DEAD = 0x0004, // Lua_UnitIsDead + MEMBER_STATUS_GHOST = 0x0008, // Lua_UnitIsGhost + MEMBER_STATUS_PVP_FFA = 0x0010, // Lua_UnitIsPVPFreeForAll + MEMBER_STATUS_UNK3 = 0x0020, // used in calls from Lua_GetPlayerMapPosition/Lua_GetBattlefieldFlagPosition + MEMBER_STATUS_AFK = 0x0040, // Lua_UnitIsAFK + MEMBER_STATUS_DND = 0x0080, // Lua_UnitIsDND }; enum GroupMemberFlags diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 0103b164f64..59c107bd40f 100755 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -762,7 +762,7 @@ bool Guild::MoveItemData::CheckItem(uint32& splitedAmount) bool Guild::MoveItemData::CanStore(Item* pItem, bool swap, bool sendError) { m_vec.clear(); - InventoryResult msg = _CanStore(pItem, swap); + InventoryResult msg = CanStore(pItem, swap); if (sendError && msg != EQUIP_ERR_OK) m_pPlayer->SendEquipError(msg, pItem); return (msg == EQUIP_ERR_OK); @@ -850,7 +850,7 @@ void Guild::PlayerMoveItemData::LogBankEvent(SQLTransaction& trans, MoveItemData pFrom->GetItem()->GetEntry(), count); } -inline InventoryResult Guild::PlayerMoveItemData::_CanStore(Item* pItem, bool swap) +inline InventoryResult Guild::PlayerMoveItemData::CanStore(Item* pItem, bool swap) { return m_pPlayer->CanStoreItem(m_container, m_slotId, m_vec, pItem, swap); } @@ -1002,11 +1002,11 @@ bool Guild::BankMoveItemData::_ReserveSpace(uint8 slotId, Item* pItem, Item* pIt return true; } -void Guild::BankMoveItemData::_CanStoreItemInTab(Item* pItem, uint8 skipSlotId, bool merge, uint32& count) +void Guild::BankMoveItemData::CanStoreItemInTab(Item* pItem, uint8 skipSlotId, bool merge, uint32& count) { for (uint8 slotId = 0; (slotId < GUILD_BANK_MAX_SLOTS) && (count > 0); ++slotId) { - // Skip slot already processed in _CanStore (when destination slot was specified) + // Skip slot already processed in CanStore (when destination slot was specified) if (slotId == skipSlotId) continue; @@ -1022,7 +1022,7 @@ void Guild::BankMoveItemData::_CanStoreItemInTab(Item* pItem, uint8 skipSlotId, } } -InventoryResult Guild::BankMoveItemData::_CanStore(Item* pItem, bool swap) +InventoryResult Guild::BankMoveItemData::CanStore(Item* pItem, bool swap) { sLog->outDebug(LOG_FILTER_GUILD, "GUILD STORAGE: CanStore() tab = %u, slot = %u, item = %u, count = %u", m_container, m_slotId, pItem->GetEntry(), pItem->GetCount()); @@ -1055,13 +1055,13 @@ InventoryResult Guild::BankMoveItemData::_CanStore(Item* pItem, bool swap) // Search for stacks to merge with if (pItem->GetMaxStackCount() > 1) { - _CanStoreItemInTab(pItem, m_slotId, true, count); + CanStoreItemInTab(pItem, m_slotId, true, count); if (count == 0) return EQUIP_ERR_OK; } // Search free slot for item - _CanStoreItemInTab(pItem, m_slotId, false, count); + CanStoreItemInTab(pItem, m_slotId, false, count); if (count == 0) return EQUIP_ERR_OK; diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index 2ea345f2ca1..3ac2b0a490d 100755 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -524,7 +524,7 @@ private: uint8 GetContainer() const { return m_container; } uint8 GetSlotId() const { return m_slotId; } protected: - virtual InventoryResult _CanStore(Item* pItem, bool swap) = 0; + virtual InventoryResult CanStore(Item* pItem, bool swap) = 0; Guild* m_pGuild; Player* m_pPlayer; @@ -547,7 +547,7 @@ private: Item* StoreItem(SQLTransaction& trans, Item* pItem); void LogBankEvent(SQLTransaction& trans, MoveItemData* pFrom, uint32 count) const; protected: - InventoryResult _CanStore(Item* pItem, bool swap); + InventoryResult CanStore(Item* pItem, bool swap); }; class BankMoveItemData : public MoveItemData @@ -566,12 +566,12 @@ private: void LogAction(MoveItemData* pFrom) const; protected: - InventoryResult _CanStore(Item* pItem, bool swap); + InventoryResult CanStore(Item* pItem, bool swap); private: Item* _StoreItem(SQLTransaction& trans, BankTab* pTab, Item* pItem, ItemPosCount& pos, bool clone) const; bool _ReserveSpace(uint8 slotId, Item* pItem, Item* pItemDest, uint32& count); - void _CanStoreItemInTab(Item* pItem, uint8 skipSlotId, bool merge, uint32& count); + void CanStoreItemInTab(Item* pItem, uint8 skipSlotId, bool merge, uint32& count); }; typedef UNORDERED_MAP<uint32, Member*> Members; diff --git a/src/server/game/Instances/InstanceSaveMgr.h b/src/server/game/Instances/InstanceSaveMgr.h index 63d54e4ec94..b4e97f40f87 100755 --- a/src/server/game/Instances/InstanceSaveMgr.h +++ b/src/server/game/Instances/InstanceSaveMgr.h @@ -80,8 +80,8 @@ class InstanceSave /* online players bound to the instance (perm/solo) does not include the members of the group unless they have permanent saves */ - void AddPlayer(Player* player) { m_playerList.push_back(player); } - bool RemovePlayer(Player* player) { m_playerList.remove(player); return UnloadIfEmpty(); } + void AddPlayer(Player* player) { TRINITY_GUARD(ACE_Thread_Mutex, _lock); m_playerList.push_back(player); } + bool RemovePlayer(Player* player) { TRINITY_GUARD(ACE_Thread_Mutex, _lock); m_playerList.remove(player); return UnloadIfEmpty(); } /* all groups bound to the instance */ void AddGroup(Group* group) { m_groupList.push_back(group); } bool RemoveGroup(Group* group) { m_groupList.remove(group); return UnloadIfEmpty(); } @@ -110,6 +110,8 @@ class InstanceSave uint32 m_mapid; Difficulty m_difficulty; bool m_canReset; + + ACE_Thread_Mutex _lock; }; typedef UNORDERED_MAP<uint32 /*PAIR32(map, difficulty)*/, time_t /*resetTime*/> ResetTimeByMapDifficultyMap; diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index b9b9ed281fa..f0e21f7f709 100755 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -141,34 +141,36 @@ void InstanceScript::AddDoor(GameObject* door, bool add) for (DoorInfoMap::iterator itr = lower; itr != upper; ++itr) { + DoorInfo const& data = itr->second; + if (add) { - itr->second.bossInfo->door[itr->second.type].insert(door); - switch (itr->second.boundary) + data.bossInfo->door[data.type].insert(door); + switch (data.boundary) { default: case BOUNDARY_NONE: break; case BOUNDARY_N: case BOUNDARY_S: - itr->second.bossInfo->boundary[itr->second.boundary] = door->GetPositionX(); + data.bossInfo->boundary[data.boundary] = door->GetPositionX(); break; case BOUNDARY_E: case BOUNDARY_W: - itr->second.bossInfo->boundary[itr->second.boundary] = door->GetPositionY(); + data.bossInfo->boundary[data.boundary] = door->GetPositionY(); break; case BOUNDARY_NW: case BOUNDARY_SE: - itr->second.bossInfo->boundary[itr->second.boundary] = door->GetPositionX() + door->GetPositionY(); + data.bossInfo->boundary[data.boundary] = door->GetPositionX() + door->GetPositionY(); break; case BOUNDARY_NE: case BOUNDARY_SW: - itr->second.bossInfo->boundary[itr->second.boundary] = door->GetPositionX() - door->GetPositionY(); + data.bossInfo->boundary[data.boundary] = door->GetPositionX() - door->GetPositionY(); break; } } else - itr->second.bossInfo->door[itr->second.type].erase(door); + data.bossInfo->door[data.type].erase(door); } if (add) diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index eff811b14eb..dd17e8277d6 100755 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -436,8 +436,8 @@ bool Loot::FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bo roundRobinPlayer = lootOwner->GetGUID(); for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) - if (Player* pl = itr->getSource()) // should actually be looted object instead of lootOwner but looter has to be really close so doesnt really matter - FillNotNormalLootFor(pl, pl->IsAtGroupRewardDistance(lootOwner)); + if (Player* player = itr->getSource()) // should actually be looted object instead of lootOwner but looter has to be really close so doesnt really matter + FillNotNormalLootFor(player, player->IsAtGroupRewardDistance(lootOwner)); for (uint8 i = 0; i < items.size(); ++i) { @@ -453,28 +453,28 @@ bool Loot::FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bo return true; } -void Loot::FillNotNormalLootFor(Player* pl, bool presentAtLooting) +void Loot::FillNotNormalLootFor(Player* player, bool presentAtLooting) { - uint32 plguid = pl->GetGUIDLow(); + uint32 plguid = player->GetGUIDLow(); QuestItemMap::const_iterator qmapitr = PlayerQuestItems.find(plguid); if (qmapitr == PlayerQuestItems.end()) - FillQuestLoot(pl); + FillQuestLoot(player); qmapitr = PlayerFFAItems.find(plguid); if (qmapitr == PlayerFFAItems.end()) - FillFFALoot(pl); + FillFFALoot(player); qmapitr = PlayerNonQuestNonFFAConditionalItems.find(plguid); if (qmapitr == PlayerNonQuestNonFFAConditionalItems.end()) - FillNonQuestNonFFAConditionalLoot(pl, presentAtLooting); + FillNonQuestNonFFAConditionalLoot(player, presentAtLooting); // if not auto-processed player will have to come and pick it up manually if (!presentAtLooting) return; // Process currency items - uint32 max_slot = GetMaxSlotInLootFor(pl); + uint32 max_slot = GetMaxSlotInLootFor(player); LootItem const* item = NULL; uint32 itemsSize = uint32(items.size()); for (uint32 i = 0; i < max_slot; ++i) @@ -484,10 +484,10 @@ void Loot::FillNotNormalLootFor(Player* pl, bool presentAtLooting) else item = &quest_items[i-itemsSize]; - if (!item->is_looted && item->freeforall && item->AllowedForPlayer(pl)) + if (!item->is_looted && item->freeforall && item->AllowedForPlayer(player)) if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item->itemid)) if (proto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS) - pl->StoreLootItem(i, this); + player->StoreLootItem(i, this); } } @@ -592,8 +592,8 @@ void Loot::NotifyItemRemoved(uint8 lootIndex) { i_next = i; ++i_next; - if (Player* pl = ObjectAccessor::FindPlayer(*i)) - pl->SendNotifyLootItemRemoved(lootIndex); + if (Player* player = ObjectAccessor::FindPlayer(*i)) + player->SendNotifyLootItemRemoved(lootIndex); else PlayersLooting.erase(i); } @@ -607,8 +607,8 @@ void Loot::NotifyMoneyRemoved() { i_next = i; ++i_next; - if (Player* pl = ObjectAccessor::FindPlayer(*i)) - pl->SendNotifyLootMoneyRemoved(); + if (Player* player = ObjectAccessor::FindPlayer(*i)) + player->SendNotifyLootMoneyRemoved(); else PlayersLooting.erase(i); } @@ -626,9 +626,9 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex) { i_next = i; ++i_next; - if (Player* pl = ObjectAccessor::FindPlayer(*i)) + if (Player* player = ObjectAccessor::FindPlayer(*i)) { - QuestItemMap::const_iterator pq = PlayerQuestItems.find(pl->GetGUIDLow()); + QuestItemMap::const_iterator pq = PlayerQuestItems.find(player->GetGUIDLow()); if (pq != PlayerQuestItems.end() && pq->second) { // find where/if the player has the given item in it's vector @@ -640,7 +640,7 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex) break; if (j < pql.size()) - pl->SendNotifyLootItemRemoved(items.size()+j); + player->SendNotifyLootItemRemoved(items.size()+j); } } else diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h index b0adeb03784..10ae786a7d6 100755 --- a/src/server/game/Loot/LootMgr.h +++ b/src/server/game/Loot/LootMgr.h @@ -149,7 +149,7 @@ struct LootItem bool AllowedForPlayer(Player const* player) const; void AddAllowedLooter(Player const* player); - AllowedLooterSet* GetAllowedLooters() { return &allowedGUIDs; } + const AllowedLooterSet & GetAllowedLooters() const { return allowedGUIDs; } }; struct QuestItem diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 26e058a32f3..9c395a2319c 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -141,9 +141,9 @@ void Map::LoadMap(int gx, int gy, bool reload) // load grid map for base map if (!m_parentMap->GridMaps[gx][gy]) - m_parentMap->EnsureGridCreated(GridPair(63-gx, 63-gy)); + m_parentMap->EnsureGridCreated(GridCoord(63-gx, 63-gy)); - ((MapInstanced*)(m_parentMap))->AddGridMapReference(GridPair(gx, gy)); + ((MapInstanced*)(m_parentMap))->AddGridMapReference(GridCoord(gx, gy)); GridMaps[gx][gy] = m_parentMap->GridMaps[gx][gy]; return; } @@ -202,10 +202,11 @@ void Map::DeleteStateMachine() } Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _parent): -i_mapEntry (sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(InstanceId), +_creatureToMoveLock(false), i_mapEntry (sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(InstanceId), m_unloadTimer(0), m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE), m_VisibilityNotifyPeriod(DEFAULT_VISIBILITY_NOTIFY_PERIOD), -m_activeNonPlayersIter(m_activeNonPlayers.end()), i_gridExpiry(expiry), i_scriptLock(false) +m_activeNonPlayersIter(m_activeNonPlayers.end()), i_gridExpiry(expiry), +i_scriptLock(false) { m_parentMap = (_parent ? _parent : this); for (unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx) @@ -233,74 +234,52 @@ void Map::InitVisibilityDistance() // Template specialization of utility methods template<class T> -void Map::AddToGrid(T* obj, NGridType *grid, Cell const& cell) +void Map::AddToGrid(T* obj, Cell const& cell) { + NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); if (obj->m_isWorldObject) - (*grid)(cell.CellX(), cell.CellY()).template AddWorldObject<T>(obj); + grid->GetGridType(cell.CellX(), cell.CellY()).template AddWorldObject<T>(obj); else - (*grid)(cell.CellX(), cell.CellY()).template AddGridObject<T>(obj); + grid->GetGridType(cell.CellX(), cell.CellY()).template AddGridObject<T>(obj); } template<> -void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell) +void Map::AddToGrid(Creature* obj, Cell const& cell) { + NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); if (obj->m_isWorldObject) - (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj); + grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj); else - (*grid)(cell.CellX(), cell.CellY()).AddGridObject(obj); + grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj); obj->SetCurrentCell(cell); } template<class T> -void Map::RemoveFromGrid(T* obj, NGridType *grid, Cell const& cell) -{ - if (obj->m_isWorldObject) - (*grid)(cell.CellX(), cell.CellY()).template RemoveWorldObject<T>(obj); - else - (*grid)(cell.CellX(), cell.CellY()).template RemoveGridObject<T>(obj); -} - -template<class T> void Map::SwitchGridContainers(T* obj, bool on) { - CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) + CellCoord p = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); + if (!p.IsCoordValid()) { sLog->outError("Map::SwitchGridContainers: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); return; } Cell cell(p); - if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) + if (!IsGridLoaded(GridCoord(cell.data.Part.grid_x, cell.data.Part.grid_y))) return; sLog->outStaticDebug("Switch object " UI64FMTD " from grid[%u, %u] %u", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y, on); NGridType *ngrid = getNGrid(cell.GridX(), cell.GridY()); ASSERT(ngrid != NULL); - GridType &grid = (*ngrid)(cell.CellX(), cell.CellY()); + GridType &grid = ngrid->GetGridType(cell.CellX(), cell.CellY()); + obj->RemoveFromGrid(); //This step is not really necessary but we want to do ASSERT in remove/add if (on) - { - grid.RemoveGridObject<T>(obj); grid.AddWorldObject<T>(obj); - /*if (!grid.RemoveGridObject<T>(obj, obj->GetGUID()) - || !grid.AddWorldObject<T>(obj, obj->GetGUID())) - { - ASSERT(false); - }*/ - } else - { - grid.RemoveWorldObject<T>(obj); grid.AddGridObject<T>(obj); - /*if (!grid.RemoveWorldObject<T>(obj, obj->GetGUID()) - || !grid.AddGridObject<T>(obj, obj->GetGUID())) - { - ASSERT(false); - }*/ - } obj->m_isWorldObject = on; } @@ -315,18 +294,20 @@ void Map::DeleteFromWorld(T* obj) } template<> -void Map::DeleteFromWorld(Player* pl) +void Map::DeleteFromWorld(Player* player) { - sObjectAccessor->RemoveObject(pl); - delete pl; + sObjectAccessor->RemoveObject(player); + sObjectAccessor->RemoveUpdateObject(player); //TODO: I do not know why we need this, it should be removed in ~Object anyway + delete player; } -void -Map::EnsureGridCreated(const GridPair &p) +//Create NGrid so the object can be added to it +//But object data is not loaded here +void Map::EnsureGridCreated(const GridCoord &p) { if (!getNGrid(p.x_coord, p.y_coord)) { - ACE_GUARD(ACE_Thread_Mutex, Guard, Lock); + TRINITY_GUARD(ACE_Thread_Mutex, Lock); if (!getNGrid(p.x_coord, p.y_coord)) { sLog->outDebug(LOG_FILTER_MAPS, "Creating grid[%u, %u] for map %u instance %u", p.x_coord, p.y_coord, GetId(), i_InstanceId); @@ -349,8 +330,8 @@ Map::EnsureGridCreated(const GridPair &p) } } -void -Map::EnsureGridLoadedAtEnter(const Cell &cell, Player* player) +//Load NGrid and make it active +void Map::EnsureGridLoadedForActiveObject(const Cell &cell, WorldObject* object) { EnsureGridLoaded(cell); NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); @@ -359,23 +340,16 @@ Map::EnsureGridLoadedAtEnter(const Cell &cell, Player* player) // refresh grid state & timer if (grid->GetGridState() != GRID_STATE_ACTIVE) { - if (player) - { - sLog->outStaticDebug("Player %s enter cell[%u, %u] triggers loading of grid[%u, %u] on map %u", player->GetName(), cell.CellX(), cell.CellY(), cell.GridX(), cell.GridY(), GetId()); - } - else - { - sLog->outStaticDebug("Active object nearby triggers loading of grid [%u, %u] on map %u", cell.GridX(), cell.GridY(), GetId()); - } - + sLog->outStaticDebug("Active object "UI64FMTD" triggers loading of grid [%u, %u] on map %u", object->GetGUID(), cell.GridX(), cell.GridY(), GetId()); ResetGridExpiry(*grid, 0.1f); grid->SetGridState(GRID_STATE_ACTIVE); } } +//Create NGrid and load the object data in it bool Map::EnsureGridLoaded(const Cell &cell) { - EnsureGridCreated(GridPair(cell.GridX(), cell.GridY())); + EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY())); NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); ASSERT(grid != NULL); @@ -389,7 +363,7 @@ bool Map::EnsureGridLoaded(const Cell &cell) loader.LoadN(); // Add resurrectable corpses to world object list in grid - sObjectAccessor->AddCorpsesToGrid(GridPair(cell.GridX(), cell.GridY()), (*grid)(cell.CellX(), cell.CellY()), this); + sObjectAccessor->AddCorpsesToGrid(GridCoord(cell.GridX(), cell.GridY()), grid->GetGridType(cell.CellX(), cell.CellY()), this); return true; } @@ -398,30 +372,25 @@ bool Map::EnsureGridLoaded(const Cell &cell) void Map::LoadGrid(float x, float y) { - CellPair pair = Trinity::ComputeCellPair(x, y); - Cell cell(pair); - EnsureGridLoaded(cell); + EnsureGridLoaded(Cell(x, y)); } -bool Map::Add(Player* player) +bool Map::AddPlayerToMap(Player* player) { - // Check if we are adding to correct map - ASSERT (player->GetMap() == this); - CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); - if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) + CellCoord cellCoord = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()); + if (!cellCoord.IsCoordValid()) { - sLog->outError("Map::Add: Player (GUID: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), p.x_coord, p.y_coord); + sLog->outError("Map::Add: Player (GUID: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord); return false; } - player->SetMap(this); - - Cell cell(p); - EnsureGridLoadedAtEnter(cell, player); - NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); - ASSERT(grid != NULL); - AddToGrid(player, grid, cell); + Cell cell(cellCoord); + EnsureGridLoadedForActiveObject(cell, player); + AddToGrid(player, cell); + // Check if we are adding to correct map + ASSERT (player->GetMap() == this); + player->SetMap(this); player->AddToWorld(); SendInitSelf(player); @@ -435,68 +404,73 @@ bool Map::Add(Player* player) } template<class T> -void -Map::Add(T *obj) +void Map::InitializeObject(T* /*obj*/) +{ +} + +template<> +void Map::InitializeObject(Creature* obj) +{ + obj->_moveState = CREATURE_CELL_MOVE_NONE; +} + +template<class T> +void Map::AddToMap(T *obj) { - CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) + //TODO: Needs clean up. An object should not be added to map twice. + if (obj->IsInWorld()) { - sLog->outError("Map::Add: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); + ASSERT(obj->IsInGrid()); + obj->UpdateObjectVisibility(true); return; } - Cell cell(p); - if (obj->IsInWorld()) // need some clean up later + CellCoord cellCoord = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); + if (!cellCoord.IsCoordValid()) { - obj->UpdateObjectVisibility(true); + sLog->outError("Map::Add: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord); return; } + Cell cell(cellCoord); if (obj->isActiveObject()) - EnsureGridLoadedAtEnter(cell); + EnsureGridLoadedForActiveObject(cell, obj); else - EnsureGridCreated(GridPair(cell.GridX(), cell.GridY())); - - NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); - ASSERT(grid != NULL); + EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY())); + AddToGrid(obj, cell); + sLog->outStaticDebug("Object %u enters grid[%u, %u]", GUID_LOPART(obj->GetGUID()), cell.GridX(), cell.GridY()); - AddToGrid(obj, grid, cell); + //Must already be set before AddToMap. Usually during obj->Create. //obj->SetMap(this); obj->AddToWorld(); + InitializeObject(obj); + if (obj->isActiveObject()) AddToActive(obj); - sLog->outStaticDebug("Object %u enters grid[%u, %u]", GUID_LOPART(obj->GetGUID()), cell.GridX(), cell.GridY()); - //something, such as vehicle, needs to be update immediately //also, trigger needs to cast spell, if not update, cannot see visual obj->UpdateObjectVisibility(true); } -bool Map::loaded(const GridPair &p) const +bool Map::IsGridLoaded(const GridCoord &p) const { return (getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord)); } void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer> &gridVisitor, TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer> &worldVisitor) { - CellPair standing_cell(Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY())); - - // Check for correctness of standing_cell, it also avoids problems with update_cell - if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) + // Check for valid position + if (!obj->IsPositionValid()) return; - // the overloaded operators handle range checking - // so there's no need for range checking inside the loop - CellPair begin_cell(standing_cell), end_cell(standing_cell); - //lets update mobs/objects in ALL visible cells around object! - CellArea area = Cell::CalculateCellArea(*obj, obj->GetGridActivationRange()); - area.ResizeBorders(begin_cell, end_cell); + // Update mobs/objects in ALL visible cells around object! + CellArea area = Cell::CalculateCellArea(obj->GetPositionX(), obj->GetPositionY(), obj->GetGridActivationRange()); - for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x) + for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x) { - for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y) + for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y) { // marked cells are those that have been visited // don't visit the same cell twice @@ -505,11 +479,10 @@ void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::Obj continue; markCell(cell_id); - CellPair pair(x, y); + CellCoord pair(x, y); Cell cell(pair); - cell.data.Part.reserved = CENTER_DISTRICT; - cell.Visit(pair, gridVisitor, *this); - cell.Visit(pair, worldVisitor, *this); + Visit(cell, gridVisitor); + Visit(cell, worldVisitor); } } } @@ -519,11 +492,11 @@ void Map::Update(const uint32 t_diff) /// update worldsessions for existing players for (m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter) { - Player* plr = m_mapRefIter->getSource(); - if (plr && plr->IsInWorld()) + Player* player = m_mapRefIter->getSource(); + if (player && player->IsInWorld()) { - //plr->Update(t_diff); - WorldSession* pSession = plr->GetSession(); + //player->Update(t_diff); + WorldSession* pSession = player->GetSession(); MapSessionFilter updater(pSession); pSession->Update(t_diff, updater); } @@ -541,15 +514,15 @@ void Map::Update(const uint32 t_diff) // to make sure calls to Map::Remove don't invalidate it for (m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter) { - Player* plr = m_mapRefIter->getSource(); + Player* player = m_mapRefIter->getSource(); - if (!plr || !plr->IsInWorld()) + if (!player || !player->IsInWorld()) continue; // update players at tick - plr->Update(t_diff); + player->Update(t_diff); - VisitNearbyCellsOf(plr, grid_object_update, world_object_update); + VisitNearbyCellsOf(player, grid_object_update, world_object_update); } // non-player active objects, increasing iterator in the loop in case of object removal @@ -607,8 +580,8 @@ void Map::ProcessRelocationNotifies(const uint32 diff) uint32 gx = grid->getX(), gy = grid->getY(); - CellPair cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS); - CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); + CellCoord cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS); + CellCoord cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); for (uint32 x = cell_min.x_coord; x < cell_max.x_coord; ++x) { @@ -618,7 +591,7 @@ void Map::ProcessRelocationNotifies(const uint32 diff) if (!isCellMarked(cell_id)) continue; - CellPair pair(x, y); + CellCoord pair(x, y); Cell cell(pair); cell.SetNoCreate(); @@ -648,8 +621,8 @@ void Map::ProcessRelocationNotifies(const uint32 diff) uint32 gx = grid->getX(), gy = grid->getY(); - CellPair cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS); - CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); + CellCoord cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS); + CellCoord cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); for (uint32 x = cell_min.x_coord; x < cell_max.x_coord; ++x) { @@ -659,7 +632,7 @@ void Map::ProcessRelocationNotifies(const uint32 diff) if (!isCellMarked(cell_id)) continue; - CellPair pair(x, y); + CellCoord pair(x, y); Cell cell(pair); cell.SetNoCreate(); Visit(cell, grid_notifier); @@ -669,29 +642,16 @@ void Map::ProcessRelocationNotifies(const uint32 diff) } } -void Map::Remove(Player* player, bool remove) +void Map::RemovePlayerFromMap(Player* player, bool remove) { player->RemoveFromWorld(); SendRemoveTransports(player); - CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); - if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) - sLog->outCrash("Map::Remove: Player is in invalid cell!"); + player->UpdateObjectVisibility(true); + if (player->IsInGrid()) + player->RemoveFromGrid(); else - { - Cell cell(p); - if (!getNGrid(cell.data.Part.grid_x, cell.data.Part.grid_y)) - sLog->outError("Map::Remove() i_grids was NULL x:%d, y:%d", cell.data.Part.grid_x, cell.data.Part.grid_y); - else - { - sLog->outStaticDebug("Remove player %s from grid[%u, %u]", player->GetName(), cell.GridX(), cell.GridY()); - NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); - ASSERT(grid != NULL); - - player->UpdateObjectVisibility(true); - RemoveFromGrid(player, grid, cell); - } - } + ASSERT(remove); //maybe deleted in logoutplayer when player is not in a map if (remove) DeleteFromWorld(player); @@ -701,28 +661,14 @@ void Map::Remove(Player* player, bool remove) template<class T> void -Map::Remove(T *obj, bool remove) +Map::RemoveFromMap(T *obj, bool remove) { obj->RemoveFromWorld(); if (obj->isActiveObject()) RemoveFromActive(obj); - CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) - sLog->outError("Map::Remove: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); - else - { - Cell cell(p); - if (loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) - { - sLog->outStaticDebug("Remove object " UI64FMTD " from grid[%u, %u]", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y); - NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); - ASSERT(grid != NULL); - - obj->UpdateObjectVisibility(true); - RemoveFromGrid(obj, grid, cell); - } - } + obj->UpdateObjectVisibility(true); + obj->RemoveFromGrid(); obj->ResetMap(); @@ -740,11 +686,8 @@ Map::PlayerRelocation(Player* player, float x, float y, float z, float orientati { ASSERT(player); - CellPair old_val = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); - CellPair new_val = Trinity::ComputeCellPair(x, y); - - Cell old_cell(old_val); - Cell new_cell(new_val); + Cell old_cell(player->GetPositionX(), player->GetPositionY()); + Cell new_cell(x, y); player->Relocate(x, y, z, orientation); @@ -752,14 +695,12 @@ Map::PlayerRelocation(Player* player, float x, float y, float z, float orientati { sLog->outStaticDebug("Player %s relocation grid[%u, %u]cell[%u, %u]->grid[%u, %u]cell[%u, %u]", player->GetName(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); - NGridType* oldGrid = getNGrid(old_cell.GridX(), old_cell.GridY()); - RemoveFromGrid(player, oldGrid, old_cell); + player->RemoveFromGrid(); if (old_cell.DiffGrid(new_cell)) - EnsureGridLoadedAtEnter(new_cell, player); + EnsureGridLoadedForActiveObject(new_cell, player); - NGridType* newGrid = getNGrid(new_cell.GridX(), new_cell.GridY()); - AddToGrid(player, newGrid, new_cell); + AddToGrid(player, new_cell); } player->UpdateObjectVisibility(false); @@ -771,9 +712,7 @@ Map::CreatureRelocation(Creature* creature, float x, float y, float z, float ang ASSERT(CheckGridIntegrity(creature, false)); Cell old_cell = creature->GetCurrentCell(); - - CellPair new_val = Trinity::ComputeCellPair(x, y); - Cell new_cell(new_val); + Cell new_cell(x, y); if (!respawnRelocationOnFail && !getNGrid(new_cell.GridX(), new_cell.GridY())) return; @@ -791,6 +730,7 @@ Map::CreatureRelocation(Creature* creature, float x, float y, float z, float ang { creature->Relocate(x, y, z, ang); creature->UpdateObjectVisibility(false); + RemoveCreatureFromMoveList(creature); } ASSERT(CheckGridIntegrity(creature, true)); @@ -798,34 +738,55 @@ Map::CreatureRelocation(Creature* creature, float x, float y, float z, float ang void Map::AddCreatureToMoveList(Creature* c, float x, float y, float z, float ang) { - if (!c) + if (_creatureToMoveLock) //can this happen? return; - i_creaturesToMove[c] = CreatureMover(x, y, z, ang); + if (c->_moveState == CREATURE_CELL_MOVE_NONE) + _creaturesToMove.push_back(c); + c->SetNewCellPosition(x, y, z, ang); +} + +void Map::RemoveCreatureFromMoveList(Creature* c) +{ + if (_creatureToMoveLock) //can this happen? + return; + + if (c->_moveState == CREATURE_CELL_MOVE_ACTIVE) + c->_moveState = CREATURE_CELL_MOVE_INACTIVE; } void Map::MoveAllCreaturesInMoveList() { - while (!i_creaturesToMove.empty()) + _creatureToMoveLock = true; + for(std::vector<Creature*>::iterator itr = _creaturesToMove.begin(); itr != _creaturesToMove.end(); ++itr) { - // get data and remove element; - CreatureMoveList::iterator iter = i_creaturesToMove.begin(); - Creature* c = iter->first; - const CreatureMover &cm = iter->second; + Creature* c = *itr; + if(c->FindMap() != this) //pet is teleported to another map + continue; + + if(c->_moveState != CREATURE_CELL_MOVE_ACTIVE) + { + c->_moveState = CREATURE_CELL_MOVE_NONE; + continue; + } + + c->_moveState = CREATURE_CELL_MOVE_NONE; + if(!c->IsInWorld()) + continue; // do move or do move to respawn or remove creature if previous all fail - if (CreatureCellRelocation(c, Cell(Trinity::ComputeCellPair(cm.x, cm.y)))) + if (CreatureCellRelocation(c, Cell(c->_newPosition.m_positionX, c->_newPosition.m_positionY))) { // update pos - c->Relocate(cm.x, cm.y, cm.z, cm.ang); - //CreatureRelocationNotify(c, new_cell, new_cell.cellPair()); + c->Relocate(c->_newPosition); + //CreatureRelocationNotify(c, new_cell, new_cell.cellCoord()); c->UpdateObjectVisibility(false); } else { // if creature can't be move in new cell/grid (not loaded) move it to repawn cell/grid // creature coordinates will be updated and notifiers send - if (!CreatureRespawnRelocation(c)) + if (!CreatureRespawnRelocation(c, false)) { // ... or unload (if respawn grid also not loaded) #ifdef TRINITY_DEBUG @@ -843,9 +804,9 @@ void Map::MoveAllCreaturesInMoveList() AddObjectToRemoveList(c); } } - - i_creaturesToMove.erase(iter); } + _creaturesToMove.clear(); + _creatureToMoveLock = false; } bool Map::CreatureCellRelocation(Creature* c, Cell new_cell) @@ -860,8 +821,8 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell) sLog->outDebug(LOG_FILTER_MAPS, "Creature (GUID: %u Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY()); #endif - RemoveFromGrid(c, getNGrid(old_cell.GridX(), old_cell.GridY()), old_cell); - AddToGrid(c, getNGrid(new_cell.GridX(), new_cell.GridY()), new_cell); + c->RemoveFromGrid(); + AddToGrid(c, new_cell); } else { @@ -876,28 +837,28 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell) // in diff. grids but active creature if (c->isActiveObject()) { - EnsureGridLoadedAtEnter(new_cell); + EnsureGridLoadedForActiveObject(new_cell, c); #ifdef TRINITY_DEBUG sLog->outDebug(LOG_FILTER_MAPS, "Active creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); #endif - RemoveFromGrid(c, getNGrid(old_cell.GridX(), old_cell.GridY()), old_cell); - AddToGrid(c, getNGrid(new_cell.GridX(), new_cell.GridY()), new_cell); + c->RemoveFromGrid(); + AddToGrid(c, new_cell); return true; } // in diff. loaded grid normal creature - if (loaded(GridPair(new_cell.GridX(), new_cell.GridY()))) + if (IsGridLoaded(GridCoord(new_cell.GridX(), new_cell.GridY()))) { #ifdef TRINITY_DEBUG sLog->outDebug(LOG_FILTER_MAPS, "Creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); #endif - RemoveFromGrid(c, getNGrid(old_cell.GridX(), old_cell.GridY()), old_cell); - EnsureGridCreated(GridPair(new_cell.GridX(), new_cell.GridY())); - AddToGrid(c, getNGrid(new_cell.GridX(), new_cell.GridY()), new_cell); + c->RemoveFromGrid(); + EnsureGridCreated(GridCoord(new_cell.GridX(), new_cell.GridY())); + AddToGrid(c, new_cell); return true; } @@ -909,13 +870,15 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell) return false; } -bool Map::CreatureRespawnRelocation(Creature* c) +bool Map::CreatureRespawnRelocation(Creature* c, bool diffGridOnly) { float resp_x, resp_y, resp_z, resp_o; - c->GetRespawnCoord(resp_x, resp_y, resp_z, &resp_o); + c->GetRespawnPosition(resp_x, resp_y, resp_z, &resp_o); + Cell resp_cell(resp_x, resp_y); - CellPair resp_val = Trinity::ComputeCellPair(resp_x, resp_y); - Cell resp_cell(resp_val); + //creature will be unloaded with grid + if (diffGridOnly && !c->GetCurrentCell().DiffGrid(resp_cell)) + return true; c->CombatStop(); c->GetMotionMaster()->Clear(); @@ -929,7 +892,7 @@ bool Map::CreatureRespawnRelocation(Creature* c) { c->Relocate(resp_x, resp_y, resp_z, resp_o); c->GetMotionMaster()->Initialize(); // prevent possible problems with default move generators - //CreatureRelocationNotify(c, resp_cell, resp_cell.cellPair()); + //CreatureRelocationNotify(c, resp_cell, resp_cell.GetCellCoord()); c->UpdateObjectVisibility(false); return true; } @@ -937,19 +900,17 @@ bool Map::CreatureRespawnRelocation(Creature* c) return false; } -bool Map::UnloadGrid(const uint32 x, const uint32 y, bool unloadAll) +bool Map::UnloadGrid(NGridType& ngrid, bool unloadAll) { - NGridType *grid = getNGrid(x, y); - ASSERT(grid != NULL); + const uint32 x = ngrid.getX(); + const uint32 y = ngrid.getY(); { - if (!unloadAll && ActiveObjectsNearGrid(x, y)) + if (!unloadAll && ActiveObjectsNearGrid(ngrid)) return false; sLog->outDebug(LOG_FILTER_MAPS, "Unloading grid[%u, %u] for map %u", x, y, GetId()); - ObjectGridUnloader unloader(*grid); - if (!unloadAll) { // Finish creature moves, remove and delete all creatures with delayed remove before moving to respawn grids @@ -957,22 +918,31 @@ bool Map::UnloadGrid(const uint32 x, const uint32 y, bool unloadAll) MoveAllCreaturesInMoveList(); // move creatures to respawn grids if this is diff.grid or to remove list - unloader.MoveToRespawnN(); + ObjectGridEvacuator worker; + TypeContainerVisitor<ObjectGridEvacuator, GridTypeMapContainer> visitor(worker); + ngrid.VisitAllGrids(visitor); // Finish creature moves, remove and delete all creatures with delayed remove before unload MoveAllCreaturesInMoveList(); } - ObjectGridCleaner cleaner(*grid); - cleaner.CleanN(); + { + ObjectGridCleaner worker; + TypeContainerVisitor<ObjectGridCleaner, GridTypeMapContainer> visitor(worker); + ngrid.VisitAllGrids(visitor); + } RemoveAllObjectsInRemoveList(); - unloader.UnloadN(); + { + ObjectGridUnloader worker; + TypeContainerVisitor<ObjectGridUnloader, GridTypeMapContainer> visitor(worker); + ngrid.VisitAllGrids(visitor); + } ASSERT(i_objectsToRemove.empty()); - delete grid; + delete &ngrid; setNGrid(NULL, x, y); } int gx = (MAX_NUMBER_OF_GRIDS - 1) - x; @@ -992,7 +962,7 @@ bool Map::UnloadGrid(const uint32 x, const uint32 y, bool unloadAll) VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gx, gy); } else - ((MapInstanced*)m_parentMap)->RemoveGridMapReference(GridPair(gx, gy)); + ((MapInstanced*)m_parentMap)->RemoveGridMapReference(GridCoord(gx, gy)); GridMaps[gx][gy] = NULL; } @@ -1006,12 +976,12 @@ void Map::RemoveAllPlayers() { for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) { - Player* plr = itr->getSource(); - if (!plr->IsBeingTeleportedFar()) + Player* player = itr->getSource(); + if (!player->IsBeingTeleportedFar()) { // this is happening for bg - sLog->outError("Map::UnloadAll: player %s is still in map %u during unload, this should not happen!", plr->GetName(), GetId()); - plr->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation()); + sLog->outError("Map::UnloadAll: player %s is still in map %u during unload, this should not happen!", player->GetName(), GetId()); + player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation()); } } } @@ -1020,13 +990,13 @@ void Map::RemoveAllPlayers() void Map::UnloadAll() { // clear all delayed moves, useless anyway do this moves before map unload. - i_creaturesToMove.clear(); + _creaturesToMove.clear(); for (GridRefManager<NGridType>::iterator i = GridRefManager<NGridType>::begin(); i != GridRefManager<NGridType>::end();) { NGridType &grid(*i->getSource()); ++i; - UnloadGrid(grid.getX(), grid.getY(), true); // deletes the grid and removes it from the GridRefManager + UnloadGrid(grid, true); // deletes the grid and removes it from the GridRefManager } } @@ -1551,7 +1521,7 @@ inline GridMap* Map::GetGrid(float x, float y) int gy=(int)(32-y/SIZE_OF_GRIDS); //grid y // ensure GridMap is loaded - EnsureGridCreated(GridPair(63-gx, 63-gy)); + EnsureGridCreated(GridCoord(63-gx, 63-gy)); return GridMaps[gx][gy]; } @@ -1820,7 +1790,7 @@ bool Map::IsInWater(float x, float y, float pZ, LiquidData* data) const LiquidData liquid_status; LiquidData* liquid_ptr = data ? data : &liquid_status; if (getLiquidStatus(x, y, pZ, MAP_ALL_LIQUIDS, liquid_ptr)) - return true; + return true; } return false; } @@ -1838,9 +1808,7 @@ bool Map::IsUnderWater(float x, float y, float z) const bool Map::CheckGridIntegrity(Creature* c, bool moved) const { Cell const& cur_cell = c->GetCurrentCell(); - - CellPair xy_val = Trinity::ComputeCellPair(c->GetPositionX(), c->GetPositionY()); - Cell xy_cell(xy_val); + Cell xy_cell(c->GetPositionX(), c->GetPositionY()); if (xy_cell != cur_cell) { sLog->outDebug(LOG_FILTER_MAPS, "Creature (GUID: %u) X: %f Y: %f (%s) is in grid[%u, %u]cell[%u, %u] instead of grid[%u, %u]cell[%u, %u]", @@ -1859,20 +1827,18 @@ const char* Map::GetMapName() const return i_mapEntry ? i_mapEntry->name[sWorld->GetDefaultDbcLocale()] : "UNNAMEDMAP\x0"; } -void Map::UpdateObjectVisibility(WorldObject* obj, Cell cell, CellPair cellpair) +void Map::UpdateObjectVisibility(WorldObject* obj, Cell cell, CellCoord cellpair) { - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::VisibleChangesNotifier notifier(*obj); TypeContainerVisitor<Trinity::VisibleChangesNotifier, WorldTypeMapContainer > player_notifier(notifier); cell.Visit(cellpair, player_notifier, *this, *obj, obj->GetVisibilityRange()); } -void Map::UpdateObjectsVisibilityFor(Player* player, Cell cell, CellPair cellpair) +void Map::UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpair) { Trinity::VisibleNotifier notifier(*player); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); TypeContainerVisitor<Trinity::VisibleNotifier, WorldTypeMapContainer > world_notifier(notifier); TypeContainerVisitor<Trinity::VisibleNotifier, GridTypeMapContainer > grid_notifier(notifier); @@ -1989,7 +1955,7 @@ void Map::DelayedUpdate(const uint32 t_diff) GridInfo* info = i->getSource()->getGridInfoRef(); ++i; // The update might delete the map and we need the next map before the iterator gets invalid ASSERT(grid->GetGridState() >= 0 && grid->GetGridState() < MAX_GRID_STATE); - si_GridStates[grid->GetGridState()]->Update(*this, *grid, *info, grid->getX(), grid->getY(), t_diff); + si_GridStates[grid->GetGridState()]->Update(*this, *grid, *info, t_diff); } } } @@ -2051,20 +2017,20 @@ void Map::RemoveAllObjectsInRemoveList() if (!corpse) sLog->outError("Tried to delete corpse/bones %u that is not in map.", obj->GetGUIDLow()); else - Remove(corpse, true); + RemoveFromMap(corpse, true); break; } case TYPEID_DYNAMICOBJECT: - Remove((DynamicObject*)obj, true); + RemoveFromMap((DynamicObject*)obj, true); break; case TYPEID_GAMEOBJECT: - Remove((GameObject*)obj, true); + RemoveFromMap((GameObject*)obj, true); break; case TYPEID_UNIT: // in case triggered sequence some spell can continue casting after prev CleanupsBeforeDelete call // make sure that like sources auras/etc removed before destructor start obj->ToCreature()->CleanupsBeforeDelete(); - Remove(obj->ToCreature(), true); + RemoveFromMap(obj->ToCreature(), true); break; default: sLog->outError("Non-grid object (TypeId: %u) is in grid object remove list, ignored.", obj->GetTypeId()); @@ -2092,28 +2058,25 @@ void Map::SendToPlayers(WorldPacket const* data) const itr->getSource()->GetSession()->SendPacket(data); } -bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const +bool Map::ActiveObjectsNearGrid(NGridType const& ngrid) const { - ASSERT(x < MAX_NUMBER_OF_GRIDS); - ASSERT(y < MAX_NUMBER_OF_GRIDS); - - CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS); - CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); + CellCoord cell_min(ngrid.getX() * MAX_NUMBER_OF_CELLS, ngrid.getY() * MAX_NUMBER_OF_CELLS); + CellCoord cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); //we must find visible range in cells so we unload only non-visible cells... float viewDist = GetVisibilityRange(); int cell_range = (int)ceilf(viewDist / SIZE_OF_GRID_CELL) + 1; - cell_min << cell_range; - cell_min -= cell_range; - cell_max >> cell_range; - cell_max += cell_range; + cell_min.dec_x(cell_range); + cell_min.dec_y(cell_range); + cell_max.inc_x(cell_range); + cell_max.inc_y(cell_range); for (MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter) { - Player* plr = iter->getSource(); + Player* player = iter->getSource(); - CellPair p = Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY()); + CellCoord p = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()); if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord)) return true; @@ -2123,7 +2086,7 @@ bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const { WorldObject* obj = *iter; - CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); + CellCoord p = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord)) return true; @@ -2140,13 +2103,13 @@ void Map::AddToActive(Creature* c) if (!c->isPet() && c->GetDBTableGUIDLow()) { float x, y, z; - c->GetRespawnCoord(x, y, z); - GridPair p = Trinity::ComputeGridPair(x, y); + c->GetRespawnPosition(x, y, z); + GridCoord p = Trinity::ComputeGridCoord(x, y); if (getNGrid(p.x_coord, p.y_coord)) getNGrid(p.x_coord, p.y_coord)->incUnloadActiveLock(); else { - GridPair p2 = Trinity::ComputeGridPair(c->GetPositionX(), c->GetPositionY()); + GridCoord p2 = Trinity::ComputeGridCoord(c->GetPositionX(), c->GetPositionY()); sLog->outError("Active creature (GUID: %u Entry: %u) added to grid[%u, %u] but spawn grid[%u, %u] was not loaded.", c->GetGUIDLow(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord); } @@ -2161,28 +2124,28 @@ void Map::RemoveFromActive(Creature* c) if (!c->isPet() && c->GetDBTableGUIDLow()) { float x, y, z; - c->GetRespawnCoord(x, y, z); - GridPair p = Trinity::ComputeGridPair(x, y); + c->GetRespawnPosition(x, y, z); + GridCoord p = Trinity::ComputeGridCoord(x, y); if (getNGrid(p.x_coord, p.y_coord)) getNGrid(p.x_coord, p.y_coord)->decUnloadActiveLock(); else { - GridPair p2 = Trinity::ComputeGridPair(c->GetPositionX(), c->GetPositionY()); + GridCoord p2 = Trinity::ComputeGridCoord(c->GetPositionX(), c->GetPositionY()); sLog->outError("Active creature (GUID: %u Entry: %u) removed from grid[%u, %u] but spawn grid[%u, %u] was not loaded.", c->GetGUIDLow(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord); } } } -template void Map::Add(Corpse*); -template void Map::Add(Creature*); -template void Map::Add(GameObject*); -template void Map::Add(DynamicObject*); +template void Map::AddToMap(Corpse*); +template void Map::AddToMap(Creature*); +template void Map::AddToMap(GameObject*); +template void Map::AddToMap(DynamicObject*); -template void Map::Remove(Corpse*, bool); -template void Map::Remove(Creature*, bool); -template void Map::Remove(GameObject*, bool); -template void Map::Remove(DynamicObject*, bool); +template void Map::RemoveFromMap(Corpse*, bool); +template void Map::RemoveFromMap(Creature*, bool); +template void Map::RemoveFromMap(GameObject*, bool); +template void Map::RemoveFromMap(DynamicObject*, bool); /* ******* Dungeon Instance Maps ******* */ @@ -2277,14 +2240,14 @@ bool InstanceMap::CanEnter(Player* player) /* Do map specific checks and add the player to the map if successful. */ -bool InstanceMap::Add(Player* player) +bool InstanceMap::AddPlayerToMap(Player* player) { // TODO: Not sure about checking player level: already done in HandleAreaTriggerOpcode // GMs still can teleport player in instance. // Is it needed? { - ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, Lock, false); + TRINITY_GUARD(ACE_Thread_Mutex, Lock); // Check moved to void WorldSession::HandleMoveWorldportAckOpcode() //if (!CanEnter(player)) //return false; @@ -2387,7 +2350,7 @@ bool InstanceMap::Add(Player* player) } // this will acquire the same mutex so it cannot be in the previous block - Map::Add(player); + Map::AddPlayerToMap(player); if (i_data) i_data->OnPlayerEnter(player); @@ -2403,13 +2366,13 @@ void InstanceMap::Update(const uint32 t_diff) i_data->Update(t_diff); } -void InstanceMap::Remove(Player* player, bool remove) +void InstanceMap::RemovePlayerFromMap(Player* player, bool remove) { sLog->outDetail("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to another map", player->GetName(), GetInstanceId(), GetMapName()); //if last player set unload timer if (!m_unloadTimer && m_mapRefManager.getSize() == 1) m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld->getIntConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); - Map::Remove(player, remove); + Map::RemovePlayerFromMap(player, remove); // for normal instances schedule the reset after all players have left SetResetSchedule(true); } @@ -2504,20 +2467,20 @@ void InstanceMap::PermBindAllPlayers(Player* player) // group members outside the instance group don't get bound for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) { - Player* plr = itr->getSource(); + Player* player = itr->getSource(); // players inside an instance cannot be bound to other instances // some players may already be permanently bound, in this case nothing happens - InstancePlayerBind* bind = plr->GetBoundInstance(save->GetMapId(), save->GetDifficulty()); + InstancePlayerBind* bind = player->GetBoundInstance(save->GetMapId(), save->GetDifficulty()); if (!bind || !bind->perm) { - plr->BindToInstance(save, true); + player->BindToInstance(save, true); WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); data << uint32(0); - plr->GetSession()->SendPacket(&data); + player->GetSession()->SendPacket(&data); } // if the leader is not in the instance the group will not get a perm bind - if (group && group->GetLeaderGUID() == plr->GetGUID()) + if (group && group->GetLeaderGUID() == player->GetGUID()) group->BindToInstance(save, true); } } @@ -2623,23 +2586,23 @@ bool BattlegroundMap::CanEnter(Player* player) return Map::CanEnter(player); } -bool BattlegroundMap::Add(Player* player) +bool BattlegroundMap::AddPlayerToMap(Player* player) { { - ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, Lock, false); + TRINITY_GUARD(ACE_Thread_Mutex, Lock); //Check moved to void WorldSession::HandleMoveWorldportAckOpcode() //if (!CanEnter(player)) //return false; // reset instance validity, battleground maps do not homebind player->m_InstanceValid = true; } - return Map::Add(player); + return Map::AddPlayerToMap(player); } -void BattlegroundMap::Remove(Player* player, bool remove) +void BattlegroundMap::RemovePlayerFromMap(Player* player, bool remove) { sLog->outDetail("MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to another map", player->GetName(), GetInstanceId(), GetMapName()); - Map::Remove(player, remove); + Map::RemovePlayerFromMap(player, remove); } void BattlegroundMap::SetUnload() @@ -2651,9 +2614,9 @@ void BattlegroundMap::RemoveAllPlayers() { if (HavePlayers()) for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) - if (Player* plr = itr->getSource()) - if (!plr->IsBeingTeleportedFar()) - plr->TeleportTo(plr->GetBattlegroundEntryPoint()); + if (Player* player = itr->getSource()) + if (!player->IsBeingTeleportedFar()) + player->TeleportTo(player->GetBattlegroundEntryPoint()); } Creature* @@ -2678,4 +2641,4 @@ void Map::UpdateIteratorBack(Player* player) { if (m_mapRefIter == player->GetMapRef()) m_mapRefIter = m_mapRefIter->nocheck_prev(); -}
\ No newline at end of file +} diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index bbd3b20ecfb..58db314deaf 100755 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -193,14 +193,6 @@ public: ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData* data = 0); }; -struct CreatureMover -{ - CreatureMover() : x(0.0f), y(0.0f), z(0.0f), ang(0.0f) {} - CreatureMover(float _x, float _y, float _z, float _ang) : x(_x), y(_y), z(_z), ang(_ang) {} - - float x, y, z, ang; -}; - // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push, N), also any gcc version not support it at some platform #if defined(__GNUC__) #pragma pack(1) @@ -226,8 +218,6 @@ enum LevelRequirementVsMode #pragma pack(pop) #endif -typedef UNORDERED_MAP<Creature*, CreatureMover> CreatureMoveList; - #define MAX_HEIGHT 100000.0f // can be use for find ground height at surface #define INVALID_HEIGHT -100000.0f // for check, must be equal to VMAP_INVALID_HEIGHT, real value for unknown height is VMAP_INVALID_HEIGHT_VALUE #define MAX_FALL_DISTANCE 250000.0f // "unlimited fall" to find VMap ground if it is available, just larger than MAX_HEIGHT - INVALID_HEIGHT @@ -254,10 +244,10 @@ class Map : public GridRefManager<NGridType> return false; } - virtual bool Add(Player*); - virtual void Remove(Player*, bool); - template<class T> void Add(T *); - template<class T> void Remove(T *, bool); + virtual bool AddPlayerToMap(Player*); + virtual void RemovePlayerFromMap(Player*, bool); + template<class T> void AddToMap(T *); + template<class T> void RemoveFromMap(T *, bool); void VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer> &gridVisitor, TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer> &worldVisitor); virtual void Update(const uint32); @@ -273,20 +263,19 @@ class Map : public GridRefManager<NGridType> bool IsRemovalGrid(float x, float y) const { - GridPair p = Trinity::ComputeGridPair(x, y); + GridCoord p = Trinity::ComputeGridCoord(x, y); return !getNGrid(p.x_coord, p.y_coord) || getNGrid(p.x_coord, p.y_coord)->GetGridState() == GRID_STATE_REMOVAL; } - bool IsLoaded(float x, float y) const + bool IsGridLoaded(float x, float y) const { - GridPair p = Trinity::ComputeGridPair(x, y); - return loaded(p); + return IsGridLoaded(Trinity::ComputeGridCoord(x, y)); } - bool GetUnloadLock(const GridPair &p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); } - void SetUnloadLock(const GridPair &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); } + bool GetUnloadLock(const GridCoord &p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); } + void SetUnloadLock(const GridCoord &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); } void LoadGrid(float x, float y); - bool UnloadGrid(const uint32 x, const uint32 y, bool pForce); + bool UnloadGrid(NGridType& ngrid, bool pForce); virtual void UnloadAll(); void ResetGridExpiry(NGridType &grid, float factor = 1) const @@ -344,7 +333,8 @@ class Map : public GridRefManager<NGridType> void RemoveAllObjectsInRemoveList(); virtual void RemoveAllPlayers(); - bool CreatureRespawnRelocation(Creature* c); // used only in MoveAllCreaturesInMoveList and ObjectGridUnloader + // used only in MoveAllCreaturesInMoveList and ObjectGridUnloader + bool CreatureRespawnRelocation(Creature* c, bool diffGridOnly); // assert print helper bool CheckGridIntegrity(Creature* c, bool moved) const; @@ -380,8 +370,8 @@ class Map : public GridRefManager<NGridType> void AddObjectToSwitchList(WorldObject* obj, bool on); virtual void DelayedUpdate(const uint32 diff); - void UpdateObjectVisibility(WorldObject* obj, Cell cell, CellPair cellpair); - void UpdateObjectsVisibilityFor(Player* player, Cell cell, CellPair cellpair); + void UpdateObjectVisibility(WorldObject* obj, Cell cell, CellCoord cellpair); + void UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpair); void resetMarkedCells() { marked_cells.reset(); } bool isCellMarked(uint32 pCellId) { return marked_cells.test(pCellId); } @@ -389,7 +379,7 @@ class Map : public GridRefManager<NGridType> bool HavePlayers() const { return !m_mapRefManager.isEmpty(); } uint32 GetPlayersCountExceptGMs() const; - bool ActiveObjectsNearGrid(uint32 x, uint32 y) const; + bool ActiveObjectsNearGrid(NGridType const& ngrid) const; void AddWorldObject(WorldObject* obj) { i_worldObjects.insert(obj); } void RemoveWorldObject(WorldObject* obj) { i_worldObjects.erase(obj); } @@ -429,8 +419,8 @@ class Map : public GridRefManager<NGridType> GameObject* GetGameObject(uint64 guid); DynamicObject* GetDynamicObject(uint64 guid); - MapInstanced* ToMainstanced(){ if (Instanceable()) return reinterpret_cast<MapInstanced*>(this); else return NULL; } - const MapInstanced* ToMainstanced() const { if (Instanceable()) return (const MapInstanced*)((MapInstanced*)this); else return NULL; } + MapInstanced* ToMapInstanced(){ if (Instanceable()) return reinterpret_cast<MapInstanced*>(this); else return NULL; } + const MapInstanced* ToMapInstanced() const { if (Instanceable()) return (const MapInstanced*)((MapInstanced*)this); else return NULL; } InstanceMap* ToInstanceMap(){ if (IsDungeon()) return reinterpret_cast<InstanceMap*>(this); else return NULL; } const InstanceMap* ToInstanceMap() const { if (IsDungeon()) return (const InstanceMap*)((InstanceMap*)this); else return NULL; } @@ -449,13 +439,17 @@ class Map : public GridRefManager<NGridType> bool CreatureCellRelocation(Creature* creature, Cell new_cell); + template<class T> void InitializeObject(T* obj); void AddCreatureToMoveList(Creature* c, float x, float y, float z, float ang); - CreatureMoveList i_creaturesToMove; + void RemoveCreatureFromMoveList(Creature* c); + + bool _creatureToMoveLock; + std::vector<Creature*> _creaturesToMove; - bool loaded(const GridPair &) const; - void EnsureGridCreated(const GridPair &); + bool IsGridLoaded(const GridCoord &) const; + void EnsureGridCreated(const GridCoord &); bool EnsureGridLoaded(Cell const&); - void EnsureGridLoadedAtEnter(Cell const&, Player* player = NULL); + void EnsureGridLoadedForActiveObject(Cell const&, WorldObject* object); void buildNGridLinkage(NGridType* pNGridType) { pNGridType->link(this); } @@ -464,8 +458,7 @@ class Map : public GridRefManager<NGridType> NGridType* getNGrid(uint32 x, uint32 y) const { - ASSERT(x < MAX_NUMBER_OF_GRIDS); - ASSERT(y < MAX_NUMBER_OF_GRIDS); + ASSERT(x < MAX_NUMBER_OF_GRIDS && y < MAX_NUMBER_OF_GRIDS); return i_grids[x][y]; } @@ -477,7 +470,7 @@ class Map : public GridRefManager<NGridType> void UpdateActiveCells(const float &x, const float &y, const uint32 t_diff); protected: - void SetUnloadReferenceLock(const GridPair &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadReferenceLock(on); } + void SetUnloadReferenceLock(const GridCoord &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadReferenceLock(on); } ACE_Thread_Mutex Lock; @@ -530,10 +523,7 @@ class Map : public GridRefManager<NGridType> // Type specific code for add/remove to/from grid template<class T> - void AddToGrid(T*, NGridType *, Cell const&); - - template<class T> - void RemoveFromGrid(T*, NGridType *, Cell const&); + void AddToGrid(T* object, Cell const& cell); template<class T> void DeleteFromWorld(T*); @@ -577,8 +567,8 @@ class InstanceMap : public Map public: InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map* _parent); ~InstanceMap(); - bool Add(Player*); - void Remove(Player*, bool); + bool AddPlayerToMap(Player*); + void RemovePlayerFromMap(Player*, bool); void Update(const uint32); void CreateInstanceData(bool load); bool Reset(uint8 method); @@ -607,8 +597,8 @@ class BattlegroundMap : public Map BattlegroundMap(uint32 id, time_t, uint32 InstanceId, Map* _parent, uint8 spawnMode); ~BattlegroundMap(); - bool Add(Player*); - void Remove(Player*, bool); + bool AddPlayerToMap(Player*); + void RemovePlayerFromMap(Player*, bool); bool CanEnter(Player* player); void SetUnload(); //void UnloadAll(bool pForce); @@ -622,28 +612,25 @@ class BattlegroundMap : public Map }; template<class T, class CONTAINER> -inline void -Map::Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor) +inline void Map::Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& visitor) { const uint32 x = cell.GridX(); const uint32 y = cell.GridY(); const uint32 cell_x = cell.CellX(); const uint32 cell_y = cell.CellY(); - if (!cell.NoCreate() || loaded(GridPair(x, y))) + if (!cell.NoCreate() || IsGridLoaded(GridCoord(x, y))) { EnsureGridLoaded(cell); - getNGrid(x, y)->Visit(cell_x, cell_y, visitor); + getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor); } } template<class NOTIFIER> -inline void -Map::VisitAll(const float &x, const float &y, float radius, NOTIFIER ¬ifier) +inline void Map::VisitAll(float const& x, float const& y, float radius, NOTIFIER& notifier) { - CellPair p(Trinity::ComputeCellPair(x, y)); + CellCoord p(Trinity::ComputeCellCoord(x, y)); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier); @@ -654,12 +641,10 @@ Map::VisitAll(const float &x, const float &y, float radius, NOTIFIER ¬ifier) // should be used with Searcher notifiers, tries to search world if nothing found in grid template<class NOTIFIER> -inline void -Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER ¬ifier) +inline void Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER ¬ifier) { - CellPair p(Trinity::ComputeCellPair(x, y)); + CellCoord p(Trinity::ComputeCellCoord(x, y)); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier); @@ -672,12 +657,10 @@ Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER ¬ } template<class NOTIFIER> -inline void -Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER ¬ifier) +inline void Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER ¬ifier) { - CellPair p(Trinity::ComputeCellPair(x, y)); + CellCoord p(Trinity::ComputeCellCoord(x, y)); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier); @@ -685,12 +668,10 @@ Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER ¬ifier } template<class NOTIFIER> -inline void -Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER ¬ifier) +inline void Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER ¬ifier) { - CellPair p(Trinity::ComputeCellPair(x, y)); + CellCoord p(Trinity::ComputeCellCoord(x, y)); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier); diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp index 418218a52b3..bbade4c9dc3 100755 --- a/src/server/game/Maps/MapInstanced.cpp +++ b/src/server/game/Maps/MapInstanced.cpp @@ -173,7 +173,7 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player) InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty) { // load/create a map - ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL); + TRINITY_GUARD(ACE_Thread_Mutex, Lock); // make sure we have a valid map id const MapEntry* entry = sMapStore.LookupEntry(GetId()); @@ -207,7 +207,7 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, BattlegroundMap* MapInstanced::CreateBattleground(uint32 InstanceId, Battleground* bg) { // load/create a map - ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL); + TRINITY_GUARD(ACE_Thread_Mutex, Lock); sLog->outDebug(LOG_FILTER_MAPS, "MapInstanced::CreateBattleground: map bg %d for %d created.", InstanceId, GetId()); diff --git a/src/server/game/Maps/MapInstanced.h b/src/server/game/Maps/MapInstanced.h index 1913f0add51..af303ed0e9e 100755 --- a/src/server/game/Maps/MapInstanced.h +++ b/src/server/game/Maps/MapInstanced.h @@ -43,17 +43,17 @@ class MapInstanced : public Map Map* FindMap(uint32 InstanceId) const { return _FindMap(InstanceId); } bool DestroyInstance(InstancedMaps::iterator &itr); - void AddGridMapReference(const GridPair &p) + void AddGridMapReference(const GridCoord &p) { ++GridMapReference[p.x_coord][p.y_coord]; - SetUnloadReferenceLock(GridPair(63-p.x_coord, 63-p.y_coord), true); + SetUnloadReferenceLock(GridCoord(63-p.x_coord, 63-p.y_coord), true); } - void RemoveGridMapReference(GridPair const& p) + void RemoveGridMapReference(GridCoord const& p) { --GridMapReference[p.x_coord][p.y_coord]; if (!GridMapReference[p.x_coord][p.y_coord]) - SetUnloadReferenceLock(GridPair(63-p.x_coord, 63-p.y_coord), false); + SetUnloadReferenceLock(GridCoord(63-p.x_coord, 63-p.y_coord), false); } InstancedMaps &GetInstancedMaps() { return m_InstancedMaps; } diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index 0b7abacad28..22eaa77cc94 100755 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -101,7 +101,7 @@ Map* MapManager::_createBaseMap(uint32 id) if (m == NULL) { - ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL); + TRINITY_GUARD(ACE_Thread_Mutex, Lock); const MapEntry* entry = sMapStore.LookupEntry(id); if (entry && entry->Instanceable()) @@ -248,7 +248,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) instaceIdToCheck = save->GetInstanceId(); // instanceId can never be 0 - will not be found - if (!player->CheckInstanceCount(instaceIdToCheck)) + if (!player->CheckInstanceCount(instaceIdToCheck) && !player->isDead()) { player->SendTransferAborted(mapid, TRANSFER_ABORT_TOO_MANY_INSTANCES); return false; @@ -292,7 +292,7 @@ void MapManager::DoDelayedMovesAndRemoves() bool MapManager::ExistMapAndVMap(uint32 mapid, float x, float y) { - GridPair p = Trinity::ComputeGridPair(x, y); + GridCoord p = Trinity::ComputeGridCoord(x, y); int gx=63-p.x_coord; int gy=63-p.y_coord; @@ -335,7 +335,7 @@ void MapManager::UnloadAll() uint32 MapManager::GetNumInstances() { - ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, 0); + TRINITY_GUARD(ACE_Thread_Mutex, Lock); uint32 ret = 0; for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr) @@ -352,7 +352,7 @@ uint32 MapManager::GetNumInstances() uint32 MapManager::GetNumPlayersInInstances() { - ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, 0); + TRINITY_GUARD(ACE_Thread_Mutex, Lock); uint32 ret = 0; for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr) diff --git a/src/server/game/Maps/MapUpdater.cpp b/src/server/game/Maps/MapUpdater.cpp index 7e6b2f03bd0..80025680753 100644 --- a/src/server/game/Maps/MapUpdater.cpp +++ b/src/server/game/Maps/MapUpdater.cpp @@ -81,7 +81,7 @@ int MapUpdater::deactivate() int MapUpdater::wait() { - ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, m_mutex, -1); + TRINITY_GUARD(ACE_Thread_Mutex, m_mutex); while (pending_requests > 0) m_condition.wait(); @@ -91,7 +91,7 @@ int MapUpdater::wait() int MapUpdater::schedule_update(Map& map, ACE_UINT32 diff) { - ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, m_mutex, -1); + TRINITY_GUARD(ACE_Thread_Mutex, m_mutex); ++pending_requests; @@ -113,7 +113,7 @@ bool MapUpdater::activated() void MapUpdater::update_finished() { - ACE_GUARD(ACE_Thread_Mutex, guard, m_mutex); + TRINITY_GUARD(ACE_Thread_Mutex, m_mutex); if (pending_requests == 0) { diff --git a/src/server/game/Miscellaneous/Formulas.h b/src/server/game/Miscellaneous/Formulas.h index f562010549b..cbcad520e5f 100755 --- a/src/server/game/Miscellaneous/Formulas.h +++ b/src/server/game/Miscellaneous/Formulas.h @@ -156,7 +156,7 @@ namespace Trinity return baseGain; } - inline uint32 Gain(Player* pl, Unit* u) + inline uint32 Gain(Player* player, Unit* u) { uint32 gain; @@ -167,7 +167,7 @@ namespace Trinity gain = 0; else { - gain = BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(), u->GetZoneId())); + gain = BaseGain(player->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(), u->GetZoneId())); if (gain != 0 && u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->isElite()) { @@ -181,7 +181,7 @@ namespace Trinity gain = uint32(gain * sWorld->getRate(RATE_XP_KILL)); } - sScriptMgr->OnGainCalculation(gain, pl, u); + sScriptMgr->OnGainCalculation(gain, player, u); return gain; } diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index fa18cd801a4..a99d0f37c02 100755 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -53,6 +53,7 @@ enum Gender // Race value is index in ChrRaces.dbc enum Races { + RACE_NONE = 0, RACE_HUMAN = 1, RACE_ORC = 2, RACE_DWARF = 3, @@ -408,7 +409,7 @@ enum SpellAttr3 enum SpellAttr4 { SPELL_ATTR4_UNK0 = 0x00000001, // 0 - SPELL_ATTR4_UNK1 = 0x00000002, // 1 proc on finishing move? + SPELL_ATTR4_PROC_ONLY_ON_DUMMY = 0x00000002, // 1 proc only on SPELL_EFFECT_DUMMY? SPELL_ATTR4_UNK2 = 0x00000004, // 2 SPELL_ATTR4_UNK3 = 0x00000008, // 3 SPELL_ATTR4_UNK4 = 0x00000010, // 4 This will no longer cause guards to attack on use?? @@ -2377,7 +2378,7 @@ enum QuestSort QUEST_SORT_ROGUE = 162, QUEST_SORT_ALCHEMY = 181, QUEST_SORT_LEATHERWORKING = 182, - QUEST_SORT_ENGINERING = 201, + QUEST_SORT_ENGINEERING = 201, QUEST_SORT_TREASURE_MAP = 221, QUEST_SORT_SUNKEN_TEMPLE_OLD = 241, QUEST_SORT_HUNTER = 261, @@ -2479,7 +2480,7 @@ enum SkillType SKILL_PET_IMP = 188, SKILL_PET_FELHUNTER = 189, SKILL_TAILORING = 197, - SKILL_ENGINERING = 202, + SKILL_ENGINEERING = 202, SKILL_PET_SPIDER = 203, SKILL_PET_VOIDWALKER = 204, SKILL_PET_SUCCUBUS = 205, @@ -2599,7 +2600,7 @@ inline uint32 SkillByQuestSort(int32 QuestSort) case QUEST_SORT_BLACKSMITHING: return SKILL_BLACKSMITHING; case QUEST_SORT_ALCHEMY: return SKILL_ALCHEMY; case QUEST_SORT_LEATHERWORKING: return SKILL_LEATHERWORKING; - case QUEST_SORT_ENGINERING: return SKILL_ENGINERING; + case QUEST_SORT_ENGINEERING: return SKILL_ENGINEERING; case QUEST_SORT_TAILORING: return SKILL_TAILORING; case QUEST_SORT_COOKING: return SKILL_COOKING; case QUEST_SORT_FIRST_AID: return SKILL_FIRST_AID; @@ -2815,7 +2816,8 @@ enum DiminishingGroup DIMINISHING_SILENCE = 16, DIMINISHING_SLEEP = 17, DIMINISHING_TAUNT = 18, - DIMINISHING_LIMITONLY = 19 + DIMINISHING_LIMITONLY = 19, + DIMINISHING_DRAGONS_BREATH = 20, }; enum SummonCategory diff --git a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp index 991b03c44e4..7c3b26c2646 100755 --- a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp @@ -29,10 +29,9 @@ #endif template<class T> -void -ConfusedMovementGenerator<T>::Initialize(T &unit) +void ConfusedMovementGenerator<T>::Initialize(T &unit) { - const float wander_distance = 11; + float const wanderDistance = 4; float x, y, z; x = unit.GetPositionX(); y = unit.GetPositionY(); @@ -47,8 +46,8 @@ ConfusedMovementGenerator<T>::Initialize(T &unit) for (uint8 idx = 0; idx <= MAX_CONF_WAYPOINTS; ++idx) { - float wanderX = x + wander_distance*(float)rand_norm() - wander_distance/2; - float wanderY = y + wander_distance*(float)rand_norm() - wander_distance/2; + float wanderX = x + wanderDistance * (float)rand_norm() - wanderDistance/2; + float wanderY = y + wanderDistance * (float)rand_norm() - wanderDistance/2; Trinity::NormalizeMapCoord(wanderX); Trinity::NormalizeMapCoord(wanderY); @@ -68,7 +67,7 @@ ConfusedMovementGenerator<T>::Initialize(T &unit) } // Taken from FleeingMovementGenerator - if (!(new_z - z) || wander_distance / fabs(new_z - z) > 1.0f) + if (!(new_z - z) || wanderDistance / fabs(new_z - z) > 1.0f) { i_waypoints[idx][0] = wanderX; i_waypoints[idx][1] = wanderY; @@ -89,29 +88,26 @@ ConfusedMovementGenerator<T>::Initialize(T &unit) unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); unit.CastStop(); unit.StopMoving(); - unit.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); + unit.AddUnitMovementFlag(MOVEMENTFLAG_WALKING); // Should actually be splineflag unit.AddUnitState(UNIT_STAT_CONFUSED); } template<> -void -ConfusedMovementGenerator<Creature>::_InitSpecific(Creature &creature, bool &is_water_ok, bool &is_land_ok) +void ConfusedMovementGenerator<Creature>::_InitSpecific(Creature &creature, bool &is_water_ok, bool &is_land_ok) { is_water_ok = creature.canSwim(); is_land_ok = creature.canWalk(); } template<> -void -ConfusedMovementGenerator<Player>::_InitSpecific(Player &, bool &is_water_ok, bool &is_land_ok) +void ConfusedMovementGenerator<Player>::_InitSpecific(Player &, bool &is_water_ok, bool &is_land_ok) { is_water_ok = true; is_land_ok = true; } template<class T> -void -ConfusedMovementGenerator<T>::Reset(T &unit) +void ConfusedMovementGenerator<T>::Reset(T &unit) { i_nextMove = 1; i_nextMoveTime.Reset(0); @@ -120,8 +116,7 @@ ConfusedMovementGenerator<T>::Reset(T &unit) } template<class T> -bool -ConfusedMovementGenerator<T>::Update(T &unit, const uint32 diff) +bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 diff) { if (!&unit) return true; @@ -141,7 +136,7 @@ ConfusedMovementGenerator<T>::Update(T &unit, const uint32 diff) unit.ClearUnitState(UNIT_STAT_MOVE); i_nextMove = urand(1, MAX_CONF_WAYPOINTS); - i_nextMoveTime.Reset(urand(0, 1500-1)); // TODO: check the minimum reset time, should be probably higher + i_nextMoveTime.Reset(urand(100, 1000)); } } } @@ -164,11 +159,11 @@ ConfusedMovementGenerator<T>::Update(T &unit, const uint32 diff) } template<class T> -void -ConfusedMovementGenerator<T>::Finalize(T &unit) +void ConfusedMovementGenerator<T>::Finalize(T &unit) { unit.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); unit.ClearUnitState(UNIT_STAT_CONFUSED); + if (unit.GetTypeId() == TYPEID_UNIT && unit.getVictim()) unit.SetTarget(unit.getVictim()->GetGUID()); } diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp index 3d7a65a4ccc..6d5c803bea8 100755 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp @@ -58,6 +58,10 @@ bool PointMovementGenerator<T>::Update(T &unit, const uint32 diff) arrived = true; return false; } + else if (!unit.HasUnitState(UNIT_STAT_MOVE) && !unit.HasUnitState(UNIT_STAT_JUMPING)) + { + i_destinationHolder.StartTravel(traveller); + } return true; } diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index 4ad2f0638d0..808d8318ea9 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -206,7 +206,13 @@ WaypointMovementGenerator<Creature>::Update(Creature &unit, const uint32 diff) MovementInform(unit); unit.UpdateWaypointID(i_currentNode); unit.ClearUnitState(UNIT_STAT_ROAMING); - unit.Relocate(node->x, node->y, node->z); + if (node->orientation) + { + unit.Relocate(node->x, node->y, node->z, node->orientation); + unit.SetFacing(node->orientation, NULL); + } + else + unit.Relocate(node->x, node->y, node->z); } } else @@ -266,7 +272,7 @@ void FlightPathMovementGenerator::Finalize(Player & player) float y = 0; float z = 0; i_destinationHolder.GetLocationNow(player.GetBaseMap(), x, y, z); - player.SetPosition(x, y, z, player.GetOrientation()); + player.UpdatePosition(x, y, z, player.GetOrientation()); } diff --git a/src/server/game/Movement/Traveller.h b/src/server/game/Movement/Traveller.h index 27700eb61c4..9cd6a6cda17 100755 --- a/src/server/game/Movement/Traveller.h +++ b/src/server/game/Movement/Traveller.h @@ -85,7 +85,7 @@ inline float Traveller<Creature>::Speed() template<> inline void Traveller<Creature>::Relocation(float x, float y, float z, float orientation) { - i_traveller.SetPosition(x, y, z, orientation); + i_traveller.UpdatePosition(x, y, z, orientation); } template<> @@ -136,7 +136,7 @@ inline float Traveller<Player>::GetMoveDestinationTo(float x, float y, float z) template<> inline void Traveller<Player>::Relocation(float x, float y, float z, float orientation) { - i_traveller.SetPosition(x, y, z, orientation); + i_traveller.UpdatePosition(x, y, z, orientation); } template<> diff --git a/src/server/game/Movement/Waypoints/WaypointManager.cpp b/src/server/game/Movement/Waypoints/WaypointManager.cpp index 0ce2a097422..2859fb9227b 100755 --- a/src/server/game/Movement/Waypoints/WaypointManager.cpp +++ b/src/server/game/Movement/Waypoints/WaypointManager.cpp @@ -43,7 +43,7 @@ void WaypointMgr::Load() { uint32 oldMSTime = getMSTime(); - QueryResult result = WorldDatabase.Query("SELECT id, point, position_x, position_y, position_z, move_flag, delay, action, action_chance FROM waypoint_data ORDER BY id, point"); + QueryResult result = WorldDatabase.Query("SELECT id, point, position_x, position_y, position_z, orientation, move_flag, delay, action, action_chance FROM waypoint_data ORDER BY id, point"); if (!result) { @@ -65,6 +65,7 @@ void WaypointMgr::Load() float x = fields[2].GetFloat(); float y = fields[3].GetFloat(); float z = fields[4].GetFloat(); + float o = fields[5].GetFloat(); Trinity::NormalizeMapCoord(x); Trinity::NormalizeMapCoord(y); @@ -73,10 +74,11 @@ void WaypointMgr::Load() wp->x = x; wp->y = y; wp->z = z; - wp->run = fields[5].GetBool(); - wp->delay = fields[6].GetUInt32(); - wp->event_id = fields[7].GetUInt32(); - wp->event_chance = fields[8].GetUInt8(); + wp->orientation = o; + wp->run = fields[6].GetBool(); + wp->delay = fields[7].GetUInt32(); + wp->event_id = fields[8].GetUInt32(); + wp->event_chance = fields[9].GetUInt8(); path.push_back(wp); ++count; @@ -98,7 +100,7 @@ void WaypointMgr::ReloadPath(uint32 id) _waypointStore.erase(itr); } - QueryResult result = WorldDatabase.PQuery("SELECT point, position_x, position_y, position_z, move_flag, delay, action, action_chance FROM waypoint_data WHERE id = %u ORDER BY point", id); + QueryResult result = WorldDatabase.PQuery("SELECT point, position_x, position_y, position_z, orientation, move_flag, delay, action, action_chance FROM waypoint_data WHERE id = %u ORDER BY point", id); if (!result) return; @@ -112,6 +114,7 @@ void WaypointMgr::ReloadPath(uint32 id) float x = fields[1].GetFloat(); float y = fields[2].GetFloat(); float z = fields[3].GetFloat(); + float o = fields[4].GetFloat(); Trinity::NormalizeMapCoord(x); Trinity::NormalizeMapCoord(y); @@ -120,10 +123,11 @@ void WaypointMgr::ReloadPath(uint32 id) wp->x = x; wp->y = y; wp->z = z; - wp->run = fields[4].GetBool(); - wp->delay = fields[5].GetUInt32(); - wp->event_id = fields[6].GetUInt32(); - wp->event_chance = fields[7].GetUInt8(); + wp->orientation = o; + wp->run = fields[5].GetBool(); + wp->delay = fields[6].GetUInt32(); + wp->event_id = fields[7].GetUInt32(); + wp->event_chance = fields[8].GetUInt8(); path.push_back(wp); diff --git a/src/server/game/Movement/Waypoints/WaypointManager.h b/src/server/game/Movement/Waypoints/WaypointManager.h index 4b374984232..be4a0c8f9bf 100755 --- a/src/server/game/Movement/Waypoints/WaypointManager.h +++ b/src/server/game/Movement/Waypoints/WaypointManager.h @@ -26,7 +26,7 @@ struct WaypointData { uint32 id; - float x, y, z; + float x, y, z, orientation; bool run; uint32 delay; uint32 event_id; diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp index b925150ef71..d641971faa0 100755 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -36,22 +36,22 @@ m_State(OBJECTIVESTATE_NEUTRAL), m_neutralValuePct(0), m_PvP(pvp) { } -bool OPvPCapturePoint::HandlePlayerEnter(Player* plr) +bool OPvPCapturePoint::HandlePlayerEnter(Player* player) { if (m_capturePoint) { - plr->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 1); - plr->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)); - plr->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct); + player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 1); + player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)); + player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct); } - return m_activePlayers[plr->GetTeamId()].insert(plr).second; + return m_activePlayers[player->GetTeamId()].insert(player).second; } -void OPvPCapturePoint::HandlePlayerLeave(Player* plr) +void OPvPCapturePoint::HandlePlayerLeave(Player* player) { if (m_capturePoint) - plr->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 0); - m_activePlayers[plr->GetTeamId()].erase(plr); + player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 0); + m_activePlayers[player->GetTeamId()].erase(player); } void OPvPCapturePoint::SendChangePhase() @@ -239,24 +239,24 @@ OutdoorPvP::~OutdoorPvP() DeleteSpawns(); } -void OutdoorPvP::HandlePlayerEnterZone(Player* plr, uint32 /*zone*/) +void OutdoorPvP::HandlePlayerEnterZone(Player* player, uint32 /*zone*/) { - m_players[plr->GetTeamId()].insert(plr); + m_players[player->GetTeamId()].insert(player); } -void OutdoorPvP::HandlePlayerLeaveZone(Player* plr, uint32 /*zone*/) +void OutdoorPvP::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/) { // inform the objectives of the leaving for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) - itr->second->HandlePlayerLeave(plr); + itr->second->HandlePlayerLeave(player); // remove the world state information from the player (we can't keep everyone up to date, so leave out those who are not in the concerning zones) - if (!plr->GetSession()->PlayerLogout()) - SendRemoveWorldStates(plr); - m_players[plr->GetTeamId()].erase(plr); - sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %s left an outdoorpvp zone", plr->GetName()); + if (!player->GetSession()->PlayerLogout()) + SendRemoveWorldStates(player); + m_players[player->GetTeamId()].erase(player); + sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %s left an outdoorpvp zone", player->GetName()); } -void OutdoorPvP::HandlePlayerResurrects(Player* /*plr*/, uint32 /*zone*/) +void OutdoorPvP::HandlePlayerResurrects(Player* /*player*/, uint32 /*zone*/) { } @@ -463,88 +463,88 @@ void OutdoorPvP::HandleKill(Player* killer, Unit* killed) } } -bool OutdoorPvP::IsInsideObjective(Player* plr) const +bool OutdoorPvP::IsInsideObjective(Player* player) const { for (OPvPCapturePointMap::const_iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) - if (itr->second->IsInsideObjective(plr)) + if (itr->second->IsInsideObjective(player)) return true; return false; } -bool OPvPCapturePoint::IsInsideObjective(Player* plr) const +bool OPvPCapturePoint::IsInsideObjective(Player* player) const { - return m_activePlayers[plr->GetTeamId()].find(plr) != m_activePlayers[plr->GetTeamId()].end(); + return m_activePlayers[player->GetTeamId()].find(player) != m_activePlayers[player->GetTeamId()].end(); } -bool OutdoorPvP::HandleCustomSpell(Player* plr, uint32 spellId, GameObject* go) +bool OutdoorPvP::HandleCustomSpell(Player* player, uint32 spellId, GameObject* go) { for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) - if (itr->second->HandleCustomSpell(plr, spellId, go)) + if (itr->second->HandleCustomSpell(player, spellId, go)) return true; return false; } -bool OPvPCapturePoint::HandleCustomSpell(Player* plr, uint32 /*spellId*/, GameObject* /*go*/) +bool OPvPCapturePoint::HandleCustomSpell(Player* player, uint32 /*spellId*/, GameObject* /*go*/) { - if (!plr->IsOutdoorPvPActive()) + if (!player->IsOutdoorPvPActive()) return false; return false; } -bool OutdoorPvP::HandleOpenGo(Player* plr, uint64 guid) +bool OutdoorPvP::HandleOpenGo(Player* player, uint64 guid) { for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) - if (itr->second->HandleOpenGo(plr, guid) >= 0) + if (itr->second->HandleOpenGo(player, guid) >= 0) return true; return false; } -bool OutdoorPvP::HandleGossipOption(Player* plr, uint64 guid, uint32 id) +bool OutdoorPvP::HandleGossipOption(Player* player, uint64 guid, uint32 id) { for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) - if (itr->second->HandleGossipOption(plr, guid, id)) + if (itr->second->HandleGossipOption(player, guid, id)) return true; return false; } -bool OutdoorPvP::CanTalkTo(Player* plr, Creature* c, GossipMenuItems const& gso) +bool OutdoorPvP::CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso) { for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) - if (itr->second->CanTalkTo(plr, c, gso)) + if (itr->second->CanTalkTo(player, c, gso)) return true; return false; } -bool OutdoorPvP::HandleDropFlag(Player* plr, uint32 id) +bool OutdoorPvP::HandleDropFlag(Player* player, uint32 id) { for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr) - if (itr->second->HandleDropFlag(plr, id)) + if (itr->second->HandleDropFlag(player, id)) return true; return false; } -bool OPvPCapturePoint::HandleGossipOption(Player* /*plr*/, uint64 /*guid*/, uint32 /*id*/) +bool OPvPCapturePoint::HandleGossipOption(Player* /*player*/, uint64 /*guid*/, uint32 /*id*/) { return false; } -bool OPvPCapturePoint::CanTalkTo(Player* /*plr*/, Creature* /*c*/, GossipMenuItems const& /*gso*/) +bool OPvPCapturePoint::CanTalkTo(Player* /*player*/, Creature* /*c*/, GossipMenuItems const& /*gso*/) { return false; } -bool OPvPCapturePoint::HandleDropFlag(Player* /*plr*/, uint32 /*id*/) +bool OPvPCapturePoint::HandleDropFlag(Player* /*player*/, uint32 /*id*/) { return false; } -int32 OPvPCapturePoint::HandleOpenGo(Player* /*plr*/, uint64 guid) +int32 OPvPCapturePoint::HandleOpenGo(Player* /*player*/, uint64 guid) { std::map<uint64, uint32>::iterator itr = m_ObjectTypes.find(guid); if (itr != m_ObjectTypes.end()) @@ -554,7 +554,7 @@ int32 OPvPCapturePoint::HandleOpenGo(Player* /*plr*/, uint64 guid) return -1; } -bool OutdoorPvP::HandleAreaTrigger(Player* /*plr*/, uint32 /*trigger*/) +bool OutdoorPvP::HandleAreaTrigger(Player* /*player*/, uint32 /*trigger*/) { return false; } @@ -572,9 +572,9 @@ void OutdoorPvP::RegisterZone(uint32 zoneId) sOutdoorPvPMgr->AddZone(zoneId, this); } -bool OutdoorPvP::HasPlayer(Player* plr) const +bool OutdoorPvP::HasPlayer(Player* player) const { - return m_players[plr->GetTeamId()].find(plr) != m_players[plr->GetTeamId()].end(); + return m_players[player->GetTeamId()].find(player) != m_players[player->GetTeamId()].end(); } void OutdoorPvP::TeamCastSpell(TeamId team, int32 spellId) diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.h b/src/server/game/OutdoorPvP/OutdoorPvP.h index 1969d1f98e1..c57eddc7f86 100755 --- a/src/server/game/OutdoorPvP/OutdoorPvP.h +++ b/src/server/game/OutdoorPvP/OutdoorPvP.h @@ -104,15 +104,15 @@ class OPvPCapturePoint void SendObjectiveComplete(uint32 id, uint64 guid); // used when player is activated/inactivated in the area - virtual bool HandlePlayerEnter(Player* plr); - virtual void HandlePlayerLeave(Player* plr); + virtual bool HandlePlayerEnter(Player* player); + virtual void HandlePlayerLeave(Player* player); // checks if player is in range of a capture credit marker - bool IsInsideObjective(Player* plr) const; + bool IsInsideObjective(Player* player) const; - virtual bool HandleCustomSpell(Player* plr, uint32 spellId, GameObject* go); + virtual bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go); - virtual int32 HandleOpenGo(Player* plr, uint64 guid); + virtual int32 HandleOpenGo(Player* player, uint64 guid); // returns true if the state of the objective has changed, in this case, the OutdoorPvP must send a world state ui update. virtual bool Update(uint32 diff); @@ -123,11 +123,11 @@ class OPvPCapturePoint virtual void SendChangePhase(); - virtual bool HandleGossipOption(Player* plr, uint64 guid, uint32 gossipid); + virtual bool HandleGossipOption(Player* player, uint64 guid, uint32 gossipid); - virtual bool CanTalkTo(Player* plr, Creature* c, GossipMenuItems const& gso); + virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso); - virtual bool HandleDropFlag(Player* plr, uint32 spellId); + virtual bool HandleDropFlag(Player* player, uint32 spellId); virtual void DeleteSpawns(); @@ -208,13 +208,13 @@ class OutdoorPvP : public ZoneScript virtual void FillInitialWorldStates(WorldPacket & /*data*/) {} // called when a player triggers an areatrigger - virtual bool HandleAreaTrigger(Player* plr, uint32 trigger); + virtual bool HandleAreaTrigger(Player* player, uint32 trigger); // called on custom spell - virtual bool HandleCustomSpell(Player* plr, uint32 spellId, GameObject* go); + virtual bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go); // called on go use - virtual bool HandleOpenGo(Player* plr, uint64 guid); + virtual bool HandleOpenGo(Player* player, uint64 guid); // setup stuff virtual bool SetupOutdoorPvP() {return true;} @@ -234,18 +234,18 @@ class OutdoorPvP : public ZoneScript virtual void HandleKillImpl(Player* /*killer*/, Unit* /*killed*/) {} // checks if player is in range of a capture credit marker - bool IsInsideObjective(Player* plr) const; + bool IsInsideObjective(Player* player) const; // awards rewards for player kill - virtual void AwardKillBonus(Player* /*plr*/) {} + virtual void AwardKillBonus(Player* /*player*/) {} uint32 GetTypeId() {return m_TypeId;} - virtual bool HandleDropFlag(Player* plr, uint32 spellId); + virtual bool HandleDropFlag(Player* player, uint32 spellId); - virtual bool HandleGossipOption(Player* plr, uint64 guid, uint32 gossipid); + virtual bool HandleGossipOption(Player* player, uint64 guid, uint32 gossipid); - virtual bool CanTalkTo(Player* plr, Creature* c, GossipMenuItems const& gso); + virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso); void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2 = 0); @@ -261,14 +261,14 @@ class OutdoorPvP : public ZoneScript bool m_sendUpdate; // world state stuff - virtual void SendRemoveWorldStates(Player* /*plr*/) {} + virtual void SendRemoveWorldStates(Player* /*player*/) {} void BroadcastPacket(WorldPacket & data) const; - virtual void HandlePlayerEnterZone(Player* plr, uint32 zone); - virtual void HandlePlayerLeaveZone(Player* plr, uint32 zone); + virtual void HandlePlayerEnterZone(Player* player, uint32 zone); + virtual void HandlePlayerLeaveZone(Player* player, uint32 zone); - virtual void HandlePlayerResurrects(Player* plr, uint32 zone); + virtual void HandlePlayerResurrects(Player* player, uint32 zone); void AddCapturePoint(OPvPCapturePoint* cp) { @@ -285,7 +285,7 @@ class OutdoorPvP : public ZoneScript void RegisterZone(uint32 zoneid); - bool HasPlayer(Player* plr) const; + bool HasPlayer(Player* player) const; void TeamCastSpell(TeamId team, int32 spellId); }; diff --git a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp index dda0e7bcb61..4a0da1d3b55 100755 --- a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp @@ -115,31 +115,31 @@ void OutdoorPvPMgr::AddZone(uint32 zoneid, OutdoorPvP* handle) m_OutdoorPvPMap[zoneid] = handle; } -void OutdoorPvPMgr::HandlePlayerEnterZone(Player* plr, uint32 zoneid) +void OutdoorPvPMgr::HandlePlayerEnterZone(Player* player, uint32 zoneid) { OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid); if (itr == m_OutdoorPvPMap.end()) return; - if (itr->second->HasPlayer(plr)) + if (itr->second->HasPlayer(player)) return; - itr->second->HandlePlayerEnterZone(plr, zoneid); - sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %u entered outdoorpvp id %u", plr->GetGUIDLow(), itr->second->GetTypeId()); + itr->second->HandlePlayerEnterZone(player, zoneid); + sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %u entered outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId()); } -void OutdoorPvPMgr::HandlePlayerLeaveZone(Player* plr, uint32 zoneid) +void OutdoorPvPMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneid) { OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid); if (itr == m_OutdoorPvPMap.end()) return; // teleport: remove once in removefromworld, once in updatezone - if (!itr->second->HasPlayer(plr)) + if (!itr->second->HasPlayer(player)) return; - itr->second->HandlePlayerLeaveZone(plr, zoneid); - sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %u left outdoorpvp id %u", plr->GetGUIDLow(), itr->second->GetTypeId()); + itr->second->HandlePlayerLeaveZone(player, zoneid); + sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %u left outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId()); } OutdoorPvP* OutdoorPvPMgr::GetOutdoorPvPToZoneId(uint32 zoneid) @@ -164,11 +164,11 @@ void OutdoorPvPMgr::Update(uint32 diff) } } -bool OutdoorPvPMgr::HandleCustomSpell(Player* plr, uint32 spellId, GameObject* go) +bool OutdoorPvPMgr::HandleCustomSpell(Player* player, uint32 spellId, GameObject* go) { for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr) { - if ((*itr)->HandleCustomSpell(plr, spellId, go)) + if ((*itr)->HandleCustomSpell(player, spellId, go)) return true; } return false; @@ -183,21 +183,21 @@ ZoneScript* OutdoorPvPMgr::GetZoneScript(uint32 zoneId) return NULL; } -bool OutdoorPvPMgr::HandleOpenGo(Player* plr, uint64 guid) +bool OutdoorPvPMgr::HandleOpenGo(Player* player, uint64 guid) { for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr) { - if ((*itr)->HandleOpenGo(plr, guid)) + if ((*itr)->HandleOpenGo(player, guid)) return true; } return false; } -void OutdoorPvPMgr::HandleGossipOption(Player* plr, uint64 guid, uint32 gossipid) +void OutdoorPvPMgr::HandleGossipOption(Player* player, uint64 guid, uint32 gossipid) { for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr) { - if ((*itr)->HandleGossipOption(plr, guid, gossipid)) + if ((*itr)->HandleGossipOption(player, guid, gossipid)) return; } } @@ -212,21 +212,21 @@ bool OutdoorPvPMgr::CanTalkTo(Player* player, Creature* creature, GossipMenuItem return false; } -void OutdoorPvPMgr::HandleDropFlag(Player* plr, uint32 spellId) +void OutdoorPvPMgr::HandleDropFlag(Player* player, uint32 spellId) { for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr) { - if ((*itr)->HandleDropFlag(plr, spellId)) + if ((*itr)->HandleDropFlag(player, spellId)) return; } } -void OutdoorPvPMgr::HandlePlayerResurrects(Player* plr, uint32 zoneid) +void OutdoorPvPMgr::HandlePlayerResurrects(Player* player, uint32 zoneid) { OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid); if (itr == m_OutdoorPvPMap.end()) return; - if (itr->second->HasPlayer(plr)) - itr->second->HandlePlayerResurrects(plr, zoneid); + if (itr->second->HasPlayer(player)) + itr->second->HandlePlayerResurrects(player, zoneid); } diff --git a/src/server/game/OutdoorPvP/OutdoorPvPMgr.h b/src/server/game/OutdoorPvP/OutdoorPvPMgr.h index 6f0e0ba91b9..32639cb692e 100755 --- a/src/server/game/OutdoorPvP/OutdoorPvPMgr.h +++ b/src/server/game/OutdoorPvP/OutdoorPvPMgr.h @@ -49,22 +49,22 @@ class OutdoorPvPMgr void InitOutdoorPvP(); // called when a player enters an outdoor pvp area - void HandlePlayerEnterZone(Player* plr, uint32 areaflag); + void HandlePlayerEnterZone(Player* player, uint32 areaflag); // called when player leaves an outdoor pvp area - void HandlePlayerLeaveZone(Player* plr, uint32 areaflag); + void HandlePlayerLeaveZone(Player* player, uint32 areaflag); // called when player resurrects - void HandlePlayerResurrects(Player* plr, uint32 areaflag); + void HandlePlayerResurrects(Player* player, uint32 areaflag); // return assigned outdoor pvp OutdoorPvP* GetOutdoorPvPToZoneId(uint32 zoneid); // handle custom (non-exist in dbc) spell if registered - bool HandleCustomSpell(Player* plr, uint32 spellId, GameObject* go); + bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go); // handle custom go if registered - bool HandleOpenGo(Player* plr, uint64 guid); + bool HandleOpenGo(Player* player, uint64 guid); ZoneScript* GetZoneScript(uint32 zoneId); @@ -76,7 +76,7 @@ class OutdoorPvPMgr bool CanTalkTo(Player* player, Creature* creature, GossipMenuItems const& gso); - void HandleDropFlag(Player* plr, uint32 spellId); + void HandleDropFlag(Player* player, uint32 spellId); private: typedef std::vector<OutdoorPvP*> OutdoorPvPSet; diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp index 03accce42ed..bbef60aa5e7 100755 --- a/src/server/game/Pools/PoolMgr.cpp +++ b/src/server/game/Pools/PoolMgr.cpp @@ -260,7 +260,7 @@ void PoolGroup<Quest>::Despawn1Object(uint32 quest_id) QuestRelations::iterator lastElement = questMap->upper_bound(itr->second); for (; qitr != lastElement; ++qitr) { - if (qitr->first == itr->second) + if (qitr->first == itr->second && qitr->second == itr->first) { questMap->erase(qitr); // iterator is now no more valid break; // but we can exit loop since the element is found @@ -279,7 +279,7 @@ void PoolGroup<Quest>::Despawn1Object(uint32 quest_id) QuestRelations::iterator lastElement = questMap->upper_bound(itr->second); for (; qitr != lastElement; ++qitr) { - if (qitr->first == itr->second) + if (qitr->first == itr->second && qitr->second == itr->first) { questMap->erase(qitr); // iterator is now no more valid break; // but we can exit loop since the element is found @@ -361,7 +361,7 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj) // Spawn if necessary (loaded grids only) Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(data->mapid)); // We use spawn coords to spawn - if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY)) + if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY)) { Creature* creature = new Creature; //sLog->outDebug(LOG_FILTER_POOLSYS, "Spawning creature %u", guid); @@ -371,7 +371,7 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj) return; } else - map->Add(creature); + map->AddToMap(creature); } } } @@ -387,7 +387,7 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj) // this base map checked as non-instanced and then only existed Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(data->mapid)); // We use current coords to unspawn, not spawn coords since creature can have changed grid - if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY)) + if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY)) { GameObject* pGameobject = new GameObject; //sLog->outDebug(LOG_FILTER_POOLSYS, "Spawning gameobject %u", guid); @@ -399,7 +399,7 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj) else { if (pGameobject->isSpawnedByDefault()) - map->Add(pGameobject); + map->AddToMap(pGameobject); } } } @@ -507,7 +507,7 @@ void PoolGroup<Creature>::ReSpawn1Object(PoolObject* obj) { if (CreatureData const* data = sObjectMgr->GetCreatureData(obj->guid)) if (Creature* creature = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_UNIT), (Creature*)NULL)) - creature->GetMap()->Add(creature); + creature->GetMap()->AddToMap(creature); } // Method that does the respawn job on the specified gameobject @@ -516,7 +516,7 @@ void PoolGroup<GameObject>::ReSpawn1Object(PoolObject* obj) { if (GameObjectData const* data = sObjectMgr->GetGOData(obj->guid)) if (GameObject* pGameobject = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)NULL)) - pGameobject->GetMap()->Add(pGameobject); + pGameobject->GetMap()->AddToMap(pGameobject); } // Nothing to do for a child Pool diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp index a1a1f5d5cac..9650afb60e2 100755 --- a/src/server/game/Quests/QuestDef.cpp +++ b/src/server/game/Quests/QuestDef.cpp @@ -205,6 +205,11 @@ int32 Quest::GetRewOrReqMoney() const return int32(RewOrReqMoney * sWorld->getRate(RATE_DROP_MONEY)); } +bool Quest::IsAutoComplete() const +{ + return QuestMethod == 0 || HasFlag(QUEST_FLAGS_AUTOCOMPLETE); +} + bool Quest::IsAllowedInRaid() const { if (IsRaidQuest()) diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h index 61d492ce88c..90e52660160 100755 --- a/src/server/game/Quests/QuestDef.h +++ b/src/server/game/Quests/QuestDef.h @@ -246,7 +246,7 @@ class Quest uint32 GetQuestStartScript() const { return QuestStartScript; } uint32 GetQuestCompleteScript() const { return QuestCompleteScript; } bool IsRepeatable() const { return QuestFlags & QUEST_TRINITY_FLAGS_REPEATABLE; } - bool IsAutoComplete() const { return QuestMethod ? false : true; } + bool IsAutoComplete() const; uint32 GetFlags() const { return QuestFlags; } bool IsDaily() const { return QuestFlags & QUEST_FLAGS_DAILY; } bool IsWeekly() const { return QuestFlags & QUEST_FLAGS_WEEKLY; } diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp index 2f849116f81..c4c8dec5500 100755 --- a/src/server/game/Reputation/ReputationMgr.cpp +++ b/src/server/game/Reputation/ReputationMgr.cpp @@ -358,7 +358,7 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in if (incremental) { // int32 *= float cause one point loss? - standing = int32(floor((float)standing * sWorld->getRate(RATE_REPUTATION_GAIN) + 0.5)); + standing = int32(floor((float)standing * sWorld->getRate(RATE_REPUTATION_GAIN) + 0.5f)); standing += itr->second.Standing + BaseRep; } diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index 3ded63fe812..88c9795e896 100755 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -266,21 +266,20 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script } } -inline GameObject* Map::_FindGameObject(WorldObject* pSearchObject, uint32 guid) const +inline GameObject* Map::_FindGameObject(WorldObject* searchObject, uint32 guid) const { - GameObject* pGameObject = NULL; + GameObject* gameobject = NULL; - CellPair p(Trinity::ComputeCellPair(pSearchObject->GetPositionX(), pSearchObject->GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - Trinity::GameObjectWithDbGUIDCheck goCheck(*pSearchObject, guid); - Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(pSearchObject, pGameObject, goCheck); + Trinity::GameObjectWithDbGUIDCheck goCheck(*searchObject, guid); + Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(searchObject, gameobject, goCheck); TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > objectChecker(checker); - cell.Visit(p, objectChecker, *pSearchObject->GetMap()); + cell.Visit(p, objectChecker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange()); - return pGameObject; + return gameobject; } /// Process queued scripts @@ -539,8 +538,8 @@ void Map::ScriptsProcess() // when script called for item spell casting then target == (unit or GO) and source is player WorldObject* worldObject; - Player* pTarget = target->ToPlayer(); - if (pTarget) + Player* plrTarget = target->ToPlayer(); + if (plrTarget) { if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER) { @@ -552,8 +551,8 @@ void Map::ScriptsProcess() } else { - pTarget = source->ToPlayer(); - if (target) + plrTarget = source->ToPlayer(); + if (plrTarget) { if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER) { @@ -566,19 +565,18 @@ void Map::ScriptsProcess() else { sLog->outError("%s neither source nor target is player (source: TypeId: %u, Entry: %u, GUID: %u; target: TypeId: %u, Entry: %u, GUID: %u), skipping.", - step.script->GetDebugInfo().c_str(), - source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUIDLow() : 0, - target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUIDLow() : 0); + step.script->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow(), + target->GetTypeId(), target->GetEntry(), target->GetGUIDLow()); break; } } // quest id and flags checked at script loading if ((worldObject->GetTypeId() != TYPEID_UNIT || ((Unit*)worldObject)->isAlive()) && - (step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(pTarget, float(step.script->QuestExplored.Distance)))) - pTarget->AreaExploredOrEventHappens(step.script->QuestExplored.QuestID); + (step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(plrTarget, float(step.script->QuestExplored.Distance)))) + plrTarget->AreaExploredOrEventHappens(step.script->QuestExplored.QuestID); else - pTarget->FailQuest(step.script->QuestExplored.QuestID); + plrTarget->FailQuest(step.script->QuestExplored.QuestID); break; } @@ -628,7 +626,7 @@ void Map::ScriptsProcess() pGO->SetLootState(GO_READY); pGO->SetRespawnTime(nTimeToDespawn); - pGO->GetMap()->Add(pGO); + pGO->GetMap()->AddToMap(pGO); } } break; @@ -819,15 +817,14 @@ void Map::ScriptsProcess() { WorldObject* wSource = dynamic_cast <WorldObject*> (source); - CellPair p(Trinity::ComputeCellPair(wSource->GetPositionX(), wSource->GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(wSource->GetPositionX(), wSource->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; Trinity::CreatureWithDbGUIDCheck target_check(wSource, step.script->CallScript.CreatureEntry); Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(wSource, cTarget, target_check); TypeContainerVisitor<Trinity::CreatureSearcher <Trinity::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker); - cell.Visit(p, unit_checker, *wSource->GetMap()); + cell.Visit(p, unit_checker, *wSource->GetMap(), *wSource, wSource->GetGridActivationRange()); } else //check hashmap holders { diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 120227c172d..925b352e616 100755 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -295,7 +295,6 @@ void ScriptMgr::Unload() void ScriptMgr::LoadDatabase() { - sScriptSystemMgr->LoadVersion(); sScriptSystemMgr->LoadScriptTexts(); sScriptSystemMgr->LoadScriptTextsCustom(); sScriptSystemMgr->LoadScriptWaypoints(); diff --git a/src/server/game/Scripting/ScriptSystem.cpp b/src/server/game/Scripting/ScriptSystem.cpp index 8c6f5626101..d0f9a0380b0 100755 --- a/src/server/game/Scripting/ScriptSystem.cpp +++ b/src/server/game/Scripting/ScriptSystem.cpp @@ -23,25 +23,6 @@ ScriptPointVector const SystemMgr::_empty; -void SystemMgr::LoadVersion() -{ - // Get Version information - QueryResult result = WorldDatabase.Query("SELECT script_version FROM version LIMIT 1"); - - if (result) - { - Field* fields = result->Fetch(); - - sLog->outString("TSCR: Database version is: %s", fields[0].GetCString()); - sLog->outString(); - } - else - { - sLog->outError("TSCR: Missing `version`.`script_version` information."); - sLog->outString(); - } -} - void SystemMgr::LoadScriptTexts() { sLog->outString("TSCR: Loading Script Texts..."); diff --git a/src/server/game/Scripting/ScriptSystem.h b/src/server/game/Scripting/ScriptSystem.h index a17033dc920..daa7fe0d596 100644 --- a/src/server/game/Scripting/ScriptSystem.h +++ b/src/server/game/Scripting/ScriptSystem.h @@ -64,7 +64,6 @@ class SystemMgr typedef UNORDERED_MAP<uint32, ScriptPointVector> PointMoveMap; //Database - void LoadVersion(); void LoadScriptTexts(); void LoadScriptTextsCustom(); void LoadScriptWaypoints(); diff --git a/src/server/game/Server/Protocol/Handlers/AuctionHouseHandler.cpp b/src/server/game/Server/Protocol/Handlers/AuctionHouseHandler.cpp index a67006382ff..2f8a27740be 100755 --- a/src/server/game/Server/Protocol/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/AuctionHouseHandler.cpp @@ -125,7 +125,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) recv_data >> buyout; recv_data >> etime; - Player* pl = GetPlayer(); + Player* player = GetPlayer(); if (!item || !bid || !etime) return; //check for cheaters @@ -162,11 +162,11 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) if (GetPlayer()->HasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - Item* it = pl->GetItemByGuid(item); + Item* it = player->GetItemByGuid(item); //do not allow to sell already auctioned items if (sAuctionMgr->GetAItem(GUID_LOPART(item))) { - sLog->outError("AuctionError, player %s is sending item id: %u, but item is already in another auction", pl->GetName(), GUID_LOPART(item)); + sLog->outError("AuctionError, player %s is sending item id: %u, but item is already in another auction", player->GetName(), GUID_LOPART(item)); SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR); return; } @@ -199,7 +199,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) //we have to take deposit : uint32 deposit = sAuctionMgr->GetAuctionDeposit(auctionHouseEntry, etime, it, count); - if (!pl->HasEnoughMoney(deposit)) + if (!player->HasEnoughMoney(deposit)) { SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_NOT_ENOUGHT_MONEY); return; @@ -211,7 +211,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) GetPlayerName(), GetAccountId(), it->GetTemplate()->Name1.c_str(), it->GetEntry(), count); } - pl->ModifyMoney(-int32(deposit)); + player->ModifyMoney(-int32(deposit)); uint32 auction_time = uint32(etime * sWorld->getRate(RATE_AUCTION_TIME)); @@ -223,7 +223,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) AH->auctioneer = GUID_LOPART(auctioneer); AH->item_guidlow = GUID_LOPART(item); AH->item_template = it->GetEntry(); - AH->owner = pl->GetGUIDLow(); + AH->owner = player->GetGUIDLow(); AH->startbid = bid; AH->bidder = 0; AH->bid = 0; @@ -236,13 +236,13 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) sAuctionMgr->AddAItem(it); auctionHouse->AddAuction(AH); - pl->MoveItemFromInventory(it->GetBagSlot(), it->GetSlot(), true); + player->MoveItemFromInventory(it->GetBagSlot(), it->GetSlot(), true); SQLTransaction trans = CharacterDatabase.BeginTransaction(); it->DeleteFromInventoryDB(trans); it->SaveToDB(trans); // recursive and not have transaction guard into self, not in inventiory and can be save standalone AH->SaveToDB(trans); - pl->SaveInventoryAndGoldToDB(trans); + player->SaveInventoryAndGoldToDB(trans); CharacterDatabase.CommitTransaction(trans); SendAuctionCommandResult(AH->Id, AUCTION_SELL_ITEM, AUCTION_OK); @@ -276,9 +276,9 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data) AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); AuctionEntry* auction = auctionHouse->GetAuction(auctionId); - Player* pl = GetPlayer(); + Player* player = GetPlayer(); - if (!auction || auction->owner == pl->GetGUIDLow()) + if (!auction || auction->owner == player->GetGUIDLow()) { //you cannot bid your own auction: SendAuctionCommandResult(0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR); @@ -287,7 +287,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data) // impossible have online own another character (use this for speedup check in case online owner) Player* auction_owner = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)); - if (!auction_owner && sObjectMgr->GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == pl->GetSession()->GetAccountId()) + if (!auction_owner && sObjectMgr->GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == player->GetSession()->GetAccountId()) { //you cannot bid your another character auction: SendAuctionCommandResult(0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR); @@ -306,7 +306,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data) return; } - if (!pl->HasEnoughMoney(price)) + if (!player->HasEnoughMoney(price)) { //you don't have enought money!, client tests! //SendAuctionCommandResult(auction->auctionId, AUCTION_PLACE_BID, ???); @@ -319,19 +319,19 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data) { if (auction->bidder > 0) { - if (auction->bidder == pl->GetGUIDLow()) - pl->ModifyMoney(-int32(price - auction->bid)); + if (auction->bidder == player->GetGUIDLow()) + player->ModifyMoney(-int32(price - auction->bid)); else { // mail to last bidder and return money sAuctionMgr->SendAuctionOutbiddedMail(auction, price, GetPlayer(), trans); - pl->ModifyMoney(-int32(price)); + player->ModifyMoney(-int32(price)); } } else - pl->ModifyMoney(-int32(price)); + player->ModifyMoney(-int32(price)); - auction->bidder = pl->GetGUIDLow(); + auction->bidder = player->GetGUIDLow(); auction->bid = price; GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price); @@ -342,15 +342,15 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data) else { //buyout: - if (pl->GetGUIDLow() == auction->bidder) - pl->ModifyMoney(-int32(auction->buyout - auction->bid)); + if (player->GetGUIDLow() == auction->bidder) + player->ModifyMoney(-int32(auction->buyout - auction->bid)); else { - pl->ModifyMoney(-int32(auction->buyout)); + player->ModifyMoney(-int32(auction->buyout)); if (auction->bidder) //buyout for bidded auction .. sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, GetPlayer(), trans); } - auction->bidder = pl->GetGUIDLow(); + auction->bidder = player->GetGUIDLow(); auction->bid = auction->buyout; GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, auction->buyout); @@ -367,7 +367,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data) sAuctionMgr->RemoveAItem(auction->item_guidlow); auctionHouse->RemoveAuction(auction, item_template); } - pl->SaveInventoryAndGoldToDB(trans); + player->SaveInventoryAndGoldToDB(trans); CharacterDatabase.CommitTransaction(trans); } @@ -394,10 +394,10 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); AuctionEntry* auction = auctionHouse->GetAuction(auctionId); - Player* pl = GetPlayer(); + Player* player = GetPlayer(); SQLTransaction trans = CharacterDatabase.BeginTransaction(); - if (auction && auction->owner == pl->GetGUIDLow()) + if (auction && auction->owner == player->GetGUIDLow()) { Item* pItem = sAuctionMgr->GetAItem(auction->item_guidlow); if (pItem) @@ -405,11 +405,11 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) if (auction->bidder > 0) // If we have a bidder, we have to send him the money he paid { uint32 auctionCut = auction->GetAuctionCut(); - if (!pl->HasEnoughMoney(auctionCut)) //player doesn't have enough money, maybe message needed + if (!player->HasEnoughMoney(auctionCut)) //player doesn't have enough money, maybe message needed return; //some auctionBidderNotification would be needed, but don't know that parts.. sAuctionMgr->SendAuctionCancelledToBidderMail(auction, trans); - pl->ModifyMoney(-int32(auctionCut)); + player->ModifyMoney(-int32(auctionCut)); } // Return the item by mail std::ostringstream msgAuctionCanceledOwner; @@ -418,7 +418,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) // item will deleted or added to received mail list MailDraft(msgAuctionCanceledOwner.str(), "") // TODO: fix body .AddItem(pItem) - .SendMailTo(trans, pl, auction, MAIL_CHECK_MASK_COPIED); + .SendMailTo(trans, player, auction, MAIL_CHECK_MASK_COPIED); } else { @@ -431,7 +431,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) { SendAuctionCommandResult(0, AUCTION_CANCEL, AUCTION_INTERNAL_ERROR); //this code isn't possible ... maybe there should be assert - sLog->outError("CHEATER : %u, he tried to cancel auction (id: %u) of another player, or auction is NULL", pl->GetGUIDLow(), auctionId); + sLog->outError("CHEATER : %u, he tried to cancel auction (id: %u) of another player, or auction is NULL", player->GetGUIDLow(), auctionId); return; } @@ -440,7 +440,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) // Now remove the auction - pl->SaveInventoryAndGoldToDB(trans); + player->SaveInventoryAndGoldToDB(trans); auction->DeleteFromDB(trans); CharacterDatabase.CommitTransaction(trans); @@ -479,7 +479,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data) AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction()); WorldPacket data(SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4)); - Player* pl = GetPlayer(); + Player* player = GetPlayer(); data << (uint32) 0; //add 0 as count uint32 count = 0; uint32 totalcount = 0; @@ -496,7 +496,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data) } } - auctionHouse->BuildListBidderItems(data, pl, count, totalcount); + auctionHouse->BuildListBidderItems(data, player, count, totalcount); data.put<uint32>(0, count); // add count to placeholder data << totalcount; data << (uint32)300; //unk 2.3.0 diff --git a/src/server/game/Server/Protocol/Handlers/CalendarHandler.cpp b/src/server/game/Server/Protocol/Handlers/CalendarHandler.cpp index 8f32ac84cb8..4c6ec6571a4 100755 --- a/src/server/game/Server/Protocol/Handlers/CalendarHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/CalendarHandler.cpp @@ -25,12 +25,14 @@ #include "Opcodes.h" #include "Player.h" -void WorldSession::HandleCalendarGetCalendar(WorldPacket & /*recv_data*/) +void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_GET_CALENDAR"); // empty + uint64 guid = _player->GetGUID(); + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GET_CALENDAR [" UI64FMTD "]", guid); - time_t cur_time = time(NULL); + time_t cur_time = time_t(time(NULL)); + sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_SEND_CALENDAR [" UI64FMTD "]", guid); WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 4+4*0+4+4*0+4+4); data << uint32(0); // invite count @@ -58,48 +60,52 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket & /*recv_data*/) } */ - data << uint32(0); // unk - data << uint32(secsToTimeBitFields(cur_time)); // current time + data << uint32(cur_time); // server time + data << uint32(secsToTimeBitFields(cur_time)); // server time uint32 counter = 0; size_t p_counter = data.wpos(); - data << uint32(counter); // instance save count + data << uint32(counter); // instance save count - for (int i = 0; i < MAX_DIFFICULTY; ++i) - { + for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) for (Player::BoundInstancesMap::const_iterator itr = _player->m_boundInstances[i].begin(); itr != _player->m_boundInstances[i].end(); ++itr) - { if (itr->second.perm) { - InstanceSave* save = itr->second.save; + InstanceSave const* save = itr->second.save; data << uint32(save->GetMapId()); data << uint32(save->GetDifficulty()); data << uint32(save->GetResetTime() - cur_time); - data << uint64(save->GetInstanceId()); // instance save id as unique instance copy id + data << uint64(save->GetInstanceId()); // instance save id as unique instance copy id ++counter; } - } - } data.put<uint32>(p_counter, counter); - data << uint32(1135753200); // unk (28.12.2005 12:00) + data << uint32(1135753200); // unk (28.12.2005 07:00) counter = 0; p_counter = data.wpos(); - data << uint32(counter); // raid reset count + data << uint32(counter); // raid reset count + std::set<uint32> sentMaps; + ResetTimeByMapDifficultyMap const& resets = sInstanceSaveMgr->GetResetTimeMap(); for (ResetTimeByMapDifficultyMap::const_iterator itr = resets.begin(); itr != resets.end(); ++itr) { - uint32 mapid = PAIR32_LOPART(itr->first); - MapEntry const* mapEnt = sMapStore.LookupEntry(mapid); - if (!mapEnt || !mapEnt->IsRaid()) + uint32 mapId = PAIR32_LOPART(itr->first); + + if (sentMaps.find(mapId) != sentMaps.end()) + continue; + + MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); + if (!mapEntry || !mapEntry->IsRaid()) continue; - data << uint32(mapid); + sentMaps.insert(mapId); + + data << uint32(mapId); data << uint32(itr->second - cur_time); - data << uint32(mapEnt->unk_time); + data << uint32(mapEntry->unk_time); ++counter; } @@ -126,17 +132,16 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket & /*recv_data*/) } */ - sLog->outDebug(LOG_FILTER_NETWORKIO, "Sending calendar"); SendPacket(&data); } -void WorldSession::HandleCalendarGetEvent(WorldPacket &recv_data) +void WorldSession::HandleCalendarGetEvent(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_GET_EVENT"); recv_data.read_skip<uint64>(); // unk } -void WorldSession::HandleCalendarGuildFilter(WorldPacket &recv_data) +void WorldSession::HandleCalendarGuildFilter(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_GUILD_FILTER"); recv_data.read_skip<uint32>(); // unk1 @@ -144,13 +149,13 @@ void WorldSession::HandleCalendarGuildFilter(WorldPacket &recv_data) recv_data.read_skip<uint32>(); // unk3 } -void WorldSession::HandleCalendarArenaTeam(WorldPacket &recv_data) +void WorldSession::HandleCalendarArenaTeam(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_ARENA_TEAM"); recv_data.read_skip<uint32>(); // unk } -void WorldSession::HandleCalendarAddEvent(WorldPacket &recv_data) +void WorldSession::HandleCalendarAddEvent(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_ADD_EVENT"); recv_data.rfinish(); // set to end to avoid warnings spam @@ -185,7 +190,7 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket &recv_data) //} } -void WorldSession::HandleCalendarUpdateEvent(WorldPacket &recv_data) +void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_UPDATE_EVENT"); recv_data.rfinish(); // set to end to avoid warnings spam @@ -203,7 +208,7 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket &recv_data) //recv_data >> uint32 } -void WorldSession::HandleCalendarRemoveEvent(WorldPacket &recv_data) +void WorldSession::HandleCalendarRemoveEvent(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_REMOVE_EVENT"); recv_data.rfinish(); // set to end to avoid warnings spam @@ -214,7 +219,7 @@ void WorldSession::HandleCalendarRemoveEvent(WorldPacket &recv_data) } -void WorldSession::HandleCalendarCopyEvent(WorldPacket &recv_data) +void WorldSession::HandleCalendarCopyEvent(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_COPY_EVENT"); recv_data.rfinish(); // set to end to avoid warnings spam @@ -225,7 +230,7 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket &recv_data) } -void WorldSession::HandleCalendarEventInvite(WorldPacket &recv_data) +void WorldSession::HandleCalendarEventInvite(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_INVITE"); recv_data.rfinish(); // set to end to avoid warnings spam @@ -238,7 +243,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket &recv_data) } -void WorldSession::HandleCalendarEventRsvp(WorldPacket &recv_data) +void WorldSession::HandleCalendarEventRsvp(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_RSVP"); recv_data.rfinish(); // set to end to avoid warnings spam @@ -249,7 +254,7 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket &recv_data) } -void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket &recv_data) +void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_REMOVE_INVITE"); recv_data.rfinish(); // set to end to avoid warnings spam @@ -260,7 +265,7 @@ void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket &recv_data) //recv_data >> uint64 } -void WorldSession::HandleCalendarEventStatus(WorldPacket &recv_data) +void WorldSession::HandleCalendarEventStatus(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_STATUS"); recv_data.rfinish(); // set to end to avoid warnings spam @@ -272,7 +277,7 @@ void WorldSession::HandleCalendarEventStatus(WorldPacket &recv_data) //recv_data >> uint32 } -void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket &recv_data) +void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_MODERATOR_STATUS"); recv_data.rfinish(); // set to end to avoid warnings spam @@ -284,7 +289,7 @@ void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket &recv_data) //recv_data >> uint32 } -void WorldSession::HandleCalendarComplain(WorldPacket &recv_data) +void WorldSession::HandleCalendarComplain(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_COMPLAIN"); recv_data.rfinish(); // set to end to avoid warnings spam @@ -294,7 +299,7 @@ void WorldSession::HandleCalendarComplain(WorldPacket &recv_data) //recv_data >> uint64 } -void WorldSession::HandleCalendarGetNumPending(WorldPacket & /*recv_data*/) +void WorldSession::HandleCalendarGetNumPending(WorldPacket& /*recv_data*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_GET_NUM_PENDING"); // empty diff --git a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp index 7b504060789..6863ef17685 100755 --- a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp @@ -686,6 +686,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte sLog->outDetail("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow()); sLog->outChar("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow()); sScriptMgr->OnPlayerCreate(&newChar); + sWorld->AddCharacterNameData(newChar.GetGUIDLow(), std::string(newChar.GetName()), newChar.getGender(), newChar.getRace(), newChar.getClass()); delete createInfo; _charCreateCallback.SetParam(NULL); @@ -741,6 +742,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data) sLog->outDetail("Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid)); sLog->outChar("Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid)); sScriptMgr->OnPlayerDelete(guid); + sWorld->DeleteCharaceterNameData(GUID_LOPART(guid)); if (sLog->IsOutCharDump()) // optimize GetPlayerDump call { @@ -918,7 +920,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) } } - if (!pCurrChar->GetMap()->Add(pCurrChar) || !pCurrChar->CheckInstanceLoginValid()) + if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid()) { AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId()); if (at) @@ -1168,6 +1170,8 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult result, std: data << uint64(guid); data << newname; SendPacket(&data); + + sWorld->UpdateCharacterNameData(guidLow, newname); } void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data) @@ -1414,6 +1418,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data) Player::Customize(guid, gender, skin, face, hairStyle, hairColor, facialHair); CharacterDatabase.PExecute("UPDATE characters set name = '%s', at_login = at_login & ~ %u WHERE guid ='%u'", newname.c_str(), uint32(AT_LOGIN_CUSTOMIZE), GUID_LOPART(guid)); CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid ='%u'", GUID_LOPART(guid)); + sWorld->UpdateCharacterNameData(GUID_LOPART(guid), newname, gender); WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1+8+(newname.size()+1)+6); data << uint8(RESPONSE_SUCCESS); @@ -1426,8 +1431,6 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data) data << uint8(hairColor); data << uint8(facialHair); SendPacket(&data); - - sWorld->ReloadSingleCharacterNameData(GUID_LOPART(guid)); } void WorldSession::HandleEquipmentSetSave(WorldPacket &recv_data) @@ -1633,6 +1636,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data) SQLTransaction trans = CharacterDatabase.BeginTransaction(); trans->PAppend("UPDATE `characters` SET name='%s', race='%u', at_login=at_login & ~ %u WHERE guid='%u'", newname.c_str(), race, used_loginFlag, lowGuid); trans->PAppend("DELETE FROM character_declinedname WHERE guid ='%u'", lowGuid); + sWorld->UpdateCharacterNameData(GUID_LOPART(guid), newname, gender, race); BattlegroundTeamId team = BG_TEAM_ALLIANCE; diff --git a/src/server/game/Server/Protocol/Handlers/ChatHandler.cpp b/src/server/game/Server/Protocol/Handlers/ChatHandler.cpp index 83d92df4f7a..852549b3f53 100755 --- a/src/server/game/Server/Protocol/Handlers/ChatHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/ChatHandler.cpp @@ -495,8 +495,8 @@ namespace Trinity class EmoteChatBuilder { public: - EmoteChatBuilder(Player const& pl, uint32 text_emote, uint32 emote_num, Unit const* target) - : i_player(pl), i_text_emote(text_emote), i_emote_num(emote_num), i_target(target) {} + EmoteChatBuilder(Player const& player, uint32 text_emote, uint32 emote_num, Unit const* target) + : i_player(player), i_text_emote(text_emote), i_emote_num(emote_num), i_target(target) {} void operator()(WorldPacket& data, LocaleConstant loc_idx) { @@ -566,10 +566,9 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket & recv_data) Unit* unit = ObjectAccessor::GetUnit(*_player, guid); - CellPair p = Trinity::ComputeCellPair(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()); + CellCoord p = Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::EmoteChatBuilder emote_builder(*GetPlayer(), text_emote, emoteNum, unit); diff --git a/src/server/game/Server/Protocol/Handlers/DuelHandler.cpp b/src/server/game/Server/Protocol/Handlers/DuelHandler.cpp index 48bc305ce30..b1e6f3fdc3f 100755 --- a/src/server/game/Server/Protocol/Handlers/DuelHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/DuelHandler.cpp @@ -27,7 +27,7 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) { uint64 guid; - Player* pl; + Player* player; Player* plTarget; recvPacket >> guid; @@ -35,21 +35,21 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) if (!GetPlayer()->duel) // ignore accept from duel-sender return; - pl = GetPlayer(); - plTarget = pl->duel->opponent; + player = GetPlayer(); + plTarget = player->duel->opponent; - if (pl == pl->duel->initiator || !plTarget || pl == plTarget || pl->duel->startTime != 0 || plTarget->duel->startTime != 0) + if (player == player->duel->initiator || !plTarget || player == plTarget || player->duel->startTime != 0 || plTarget->duel->startTime != 0) return; //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: Received CMSG_DUEL_ACCEPTED"); - sLog->outStaticDebug("Player 1 is: %u (%s)", pl->GetGUIDLow(), pl->GetName()); + sLog->outStaticDebug("Player 1 is: %u (%s)", player->GetGUIDLow(), player->GetName()); sLog->outStaticDebug("Player 2 is: %u (%s)", plTarget->GetGUIDLow(), plTarget->GetName()); time_t now = time(NULL); - pl->duel->startTimer = now; + player->duel->startTimer = now; plTarget->duel->startTimer = now; - pl->SendDuelCountdown(3000); + player->SendDuelCountdown(3000); plTarget->SendDuelCountdown(3000); } diff --git a/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp b/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp index 57a54bd440f..65865280459 100755 --- a/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp @@ -306,9 +306,9 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data) return; } - if (Player* plr = grp->GetInvited(guid)) + if (Player* player = grp->GetInvited(guid)) { - plr->UninviteFromGroup(); + player->UninviteFromGroup(); return; } @@ -350,9 +350,9 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data) return; } - if (Player* plr = grp->GetInvited(membername)) + if (Player* player = grp->GetInvited(membername)) { - plr->UninviteFromGroup(); + player->UninviteFromGroup(); return; } @@ -850,10 +850,8 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke if (mask & GROUP_UPDATE_FLAG_VEHICLE_SEAT) { - if (player->GetVehicle()){ - Vehicle* vv=player->GetVehicle(); - *data << (uint32) vv->GetVehicleInfo()->m_seatID[player->m_movementInfo.t_seat]; - } + if (Vehicle* veh = player->GetVehicle()) + *data << (uint32) veh->GetVehicleInfo()->m_seatID[player->m_movementInfo.t_seat]; } if (mask & GROUP_UPDATE_FLAG_PET_AURAS) diff --git a/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp b/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp index eca466436be..f4e3af72892 100755 --- a/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp @@ -1341,7 +1341,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) _player->ToggleMetaGemsActive(slot, true); //turn on all metagems (except for target item) - itemTarget->SetSoulboundTradeable(NULL, _player, false); // clear tradeable flag + itemTarget->ClearSoulboundTradeable(_player); // clear tradeable flag } void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data) diff --git a/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp b/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp index fab7bf841c2..1ff1181bc6a 100755 --- a/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp @@ -419,8 +419,8 @@ void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck* pRoleCheck) data << uint64(guid); // Guid data << uint8(roles > 0); // Ready data << uint32(roles); // Roles - Player* plr = ObjectAccessor::FindPlayer(guid); - data << uint8(plr ? plr->getLevel() : 0); // Level + Player* player = ObjectAccessor::FindPlayer(guid); + data << uint8(player ? player->getLevel() : 0); // Level for (LfgRolesMap::const_iterator it = pRoleCheck->roles.begin(); it != pRoleCheck->roles.end(); ++it) { @@ -432,8 +432,8 @@ void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck* pRoleCheck) data << uint64(guid); // Guid data << uint8(roles > 0); // Ready data << uint32(roles); // Roles - plr = ObjectAccessor::FindPlayer(guid); - data << uint8(plr ? plr->getLevel() : 0); // Level + player = ObjectAccessor::FindPlayer(guid); + data << uint8(player ? player->getLevel() : 0); // Level } } SendPacket(&data); diff --git a/src/server/game/Server/Protocol/Handlers/LootHandler.cpp b/src/server/game/Server/Protocol/Handlers/LootHandler.cpp index 83d3fad3b21..05b4afc99e7 100755 --- a/src/server/game/Server/Protocol/Handlers/LootHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/LootHandler.cpp @@ -489,10 +489,10 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket & recv_data) } // list of players allowed to receive this item in trade - AllowedLooterSet* looters = item.GetAllowedLooters(); + AllowedLooterSet looters = item.GetAllowedLooters(); // not move item from loot to target inventory - Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomPropertyId, (looters->size() > 1) ? looters : NULL); + Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomPropertyId, looters); target->SendNewItem(newitem, uint32(item.count), false, false, true); target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, item.itemid, item.count); target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, pLoot->loot_type, item.count); diff --git a/src/server/game/Server/Protocol/Handlers/MailHandler.cpp b/src/server/game/Server/Protocol/Handlers/MailHandler.cpp index 432a8bf3f6a..785fcdbf067 100755 --- a/src/server/game/Server/Protocol/Handlers/MailHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/MailHandler.cpp @@ -75,9 +75,9 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) if (receiver.empty()) return; - Player* pl = _player; + Player* player = _player; - if (pl->getLevel() < sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ)) + if (player->getLevel() < sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ)) { SendNotification(GetTrinityString(LANG_MAIL_SENDER_REQ), sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ)); return; @@ -90,16 +90,16 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) if (!rc) { sLog->outDetail("Player %u is sending mail to %s (GUID: not existed!) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u", - pl->GetGUIDLow(), receiver.c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); - pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND); + player->GetGUIDLow(), receiver.c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); + player->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND); return; } - sLog->outDetail("Player %u is sending mail to %s (GUID: %u) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u", pl->GetGUIDLow(), receiver.c_str(), GUID_LOPART(rc), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); + sLog->outDetail("Player %u is sending mail to %s (GUID: %u) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u", player->GetGUIDLow(), receiver.c_str(), GUID_LOPART(rc), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); - if (pl->GetGUID() == rc) + if (player->GetGUID() == rc) { - pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANNOT_SEND_TO_SELF); + player->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANNOT_SEND_TO_SELF); return; } @@ -107,9 +107,9 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) uint32 reqmoney = cost + money; - if (!pl->HasEnoughMoney(reqmoney)) + if (!player->HasEnoughMoney(reqmoney)) { - pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY); + player->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY); return; } @@ -142,14 +142,14 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) //do not allow to have more than 100 mails in mailbox.. mails count is in opcode uint8!!! - so max can be 255.. if (mails_count > 100) { - pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_CAP_REACHED); + player->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_CAP_REACHED); return; } // test the receiver's Faction... or all items are account bound bool accountBound = items_count ? true : false; for (uint8 i = 0; i < items_count; ++i) { - Item* item = pl->GetItemByGuid(itemGUIDs[i]); + Item* item = player->GetItemByGuid(itemGUIDs[i]); if (item) { ItemTemplate const* itemProto = item->GetTemplate(); @@ -161,9 +161,9 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) } } - if (!accountBound && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL) && pl->GetTeam() != rc_team && AccountMgr::IsPlayerAccount(GetSecurity())) + if (!accountBound && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL) && player->GetTeam() != rc_team && AccountMgr::IsPlayerAccount(GetSecurity())) { - pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_YOUR_TEAM); + player->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_YOUR_TEAM); return; } @@ -183,56 +183,56 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) { if (!itemGUIDs[i]) { - pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID); + player->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID); return; } - Item* item = pl->GetItemByGuid(itemGUIDs[i]); + Item* item = player->GetItemByGuid(itemGUIDs[i]); // prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail) if (!item) { - pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID); + player->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID); return; } if (!item->CanBeTraded(true)) { - pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM); + player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM); return; } - if (item->IsBoundAccountWide() && item->IsSoulBound() && pl->GetSession()->GetAccountId() != rc_account) + if (item->IsBoundAccountWide() && item->IsSoulBound() && player->GetSession()->GetAccountId() != rc_account) { - pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_ARTEFACTS_ONLY_FOR_OWN_CHARACTERS); + player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_ARTEFACTS_ONLY_FOR_OWN_CHARACTERS); return; } if (item->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION)) { - pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM); + player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM); return; } if (COD && item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED)) { - pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD); + player->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD); return; } if (item->IsNotEmptyBag()) { - pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS); + player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS); return; } items[i] = item; } - pl->SendMailResult(0, MAIL_SEND, MAIL_OK); + player->SendMailResult(0, MAIL_SEND, MAIL_OK); - pl->ModifyMoney(-int32(reqmoney)); - pl->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, cost); + player->ModifyMoney(-int32(reqmoney)); + player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, cost); bool needItemDelay = false; @@ -254,7 +254,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) } item->SetNotRefundable(GetPlayer()); // makes the item no longer refundable - pl->MoveItemFromInventory(items[i]->GetBagSlot(), item->GetSlot(), true); + player->MoveItemFromInventory(items[i]->GetBagSlot(), item->GetSlot(), true); item->DeleteFromInventoryDB(trans); // deletes item from character's inventory item->SetOwnerGUID(rc); @@ -264,7 +264,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) } // if item send to character at another account, then apply item delivery delay - needItemDelay = pl->GetSession()->GetAccountId() != rc_account; + needItemDelay = player->GetSession()->GetAccountId() != rc_account; } if (money > 0 && !AccountMgr::IsPlayerAccount(GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) @@ -281,9 +281,9 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) draft .AddMoney(money) .AddCOD(COD) - .SendMailTo(trans, MailReceiver(receive, GUID_LOPART(rc)), MailSender(pl), body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay); + .SendMailTo(trans, MailReceiver(receive, GUID_LOPART(rc)), MailSender(player), body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay); - pl->SaveInventoryAndGoldToDB(trans); + player->SaveInventoryAndGoldToDB(trans); CharacterDatabase.CommitTransaction(trans); } @@ -298,14 +298,14 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data) if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; - Player* pl = _player; - Mail* m = pl->GetMail(mailId); + Player* player = _player; + Mail* m = player->GetMail(mailId); if (m) { - if (pl->unReadMails) - --pl->unReadMails; + if (player->unReadMails) + --player->unReadMails; m->checked = m->checked | MAIL_CHECK_MASK_READ; - pl->m_mailsUpdated = true; + player->m_mailsUpdated = true; m->state = MAIL_STATE_CHANGED; } } @@ -323,20 +323,20 @@ void WorldSession::HandleMailDelete(WorldPacket & recv_data) return; Mail* m = _player->GetMail(mailId); - Player* pl = _player; - pl->m_mailsUpdated = true; + Player* player = _player; + player->m_mailsUpdated = true; if (m) { // delete shouldn't show up for COD mails if (m->COD) { - pl->SendMailResult(mailId, MAIL_DELETED, MAIL_ERR_INTERNAL_ERROR); + player->SendMailResult(mailId, MAIL_DELETED, MAIL_ERR_INTERNAL_ERROR); return; } m->state = MAIL_STATE_DELETED; } - pl->SendMailResult(mailId, MAIL_DELETED, MAIL_OK); + player->SendMailResult(mailId, MAIL_DELETED, MAIL_OK); } void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data) @@ -350,11 +350,11 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data) if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; - Player* pl = _player; - Mail* m = pl->GetMail(mailId); + Player* player = _player; + Mail* m = player->GetMail(mailId); if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) { - pl->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR); + player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR); return; } //we can return mail now @@ -362,7 +362,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data) SQLTransaction trans = CharacterDatabase.BeginTransaction(); trans->PAppend("DELETE FROM mail WHERE id = '%u'", mailId); // needed? trans->PAppend("DELETE FROM mail_items WHERE mail_id = '%u'", mailId); - pl->RemoveMail(mailId); + player->RemoveMail(mailId); // only return mail if the player exists (and delete if not existing) if (m->messageType == MAIL_NORMAL && m->sender) @@ -375,7 +375,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data) { for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) { - Item* item = pl->GetMItem(itr2->item_guid); + Item* item = player->GetMItem(itr2->item_guid); if (item) draft.AddItem(item); else @@ -383,7 +383,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data) //WTF? } - pl->RemoveMItem(itr2->item_guid); + player->RemoveMItem(itr2->item_guid); } } draft.AddMoney(m->money).SendReturnToSender(GetAccountId(), m->receiver, m->sender, trans); @@ -392,7 +392,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data) CharacterDatabase.CommitTransaction(trans); delete m; //we can deallocate old mail - pl->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_OK); + player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_OK); } //called when player takes item attached in mail @@ -408,23 +408,23 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data) if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; - Player* pl = _player; + Player* player = _player; - Mail* m = pl->GetMail(mailId); + Mail* m = player->GetMail(mailId); if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) { - pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR); + player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR); return; } // prevent cheating with skip client money check - if (!pl->HasEnoughMoney(m->COD)) + if (!player->HasEnoughMoney(m->COD)) { - pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_NOT_ENOUGH_MONEY); + player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_NOT_ENOUGH_MONEY); return; } - Item* it = pl->GetMItem(itemId); + Item* it = player->GetMItem(itemId); ItemPosCountVec dest; uint8 msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, it, false); @@ -471,24 +471,24 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data) .SendMailTo(trans, MailReceiver(receive, m->sender), MailSender(MAIL_NORMAL, m->receiver), MAIL_CHECK_MASK_COD_PAYMENT); } - pl->ModifyMoney(-int32(m->COD)); + player->ModifyMoney(-int32(m->COD)); } m->COD = 0; m->state = MAIL_STATE_CHANGED; - pl->m_mailsUpdated = true; - pl->RemoveMItem(it->GetGUIDLow()); + player->m_mailsUpdated = true; + player->RemoveMItem(it->GetGUIDLow()); uint32 count = it->GetCount(); // save counts before store and possible merge with deleting - pl->MoveItemToInventory(dest, it, true); + player->MoveItemToInventory(dest, it, true); - pl->SaveInventoryAndGoldToDB(trans); - pl->_SaveMail(trans); + player->SaveInventoryAndGoldToDB(trans); + player->_SaveMail(trans); CharacterDatabase.CommitTransaction(trans); - pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_OK, 0, itemId, count); + player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_OK, 0, itemId, count); } else - pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_EQUIP_ERROR, msg); + player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_EQUIP_ERROR, msg); } void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data) @@ -501,26 +501,26 @@ void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data) if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; - Player* pl = _player; + Player* player = _player; - Mail* m = pl->GetMail(mailId); + Mail* m = player->GetMail(mailId); if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) { - pl->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_ERR_INTERNAL_ERROR); + player->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_ERR_INTERNAL_ERROR); return; } - pl->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_OK); + player->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_OK); - pl->ModifyMoney(m->money); + player->ModifyMoney(m->money); m->money = 0; m->state = MAIL_STATE_CHANGED; - pl->m_mailsUpdated = true; + player->m_mailsUpdated = true; // save money and mail to prevent cheating SQLTransaction trans = CharacterDatabase.BeginTransaction(); - pl->SaveGoldToDB(trans); - pl->_SaveMail(trans); + player->SaveGoldToDB(trans); + player->_SaveMail(trans); CharacterDatabase.CommitTransaction(trans); } @@ -533,11 +533,11 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data) if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; - Player* pl = _player; + Player* player = _player; //load players mails, and mailed items - if (!pl->m_mailsLoaded) - pl ->_LoadMail(); + if (!player->m_mailsLoaded) + player ->_LoadMail(); // client can't work with packets > max int16 value const uint32 maxPacketSize = 32767; @@ -550,7 +550,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data) data << uint8(0); // mail's count time_t cur_time = time(NULL); - for (PlayerMails::iterator itr = pl->GetMailBegin(); itr != pl->GetMailEnd(); ++itr) + for (PlayerMails::iterator itr = player->GetMailBegin(); itr != player->GetMailEnd(); ++itr) { // packet send mail count as uint8, prevent overflow if (mailsCount >= 254) @@ -605,7 +605,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data) for (uint8 i = 0; i < item_count; ++i) { - Item* item = pl->GetMItem((*itr)->items[i].item_guid); + Item* item = player->GetMItem((*itr)->items[i].item_guid); // item index (0-6?) data << uint8(i); // item guid low? @@ -658,17 +658,17 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data) if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; - Player* pl = _player; + Player* player = _player; - Mail* m = pl->GetMail(mailId); + Mail* m = player->GetMail(mailId); if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) { - pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR); + player->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR); return; } Item* bodyItem = new Item; // This is not bag and then can be used new Item. - if (!bodyItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), MAIL_BODY_ITEM_TEMPLATE, pl)) + if (!bodyItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), MAIL_BODY_ITEM_TEMPLATE, player)) { delete bodyItem; return; @@ -680,7 +680,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data) MailTemplateEntry const* mailTemplateEntry = sMailTemplateStore.LookupEntry(m->mailTemplateId); if (!mailTemplateEntry) { - pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR); + player->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR); return; } @@ -700,14 +700,14 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data) { m->checked = m->checked | MAIL_CHECK_MASK_COPIED; m->state = MAIL_STATE_CHANGED; - pl->m_mailsUpdated = true; + player->m_mailsUpdated = true; - pl->StoreItem(dest, bodyItem, true); - pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_OK); + player->StoreItem(dest, bodyItem, true); + player->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_OK); } else { - pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_EQUIP_ERROR, msg); + player->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_EQUIP_ERROR, msg); delete bodyItem; } } diff --git a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp index 1b0cef69c04..7327cdbba65 100755 --- a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp @@ -239,8 +239,8 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data) data << uint32(matchcount); // placeholder, count of players matching criteria data << uint32(displaycount); // placeholder, count of players displayed - ACE_GUARD(ACE_Thread_Mutex, g, *HashMapHolder<Player>::GetLock()); - HashMapHolder<Player>::MapType& m = sObjectAccessor->GetPlayers(); + TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock()); + HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers(); for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { if (AccountMgr::IsPlayerAccount(security)) @@ -339,12 +339,6 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data) if ((matchcount++) >= sWorld->getIntConfig(CONFIG_MAX_WHO)) continue; - if (itr->second->isGameMaster()) - { - pname = "<GM>"; - pname.append(itr->second->GetName()); - } - data << pname; // player name data << gname; // guild name data << uint32(lvl); // player level @@ -1196,18 +1190,18 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) _player->SetSelection(guid); - Player* plr = ObjectAccessor::FindPlayer(guid); - if (!plr) // wrong player + Player* player = ObjectAccessor::FindPlayer(guid); + if (!player) // wrong player return; uint32 talent_points = 0x47; - uint32 guid_size = plr->GetPackGUID().wpos(); + uint32 guid_size = player->GetPackGUID().wpos(); WorldPacket data(SMSG_INSPECT_TALENT, guid_size+4+talent_points); - data.append(plr->GetPackGUID()); + data.append(player->GetPackGUID()); if (sWorld->getBoolConfig(CONFIG_TALENTS_INSPECTING) || _player->isGameMaster()) { - plr->BuildPlayerTalentsInfoData(&data); + player->BuildPlayerTalentsInfoData(&data); } else { @@ -1216,7 +1210,7 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) data << uint8(0); // talentGroupIndex } - plr->BuildEnchantmentsInfoData(&data); + player->BuildEnchantmentsInfoData(&data); SendPacket(&data); } @@ -1297,15 +1291,15 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) return; } - Player* plr = sObjectAccessor->FindPlayerByName(charname.c_str()); + Player* player = sObjectAccessor->FindPlayerByName(charname.c_str()); - if (!plr) + if (!player) { SendNotification(LANG_PLAYER_NOT_EXIST_OR_OFFLINE, charname.c_str()); return; } - uint32 accid = plr->GetSession()->GetAccountId(); + uint32 accid = player->GetSession()->GetAccountId(); QueryResult result = LoginDatabase.PQuery("SELECT username, email, last_ip FROM account WHERE id=%u", accid); if (!result) diff --git a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp index bf971cae32f..90368ae3011 100755 --- a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp @@ -68,7 +68,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() if (GetPlayer()->IsInWorld()) { sLog->outCrash("Player (Name %s) is still in world when teleported from map %u to new map %u", GetPlayer()->GetName(), oldMap->GetId(), loc.GetMapId()); - oldMap->Remove(GetPlayer(), false); + oldMap->RemovePlayerFromMap(GetPlayer(), false); } // relocate the player to the teleport destination @@ -88,7 +88,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->SetMap(newMap); GetPlayer()->SendInitialPacketsBeforeAddToMap(); - if (!GetPlayer()->GetMap()->Add(GetPlayer())) + if (!GetPlayer()->GetMap()->AddPlayerToMap(GetPlayer())) { sLog->outError("WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.GetMapId()); GetPlayer()->ResetMap(); @@ -215,7 +215,7 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data) WorldLocation const& dest = plMover->GetTeleportDest(); - plMover->SetPosition(dest, true); + plMover->UpdatePosition(dest, true); uint32 newzone, newarea; plMover->GetZoneAndAreaId(newzone, newarea); @@ -355,7 +355,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data) return; } - mover->SetPosition(movementInfo.pos); + mover->UpdatePosition(movementInfo.pos); if (plMover) // nothing is charmed, or player charmed { @@ -373,7 +373,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data) if (plMover->isAlive()) { plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, GetPlayer()->GetMaxHealth()); - // pl can be alive if GM/etc + // player can be alive if GM/etc // change the death state to CORPSE to prevent the death timer from // starting in the next player update if (!plMover->isAlive()) diff --git a/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp b/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp index bfd1fae2306..bf951619e63 100755 --- a/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp @@ -31,27 +31,44 @@ #include "Pet.h" #include "MapManager.h" -void WorldSession::SendNameQueryOpcode(Player* p) +void WorldSession::SendNameQueryOpcode(uint64 guid) { - if (!p) - return; + Player* player = NULL; + const CharacterNameData* nameData = sWorld->GetCharacterNameData(GUID_LOPART(guid)); + if (nameData) + player = ObjectAccessor::FindPlayer(guid); + // guess size WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10)); - data.append(p->GetPackGUID()); // player guid + data.appendPackGUID(guid); data << uint8(0); // added in 3.1 - data << p->GetName(); // played name - data << uint8(0); // realm name for cross realm BG usage - data << uint8(p->getRace()); - data << uint8(p->getGender()); - data << uint8(p->getClass()); - if (DeclinedName const* names = p->GetDeclinedNames()) + if (nameData) { - data << uint8(1); // is declined - for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) - data << names->name[i]; + data << nameData->m_name; // played name + data << uint8(0); // realm name for cross realm BG usage + data << uint8(nameData->m_race); + data << uint8(nameData->m_gender); + data << uint8(nameData->m_class); } else - data << uint8(0); // is not declined + { + data << std::string(GetTrinityString(LANG_NON_EXIST_CHARACTER)); + data << uint32(0); + } + + if (player) + { + if (DeclinedName const* names = player->GetDeclinedNames()) + { + data << uint8(1); // is declined + for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) + data << names->name[i]; + } + else + data << uint8(0); // is not declined + } + else //TODO: decline names may also need to be stored in char name data + data << uint8(0); SendPacket(&data); } @@ -65,32 +82,7 @@ void WorldSession::HandleNameQueryOpcode(WorldPacket& recv_data) // This is disable by default to prevent lots of console spam // sLog->outString("HandleNameQueryOpcode %u", guid); - if (Player* pChar = ObjectAccessor::FindPlayer(guid)) - SendNameQueryOpcode(pChar); - else - { - if (CharacterNameData* cname = sWorld->GetCharacterNameData(guid)) - { - WorldPacket data(SMSG_NAME_QUERY_RESPONSE, 8+1+1+1+1+1+1+10); - data.appendPackGUID(guid); - data << uint8(0); - if (cname->m_name == "") - { - data << std::string(GetTrinityString(LANG_NON_EXIST_CHARACTER)); - data << uint32(0); - } - else - { - data << cname->m_name; - data << uint8(0); - data << uint8(cname->m_race); - data << uint8(cname->m_gender); - data << uint8(cname->m_class); - } - data << uint8(0); - SendPacket(&data); - } - } + SendNameQueryOpcode(guid); } void WorldSession::HandleQueryTimeOpcode(WorldPacket & /*recv_data*/) @@ -387,8 +379,8 @@ void WorldSession::HandlePageTextQueryOpcode(WorldPacket & recv_data) int loc_idx = GetSessionDbLocaleIndex(); if (loc_idx >= 0) - if (PageTextLocale const* pl = sObjectMgr->GetPageTextLocale(pageID)) - ObjectMgr::GetLocaleString(pl->Text, loc_idx, Text); + if (PageTextLocale const* player = sObjectMgr->GetPageTextLocale(pageID)) + ObjectMgr::GetLocaleString(player->Text, loc_idx, Text); data << Text; data << uint32(pageText->NextPage); diff --git a/src/server/game/Server/Protocol/Handlers/VehicleHandler.cpp b/src/server/game/Server/Protocol/Handlers/VehicleHandler.cpp index 7187241cc3a..256f8b327ff 100644 --- a/src/server/game/Server/Protocol/Handlers/VehicleHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/VehicleHandler.cpp @@ -129,16 +129,16 @@ void WorldSession::HandleEnterPlayerVehicle(WorldPacket &data) uint64 guid; data >> guid; - if (Player* pl = ObjectAccessor::FindPlayer(guid)) + if (Player* player = ObjectAccessor::FindPlayer(guid)) { - if (!pl->GetVehicleKit()) + if (!player->GetVehicleKit()) return; - if (!pl->IsInRaidWith(_player)) + if (!player->IsInRaidWith(_player)) return; - if (!pl->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) + if (!player->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) return; - _player->EnterVehicle(pl); + _player->EnterVehicle(player); } } @@ -157,23 +157,23 @@ void WorldSession::HandleEjectPassenger(WorldPacket &data) if (IS_PLAYER_GUID(guid)) { - Player* plr = ObjectAccessor::FindPlayer(guid); - if (!plr) + Player* player = ObjectAccessor::FindPlayer(guid); + if (!player) { sLog->outError("Player %u tried to eject player %u from vehicle, but the latter was not found in world!", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid)); return; } - if (!plr->IsOnVehicle(vehicle->GetBase())) + if (!player->IsOnVehicle(vehicle->GetBase())) { sLog->outError("Player %u tried to eject player %u, but they are not in the same vehicle", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid)); return; } - VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(plr); + VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(player); ASSERT(seat); if (seat->IsEjectable()) - plr->ExitVehicle(); + player->ExitVehicle(); else sLog->outError("Player %u attempted to eject player %u from non-ejectable seat.", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid)); } diff --git a/src/server/game/Server/Protocol/WorldLog.cpp b/src/server/game/Server/Protocol/WorldLog.cpp index 579e4363253..334c189af81 100755 --- a/src/server/game/Server/Protocol/WorldLog.cpp +++ b/src/server/game/Server/Protocol/WorldLog.cpp @@ -61,7 +61,7 @@ void WorldLog::outTimestampLog(char const* fmt, ...) { if (LogWorld()) { - ACE_GUARD(ACE_Thread_Mutex, Guard, Lock); + TRINITY_GUARD(ACE_Thread_Mutex, Lock); ASSERT(i_file); Log::outTimestamp(i_file); @@ -89,7 +89,7 @@ void WorldLog::outLog(char const* fmt, ...) { if (LogWorld()) { - ACE_GUARD(ACE_Thread_Mutex, Guard, Lock); + TRINITY_GUARD(ACE_Thread_Mutex, Lock); ASSERT(i_file); va_list args; diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index cc57b72d9b4..14c86286718 100755 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -55,12 +55,12 @@ bool MapSessionFilter::Process(WorldPacket* packet) if (opHandle.packetProcessing == PROCESS_THREADUNSAFE) return false; - Player* plr = m_pSession->GetPlayer(); - if (!plr) + Player* player = m_pSession->GetPlayer(); + if (!player) return false; //in Map::Update() we do not process packets where player is not in world! - return plr->IsInWorld(); + return player->IsInWorld(); } //we should process ALL packets when player is not in world/logged in @@ -77,12 +77,12 @@ bool WorldSessionFilter::Process(WorldPacket* packet) return true; //no player attached? -> our client! ^^ - Player* plr = m_pSession->GetPlayer(); - if (!plr) + Player* player = m_pSession->GetPlayer(); + if (!player) return true; //lets process all packets for non-in-the-world player - return (plr->IsInWorld() == false); + return (player->IsInWorld() == false); } /// WorldSession constructor @@ -494,7 +494,7 @@ void WorldSession::LogoutPlayer(bool Save) _player->CleanupsBeforeDelete(); sLog->outChar("Account: %d (IP: %s) Logout Character:[%s] (GUID: %u)", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName(), _player->GetGUIDLow()); Map* _map = _player->GetMap(); - _map->Remove(_player, true); + _map->RemovePlayerFromMap(_player, true); SetPlayer(NULL); // deleted in Remove call ///- Send the 'logout complete' packet to the client @@ -964,9 +964,9 @@ void WorldSession::SendAddonsInfo() SendPacket(&data); } -void WorldSession::SetPlayer(Player* plr) +void WorldSession::SetPlayer(Player* player) { - _player = plr; + _player = player; // set m_GUID that can be used while player loggined and later until m_playerRecentlyLogout not reset if (_player) @@ -999,6 +999,7 @@ void WorldSession::ProcessQueryCallbacks() HandleCharCreateCallback(pResult, _charCreateCallback.GetParam()); // Don't call FreeResult() here, the callback handler will do that depending on the events in the callback chain } + //! HandlePlayerLoginOpcode if (_charLoginCallback.ready()) { diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 8b8b3b96b85..4a83c2d4092 100755 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -223,10 +223,10 @@ class WorldSession void SizeError(WorldPacket const& packet, uint32 size) const; - void ReadAddonsInfo(WorldPacket &data); + void ReadAddonsInfo(WorldPacket& data); void SendAddonsInfo(); - void ReadMovementInfo(WorldPacket &data, MovementInfo* mi); + void ReadMovementInfo(WorldPacket& data, MovementInfo* mi); void WriteMovementInfo(WorldPacket* data, MovementInfo* mi); void SendPacket(WorldPacket const* packet); @@ -247,7 +247,7 @@ class 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* player); uint8 Expansion() const { return m_expansion; } /// Session in auth.queue currently @@ -278,11 +278,11 @@ class WorldSession void SendAuthWaitQue(uint32 position); //void SendTestCreatureQueryOpcode(uint32 entry, uint64 guid, uint32 testvalue); - void SendNameQueryOpcode(Player* p); + void SendNameQueryOpcode(uint64 guid); void SendTrainerList(uint64 guid); void SendTrainerList(uint64 guid, const std::string& strTitle); - void SendListInventory(uint64 vendorGuid); + void SendListInventory(uint64 guid); void SendShowBank(uint64 guid); void SendTabardVendorActivate(uint64 guid); void SendSpiritResurrect(); @@ -381,9 +381,7 @@ class WorldSession } bool IsConnectionIdle() const { - if (m_timeOutTime <= 0 && !m_inQueue) - return true; - return false; + return (m_timeOutTime <= 0 && !m_inQueue); } // Recruit-A-Friend Handling @@ -421,11 +419,11 @@ class 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); @@ -438,7 +436,7 @@ class WorldSession void HandleMoveKnockBackAck(WorldPacket& recvPacket); void HandleMoveTeleportAck(WorldPacket& recvPacket); - void HandleForceSpeedChangeAck(WorldPacket & recv_data); + void HandleForceSpeedChangeAck(WorldPacket& recv_data); void HandlePingOpcode(WorldPacket& recvPacket); void HandleAuthSessionOpcode(WorldPacket& recvPacket); @@ -483,10 +481,10 @@ class WorldSession void HandleAreaTriggerOpcode(WorldPacket& recvPacket); - void HandleSetFactionAtWar(WorldPacket & recv_data); - void HandleSetFactionCheat(WorldPacket & recv_data); - void HandleSetWatchedFactionOpcode(WorldPacket & recv_data); - void HandleSetFactionInactiveOpcode(WorldPacket & recv_data); + void HandleSetFactionAtWar(WorldPacket& recv_data); + void HandleSetFactionCheat(WorldPacket& recv_data); + void HandleSetWatchedFactionOpcode(WorldPacket& recv_data); + void HandleSetFactionInactiveOpcode(WorldPacket& recv_data); void HandleUpdateAccountData(WorldPacket& recvPacket); void HandleRequestAccountData(WorldPacket& recvPacket); @@ -507,17 +505,17 @@ class WorldSession void HandleMoveWorldportAckOpcode(); // for server-side calls void HandleMovementOpcodes(WorldPacket& recvPacket); - void HandleSetActiveMoverOpcode(WorldPacket &recv_data); - void HandleMoveNotActiveMover(WorldPacket &recv_data); - void HandleDismissControlledVehicle(WorldPacket &recv_data); - void HandleRequestVehicleExit(WorldPacket &recv_data); - void HandleChangeSeatsOnControlledVehicle(WorldPacket &recv_data); - void HandleMoveTimeSkippedOpcode(WorldPacket &recv_data); + void HandleSetActiveMoverOpcode(WorldPacket& recv_data); + void HandleMoveNotActiveMover(WorldPacket& recv_data); + void HandleDismissControlledVehicle(WorldPacket& recv_data); + void HandleRequestVehicleExit(WorldPacket& recv_data); + void HandleChangeSeatsOnControlledVehicle(WorldPacket& recv_data); + void HandleMoveTimeSkippedOpcode(WorldPacket& recv_data); - void HandleRequestRaidInfoOpcode(WorldPacket & recv_data); + void HandleRequestRaidInfoOpcode(WorldPacket& recv_data); - void HandleBattlefieldStatusOpcode(WorldPacket &recv_data); - void HandleBattleMasterHelloOpcode(WorldPacket &recv_data); + void HandleBattlefieldStatusOpcode(WorldPacket& recv_data); + void HandleBattleMasterHelloOpcode(WorldPacket& recv_data); void HandleGroupInviteOpcode(WorldPacket& recvPacket); //void HandleGroupCancelOpcode(WorldPacket& recvPacket); @@ -527,17 +525,17 @@ class WorldSession void HandleGroupUninviteGuidOpcode(WorldPacket& recvPacket); void HandleGroupSetLeaderOpcode(WorldPacket& recvPacket); void HandleGroupDisbandOpcode(WorldPacket& recvPacket); - void HandleOptOutOfLootOpcode(WorldPacket &recv_data); + void HandleOptOutOfLootOpcode(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); @@ -613,25 +611,25 @@ class 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 HandleAuctionRemoveItem(WorldPacket & recv_data); - void HandleAuctionListOwnerItems(WorldPacket & recv_data); - void HandleAuctionPlaceBid(WorldPacket & recv_data); - 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 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 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 SendItemPageInfo(ItemTemplate* itemProto); void HandleSplitItemOpcode(WorldPacket& recvPacket); @@ -645,9 +643,9 @@ class WorldSession void HandleListInventoryOpcode(WorldPacket& recvPacket); void HandleAutoStoreBagItemOpcode(WorldPacket& recvPacket); void HandleReadItem(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); @@ -728,18 +726,18 @@ class WorldSession void HandlePageQuerySkippedOpcode(WorldPacket& recvPacket); void HandlePageTextQueryOpcode(WorldPacket& recvPacket); - void HandleTutorialFlag (WorldPacket & recv_data); - void HandleTutorialClear(WorldPacket & recv_data); - void HandleTutorialReset(WorldPacket & recv_data); + void HandleTutorialFlag (WorldPacket& recv_data); + void HandleTutorialClear(WorldPacket& recv_data); + void HandleTutorialReset(WorldPacket& recv_data); //Pet - void HandlePetAction(WorldPacket & recv_data); + void HandlePetAction(WorldPacket& recv_data); void HandlePetStopAttack(WorldPacket& recv_data); void HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid, uint16 flag, uint64 guid2); - void HandlePetNameQuery(WorldPacket & recv_data); - void HandlePetSetAction(WorldPacket & recv_data); - void HandlePetAbandon(WorldPacket & recv_data); - void HandlePetRename(WorldPacket & recv_data); + void HandlePetNameQuery(WorldPacket& recv_data); + void HandlePetSetAction(WorldPacket& recv_data); + void HandlePetAbandon(WorldPacket& recv_data); + void HandlePetRename(WorldPacket& recv_data); void HandlePetCancelAuraOpcode(WorldPacket& recvPacket); void HandlePetSpellAutocastOpcode(WorldPacket& recvPacket); void HandlePetCastSpellOpcode(WorldPacket& recvPacket); @@ -756,15 +754,15 @@ class WorldSession void HandleDismissCritter(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 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 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); @@ -783,17 +781,17 @@ class WorldSession void HandleInstanceLockResponse(WorldPacket& recvPacket); // Looking for Dungeon/Raid - void HandleLfgSetCommentOpcode(WorldPacket & recv_data); + void HandleLfgSetCommentOpcode(WorldPacket& recv_data); void HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& recv_data); void HandleLfgPartyLockInfoRequestOpcode(WorldPacket& recv_data); - void HandleLfgJoinOpcode(WorldPacket &recv_data); - void HandleLfgLeaveOpcode(WorldPacket & /*recv_data*/); - void HandleLfgSetRolesOpcode(WorldPacket &recv_data); - void HandleLfgProposalResultOpcode(WorldPacket &recv_data); - void HandleLfgSetBootVoteOpcode(WorldPacket &recv_data); - void HandleLfgTeleportOpcode(WorldPacket &recv_data); - void HandleLfrSearchOpcode(WorldPacket &recv_data); - void HandleLfrLeaveOpcode(WorldPacket &recv_data); + void HandleLfgJoinOpcode(WorldPacket& recv_data); + void HandleLfgLeaveOpcode(WorldPacket& recv_data); + void HandleLfgSetRolesOpcode(WorldPacket& recv_data); + void HandleLfgProposalResultOpcode(WorldPacket& recv_data); + void HandleLfgSetBootVoteOpcode(WorldPacket& recv_data); + void HandleLfgTeleportOpcode(WorldPacket& recv_data); + void HandleLfrSearchOpcode(WorldPacket& recv_data); + void HandleLfrLeaveOpcode(WorldPacket& recv_data); void SendLfgUpdatePlayer(const LfgUpdateData& updateData); void SendLfgUpdateParty(const LfgUpdateData& updateData); @@ -836,7 +834,7 @@ class WorldSession void HandleItemRefundInfoRequest(WorldPacket& recv_data); void HandleItemRefund(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); @@ -878,7 +876,7 @@ class WorldSession void HandleCalendarGetNumPending(WorldPacket& recv_data); void HandleSpellClick(WorldPacket& recv_data); - void HandleMirrorImageDataRequest(WorldPacket & recv_data); + void HandleMirrorImageDataRequest(WorldPacket& recv_data); void HandleAlterAppearance(WorldPacket& recv_data); void HandleRemoveGlyph(WorldPacket& recv_data); void HandleCharCustomize(WorldPacket& recv_data); @@ -890,8 +888,8 @@ class WorldSession void HandleReadyForAccountDataTimes(WorldPacket& recv_data); void HandleQueryQuestsCompleted(WorldPacket& recv_data); void HandleQuestPOIQuery(WorldPacket& recv_data); - void HandleEjectPassenger(WorldPacket &data); - void HandleEnterPlayerVehicle(WorldPacket &data); + void HandleEjectPassenger(WorldPacket& data); + void HandleEnterPlayerVehicle(WorldPacket& data); void HandleUpdateProjectilePosition(WorldPacket& recvPacket); private: diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 3875156289e..0ddc03e3d5c 100755 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -802,7 +802,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) recvPacket >> clientSeed; recvPacket >> unk5 >> unk6 >> unk7; recvPacket >> unk4; - recvPacket.read (digest, 20); + recvPacket.read(digest, 20); sLog->outStaticDebug ("WorldSocket::HandleAuthSession: client %u, unk2 %u, account %s, unk3 %u, clientseed %u", BuiltNumberClient, diff --git a/src/server/game/Server/WorldSocketMgr.cpp b/src/server/game/Server/WorldSocketMgr.cpp index ec29273d6b0..5fb66524976 100755 --- a/src/server/game/Server/WorldSocketMgr.cpp +++ b/src/server/game/Server/WorldSocketMgr.cpp @@ -109,7 +109,7 @@ class ReactorRunnable : protected ACE_Task_Base int AddSocket (WorldSocket* sock) { - ACE_GUARD_RETURN (ACE_Thread_Mutex, Guard, m_NewSockets_Lock, -1); + TRINITY_GUARD(ACE_Thread_Mutex, m_NewSockets_Lock); ++m_Connections; sock->AddReference(); @@ -130,7 +130,7 @@ class ReactorRunnable : protected ACE_Task_Base void AddNewSockets() { - ACE_GUARD (ACE_Thread_Mutex, Guard, m_NewSockets_Lock); + TRINITY_GUARD(ACE_Thread_Mutex, m_NewSockets_Lock); if (m_NewSockets.empty()) return; @@ -192,7 +192,7 @@ class ReactorRunnable : protected ACE_Task_Base } } - sLog->outStaticDebug ("Network Thread Exitting"); + sLog->outStaticDebug ("Network Thread exits"); return 0; } diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 4876f435f55..152f94ad420 100755 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -719,7 +719,7 @@ int32 AuraEffect::CalculateAmount(Unit* caster) case SPELL_AURA_MOD_THREAT: { uint8 level_diff = 0; - float multiplier = 0.0; + float multiplier = 0.0f; switch (GetId()) { // Arcane Shroud @@ -903,25 +903,6 @@ void AuraEffect::CalculateSpellMod() default: break; } - case SPELL_AURA_MOD_SPELL_CRIT_CHANCE: - switch (GetId()) - { - case 51466: // Elemental oath - case 51470: // Elemental oath - // "while Clearcasting from Elemental Focus is active, you deal 5%/10% more spell damage." - if (!m_spellmod) - { - m_spellmod = new SpellModifier(GetBase()); - m_spellmod->op = SPELLMOD_EFFECT2; - m_spellmod->type = SPELLMOD_FLAT; - m_spellmod->spellId = GetId(); - m_spellmod->mask[1] = 0x0004000; - } - m_spellmod->value = GetBase()->GetUnitOwner()->CalculateSpellDamage(GetBase()->GetUnitOwner(), GetSpellInfo(), 1); - break; - default: - break; - } break; case SPELL_AURA_ADD_FLAT_MODIFIER: case SPELL_AURA_ADD_PCT_MODIFIER: @@ -1588,9 +1569,9 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const target->RemoveAurasDueToSpell(spellId2); // Improved Barkskin - apply/remove armor bonus due to shapeshift - if (Player* pl=target->ToPlayer()) + if (Player* player=target->ToPlayer()) { - if (pl->HasSpell(63410) || pl->HasSpell(63411)) + if (player->HasSpell(63410) || player->HasSpell(63411)) { target->RemoveAurasDueToSpell(66530); target->CastSpell(target, 66530, true); @@ -2866,7 +2847,7 @@ void AuraEffect::HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode if (target->GetTypeId() == TYPEID_UNIT) target->SetFlying(apply); - if (Player* plr = target->m_movedPlayer) + if (Player* player = target->m_movedPlayer) { // allow flying WorldPacket data; @@ -2876,7 +2857,7 @@ void AuraEffect::HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12); data.append(target->GetPackGUID()); data << uint32(0); // unk - plr->SendDirectMessage(&data); + player->SendDirectMessage(&data); } } @@ -3265,16 +3246,16 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp, // do not remove unit flag if there are more than this auraEffect of that kind on unit on unit if (mode & AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK && (apply || (!target->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !target->HasAuraType(SPELL_AURA_FLY)))) { - if (Player* plr = target->m_movedPlayer) + if (Player* player = target->m_movedPlayer) { WorldPacket data; if (apply) data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12); else data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12); - data.append(plr->GetPackGUID()); + data.append(player->GetPackGUID()); data << uint32(0); // unknown - plr->SendDirectMessage(&data); + player->SendDirectMessage(&data); } } @@ -4003,8 +3984,18 @@ void AuraEffect::HandleAuraModIncreaseEnergyPercent(AuraApplication const* aurAp // return; UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType); + float amount = float(GetAmount()); - target->HandleStatModifier(unitMod, TOTAL_PCT, float(GetAmount()), apply); + if (apply) + { + target->HandleStatModifier(unitMod, TOTAL_PCT, amount, apply); + target->ModifyPowerPct(powerType, amount, apply); + } + else + { + target->ModifyPowerPct(powerType, amount, apply); + target->HandleStatModifier(unitMod, TOTAL_PCT, amount, apply); + } } void AuraEffect::HandleAuraModIncreaseHealthPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const @@ -5403,9 +5394,9 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode if (target->GetTypeId() != TYPEID_PLAYER) return; - Player* plr = (Player*)target; + Player* player = (Player*)target; - if (plr->getClass() != CLASS_DEATH_KNIGHT) + if (player->getClass() != CLASS_DEATH_KNIGHT) return; uint32 runes = m_amount; @@ -5414,17 +5405,17 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode { for (uint32 i = 0; i < MAX_RUNES && runes; ++i) { - if (GetMiscValue() != plr->GetCurrentRune(i)) + if (GetMiscValue() != player->GetCurrentRune(i)) continue; - if (!plr->GetRuneCooldown(i)) + if (!player->GetRuneCooldown(i)) { - plr->AddRuneByAuraEffect(i, RuneType(GetMiscValueB()), this); + player->AddRuneByAuraEffect(i, RuneType(GetMiscValueB()), this); --runes; } } } else - plr->RemoveRunesByAuraEffect(this); + player->RemoveRunesByAuraEffect(this); } void AuraEffect::HandleAuraLinked(AuraApplication const* aurApp, uint8 mode, bool apply) const @@ -5608,6 +5599,9 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const case 66149: // Bullet Controller Periodic - 10 Man case 68396: // Bullet Controller Periodic - 25 Man { + if (!caster) + break; + caster->CastCustomSpell(66152, SPELLVALUE_MAX_TARGETS, urand(1, 6), target, true); caster->CastCustomSpell(66153, SPELLVALUE_MAX_TARGETS, urand(1, 6), target, true); break; @@ -5720,9 +5714,8 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const // eff_radius == 0 float radius = GetSpellInfo()->GetMaxRange(false); - CellPair p(Trinity::ComputeCellPair(target->GetPositionX(), target->GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(target->GetPositionX(), target->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; Trinity::AnyUnfriendlyAttackableVisibleUnitInObjectRangeCheck u_check(target, radius); Trinity::UnitListSearcher<Trinity::AnyUnfriendlyAttackableVisibleUnitInObjectRangeCheck> checker(target, targets, u_check); diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index df6ac44f2cc..525084a70ed 100755 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -557,7 +557,14 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply) else { // owner has to be in world, or effect has to be applied to self - ASSERT((!GetOwner()->IsInWorld() && GetOwner() == itr->first) || GetOwner()->IsInMap(itr->first)); + if (!GetOwner()->IsSelfOrInSameMap(itr->first)) + { + //TODO: There is a crash caused by shadowfiend load addon + sLog->outCrash("Aura %u: Owner %s (map %u) is not in the same map as target %s (map %u).", GetSpellInfo()->Id, + GetOwner()->GetName(), GetOwner()->IsInWorld() ? GetOwner()->GetMap()->GetId() : uint32(-1), + itr->first->GetName(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() : uint32(-1)); + ASSERT(false); + } itr->first->_CreateAuraApplication(this, itr->second); ++itr; } diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index fd782519410..dc56e04c3b5 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -598,9 +598,8 @@ WorldObject* Spell::FindCorpseUsing() // non-standard target selection float max_range = m_spellInfo->GetMaxRange(false); - CellPair p(Trinity::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(m_caster->GetPositionX(), m_caster->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); WorldObject* result = NULL; @@ -1202,7 +1201,6 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) m_spellAura = NULL; // Set aura to null for every target-make sure that pointer is not used for unit without aura applied //Spells with this flag cannot trigger if effect is casted on self - // Slice and Dice, relentless strikes, eviscerate bool canEffectTrigger = !(m_spellInfo->AttributesEx3 & SPELL_ATTR3_CANT_TRIGGER_PROC) && unitTarget->CanProc() && CanExecuteTriggersOnHit(mask); Unit* spellHitTarget = NULL; @@ -1433,7 +1431,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, const uint32 effectMask, bool if (m_spellInfo->Speed > 0.0f && unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE) && unit->GetCharmerOrOwnerGUID() != m_caster->GetGUID()) return SPELL_MISS_EVADE; - if (m_caster->IsValidAttackTarget(unit)) + if (m_caster->_IsValidAttackTarget(unit, m_spellInfo)) { unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_HITBYSPELL); //TODO: This is a hack. But we do not know what types of stealth should be interrupted by CC @@ -1539,7 +1537,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, const uint32 effectMask, bool if (AuraApplication* aurApp = m_spellAura->GetApplicationOfTarget(m_originalCaster->GetGUID())) positive = aurApp->IsPositive(); - duration = m_originalCaster->ModSpellDuration(aurSpellInfo, unit, duration, positive); + duration = m_originalCaster->ModSpellDuration(aurSpellInfo, unit, duration, positive, effectMask); // Haste modifies duration of channeled spells if (m_spellInfo->IsChanneled()) @@ -1598,12 +1596,12 @@ void Spell::DoTriggersOnSpellHit(Unit* unit, uint8 effMask) // this is executed after spell proc spells on target hit // spells are triggered for each hit spell target // info confirmed with retail sniffs of permafrost and shadow weaving - if (!m_hitTriggerSpells.empty() && CanExecuteTriggersOnHit(effMask)) + if (!m_hitTriggerSpells.empty()) { int _duration = 0; for (HitTriggerSpells::const_iterator i = m_hitTriggerSpells.begin(); i != m_hitTriggerSpells.end(); ++i) { - if (roll_chance_i(i->second)) + if (CanExecuteTriggersOnHit(effMask, i->first) && roll_chance_i(i->second)) { m_caster->CastSpell(unit, i->first, true); sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Spell %d triggered spell %d by SPELL_AURA_ADD_TARGET_TRIGGER aura", m_spellInfo->Id, i->first->Id); @@ -3836,19 +3834,23 @@ void Spell::SendSpellGo() if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list { - Player* player = m_caster->ToPlayer(); - uint8 runeMaskInitial = m_runesState; - uint8 runeMaskAfterCast = player->GetRunesState(); - data << uint8(runeMaskInitial); // runes state before - data << uint8(runeMaskAfterCast); // runes state after - for (uint8 i = 0; i < MAX_RUNES; ++i) + //TODO: There is a crash caused by a spell with CAST_FLAG_RUNE_LIST casted by a creature + //The creature is the mover of a player, so HandleCastSpellOpcode uses it as the caster + if (Player* player = m_caster->ToPlayer()) { - uint8 mask = (1 << i); - if (mask & runeMaskInitial && !(mask & runeMaskAfterCast)) // usable before andon cooldown now... + uint8 runeMaskInitial = m_runesState; + uint8 runeMaskAfterCast = player->GetRunesState(); + data << uint8(runeMaskInitial); // runes state before + data << uint8(runeMaskAfterCast); // runes state after + for (uint8 i = 0; i < MAX_RUNES; ++i) { - // float casts ensure the division is performed on floats as we need float result - float baseCd = float(player->GetRuneBaseCooldown(i)); - data << uint8((baseCd - float(player->GetRuneCooldown(i))) / baseCd * 255); // rune cooldown passed + uint8 mask = (1 << i); + if (mask & runeMaskInitial && !(mask & runeMaskAfterCast)) // usable before andon cooldown now... + { + // float casts ensure the division is performed on floats as we need float result + float baseCd = float(player->GetRuneBaseCooldown(i)); + data << uint8((baseCd - float(player->GetRuneCooldown(i))) / baseCd * 255); // rune cooldown passed + } } } } @@ -4328,9 +4330,9 @@ SpellCastResult Spell::CheckRuneCost(uint32 runeCostID) if (m_caster->GetTypeId() != TYPEID_PLAYER) return SPELL_CAST_OK; - Player* plr = (Player*)m_caster; + Player* player = (Player*)m_caster; - if (plr->getClass() != CLASS_DEATH_KNIGHT) + if (player->getClass() != CLASS_DEATH_KNIGHT) return SPELL_CAST_OK; SpellRuneCostEntry const* src = sSpellRuneCostStore.LookupEntry(runeCostID); @@ -4354,8 +4356,8 @@ SpellCastResult Spell::CheckRuneCost(uint32 runeCostID) for (uint32 i = 0; i < MAX_RUNES; ++i) { - RuneType rune = plr->GetCurrentRune(i); - if ((plr->GetRuneCooldown(i) == 0) && (runeCost[rune] > 0)) + RuneType rune = player->GetCurrentRune(i); + if ((player->GetRuneCooldown(i) == 0) && (runeCost[rune] > 0)) runeCost[rune]--; } @@ -5639,7 +5641,16 @@ SpellCastResult Spell::CheckRange(bool strict) if (!strict && m_casttime == 0) return SPELL_CAST_OK; - uint32 range_type = m_spellInfo->RangeEntry ? m_spellInfo->RangeEntry->type : 0; + uint32 range_type = 0; + + if (m_spellInfo->RangeEntry) + { + // self cast is used for triggered spells, no range checking needed + if (m_spellInfo->RangeEntry->ID == 1) + return SPELL_CAST_OK; + + range_type = m_spellInfo->RangeEntry->type; + } Unit* target = m_targets.GetUnitTarget(); float max_range = m_caster->GetSpellMaxRangeForTarget(target, m_spellInfo); @@ -5820,9 +5831,8 @@ SpellCastResult Spell::CheckItems() // check spell focus object if (m_spellInfo->RequiresSpellFocus) { - CellPair p(Trinity::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(m_caster->GetPositionX(), m_caster->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; GameObject* ok = NULL; Trinity::GameObjectFocusCheck go_check(m_caster, m_spellInfo->RequiresSpellFocus); @@ -6409,7 +6419,8 @@ bool Spell::IsNextMeleeSwingSpell() const bool Spell::IsAutoActionResetSpell() const { - return !IsTriggered() && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK); + // TODO: changed SPELL_INTERRUPT_FLAG_AUTOATTACK -> SPELL_INTERRUPT_FLAG_INTERRUPT to fix compile - is this check correct at all? + return !IsTriggered() && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT); } bool Spell::IsNeedSendToClient() const @@ -7085,17 +7096,17 @@ void Spell::CallScriptAfterUnitTargetSelectHandlers(std::list<Unit*>& unitTarget } } -bool Spell::CanExecuteTriggersOnHit(uint8 effMask) const +bool Spell::CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const* spellInfo) const { - // check which effects can trigger proc - // don't allow to proc for dummy-only spell target hits - // prevents triggering/procing effects twice from spells like Eviscerate - for (uint8 i = 0;effMask && i < MAX_SPELL_EFFECTS; ++i) + bool only_on_dummy = (spellInfo && (spellInfo->AttributesEx4 & SPELL_ATTR4_PROC_ONLY_ON_DUMMY)); + // If triggered spell has SPELL_ATTR4_PROC_ONLY_ON_DUMMY then it can only proc on a casted spell with SPELL_EFFECT_DUMMY + // If triggered spell doesn't have SPELL_ATTR4_PROC_ONLY_ON_DUMMY then it can NOT proc on SPELL_EFFECT_DUMMY (needs confirmation) + for (uint8 i = 0;i < MAX_SPELL_EFFECTS; ++i) { - if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_DUMMY) - effMask &= ~(1<<i); + if ((effMask & (1 << i)) && (only_on_dummy == (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_DUMMY))) + return true; } - return effMask; + return false; } void Spell::PrepareTriggersExecutedOnHit() diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 27b0844f32e..624c3b9b9b3 100755 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -453,7 +453,7 @@ class Spell UsedSpellMods m_appliedMods; - int32 CalcCastTime() const { return m_casttime; } + int32 GetCastTime() const { return m_casttime; } bool IsAutoRepeat() const { return m_autoRepeat; } void SetAutoRepeat(bool rep) { m_autoRepeat = rep; } void ReSetTimer() { m_timer = m_casttime > 0 ? m_casttime : 0; } @@ -633,7 +633,7 @@ class Spell void CallScriptAfterUnitTargetSelectHandlers(std::list<Unit*>& unitTargets, SpellEffIndex effIndex); std::list<SpellScript*> m_loadedScripts; - bool CanExecuteTriggersOnHit(uint8 effMask) const; + bool CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const* spellInfo = NULL) const; void PrepareTriggersExecutedOnHit(); typedef std::list< std::pair<SpellInfo const*, int32> > HitTriggerSpells; HitTriggerSpells m_hitTriggerSpells; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 926a2280d18..db48f2b8693 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -456,7 +456,11 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex) ApplyPctF(damage, m_caster->GetTotalAttackPowerValue(BASE_ATTACK)); // Shield Slam else if (m_spellInfo->SpellFamilyFlags[1] & 0x200 && m_spellInfo->Category == 1209) - damage += int32(m_caster->ApplyEffectModifiers(m_spellInfo, effIndex, float(m_caster->GetShieldBlockValue()))); + { + uint8 level = m_caster->getLevel(); + uint32 block_value = m_caster->GetShieldBlockValue(uint32(float(level) * 24.5f), uint32(float(level) * 34.5f)); + damage += int32(m_caster->ApplyEffectModifiers(m_spellInfo, effIndex, float(block_value))); + } // Victory Rush else if (m_spellInfo->SpellFamilyFlags[1] & 0x100) ApplyPctF(damage, m_caster->GetTotalAttackPowerValue(BASE_ATTACK)); @@ -716,7 +720,9 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex) // Shield of Righteousness if (m_spellInfo->SpellFamilyFlags[EFFECT_1] & 0x100000) { - damage += CalculatePctN(m_caster->GetShieldBlockValue(), m_spellInfo->Effects[EFFECT_1].CalcValue()); + uint8 level = m_caster->getLevel(); + uint32 block_value = m_caster->GetShieldBlockValue(uint32(float(level) * 29.5f), uint32(float(level) * 39.5f)); + damage += CalculatePctN(block_value, m_spellInfo->Effects[EFFECT_1].CalcValue()); break; } break; @@ -1663,13 +1669,6 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex) } return; } - // Priest Shadowfiend (34433) need apply mana gain trigger aura on pet - case 41967: - { - if (Unit* pet = unitTarget->GetGuardianPet()) - pet->CastSpell(pet, 28305, true); - return; - } } } @@ -2142,6 +2141,16 @@ void Spell::EffectSendEvent(SpellEffIndex effIndex) && effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; + //! it's possible for spells with this spell effect to either have a target or no target + //! in case of a target, we will execute this handler on SPELL_EFFECT_HANDLE_HIT_TARGET + //! with all relevant variables, and we will skip SPELL_EFFECT_HANDLE_HIT + if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT) + { + if (GetSpellInfo()->Effects[effIndex].TargetA.GetTarget() != 0 || + GetSpellInfo()->Effects[effIndex].TargetB.GetTarget() != 0) + return; + } + WorldObject* target = NULL; // call events for target if present @@ -2238,6 +2247,13 @@ void Spell::EffectHeal(SpellEffIndex /*effIndex*/) addhealth += damageAmount; } + // Runic Healing Injector (heal increased by 25% for engineers - 3.2.0 patch change) + else if (m_spellInfo->Id == 67489) + { + if (Player* player = m_caster->ToPlayer()) + if (player->HasSkill(SKILL_ENGINEERING)) + AddPctN(addhealth, 25); + } // Swiftmend - consumes Regrowth or Rejuvenation else if (m_spellInfo->TargetAuraState == AURA_STATE_SWIFTMEND && unitTarget->HasAuraState(AURA_STATE_SWIFTMEND, m_spellInfo, m_caster)) { @@ -2575,7 +2591,7 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex) return; } - dynObj->GetMap()->Add(dynObj); + dynObj->GetMap()->AddToMap(dynObj); if (Aura* aura = Aura::TryCreate(m_spellInfo, MAX_EFFECT_MASK, dynObj, caster, &m_spellValue->EffectBasePoints[0])) { @@ -2630,6 +2646,13 @@ void Spell::EffectEnergize(SpellEffIndex effIndex) case 48542: // Revitalize damage = int32(CalculatePctN(unitTarget->GetMaxPower(power), damage)); break; + case 67490: // Runic Mana Injector (mana gain increased by 25% for engineers - 3.2.0 patch change) + { + if (Player* player = m_caster->ToPlayer()) + if (player->HasSkill(SKILL_ENGINEERING)) + AddPctN(damage, 25); + break; + } case 71132: // Glyph of Shadow Word: Pain damage = int32(CalculatePctN(unitTarget->GetCreateMana(), 1)); // set 1 as value, missing in dbc break; @@ -3368,7 +3391,7 @@ void Spell::EffectDistract(SpellEffIndex /*effIndex*/) if (unitTarget->GetTypeId() == TYPEID_PLAYER) { // For players just turn them - unitTarget->ToPlayer()->SetPosition(unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), angle, false); + unitTarget->ToPlayer()->UpdatePosition(unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), angle, false); unitTarget->ToPlayer()->SendTeleportAckPacket(); } else @@ -3422,7 +3445,7 @@ void Spell::EffectAddFarsight(SpellEffIndex effIndex) dynObj->SetDuration(duration); dynObj->setActive(true); //must before add to map to be put in world container - dynObj->GetMap()->Add(dynObj); //grid will also be loaded + dynObj->GetMap()->AddToMap(dynObj); //grid will also be loaded dynObj->SetCasterViewpoint(); } @@ -3575,7 +3598,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) // add new enchanting if equipped item_owner->ApplyEnchantment(itemTarget, PERM_ENCHANTMENT_SLOT, true); - itemTarget->SetSoulboundTradeable(NULL, item_owner, false); + itemTarget->ClearSoulboundTradeable(item_owner); } } @@ -3639,7 +3662,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) // add new enchanting if equipped item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, true); - itemTarget->SetSoulboundTradeable(NULL, item_owner, false); + itemTarget->ClearSoulboundTradeable(item_owner); } void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) @@ -3812,7 +3835,7 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/) pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1); // add to world - pet->GetMap()->Add(pet->ToCreature()); + pet->GetMap()->AddToMap(pet->ToCreature()); // visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL, level); @@ -4320,19 +4343,22 @@ void Spell::EffectInterruptCast(SpellEffIndex effIndex) // TODO: not all spells that used this effect apply cooldown at school spells // also exist case: apply cooldown to interrupted cast only and to all spells - for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i) + // there is no CURRENT_AUTOREPEAT_SPELL spells that can be interrupted + for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_AUTOREPEAT_SPELL; ++i) { if (Spell* spell = unitTarget->GetCurrentSpell(CurrentSpellTypes(i))) { SpellInfo const* curSpellInfo = spell->m_spellInfo; // check if we can interrupt spell if ((spell->getState() == SPELL_STATE_CASTING - || (spell->getState() == SPELL_STATE_PREPARING && spell->CalcCastTime() > 0.0f)) - && curSpellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT && curSpellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) + || (spell->getState() == SPELL_STATE_PREPARING && spell->GetCastTime() > 0.0f)) + && curSpellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE + && ((i == CURRENT_GENERIC_SPELL && curSpellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT) + || (i == CURRENT_CHANNELED_SPELL && curSpellInfo->ChannelInterruptFlags & CHANNEL_INTERRUPT_FLAG_INTERRUPT))) { if (m_originalCaster) { - int32 duration = m_originalCaster->ModSpellDuration(m_spellInfo, unitTarget, m_originalCaster->CalcSpellDuration(m_spellInfo), false); + int32 duration = m_originalCaster->ModSpellDuration(m_spellInfo, unitTarget, m_originalCaster->CalcSpellDuration(m_spellInfo), false, 1 << effIndex); unitTarget->ProhibitSpellSchool(curSpellInfo->GetSchoolMask(), duration/*GetSpellDuration(m_spellInfo)*/); } ExecuteLogEffectInterruptCast(effIndex, unitTarget, curSpellInfo->Id); @@ -4378,12 +4404,12 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) ExecuteLogEffectSummonObject(effIndex, pGameObj); // Wild object not have owner and check clickable by players - map->Add(pGameObj); + map->AddToMap(pGameObj); if (pGameObj->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP && m_caster->GetTypeId() == TYPEID_PLAYER) { - Player* pl = m_caster->ToPlayer(); - Battleground* bg = pl->GetBattleground(); + Player* player = m_caster->ToPlayer(); + Battleground* bg = player->GetBattleground(); switch (pGameObj->GetMapId()) { @@ -4393,7 +4419,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) { uint32 team = ALLIANCE; - if (pl->GetTeam() == team) + if (player->GetTeam() == team) team = HORDE; ((BattlegroundWS*)bg)->SetDroppedFlagGUID(pGameObj->GetGUID(), team); @@ -4423,7 +4449,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) ExecuteLogEffectSummonObject(effIndex, linkedGO); // Wild object not have owner and check clickable by players - map->Add(linkedGO); + map->AddToMap(linkedGO); } else { @@ -4937,6 +4963,25 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) } return; } + case 57347: // Retrieving (Wintergrasp RP-GG pickup spell) + { + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + unitTarget->ToCreature()->DespawnOrUnsummon(); + + return; + } + case 57349: // Drop RP-GG (Wintergrasp RP-GG at death drop spell) + { + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + // Delete item from inventory at death + m_caster->ToPlayer()->DestroyItemCount(damage, 5, true); + + return; + } case 58418: // Portal to Orgrimmar case 58420: // Portal to Stormwind { @@ -5328,11 +5373,11 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) case 64142: // Upper Deck - Create Foam Sword if (unitTarget->GetTypeId() != TYPEID_PLAYER) return; - Player* plr = unitTarget->ToPlayer(); + Player* player = unitTarget->ToPlayer(); static uint32 const itemId[] = {45061, 45176, 45177, 45178, 45179, 0}; // player can only have one of these items for (uint32 const* itr = &itemId[0]; *itr; ++itr) - if (plr->HasItemCount(*itr, 1, true)) + if (player->HasItemCount(*itr, 1, true)) return; DoCreateItem(effIndex, itemId[urand(0, 4)]); return; @@ -5583,7 +5628,7 @@ void Spell::EffectDuel(SpellEffIndex effIndex) ExecuteLogEffectSummonObject(effIndex, pGameObj); m_caster->AddGameObject(pGameObj); - map->Add(pGameObj); + map->AddToMap(pGameObj); //END // Send request @@ -5934,7 +5979,7 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex) ExecuteLogEffectSummonObject(effIndex, pGameObj); - map->Add(pGameObj); + map->AddToMap(pGameObj); m_caster->m_ObjectSlot[slot] = pGameObj->GetGUID(); } @@ -6139,15 +6184,15 @@ void Spell::EffectSelfResurrect(SpellEffIndex effIndex) mana = CalculatePctN(m_caster->GetMaxPower(POWER_MANA), damage); } - Player* plr = m_caster->ToPlayer(); - plr->ResurrectPlayer(0.0f); + Player* player = m_caster->ToPlayer(); + player->ResurrectPlayer(0.0f); - plr->SetHealth(health); - plr->SetPower(POWER_MANA, mana); - plr->SetPower(POWER_RAGE, 0); - plr->SetPower(POWER_ENERGY, plr->GetMaxPower(POWER_ENERGY)); + player->SetHealth(health); + player->SetPower(POWER_MANA, mana); + player->SetPower(POWER_RAGE, 0); + player->SetPower(POWER_ENERGY, player->GetMaxPower(POWER_ENERGY)); - plr->SpawnCorpseBones(); + player->SpawnCorpseBones(); } void Spell::EffectSkinning(SpellEffIndex /*effIndex*/) @@ -6630,7 +6675,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) //m_caster->AddGameObject(pGameObj); //m_ObjToDel.push_back(pGameObj); - cMap->Add(pGameObj); + cMap->AddToMap(pGameObj); if (uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry()) { @@ -6645,7 +6690,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) ExecuteLogEffectSummonObject(effIndex, linkedGO); - linkedGO->GetMap()->Add(linkedGO); + linkedGO->GetMap()->AddToMap(linkedGO); } else { @@ -6921,9 +6966,9 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex) if (m_caster->GetTypeId() != TYPEID_PLAYER) return; - Player* plr = m_caster->ToPlayer(); + Player* player = m_caster->ToPlayer(); - if (plr->getClass() != CLASS_DEATH_KNIGHT) + if (player->getClass() != CLASS_DEATH_KNIGHT) return; // needed later @@ -6933,9 +6978,9 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex) if (count == 0) count = 1; for (uint32 j = 0; j < MAX_RUNES && count > 0; ++j) { - if (plr->GetRuneCooldown(j) && plr->GetCurrentRune(j) == RuneType(m_spellInfo->Effects[effIndex].MiscValue)) + if (player->GetRuneCooldown(j) && player->GetCurrentRune(j) == RuneType(m_spellInfo->Effects[effIndex].MiscValue)) { - plr->SetRuneCooldown(j, 0); + player->SetRuneCooldown(j, 0); --count; } } @@ -6948,8 +6993,8 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex) for (uint32 i = 0; i < MAX_RUNES; ++i) { - if (plr->GetRuneCooldown(i) && (plr->GetCurrentRune(i) == RUNE_FROST || plr->GetCurrentRune(i) == RUNE_DEATH)) - plr->SetRuneCooldown(i, 0); + if (player->GetRuneCooldown(i) && (player->GetCurrentRune(i) == RUNE_FROST || player->GetCurrentRune(i) == RUNE_DEATH)) + player->SetRuneCooldown(i, 0); } } } @@ -6968,7 +7013,7 @@ void Spell::EffectCreateTamedPet(SpellEffIndex effIndex) return; // add to world - pet->GetMap()->Add(pet->ToCreature()); + pet->GetMap()->AddToMap(pet->ToCreature()); // unitTarget has pet now unitTarget->SetMinion(pet, true); @@ -7069,9 +7114,9 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* // level of pet summoned using engineering item based at engineering skill level if (m_CastItem && caster->GetTypeId() == TYPEID_PLAYER) if (ItemTemplate const* proto = m_CastItem->GetTemplate()) - if (proto->RequiredSkill == SKILL_ENGINERING) - if (uint16 skill202 = caster->ToPlayer()->GetSkillValue(SKILL_ENGINERING)) - level = skill202/5; + if (proto->RequiredSkill == SKILL_ENGINEERING) + if (uint16 skill202 = caster->ToPlayer()->GetSkillValue(SKILL_ENGINEERING)) + level = skill202 / 5; //float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); float radius = 5.0f; diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 543baa82789..972276c7d26 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1735,6 +1735,17 @@ uint32 SpellInfo::GetEffectMechanicMask(uint8 effIndex) const return mask; } +uint32 SpellInfo::GetSpellMechanicMaskByEffectMask(uint32 effectMask) const +{ + uint32 mask = 0; + if (Mechanic) + mask |= 1<< Mechanic; + for (int i = 0; i < MAX_SPELL_EFFECTS; ++i) + if ((effectMask & (1 << i)) && Effects[i].Mechanic) + mask |= 1<< Effects[i].Mechanic; + return mask; +} + Mechanics SpellInfo::GetEffectMechanic(uint8 effIndex) const { if (Effects[effIndex].IsEffect() && Effects[effIndex].Mechanic) diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index b4f4ca8c11e..7faf0de890d 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -444,6 +444,7 @@ public: SpellSchoolMask GetSchoolMask() const; uint32 GetAllEffectsMechanicMask() const; uint32 GetEffectMechanicMask(uint8 effIndex) const; + uint32 GetSpellMechanicMaskByEffectMask(uint32 effectMask) const; Mechanics GetEffectMechanic(uint8 effIndex) const; uint32 GetDispelMask() const; static uint32 GetDispelMask(DispelType type); diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index cfa28080b2b..c85758c3897 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -96,7 +96,7 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto, return DIMINISHING_CONTROLLED_ROOT; // Dragon's Breath else if (spellproto->SpellFamilyFlags[0] & 0x800000) - return DIMINISHING_DISORIENT; + return DIMINISHING_DRAGONS_BREATH; break; } case SPELLFAMILY_WARRIOR: @@ -167,7 +167,7 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto, } case SPELLFAMILY_HUNTER: { - // Hunter's mark + // Hunter's Mark if ((spellproto->SpellFamilyFlags[0] & 0x400) && spellproto->SpellIconID == 538) return DIMINISHING_LIMITONLY; // Scatter Shot (own diminishing) @@ -321,20 +321,20 @@ bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group) { switch (group) { + case DIMINISHING_BANISH: case DIMINISHING_CONTROLLED_STUN: - case DIMINISHING_STUN: - case DIMINISHING_ENTRAPMENT: case DIMINISHING_CONTROLLED_ROOT: - case DIMINISHING_ROOT: + case DIMINISHING_CYCLONE: + case DIMINISHING_DISORIENT: + case DIMINISHING_ENTRAPMENT: case DIMINISHING_FEAR: + case DIMINISHING_HORROR: case DIMINISHING_MIND_CONTROL: - case DIMINISHING_DISORIENT: - case DIMINISHING_CYCLONE: - case DIMINISHING_BANISH: - case DIMINISHING_LIMITONLY: case DIMINISHING_OPENING_STUN: - case DIMINISHING_HORROR: + case DIMINISHING_ROOT: + case DIMINISHING_STUN: case DIMINISHING_SLEEP: + case DIMINISHING_LIMITONLY: return true; default: return false; @@ -351,7 +351,7 @@ SpellMgr::~SpellMgr() } /// Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book, etc -bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* pl, bool msg) +bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* player, bool msg) { // not exist if (!spellInfo) @@ -378,8 +378,8 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* pl, bool msg) { if (msg) { - if (pl) - ChatHandler(pl).PSendSysMessage("Craft spell %u not have create item entry.", spellInfo->Id); + if (player) + ChatHandler(player).PSendSysMessage("Craft spell %u not have create item entry.", spellInfo->Id); else sLog->outErrorDb("Craft spell %u not have create item entry.", spellInfo->Id); } @@ -392,8 +392,8 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* pl, bool msg) { if (msg) { - if (pl) - ChatHandler(pl).PSendSysMessage("Craft spell %u create not-exist in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Effects[i].ItemType); + if (player) + ChatHandler(player).PSendSysMessage("Craft spell %u create not-exist in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Effects[i].ItemType); else sLog->outErrorDb("Craft spell %u create not-exist in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Effects[i].ItemType); } @@ -406,12 +406,12 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* pl, bool msg) case SPELL_EFFECT_LEARN_SPELL: { SpellInfo const* spellInfo2 = sSpellMgr->GetSpellInfo(spellInfo->Effects[i].TriggerSpell); - if (!IsSpellValid(spellInfo2, pl, msg)) + if (!IsSpellValid(spellInfo2, player, msg)) { if (msg) { - if (pl) - ChatHandler(pl).PSendSysMessage("Spell %u learn to broken spell %u, and then...", spellInfo->Id, spellInfo->Effects[i].TriggerSpell); + if (player) + ChatHandler(player).PSendSysMessage("Spell %u learn to broken spell %u, and then...", spellInfo->Id, spellInfo->Effects[i].TriggerSpell); else sLog->outErrorDb("Spell %u learn to invalid spell %u, and then...", spellInfo->Id, spellInfo->Effects[i].TriggerSpell); } @@ -430,8 +430,8 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* pl, bool msg) { if (msg) { - if (pl) - ChatHandler(pl).PSendSysMessage("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Reagent[j]); + if (player) + ChatHandler(player).PSendSysMessage("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Reagent[j]); else sLog->outErrorDb("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Reagent[j]); } @@ -694,6 +694,38 @@ void SpellMgr::GetSetOfSpellsInSpellGroup(SpellGroup group_id, std::set<uint32>& } } +bool SpellMgr::AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, int32 amount, std::map<SpellGroup, int32>& groups) const +{ + uint32 spellId = spellInfo->GetFirstRankSpell()->Id; + SpellSpellGroupMapBounds spellGroup = GetSpellSpellGroupMapBounds(spellId); + // Find group with SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT if it belongs to one + for (SpellSpellGroupMap::const_iterator itr = spellGroup.first; itr != spellGroup.second ; ++itr) + { + SpellGroup group = itr->second; + SpellGroupStackMap::const_iterator found = mSpellGroupStack.find(group); + if (found != mSpellGroupStack.end()) + { + if (found->second == SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT) + { + // Put the highest amount in the map + if (groups.find(group) == groups.end()) + groups[group] = amount; + else + { + int32 curr_amount = groups[group]; + // Take absolute value because this also counts for the highest negative aura + if (abs(curr_amount) < abs(amount)) + groups[group] = amount; + } + // return because a spell should be in only one SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT group + return true; + } + } + } + // Not in a SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT group, so return false + return false; +} + SpellGroupStackRule SpellMgr::CheckSpellGroupStackRules(SpellInfo const* spellInfo1, SpellInfo const* spellInfo2) const { uint32 spellid_1 = spellInfo1->GetFirstRankSpell()->Id; @@ -2937,7 +2969,7 @@ void SpellMgr::LoadDbcDataCorrections() spellInfo->EffectImplicitTargetB[0] = 0; break; case 31344: // Howl of Azgalor - spellInfo->EffectRadiusIndex[0] = 12; // 100yards instead of 50000?! + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_100_YARDS; // 100yards instead of 50000?! break; case 42818: // Headless Horseman - Wisp Flight Port case 42821: // Headless Horseman - Wisp Flight Missile @@ -2973,7 +3005,7 @@ void SpellMgr::LoadDbcDataCorrections() case 59725: // Improved Spell Reflection - aoe aura // Target entry seems to be wrong for this spell :/ spellInfo->EffectImplicitTargetA[0] = TARGET_UNIT_CASTER_AREA_PARTY; - spellInfo->EffectRadiusIndex[0] = 45; + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_10_YARDS_2; break; case 44978: case 45001: case 45002: // Wild Magic case 45004: case 45006: case 45010: // Wild Magic @@ -3077,7 +3109,7 @@ void SpellMgr::LoadDbcDataCorrections() spellInfo->EffectImplicitTargetA[0] = TARGET_UNIT_CASTER; break; case 29809: // Desecration Arm - 36 instead of 37 - typo? :/ - spellInfo->EffectRadiusIndex[0] = 37; + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_7_YARDS; break; // Master Shapeshifter: missing stance data for forms other than bear - bear version has correct data // To prevent aura staying on target after talent unlearned @@ -3090,11 +3122,18 @@ void SpellMgr::LoadDbcDataCorrections() case 48422: spellInfo->Stances = 1 << (FORM_TREE - 1); break; + case 51466: // Elemental Oath (Rank 1) + case 51470: // Elemental Oath (Rank 2) + spellInfo->Effect[EFFECT_1] = SPELL_EFFECT_APPLY_AURA; + spellInfo->EffectApplyAuraName[EFFECT_1] = SPELL_AURA_ADD_FLAT_MODIFIER; + spellInfo->EffectMiscValue[EFFECT_1] = SPELLMOD_EFFECT2; + spellInfo->EffectSpellClassMask[EFFECT_1] = flag96(0x00000000, 0x00004000, 0x00000000); + break; case 47569: // Improved Shadowform (Rank 1) // with this spell atrribute aura can be stacked several times spellInfo->Attributes &= ~SPELL_ATTR0_NOT_SHAPESHIFT; break; - case 64904: //Hymn of Hope + case 64904: // Hymn of Hope spellInfo->EffectApplyAuraName[EFFECT_1] = SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT; break; case 30421: // Nether Portal - Perseverence @@ -3109,6 +3148,7 @@ void SpellMgr::LoadDbcDataCorrections() case 51726: spellInfo->AttributesEx3 |= SPELL_ATTR3_STACK_FOR_DIFF_CASTERS; spellInfo->SpellFamilyFlags[2] = 0x10; + spellInfo->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN; break; case 41913: // Parasitic Shadowfiend Passive spellInfo->EffectApplyAuraName[0] = 4; // proc debuff, and summon infinite fiends @@ -3139,6 +3179,24 @@ void SpellMgr::LoadDbcDataCorrections() case 6474: // Earthbind Totem (instant pulse) spellInfo->AttributesEx5 |= SPELL_ATTR5_START_PERIODIC_AT_APPLY; break; + case 2895: // Wrath of Air Totem rank 1 (Aura) + case 68933: // Wrath of Air Totem rank 2 (Aura) + spellInfo->EffectImplicitTargetA[0] = TARGET_UNIT_CASTER; + spellInfo->EffectImplicitTargetB[0] = 0; + break; + case 52109: // Flametongue Totem rank 1 (Aura) + case 52110: // Flametongue Totem rank 2 (Aura) + case 52111: // Flametongue Totem rank 3 (Aura) + case 52112: // Flametongue Totem rank 4 (Aura) + case 52113: // Flametongue Totem rank 5 (Aura) + case 58651: // Flametongue Totem rank 6 (Aura) + case 58654: // Flametongue Totem rank 7 (Aura) + case 58655: // Flametongue Totem rank 8 (Aura) + spellInfo->EffectImplicitTargetA[0] = TARGET_UNIT_CASTER; + spellInfo->EffectImplicitTargetA[1] = TARGET_UNIT_CASTER; + spellInfo->EffectImplicitTargetB[0] = 0; + spellInfo->EffectImplicitTargetB[1] = 0; + break; case 53241: // Marked for Death (Rank 1) case 53243: // Marked for Death (Rank 2) case 53244: // Marked for Death (Rank 3) @@ -3177,7 +3235,7 @@ void SpellMgr::LoadDbcDataCorrections() // ULDUAR SPELLS // case 62374: // Pursued (Flame Leviathan) - spellInfo->EffectRadiusIndex[0] = 28; // 50000yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // 50000yd break; case 63342: // Focused Eyebeam Summon Trigger (Kologarn) spellInfo->MaxAffectedTargets = 1; @@ -3245,7 +3303,7 @@ void SpellMgr::LoadDbcDataCorrections() break; case 69055: // Saber Lash (Lord Marrowgar) case 70814: // Saber Lash (Lord Marrowgar) - spellInfo->EffectRadiusIndex[0] = 8; // 5yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_5_YARDS; // 5yd break; case 69075: // Bone Storm (Lord Marrowgar) case 70834: // Bone Storm (Lord Marrowgar) @@ -3257,7 +3315,7 @@ void SpellMgr::LoadDbcDataCorrections() case 71160: // Plague Stench (Stinky) case 71161: // Plague Stench (Stinky) case 71123: // Decimate (Stinky & Precious) - spellInfo->EffectRadiusIndex[0] = 12; // 100yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_100_YARDS; // 100yd break; case 72723: // Resistant Skin (Deathbringer Saurfang adds) // this spell initially granted Shadow damage immunity, however it was removed but the data was left in client @@ -3284,7 +3342,7 @@ void SpellMgr::LoadDbcDataCorrections() case 72464: // Mutated Plague (Professor Putricide) case 72506: // Mutated Plague (Professor Putricide) case 72507: // Mutated Plague (Professor Putricide) - spellInfo->EffectRadiusIndex[0] = 28; // 50000yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // 50000yd break; case 70911: // Unbound Plague (Professor Putricide) (needs target selection script) case 72854: // Unbound Plague (Professor Putricide) (needs target selection script) @@ -3295,7 +3353,7 @@ void SpellMgr::LoadDbcDataCorrections() case 71518: // Unholy Infusion Quest Credit (Professor Putricide) case 72934: // Blood Infusion Quest Credit (Blood-Queen Lana'thel) case 72289: // Frost Infusion Quest Credit (Sindragosa) - spellInfo->EffectRadiusIndex[0] = 28; // another missing radius + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // another missing radius break; case 71708: // Empowered Flare (Blood Prince Council) case 72785: // Empowered Flare (Blood Prince Council) @@ -3322,7 +3380,7 @@ void SpellMgr::LoadDbcDataCorrections() break; case 72706: // Achievement Check (Valithria Dreamwalker) case 71357: // Order Whelp - spellInfo->EffectRadiusIndex[0] = 22; // 200yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd break; case 70598: // Sindragosa's Fury spellInfo->EffectImplicitTargetA[0] = TARGET_DEST_CASTER; @@ -3346,12 +3404,12 @@ void SpellMgr::LoadDbcDataCorrections() case 73708: // Defile case 73709: // Defile case 73710: // Defile - spellInfo->EffectRadiusIndex[0] = 22; // 200yd - spellInfo->EffectRadiusIndex[1] = 22; // 200yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd + spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_200_YARDS; // 200yd break; case 69030: // Val'kyr Target Search - spellInfo->EffectRadiusIndex[0] = 22; // 200yd - spellInfo->EffectRadiusIndex[1] = 22; // 200yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd + spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_200_YARDS; // 200yd break; case 69198: // Raging Spirit Visual spellInfo->rangeIndex = 13; // 50000yd @@ -3360,9 +3418,9 @@ void SpellMgr::LoadDbcDataCorrections() case 74295: // Harvest Souls case 74296: // Harvest Souls case 74297: // Harvest Souls - spellInfo->EffectRadiusIndex[0] = 28; // 50000yd - spellInfo->EffectRadiusIndex[1] = 28; // 50000yd - spellInfo->EffectRadiusIndex[2] = 28; // 50000yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // 50000yd + spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_50000_YARDS; // 50000yd + spellInfo->EffectRadiusIndex[2] = EFFECT_RADIUS_50000_YARDS; // 50000yd break; case 73655: // Harvest Soul spellInfo->AttributesEx3 |= SPELL_ATTR3_NO_DONE_BONUS; @@ -3374,34 +3432,34 @@ void SpellMgr::LoadDbcDataCorrections() spellInfo->DurationIndex = 28; // 5 seconds break; case 73529: // Shadow Trap - spellInfo->EffectRadiusIndex[1] = 13; // 10yd + spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_10_YARDS; // 10yd break; case 74282: // Shadow Trap (searcher) - spellInfo->EffectRadiusIndex[0] = 15; // 3yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_3_YARDS; // 3yd break; case 72595: // Restore Soul case 73650: // Restore Soul - spellInfo->EffectRadiusIndex[0] = 22; // 200yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd break; case 74086: // Destroy Soul - spellInfo->EffectRadiusIndex[0] = 22; // 200yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd break; case 74302: // Summon Spirit Bomb case 74342: // Summon Spirit Bomb - spellInfo->EffectRadiusIndex[0] = 22; // 200yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd spellInfo->MaxAffectedTargets = 1; break; case 74341: // Summon Spirit Bomb case 74343: // Summon Spirit Bomb - spellInfo->EffectRadiusIndex[0] = 22; // 200yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd spellInfo->MaxAffectedTargets = 3; break; case 73579: // Summon Spirit Bomb - spellInfo->EffectRadiusIndex[0] = 20; // 25yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_25_YARDS; // 25yd break; case 72350: // Fury of Frostmourne - spellInfo->EffectRadiusIndex[0] = 28; // 50000yd - spellInfo->EffectRadiusIndex[1] = 28; // 50000yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // 50000yd + spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_50000_YARDS; // 50000yd break; case 75127: // Kill Frostmourne Players case 72351: // Fury of Frostmourne @@ -3409,18 +3467,18 @@ void SpellMgr::LoadDbcDataCorrections() case 72429: // Mass Resurrection case 73159: // Play Movie case 73582: // Trigger Vile Spirit (Inside, Heroic) - spellInfo->EffectRadiusIndex[0] = 28; // 50000yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // 50000yd break; case 72376: // Raise Dead spellInfo->MaxAffectedTargets = 3; - spellInfo->EffectRadiusIndex[0] = 28; // 50000yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // 50000yd break; case 71809: // Jump spellInfo->rangeIndex = 3; // 20yd - spellInfo->EffectRadiusIndex[0] = 20; // 25yd + spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_25_YARDS; // 25yd break; case 72405: // Broken Frostmourne - spellInfo->EffectRadiusIndex[1] = 22; // 200yd + spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_200_YARDS; // 200yd break; default: break; diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index d701ab2882c..552519d9940 100755 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -322,6 +322,7 @@ typedef UNORDERED_MAP<uint32, SpellBonusEntry> SpellBonusMap; enum SpellGroup { + SPELL_GROUP_NONE = 0, SPELL_GROUP_ELIXIR_BATTLE = 1, SPELL_GROUP_ELIXIR_GUARDIAN = 2, SPELL_GROUP_ELIXIR_UNSTABLE = 3, @@ -344,8 +345,9 @@ enum SpellGroupStackRule SPELL_GROUP_STACK_RULE_DEFAULT = 0, SPELL_GROUP_STACK_RULE_EXCLUSIVE = 1, SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER = 2, + SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT = 3, }; -#define SPELL_GROUP_STACK_RULE_MAX 3 +#define SPELL_GROUP_STACK_RULE_MAX 4 typedef std::map<SpellGroup, SpellGroupStackRule> SpellGroupStackMap; @@ -379,6 +381,68 @@ struct SpellTargetPosition float target_Orientation; }; +// Enum with EffectRadiusIndex and their actual radius +enum EffectRadiusIndex +{ + EFFECT_RADIUS_2_YARDS = 7, + EFFECT_RADIUS_5_YARDS = 8, + EFFECT_RADIUS_20_YARDS = 9, + EFFECT_RADIUS_30_YARDS = 10, + EFFECT_RADIUS_45_YARDS = 11, + EFFECT_RADIUS_100_YARDS = 12, + EFFECT_RADIUS_10_YARDS = 13, + EFFECT_RADIUS_8_YARDS = 14, + EFFECT_RADIUS_3_YARDS = 15, + EFFECT_RADIUS_1_YARD = 16, + EFFECT_RADIUS_13_YARDS = 17, + EFFECT_RADIUS_15_YARDS = 18, + EFFECT_RADIUS_18_YARDS = 19, + EFFECT_RADIUS_25_YARDS = 20, + EFFECT_RADIUS_35_YARDS = 21, + EFFECT_RADIUS_200_YARDS = 22, + EFFECT_RADIUS_40_YARDS = 23, + EFFECT_RADIUS_65_YARDS = 24, + EFFECT_RADIUS_70_YARDS = 25, + EFFECT_RADIUS_4_YARDS = 26, + EFFECT_RADIUS_50_YARDS = 27, + EFFECT_RADIUS_50000_YARDS = 28, + EFFECT_RADIUS_6_YARDS = 29, + EFFECT_RADIUS_500_YARDS = 30, + EFFECT_RADIUS_80_YARDS = 31, + EFFECT_RADIUS_12_YARDS = 32, + EFFECT_RADIUS_99_YARDS = 33, + EFFECT_RADIUS_55_YARDS = 35, + EFFECT_RADIUS_0_YARDS = 36, + EFFECT_RADIUS_7_YARDS = 37, + EFFECT_RADIUS_21_YARDS = 38, + EFFECT_RADIUS_34_YARDS = 39, + EFFECT_RADIUS_9_YARDS = 40, + EFFECT_RADIUS_150_YARDS = 41, + EFFECT_RADIUS_11_YARDS = 42, + EFFECT_RADIUS_16_YARDS = 43, + EFFECT_RADIUS_0_5_YARDS = 44, // 0.5 yards + EFFECT_RADIUS_10_YARDS_2 = 45, + EFFECT_RADIUS_5_YARDS_2 = 46, + EFFECT_RADIUS_15_YARDS_2 = 47, + EFFECT_RADIUS_60_YARDS = 48, + EFFECT_RADIUS_90_YARDS = 49, + EFFECT_RADIUS_15_YARDS_3 = 50, + EFFECT_RADIUS_60_YARDS_2 = 51, + EFFECT_RADIUS_5_YARDS_3 = 52, + EFFECT_RADIUS_60_YARDS_3 = 53, + EFFECT_RADIUS_50000_YARDS_2 = 54, + EFFECT_RADIUS_130_YARDS = 55, + EFFECT_RADIUS_38_YARDS = 56, + EFFECT_RADIUS_45_YARDS_2 = 57, + EFFECT_RADIUS_32_YARDS = 59, + EFFECT_RADIUS_44_YARDS = 60, + EFFECT_RADIUS_14_YARDS = 61, + EFFECT_RADIUS_47_YARDS = 62, + EFFECT_RADIUS_23_YARDS = 63, + EFFECT_RADIUS_3_5_YARDS = 64, // 3.5 yards + EFFECT_RADIUS_80_YARDS_2 = 65 +}; + typedef UNORDERED_MAP<uint32, SpellTargetPosition> SpellTargetPositionMap; // Spell pet auras @@ -553,7 +617,7 @@ class SpellMgr // Accessors (const or static functions) public: // Spell correctess for client using - static bool IsSpellValid(SpellInfo const* spellInfo, Player* pl = NULL, bool msg = true); + static bool IsSpellValid(SpellInfo const* spellInfo, Player* player = NULL, bool msg = true); // Spell difficulty uint32 GetSpellDifficultyId(uint32 spellId) const; @@ -596,6 +660,7 @@ class SpellMgr void GetSetOfSpellsInSpellGroup(SpellGroup group_id, std::set<uint32>& foundSpells, std::set<SpellGroup>& usedGroups) const; // Spell Group Stack Rules table + bool AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, int32 amount, std::map<SpellGroup, int32>& groups) const; SpellGroupStackRule CheckSpellGroupStackRules(SpellInfo const* spellInfo1, SpellInfo const* spellInfo2) const; // Spell proc event table diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index f901c0acac8..2915bab4b77 100755 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -381,12 +381,12 @@ void CreatureTextMgr::SendChatPacket(WorldPacket* data, WorldObject* source, Cha const SessionMap smap = sWorld->GetAllSessions(); for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter) { - if (Player* plr = (*iter).second->GetPlayer()) + if (Player* player = (*iter).second->GetPlayer()) { if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid - data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(plr->GetGUID())); - if (plr->GetSession() && (!team || Team(plr->GetTeam()) == team) && (!gmOnly || plr->isGameMaster())) - plr->GetSession()->SendPacket(data); + data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(player->GetGUID())); + if (player->GetSession() && (!team || Team(player->GetTeam()) == team) && (!gmOnly || player->isGameMaster())) + player->GetSession()->SendPacket(data); } } return; diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp index 92fa001fe46..bdb912aa8b0 100644 --- a/src/server/game/Tools/PlayerDump.cpp +++ b/src/server/game/Tools/PlayerDump.cpp @@ -443,6 +443,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s typedef PetIds::value_type PetIdsPair; PetIds petids; + uint8 gender; + uint8 race; + uint8 playerClass; SQLTransaction trans = CharacterDatabase.BeginTransaction(); while (!feof(fin)) { @@ -512,6 +515,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s if (!changenth(line, 2, chraccount)) // characters.account update ROLLBACK(DUMP_FILE_BROKEN); + race = uint8(atol(getnth(line, 4).c_str())); + playerClass = uint8(atol(getnth(line, 5).c_str())); + gender = uint8(atol(getnth(line, 6).c_str())); if (name == "") { // check if the original name already exists @@ -520,10 +526,8 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s result = CharacterDatabase.PQuery("SELECT 1 FROM characters WHERE name = '%s'", name.c_str()); if (result) - { if (!changenth(line, 37, "1")) // characters.at_login set to "rename on login" ROLLBACK(DUMP_FILE_BROKEN); - } } else if (!changenth(line, 3, name.c_str())) // characters.name ROLLBACK(DUMP_FILE_BROKEN); @@ -654,6 +658,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s CharacterDatabase.CommitTransaction(trans); + // in case of name conflict player has to rename at login anyway + sWorld->AddCharacterNameData(guid, name, gender, race, playerClass); + sObjectMgr->m_hiItemGuid += items.size(); sObjectMgr->m_mailid += mails.size(); @@ -664,4 +671,3 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s return DUMP_SUCCESS; } - diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 34b93c71fb4..8aca4563b91 100755 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -132,10 +132,6 @@ World::~World() VMAP::VMapFactory::clear(); - // Clean up character name data - for (std::map<uint32, CharacterNameData*>::iterator itr = m_CharacterNameDataMap.begin(); itr != m_CharacterNameDataMap.end(); ++itr) - delete itr->second; - //TODO free addSessQueue } @@ -2750,22 +2746,18 @@ void World::UpdateMaxSessionCounters() void World::LoadDBVersion() { - QueryResult result = WorldDatabase.Query("SELECT db_version, script_version, cache_id FROM version LIMIT 1"); + QueryResult result = WorldDatabase.Query("SELECT db_version, cache_id FROM version LIMIT 1"); if (result) { Field* fields = result->Fetch(); m_DBVersion = fields[0].GetString(); - m_CreatureEventAIVersion = fields[1].GetString(); // will be overwrite by config values if different and non-0 - m_int_configs[CONFIG_CLIENTCACHE_VERSION] = fields[2].GetUInt32(); + m_int_configs[CONFIG_CLIENTCACHE_VERSION] = fields[1].GetUInt32(); } if (m_DBVersion.empty()) m_DBVersion = "Unknown world database."; - - if (m_CreatureEventAIVersion.empty()) - m_CreatureEventAIVersion = "Unknown creature EventAI."; } void World::ProcessStartEvent() @@ -2864,58 +2856,48 @@ void World::LoadCharacterNameData() return; } - ACE_Guard<ACE_Thread_Mutex> guard(m_CharacterNameDataMapMutex); - uint32 count = 0; do { Field *fields = result->Fetch(); - CharacterNameData* data = new CharacterNameData; - data->m_name = fields[1].GetString(); - data->m_race = fields[2].GetUInt8(); - data->m_gender = fields[3].GetUInt8(); - data->m_class = fields[4].GetUInt8(); - - m_CharacterNameDataMap[fields[0].GetUInt32()] = data; + AddCharacterNameData(fields[0].GetUInt32(), fields[1].GetString(), + fields[3].GetUInt8() /*gender*/, fields[2].GetUInt8() /*race*/, fields[4].GetUInt8() /*class*/); ++count; } while (result->NextRow()); sLog->outString("Loaded name data for %u characters", count); } -void World::ReloadSingleCharacterNameData(uint32 guid) +void World::AddCharacterNameData(uint32 guid, std::string const& name, uint8 gender, uint8 race, uint8 playerClass) { - ACE_Guard<ACE_Thread_Mutex> guard(m_CharacterNameDataMapMutex); + CharacterNameData& data = _characterNameDataMap[guid]; + data.m_name = name; + data.m_race = race; + data.m_gender = gender; + data.m_class = playerClass; +} - std::map<uint32, CharacterNameData*>::iterator itr = m_CharacterNameDataMap.find(guid); +void World::UpdateCharacterNameData(uint32 guid, std::string const& name, uint8 gender /*= GENDER_NONE*/, uint8 race /*= RACE_NONE*/) +{ + std::map<uint32, CharacterNameData>::iterator itr = _characterNameDataMap.find(guid); + if (itr == _characterNameDataMap.end()) + return; - if (itr != m_CharacterNameDataMap.end()) - { - delete itr->second; - m_CharacterNameDataMap.erase(itr); - } + itr->second.m_name = name; - QueryResult result = CharacterDatabase.PQuery("SELECT name, race, gender, class FROM characters WHERE guid = '%u'", guid); - if (result) - { - Field *fields = result->Fetch(); - CharacterNameData* newdata = new CharacterNameData; - newdata->m_name = fields[0].GetString(); - newdata->m_race = fields[1].GetUInt8(); - newdata->m_gender = fields[2].GetUInt8(); - newdata->m_class = fields[3].GetUInt8(); - m_CharacterNameDataMap[guid] = newdata; - } + if (gender != GENDER_NONE) + itr->second.m_gender = gender; + + if (race != RACE_NONE) + itr->second.m_race = race; } -CharacterNameData* World::GetCharacterNameData(uint32 guid) +CharacterNameData const* World::GetCharacterNameData(uint32 guid) const { - ACE_Guard<ACE_Thread_Mutex> guard(m_CharacterNameDataMapMutex); - - std::map<uint32, CharacterNameData*>::iterator itr = m_CharacterNameDataMap.find(guid); - if (itr != m_CharacterNameDataMap.end()) - return itr->second; + std::map<uint32, CharacterNameData>::const_iterator itr = _characterNameDataMap.find(guid); + if (itr != _characterNameDataMap.end()) + return &itr->second; else return NULL; } diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 7430dd22420..f643ae60287 100755 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -722,10 +722,9 @@ class World LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if (m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; } - //used World DB version + // used World DB version void LoadDBVersion(); char const* GetDBVersion() const { return m_DBVersion.c_str(); } - char const* GetCreatureEventAIVersion() const { return m_CreatureEventAIVersion.c_str(); } void RecordTimeDiff(const char * text, ...); @@ -739,8 +738,10 @@ class World bool isEventKillStart; - CharacterNameData *GetCharacterNameData(uint32 guid); - void ReloadSingleCharacterNameData(uint32 guid); + CharacterNameData const* GetCharacterNameData(uint32 guid) const; + void AddCharacterNameData(uint32 guid, std::string const& name, uint8 gender, uint8 race, uint8 playerClass); + void UpdateCharacterNameData(uint32 guid, std::string const& name, uint8 gender = GENDER_NONE, uint8 race = RACE_NONE); + void DeleteCharaceterNameData(uint32 guid) { _characterNameDataMap.erase(guid); } uint32 GetCleaningFlags() const { return m_CleaningFlags; } void SetCleaningFlags(uint32 flags) { m_CleaningFlags = flags; } @@ -819,18 +820,16 @@ class World //Player Queue Queue m_QueuedPlayer; - //sessions that are added async + // sessions that are added async void AddSession_(WorldSession* s); ACE_Based::LockedQueue<WorldSession*, ACE_Thread_Mutex> addSessQueue; - //used versions + // used versions std::string m_DBVersion; - std::string m_CreatureEventAIVersion; std::list<std::string> m_Autobroadcasts; - std::map<uint32, CharacterNameData*> m_CharacterNameDataMap; - ACE_Thread_Mutex m_CharacterNameDataMapMutex; + std::map<uint32, CharacterNameData> _characterNameDataMap; void LoadCharacterNameData(); void ProcessQueryCallbacks(); diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 1b3454e5ae6..ae3250ad7b7 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -60,7 +60,7 @@ public: return commandTable; } - static bool HandleAccountAddonCommand(ChatHandler* handler, const char* args) + static bool HandleAccountAddonCommand(ChatHandler* handler, char const* args) { if (!*args) { @@ -69,11 +69,11 @@ public: return false; } - char *szExp = strtok((char*)args, " "); + char* exp = strtok((char*)args, " "); - uint32 account_id = handler->GetSession()->GetAccountId(); + uint32 accountId = handler->GetSession()->GetAccountId(); - int expansion = atoi(szExp); //get int anyway (0 if error) + int expansion = atoi(exp); //get int anyway (0 if error) if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION)) { handler->SendSysMessage(LANG_IMPROPER_VALUE); @@ -82,78 +82,74 @@ public: } // No SQL injection - LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, account_id); + LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, accountId); handler->PSendSysMessage(LANG_ACCOUNT_ADDON, expansion); return true; } /// Create an account - static bool HandleAccountCreateCommand(ChatHandler* handler, const char* args) + static bool HandleAccountCreateCommand(ChatHandler* handler, char const* args) { if (!*args) return false; ///- %Parse the command line arguments - char *szAcc = strtok((char*)args, " "); - char *szPassword = strtok(NULL, " "); - if (!szAcc || !szPassword) + char* accountName = strtok((char*)args, " "); + char* password = strtok(NULL, " "); + if (!accountName || !password) return false; - // normalized in AccountMgr::CreateAccount - std::string account_name = szAcc; - std::string password = szPassword; - - AccountOpResult result = AccountMgr::CreateAccount(account_name, password); + AccountOpResult result = AccountMgr::CreateAccount(std::string(accountName), std::string(password)); switch (result) { - case AOR_OK: - handler->PSendSysMessage(LANG_ACCOUNT_CREATED, account_name.c_str()); - break; - case AOR_NAME_TOO_LONG: - handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG); - handler->SetSentErrorMessage(true); - return false; - case AOR_NAME_ALREDY_EXIST: - handler->SendSysMessage(LANG_ACCOUNT_ALREADY_EXIST); - handler->SetSentErrorMessage(true); - return false; - case AOR_DB_INTERNAL_ERROR: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR, account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - default: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED, account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; + case AOR_OK: + handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName); + break; + case AOR_NAME_TOO_LONG: + handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG); + handler->SetSentErrorMessage(true); + return false; + case AOR_NAME_ALREDY_EXIST: + handler->SendSysMessage(LANG_ACCOUNT_ALREADY_EXIST); + handler->SetSentErrorMessage(true); + return false; + case AOR_DB_INTERNAL_ERROR: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR, accountName); + handler->SetSentErrorMessage(true); + return false; + default: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED, accountName); + handler->SetSentErrorMessage(true); + return false; } return true; } /// Delete a user account and all associated characters in this realm - /// \todo This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm, delete account chars in realm then delete account - static bool HandleAccountDeleteCommand(ChatHandler* handler, const char* args) + /// \todo This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm then delete account) + static bool HandleAccountDeleteCommand(ChatHandler* handler, char const* args) { if (!*args) return false; ///- Get the account name from the command line - char *account_name_str=strtok ((char*)args, " "); - if (!account_name_str) + char* account = strtok((char*)args, " "); + if (!account) return false; - std::string account_name = account_name_str; - if (!AccountMgr::normalizeString(account_name)) + std::string accountName = account; + if (!AccountMgr::normalizeString(accountName)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); handler->SetSentErrorMessage(true); return false; } - uint32 account_id = AccountMgr::GetId(account_name); - if (!account_id) + uint32 accountId = AccountMgr::GetId(accountName); + if (!accountId) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); handler->SetSentErrorMessage(true); return false; } @@ -161,34 +157,34 @@ public: /// Commands not recommended call from chat, but support anyway /// can delete only for account with less security /// This is also reject self apply in fact - if (handler->HasLowerSecurityAccount (NULL, account_id, true)) + if (handler->HasLowerSecurityAccount(NULL, accountId, true)) return false; - AccountOpResult result = AccountMgr::DeleteAccount(account_id); + AccountOpResult result = AccountMgr::DeleteAccount(accountId); switch (result) { - case AOR_OK: - handler->PSendSysMessage(LANG_ACCOUNT_DELETED, account_name.c_str()); - break; - case AOR_NAME_NOT_EXIST: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - case AOR_DB_INTERNAL_ERROR: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR, account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - default: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED, account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; + case AOR_OK: + handler->PSendSysMessage(LANG_ACCOUNT_DELETED, accountName.c_str()); + break; + case AOR_NAME_NOT_EXIST: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->SetSentErrorMessage(true); + return false; + case AOR_DB_INTERNAL_ERROR: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR, accountName.c_str()); + handler->SetSentErrorMessage(true); + return false; + default: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED, accountName.c_str()); + handler->SetSentErrorMessage(true); + return false; } return true; } /// Display info on users currently in the realm - static bool HandleAccountOnlineListCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleAccountOnlineListCommand(ChatHandler* handler, char const* /*args*/) { ///- Get the list of accounts ID logged to the realm QueryResult resultDB = CharacterDatabase.Query("SELECT name, account, map, zone FROM characters WHERE online > 0"); @@ -218,6 +214,7 @@ public: "LEFT JOIN account_access aa " "ON (a.id = aa.id) " "WHERE a.id = '%u'", account); + if (resultLogin) { Field* fieldsLogin = resultLogin->Fetch(); @@ -229,13 +226,13 @@ public: else handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name.c_str()); - }while (resultDB->NextRow()); + } while (resultDB->NextRow()); handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR); return true; } - static bool HandleAccountLockCommand(ChatHandler* handler, const char* args) + static bool HandleAccountLockCommand(ChatHandler* handler, char const* args) { if (!*args) { @@ -244,15 +241,15 @@ public: return false; } - std::string argstr = (char*)args; - if (argstr == "on") + std::string param = (char*)args; + if (param == "on") { LoginDatabase.PExecute("UPDATE account SET locked = '1' WHERE id = '%d'", handler->GetSession()->GetAccountId()); handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED); return true; } - if (argstr == "off") + if (param == "off") { LoginDatabase.PExecute("UPDATE account SET locked = '0' WHERE id = '%d'", handler->GetSession()->GetAccountId()); handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED); @@ -264,7 +261,7 @@ public: return false; } - static bool HandleAccountPasswordCommand(ChatHandler* handler, const char* args) + static bool HandleAccountPasswordCommand(ChatHandler* handler, char const* args) { if (!*args) { @@ -273,95 +270,95 @@ public: return false; } - char *old_pass = strtok((char*)args, " "); - char *new_pass = strtok(NULL, " "); - char *new_pass_c = strtok(NULL, " "); + char* oldPassword = strtok((char*)args, " "); + char* newPassword = strtok(NULL, " "); + char* passwordConfirmation = strtok(NULL, " "); - if (!old_pass || !new_pass || !new_pass_c) + if (!oldPassword || !newPassword || !passwordConfirmation) { handler->SendSysMessage(LANG_CMD_SYNTAX); handler->SetSentErrorMessage(true); return false; } - if (!AccountMgr::CheckPassword(handler->GetSession()->GetAccountId(), std::string(old_pass))) + if (!AccountMgr::CheckPassword(handler->GetSession()->GetAccountId(), std::string(oldPassword))) { handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD); handler->SetSentErrorMessage(true); return false; } - if (strcmp(new_pass, new_pass_c) != 0) + if (strcmp(newPassword, passwordConfirmation) != 0) { handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH); handler->SetSentErrorMessage(true); return false; } - AccountOpResult result = AccountMgr::ChangePassword(handler->GetSession()->GetAccountId(), std::string(new_pass)); + AccountOpResult result = AccountMgr::ChangePassword(handler->GetSession()->GetAccountId(), std::string(newPassword)); switch (result) { - case AOR_OK: - handler->SendSysMessage(LANG_COMMAND_PASSWORD); - break; - case AOR_PASS_TOO_LONG: - handler->SendSysMessage(LANG_PASSWORD_TOO_LONG); - handler->SetSentErrorMessage(true); - return false; - default: - handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); - handler->SetSentErrorMessage(true); - return false; + case AOR_OK: + handler->SendSysMessage(LANG_COMMAND_PASSWORD); + break; + case AOR_PASS_TOO_LONG: + handler->SendSysMessage(LANG_PASSWORD_TOO_LONG); + handler->SetSentErrorMessage(true); + return false; + default: + handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); + handler->SetSentErrorMessage(true); + return false; } return true; } - static bool HandleAccountCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleAccountCommand(ChatHandler* handler, char const* /*args*/) { - AccountTypes gmlevel = handler->GetSession()->GetSecurity(); - handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmlevel)); + AccountTypes gmLevel = handler->GetSession()->GetSecurity(); + handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmLevel)); return true; } /// Set/Unset the expansion level for an account - static bool HandleAccountSetAddonCommand(ChatHandler* handler, const char *args) + static bool HandleAccountSetAddonCommand(ChatHandler* handler, char const* args) { ///- Get the command line arguments - char *szAcc = strtok((char*)args, " "); - char *szExp = strtok(NULL, " "); + char* account = strtok((char*)args, " "); + char* exp = strtok(NULL, " "); - if (!szAcc) + if (!account) return false; - std::string account_name; - uint32 account_id; + std::string accountName; + uint32 accountId; - if (!szExp) + if (!exp) { Player* player = handler->getSelectedPlayer(); if (!player) return false; - account_id = player->GetSession()->GetAccountId(); - AccountMgr::GetName(account_id, account_name); - szExp = szAcc; + accountId = player->GetSession()->GetAccountId(); + AccountMgr::GetName(accountId, accountName); + exp = account; } else { ///- Convert Account name to Upper Format - account_name = szAcc; - if (!AccountMgr::normalizeString(account_name)) + accountName = account; + if (!AccountMgr::normalizeString(accountName)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); handler->SetSentErrorMessage(true); return false; } - account_id = AccountMgr::GetId(account_name); - if (!account_id) + accountId = AccountMgr::GetId(accountName); + if (!accountId) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); handler->SetSentErrorMessage(true); return false; } @@ -370,21 +367,21 @@ public: // Let set addon state only for lesser (strong) security level // or to self account - if (handler->GetSession() && handler->GetSession()->GetAccountId () != account_id && - handler->HasLowerSecurityAccount (NULL, account_id, true)) + if (handler->GetSession() && handler->GetSession()->GetAccountId () != accountId && + handler->HasLowerSecurityAccount(NULL, accountId, true)) return false; - int expansion = atoi(szExp); //get int anyway (0 if error) + int expansion = atoi(exp); //get int anyway (0 if error) if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION)) return false; // No SQL injection - LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, account_id); - handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, account_name.c_str(), account_id, expansion); + LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, accountId); + handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, accountName.c_str(), accountId, expansion); return true; } - static bool HandleAccountSetGmLevelCommand(ChatHandler* handler, const char *args) + static bool HandleAccountSetGmLevelCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -433,16 +430,16 @@ public: // handler->getSession() == NULL only for console targetAccountId = (isAccountNameGiven) ? AccountMgr::GetId(targetAccountName) : handler->getSelectedPlayer()->GetSession()->GetAccountId(); int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2); - uint32 plSecurity; + uint32 playerSecurity; if (handler->GetSession()) - plSecurity = AccountMgr::GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID); + playerSecurity = AccountMgr::GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID); else - plSecurity = SEC_CONSOLE; + playerSecurity = SEC_CONSOLE; // can set security level only for target with less security and to less security that we have // This is also reject self apply in fact targetSecurity = AccountMgr::GetSecurity(targetAccountId, gmRealmID); - if (targetSecurity >= plSecurity || gm >= plSecurity) + if (targetSecurity >= playerSecurity || gm >= playerSecurity) { handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); handler->SetSentErrorMessage(true); @@ -450,7 +447,7 @@ public: } // Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1 - if (gmRealmID == -1 && !AccountMgr::IsConsoleAccount(plSecurity)) + if (gmRealmID == -1 && !AccountMgr::IsConsoleAccount(playerSecurity)) { QueryResult result = LoginDatabase.PQuery("SELECT * FROM account_access WHERE id = '%u' AND gmlevel > '%d'", targetAccountId, gm); if (result) @@ -476,73 +473,75 @@ public: LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u' AND (RealmID = '%d' OR RealmID = '-1')", targetAccountId, realmID); if (gm != 0) - LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', '%d')", targetAccountId, gm, realmID); + LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', '%d')", targetAccountId, gm, gmRealmID); + handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); return true; } /// Set password for account - static bool HandleAccountSetPasswordCommand(ChatHandler* handler, const char *args) + static bool HandleAccountSetPasswordCommand(ChatHandler* handler, char const* args) { if (!*args) return false; ///- Get the command line arguments - char *szAccount = strtok ((char*)args, " "); - char *szPassword1 = strtok (NULL, " "); - char *szPassword2 = strtok (NULL, " "); + char* account = strtok((char*)args, " "); + char* password = strtok(NULL, " "); + char* passwordConfirmation = strtok(NULL, " "); - if (!szAccount||!szPassword1 || !szPassword2) + if (!account || !password || !passwordConfirmation) return false; - std::string account_name = szAccount; - if (!AccountMgr::normalizeString(account_name)) + std::string accountName = account; + if (!AccountMgr::normalizeString(accountName)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); handler->SetSentErrorMessage(true); return false; } - uint32 targetAccountId = AccountMgr::GetId(account_name); + uint32 targetAccountId = AccountMgr::GetId(accountName); if (!targetAccountId) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); handler->SetSentErrorMessage(true); return false; } /// can set password only for target with less security /// This is also reject self apply in fact - if (handler->HasLowerSecurityAccount (NULL, targetAccountId, true)) + if (handler->HasLowerSecurityAccount(NULL, targetAccountId, true)) return false; - if (strcmp(szPassword1, szPassword2)) + if (strcmp(password, passwordConfirmation)) { - handler->SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); - handler->SetSentErrorMessage (true); + handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH); + handler->SetSentErrorMessage(true); return false; } - AccountOpResult result = AccountMgr::ChangePassword(targetAccountId, szPassword1); + AccountOpResult result = AccountMgr::ChangePassword(targetAccountId, password); switch (result) { - case AOR_OK: - handler->SendSysMessage(LANG_COMMAND_PASSWORD); - break; - case AOR_NAME_NOT_EXIST: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - case AOR_PASS_TOO_LONG: - handler->SendSysMessage(LANG_PASSWORD_TOO_LONG); - handler->SetSentErrorMessage(true); - return false; - default: - handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); - handler->SetSentErrorMessage(true); - return false; + case AOR_OK: + handler->SendSysMessage(LANG_COMMAND_PASSWORD); + break; + case AOR_NAME_NOT_EXIST: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->SetSentErrorMessage(true); + return false; + case AOR_PASS_TOO_LONG: + handler->SendSysMessage(LANG_PASSWORD_TOO_LONG); + handler->SetSentErrorMessage(true); + return false; + default: + handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); + handler->SetSentErrorMessage(true); + return false; } + return true; } }; diff --git a/src/server/scripts/Commands/cs_achievement.cpp b/src/server/scripts/Commands/cs_achievement.cpp index 88e07a07fe7..61ce13f0ecb 100644 --- a/src/server/scripts/Commands/cs_achievement.cpp +++ b/src/server/scripts/Commands/cs_achievement.cpp @@ -45,7 +45,7 @@ public: return commandTable; } - static bool HandleAchievementAddCommand(ChatHandler* handler, const char *args) + static bool HandleAchievementAddCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -53,8 +53,8 @@ public: uint32 achievementId = atoi((char*)args); if (!achievementId) { - if (char* cId = handler->extractKeyFromLink((char*)args, "Hachievement")) - achievementId = atoi(cId); + if (char* id = handler->extractKeyFromLink((char*)args, "Hachievement")) + achievementId = atoi(id); if (!achievementId) return false; } @@ -67,8 +67,8 @@ public: return false; } - if (AchievementEntry const* pAE = GetAchievementStore()->LookupEntry(achievementId)) - target->CompletedAchievement(pAE); + if (AchievementEntry const* achievementEntry = GetAchievementStore()->LookupEntry(achievementId)) + target->CompletedAchievement(achievementEntry); return true; } diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index dca2f1e4f0e..9e1d5717f1f 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -98,7 +98,7 @@ public: return commandTable; } - static bool HandleDebugPlayCinematicCommand(ChatHandler* handler, const char* args) + static bool HandleDebugPlayCinematicCommand(ChatHandler* handler, char const* args) { // USAGE: .debug play cinematic #cinematicid // #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column) @@ -109,20 +109,20 @@ public: return false; } - uint32 dwId = atoi((char*)args); + uint32 id = atoi((char*)args); - if (!sCinematicSequencesStore.LookupEntry(dwId)) + if (!sCinematicSequencesStore.LookupEntry(id)) { - handler->PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, dwId); + handler->PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, id); handler->SetSentErrorMessage(true); return false; } - handler->GetSession()->GetPlayer()->SendCinematicStart(dwId); + handler->GetSession()->GetPlayer()->SendCinematicStart(id); return true; } - static bool HandleDebugPlayMovieCommand(ChatHandler* handler, const char* args) + static bool HandleDebugPlayMovieCommand(ChatHandler* handler, char const* args) { // USAGE: .debug play movie #movieid // #movieid - ID decimal number from Movie.dbc (1st column) @@ -133,21 +133,21 @@ public: return false; } - uint32 dwId = atoi((char*)args); + uint32 id = atoi((char*)args); - if (!sMovieStore.LookupEntry(dwId)) + if (!sMovieStore.LookupEntry(id)) { - handler->PSendSysMessage(LANG_MOVIE_NOT_EXIST, dwId); + handler->PSendSysMessage(LANG_MOVIE_NOT_EXIST, id); handler->SetSentErrorMessage(true); return false; } - handler->GetSession()->GetPlayer()->SendMovieStart(dwId); + handler->GetSession()->GetPlayer()->SendMovieStart(id); return true; } //Play sound - static bool HandleDebugPlaySoundCommand(ChatHandler* handler, const char* args) + static bool HandleDebugPlaySoundCommand(ChatHandler* handler, char const* args) { // USAGE: .debug playsound #soundid // #soundid - ID decimal number from SoundEntries.dbc (1st column) @@ -158,11 +158,11 @@ public: return false; } - uint32 dwSoundId = atoi((char*)args); + uint32 soundId = atoi((char*)args); - if (!sSoundEntriesStore.LookupEntry(dwSoundId)) + if (!sSoundEntriesStore.LookupEntry(soundId)) { - handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId); + handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId); handler->SetSentErrorMessage(true); return false; } @@ -176,48 +176,48 @@ public: } if (handler->GetSession()->GetPlayer()->GetSelection()) - unit->PlayDistanceSound(dwSoundId, handler->GetSession()->GetPlayer()); + unit->PlayDistanceSound(soundId, handler->GetSession()->GetPlayer()); else - unit->PlayDirectSound(dwSoundId, handler->GetSession()->GetPlayer()); + unit->PlayDirectSound(soundId, handler->GetSession()->GetPlayer()); - handler->PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId); + handler->PSendSysMessage(LANG_YOU_HEAR_SOUND, soundId); return true; } - static bool HandleDebugSendSpellFailCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSendSpellFailCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - char* px = strtok((char*)args, " "); - if (!px) + char* result = strtok((char*)args, " "); + if (!result) return false; - uint8 failnum = (uint8)atoi(px); - if (failnum == 0 && *px != '0') + uint8 failNum = (uint8)atoi(result); + if (failNum == 0 && *result != '0') return false; - char* p1 = strtok(NULL, " "); - uint8 failarg1 = p1 ? (uint8)atoi(p1) : 0; + char* fail1 = strtok(NULL, " "); + uint8 failArg1 = fail1 ? (uint8)atoi(fail1) : 0; - char* p2 = strtok(NULL, " "); - uint8 failarg2 = p2 ? (uint8)atoi(p2) : 0; + char* fail2 = strtok(NULL, " "); + uint8 failArg2 = fail2 ? (uint8)atoi(fail2) : 0; WorldPacket data(SMSG_CAST_FAILED, 5); data << uint8(0); data << uint32(133); - data << uint8(failnum); - if (p1 || p2) - data << uint32(failarg1); - if (p2) - data << uint32(failarg2); + data << uint8(failNum); + if (fail1 || fail2) + data << uint32(failArg1); + if (fail2) + data << uint32(failArg2); handler->GetSession()->SendPacket(&data); return true; } - static bool HandleDebugSendEquipErrorCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSendEquipErrorCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -227,7 +227,7 @@ public: return true; } - static bool HandleDebugSendSellErrorCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSendSellErrorCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -237,7 +237,7 @@ public: return true; } - static bool HandleDebugSendBuyErrorCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSendBuyErrorCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -247,7 +247,7 @@ public: return true; } - static bool HandleDebugSendOpcodeCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleDebugSendOpcodeCommand(ChatHandler* handler, char const* /*args*/) { Unit* unit = handler->getSelectedUnit(); Player* player = NULL; @@ -255,7 +255,9 @@ public: player = handler->GetSession()->GetPlayer(); else player = (Player*)unit; - if (!unit) unit = player; + + if (!unit) + unit = player; std::ifstream ifs("opcode.txt"); if (ifs.bad()) @@ -296,9 +298,7 @@ public: } // regular data else - { ifs.putback(commentToken[1]); - } } parsedStream.put(commentToken[0]); } @@ -418,7 +418,7 @@ public: return true; } - static bool HandleDebugUpdateWorldStateCommand(ChatHandler* handler, const char* args) + static bool HandleDebugUpdateWorldStateCommand(ChatHandler* handler, char const* args) { char* w = strtok((char*)args, " "); char* s = strtok(NULL, " "); @@ -432,14 +432,16 @@ public: return true; } - static bool HandleDebugAreaTriggersCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleDebugAreaTriggersCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); if (!player->isDebugAreaTriggers) { handler->PSendSysMessage(LANG_DEBUG_AREATRIGGER_ON); player->isDebugAreaTriggers = true; - } else { + } + else + { handler->PSendSysMessage(LANG_DEBUG_AREATRIGGER_OFF); player->isDebugAreaTriggers = false; } @@ -447,12 +449,12 @@ public: } //Send notification in channel - static bool HandleDebugSendChannelNotifyCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSendChannelNotifyCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - const char *name = "test"; + char const* name = "test"; uint8 code = atoi(args); WorldPacket data(SMSG_CHANNEL_NOTIFY, (1+10)); @@ -465,12 +467,12 @@ public: } //Send notification in chat - static bool HandleDebugSendChatMsgCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSendChatMsgCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - const char *msg = "testtest"; + char const* msg = "testtest"; uint8 type = atoi(args); WorldPacket data; ChatHandler::FillMessageData(&data, handler->GetSession(), type, 0, "chan", handler->GetSession()->GetPlayer()->GetGUID(), msg, handler->GetSession()->GetPlayer()); @@ -478,54 +480,64 @@ public: return true; } - static bool HandleDebugSendQuestPartyMsgCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSendQuestPartyMsgCommand(ChatHandler* handler, char const* args) { uint32 msg = atol((char*)args); handler->GetSession()->GetPlayer()->SendPushToPartyResponse(handler->GetSession()->GetPlayer(), msg); return true; } - static bool HandleDebugGetLootRecipientCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleDebugGetLootRecipientCommand(ChatHandler* handler, char const* /*args*/) { Creature* target = handler->getSelectedCreature(); if (!target) return false; - handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s", target->GetName(), target->GetGUIDLow(), target->GetDBTableGUIDLow(), target->hasLootRecipient()?(target->GetLootRecipient()?target->GetLootRecipient()->GetName():"offline"):"no loot recipient"); + handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s", target->GetName(), target->GetGUIDLow(), target->GetDBTableGUIDLow(), target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName() : "offline") : "no loot recipient"); return true; } - static bool HandleDebugSendQuestInvalidMsgCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSendQuestInvalidMsgCommand(ChatHandler* handler, char const* args) { uint32 msg = atol((char*)args); handler->GetSession()->GetPlayer()->SendCanTakeQuestResponse(msg); return true; } - static bool HandleDebugGetItemStateCommand(ChatHandler* handler, const char* args) + static bool HandleDebugGetItemStateCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - std::string state_str = args; + std::string itemState = args; ItemUpdateState state = ITEM_UNCHANGED; - bool list_queue = false, check_all = false; - if (state_str == "unchanged") state = ITEM_UNCHANGED; - else if (state_str == "changed") state = ITEM_CHANGED; - else if (state_str == "new") state = ITEM_NEW; - else if (state_str == "removed") state = ITEM_REMOVED; - else if (state_str == "queue") list_queue = true; - else if (state_str == "check_all") check_all = true; - else return false; + bool listQueue = false; + bool checkAll = false; + + if (itemState == "unchanged") + state = ITEM_UNCHANGED; + else if (itemState == "changed") + state = ITEM_CHANGED; + else if (itemState == "new") + state = ITEM_NEW; + else if (itemState == "removed") + state = ITEM_REMOVED; + else if (itemState == "queue") + listQueue = true; + else if (itemState == "check_all") + checkAll = true; + else + return false; Player* player = handler->getSelectedPlayer(); - if (!player) player = handler->GetSession()->GetPlayer(); + if (!player) + player = handler->GetSession()->GetPlayer(); - if (!list_queue && !check_all) + if (!listQueue && !checkAll) { - state_str = "The player has the following " + state_str + " items: "; - handler->SendSysMessage(state_str.c_str()); + itemState = "The player has the following " + itemState + " items: "; + handler->SendSysMessage(itemState.c_str()); for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) { if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) @@ -546,60 +558,73 @@ public: } } - if (list_queue) + if (listQueue) { - std::vector<Item*> &updateQueue = player->GetItemUpdateQueue(); + std::vector<Item*>& updateQueue = player->GetItemUpdateQueue(); for (size_t i = 0; i < updateQueue.size(); ++i) { Item* item = updateQueue[i]; - if (!item) continue; + if (!item) + continue; Bag* container = item->GetContainer(); - uint8 bag_slot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0); + uint8 bagSlot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0); std::string st; switch (item->GetState()) { - case ITEM_UNCHANGED: st = "unchanged"; break; - case ITEM_CHANGED: st = "changed"; break; - case ITEM_NEW: st = "new"; break; - case ITEM_REMOVED: st = "removed"; break; + case ITEM_UNCHANGED: + st = "unchanged"; + break; + case ITEM_CHANGED: + st = "changed"; + break; + case ITEM_NEW: + st = "new"; + break; + case ITEM_REMOVED: + st = "removed"; + break; } - handler->PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bag_slot, item->GetSlot(), item->GetGUIDLow(), st.c_str()); + handler->PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bagSlot, item->GetSlot(), item->GetGUIDLow(), st.c_str()); } if (updateQueue.empty()) handler->PSendSysMessage("The player's updatequeue is empty"); } - if (check_all) + if (checkAll) { bool error = false; - std::vector<Item*> &updateQueue = player->GetItemUpdateQueue(); + std::vector<Item*>& updateQueue = player->GetItemUpdateQueue(); for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) { if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) continue; Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); - if (!item) continue; + if (!item) + continue; if (item->GetSlot() != i) { handler->PSendSysMessage("Item with slot %d and guid %d has an incorrect slot value: %d", i, item->GetGUIDLow(), item->GetSlot()); - error = true; continue; + error = true; + continue; } if (item->GetOwnerGUID() != player->GetGUID()) { handler->PSendSysMessage("The item with slot %d and itemguid %d does have non-matching owner guid (%d) and player guid (%d) !", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); - error = true; continue; + error = true; + continue; } if (Bag* container = item->GetContainer()) { handler->PSendSysMessage("The item with slot %d and guid %d has a container (slot: %d, guid: %d) but shouldn't!", item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); - error = true; continue; + error = true; + continue; } if (item->IsInUpdateQueue()) @@ -608,25 +633,29 @@ public: if (qp > updateQueue.size()) { handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) larger than the update queue size! ", item->GetSlot(), item->GetGUIDLow(), qp); - error = true; continue; + error = true; + continue; } if (updateQueue[qp] == NULL) { handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) pointing to NULL in the queue!", item->GetSlot(), item->GetGUIDLow(), qp); - error = true; continue; + error = true; + continue; } if (updateQueue[qp] != item) { handler->PSendSysMessage("The item with slot %d and guid %d has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", item->GetSlot(), item->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); - error = true; continue; + error = true; + continue; } } else if (item->GetState() != ITEM_UNCHANGED) { handler->PSendSysMessage("The item with slot %d and guid %d is not in queue but should be (state: %d)!", item->GetSlot(), item->GetGUIDLow(), item->GetState()); - error = true; continue; + error = true; + continue; } if (Bag* bag = item->ToBag()) @@ -634,31 +663,36 @@ public: for (uint8 j = 0; j < bag->GetBagSize(); ++j) { Item* item2 = bag->GetItemByPos(j); - if (!item2) continue; + if (!item2) + continue; if (item2->GetSlot() != j) { handler->PSendSysMessage("The item in bag %d and slot %d (guid: %d) has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUIDLow(), item2->GetSlot()); - error = true; continue; + error = true; + continue; } if (item2->GetOwnerGUID() != player->GetGUID()) { handler->PSendSysMessage("The item in bag %d at slot %d and with itemguid %d, the owner's guid (%d) and the player's guid (%d) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()), player->GetGUIDLow()); - error = true; continue; + error = true; + continue; } Bag* container = item2->GetContainer(); if (!container) { handler->PSendSysMessage("The item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow()); - error = true; continue; + error = true; + continue; } if (container != bag) { handler->PSendSysMessage("The item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); - error = true; continue; + error = true; + continue; } if (item2->IsInUpdateQueue()) @@ -667,25 +701,29 @@ public: if (qp > updateQueue.size()) { handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); - error = true; continue; + error = true; + continue; } if (updateQueue[qp] == NULL) { handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); - error = true; continue; + error = true; + continue; } if (updateQueue[qp] != item2) { handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); - error = true; continue; + error = true; + continue; } } else if (item2->GetState() != ITEM_UNCHANGED) { handler->PSendSysMessage("The item in bag %d at slot %d having guid %d is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), item2->GetState()); - error = true; continue; + error = true; + continue; } } } @@ -694,33 +732,40 @@ public: for (size_t i = 0; i < updateQueue.size(); ++i) { Item* item = updateQueue[i]; - if (!item) continue; + if (!item) + continue; if (item->GetOwnerGUID() != player->GetGUID()) { handler->PSendSysMessage("queue(" SIZEFMTD "): For the item with guid %d, the owner's guid (%d) and the player's guid (%d) don't match!", i, item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); - error = true; continue; + error = true; + continue; } if (item->GetQueuePos() != i) { handler->PSendSysMessage("queue(" SIZEFMTD "): For the item with guid %d, the queuepos doesn't match it's position in the queue!", i, item->GetGUIDLow()); - error = true; continue; + error = true; + continue; } - if (item->GetState() == ITEM_REMOVED) continue; + if (item->GetState() == ITEM_REMOVED) + continue; + Item* test = player->GetItemByPos(item->GetBagSlot(), item->GetSlot()); if (test == NULL) { handler->PSendSysMessage("queue(" SIZEFMTD "): The bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have any item at that position!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow()); - error = true; continue; + error = true; + continue; } if (test != item) { handler->PSendSysMessage("queue(" SIZEFMTD "): The bag(%d) and slot(%d) values for the item with guid %d are incorrect, an item which guid is %d is there instead!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); - error = true; continue; + error = true; + continue; } } if (!error) @@ -730,54 +775,54 @@ public: return true; } - static bool HandleDebugBattlegroundCommand(ChatHandler* /*handler*/, const char* /*args*/) + static bool HandleDebugBattlegroundCommand(ChatHandler* /*handler*/, char const* /*args*/) { sBattlegroundMgr->ToggleTesting(); return true; } - static bool HandleDebugArenaCommand(ChatHandler* /*handler*/, const char* /*args*/) + static bool HandleDebugArenaCommand(ChatHandler* /*handler*/, char const* /*args*/) { sBattlegroundMgr->ToggleArenaTesting(); return true; } - static bool HandleDebugThreatListCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleDebugThreatListCommand(ChatHandler* handler, char const* /*args*/) { Creature* target = handler->getSelectedCreature(); if (!target || target->isTotem() || target->isPet()) return false; - std::list<HostileReference*>& tlist = target->getThreatManager().getThreatList(); + std::list<HostileReference*>& threatList = target->getThreatManager().getThreatList(); std::list<HostileReference*>::iterator itr; - uint32 cnt = 0; + uint32 count = 0; handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName(), target->GetGUIDLow()); - for (itr = tlist.begin(); itr != tlist.end(); ++itr) + for (itr = threatList.begin(); itr != threatList.end(); ++itr) { Unit* unit = (*itr)->getTarget(); if (!unit) continue; - ++cnt; - handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", cnt, unit->GetName(), unit->GetGUIDLow(), (*itr)->getThreat()); + ++count; + handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName(), unit->GetGUIDLow(), (*itr)->getThreat()); } handler->SendSysMessage("End of threat list."); return true; } - static bool HandleDebugHostileRefListCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleDebugHostileRefListCommand(ChatHandler* handler, char const* /*args*/) { Unit* target = handler->getSelectedUnit(); if (!target) target = handler->GetSession()->GetPlayer(); HostileReference* ref = target->getHostileRefManager().getFirst(); - uint32 cnt = 0; + uint32 count = 0; handler->PSendSysMessage("Hostil reference list of %s (guid %u)", target->GetName(), target->GetGUIDLow()); while (ref) { if (Unit* unit = ref->getSource()->getOwner()) { - ++cnt; - handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", cnt, unit->GetName(), unit->GetGUIDLow(), ref->getThreat()); + ++count; + handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName(), unit->GetGUIDLow(), ref->getThreat()); } ref = ref->next(); } @@ -785,7 +830,7 @@ public: return true; } - static bool HandleDebugSetVehicleIdCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSetVehicleIdCommand(ChatHandler* handler, char const* args) { Unit* target = handler->getSelectedUnit(); if (!target || target->IsVehicle()) @@ -804,7 +849,7 @@ public: return true; } - static bool HandleDebugEnterVehicleCommand(ChatHandler* handler, const char* args) + static bool HandleDebugEnterVehicleCommand(ChatHandler* handler, char const* args) { Unit* target = handler->getSelectedUnit(); if (!target || !target->IsVehicle()) @@ -839,7 +884,7 @@ public: return true; } - static bool HandleDebugSpawnVehicleCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSpawnVehicleCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -880,12 +925,12 @@ public: return false; } - map->Add(v->ToCreature()); + map->AddToMap(v->ToCreature()); return true; } - static bool HandleDebugSendLargePacketCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleDebugSendLargePacketCommand(ChatHandler* handler, char const* /*args*/) { const char* stuffingString = "This is a dummy string to push the packet's size beyond 128000 bytes. "; std::ostringstream ss; @@ -895,7 +940,7 @@ public: return true; } - static bool HandleDebugSendSetPhaseShiftCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSendSetPhaseShiftCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -905,7 +950,7 @@ public: return true; } - static bool HandleDebugGetItemValueCommand(ChatHandler* handler, const char* args) + static bool HandleDebugGetItemValueCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -934,7 +979,7 @@ public: return true; } - static bool HandleDebugSetItemValueCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSetItemValueCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -963,7 +1008,7 @@ public: return true; } - static bool HandleDebugItemExpireCommand(ChatHandler* handler, const char* args) + static bool HandleDebugItemExpireCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -986,17 +1031,17 @@ public: } //show animation - static bool HandleDebugAnimCommand(ChatHandler* handler, const char* args) + static bool HandleDebugAnimCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - uint32 anim_id = atoi((char*)args); - handler->GetSession()->GetPlayer()->HandleEmoteCommand(anim_id); + uint32 animId = atoi((char*)args); + handler->GetSession()->GetPlayer()->HandleEmoteCommand(animId); return true; } - static bool HandleDebugSetAuraStateCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSetAuraStateCommand(ChatHandler* handler, char const* args) { if (!*args) { @@ -1026,16 +1071,16 @@ public: return true; } - static bool HandleDebugSetValueCommand(ChatHandler* handler, const char* args) + static bool HandleDebugSetValueCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pz = strtok(NULL, " "); + char* x = strtok((char*)args, " "); + char* y = strtok(NULL, " "); + char* z = strtok(NULL, " "); - if (!px || !py) + if (!x || !y) return false; WorldObject* target = handler->getSelectedObject(); @@ -1048,41 +1093,42 @@ public: uint64 guid = target->GetGUID(); - uint32 Opcode = (uint32)atoi(px); - if (Opcode >= target->GetValuesCount()) + uint32 opcode = (uint32)atoi(x); + if (opcode >= target->GetValuesCount()) { - handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); + handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, GUID_LOPART(guid), target->GetValuesCount()); return false; } - bool isint32 = true; - if (pz) - isint32 = (bool)atoi(pz); - if (isint32) + bool isInt32 = true; + if (z) + isInt32 = (bool)atoi(z); + + if (isInt32) { - uint32 iValue = (uint32)atoi(py); - target->SetUInt32Value(Opcode, iValue); - handler->PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); + uint32 value = (uint32)atoi(y); + target->SetUInt32Value(opcode , value); + handler->PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), opcode, value); } else { - float fValue = (float)atof(py); - target->SetFloatValue(Opcode, fValue); - handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); + float value = (float)atof(y); + target->SetFloatValue(opcode , value); + handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), opcode, value); } return true; } - static bool HandleDebugGetValueCommand(ChatHandler* handler, const char* args) + static bool HandleDebugGetValueCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - char* px = strtok((char*)args, " "); - char* pz = strtok(NULL, " "); + char* x = strtok((char*)args, " "); + char* z = strtok(NULL, " "); - if (!px) + if (!x) return false; Unit* target = handler->getSelectedUnit(); @@ -1095,62 +1141,62 @@ public: uint64 guid = target->GetGUID(); - uint32 Opcode = (uint32)atoi(px); - if (Opcode >= target->GetValuesCount()) + uint32 opcode = (uint32)atoi(x); + if (opcode >= target->GetValuesCount()) { - handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); + handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, GUID_LOPART(guid), target->GetValuesCount()); return false; } - bool isint32 = true; - if (pz) - isint32 = (bool)atoi(pz); + bool isInt32 = true; + if (z) + isInt32 = (bool)atoi(z); - if (isint32) + if (isInt32) { - uint32 iValue = target->GetUInt32Value(Opcode); - handler->PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); + uint32 value = target->GetUInt32Value(opcode); + handler->PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), opcode, value); } else { - float fValue = target->GetFloatValue(Opcode); - handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); + float value = target->GetFloatValue(opcode); + handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), opcode, value); } return true; } - static bool HandleDebugMod32ValueCommand(ChatHandler* handler, const char* args) + static bool HandleDebugMod32ValueCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); + char* x = strtok((char*)args, " "); + char* y = strtok(NULL, " "); - if (!px || !py) + if (!x || !y) return false; - uint32 Opcode = (uint32)atoi(px); - int Value = atoi(py); + uint32 opcode = (uint32)atoi(x); + int value = atoi(y); - if (Opcode >= handler->GetSession()->GetPlayer()->GetValuesCount()) + if (opcode >= handler->GetSession()->GetPlayer()->GetValuesCount()) { - handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, handler->GetSession()->GetPlayer()->GetGUIDLow(), handler->GetSession()->GetPlayer()->GetValuesCount()); + handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, handler->GetSession()->GetPlayer()->GetGUIDLow(), handler->GetSession()->GetPlayer()->GetValuesCount()); return false; } - int CurrentValue = (int)handler->GetSession()->GetPlayer()->GetUInt32Value(Opcode); + int currentValue = (int)handler->GetSession()->GetPlayer()->GetUInt32Value(opcode); - CurrentValue += Value; - handler->GetSession()->GetPlayer()->SetUInt32Value(Opcode, (uint32)CurrentValue); + currentValue += value; + handler->GetSession()->GetPlayer()->SetUInt32Value(opcode , (uint32)currentValue); - handler->PSendSysMessage(LANG_CHANGE_32BIT_FIELD, Opcode, CurrentValue); + handler->PSendSysMessage(LANG_CHANGE_32BIT_FIELD, opcode, currentValue); return true; } - static bool HandleDebugUpdateCommand(ChatHandler* handler, const char* args) + static bool HandleDebugUpdateCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1158,49 +1204,48 @@ public: uint32 updateIndex; uint32 value; - char* pUpdateIndex = strtok((char*)args, " "); + char* index = strtok((char*)args, " "); - Unit* chr = handler->getSelectedUnit(); - if (chr == NULL) + Unit* unit = handler->getSelectedUnit(); + if (!unit) { handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); handler->SetSentErrorMessage(true); return false; } - if (!pUpdateIndex) - { + if (!index) return true; - } - updateIndex = atoi(pUpdateIndex); + + updateIndex = atoi(index); //check updateIndex - if (chr->GetTypeId() == TYPEID_PLAYER) - { - if (updateIndex >= PLAYER_END) return true; - } - else + if (unit->GetTypeId() == TYPEID_PLAYER) { - if (updateIndex >= UNIT_END) return true; + if (updateIndex >= PLAYER_END) + return true; } + else if (updateIndex >= UNIT_END) + return true; - char* pvalue = strtok(NULL, " "); - if (!pvalue) + char* val = strtok(NULL, " "); + if (!val) { - value=chr->GetUInt32Value(updateIndex); + value = unit->GetUInt32Value(updateIndex); - handler->PSendSysMessage(LANG_UPDATE, chr->GetGUIDLow(), updateIndex, value); + handler->PSendSysMessage(LANG_UPDATE, unit->GetGUIDLow(), updateIndex, value); return true; } - value=atoi(pvalue); + value = atoi(val); - handler->PSendSysMessage(LANG_UPDATE_CHANGE, chr->GetGUIDLow(), updateIndex, value); + handler->PSendSysMessage(LANG_UPDATE_CHANGE, unit->GetGUIDLow(), updateIndex, value); - chr->SetUInt32Value(updateIndex, value); + unit->SetUInt32Value(updateIndex, value); return true; } - static bool HandleDebugSet32BitCommand(ChatHandler* handler, const char* args) + + static bool HandleDebugSet32BitCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1213,21 +1258,21 @@ public: return false; } - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); + char* x = strtok((char*)args, " "); + char* y = strtok(NULL, " "); - if (!px || !py) + if (!x || !y) return false; - uint32 Opcode = (uint32)atoi(px); - uint32 Value = (uint32)atoi(py); - if (Value > 32) //uint32 = 32 bits + uint32 opcode = (uint32)atoi(x); + uint32 val = (uint32)atoi(y); + if (val > 32) //uint32 = 32 bits return false; - uint32 iValue = Value ? 1 << (Value - 1) : 0; - target->SetUInt32Value(Opcode, iValue); + uint32 value = val ? 1 << (val - 1) : 0; + target->SetUInt32Value(opcode, value); - handler->PSendSysMessage(LANG_SET_32BIT_FIELD, Opcode, iValue); + handler->PSendSysMessage(LANG_SET_32BIT_FIELD, opcode, value); return true; } }; diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp index 20ade38d676..3bd745df4f4 100644 --- a/src/server/scripts/Commands/cs_event.cpp +++ b/src/server/scripts/Commands/cs_event.cpp @@ -49,7 +49,7 @@ public: return commandTable; } - static bool HandleEventActiveListCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleEventActiveListCommand(ChatHandler* handler, char const* /*args*/) { uint32 counter = 0; @@ -60,13 +60,13 @@ public: for (GameEventMgr::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr) { - uint32 event_id = *itr; - GameEventData const& eventData = events[event_id]; + uint32 eventId = *itr; + GameEventData const& eventData = events[eventId]; if (handler->GetSession()) - handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, event_id, event_id, eventData.description.c_str(), active); + handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, eventId, eventId, eventData.description.c_str(), active); else - handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, event_id, eventData.description.c_str(), active); + handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, eventId, eventData.description.c_str(), active); ++counter; } @@ -78,28 +78,28 @@ public: return true; } - static bool HandleEventInfoCommand(ChatHandler* handler, const char* args) + static bool HandleEventInfoCommand(ChatHandler* handler, char const* args) { if (!*args) return false; // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args, "Hgameevent"); - if (!cId) + char* id = handler->extractKeyFromLink((char*)args, "Hgameevent"); + if (!id) return false; - uint32 event_id = atoi(cId); + uint32 eventId = atoi(id); GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); - if (event_id >=events.size()) + if (eventId >= events.size()) { handler->SendSysMessage(LANG_EVENT_NOT_EXIST); handler->SetSentErrorMessage(true); return false; } - GameEventData const& eventData = events[event_id]; + GameEventData const& eventData = events[eventId]; if (!eventData.isValid()) { handler->SendSysMessage(LANG_EVENT_NOT_EXIST); @@ -108,47 +108,47 @@ public: } GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList(); - bool active = activeEvents.find(event_id) != activeEvents.end(); + bool active = activeEvents.find(eventId) != activeEvents.end(); char const* activeStr = active ? handler->GetTrinityString(LANG_ACTIVE) : ""; std::string startTimeStr = TimeToTimestampStr(eventData.start); std::string endTimeStr = TimeToTimestampStr(eventData.end); - uint32 delay = sGameEventMgr->NextCheck(event_id); - time_t nextTime = time(NULL)+delay; - std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(NULL)+delay) : "-"; + uint32 delay = sGameEventMgr->NextCheck(eventId); + time_t nextTime = time(NULL) + delay; + std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(NULL) + delay) : "-"; std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE); std::string lengthStr = secsToTimeString(eventData.length * MINUTE); - handler->PSendSysMessage(LANG_EVENT_INFO, event_id, eventData.description.c_str(), activeStr, + handler->PSendSysMessage(LANG_EVENT_INFO, eventId, eventData.description.c_str(), activeStr, startTimeStr.c_str(), endTimeStr.c_str(), occurenceStr.c_str(), lengthStr.c_str(), nextStr.c_str()); return true; } - static bool HandleEventStartCommand(ChatHandler* handler, const char* args) + static bool HandleEventStartCommand(ChatHandler* handler, char const* args) { if (!*args) return false; // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args, "Hgameevent"); - if (!cId) + char* id = handler->extractKeyFromLink((char*)args, "Hgameevent"); + if (!id) return false; - int32 event_id = atoi(cId); + int32 eventId = atoi(id); GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); - if (event_id < 1 || uint32(event_id) >= events.size()) + if (eventId < 1 || uint32(eventId) >= events.size()) { handler->SendSysMessage(LANG_EVENT_NOT_EXIST); handler->SetSentErrorMessage(true); return false; } - GameEventData const& eventData = events[event_id]; + GameEventData const& eventData = events[eventId]; if (!eventData.isValid()) { handler->SendSysMessage(LANG_EVENT_NOT_EXIST); @@ -157,39 +157,39 @@ public: } GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList(); - if (activeEvents.find(event_id) != activeEvents.end()) + if (activeEvents.find(eventId) != activeEvents.end()) { - handler->PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE, event_id); + handler->PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE, eventId); handler->SetSentErrorMessage(true); return false; } - sGameEventMgr->StartEvent(event_id, true); + sGameEventMgr->StartEvent(eventId, true); return true; } - static bool HandleEventStopCommand(ChatHandler* handler, const char* args) + static bool HandleEventStopCommand(ChatHandler* handler, char const* args) { if (!*args) return false; // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args, "Hgameevent"); - if (!cId) + char* id = handler->extractKeyFromLink((char*)args, "Hgameevent"); + if (!id) return false; - int32 event_id = atoi(cId); + int32 eventId = atoi(id); GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); - if (event_id < 1 || uint32(event_id) >= events.size()) + if (eventId < 1 || uint32(eventId) >= events.size()) { handler->SendSysMessage(LANG_EVENT_NOT_EXIST); handler->SetSentErrorMessage(true); return false; } - GameEventData const& eventData = events[event_id]; + GameEventData const& eventData = events[eventId]; if (!eventData.isValid()) { handler->SendSysMessage(LANG_EVENT_NOT_EXIST); @@ -199,14 +199,14 @@ public: GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList(); - if (activeEvents.find(event_id) == activeEvents.end()) + if (activeEvents.find(eventId) == activeEvents.end()) { - handler->PSendSysMessage(LANG_EVENT_NOT_ACTIVE, event_id); + handler->PSendSysMessage(LANG_EVENT_NOT_ACTIVE, eventId); handler->SetSentErrorMessage(true); return false; } - sGameEventMgr->StopEvent(event_id, true); + sGameEventMgr->StopEvent(eventId, true); return true; } }; diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index 9a7146c641c..ab077af0863 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -53,7 +53,7 @@ public: } // Enables or disables hiding of the staff badge - static bool HandleGMChatCommand(ChatHandler* handler, const char* args) + static bool HandleGMChatCommand(ChatHandler* handler, char const* args) { if (!*args) { @@ -65,16 +65,16 @@ public: return true; } - std::string argstr = (char*)args; + std::string param = (char*)args; - if (argstr == "on") + if (param == "on") { handler->GetSession()->GetPlayer()->SetGMChat(true); handler->GetSession()->SendNotification(LANG_GM_CHAT_ON); return true; } - if (argstr == "off") + if (param == "off") { handler->GetSession()->GetPlayer()->SetGMChat(false); handler->GetSession()->SendNotification(LANG_GM_CHAT_OFF); @@ -86,7 +86,7 @@ public: return false; } - static bool HandleGMFlyCommand(ChatHandler* handler, const char* args) + static bool HandleGMFlyCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -112,17 +112,17 @@ public: return true; } - static bool HandleGMListIngameCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleGMListIngameCommand(ChatHandler* handler, char const* /*args*/) { bool first = true; bool footer = false; - ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true); - HashMapHolder<Player>::MapType &m = sObjectAccessor->GetPlayers(); + TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock()); + HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers(); for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { - AccountTypes itr_sec = itr->second->GetSession()->GetSecurity(); - if ((itr->second->isGameMaster() || (!AccountMgr::IsPlayerAccount(itr_sec) && itr_sec <= AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) && + AccountTypes itrSec = itr->second->GetSession()->GetSecurity(); + if ((itr->second->isGameMaster() || (!AccountMgr::IsPlayerAccount(itrSec) && itrSec <= AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) && (!handler->GetSession() || itr->second->IsVisibleGloballyFor(handler->GetSession()->GetPlayer()))) { if (first) @@ -132,12 +132,12 @@ public: handler->SendSysMessage(LANG_GMS_ON_SRV); handler->SendSysMessage("========================"); } - const char* name = itr->second->GetName(); - uint8 security = itr_sec; + char const* name = itr->second->GetName(); + uint8 security = itrSec; uint8 max = ((16 - strlen(name)) / 2); uint8 max2 = max; - if (((max)+(max2)+(strlen(name))) == 16) - max2 = ((max)-1); + if ((max + max2 + strlen(name)) == 16) + max2 = max - 1; if (handler->GetSession()) handler->PSendSysMessage("| %s GMLevel %u", name, security); else @@ -152,7 +152,7 @@ public: } /// Display the list of GMs - static bool HandleGMListFullCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleGMListFullCommand(ChatHandler* handler, char const* /*args*/) { ///- Get the accounts with GM Level >0 QueryResult result = LoginDatabase.PQuery("SELECT a.username, aa.gmlevel FROM account a, account_access aa WHERE a.id=aa.id AND aa.gmlevel >= %u", SEC_MODERATOR); @@ -164,19 +164,17 @@ public: do { Field* fields = result->Fetch(); - const char* name = fields[0].GetCString(); + char const* name = fields[0].GetCString(); uint8 security = fields[1].GetUInt8(); - uint8 max = ((16 - strlen(name)) / 2); + uint8 max = (16 - strlen(name)) / 2; uint8 max2 = max; - if (((max)+(max2)+(strlen(name))) == 16) - max2 = ((max)-1); + if ((max + max2 + strlen(name)) == 16) + max2 = max - 1; if (handler->GetSession()) handler->PSendSysMessage("| %s GMLevel %u", name, security); else handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security); - } - while (result->NextRow()); - + } while (result->NextRow()); handler->SendSysMessage("========================"); } else @@ -185,24 +183,24 @@ public: } //Enable\Disable Invisible mode - static bool HandleGMVisibleCommand(ChatHandler* handler, const char* args) + static bool HandleGMVisibleCommand(ChatHandler* handler, char const* args) { if (!*args) { - handler->PSendSysMessage(LANG_YOU_ARE, handler->GetSession()->GetPlayer()->isGMVisible() ? handler->GetTrinityString(LANG_VISIBLE) : handler->GetTrinityString(LANG_INVISIBLE)); + handler->PSendSysMessage(LANG_YOU_ARE, handler->GetSession()->GetPlayer()->isGMVisible() ? handler->GetTrinityString(LANG_VISIBLE) : handler->GetTrinityString(LANG_INVISIBLE)); return true; } - std::string argstr = (char*)args; + std::string param = (char*)args; - if (argstr == "on") + if (param == "on") { handler->GetSession()->GetPlayer()->SetGMVisible(true); handler->GetSession()->SendNotification(LANG_INVISIBLE_VISIBLE); return true; } - if (argstr == "off") + if (param == "off") { handler->GetSession()->SendNotification(LANG_INVISIBLE_INVISIBLE); handler->GetSession()->GetPlayer()->SetGMVisible(false); @@ -215,7 +213,7 @@ public: } //Enable\Disable GM Mode - static bool HandleGMCommand(ChatHandler* handler, const char* args) + static bool HandleGMCommand(ChatHandler* handler, char const* args) { if (!*args) { @@ -226,9 +224,9 @@ public: return true; } - std::string argstr = (char*)args; + std::string param = (char*)args; - if (argstr == "on") + if (param == "on") { handler->GetSession()->GetPlayer()->SetGameMaster(true); handler->GetSession()->SendNotification(LANG_GM_ON); @@ -240,7 +238,7 @@ public: return true; } - if (argstr == "off") + if (param == "off") { handler->GetSession()->GetPlayer()->SetGameMaster(false); handler->GetSession()->SendNotification(LANG_GM_OFF); diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index 118ab9eb13a..5ed2d6a3dd8 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -57,6 +57,7 @@ public: }; return commandTable; } + /** \brief Teleport the GM to the specified creature * * .gocreature <GUID> --> TP using creature.guid @@ -68,59 +69,52 @@ public: * you will be teleported to the first one that is found. */ //teleport to creature - static bool HandleGoCreatureCommand(ChatHandler* handler, const char* args) + static bool HandleGoCreatureCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - Player* _player = handler->GetSession()->GetPlayer(); + + Player* player = handler->GetSession()->GetPlayer(); // "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r - char* pParam1 = handler->extractKeyFromLink((char*)args, "Hcreature"); - if (!pParam1) + char* param1 = handler->extractKeyFromLink((char*)args, "Hcreature"); + if (!param1) return false; std::ostringstream whereClause; // User wants to teleport to the NPC's template entry - if (strcmp(pParam1, "id") == 0) + if (strcmp(param1, "id") == 0) { - //sLog->outError("DEBUG: ID found"); - // Get the "creature_template.entry" // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r char* tail = strtok(NULL, ""); if (!tail) return false; - char* cId = handler->extractKeyFromLink(tail, "Hcreature_entry"); - if (!cId) + char* id = handler->extractKeyFromLink(tail, "Hcreature_entry"); + if (!id) return false; - int32 tEntry = atoi(cId); - //sLog->outError("DEBUG: ID value: %d", tEntry); - if (!tEntry) + int32 entry = atoi(id); + if (!entry) return false; - whereClause << "WHERE id = '" << tEntry << '\''; + whereClause << "WHERE id = '" << entry << '\''; } else { - //sLog->outError("DEBUG: ID *not found*"); - - int32 guid = atoi(pParam1); + int32 guid = atoi(param1); // Number is invalid - maybe the user specified the mob's name if (!guid) { - std::string name = pParam1; + std::string name = param1; WorldDatabase.EscapeString(name); whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" '" << name << '\''; } else - { whereClause << "WHERE guid = '" << guid << '\''; - } } - //sLog->outError("DEBUG: %s", whereClause.c_str()); QueryResult result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map, guid, id FROM creature %s", whereClause.str().c_str()); if (!result) @@ -137,12 +131,12 @@ public: float y = fields[1].GetFloat(); float z = fields[2].GetFloat(); float ort = fields[3].GetFloat(); - int mapid = fields[4].GetUInt16(); + int mapId = fields[4].GetUInt16(); uint32 guid = fields[5].GetUInt32(); uint32 id = fields[6].GetUInt32(); // if creature is in same map with caster go at its current location - if (Creature* creature = sObjectAccessor->GetCreature(*_player, MAKE_NEW_GUID(guid, id, HIGHGUID_UNIT))) + if (Creature* creature = sObjectAccessor->GetCreature(*player, MAKE_NEW_GUID(guid, id, HIGHGUID_UNIT))) { x = creature->GetPositionX(); y = creature->GetPositionY(); @@ -150,46 +144,47 @@ public: ort = creature->GetOrientation(); } - if (!MapManager::IsValidMapCoord(mapid, x, y, z, ort)) + if (!MapManager::IsValidMapCoord(mapId, x, y, z, ort)) { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid); + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId); handler->SetSentErrorMessage(true); return false; } // stop flight if need - if (_player->isInFlight()) + if (player->isInFlight()) { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); } // save only in non-flight case else - _player->SaveRecallPosition(); + player->SaveRecallPosition(); - _player->TeleportTo(mapid, x, y, z, ort); + player->TeleportTo(mapId, x, y, z, ort); return true; } - static bool HandleGoGraveyardCommand(ChatHandler* handler, const char* args) + + static bool HandleGoGraveyardCommand(ChatHandler* handler, char const* args) { - Player* _player = handler->GetSession()->GetPlayer(); + Player* player = handler->GetSession()->GetPlayer(); if (!*args) return false; - char *gyId = strtok((char*)args, " "); + char* gyId = strtok((char*)args, " "); if (!gyId) return false; - int32 i_gyId = atoi(gyId); + int32 graveyardId = atoi(gyId); - if (!i_gyId) + if (!graveyardId) return false; - WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(i_gyId); + WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(graveyardId); if (!gy) { - handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, i_gyId); + handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, graveyardId); handler->SetSentErrorMessage(true); return false; } @@ -202,93 +197,92 @@ public: } // stop flight if need - if (_player->isInFlight()) + if (player->isInFlight()) { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); } // save only in non-flight case else - _player->SaveRecallPosition(); + player->SaveRecallPosition(); - _player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, _player->GetOrientation()); + player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, player->GetOrientation()); return true; } + //teleport to grid - static bool HandleGoGridCommand(ChatHandler* handler, const char* args) + static bool HandleGoGridCommand(ChatHandler* handler, char const* args) { - if (!*args) return false; - Player* _player = handler->GetSession()->GetPlayer(); + if (!*args) + return false; + + Player* player = handler->GetSession()->GetPlayer(); - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pmapid = strtok(NULL, " "); + char* gridX = strtok((char*)args, " "); + char* gridY = strtok(NULL, " "); + char* id = strtok(NULL, " "); - if (!px || !py) + if (!gridX || !gridY) return false; - float grid_x = (float)atof(px); - float grid_y = (float)atof(py); - uint32 mapid; - if (pmapid) - mapid = (uint32)atoi(pmapid); - else mapid = _player->GetMapId(); + uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId(); // center of grid - float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; - float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; + float x = ((float)atof(gridX) - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS; + float y = ((float)atof(gridY) - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS; - if (!MapManager::IsValidMapCoord(mapid, x, y)) + if (!MapManager::IsValidMapCoord(mapId, x, y)) { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid); + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId); handler->SetSentErrorMessage(true); return false; } // stop flight if need - if (_player->isInFlight()) + if (player->isInFlight()) { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); } // save only in non-flight case else - _player->SaveRecallPosition(); + player->SaveRecallPosition(); - Map const* map = sMapMgr->CreateBaseMap(mapid); + Map const* map = sMapMgr->CreateBaseMap(mapId); float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); - _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); + player->TeleportTo(mapId, x, y, z, player->GetOrientation()); return true; } + //teleport to gameobject - static bool HandleGoObjectCommand(ChatHandler* handler, const char* args) + static bool HandleGoObjectCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - Player* _player = handler->GetSession()->GetPlayer(); + Player* player = handler->GetSession()->GetPlayer(); // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); - if (!cId) + char* id = handler->extractKeyFromLink((char*)args, "Hgameobject"); + if (!id) return false; - int32 guid = atoi(cId); + int32 guid = atoi(id); if (!guid) return false; float x, y, z, ort; - int mapid; + int mapId; // by DB guid - if (GameObjectData const* go_data = sObjectMgr->GetGOData(guid)) + if (GameObjectData const* goData = sObjectMgr->GetGOData(guid)) { - x = go_data->posX; - y = go_data->posY; - z = go_data->posZ; - ort = go_data->orientation; - mapid = go_data->mapid; + x = goData->posX; + y = goData->posY; + z = goData->posZ; + ort = goData->orientation; + mapId = goData->mapid; } else { @@ -297,45 +291,46 @@ public: return false; } - if (!MapManager::IsValidMapCoord(mapid, x, y, z, ort)) + if (!MapManager::IsValidMapCoord(mapId, x, y, z, ort)) { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid); + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId); handler->SetSentErrorMessage(true); return false; } // stop flight if need - if (_player->isInFlight()) + if (player->isInFlight()) { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); } // save only in non-flight case else - _player->SaveRecallPosition(); + player->SaveRecallPosition(); - _player->TeleportTo(mapid, x, y, z, ort); + player->TeleportTo(mapId, x, y, z, ort); return true; } - static bool HandleGoTaxinodeCommand(ChatHandler* handler, const char* args) + + static bool HandleGoTaxinodeCommand(ChatHandler* handler, char const* args) { - Player* _player = handler->GetSession()->GetPlayer(); + Player* player = handler->GetSession()->GetPlayer(); if (!*args) return false; - char* cNodeId = handler->extractKeyFromLink((char*)args, "Htaxinode"); - if (!cNodeId) + char* id = handler->extractKeyFromLink((char*)args, "Htaxinode"); + if (!id) return false; - int32 i_nodeId = atoi(cNodeId); - if (!i_nodeId) + int32 nodeId = atoi(id); + if (!nodeId) return false; - TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i_nodeId); + TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(nodeId); if (!node) { - handler->PSendSysMessage(LANG_COMMAND_GOTAXINODENOTFOUND, i_nodeId); + handler->PSendSysMessage(LANG_COMMAND_GOTAXINODENOTFOUND, nodeId); handler->SetSentErrorMessage(true); return false; } @@ -349,38 +344,39 @@ public: } // stop flight if need - if (_player->isInFlight()) + if (player->isInFlight()) { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); } // save only in non-flight case else - _player->SaveRecallPosition(); + player->SaveRecallPosition(); - _player->TeleportTo(node->map_id, node->x, node->y, node->z, _player->GetOrientation()); + player->TeleportTo(node->map_id, node->x, node->y, node->z, player->GetOrientation()); return true; } - static bool HandleGoTriggerCommand(ChatHandler* handler, const char* args) + + static bool HandleGoTriggerCommand(ChatHandler* handler, char const* args) { - Player* _player = handler->GetSession()->GetPlayer(); + Player* player = handler->GetSession()->GetPlayer(); if (!*args) return false; - char *atId = strtok((char*)args, " "); - if (!atId) + char* id = strtok((char*)args, " "); + if (!id) return false; - int32 i_atId = atoi(atId); + int32 areaTriggerId = atoi(id); - if (!i_atId) + if (!areaTriggerId) return false; - AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(i_atId); + AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(areaTriggerId); if (!at) { - handler->PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, i_atId); + handler->PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, areaTriggerId); handler->SetSentErrorMessage(true); return false; } @@ -393,49 +389,50 @@ public: } // stop flight if need - if (_player->isInFlight()) + if (player->isInFlight()) { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); } // save only in non-flight case else - _player->SaveRecallPosition(); + player->SaveRecallPosition(); - _player->TeleportTo(at->mapid, at->x, at->y, at->z, _player->GetOrientation()); + player->TeleportTo(at->mapid, at->x, at->y, at->z, player->GetOrientation()); return true; } + //teleport at coordinates - static bool HandleGoZoneXYCommand(ChatHandler* handler, const char* args) + static bool HandleGoZoneXYCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - Player* _player = handler->GetSession()->GetPlayer(); + Player* player = handler->GetSession()->GetPlayer(); - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); + char* zoneX = strtok((char*)args, " "); + char* zoneY = strtok(NULL, " "); char* tail = strtok(NULL, ""); - char* cAreaId = handler->extractKeyFromLink(tail, "Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r + char* id = handler->extractKeyFromLink(tail, "Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r - if (!px || !py) + if (!zoneX || !zoneY) return false; - float x = (float)atof(px); - float y = (float)atof(py); + float x = (float)atof(zoneX); + float y = (float)atof(zoneY); // prevent accept wrong numeric args - if ((x == 0.0f && *px != '0') || (y == 0.0f && *py != '0')) + if ((x == 0.0f && *zoneX != '0') || (y == 0.0f && *zoneY != '0')) return false; - uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId(); + uint32 areaId = id ? (uint32)atoi(id) : player->GetZoneId(); - AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid); + AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId); if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry) { - handler->PSendSysMessage(LANG_INVALID_ZONE_COORD, x, y, areaid); + handler->PSendSysMessage(LANG_INVALID_ZONE_COORD, x, y, areaId); handler->SetSentErrorMessage(true); return false; } @@ -462,99 +459,90 @@ public: } // stop flight if need - if (_player->isInFlight()) + if (player->isInFlight()) { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); } // save only in non-flight case else - _player->SaveRecallPosition(); + player->SaveRecallPosition(); float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); - _player->TeleportTo(zoneEntry->mapid, x, y, z, _player->GetOrientation()); + player->TeleportTo(zoneEntry->mapid, x, y, z, player->GetOrientation()); return true; } + //teleport at coordinates, including Z and orientation - static bool HandleGoXYZCommand(ChatHandler* handler, const char* args) + static bool HandleGoXYZCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - Player* _player = handler->GetSession()->GetPlayer(); + Player* player = handler->GetSession()->GetPlayer(); - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pz = strtok(NULL, " "); - char* pmapid = strtok(NULL, " "); + char* goX = strtok((char*)args, " "); + char* goY = strtok(NULL, " "); + char* goZ = strtok(NULL, " "); + char* id = strtok(NULL, " "); char* port = strtok(NULL, " "); - if (!px || !py) + if (!goX || !goY) return false; - float x = (float)atof(px); - float y = (float)atof(py); + float x = (float)atof(goX); + float y = (float)atof(goY); float z; - float ort; - uint32 mapid; - - if (pmapid) - mapid = (uint32)atoi(pmapid); - else - mapid = _player->GetMapId(); - - if ( port ) - ort = (float)atof(port); - else - ort = _player->GetOrientation(); - - if ( pz ) + float ort = port ? (float)atof(port) : player->GetOrientation(); + uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId(); + + if (goZ) { - z = (float)atof(pz); - if (!MapManager::IsValidMapCoord(mapid, x, y, z)) + z = (float)atof(goZ); + if (!MapManager::IsValidMapCoord(mapId, x, y, z)) { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid); + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId); handler->SetSentErrorMessage(true); return false; } } else { - if (!MapManager::IsValidMapCoord(mapid, x, y)) + if (!MapManager::IsValidMapCoord(mapId, x, y)) { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid); + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId); handler->SetSentErrorMessage(true); return false; } - Map const* map = sMapMgr->CreateBaseMap(mapid); + Map const* map = sMapMgr->CreateBaseMap(mapId); z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); } // stop flight if need - if (_player->isInFlight()) + if (player->isInFlight()) { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); } // save only in non-flight case else - _player->SaveRecallPosition(); - - _player->TeleportTo(mapid, x, y, z, ort); + player->SaveRecallPosition(); + player->TeleportTo(mapId, x, y, z, ort); return true; } - static bool HandleGoTicketCommand(ChatHandler* handler, const char* args) + + static bool HandleGoTicketCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - char *sTicketId = strtok((char*)args, " "); - if (!sTicketId) + char* id = strtok((char*)args, " "); + if (!id) return false; - uint32 ticketId = atoi(sTicketId); + uint32 ticketId = atoi(id); if (!ticketId) return false; @@ -565,16 +553,16 @@ public: return true; } - Player* _player = handler->GetSession()->GetPlayer(); - if (_player->isInFlight()) + Player* player = handler->GetSession()->GetPlayer(); + if (player->isInFlight()) { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); } else - _player->SaveRecallPosition(); + player->SaveRecallPosition(); - ticket->TeleportTo(_player); + ticket->TeleportTo(player); return true; } }; diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index f8e636fb961..4c9960992e1 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -69,35 +69,35 @@ public: return commandTable; } - static bool HandleGameObjectActivateCommand(ChatHandler* handler, const char* args) + static bool HandleGameObjectActivateCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); - if (!cId) + char* id = handler->extractKeyFromLink((char*)args, "Hgameobject"); + if (!id) return false; - uint32 lowguid = atoi(cId); - if (!lowguid) + uint32 guidLow = atoi(id); + if (!guidLow) return false; - GameObject* obj = NULL; + GameObject* object = NULL; // by DB guid - if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid)) - obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id); + if (GameObjectData const* goData = sObjectMgr->GetGOData(guidLow)) + object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, goData->id); - if (!obj) + if (!object) { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); handler->SetSentErrorMessage(true); return false; } // Activate - obj->SetLootState(GO_READY); - obj->UseDoorOrButton(10000); + object->SetLootState(GO_READY); + object->UseDoorOrButton(10000); handler->PSendSysMessage("Object activated!"); @@ -105,92 +105,92 @@ public: } //spawn go - static bool HandleGameObjectAddCommand(ChatHandler* handler, const char* args) + static bool HandleGameObjectAddCommand(ChatHandler* handler, char const* args) { if (!*args) return false; // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject_entry"); - if (!cId) + char* id = handler->extractKeyFromLink((char*)args, "Hgameobject_entry"); + if (!id) return false; - uint32 id = atol(cId); - if (!id) + uint32 objectId = atol(id); + if (!objectId) return false; char* spawntimeSecs = strtok(NULL, " "); - const GameObjectTemplate* gInfo = sObjectMgr->GetGameObjectTemplate(id); + const GameObjectTemplate* objectInfo = sObjectMgr->GetGameObjectTemplate(objectId); - if (!gInfo) + if (!objectInfo) { - handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, id); + handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, objectId); handler->SetSentErrorMessage(true); return false; } - if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId)) + if (objectInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId)) { // report to DB errors log as in loading case - sLog->outErrorDb("Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", id, gInfo->type, gInfo->displayId); - handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, id); + sLog->outErrorDb("Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", objectId, objectInfo->type, objectInfo->displayId); + handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, objectId); handler->SetSentErrorMessage(true); return false; } - Player* chr = handler->GetSession()->GetPlayer(); - float x = float(chr->GetPositionX()); - float y = float(chr->GetPositionY()); - float z = float(chr->GetPositionZ()); - float o = float(chr->GetOrientation()); - Map* map = chr->GetMap(); + Player* player = handler->GetSession()->GetPlayer(); + float x = float(player->GetPositionX()); + float y = float(player->GetPositionY()); + float z = float(player->GetPositionZ()); + float o = float(player->GetOrientation()); + Map* map = player->GetMap(); - GameObject* pGameObj = new GameObject; - uint32 db_lowGUID = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT); + GameObject* object = new GameObject; + uint32 guidLow = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT); - if (!pGameObj->Create(db_lowGUID, gInfo->entry, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY)) + if (!object->Create(guidLow, objectInfo->entry, map, player->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY)) { - delete pGameObj; + delete object; return false; } if (spawntimeSecs) { uint32 value = atoi((char*)spawntimeSecs); - pGameObj->SetRespawnTime(value); - //sLog->outDebug(LOG_FILTER_TSCR, "*** spawntimeSecs: %d", value); + object->SetRespawnTime(value); } // fill the gameobject data and save to the db - pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); + object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), player->GetPhaseMaskForSpawn()); // this will generate a new guid if the object is in an instance - if (!pGameObj->LoadFromDB(db_lowGUID, map)) + if (!object->LoadFromDB(guidLow, map)) { - delete pGameObj; + delete object; return false; } - map->Add(pGameObj); + map->AddToMap(object); // TODO: is it really necessary to add both the real and DB table guid here ? - sObjectMgr->AddGameobjectToGrid(db_lowGUID, sObjectMgr->GetGOData(db_lowGUID)); + sObjectMgr->AddGameobjectToGrid(guidLow, sObjectMgr->GetGOData(guidLow)); - handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, id, gInfo->name.c_str(), db_lowGUID, x, y, z); + handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, objectId, objectInfo->name.c_str(), guidLow, x, y, z); return true; } // add go, temp only - static bool HandleGameObjectAddTempCommand(ChatHandler* handler, const char* args) + static bool HandleGameObjectAddTempCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - char* charID = strtok((char*)args, " "); - if (!charID) + + char* id = strtok((char*)args, " "); + if (!id) return false; - Player* chr = handler->GetSession()->GetPlayer(); + Player* player = handler->GetSession()->GetPlayer(); char* spawntime = strtok(NULL, " "); uint32 spawntm = 300; @@ -198,46 +198,47 @@ public: if (spawntime) spawntm = atoi((char*)spawntime); - float x = chr->GetPositionX(); - float y = chr->GetPositionY(); - float z = chr->GetPositionZ(); - float ang = chr->GetOrientation(); + float x = player->GetPositionX(); + float y = player->GetPositionY(); + float z = player->GetPositionZ(); + float ang = player->GetOrientation(); float rot2 = sin(ang/2); float rot3 = cos(ang/2); - uint32 id = atoi(charID); + uint32 objectId = atoi(id); - chr->SummonGameObject(id, x, y, z, ang, 0, 0, rot2, rot3, spawntm); + player->SummonGameObject(objectId, x, y, z, ang, 0, 0, rot2, rot3, spawntm); return true; } - static bool HandleGameObjectTargetCommand(ChatHandler* handler, const char* args) + static bool HandleGameObjectTargetCommand(ChatHandler* handler, char const* args) { - Player* pl = handler->GetSession()->GetPlayer(); + Player* player = handler->GetSession()->GetPlayer(); QueryResult result; GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr->GetActiveEventList(); + if (*args) { // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject_entry"); - if (!cId) + char* id = handler->extractKeyFromLink((char*)args, "Hgameobject_entry"); + if (!id) return false; - uint32 id = atol(cId); + uint32 objectId = atol(id); - if (id) + if (objectId) result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(), id); + player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), objectId); else { - std::string name = cId; + std::string name = id; WorldDatabase.EscapeString(name); result = WorldDatabase.PQuery( "SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ " "FROM gameobject, gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'")" ORDER BY order_ ASC LIMIT 1", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(), name.c_str()); + player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), name.c_str()); } } else @@ -250,8 +251,8 @@ public: { if (initString) { - eventFilter << "OR eventEntry IN (" <<*itr; - initString =false; + eventFilter << "OR eventEntry IN (" << *itr; + initString = false; } else eventFilter << ',' << *itr; @@ -277,25 +278,25 @@ public: bool found = false; float x, y, z, o; - uint32 lowguid, id; - uint16 mapid, phase; - uint32 pool_id; + uint32 guidLow, id; + uint16 mapId, phase; + uint32 poolId; do { Field* fields = result->Fetch(); - lowguid = fields[0].GetUInt32(); + guidLow = fields[0].GetUInt32(); id = fields[1].GetUInt32(); x = fields[2].GetFloat(); y = fields[3].GetFloat(); z = fields[4].GetFloat(); o = fields[5].GetFloat(); - mapid = fields[6].GetUInt16(); + mapId = fields[6].GetUInt16(); phase = fields[7].GetUInt16(); - pool_id = sPoolMgr->IsPartOfAPool<GameObject>(lowguid); - if (!pool_id || sPoolMgr->IsSpawnedObject<GameObject>(lowguid)) + poolId = sPoolMgr->IsPartOfAPool<GameObject>(guidLow); + if (!poolId || sPoolMgr->IsSpawnedObject<GameObject>(guidLow)) found = true; - } while (result->NextRow() && (!found)); + } while (result->NextRow() && !found); if (!found) { @@ -303,21 +304,21 @@ public: return false; } - GameObjectTemplate const* goI = sObjectMgr->GetGameObjectTemplate(id); + GameObjectTemplate const* objectInfo = sObjectMgr->GetGameObjectTemplate(id); - if (!goI) + if (!objectInfo) { handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, id); return false; } - GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(MAKE_NEW_GUID(lowguid, id, HIGHGUID_GAMEOBJECT)); + GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(MAKE_NEW_GUID(guidLow, id, HIGHGUID_GAMEOBJECT)); - handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name.c_str(), lowguid, id, x, y, z, mapid, o, phase); + handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, guidLow, objectInfo->name.c_str(), guidLow, id, x, y, z, mapId, o, phase); if (target) { - int32 curRespawnDelay = int32(target->GetRespawnTimeEx()-time(NULL)); + int32 curRespawnDelay = int32(target->GetRespawnTimeEx() - time(NULL)); if (curRespawnDelay < 0) curRespawnDelay = 0; @@ -330,219 +331,217 @@ public: } //delete object by selection or guid - static bool HandleGameObjectDeleteCommand(ChatHandler* handler, const char* args) + static bool HandleGameObjectDeleteCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); - if (!cId) + char* id = handler->extractKeyFromLink((char*)args, "Hgameobject"); + if (!id) return false; - uint32 lowguid = atoi(cId); - if (!lowguid) + uint32 guidLow = atoi(id); + if (!guidLow) return false; - GameObject* obj = NULL; + GameObject* object = NULL; // by DB guid - if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid)) - obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id); + if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) + object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - if (!obj) + if (!object) { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); handler->SetSentErrorMessage(true); return false; } - uint64 owner_guid = obj->GetOwnerGUID(); - if (owner_guid) + uint64 ownerGuid = object->GetOwnerGUID(); + if (ownerGuid) { - Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), owner_guid); - if (!owner || !IS_PLAYER_GUID(owner_guid)) + Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), ownerGuid); + if (!owner || !IS_PLAYER_GUID(ownerGuid)) { - handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow()); + handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(ownerGuid), object->GetGUIDLow()); handler->SetSentErrorMessage(true); return false; } - owner->RemoveGameObject(obj, false); + owner->RemoveGameObject(object, false); } - obj->SetRespawnTime(0); // not save respawn time - obj->Delete(); - obj->DeleteFromDB(); + object->SetRespawnTime(0); // not save respawn time + object->Delete(); + object->DeleteFromDB(); - handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, obj->GetGUIDLow()); + handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetGUIDLow()); return true; } //turn selected object - static bool HandleGameObjectTurnCommand(ChatHandler* handler, const char* args) + static bool HandleGameObjectTurnCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); - if (!cId) + char* id = handler->extractKeyFromLink((char*)args, "Hgameobject"); + if (!id) return false; - uint32 lowguid = atoi(cId); - if (!lowguid) + uint32 guidLow = atoi(id); + if (!guidLow) return false; - GameObject* obj = NULL; + GameObject* object = NULL; // by DB guid - if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid)) - obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id); + if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) + object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - if (!obj) + if (!object) { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); handler->SetSentErrorMessage(true); return false; } - char* po = strtok(NULL, " "); + char* orientation = strtok(NULL, " "); float o; - if (po) - { - o = (float)atof(po); - } + if (orientation) + o = (float)atof(orientation); else { - Player* chr = handler->GetSession()->GetPlayer(); - o = chr->GetOrientation(); + Player* player = handler->GetSession()->GetPlayer(); + o = player->GetOrientation(); } - obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o); - obj->UpdateRotationFields(); - obj->DestroyForNearbyPlayers(); - obj->UpdateObjectVisibility(); + object->Relocate(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), o); + object->UpdateRotationFields(); + object->DestroyForNearbyPlayers(); + object->UpdateObjectVisibility(); - obj->SaveToDB(); - obj->Refresh(); + object->SaveToDB(); + object->Refresh(); - handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name.c_str(), obj->GetGUIDLow(), o); + handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow(), o); return true; } //move selected object - static bool HandleGameObjectMoveCommand(ChatHandler* handler, const char* args) + static bool HandleGameObjectMoveCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); - if (!cId) + char* id = handler->extractKeyFromLink((char*)args, "Hgameobject"); + if (!id) return false; - uint32 lowguid = atoi(cId); - if (!lowguid) + uint32 guidLow = atoi(id); + if (!guidLow) return false; - GameObject* obj = NULL; + GameObject* object = NULL; // by DB guid - if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid)) - obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id); + if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) + object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - if (!obj) + if (!object) { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); handler->SetSentErrorMessage(true); return false; } - char* px = strtok(NULL, " "); - char* py = strtok(NULL, " "); - char* pz = strtok(NULL, " "); + char* toX = strtok(NULL, " "); + char* toY = strtok(NULL, " "); + char* toZ = strtok(NULL, " "); - if (!px) + if (!toX) { - Player* chr = handler->GetSession()->GetPlayer(); - obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation()); - obj->DestroyForNearbyPlayers(); - obj->UpdateObjectVisibility(); + Player* player = handler->GetSession()->GetPlayer(); + object->Relocate(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), object->GetOrientation()); + object->DestroyForNearbyPlayers(); + object->UpdateObjectVisibility(); } else { - if (!py || !pz) + if (!toY || !toZ) return false; - float x = (float)atof(px); - float y = (float)atof(py); - float z = (float)atof(pz); + float x = (float)atof(toX); + float y = (float)atof(toY); + float z = (float)atof(toZ); - if (!MapManager::IsValidMapCoord(obj->GetMapId(), x, y, z)) + if (!MapManager::IsValidMapCoord(object->GetMapId(), x, y, z)) { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, obj->GetMapId()); + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, object->GetMapId()); handler->SetSentErrorMessage(true); return false; } - obj->Relocate(x, y, z, obj->GetOrientation()); - obj->DestroyForNearbyPlayers(); - obj->UpdateObjectVisibility(); + object->Relocate(x, y, z, object->GetOrientation()); + object->DestroyForNearbyPlayers(); + object->UpdateObjectVisibility(); } - obj->SaveToDB(); - obj->Refresh(); + object->SaveToDB(); + object->Refresh(); - handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name.c_str(), obj->GetGUIDLow()); + handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow()); return true; } - //set pahsemask for selected object - static bool HandleGameObjectSetPhaseCommand(ChatHandler* handler, const char* args) + //set phasemask for selected object + static bool HandleGameObjectSetPhaseCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); - if (!cId) + char* id = handler->extractKeyFromLink((char*)args, "Hgameobject"); + if (!id) return false; - uint32 lowguid = atoi(cId); - if (!lowguid) + uint32 guidLow = atoi(id); + if (!guidLow) return false; - GameObject* obj = NULL; + GameObject* object = NULL; // by DB guid - if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid)) - obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id); + if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) + object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - if (!obj) + if (!object) { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); handler->SetSentErrorMessage(true); return false; } - char* phaseStr = strtok (NULL, " "); - uint32 phasemask = phaseStr? atoi(phaseStr) : 0; - if (phasemask == 0) + char* phase = strtok (NULL, " "); + uint32 phaseMask = phase ? atoi(phase) : 0; + if (phaseMask == 0) { handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } - obj->SetPhaseMask(phasemask, true); - obj->SaveToDB(); + object->SetPhaseMask(phaseMask, true); + object->SaveToDB(); return true; } - static bool HandleGameObjectNearCommand(ChatHandler* handler, const char* args) + static bool HandleGameObjectNearCommand(ChatHandler* handler, char const* args) { float distance = (!*args) ? 10.0f : (float)(atof(args)); uint32 count = 0; - Player* pl = handler->GetSession()->GetPlayer(); + Player* player = handler->GetSession()->GetPlayer(); QueryResult result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, " "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ " "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), - pl->GetMapId(), pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), distance*distance); + player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), + player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), distance * distance); if (result) { @@ -554,14 +553,14 @@ public: float x = fields[2].GetFloat(); float y = fields[3].GetFloat(); float z = fields[4].GetFloat(); - uint16 mapid = fields[5].GetUInt16(); + uint16 mapId = fields[5].GetUInt16(); - GameObjectTemplate const* gInfo = sObjectMgr->GetGameObjectTemplate(entry); + GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry); - if (!gInfo) + if (!gameObjectInfo) continue; - handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name.c_str(), x, y, z, mapid); + handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gameObjectInfo->name.c_str(), x, y, z, mapId); ++count; } while (result->NextRow()); @@ -572,99 +571,97 @@ public: } //show info of gameobject - static bool HandleGameObjectInfoCommand(ChatHandler* handler, const char* args) + static bool HandleGameObjectInfoCommand(ChatHandler* handler, char const* args) { uint32 entry = 0; uint32 type = 0; - uint32 displayid = 0; + uint32 displayId = 0; std::string name; uint32 lootId = 0; if (!*args) { - if (WorldObject* obj = handler->getSelectedObject()) - entry = obj->GetEntry(); + if (WorldObject* object = handler->getSelectedObject()) + entry = object->GetEntry(); else entry = atoi((char*)args); } - GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry); + GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry); - if (!goinfo) + if (!gameObjectInfo) return false; - type = goinfo->type; - displayid = goinfo->displayId; - name = goinfo->name; + type = gameObjectInfo->type; + displayId = gameObjectInfo->displayId; + name = gameObjectInfo->name; if (type == GAMEOBJECT_TYPE_CHEST) - lootId = goinfo->chest.lootId; + lootId = gameObjectInfo->chest.lootId; else if (type == GAMEOBJECT_TYPE_FISHINGHOLE) - lootId = goinfo->fishinghole.lootId; + lootId = gameObjectInfo->fishinghole.lootId; handler->PSendSysMessage(LANG_GOINFO_ENTRY, entry); handler->PSendSysMessage(LANG_GOINFO_TYPE, type); handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId); - handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayid); + handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayId); handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str()); return true; } - static bool HandleGameObjectSetStateCommand(ChatHandler* handler, const char* args) + static bool HandleGameObjectSetStateCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); - if (!cId) + char* id = handler->extractKeyFromLink((char*)args, "Hgameobject"); + if (!id) return false; - uint32 lowguid = atoi(cId); - if (!lowguid) + uint32 guidLow = atoi(id); + if (!guidLow) return false; - GameObject* gobj = NULL; + GameObject* object = NULL; - if (GameObjectData const* goData = sObjectMgr->GetGOData(lowguid)) - gobj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, goData->id); + if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) + object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - if (!gobj) + if (!object) { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); handler->SetSentErrorMessage(true); return false; } - char* ctype = strtok(NULL, " "); - if (!ctype) + char* type = strtok(NULL, " "); + if (!type) return false; - int32 type = atoi(ctype); - if (type < 0) + int32 objectType = atoi(type); + if (objectType < 0) { - if (type == -1) - gobj->SendObjectDeSpawnAnim(gobj->GetGUID()); - else if (type == -2) - { + if (objectType == -1) + object->SendObjectDeSpawnAnim(object->GetGUID()); + else if (objectType == -2) return false; - } return true; } - char* cstate = strtok(NULL, " "); - if (!cstate) + char* state = strtok(NULL, " "); + if (!state) return false; - int32 state = atoi(cstate); + int32 objectState = atoi(state); - if (type < 4) - gobj->SetByteValue(GAMEOBJECT_BYTES_1, type, state); - else if (type == 4) + if (objectType < 4) + object->SetByteValue(GAMEOBJECT_BYTES_1, objectType, objectState); + else if (objectType == 4) { WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8+4); - data << gobj->GetGUID(); - data << (uint32)(state); - gobj->SendMessageToSet(&data, true); + data << object->GetGUID(); + data << (uint32)(objectState); + object->SendMessageToSet(&data, true); } - handler->PSendSysMessage("Set gobject type %d state %d", type, state); + handler->PSendSysMessage("Set gobject type %d state %d", objectType, objectState); return true; } }; diff --git a/src/server/scripts/Commands/cs_gps.cpp b/src/server/scripts/Commands/cs_gps.cpp index 2a270527fb8..bafaae465ef 100644 --- a/src/server/scripts/Commands/cs_gps.cpp +++ b/src/server/scripts/Commands/cs_gps.cpp @@ -43,16 +43,16 @@ public: return commandTable; } - static bool HandleGPSCommand(ChatHandler* handler, const char *args) + static bool HandleGPSCommand(ChatHandler* handler, char const* args) { - WorldObject* obj = NULL; + WorldObject* object = NULL; if (*args) { uint64 guid = handler->extractGuidFromLink((char*)args); if (guid) - obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT); + object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT); - if (!obj) + if (!object) { handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); handler->SetSentErrorMessage(true); @@ -61,71 +61,73 @@ public: } else { - obj = handler->getSelectedUnit(); + object = handler->getSelectedUnit(); - if (!obj) + if (!object) { handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); handler->SetSentErrorMessage(true); return false; } } - CellPair cell_val = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - Cell cell(cell_val); - uint32 zone_id, area_id; - obj->GetZoneAndAreaId(zone_id, area_id); + CellCoord cellCoord = Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY()); + Cell cell(cellCoord); - MapEntry const* mapEntry = sMapStore.LookupEntry(obj->GetMapId()); - AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zone_id); - AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(area_id); + uint32 zoneId, areaId; + object->GetZoneAndAreaId(zoneId, areaId); - float zone_x = obj->GetPositionX(); - float zone_y = obj->GetPositionY(); + MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId()); + AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zoneId); + AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId); - Map2ZoneCoordinates(zone_x, zone_y, zone_id); + float zoneX = object->GetPositionX(); + float zoneY = object->GetPositionY(); - Map const* map = obj->GetMap(); - float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT); - float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ()); + Map2ZoneCoordinates(zoneX, zoneY, zoneId); - GridPair p = Trinity::ComputeGridPair(obj->GetPositionX(), obj->GetPositionY()); + Map const* map = object->GetMap(); + float groundZ = map->GetHeight(object->GetPositionX(), object->GetPositionY(), MAX_HEIGHT); + float floorZ = map->GetHeight(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ()); + + GridCoord gridCoord = Trinity::ComputeGridCoord(object->GetPositionX(), object->GetPositionY()); // 63? WHY? - int gx = 63 - p.x_coord; - int gy = 63 - p.y_coord; + int gridX = 63 - gridCoord.x_coord; + int gridY = 63 - gridCoord.y_coord; - uint32 have_map = Map::ExistMap(obj->GetMapId(), gx, gy) ? 1 : 0; - uint32 have_vmap = Map::ExistVMap(obj->GetMapId(), gx, gy) ? 1 : 0; + uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0; + uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0; - if (have_vmap) + if (haveVMap) { - if (map->IsOutdoors(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ())) + if (map->IsOutdoors(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ())) handler->PSendSysMessage("You are outdoors"); else handler->PSendSysMessage("You are indoors"); } - else handler->PSendSysMessage("no VMAP available for area info"); + else + handler->PSendSysMessage("no VMAP available for area info"); handler->PSendSysMessage(LANG_MAP_POSITION, - obj->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"), - zone_id, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"), - area_id, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"), - obj->GetPhaseMask(), - obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), - cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), - zone_x, zone_y, ground_z, floor_z, have_map, have_vmap); - - LiquidData liquid_status; - ZLiquidStatus res = map->getLiquidStatus(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), MAP_ALL_LIQUIDS, &liquid_status); - if (res) - { - handler->PSendSysMessage(LANG_LIQUID_STATUS, liquid_status.level, liquid_status.depth_level, liquid_status.type, res); - } + object->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"), + zoneId, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"), + areaId, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"), + object->GetPhaseMask(), + object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(), + cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(), + zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap); + + LiquidData liquidStatus; + ZLiquidStatus status = map->getLiquidStatus(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus); + + if (status) + handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidStatus.level, liquidStatus.depth_level, liquidStatus.type, status); + return true; } - static bool HandleWPGPSCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleWPGPSCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp index 6f44000017d..f6c6d89c0b7 100644 --- a/src/server/scripts/Commands/cs_honor.cpp +++ b/src/server/scripts/Commands/cs_honor.cpp @@ -39,12 +39,14 @@ public: { "", SEC_GAMEMASTER, false, &HandleHonorAddCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; + static ChatCommand honorCommandTable[] = { { "add", SEC_GAMEMASTER, false, NULL, "", honorAddCommandTable }, { "update", SEC_GAMEMASTER, false, &HandleHonorUpdateCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; + static ChatCommand commandTable[] = { { "honor", SEC_GAMEMASTER, false, NULL, "", honorCommandTable }, @@ -52,7 +54,8 @@ public: }; return commandTable; } - static bool HandleHonorAddCommand(ChatHandler* handler, const char* args) + + static bool HandleHonorAddCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -73,7 +76,8 @@ public: target->RewardHonor(NULL, 1, amount); return true; } - static bool HandleHonorAddKillCommand(ChatHandler* handler, const char* /*args*/) + + static bool HandleHonorAddKillCommand(ChatHandler* handler, char const* /*args*/) { Unit* target = handler->getSelectedUnit(); if (!target) @@ -90,7 +94,8 @@ public: handler->GetSession()->GetPlayer()->RewardHonor(target, 1); return true; } - static bool HandleHonorUpdateCommand(ChatHandler* handler, const char* /*args*/) + + static bool HandleHonorUpdateCommand(ChatHandler* handler, char const* /*args*/) { Player* target = handler->getSelectedPlayer(); if (!target) diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp index 9eb315b0b6a..d03291d6d5d 100644 --- a/src/server/scripts/Commands/cs_learn.cpp +++ b/src/server/scripts/Commands/cs_learn.cpp @@ -37,28 +37,29 @@ public: { static ChatCommand learnAllMyCommandTable[] = { - { "class", SEC_ADMINISTRATOR, false, &HandleLearnAllMyClassCommand, "", NULL }, - { "pettalents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyPetTalentsCommand, "", NULL }, - { "spells", SEC_ADMINISTRATOR, false, &HandleLearnAllMySpellsCommand, "", NULL }, - { "talents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyTalentsCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "class", SEC_ADMINISTRATOR, false, &HandleLearnAllMyClassCommand, "", NULL }, + { "pettalents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyPetTalentsCommand, "", NULL }, + { "spells", SEC_ADMINISTRATOR, false, &HandleLearnAllMySpellsCommand, "", NULL }, + { "talents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyTalentsCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } }; + static ChatCommand learnAllCommandTable[] = { - { "my", SEC_ADMINISTRATOR, false, NULL, "", learnAllMyCommandTable }, - { "gm", SEC_GAMEMASTER, false, &HandleLearnAllGMCommand, "", NULL }, - { "crafts", SEC_GAMEMASTER, false, &HandleLearnAllCraftsCommand, "", NULL }, - { "default", SEC_MODERATOR, false, &HandleLearnAllDefaultCommand, "", NULL }, - { "lang", SEC_MODERATOR, false, &HandleLearnAllLangCommand, "", NULL }, - { "recipes", SEC_GAMEMASTER, false, &HandleLearnAllRecipesCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "my", SEC_ADMINISTRATOR, false, NULL, "", learnAllMyCommandTable }, + { "gm", SEC_GAMEMASTER, false, &HandleLearnAllGMCommand, "", NULL }, + { "crafts", SEC_GAMEMASTER, false, &HandleLearnAllCraftsCommand, "", NULL }, + { "default", SEC_MODERATOR, false, &HandleLearnAllDefaultCommand, "", NULL }, + { "lang", SEC_MODERATOR, false, &HandleLearnAllLangCommand, "", NULL }, + { "recipes", SEC_GAMEMASTER, false, &HandleLearnAllRecipesCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } }; static ChatCommand learnCommandTable[] = { - { "all", SEC_ADMINISTRATOR, false, NULL, "", learnAllCommandTable }, - { "", SEC_ADMINISTRATOR, false, &HandleLearnCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "all", SEC_ADMINISTRATOR, false, NULL, "", learnAllCommandTable }, + { "", SEC_ADMINISTRATOR, false, &HandleLearnCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } }; static ChatCommand commandTable[] = @@ -68,7 +69,8 @@ public: }; return commandTable; } - static bool HandleLearnCommand(ChatHandler* handler, const char* args) + + static bool HandleLearnCommand(ChatHandler* handler, char const* args) { Player* targetPlayer = handler->getSelectedPlayer(); @@ -84,8 +86,8 @@ public: if (!spell || !sSpellMgr->GetSpellInfo(spell)) return false; - char const* allStr = strtok(NULL, " "); - bool allRanks = allStr ? (strncmp(allStr, "all", strlen(allStr)) == 0) : false; + char const* all = strtok(NULL, " "); + bool allRanks = all ? (strncmp(all, "all", strlen(all)) == 0) : false; SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell); if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer())) @@ -110,14 +112,14 @@ public: else targetPlayer->learnSpell(spell, false); - uint32 first_spell = sSpellMgr->GetFirstSpellInChain(spell); - if (GetTalentSpellCost(first_spell)) + uint32 firstSpell = sSpellMgr->GetFirstSpellInChain(spell); + if (GetTalentSpellCost(firstSpell)) targetPlayer->SendTalentsInfoData(false); return true; } - static bool HandleLearnAllGMCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleLearnAllGMCommand(ChatHandler* handler, char const* /*args*/) { for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i) { @@ -135,19 +137,19 @@ public: return true; } - static bool HandleLearnAllMyClassCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleLearnAllMyClassCommand(ChatHandler* handler, char const* /*args*/) { HandleLearnAllMySpellsCommand(handler, ""); HandleLearnAllMyTalentsCommand(handler, ""); return true; } - static bool HandleLearnAllMySpellsCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleLearnAllMySpellsCommand(ChatHandler* handler, char const* /*args*/) { - ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(handler->GetSession()->GetPlayer()->getClass()); - if (!clsEntry) + ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(handler->GetSession()->GetPlayer()->getClass()); + if (!classEntry) return true; - uint32 family = clsEntry->spellfamily; + uint32 family = classEntry->spellfamily; for (uint32 i = 0; i < sSkillLineAbilityStore.GetNumRows(); ++i) { @@ -172,8 +174,8 @@ public: continue; // skip spells with first rank learned as talent (and all talents then also) - uint32 first_rank = sSpellMgr->GetFirstSpellInChain(spellInfo->Id); - if (GetTalentSpellCost(first_rank) > 0) + uint32 firstRank = sSpellMgr->GetFirstSpellInChain(spellInfo->Id); + if (GetTalentSpellCost(firstRank) > 0) continue; // skip broken spells @@ -187,7 +189,7 @@ public: return true; } - static bool HandleLearnAllMyTalentsCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleLearnAllMyTalentsCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); uint32 classMask = player->getClassMask(); @@ -207,7 +209,7 @@ public: // search highest talent rank uint32 spellId = 0; - for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank) { if (talentInfo->RankID[rank] != 0) { @@ -234,7 +236,7 @@ public: return true; } - static bool HandleLearnAllMyPetTalentsCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleLearnAllMyPetTalentsCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); @@ -246,23 +248,23 @@ public: return false; } - CreatureTemplate const* ci = pet->GetCreatureInfo(); - if (!ci) + CreatureTemplate const* creatureInfo = pet->GetCreatureInfo(); + if (!creatureInfo) { handler->SendSysMessage(LANG_WRONG_PET_TYPE); handler->SetSentErrorMessage(true); return false; } - CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->family); - if (!pet_family) + CreatureFamilyEntry const* petFamily = sCreatureFamilyStore.LookupEntry(creatureInfo->family); + if (!petFamily) { handler->SendSysMessage(LANG_WRONG_PET_TYPE); handler->SetSentErrorMessage(true); return false; } - if (pet_family->petTalentType < 0) // not hunter pet + if (petFamily->petTalentType < 0) // not hunter pet { handler->SendSysMessage(LANG_WRONG_PET_TYPE); handler->SetSentErrorMessage(true); @@ -280,30 +282,30 @@ public: continue; // prevent learn talent for different family (cheating) - if (((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask) == 0) + if (((1 << petFamily->petTalentType) & talentTabInfo->petTalentMask) == 0) continue; // search highest talent rank - uint32 spellid = 0; + uint32 spellId = 0; for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) { if (talentInfo->RankID[rank] != 0) { - spellid = talentInfo->RankID[rank]; + spellId = talentInfo->RankID[rank]; break; } } - if (!spellid) // ??? none spells in talent + if (!spellId) // ??? none spells in talent continue; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer(), false)) continue; // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) - pet->learnSpellHighRank(spellid); + pet->learnSpellHighRank(spellId); } pet->SetFreeTalentPoints(0); @@ -312,7 +314,7 @@ public: return true; } - static bool HandleLearnAllLangCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleLearnAllLangCommand(ChatHandler* handler, char const* /*args*/) { // skipping UNIVERSAL language (0) for (uint8 i = 1; i < LANGUAGES_COUNT; ++i) @@ -322,7 +324,7 @@ public: return true; } - static bool HandleLearnAllDefaultCommand(ChatHandler* handler, const char* args) + static bool HandleLearnAllDefaultCommand(ChatHandler* handler, char const* args) { Player* target; if (!handler->extractPlayerTarget((char*)args, &target)) @@ -335,9 +337,8 @@ public: return true; } - static bool HandleLearnAllCraftsCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleLearnAllCraftsCommand(ChatHandler* handler, char const* /*args*/) { - for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i) { SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i); @@ -355,7 +356,7 @@ public: return true; } - static bool HandleLearnAllRecipesCommand(ChatHandler* handler, const char* args) + static bool HandleLearnAllRecipesCommand(ChatHandler* handler, char const* args) { // Learns all recipes of specified profession and sets skill to max // Example: .learn all_recipes enchanting @@ -370,13 +371,13 @@ public: if (!*args) return false; - std::wstring wnamepart; + std::wstring namePart; - if (!Utf8toWStr(args, wnamepart)) + if (!Utf8toWStr(args, namePart)) return false; // converting string that we try to find to lower case - wstrToLower(wnamepart); + wstrToLower(namePart); std::string name; @@ -392,29 +393,29 @@ public: !skillInfo->canLink) // only prof with recipes have set continue; - int loc = handler->GetSessionDbcLocale(); - name = skillInfo->name[loc]; + int locale = handler->GetSessionDbcLocale(); + name = skillInfo->name[locale]; if (name.empty()) continue; - if (!Utf8FitTo(name, wnamepart)) + if (!Utf8FitTo(name, namePart)) { - loc = 0; - for (; loc < TOTAL_LOCALES; ++loc) + locale = 0; + for (; locale < TOTAL_LOCALES; ++locale) { - if (loc == handler->GetSessionDbcLocale()) + if (locale == handler->GetSessionDbcLocale()) continue; - name = skillInfo->name[loc]; + name = skillInfo->name[locale]; if (name.empty()) continue; - if (Utf8FitTo(name, wnamepart)) + if (Utf8FitTo(name, namePart)) break; } } - if (loc < TOTAL_LOCALES) + if (locale < TOTAL_LOCALES) { targetSkillInfo = skillInfo; break; @@ -431,7 +432,8 @@ public: handler->PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str()); return true; } - static void HandleLearnSkillRecipesHelper(Player* player, uint32 skill_id) + + static void HandleLearnSkillRecipesHelper(Player* player, uint32 skillId) { uint32 classmask = player->getClassMask(); @@ -442,7 +444,7 @@ public: continue; // wrong skill - if (skillLine->skillId != skill_id) + if (skillLine->skillId != skillId) continue; // not high rank diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index cdb87fde354..20d0994b911 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -149,13 +149,13 @@ public: // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); creature->LoadFromDB(db_guid, map); - map->Add(creature); + map->AddToMap(creature); sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid)); return true; } //add item in vendorlist - static bool HandleNpcAddVendorItemCommand(ChatHandler* handler, const char* args) + static bool HandleNpcAddVendorItemCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -168,7 +168,11 @@ public: return false; } - uint32 itemId = atol(pitem); + int32 item_int = atol(pitem); + if (item_int <= 0) + return false; + + uint32 itemId = item_int; char* fmaxcount = strtok(NULL, " "); //add maxcount, default: 0 uint32 maxcount = 0; @@ -623,7 +627,7 @@ public: const_cast<CreatureData*>(data)->posZ = z; const_cast<CreatureData*>(data)->orientation = o; } - creature->GetMap()->CreatureRelocation(creature, x, y, z, o); + creature->SetPosition(x, y, z, o); creature->GetMotionMaster()->Initialize(); if (creature->isAlive()) // dead creature will reset movement generator at respawn { @@ -1142,7 +1146,7 @@ public: pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1); // add to world - pet->GetMap()->Add(pet->ToCreature()); + pet->GetMap()->AddToMap(pet->ToCreature()); // visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL, level); diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp index 17c076f903c..8bfa010463a 100644 --- a/src/server/scripts/Commands/cs_tele.cpp +++ b/src/server/scripts/Commands/cs_tele.cpp @@ -125,6 +125,29 @@ public: if (!handler->extractPlayerTarget(nameStr, &target, &target_guid, &target_name)) return false; + if (strcmp(teleStr, "$home") == 0) // References target's homebind + { + if (target) + target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->GetOrientation()); + else + { + QueryResult resultDB = CharacterDatabase.PQuery("SELECT mapId, zoneId, posX, posY, posZ FROM character_homebind WHERE guid = %u", target_guid); + if (resultDB) + { + Field* fieldsDB = resultDB->Fetch(); + uint32 mapId = fieldsDB[0].GetUInt32(); + uint32 zoneId = fieldsDB[1].GetUInt32(); + float posX = fieldsDB[2].GetFloat(); + float posY = fieldsDB[3].GetFloat(); + float posZ = fieldsDB[4].GetFloat(); + + Player::SavePositionInDB(mapId, posX, posY, posZ, 0, zoneId, target_guid); + } + } + + return true; + } + // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r GameTele const* tele = handler->extractGameTeleFromLink(teleStr); if (!tele) @@ -228,38 +251,38 @@ public: for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* pl = itr->getSource(); + Player* player = itr->getSource(); - if (!pl || !pl->GetSession()) + if (!player || !player->GetSession()) continue; // check online security - if (handler->HasLowerSecurity(pl, 0)) + if (handler->HasLowerSecurity(player, 0)) return false; - std::string plNameLink = handler->GetNameLink(pl); + std::string plNameLink = handler->GetNameLink(player); - if (pl->IsBeingTeleported()) + if (player->IsBeingTeleported()) { handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str()); continue; } handler->PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(), "", tele->name.c_str()); - if (handler->needReportToTarget(pl)) - (ChatHandler(pl)).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str()); + if (handler->needReportToTarget(player)) + (ChatHandler(player)).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str()); // stop flight if need - if (pl->isInFlight()) + if (player->isInFlight()) { - pl->GetMotionMaster()->MovementExpired(); - pl->CleanupAfterTaxiFlight(); + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); } // save only in non-flight case else - pl->SaveRecallPosition(); + player->SaveRecallPosition(); - pl->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation); + player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation); } return true; diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 34ea264fd9e..f754a32fbfc 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -591,7 +591,7 @@ public: wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); wpCreature2->LoadFromDB(wpCreature2->GetDBTableGUIDLow(), map); - map->Add(wpCreature2); + map->AddToMap(wpCreature2); //sMapMgr->GetMap(npcCreature->GetMapId())->Add(wpCreature2); } @@ -790,12 +790,12 @@ public: wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(), map); - map->Add(wpCreature); + map->AddToMap(wpCreature); if (target) { wpCreature->SetDisplayId(target->GetDisplayId()); - wpCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); + wpCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5f); wpCreature->SetLevel(point > STRONG_MAX_LEVEL ? STRONG_MAX_LEVEL : point); } } @@ -837,12 +837,12 @@ public: creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); creature->LoadFromDB(creature->GetDBTableGUIDLow(), map); - map->Add(creature); + map->AddToMap(creature); if (target) { creature->SetDisplayId(target->GetDisplayId()); - creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); + creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5f); } return true; @@ -858,7 +858,7 @@ public: else Maxpoint = 0; - result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z FROM waypoint_data WHERE point ='%u' AND id = '%u'", Maxpoint, pathid); + result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation FROM waypoint_data WHERE point ='%u' AND id = '%u'", Maxpoint, pathid); if (!result) { handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, pathid); @@ -866,13 +866,13 @@ public: return false; } Field* fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); + float x = fields[0].GetFloat(); + float y = fields[1].GetFloat(); + float z = fields[2].GetFloat(); + float o = fields[3].GetFloat(); uint32 id = VISUAL_WAYPOINT; Player* chr = handler->GetSession()->GetPlayer(); - float o = chr->GetOrientation(); Map* map = chr->GetMap(); Creature* creature = new Creature; @@ -885,12 +885,12 @@ public: creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); creature->LoadFromDB(creature->GetDBTableGUIDLow(), map); - map->Add(creature); + map->AddToMap(creature); if (target) { creature->SetDisplayId(target->GetDisplayId()); - creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); + creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5f); } return true; diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp index e3295a6c45e..89a58e93853 100644 --- a/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp +++ b/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp @@ -52,33 +52,31 @@ class mob_av_marshal_or_warmaster : public CreatureScript public: mob_av_marshal_or_warmaster() - : CreatureScript("mob_av_marshal_or_warmaster") - { - } + : CreatureScript("mob_av_marshal_or_warmaster") {} struct mob_av_marshal_or_warmasterAI : public ScriptedAI { - mob_av_marshal_or_warmasterAI(Creature* c) : ScriptedAI(c) {} + mob_av_marshal_or_warmasterAI(Creature* creature) : ScriptedAI(creature) {} - uint32 uiChargeTimer; - uint32 uiCleaveTimer; - uint32 uiDemoralizingShoutTimer; - uint32 uiWhirlwind1Timer; - uint32 uiWhirlwind2Timer; - uint32 uiEnrageTimer; - uint32 uiResetTimer; + uint32 ChargeTimer; + uint32 CleaveTimer; + uint32 DemoralizingShoutTimer; + uint32 Whirlwind1Timer; + uint32 Whirlwind2Timer; + uint32 EnrageTimer; + uint32 ResetTimer; bool bHasAura; void Reset() { - uiChargeTimer = urand(2*IN_MILLISECONDS, 12*IN_MILLISECONDS); - uiCleaveTimer = urand(1*IN_MILLISECONDS, 11*IN_MILLISECONDS); - uiDemoralizingShoutTimer = urand(2*IN_MILLISECONDS, 2*IN_MILLISECONDS); - uiWhirlwind1Timer = urand(1*IN_MILLISECONDS, 12*IN_MILLISECONDS); - uiWhirlwind2Timer = urand(5*IN_MILLISECONDS, 20*IN_MILLISECONDS); - uiEnrageTimer = urand(5*IN_MILLISECONDS, 20*IN_MILLISECONDS); - uiResetTimer = 5*IN_MILLISECONDS; + ChargeTimer = urand(2 * IN_MILLISECONDS, 12 * IN_MILLISECONDS); + CleaveTimer = urand(1 * IN_MILLISECONDS, 11 * IN_MILLISECONDS); + DemoralizingShoutTimer = urand(2 * IN_MILLISECONDS, 2 * IN_MILLISECONDS); + Whirlwind1Timer = urand(1 * IN_MILLISECONDS, 12 * IN_MILLISECONDS); + Whirlwind2Timer = urand(5 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); + EnrageTimer = urand(5 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); + ResetTimer = 5 * IN_MILLISECONDS; bHasAura = false; } @@ -126,49 +124,49 @@ class mob_av_marshal_or_warmaster : public CreatureScript if (!UpdateVictim()) return; - if (uiChargeTimer <= diff) + if (ChargeTimer <= diff) { DoCast(me->getVictim(), SPELL_CHARGE); - uiChargeTimer = urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else uiChargeTimer -= diff; + ChargeTimer = urand(10 * IN_MILLISECONDS, 25 * IN_MILLISECONDS); + } else ChargeTimer -= diff; - if (uiCleaveTimer <= diff) + if (CleaveTimer <= diff) { DoCast(me->getVictim(), SPELL_CLEAVE); - uiCleaveTimer = urand(10*IN_MILLISECONDS, 16*IN_MILLISECONDS); - } else uiCleaveTimer -= diff; + CleaveTimer = urand(10 * IN_MILLISECONDS, 16 * IN_MILLISECONDS); + } else CleaveTimer -= diff; - if (uiDemoralizingShoutTimer <= diff) + if (DemoralizingShoutTimer <= diff) { DoCast(me->getVictim(), SPELL_DEMORALIZING_SHOUT); - uiDemoralizingShoutTimer = urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else uiDemoralizingShoutTimer -= diff; + DemoralizingShoutTimer = urand(10 * IN_MILLISECONDS, 15 * IN_MILLISECONDS); + } else DemoralizingShoutTimer -= diff; - if (uiWhirlwind1Timer <= diff) + if (Whirlwind1Timer <= diff) { DoCast(me->getVictim(), SPELL_WHIRLWIND1); - uiWhirlwind1Timer = urand(6*IN_MILLISECONDS, 20*IN_MILLISECONDS); - } else uiWhirlwind1Timer -= diff; + Whirlwind1Timer = urand(6 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); + } else Whirlwind1Timer -= diff; - if (uiWhirlwind2Timer <= diff) + if (Whirlwind2Timer <= diff) { DoCast(me->getVictim(), SPELL_WHIRLWIND2); - uiWhirlwind2Timer = urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else uiWhirlwind2Timer -= diff; + Whirlwind2Timer = urand(10 * IN_MILLISECONDS, 25 * IN_MILLISECONDS); + } else Whirlwind2Timer -= diff; - if (uiEnrageTimer <= diff) + if (EnrageTimer <= diff) { DoCast(me->getVictim(), SPELL_ENRAGE); - uiEnrageTimer = urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS); - }else uiEnrageTimer -= diff; + EnrageTimer = urand(10 * IN_MILLISECONDS, 30 * IN_MILLISECONDS); + }else EnrageTimer -= diff; // check if creature is not outside of building - if (uiResetTimer <= diff) + if (ResetTimer <= diff) { if (me->GetDistance2d(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY()) > 50) EnterEvadeMode(); - uiResetTimer = 5*IN_MILLISECONDS; - } else uiResetTimer -= diff; + ResetTimer = 5 * IN_MILLISECONDS; + } else ResetTimer -= diff; DoMeleeAttackIfReady(); } diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp index f1884b7c0e9..d66c138ebf2 100644 --- a/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp +++ b/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp @@ -48,7 +48,7 @@ public: struct mob_water_elementalAI : public ScriptedAI { - mob_water_elementalAI(Creature* c) : ScriptedAI(c) {} + mob_water_elementalAI(Creature* creature) : ScriptedAI(creature) {} uint32 waterBoltTimer; uint64 balindaGUID; @@ -56,8 +56,8 @@ public: void Reset() { - waterBoltTimer = 3*IN_MILLISECONDS; - resetTimer = 5*IN_MILLISECONDS; + waterBoltTimer = 3 * IN_MILLISECONDS; + resetTimer = 5 * IN_MILLISECONDS; } void UpdateAI(const uint32 diff) @@ -68,7 +68,7 @@ public: if (waterBoltTimer < diff) { DoCast(me->getVictim(), SPELL_WATERBOLT); - waterBoltTimer = 5*IN_MILLISECONDS; + waterBoltTimer = 5 * IN_MILLISECONDS; } else waterBoltTimer -= diff; // check if creature is not outside of building @@ -77,7 +77,7 @@ public: if (Creature* pBalinda = Unit::GetCreature(*me, balindaGUID)) if (me->GetDistance2d(pBalinda->GetHomePosition().GetPositionX(), pBalinda->GetHomePosition().GetPositionY()) > 50) EnterEvadeMode(); - resetTimer = 5*IN_MILLISECONDS; + resetTimer = 5 * IN_MILLISECONDS; } else resetTimer -= diff; DoMeleeAttackIfReady(); @@ -97,7 +97,7 @@ public: struct boss_balindaAI : public ScriptedAI { - boss_balindaAI(Creature* c) : ScriptedAI(c), summons(me) {} + boss_balindaAI(Creature* creature) : ScriptedAI(creature), summons(me) {} uint32 arcaneExplosionTimer; uint32 coneOfColdTimer; @@ -110,11 +110,11 @@ public: void Reset() { - arcaneExplosionTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - coneOfColdTimer = 8*IN_MILLISECONDS; - fireBoltTimer = 1*IN_MILLISECONDS; - frostboltTimer = 4*IN_MILLISECONDS; - resetTimer = 5*IN_MILLISECONDS; + arcaneExplosionTimer = urand(5 * IN_MILLISECONDS, 15 * IN_MILLISECONDS); + coneOfColdTimer = 8 * IN_MILLISECONDS; + fireBoltTimer = 1 * IN_MILLISECONDS; + frostboltTimer = 4 * IN_MILLISECONDS; + resetTimer = 5 * IN_MILLISECONDS; waterElementalTimer = 0; summons.DespawnAll(); @@ -151,32 +151,32 @@ public: if (waterElementalTimer < diff) { if (summons.empty()) - me->SummonCreature(NPC_WATER_ELEMENTAL, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45*IN_MILLISECONDS); - waterElementalTimer = 50*IN_MILLISECONDS; + me->SummonCreature(NPC_WATER_ELEMENTAL, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45 * IN_MILLISECONDS); + waterElementalTimer = 50 * IN_MILLISECONDS; } else waterElementalTimer -= diff; if (arcaneExplosionTimer < diff) { DoCast(me->getVictim(), SPELL_ARCANE_EXPLOSION); - arcaneExplosionTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); + arcaneExplosionTimer = urand(5 * IN_MILLISECONDS, 15 * IN_MILLISECONDS); } else arcaneExplosionTimer -= diff; if (coneOfColdTimer < diff) { DoCast(me->getVictim(), SPELL_CONE_OF_COLD); - coneOfColdTimer = urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS); + coneOfColdTimer = urand(10 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); } else coneOfColdTimer -= diff; if (fireBoltTimer < diff) { DoCast(me->getVictim(), SPELL_FIREBALL); - fireBoltTimer = urand(5*IN_MILLISECONDS, 9*IN_MILLISECONDS); + fireBoltTimer = urand(5 * IN_MILLISECONDS, 9 * IN_MILLISECONDS); } else fireBoltTimer -= diff; if (frostboltTimer < diff) { DoCast(me->getVictim(), SPELL_FROSTBOLT); - frostboltTimer = urand(4*IN_MILLISECONDS, 12*IN_MILLISECONDS); + frostboltTimer = urand(4 * IN_MILLISECONDS, 12 * IN_MILLISECONDS); } else frostboltTimer -= diff; // check if creature is not outside of building @@ -187,7 +187,7 @@ public: EnterEvadeMode(); DoScriptText(YELL_EVADE, me); } - resetTimer = 5*IN_MILLISECONDS; + resetTimer = 5 * IN_MILLISECONDS; } else resetTimer -= diff; DoMeleeAttackIfReady(); diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/boss_drekthar.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/boss_drekthar.cpp index e7a7b1a01ba..c72014b96d7 100644 --- a/src/server/scripts/EasternKingdoms/AlteracValley/boss_drekthar.cpp +++ b/src/server/scripts/EasternKingdoms/AlteracValley/boss_drekthar.cpp @@ -48,23 +48,23 @@ public: struct boss_drektharAI : public ScriptedAI { - boss_drektharAI(Creature* c) : ScriptedAI(c) {} + boss_drektharAI(Creature* creature) : ScriptedAI(creature) {} - uint32 uiWhirlwindTimer; - uint32 uiWhirlwind2Timer; - uint32 uiKnockdownTimer; - uint32 uiFrenzyTimer; - uint32 uiYellTimer; - uint32 uiResetTimer; + uint32 WhirlwindTimer; + uint32 Whirlwind2Timer; + uint32 KnockdownTimer; + uint32 FrenzyTimer; + uint32 YellTimer; + uint32 ResetTimer; void Reset() { - uiWhirlwindTimer = urand(1*IN_MILLISECONDS, 20*IN_MILLISECONDS); - uiWhirlwind2Timer = urand(1*IN_MILLISECONDS, 20*IN_MILLISECONDS); - uiKnockdownTimer = 12*IN_MILLISECONDS; - uiFrenzyTimer = 6*IN_MILLISECONDS; - uiResetTimer = 5*IN_MILLISECONDS; - uiYellTimer = urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS); //20 to 30 seconds + WhirlwindTimer = urand(1 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); + Whirlwind2Timer = urand(1 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); + KnockdownTimer = 12 * IN_MILLISECONDS; + FrenzyTimer = 6 * IN_MILLISECONDS; + ResetTimer = 5 * IN_MILLISECONDS; + YellTimer = urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS); //20 to 30 seconds } void EnterCombat(Unit* /*who*/) @@ -83,46 +83,46 @@ public: if (!UpdateVictim()) return; - if (uiWhirlwindTimer <= diff) + if (WhirlwindTimer <= diff) { DoCast(me->getVictim(), SPELL_WHIRLWIND); - uiWhirlwindTimer = urand(8*IN_MILLISECONDS, 18*IN_MILLISECONDS); - } else uiWhirlwindTimer -= diff; + WhirlwindTimer = urand(8 * IN_MILLISECONDS, 18 * IN_MILLISECONDS); + } else WhirlwindTimer -= diff; - if (uiWhirlwind2Timer <= diff) + if (Whirlwind2Timer <= diff) { DoCast(me->getVictim(), SPELL_WHIRLWIND2); - uiWhirlwind2Timer = urand(7*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else uiWhirlwind2Timer -= diff; + Whirlwind2Timer = urand(7 * IN_MILLISECONDS, 25 * IN_MILLISECONDS); + } else Whirlwind2Timer -= diff; - if (uiKnockdownTimer <= diff) + if (KnockdownTimer <= diff) { DoCast(me->getVictim(), SPELL_KNOCKDOWN); - uiKnockdownTimer = urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else uiKnockdownTimer -= diff; + KnockdownTimer = urand(10 * IN_MILLISECONDS, 15 * IN_MILLISECONDS); + } else KnockdownTimer -= diff; - if (uiFrenzyTimer <= diff) + if (FrenzyTimer <= diff) { DoCast(me->getVictim(), SPELL_FRENZY); - uiFrenzyTimer = urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else uiFrenzyTimer -= diff; + FrenzyTimer = urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS); + } else FrenzyTimer -= diff; - if (uiYellTimer <= diff) + if (YellTimer <= diff) { DoScriptText(RAND(YELL_RANDOM1, YELL_RANDOM2, YELL_RANDOM3, YELL_RANDOM4, YELL_RANDOM5), me); - uiYellTimer = urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS); //20 to 30 seconds - } else uiYellTimer -= diff; + YellTimer = urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS); //20 to 30 seconds + } else YellTimer -= diff; // check if creature is not outside of building - if (uiResetTimer <= diff) + if (ResetTimer <= diff) { if (me->GetDistance2d(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY()) > 50) { EnterEvadeMode(); DoScriptText(YELL_EVADE, me); } - uiResetTimer = 5*IN_MILLISECONDS; - } else uiResetTimer -= diff; + ResetTimer = 5 * IN_MILLISECONDS; + } else ResetTimer -= diff; DoMeleeAttackIfReady(); } diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/boss_galvangar.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/boss_galvangar.cpp index 40d1ca2fe68..2b338833f4b 100644 --- a/src/server/scripts/EasternKingdoms/AlteracValley/boss_galvangar.cpp +++ b/src/server/scripts/EasternKingdoms/AlteracValley/boss_galvangar.cpp @@ -39,23 +39,23 @@ public: struct boss_galvangarAI : public ScriptedAI { - boss_galvangarAI(Creature* c) : ScriptedAI(c) {} + boss_galvangarAI(Creature* creature) : ScriptedAI(creature) {} - uint32 uiCleaveTimer; - uint32 uiFrighteningShoutTimer; - uint32 uiWhirlwind1Timer; - uint32 uiWhirlwind2Timer; - uint32 uiMortalStrikeTimer; - uint32 uiResetTimer; + uint32 CleaveTimer; + uint32 FrighteningShoutTimer; + uint32 Whirlwind1Timer; + uint32 Whirlwind2Timer; + uint32 MortalStrikeTimer; + uint32 ResetTimer; void Reset() { - uiCleaveTimer = urand(1*IN_MILLISECONDS, 9*IN_MILLISECONDS); - uiFrighteningShoutTimer = urand(2*IN_MILLISECONDS, 19*IN_MILLISECONDS); - uiWhirlwind1Timer = urand(1*IN_MILLISECONDS, 13*IN_MILLISECONDS); - uiWhirlwind2Timer = urand(5*IN_MILLISECONDS, 20*IN_MILLISECONDS); - uiMortalStrikeTimer = urand(5*IN_MILLISECONDS, 20*IN_MILLISECONDS); - uiResetTimer = 5*IN_MILLISECONDS; + CleaveTimer = urand(1 * IN_MILLISECONDS, 9 * IN_MILLISECONDS); + FrighteningShoutTimer = urand(2 * IN_MILLISECONDS, 19 * IN_MILLISECONDS); + Whirlwind1Timer = urand(1 * IN_MILLISECONDS, 13 * IN_MILLISECONDS); + Whirlwind2Timer = urand(5 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); + MortalStrikeTimer = urand(5 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); + ResetTimer = 5 * IN_MILLISECONDS; } void EnterCombat(Unit* /*who*/) @@ -73,46 +73,46 @@ public: if (!UpdateVictim()) return; - if (uiCleaveTimer <= diff) + if (CleaveTimer <= diff) { DoCast(me->getVictim(), SPELL_CLEAVE); - uiCleaveTimer = urand(10*IN_MILLISECONDS, 16*IN_MILLISECONDS); - } else uiCleaveTimer -= diff; + CleaveTimer = urand(10 * IN_MILLISECONDS, 16 * IN_MILLISECONDS); + } else CleaveTimer -= diff; - if (uiFrighteningShoutTimer <= diff) + if (FrighteningShoutTimer <= diff) { DoCast(me->getVictim(), SPELL_FRIGHTENING_SHOUT); - uiFrighteningShoutTimer = urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else uiFrighteningShoutTimer -= diff; + FrighteningShoutTimer = urand(10 * IN_MILLISECONDS, 15 * IN_MILLISECONDS); + } else FrighteningShoutTimer -= diff; - if (uiWhirlwind1Timer <= diff) + if (Whirlwind1Timer <= diff) { DoCast(me->getVictim(), SPELL_WHIRLWIND1); - uiWhirlwind1Timer = urand(6*IN_MILLISECONDS, 10*IN_MILLISECONDS); - } else uiWhirlwind1Timer -= diff; + Whirlwind1Timer = urand(6 * IN_MILLISECONDS, 10 * IN_MILLISECONDS); + } else Whirlwind1Timer -= diff; - if (uiWhirlwind2Timer <= diff) + if (Whirlwind2Timer <= diff) { DoCast(me->getVictim(), SPELL_WHIRLWIND2); - uiWhirlwind2Timer = urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else uiWhirlwind2Timer -= diff; + Whirlwind2Timer = urand(10 * IN_MILLISECONDS, 25 * IN_MILLISECONDS); + } else Whirlwind2Timer -= diff; - if (uiMortalStrikeTimer <= diff) + if (MortalStrikeTimer <= diff) { DoCast(me->getVictim(), SPELL_MORTAL_STRIKE); - uiMortalStrikeTimer = urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else uiMortalStrikeTimer -= diff; + MortalStrikeTimer = urand(10 * IN_MILLISECONDS, 30 * IN_MILLISECONDS); + } else MortalStrikeTimer -= diff; // check if creature is not outside of building - if (uiResetTimer <= diff) + if (ResetTimer <= diff) { if (me->GetDistance2d(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY()) > 50) { EnterEvadeMode(); DoScriptText(YELL_EVADE, me); } - uiResetTimer = 5*IN_MILLISECONDS; - } else uiResetTimer -= diff; + ResetTimer = 5 * IN_MILLISECONDS; + } else ResetTimer -= diff; DoMeleeAttackIfReady(); } diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp index 973e7ca5f64..c933757c14a 100644 --- a/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp +++ b/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp @@ -46,21 +46,21 @@ public: struct boss_vanndarAI : public ScriptedAI { - boss_vanndarAI(Creature* c) : ScriptedAI(c) {} + boss_vanndarAI(Creature* creature) : ScriptedAI(creature) {} - uint32 uiAvatarTimer; - uint32 uiThunderclapTimer; - uint32 uiStormboltTimer; - uint32 uiResetTimer; - uint32 uiYellTimer; + uint32 AvatarTimer; + uint32 ThunderclapTimer; + uint32 StormboltTimer; + uint32 ResetTimer; + uint32 YellTimer; void Reset() { - uiAvatarTimer = 3*IN_MILLISECONDS; - uiThunderclapTimer = 4*IN_MILLISECONDS; - uiStormboltTimer = 6*IN_MILLISECONDS; - uiResetTimer = 5*IN_MILLISECONDS; - uiYellTimer = urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS); + AvatarTimer = 3 * IN_MILLISECONDS; + ThunderclapTimer = 4 * IN_MILLISECONDS; + StormboltTimer = 6 * IN_MILLISECONDS; + ResetTimer = 5 * IN_MILLISECONDS; + YellTimer = urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS); } void EnterCombat(Unit* /*who*/) @@ -79,40 +79,40 @@ public: if (!UpdateVictim()) return; - if (uiAvatarTimer <= diff) + if (AvatarTimer <= diff) { DoCast(me->getVictim(), SPELL_AVATAR); - uiAvatarTimer = urand(15*IN_MILLISECONDS, 20*IN_MILLISECONDS); - } else uiAvatarTimer -= diff; + AvatarTimer = urand(15 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); + } else AvatarTimer -= diff; - if (uiThunderclapTimer <= diff) + if (ThunderclapTimer <= diff) { DoCast(me->getVictim(), SPELL_THUNDERCLAP); - uiThunderclapTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else uiThunderclapTimer -= diff; + ThunderclapTimer = urand(5 * IN_MILLISECONDS, 15 * IN_MILLISECONDS); + } else ThunderclapTimer -= diff; - if (uiStormboltTimer <= diff) + if (StormboltTimer <= diff) { DoCast(me->getVictim(), SPELL_STORMBOLT); - uiStormboltTimer = urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else uiStormboltTimer -= diff; + StormboltTimer = urand(10 * IN_MILLISECONDS, 25 * IN_MILLISECONDS); + } else StormboltTimer -= diff; - if (uiYellTimer <= diff) + if (YellTimer <= diff) { DoScriptText(RAND(YELL_RANDOM1, YELL_RANDOM2, YELL_RANDOM3, YELL_RANDOM4, YELL_RANDOM5, YELL_RANDOM6, YELL_RANDOM7), me); - uiYellTimer = urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS); //20 to 30 seconds - } else uiYellTimer -= diff; + YellTimer = urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS); //20 to 30 seconds + } else YellTimer -= diff; // check if creature is not outside of building - if (uiResetTimer <= diff) + if (ResetTimer <= diff) { if (me->GetDistance2d(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY()) > 50) { EnterEvadeMode(); DoScriptText(YELL_EVADE, me); } - uiResetTimer = 5*IN_MILLISECONDS; - } else uiResetTimer -= diff; + ResetTimer = 5 * IN_MILLISECONDS; + } else ResetTimer -= diff; DoMeleeAttackIfReady(); } diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp index f205d1d7932..36a91ab3d51 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp @@ -15,35 +15,11 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Blackrock_Depths -SD%Complete: 95 -SDComment: Quest support: 4001, 4342, 7604, 4322. Vendor Lokhtos Darkbargainer. Need to rewrite the Jail Break support -SDCategory: Blackrock Depths -EndScriptData */ - -/* ContentData -go_shadowforge_brazier -at_ring_of_law -npc_grimstone -mob_phalanx -npc_kharan_mighthammer -npc_lokhtos_darkbargainer -npc_dughal_stormwing -npc_marshal_windsor -npc_marshal_reginald_windsor -npc_tobias_seecher -npc_rocknot -EndContentData */ - #include "ScriptPCH.h" #include "ScriptedEscortAI.h" #include "blackrock_depths.h" -/*###### -+## go_shadowforge_brazier -+######*/ - +//go_shadowforge_brazier class go_shadowforge_brazier : public GameObjectScript { public: @@ -65,13 +41,9 @@ public: } return false; } - }; -/*###### -## npc_grimstone -######*/ - +// npc_grimstone enum eGrimstone { NPC_GRIMSTONE = 10096, @@ -120,21 +92,17 @@ public: } return false; } - }; -/*###### -## npc_grimstone -######*/ - +// npc_grimstone enum GrimstoneTexts { - SCRIPT_TEXT1 = -1230003, - SCRIPT_TEXT2 = -1230004, - SCRIPT_TEXT3 = -1230005, - SCRIPT_TEXT4 = -1230006, - SCRIPT_TEXT5 = -1230007, - SCRIPT_TEXT6 = -1230008 + SCRIPT_TEXT1 = -1230003, + SCRIPT_TEXT2 = -1230004, + SCRIPT_TEXT3 = -1230005, + SCRIPT_TEXT4 = -1230006, + SCRIPT_TEXT5 = -1230007, + SCRIPT_TEXT6 = -1230008 }; //TODO: implement quest part of event (different end boss) @@ -150,19 +118,19 @@ public: struct npc_grimstoneAI : public npc_escortAI { - npc_grimstoneAI(Creature* c) : npc_escortAI(c) + npc_grimstoneAI(Creature* creature) : npc_escortAI(creature) { - instance = c->GetInstanceScript(); + instance = creature->GetInstanceScript(); MobSpawnId = rand()%6; } InstanceScript* instance; - uint8 EventPhase; + uint8 EventPhase; uint32 Event_Timer; - uint8 MobSpawnId; - uint8 MobCount; + uint8 MobSpawnId; + uint8 MobCount; uint32 MobDeath_Timer; uint64 RingMobGUID[4]; @@ -174,16 +142,16 @@ public: { me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - EventPhase = 0; - Event_Timer = 1000; + EventPhase = 0; + Event_Timer = 1000; - MobCount = 0; - MobDeath_Timer = 0; + MobCount = 0; + MobDeath_Timer = 0; for (uint8 i = 0; i < MAX_MOB_AMOUNT; ++i) RingMobGUID[i] = 0; - RingBossGUID = 0; + RingBossGUID = 0; CanWalk = false; } @@ -215,24 +183,24 @@ public: { case 0: DoScriptText(SCRIPT_TEXT1, me);//2 - CanWalk = false; - Event_Timer = 5000; + CanWalk = false; + Event_Timer = 5000; break; case 1: DoScriptText(SCRIPT_TEXT2, me);//4 - CanWalk = false; - Event_Timer = 5000; + CanWalk = false; + Event_Timer = 5000; break; case 2: - CanWalk = false; + CanWalk = false; break; case 3: DoScriptText(SCRIPT_TEXT3, me);//5 break; case 4: DoScriptText(SCRIPT_TEXT4, me);//6 - CanWalk = false; - Event_Timer = 5000; + CanWalk = false; + Event_Timer = 5000; break; case 5: if (instance) @@ -259,16 +227,16 @@ public: { if (MobDeath_Timer <= diff) { - MobDeath_Timer = 2500; + MobDeath_Timer = 2500; if (RingBossGUID) { Creature* boss = Unit::GetCreature(*me, RingBossGUID); if (boss && !boss->isAlive() && boss->isDead()) { - RingBossGUID = 0; - Event_Timer = 5000; - MobDeath_Timer = 0; + RingBossGUID = 0; + Event_Timer = 5000; + MobDeath_Timer = 0; return; } return; @@ -279,7 +247,7 @@ public: Creature* mob = Unit::GetCreature(*me, RingMobGUID[i]); if (mob && !mob->isAlive() && mob->isDead()) { - RingMobGUID[i] = 0; + RingMobGUID[i] = 0; --MobCount; //seems all are gone, so set timer to continue and discontinue this @@ -365,18 +333,14 @@ public: npc_escortAI::UpdateAI(diff); } }; - }; -/*###### -## mob_phalanx -######*/ - +// mob_phalanx enum PhalanxSpells { - SPELL_THUNDERCLAP = 8732, - SPELL_FIREBALLVOLLEY = 22425, - SPELL_MIGHTYBLOW = 14099 + SPELL_THUNDERCLAP = 8732, + SPELL_FIREBALLVOLLEY = 22425, + SPELL_MIGHTYBLOW = 14099 }; class mob_phalanx : public CreatureScript @@ -399,9 +363,9 @@ public: void Reset() { - ThunderClap_Timer = 12000; - FireballVolley_Timer =0; - MightyBlow_Timer = 15000; + ThunderClap_Timer = 12000; + FireballVolley_Timer = 0; + MightyBlow_Timer = 15000; } void UpdateAI(const uint32 diff) @@ -437,22 +401,17 @@ public: DoMeleeAttackIfReady(); } }; - }; -/*###### -## npc_kharan_mighthammer -######*/ - +// npc_kharan_mighthammer enum KharamQuests { - QUEST_4001 = 4001, - QUEST_4342 = 4342 + QUEST_4001 = 4001, + QUEST_4342 = 4342 }; #define GOSSIP_ITEM_KHARAN_1 "I need to know where the princess are, Kharan!" #define GOSSIP_ITEM_KHARAN_2 "All is not lost, Kharan!" - #define GOSSIP_ITEM_KHARAN_3 "Gor'shak is my friend, you can trust me." #define GOSSIP_ITEM_KHARAN_4 "Not enough, you need to tell me more." #define GOSSIP_ITEM_KHARAN_5 "So what happened?" @@ -467,13 +426,13 @@ class npc_kharan_mighthammer : public CreatureScript public: npc_kharan_mighthammer() : CreatureScript("npc_kharan_mighthammer") { } - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction) + bool OnGossipSelect(Player* player, Creature* creature, uint32 /*Sender*/, uint32 action) { player->PlayerTalkClass->ClearMenus(); - switch (uiAction) + switch (action) { case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_KHARAN_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_KHARAN_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); player->SEND_GOSSIP_MENU(2475, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+2: @@ -534,13 +493,9 @@ public: return true; } - }; -/*###### -## npc_lokhtos_darkbargainer -######*/ - +// npc_lokhtos_darkbargainer enum LokhtosItems { ITEM_THRORIUM_BROTHERHOOD_CONTRACT = 18628, @@ -565,15 +520,15 @@ class npc_lokhtos_darkbargainer : public CreatureScript public: npc_lokhtos_darkbargainer() : CreatureScript("npc_lokhtos_darkbargainer") { } - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction) + bool OnGossipSelect(Player* player, Creature* creature, uint32 /*Sender*/, uint32 action) { player->PlayerTalkClass->ClearMenus(); - if (uiAction == GOSSIP_ACTION_INFO_DEF + 1) + if (action == GOSSIP_ACTION_INFO_DEF + 1) { player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, SPELL_CREATE_THORIUM_BROTHERHOOD_CONTRACT_DND, false); } - if (uiAction == GOSSIP_ACTION_TRADE) + if (action == GOSSIP_ACTION_TRADE) player->GetSession()->SendListInventory(creature->GetGUID()); return true; @@ -601,18 +556,15 @@ public: return true; } - }; -/*###### -## npc_dughal_stormwing -######*/ - +// npc_dughal_stormwing enum DughalQuests { - QUEST_JAIL_BREAK = 4322 + QUEST_JAIL_BREAK = 4322 }; +// DELETE THIS IF IT IS NOT NEEDED! #define SAY_DUGHAL_FREE "Thank you, $N! I'm free!!!" #define GOSSIP_DUGHAL "You're free, Dughal! Get out of here!" @@ -633,10 +585,10 @@ public: return dughal_stormwingAI; } - bool OnGossipSelect(Player* player, Creature* creature, uint32 uiSender, uint32 uiAction) + bool OnGossipSelect(Player* player, Creature* creature, uint32 Sender, uint32 action) { player->PlayerTalkClass->ClearMenus(); - if (uiAction == GOSSIP_ACTION_INFO_DEF + 1) + if (action == GOSSIP_ACTION_INFO_DEF + 1) { player->CLOSE_GOSSIP_MENU(); CAST_AI(npc_escort::npc_escortAI, (creature->AI()))->Start(false, true, player->GetGUID()); @@ -707,14 +659,11 @@ public: npc_escortAI::UpdateAI(diff); } }; - }; */ -/*###### -## npc_marshal_windsor -######*/ +// npc_marshal_windsor #define SAY_WINDSOR_AGGRO1 "You locked up the wrong Marshal. Prepare to be destroyed!" #define SAY_WINDSOR_AGGRO2 "I bet you're sorry now, aren't you !?!!" #define SAY_WINDSOR_AGGRO3 "You better hold me back $N or they are going to feel some prison house beatings." @@ -771,7 +720,6 @@ public: instance->SetData(DATA_QUEST_JAIL_BREAK, ENCOUNTER_STATE_IN_PROGRESS); creature->setFaction(11); } - } return false; } @@ -875,14 +823,11 @@ public: npc_escortAI::UpdateAI(diff); } }; - }; */ -/*###### -## npc_marshal_reginald_windsor -######*/ +// npc_marshal_reginald_windsor #define SAY_REGINALD_WINDSOR_0_1 "Can you feel the power, $N??? It's time to ROCK!" #define SAY_REGINALD_WINDSOR_0_2 "Now we just have to free Tobias and we can get out of here. This way!" #define SAY_REGINALD_WINDSOR_5_1 "Open it." @@ -1096,13 +1041,10 @@ public: npc_escortAI::UpdateAI(diff); } }; - }; */ -/*###### -## npc_tobias_seecher -######*/ +// npc_tobias_seecher #define SAY_TOBIAS_FREE "Thank you! I will run for safety immediately!" /* class npc_tobias_seecher : public CreatureScript @@ -1123,10 +1065,10 @@ public: return tobias_seecherAI; } - bool OnGossipSelect(Player* player, Creature* creature, uint32 uiSender, uint32 uiAction) + bool OnGossipSelect(Player* player, Creature* creature, uint32 Sender, uint32 action) { player->PlayerTalkClass->ClearMenus(); - if (uiAction == GOSSIP_ACTION_INFO_DEF + 1) + if (action == GOSSIP_ACTION_INFO_DEF + 1) { player->CLOSE_GOSSIP_MENU(); CAST_AI(npc_escort::npc_escortAI, (creature->AI()))->Start(false, true, player->GetGUID()); @@ -1198,28 +1140,24 @@ public: npc_escortAI::UpdateAI(diff); } }; - }; */ -/*###### -## npc_rocknot -######*/ - +// npc_rocknot enum RocknotSays { - SAY_GOT_BEER = -1230000 + SAY_GOT_BEER = -1230000 }; enum RocknotSpells { - SPELL_DRUNKEN_RAGE = 14872 + SPELL_DRUNKEN_RAGE = 14872 }; enum RocknotQuests { - QUEST_ALE = 4295 + QUEST_ALE = 4295 }; class npc_rocknot : public CreatureScript @@ -1248,6 +1186,7 @@ public: { DoScriptText(SAY_GOT_BEER, creature); creature->CastSpell(creature, SPELL_DRUNKEN_RAGE, false); + if (npc_escortAI* escortAI = CAST_AI(npc_rocknot::npc_rocknotAI, creature->AI())) escortAI->Start(false, false); } @@ -1263,9 +1202,9 @@ public: struct npc_rocknotAI : public npc_escortAI { - npc_rocknotAI(Creature* c) : npc_escortAI(c) + npc_rocknotAI(Creature* creature) : npc_escortAI(creature) { - instance = c->GetInstanceScript(); + instance = creature->GetInstanceScript(); } InstanceScript* instance; @@ -1278,8 +1217,8 @@ public: if (HasEscortState(STATE_ESCORT_ESCORTING)) return; - BreakKeg_Timer = 0; - BreakDoor_Timer = 0; + BreakKeg_Timer = 0; + BreakDoor_Timer = 0; } void DoGo(uint32 id, uint32 state) @@ -1324,8 +1263,8 @@ public: if (BreakKeg_Timer <= diff) { DoGo(DATA_GO_BAR_KEG, 0); - BreakKeg_Timer = 0; - BreakDoor_Timer = 1000; + BreakKeg_Timer = 0; + BreakDoor_Timer = 1000; } else BreakKeg_Timer -= diff; } @@ -1351,13 +1290,8 @@ public: npc_escortAI::UpdateAI(diff); } }; - }; -/*###### -## -######*/ - void AddSC_blackrock_depths() { new go_shadowforge_brazier(); @@ -1366,9 +1300,11 @@ void AddSC_blackrock_depths() new mob_phalanx(); new npc_kharan_mighthammer(); new npc_lokhtos_darkbargainer(); - //new npc_dughal_stormwing(); - //new npc_tobias_seecher(); - //new npc_marshal_windsor(); - //new npc_marshal_reginald_windsor(); new npc_rocknot(); + // Fix us + /*new npc_dughal_stormwing(); + new npc_tobias_seecher(); + new npc_marshal_windsor(); + new npc_marshal_reginald_windsor(); + */ } diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_ambassador_flamelash.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_ambassador_flamelash.cpp index ad663415cbe..86bd0a0b393 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_ambassador_flamelash.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_ambassador_flamelash.cpp @@ -16,13 +16,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Boss_Ambassador_Flamelash -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - #include "ScriptPCH.h" enum Spells @@ -42,15 +35,15 @@ public: struct boss_ambassador_flamelashAI : public ScriptedAI { - boss_ambassador_flamelashAI(Creature* c) : ScriptedAI(c) {} + boss_ambassador_flamelashAI(Creature* creature) : ScriptedAI(creature) {} uint32 FireBlast_Timer; uint32 Spirit_Timer; void Reset() { - FireBlast_Timer = 2000; - Spirit_Timer = 24000; + FireBlast_Timer = 2000; + Spirit_Timer = 24000; } void EnterCombat(Unit* /*who*/) {} @@ -88,7 +81,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_ambassador_flamelash() diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_anubshiah.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_anubshiah.cpp index 1edb5d99463..3d37d1885da 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_anubshiah.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_anubshiah.cpp @@ -16,13 +16,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Boss_Anubshiah -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - #include "ScriptPCH.h" enum Spells @@ -46,7 +39,7 @@ public: struct boss_anubshiahAI : public ScriptedAI { - boss_anubshiahAI(Creature* c) : ScriptedAI(c) {} + boss_anubshiahAI(Creature* creature) : ScriptedAI(creature) {} uint32 ShadowBolt_Timer; uint32 CurseOfTongues_Timer; @@ -56,16 +49,14 @@ public: void Reset() { - ShadowBolt_Timer = 7000; - CurseOfTongues_Timer = 24000; - CurseOfWeakness_Timer = 12000; - DemonArmor_Timer = 3000; - EnvelopingWeb_Timer = 16000; + ShadowBolt_Timer = 7000; + CurseOfTongues_Timer = 24000; + CurseOfWeakness_Timer = 12000; + DemonArmor_Timer = 3000; + EnvelopingWeb_Timer = 16000; } - void EnterCombat(Unit* /*who*/) - { - } + void EnterCombat(Unit* /*who*/) {} void UpdateAI(const uint32 diff) { @@ -113,7 +104,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_anubshiah() diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp index 1d9878a331a..deda95ff454 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp @@ -16,13 +16,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Boss_Emperor_Dagran_Thaurissan -SD%Complete: 99 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - #include "ScriptPCH.h" #include "blackrock_depths.h" @@ -50,7 +43,7 @@ public: struct boss_draganthaurissanAI : public ScriptedAI { - boss_draganthaurissanAI(Creature* c) : ScriptedAI(c) + boss_draganthaurissanAI(Creature* creature) : ScriptedAI(creature) { instance = me->GetInstanceScript(); } @@ -62,9 +55,9 @@ public: void Reset() { - HandOfThaurissan_Timer = 4000; - AvatarOfFlame_Timer = 25000; - //Counter= 0; + HandOfThaurissan_Timer = 4000; + AvatarOfFlame_Timer = 25000; + //Counter = 0; } void EnterCombat(Unit* /*who*/) @@ -107,7 +100,7 @@ public: //else //{ HandOfThaurissan_Timer = 5000; - //Counter = 0; + //Counter = 0; //} } else HandOfThaurissan_Timer -= diff; @@ -121,7 +114,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_draganthaurissan() diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_general_angerforge.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_general_angerforge.cpp index 9b290b2e352..d402e70d671 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_general_angerforge.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_general_angerforge.cpp @@ -16,13 +16,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Boss_General_Angerforge -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - #include "ScriptPCH.h" enum Spells @@ -44,7 +37,7 @@ public: struct boss_general_angerforgeAI : public ScriptedAI { - boss_general_angerforgeAI(Creature* c) : ScriptedAI(c) {} + boss_general_angerforgeAI(Creature* creature) : ScriptedAI(creature) {} uint32 MightyBlow_Timer; uint32 HamString_Timer; @@ -54,16 +47,14 @@ public: void Reset() { - MightyBlow_Timer = 8000; - HamString_Timer = 12000; - Cleave_Timer = 16000; - Adds_Timer = 0; - Medics = false; + MightyBlow_Timer = 8000; + HamString_Timer = 12000; + Cleave_Timer = 16000; + Adds_Timer = 0; + Medics = false; } - void EnterCombat(Unit* /*who*/) - { - } + void EnterCombat(Unit* /*who*/) {} void SummonAdds(Unit* victim) { @@ -129,7 +120,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_general_angerforge() diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_gorosh_the_dervish.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_gorosh_the_dervish.cpp index c82c5f82965..1055e20bddd 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_gorosh_the_dervish.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_gorosh_the_dervish.cpp @@ -16,13 +16,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Boss_Gorosh_the_Dervish -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - #include "ScriptPCH.h" enum Spells @@ -43,15 +36,15 @@ public: struct boss_gorosh_the_dervishAI : public ScriptedAI { - boss_gorosh_the_dervishAI(Creature* c) : ScriptedAI(c) {} + boss_gorosh_the_dervishAI(Creature* creature) : ScriptedAI(creature) {} uint32 WhirlWind_Timer; uint32 MortalStrike_Timer; void Reset() { - WhirlWind_Timer = 12000; - MortalStrike_Timer = 22000; + WhirlWind_Timer = 12000; + MortalStrike_Timer = 22000; } void EnterCombat(Unit* /*who*/) @@ -81,7 +74,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_gorosh_the_dervish() diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_grizzle.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_grizzle.cpp index e8b794a2edb..df850a276b7 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_grizzle.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_grizzle.cpp @@ -16,13 +16,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Boss_Grizzle -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - #include "ScriptPCH.h" enum Spells @@ -43,20 +36,18 @@ public: struct boss_grizzleAI : public ScriptedAI { - boss_grizzleAI(Creature* c) : ScriptedAI(c) {} + boss_grizzleAI(Creature* creature) : ScriptedAI(creature) {} uint32 GroundTremor_Timer; uint32 Frenzy_Timer; void Reset() { - GroundTremor_Timer = 12000; - Frenzy_Timer =0; + GroundTremor_Timer = 12000; + Frenzy_Timer = 0; } - void EnterCombat(Unit* /*who*/) - { - } + void EnterCombat(Unit* /*who*/) {} void UpdateAI(const uint32 diff) { @@ -86,7 +77,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_grizzle() diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_high_interrogator_gerstahn.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_high_interrogator_gerstahn.cpp index 5b7ce8bd760..28e8b47f680 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_high_interrogator_gerstahn.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_high_interrogator_gerstahn.cpp @@ -16,13 +16,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Boss_High_Interrogator_Gerstahn -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - #include "ScriptPCH.h" enum Spells @@ -45,7 +38,7 @@ public: struct boss_high_interrogator_gerstahnAI : public ScriptedAI { - boss_high_interrogator_gerstahnAI(Creature* c) : ScriptedAI(c) {} + boss_high_interrogator_gerstahnAI(Creature* creature) : ScriptedAI(creature) {} uint32 ShadowWordPain_Timer; uint32 ManaBurn_Timer; @@ -54,15 +47,13 @@ public: void Reset() { - ShadowWordPain_Timer = 4000; - ManaBurn_Timer = 14000; - PsychicScream_Timer = 32000; - ShadowShield_Timer = 8000; + ShadowWordPain_Timer = 4000; + ManaBurn_Timer = 14000; + PsychicScream_Timer = 32000; + ShadowShield_Timer = 8000; } - void EnterCombat(Unit* /*who*/) - { - } + void EnterCombat(Unit* /*who*/) {} void UpdateAI(const uint32 diff) { @@ -103,7 +94,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_high_interrogator_gerstahn() diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_magmus.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_magmus.cpp index 4c6bbf33e59..0f767f7bc23 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_magmus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_magmus.cpp @@ -16,13 +16,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Boss_Magmus -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - #include "ScriptPCH.h" enum Spells @@ -33,7 +26,7 @@ enum Spells enum eEnums { - DATA_THRONE_DOOR = 24 // not id or guid of doors but number of enum in blackrock_depths.h + DATA_THRONE_DOOR = 24 // not id or guid of doors but number of enum in blackrock_depths.h }; class boss_magmus : public CreatureScript @@ -48,20 +41,18 @@ public: struct boss_magmusAI : public ScriptedAI { - boss_magmusAI(Creature* c) : ScriptedAI(c) {} + boss_magmusAI(Creature* creature) : ScriptedAI(creature) {} uint32 FieryBurst_Timer; uint32 WarStomp_Timer; void Reset() { - FieryBurst_Timer = 5000; - WarStomp_Timer =0; + FieryBurst_Timer = 5000; + WarStomp_Timer = 0; } - void EnterCombat(Unit* /*who*/) - { - } + void EnterCombat(Unit* /*who*/) {} void UpdateAI(const uint32 diff) { @@ -95,7 +86,6 @@ public: instance->HandleGameObject(instance->GetData64(DATA_THRONE_DOOR), true); } }; - }; void AddSC_boss_magmus() diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_moira_bronzebeard.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_moira_bronzebeard.cpp index ac05f8d86bb..6c10a4a7cce 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_moira_bronzebeard.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_moira_bronzebeard.cpp @@ -16,13 +16,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Boss_Moira_Bronzbeard -SD%Complete: 90 -SDComment: Healing of Emperor NYI -SDCategory: Blackrock Depths -EndScriptData */ - #include "ScriptPCH.h" enum Spells @@ -47,7 +40,7 @@ public: struct boss_moira_bronzebeardAI : public ScriptedAI { - boss_moira_bronzebeardAI(Creature* c) : ScriptedAI(c) {} + boss_moira_bronzebeardAI(Creature* creature) : ScriptedAI(creature) {} uint32 Heal_Timer; uint32 MindBlast_Timer; @@ -56,15 +49,13 @@ public: void Reset() { - Heal_Timer = 12000; //These times are probably wrong - MindBlast_Timer = 16000; - ShadowWordPain_Timer = 2000; - Smite_Timer = 8000; + Heal_Timer = 12000; // These times are probably wrong + MindBlast_Timer = 16000; + ShadowWordPain_Timer = 2000; + Smite_Timer = 8000; } - void EnterCombat(Unit* /*who*/) - { - } + void EnterCombat(Unit* /*who*/) {} void UpdateAI(const uint32 diff) { @@ -92,10 +83,8 @@ public: DoCast(me->getVictim(), SPELL_SMITE); Smite_Timer = 10000; } else Smite_Timer -= diff; - } }; - }; void AddSC_boss_moira_bronzebeard() diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_tomb_of_seven.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_tomb_of_seven.cpp index aecb3445b01..2fa19405153 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_tomb_of_seven.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_tomb_of_seven.cpp @@ -16,30 +16,23 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Boss_Tomb_Of_Seven -SD%Complete: 90 -SDComment: Learning Smelt Dark Iron if tribute quest rewarded. Missing event. -SDCategory: Blackrock Depths -EndScriptData */ - #include "ScriptPCH.h" #include "blackrock_depths.h" enum Spells { - SPELL_SMELT_DARK_IRON = 14891, - SPELL_LEARN_SMELT = 14894, + SPELL_SMELT_DARK_IRON = 14891, + SPELL_LEARN_SMELT = 14894, }; enum Quests { - QUEST_SPECTRAL_CHALICE = 4083 + QUEST_SPECTRAL_CHALICE = 4083 }; enum Misc { - DATA_SKILLPOINT_MIN = 230 + DATA_SKILLPOINT_MIN = 230 }; #define GOSSIP_ITEM_TEACH_1 "Teach me the art of smelting dark iron" @@ -52,10 +45,10 @@ class boss_gloomrel : public CreatureScript public: boss_gloomrel() : CreatureScript("boss_gloomrel") { } - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction) + bool OnGossipSelect(Player* player, Creature* creature, uint32 /*Sender*/, uint32 action) { player->PlayerTalkClass->ClearMenus(); - switch (uiAction) + switch (action) { case GOSSIP_ACTION_INFO_DEF+1: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TEACH_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); @@ -92,7 +85,6 @@ public: player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); return true; } - }; enum DoomrelSpells @@ -112,10 +104,10 @@ class boss_doomrel : public CreatureScript public: boss_doomrel() : CreatureScript("boss_doomrel") { } - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction) + bool OnGossipSelect(Player* player, Creature* creature, uint32 /*Sender*/, uint32 action) { player->PlayerTalkClass->ClearMenus(); - switch (uiAction) + switch (action) { case GOSSIP_ACTION_INFO_DEF+1: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SELECT_DOOMREL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); @@ -150,9 +142,9 @@ public: struct boss_doomrelAI : public ScriptedAI { - boss_doomrelAI(Creature* c) : ScriptedAI(c) + boss_doomrelAI(Creature* creature) : ScriptedAI(creature) { - instance = c->GetInstanceScript(); + instance = creature->GetInstanceScript(); } InstanceScript* instance; @@ -164,11 +156,11 @@ public: void Reset() { - ShadowVolley_Timer = 10000; - Immolate_Timer = 18000; - CurseOfWeakness_Timer = 5000; - DemonArmor_Timer = 16000; - Voidwalkers = false; + ShadowVolley_Timer = 10000; + Immolate_Timer = 18000; + CurseOfWeakness_Timer = 5000; + DemonArmor_Timer = 16000; + Voidwalkers = false; me->setFaction(FACTION_FRIEND); @@ -252,7 +244,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_tomb_of_seven() diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp index 36135d6ea55..ae81c3bed64 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp @@ -16,13 +16,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Instance_Blackrock_Depths -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - #include "ScriptPCH.h" #include "blackrock_depths.h" @@ -63,7 +56,6 @@ enum eEnums GO_GOLEM_ROOM_N = 170573, // Magmus door North GO_GOLEM_ROOM_S = 170574, // Magmus door Soutsh GO_THRONE_ROOM = 170575, // Throne door - GO_SPECTRAL_CHALICE = 164869, GO_CHEST_SEVEN = 169243 }; @@ -82,7 +74,7 @@ public: { instance_blackrock_depths_InstanceMapScript(Map* map) : InstanceScript(map) {} - uint32 m_auiEncounter[MAX_ENCOUNTER]; + uint32 encounter[MAX_ENCOUNTER]; std::string str_data; uint64 EmperorGUID; @@ -121,59 +113,59 @@ public: void Initialize() { - memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); - - EmperorGUID = 0; - PhalanxGUID = 0; - MagmusGUID = 0; - MoiraGUID = 0; - - GoArena1GUID = 0; - GoArena2GUID = 0; - GoArena3GUID = 0; - GoArena4GUID = 0; - GoShadowLockGUID = 0; - GoShadowMechGUID = 0; - GoShadowGiantGUID = 0; - GoShadowDummyGUID = 0; - GoBarKegGUID = 0; - GoBarKegTrapGUID = 0; - GoBarDoorGUID = 0; - GoTombEnterGUID = 0; - GoTombExitGUID = 0; - GoLyceumGUID = 0; - GoSFSGUID = 0; - GoSFNGUID = 0; - GoGolemNGUID = 0; - GoGolemSGUID = 0; - GoThroneGUID = 0; - GoChestGUID = 0; - GoSpectralChaliceGUID = 0; - - BarAleCount = 0; - GhostKillCount = 0; - TombEventStarterGUID = 0; + memset(&encounter, 0, sizeof(encounter)); + + EmperorGUID = 0; + PhalanxGUID = 0; + MagmusGUID = 0; + MoiraGUID = 0; + + GoArena1GUID = 0; + GoArena2GUID = 0; + GoArena3GUID = 0; + GoArena4GUID = 0; + GoShadowLockGUID = 0; + GoShadowMechGUID = 0; + GoShadowGiantGUID = 0; + GoShadowDummyGUID = 0; + GoBarKegGUID = 0; + GoBarKegTrapGUID = 0; + GoBarDoorGUID = 0; + GoTombEnterGUID = 0; + GoTombExitGUID = 0; + GoLyceumGUID = 0; + GoSFSGUID = 0; + GoSFNGUID = 0; + GoGolemNGUID = 0; + GoGolemSGUID = 0; + GoThroneGUID = 0; + GoChestGUID = 0; + GoSpectralChaliceGUID = 0; + + BarAleCount = 0; + GhostKillCount = 0; + TombEventStarterGUID = 0; TombTimer = TIMER_TOMBOFTHESEVEN; - TombEventCounter = 0; + TombEventCounter = 0; for (uint8 i = 0; i < 7; ++i) - TombBossGUIDs[i] = 0; + TombBossGUIDs[i] = 0; } void OnCreatureCreate(Creature* creature) { switch (creature->GetEntry()) { - case NPC_EMPEROR: EmperorGUID = creature->GetGUID(); break; - case NPC_PHALANX: PhalanxGUID = creature->GetGUID(); break; - case NPC_MOIRA: MoiraGUID = creature->GetGUID(); break; - case NPC_DOOMREL: TombBossGUIDs[0] = creature->GetGUID(); break; - case NPC_DOPEREL: TombBossGUIDs[1] = creature->GetGUID(); break; - case NPC_HATEREL: TombBossGUIDs[2] = creature->GetGUID(); break; - case NPC_VILEREL: TombBossGUIDs[3] = creature->GetGUID(); break; - case NPC_SEETHREL: TombBossGUIDs[4] = creature->GetGUID(); break; - case NPC_GLOOMREL: TombBossGUIDs[5] = creature->GetGUID(); break; - case NPC_ANGERREL: TombBossGUIDs[6] = creature->GetGUID(); break; + case NPC_EMPEROR: EmperorGUID = creature->GetGUID(); break; + case NPC_PHALANX: PhalanxGUID = creature->GetGUID(); break; + case NPC_MOIRA: MoiraGUID = creature->GetGUID(); break; + case NPC_DOOMREL: TombBossGUIDs[0] = creature->GetGUID(); break; + case NPC_DOPEREL: TombBossGUIDs[1] = creature->GetGUID(); break; + case NPC_HATEREL: TombBossGUIDs[2] = creature->GetGUID(); break; + case NPC_VILEREL: TombBossGUIDs[3] = creature->GetGUID(); break; + case NPC_SEETHREL: TombBossGUIDs[4] = creature->GetGUID(); break; + case NPC_GLOOMREL: TombBossGUIDs[5] = creature->GetGUID(); break; + case NPC_ANGERREL: TombBossGUIDs[6] = creature->GetGUID(); break; case NPC_MAGMUS: MagmusGUID = creature->GetGUID(); if (!creature->isAlive()) @@ -239,25 +231,25 @@ public: switch (type) { case TYPE_RING_OF_LAW: - m_auiEncounter[0] = data; + encounter[0] = data; break; case TYPE_VAULT: - m_auiEncounter[1] = data; + encounter[1] = data; break; case TYPE_BAR: if (data == SPECIAL) ++BarAleCount; else - m_auiEncounter[2] = data; + encounter[2] = data; break; case TYPE_TOMB_OF_SEVEN: - m_auiEncounter[3] = data; + encounter[3] = data; break; case TYPE_LYCEUM: - m_auiEncounter[4] = data; + encounter[4] = data; break; case TYPE_IRON_HALL: - m_auiEncounter[5] = data; + encounter[5] = data; break; case DATA_GHOSTKILL: GhostKillCount += data; @@ -269,8 +261,8 @@ public: OUT_SAVE_INST_DATA; std::ostringstream saveStream; - saveStream << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2] << ' ' - << m_auiEncounter[3] << ' ' << m_auiEncounter[4] << ' ' << m_auiEncounter[5] << ' ' << GhostKillCount; + saveStream << encounter[0] << ' ' << encounter[1] << ' ' << encounter[2] << ' ' + << encounter[3] << ' ' << encounter[4] << ' ' << encounter[5] << ' ' << GhostKillCount; str_data = saveStream.str(); @@ -284,20 +276,20 @@ public: switch (type) { case TYPE_RING_OF_LAW: - return m_auiEncounter[0]; + return encounter[0]; case TYPE_VAULT: - return m_auiEncounter[1]; + return encounter[1]; case TYPE_BAR: - if (m_auiEncounter[2] == IN_PROGRESS && BarAleCount == 3) + if (encounter[2] == IN_PROGRESS && BarAleCount == 3) return SPECIAL; else - return m_auiEncounter[2]; + return encounter[2]; case TYPE_TOMB_OF_SEVEN: - return m_auiEncounter[3]; + return encounter[3]; case TYPE_LYCEUM: - return m_auiEncounter[4]; + return encounter[4]; case TYPE_IRON_HALL: - return m_auiEncounter[5]; + return encounter[5]; case DATA_GHOSTKILL: return GhostKillCount; } @@ -362,12 +354,12 @@ public: OUT_LOAD_INST_DATA(in); std::istringstream loadStream(in); - loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3] - >> m_auiEncounter[4] >> m_auiEncounter[5] >> GhostKillCount; + loadStream >> encounter[0] >> encounter[1] >> encounter[2] >> encounter[3] + >> encounter[4] >> encounter[5] >> GhostKillCount; for (uint8 i = 0; i < MAX_ENCOUNTER; ++i) - if (m_auiEncounter[i] == IN_PROGRESS) - m_auiEncounter[i] = NOT_STARTED; + if (encounter[i] == IN_PROGRESS) + encounter[i] = NOT_STARTED; if (GhostKillCount > 0 && GhostKillCount < 7) GhostKillCount = 0;//reset tomb of seven event if (GhostKillCount >= 7) @@ -459,7 +451,6 @@ public: TombOfSevenEnd(); } }; - }; void AddSC_instance_blackrock_depths() diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_drakkisath.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_drakkisath.cpp index 5c68b933568..eec118b2972 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_drakkisath.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_drakkisath.cpp @@ -58,10 +58,10 @@ public: void EnterCombat(Unit* /*who*/) { _EnterCombat(); - events.ScheduleEvent(EVENT_FIRE_NOVA, 6*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_CLEAVE, 8*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_CONFLIGURATION, 15*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_THUNDERCLAP, 17*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_FIRE_NOVA, 6 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CLEAVE, 8 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CONFLIGURATION, 15 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_THUNDERCLAP, 17 * IN_MILLISECONDS); } void JustDied(Unit* /*who*/) @@ -85,19 +85,19 @@ public: { case EVENT_FIRE_NOVA: DoCast(me->getVictim(), SPELL_FIRENOVA); - events.ScheduleEvent(EVENT_FIRE_NOVA, 10*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_FIRE_NOVA, 10 * IN_MILLISECONDS); break; case EVENT_CLEAVE: DoCast(me->getVictim(), SPELL_CLEAVE); - events.ScheduleEvent(EVENT_CLEAVE, 8*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CLEAVE, 8 * IN_MILLISECONDS); break; case EVENT_CONFLIGURATION: DoCast(me->getVictim(), SPELL_CONFLIGURATION); - events.ScheduleEvent(EVENT_CONFLIGURATION, 18*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CONFLIGURATION, 18 * IN_MILLISECONDS); break; case EVENT_THUNDERCLAP: DoCast(me->getVictim(), SPELL_THUNDERCLAP); - events.ScheduleEvent(EVENT_THUNDERCLAP, 20*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_THUNDERCLAP, 20 * IN_MILLISECONDS); break; } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_gyth.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_gyth.cpp index b08478a1145..88b1bbc49e2 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_gyth.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_gyth.cpp @@ -74,9 +74,9 @@ public: void EnterCombat(Unit* /*who*/) { _EnterCombat(); - events.ScheduleEvent(EVENT_SUMMON_DRAGON_PACK, 3*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_SUMMON_ORC_PACK, 60*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_AGGRO, 60*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SUMMON_DRAGON_PACK, 3 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SUMMON_ORC_PACK, 60 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_AGGRO, 60 * IN_MILLISECONDS); } void JustDied(Unit* /*who*/) @@ -87,7 +87,7 @@ public: void SummonCreatureWithRandomTarget(uint32 creatureId, uint8 count) { for (uint8 n = 0; n < count; n++) - if (Unit* Summoned = me->SummonCreature(creatureId, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 240*IN_MILLISECONDS)) + if (Unit* Summoned = me->SummonCreature(creatureId, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 240 * IN_MILLISECONDS)) if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50.0f, true)) Summoned->AddThreat(target, 250.0f); } @@ -99,7 +99,7 @@ public: if (!SummonedRend && HealthBelowPct(11)) { - events.ScheduleEvent(EVENT_SUMMON_REND, 8*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SUMMON_REND, 8 * IN_MILLISECONDS); SummonedRend = true; } @@ -118,10 +118,10 @@ public: me->InterruptNonMeleeSpells(false); // Gyth model me->SetDisplayId(me->GetCreatureInfo()->Modelid1); - me->SummonCreature(NPC_WARCHIEF_REND_BLACKHAND, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 900*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_CORROSIVE_ACID, 8*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_FREEZE, 11*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_FLAME_BREATH, 4*IN_MILLISECONDS); + me->SummonCreature(NPC_WARCHIEF_REND_BLACKHAND, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 900 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CORROSIVE_ACID, 8 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_FREEZE, 11 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_FLAME_BREATH, 4 * IN_MILLISECONDS); events.CancelEvent(EVENT_SUMMON_REND); break; case EVENT_AGGRO: @@ -152,11 +152,11 @@ public: break; case EVENT_CORROSIVE_ACID: DoCast(me->getVictim(), SPELL_CORROSIVE_ACID); - events.ScheduleEvent(EVENT_CORROSIVE_ACID, 7*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CORROSIVE_ACID, 7 * IN_MILLISECONDS); break; case EVENT_FREEZE: DoCast(me->getVictim(), SPELL_FREEZE); - events.ScheduleEvent(EVENT_FREEZE, 16*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_FREEZE, 16 * IN_MILLISECONDS); break; case EVENT_FLAME_BREATH: DoCast(me->getVictim(), SPELL_FLAMEBREATH); diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_halycon.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_halycon.cpp index 5a3adfe499f..59c1ea1c9a4 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_halycon.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_halycon.cpp @@ -59,8 +59,8 @@ public: void EnterCombat(Unit* /*who*/) { _EnterCombat(); - events.ScheduleEvent(EVENT_CROWD_PUMMEL, 8*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_MIGHTY_BLOW, 14*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CROWD_PUMMEL, 8 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_MIGHTY_BLOW, 14 * IN_MILLISECONDS); } void JustDied(Unit* /*who*/) @@ -76,7 +76,7 @@ public: //Summon Gizrul if (!Summoned && HealthBelowPct(25)) { - me->SummonCreature(NPC_GIZRUL_THE_SLAVENER, SummonLocation, TEMPSUMMON_TIMED_DESPAWN, 300*IN_MILLISECONDS); + me->SummonCreature(NPC_GIZRUL_THE_SLAVENER, SummonLocation, TEMPSUMMON_TIMED_DESPAWN, 300 * IN_MILLISECONDS); Summoned = true; } @@ -91,11 +91,11 @@ public: { case EVENT_CROWD_PUMMEL: DoCast(me->getVictim(), SPELL_CROWDPUMMEL); - events.ScheduleEvent(EVENT_CROWD_PUMMEL, 14*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CROWD_PUMMEL, 14 * IN_MILLISECONDS); break; case EVENT_MIGHTY_BLOW: DoCast(me->getVictim(), SPELL_MIGHTYBLOW); - events.ScheduleEvent(EVENT_MIGHTY_BLOW, 10*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_MIGHTY_BLOW, 10 * IN_MILLISECONDS); break; } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_highlord_omokk.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_highlord_omokk.cpp index d1c1a2db699..4c91f79624a 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_highlord_omokk.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_highlord_omokk.cpp @@ -64,13 +64,13 @@ public: void EnterCombat(Unit* /*who*/) { _EnterCombat(); - events.ScheduleEvent(EVENT_WARSTOMP, 15*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_CLEAVE, 6*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_STRIKE, 10*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_REND, 14*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_SUNDER_ARMOR, 2*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_KNOCK_AWAY, 18*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_SLOW, 24*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_WARSTOMP, 15 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CLEAVE, 6 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_STRIKE, 10 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_REND, 14 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SUNDER_ARMOR, 2 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_KNOCK_AWAY, 18 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SLOW, 24 * IN_MILLISECONDS); } void JustDied(Unit* /*who*/) @@ -94,31 +94,31 @@ public: { case EVENT_WARSTOMP: DoCast(me->getVictim(), SPELL_WARSTOMP); - events.ScheduleEvent(EVENT_WARSTOMP, 14*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_WARSTOMP, 14 * IN_MILLISECONDS); break; case EVENT_CLEAVE: DoCast(me->getVictim(), SPELL_CLEAVE); - events.ScheduleEvent(EVENT_CLEAVE, 8*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CLEAVE, 8 * IN_MILLISECONDS); break; case EVENT_STRIKE: DoCast(me->getVictim(), SPELL_STRIKE); - events.ScheduleEvent(EVENT_STRIKE, 10*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_STRIKE, 10 * IN_MILLISECONDS); break; case EVENT_REND: DoCast(me->getVictim(), SPELL_REND); - events.ScheduleEvent(EVENT_REND, 18*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_REND, 18 * IN_MILLISECONDS); break; case EVENT_SUNDER_ARMOR: DoCast(me->getVictim(), SPELL_SUNDERARMOR); - events.ScheduleEvent(EVENT_SUNDER_ARMOR, 25*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SUNDER_ARMOR, 25 * IN_MILLISECONDS); break; case EVENT_KNOCK_AWAY: DoCast(me->getVictim(), SPELL_KNOCKAWAY); - events.ScheduleEvent(EVENT_KNOCK_AWAY, 12*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_KNOCK_AWAY, 12 * IN_MILLISECONDS); break; case EVENT_SLOW: DoCast(me->getVictim(), SPELL_SLOW); - events.ScheduleEvent(EVENT_SLOW, 18*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SLOW, 18 * IN_MILLISECONDS); break; } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_mother_smolderweb.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_mother_smolderweb.cpp index 3c467b1c7a8..a2314518f28 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_mother_smolderweb.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_mother_smolderweb.cpp @@ -55,8 +55,8 @@ public: void EnterCombat(Unit* /*who*/) { _EnterCombat(); - events.ScheduleEvent(EVENT_CRYSTALIZE, 20*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_MOTHERS_MILK, 10*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CRYSTALIZE, 20 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_MOTHERS_MILK, 10 * IN_MILLISECONDS); } void JustDied(Unit* /*who*/) @@ -86,11 +86,11 @@ public: { case EVENT_CRYSTALIZE: DoCast(me, SPELL_CRYSTALIZE); - events.ScheduleEvent(EVENT_CRYSTALIZE, 15*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CRYSTALIZE, 15 * IN_MILLISECONDS); break; case EVENT_MOTHERS_MILK: DoCast(me, SPELL_MOTHERSMILK); - events.ScheduleEvent(EVENT_MOTHERS_MILK, urand(5*IN_MILLISECONDS, 12500)); + events.ScheduleEvent(EVENT_MOTHERS_MILK, urand(5 * IN_MILLISECONDS, 12500)); break; } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_overlord_wyrmthalak.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_overlord_wyrmthalak.cpp index 4f71bdef129..28680ef5049 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_overlord_wyrmthalak.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_overlord_wyrmthalak.cpp @@ -71,10 +71,10 @@ public: void EnterCombat(Unit* /*who*/) { _EnterCombat(); - events.ScheduleEvent(EVENT_BLAST_WAVE, 20*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_SHOUT, 2*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_CLEAVE, 6*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_KNOCK_AWAY, 12*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_BLAST_WAVE, 20 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SHOUT, 2 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CLEAVE, 6 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_KNOCK_AWAY, 12 * IN_MILLISECONDS); } void JustDied(Unit* /*who*/) @@ -91,9 +91,9 @@ public: { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) { - if (Creature* warlord = me->SummonCreature(NPC_SPIRESTONE_WARLORD, SummonLocation1, TEMPSUMMON_TIMED_DESPAWN, 300*IN_MILLISECONDS)) + if (Creature* warlord = me->SummonCreature(NPC_SPIRESTONE_WARLORD, SummonLocation1, TEMPSUMMON_TIMED_DESPAWN, 300 * IN_MILLISECONDS)) warlord->AI()->AttackStart(target); - if (Creature* berserker = me->SummonCreature(NPC_SMOLDERTHORN_BERSERKER, SummonLocation2, TEMPSUMMON_TIMED_DESPAWN, 300*IN_MILLISECONDS)) + if (Creature* berserker = me->SummonCreature(NPC_SMOLDERTHORN_BERSERKER, SummonLocation2, TEMPSUMMON_TIMED_DESPAWN, 300 * IN_MILLISECONDS)) berserker->AI()->AttackStart(target); Summoned = true; } @@ -110,19 +110,19 @@ public: { case EVENT_BLAST_WAVE: DoCast(me->getVictim(), SPELL_BLASTWAVE); - events.ScheduleEvent(EVENT_BLAST_WAVE, 20*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_BLAST_WAVE, 20 * IN_MILLISECONDS); break; case EVENT_SHOUT: DoCast(me->getVictim(), SPELL_SHOUT); - events.ScheduleEvent(EVENT_SHOUT, 10*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SHOUT, 10 * IN_MILLISECONDS); break; case EVENT_CLEAVE: DoCast(me->getVictim(), SPELL_CLEAVE); - events.ScheduleEvent(EVENT_CLEAVE, 7*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CLEAVE, 7 * IN_MILLISECONDS); break; case EVENT_KNOCK_AWAY: DoCast(me->getVictim(), SPELL_KNOCKAWAY); - events.ScheduleEvent(EVENT_KNOCK_AWAY, 14*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_KNOCK_AWAY, 14 * IN_MILLISECONDS); break; } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_pyroguard_emberseer.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_pyroguard_emberseer.cpp index c938561eb9c..b4d44d85dec 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_pyroguard_emberseer.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_pyroguard_emberseer.cpp @@ -57,9 +57,9 @@ public: void EnterCombat(Unit* /*who*/) { _EnterCombat(); - events.ScheduleEvent(EVENT_FIRENOVA, 6*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_FLAMEBUFFET, 3*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_PYROBLAST, 14*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_FIRENOVA, 6 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_FLAMEBUFFET, 3 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_PYROBLAST, 14 * IN_MILLISECONDS); } void JustDied(Unit* /*who*/) @@ -83,16 +83,16 @@ public: { case EVENT_FIRENOVA: DoCast(me->getVictim(), SPELL_FIRENOVA); - events.ScheduleEvent(EVENT_FIRENOVA, 6*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_FIRENOVA, 6 * IN_MILLISECONDS); break; case EVENT_FLAMEBUFFET: DoCast(me->getVictim(), SPELL_FLAMEBUFFET); - events.ScheduleEvent(EVENT_FLAMEBUFFET, 14*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_FLAMEBUFFET, 14 * IN_MILLISECONDS); break; case EVENT_PYROBLAST: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) DoCast(target, SPELL_PYROBLAST); - events.ScheduleEvent(EVENT_PYROBLAST, 15*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_PYROBLAST, 15 * IN_MILLISECONDS); break; } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_quartermaster_zigris.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_quartermaster_zigris.cpp index ee954d1adfa..bb8f45082dc 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_quartermaster_zigris.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_quartermaster_zigris.cpp @@ -56,8 +56,8 @@ public: void EnterCombat(Unit* /*who*/) { _EnterCombat(); - events.ScheduleEvent(EVENT_SHOOT, 1*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_STUN_BOMB, 16*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SHOOT, 1 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_STUN_BOMB, 16 * IN_MILLISECONDS); } void JustDied(Unit* /*who*/) @@ -85,7 +85,7 @@ public: break; case EVENT_STUN_BOMB: DoCast(me->getVictim(), SPELL_STUNBOMB); - events.ScheduleEvent(EVENT_STUN_BOMB, 14*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_STUN_BOMB, 14 * IN_MILLISECONDS); break; } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_rend_blackhand.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_rend_blackhand.cpp index 634b65e0002..762de86a82b 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_rend_blackhand.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_rend_blackhand.cpp @@ -56,9 +56,9 @@ public: void EnterCombat(Unit* /*who*/) { _EnterCombat(); - events.ScheduleEvent(EVENT_WHIRLWIND, 20*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_CLEAVE, 5*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_THUNDERCLAP, 9*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_WHIRLWIND, 20 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CLEAVE, 5 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_THUNDERCLAP, 9 * IN_MILLISECONDS); } void JustDied(Unit* /*who*/) @@ -82,15 +82,15 @@ public: { case EVENT_WHIRLWIND: DoCast(me->getVictim(), SPELL_WHIRLWIND); - events.ScheduleEvent(EVENT_WHIRLWIND, 18*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_WHIRLWIND, 18 * IN_MILLISECONDS); break; case EVENT_CLEAVE: DoCast(me->getVictim(), SPELL_CLEAVE); - events.ScheduleEvent(EVENT_CLEAVE, 10*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CLEAVE, 10 * IN_MILLISECONDS); break; case EVENT_THUNDERCLAP: DoCast(me->getVictim(), SPELL_THUNDERCLAP); - events.ScheduleEvent(EVENT_THUNDERCLAP, 16*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_THUNDERCLAP, 16 * IN_MILLISECONDS); break; } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_shadow_hunter_voshgajin.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_shadow_hunter_voshgajin.cpp index 71ce5c8d48e..fcd41f97ad0 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_shadow_hunter_voshgajin.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_shadow_hunter_voshgajin.cpp @@ -57,9 +57,9 @@ public: void EnterCombat(Unit* /*who*/) { _EnterCombat(); - events.ScheduleEvent(EVENT_CURSE_OF_BLOOD, 2*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_HEX, 8*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_CLEAVE, 14*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CURSE_OF_BLOOD, 2 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_HEX, 8 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CLEAVE, 14 * IN_MILLISECONDS); } void JustDied(Unit* /*who*/) @@ -83,16 +83,16 @@ public: { case EVENT_CURSE_OF_BLOOD: DoCast(me->getVictim(), SPELL_CURSEOFBLOOD); - events.ScheduleEvent(EVENT_CURSE_OF_BLOOD, 45*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CURSE_OF_BLOOD, 45 * IN_MILLISECONDS); break; case EVENT_HEX: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) DoCast(target, SPELL_HEX); - events.ScheduleEvent(EVENT_HEX, 15*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_HEX, 15 * IN_MILLISECONDS); break; case EVENT_CLEAVE: DoCast(me->getVictim(), SPELL_CLEAVE); - events.ScheduleEvent(EVENT_CLEAVE, 7*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CLEAVE, 7 * IN_MILLISECONDS); break; } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_the_beast.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_the_beast.cpp index ea7a4b79ee2..f2b3f3ff87b 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_the_beast.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_the_beast.cpp @@ -56,9 +56,9 @@ public: void EnterCombat(Unit* /*who*/) { _EnterCombat(); - events.ScheduleEvent(EVENT_FLAME_BREAK, 12*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_IMMOLATE, 3*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_TERRIFYING_ROAR, 23*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_FLAME_BREAK, 12 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_IMMOLATE, 3 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_TERRIFYING_ROAR, 23 * IN_MILLISECONDS); } void JustDied(Unit* /*who*/) @@ -82,16 +82,16 @@ public: { case EVENT_FLAME_BREAK: DoCast(me->getVictim(), SPELL_FLAMEBREAK); - events.ScheduleEvent(EVENT_FLAME_BREAK, 10*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_FLAME_BREAK, 10 * IN_MILLISECONDS); break; case EVENT_IMMOLATE: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) DoCast(target, SPELL_IMMOLATE); - events.ScheduleEvent(EVENT_IMMOLATE, 8*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_IMMOLATE, 8 * IN_MILLISECONDS); break; case EVENT_TERRIFYING_ROAR: DoCast(me->getVictim(), SPELL_TERRIFYINGROAR); - events.ScheduleEvent(EVENT_TERRIFYING_ROAR, 20*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_TERRIFYING_ROAR, 20 * IN_MILLISECONDS); break; } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_warmaster_voone.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_warmaster_voone.cpp index b1ae9b07630..40ead810600 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_warmaster_voone.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_warmaster_voone.cpp @@ -62,12 +62,12 @@ public: void EnterCombat(Unit* /*who*/) { _EnterCombat(); - events.ScheduleEvent(EVENT_SNAP_KICK, 8*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_CLEAVE, 14*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_UPPERCUT, 20*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_MORTAL_STRIKE, 12*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_PUMMEL, 32*IN_MILLISECONDS); - events.ScheduleEvent(EVENT_THROW_AXE, 1*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SNAP_KICK, 8 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CLEAVE, 14 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_UPPERCUT, 20 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_MORTAL_STRIKE, 12 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_PUMMEL, 32 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_THROW_AXE, 1 * IN_MILLISECONDS); } void JustDied(Unit* /*who*/) @@ -91,27 +91,27 @@ public: { case EVENT_SNAP_KICK: DoCast(me->getVictim(), SPELL_SNAPKICK); - events.ScheduleEvent(EVENT_SNAP_KICK, 6*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SNAP_KICK, 6 * IN_MILLISECONDS); break; case EVENT_CLEAVE: DoCast(me->getVictim(), SPELL_CLEAVE); - events.ScheduleEvent(EVENT_CLEAVE, 12*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CLEAVE, 12 * IN_MILLISECONDS); break; case EVENT_UPPERCUT: DoCast(me->getVictim(), SPELL_UPPERCUT); - events.ScheduleEvent(EVENT_UPPERCUT, 14*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_UPPERCUT, 14 * IN_MILLISECONDS); break; case EVENT_MORTAL_STRIKE: DoCast(me->getVictim(), SPELL_MORTALSTRIKE); - events.ScheduleEvent(EVENT_MORTAL_STRIKE, 10*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_MORTAL_STRIKE, 10 * IN_MILLISECONDS); break; case EVENT_PUMMEL: DoCast(me->getVictim(), SPELL_PUMMEL); - events.ScheduleEvent(EVENT_MORTAL_STRIKE, 16*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_MORTAL_STRIKE, 16 * IN_MILLISECONDS); break; case EVENT_THROW_AXE: DoCast(me->getVictim(), SPELL_THROWAXE); - events.ScheduleEvent(EVENT_THROW_AXE, 8*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_THROW_AXE, 8 * IN_MILLISECONDS); break; } } diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/instance_blackrock_spire.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/instance_blackrock_spire.cpp index d65c1c68090..cff1c831eee 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/instance_blackrock_spire.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/instance_blackrock_spire.cpp @@ -33,7 +33,7 @@ public: { instance_blackrock_spireMapScript(InstanceMap* map) : InstanceScript(map) {} - uint32 Encounter[MAX_ENCOUNTER]; + uint32 encounter[MAX_ENCOUNTER]; std::string m_strInstData; uint64 HighlordOmokk; uint64 ShadowHunterVoshgajin; @@ -53,27 +53,27 @@ public: void Initialize() { SetBossNumber(MAX_ENCOUNTER); - HighlordOmokk = 0; - ShadowHunterVoshgajin = 0; - WarMasterVoone = 0; - MotherSmolderweb = 0; - UrokDoomhowl = 0; - QuartermasterZigris = 0; - GizrultheSlavener = 0; - Halycon = 0; - OverlordWyrmthalak = 0; - PyroguardEmberseer = 0; - WarchiefRendBlackhand = 0; - Gyth = 0; - TheBeast = 0; - GeneralDrakkisath = 0; + HighlordOmokk = 0; + ShadowHunterVoshgajin = 0; + WarMasterVoone = 0; + MotherSmolderweb = 0; + UrokDoomhowl = 0; + QuartermasterZigris = 0; + GizrultheSlavener = 0; + Halycon = 0; + OverlordWyrmthalak = 0; + PyroguardEmberseer = 0; + WarchiefRendBlackhand = 0; + Gyth = 0; + TheBeast = 0; + GeneralDrakkisath = 0; } bool IsEncounterInProgress() const { for (uint8 i = 0; i < MAX_ENCOUNTER; ++i) { - if (Encounter[i] == IN_PROGRESS) + if (encounter[i] == IN_PROGRESS) return true; } return false; diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp index ce4a2a10cac..c64fc6f2dab 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp @@ -206,7 +206,7 @@ public: { float x = KaelLocations[0][0]; float y = KaelLocations[0][1]; - me->GetMap()->CreatureRelocation(me, x, y, LOCATION_Z, 0.0f); + me->SetPosition(x, y, LOCATION_Z, 0.0f); //me->SendMonsterMove(x, y, LOCATION_Z, 0, 0, 0); // causes some issues... std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp index e6610294071..a6bb95995be 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp @@ -51,9 +51,11 @@ public: phase = 0; me->GetPosition(x, y, z); - z += 4; x -= 3.5; y -= 5; + z += 4.0f; + x -= 3.5f; + y -= 5.0f; me->GetMotionMaster()->Clear(false); - me->GetMap()->CreatureRelocation(me, x, y, z, 0.0f); + me->SetPosition(x, y, z, 0.0f); } void UpdateAI(const uint32 diff) @@ -78,7 +80,9 @@ public: break; case 1: player->GetClosePoint(x, y, z, me->GetObjectSize()); - z += 2.5; x -= 2; y -= 1.5; + z += 2.5f; + x -= 2.0f; + y -= 1.5f; me->GetMotionMaster()->MovePoint(0, x, y, z); me->SetTarget(player->GetGUID()); me->SetVisible(true); diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp index 667e1cd279e..9afbeaa0172 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp @@ -756,7 +756,7 @@ public: { float x, y, z; me->GetPosition(x, y, z); //this visual aura some under ground - me->GetMap()->CreatureRelocation(me, x, y, z + 0.35f, 0.0f); + me->SetPosition(x, y, z + 0.35f, 0.0f); Despawn(); Creature* debuff = DoSpawnCreature(HELPER, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 14500); if (debuff) diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp index 4de719d684e..4e3f3899b35 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp @@ -484,15 +484,14 @@ public: float x, y, z; me->GetPosition(x, y, z); - CellPair pair(Trinity::ComputeCellPair(x, y)); + CellCoord pair(Trinity::ComputeCellCoord(x, y)); Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::AllCreaturesOfEntryInRange check(me, entry, 100); Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(me, templist, check); TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher); - cell.Visit(pair, cSearcher, *(me->GetMap())); + cell.Visit(pair, cSearcher, *(me->GetMap()), *me, me->GetGridActivationRange()); for (std::list<Creature*>::const_iterator i = templist.begin(); i != templist.end(); ++i) { diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index 2e4e92685ea..df3bb5d4525 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -661,7 +661,7 @@ public: void JustDied(Unit* /*killer*/) { DoScriptText(SAY_SATH_DEATH, me); - me->GetMap()->CreatureRelocation(me, me->GetPositionX(), me->GetPositionY(), DRAGON_REALM_Z, me->GetOrientation()); + me->SetPosition(me->GetPositionX(), me->GetPositionY(), DRAGON_REALM_Z, me->GetOrientation()); TeleportAllPlayersBack(); if (Creature* Kalecgos = Unit::GetCreature(*me, KalecgosGUID)) { diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp index ba2d638d45f..413897c94e8 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp @@ -189,22 +189,21 @@ class boss_akilzon : public CreatureScript for (uint8 i = 2; i < StormCount; ++i) bp0 *= 2; - CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); + CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); std::list<Unit*> tempUnitMap; { - Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(me, me, 999); + Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(me, me, SIZE_OF_GRIDS); Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(me, tempUnitMap, u_check); TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); - cell.Visit(p, world_unit_searcher, *(me->GetMap())); - cell.Visit(p, grid_unit_searcher, *(me->GetMap())); + cell.Visit(p, world_unit_searcher, *me->GetMap(), *me, SIZE_OF_GRIDS); + cell.Visit(p, grid_unit_searcher, *me->GetMap(), *me, SIZE_OF_GRIDS); } //dealdamege for (std::list<Unit*>::const_iterator i = tempUnitMap.begin(); i != tempUnitMap.end(); ++i) diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp index d4d4e7314b4..162c84f1fa7 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp @@ -335,7 +335,7 @@ class boss_hexlord_malacrass : public CreatureScript else { creature->AI()->EnterEvadeMode(); - creature->GetMap()->CreatureRelocation(me, Pos_X[i], POS_Y, POS_Z, ORIENT); + creature->SetPosition(Pos_X[i], POS_Y, POS_Z, ORIENT); creature->StopMoving(); } } diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp index d2ad81b4910..aea9e322583 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp @@ -233,9 +233,8 @@ class boss_janalai : public CreatureScript me->GetPosition(x, y, z); { - CellPair pair(Trinity::ComputeCellPair(x, y)); + CellCoord pair(Trinity::ComputeCellCoord(x, y)); Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::AllCreaturesOfEntryInRange check(me, MOB_EGG, 100); @@ -243,7 +242,7 @@ class boss_janalai : public CreatureScript TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher); - cell.Visit(pair, cSearcher, *(me->GetMap())); + cell.Visit(pair, cSearcher, *me->GetMap(), *me, me->GetGridActivationRange()); } //sLog->outError("Eggs %d at middle", templist.size()); @@ -267,9 +266,8 @@ class boss_janalai : public CreatureScript me->GetPosition(x, y, z); { - CellPair pair(Trinity::ComputeCellPair(x, y)); + CellCoord pair(Trinity::ComputeCellCoord(x, y)); Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::AllCreaturesOfEntryInRange check(me, MOB_FIRE_BOMB, 100); @@ -277,7 +275,7 @@ class boss_janalai : public CreatureScript TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher); - cell.Visit(pair, cSearcher, *(me->GetMap())); + cell.Visit(pair, cSearcher, *me->GetMap(), *me, me->GetGridActivationRange()); } for (std::list<Creature*>::const_iterator i = templist.begin(); i != templist.end(); ++i) { @@ -519,9 +517,8 @@ class mob_janalai_hatcher : public CreatureScript me->GetPosition(x, y, z); { - CellPair pair(Trinity::ComputeCellPair(x, y)); + CellCoord pair(Trinity::ComputeCellCoord(x, y)); Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::AllCreaturesOfEntryInRange check(me, 23817, 50); @@ -529,7 +526,7 @@ class mob_janalai_hatcher : public CreatureScript TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher); - cell.Visit(pair, cSearcher, *(me->GetMap())); + cell.Visit(pair, cSearcher, *(me->GetMap()), *me, me->GetGridActivationRange()); } //sLog->outError("Eggs %d at %d", templist.size(), side); diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp index 17968766a5f..3ff465a3c1d 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp @@ -162,9 +162,8 @@ class boss_nalorakk : public CreatureScript me->GetPosition(x, y, z); { - CellPair pair(Trinity::ComputeCellPair(x, y)); + CellCoord pair(Trinity::ComputeCellCoord(x, y)); Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::AllFriendlyCreaturesInGrid check(me); @@ -172,7 +171,7 @@ class boss_nalorakk : public CreatureScript TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>, GridTypeMapContainer> cSearcher(searcher); - cell.Visit(pair, cSearcher, *(me->GetMap())); + cell.Visit(pair, cSearcher, *(me->GetMap()), *me, me->GetGridActivationRange()); } if (templist.empty()) diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp index f70c764f306..f45c943b0f1 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp @@ -91,9 +91,9 @@ class boss_mandokir : public CreatureScript MortalStrike_Timer = 1000; Check_Timer = 1000; - targetX = 0.0; - targetY = 0.0; - targetZ = 0.0; + targetX = 0.0f; + targetY = 0.0f; + targetZ = 0.0f; TargetInRange = 0; WatchTarget = 0; diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp index b9ae61c122e..f6704a50e6f 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp @@ -185,7 +185,7 @@ class boss_marli : public CreatureScript if (target) { DoCast(target, SPELL_CHARGE); - //me->GetMap()->CreatureRelocation(me, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); + //me->SetPosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); //me->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true, 1); AttackStart(target); } diff --git a/src/server/scripts/EasternKingdoms/eversong_woods.cpp b/src/server/scripts/EasternKingdoms/eversong_woods.cpp index 10b7066068b..d02cce3f17c 100644 --- a/src/server/scripts/EasternKingdoms/eversong_woods.cpp +++ b/src/server/scripts/EasternKingdoms/eversong_woods.cpp @@ -35,91 +35,6 @@ EndContentData */ #include "ScriptedEscortAI.h" /*###### -## npc_prospector_anvilward -######*/ - -#define GOSSIP_HELLO "I need a moment of your time, sir." -#define GOSSIP_SELECT "Why... yes, of course. I've something to show you right inside this building, Mr. Anvilward." - -enum eProspectorAnvilward -{ - SAY_ANVIL1 = -1000209, - SAY_ANVIL2 = -1000210, - QUEST_THE_DWARVEN_SPY = 8483, -}; - -class npc_prospector_anvilward : public CreatureScript -{ -public: - npc_prospector_anvilward() : CreatureScript("npc_prospector_anvilward") { } - - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction) - { - player->PlayerTalkClass->ClearMenus(); - switch (uiAction) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SELECT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(8240, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->CLOSE_GOSSIP_MENU(); - if (npc_escortAI* pEscortAI = CAST_AI(npc_prospector_anvilward::npc_prospector_anvilwardAI, creature->AI())) - pEscortAI->Start(true, false, player->GetGUID()); - break; - } - return true; - } - - bool OnGossipHello(Player* player, Creature* creature) - { - if (player->GetQuestStatus(QUEST_THE_DWARVEN_SPY) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(8239, creature->GetGUID()); - return true; - } - - CreatureAI* GetAI(Creature* creature) const - { - return new npc_prospector_anvilwardAI(creature); - } - - struct npc_prospector_anvilwardAI : public npc_escortAI - { - // CreatureAI functions - npc_prospector_anvilwardAI(Creature* c) : npc_escortAI(c) {} - - // Pure Virtual Functions - void WaypointReached(uint32 i) - { - Player* player = GetPlayerForEscort(); - - if (!player) - return; - - switch (i) - { - case 0: DoScriptText(SAY_ANVIL1, me, player); break; - case 5: DoScriptText(SAY_ANVIL2, me, player); break; - case 6: me->setFaction(24); break; - } - } - - void Reset() - { - me->RestoreFaction(); - } - - void JustDied(Unit* /*killer*/) - { - me->RestoreFaction(); - } - }; - -}; - -/*###### ## Quest 9686 Second Trial ######*/ @@ -711,7 +626,6 @@ public: void AddSC_eversong_woods() { - new npc_prospector_anvilward(); new npc_second_trial_controller(); new npc_second_trial_paladin(); new go_second_trial(); diff --git a/src/server/scripts/EasternKingdoms/undercity.cpp b/src/server/scripts/EasternKingdoms/undercity.cpp index 042c8f695c7..b8f2499c4e6 100644 --- a/src/server/scripts/EasternKingdoms/undercity.cpp +++ b/src/server/scripts/EasternKingdoms/undercity.cpp @@ -107,10 +107,10 @@ public: { if (summoned->GetEntry() == ENTRY_HIGHBORNE_BUNNY) { - if (Unit* target = Unit::GetUnit(*summoned, targetGUID)) + if (Creature* target = Unit::GetCreature(*summoned, targetGUID)) { target->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), me->GetPositionZ()+15.0f, 0); - target->GetMap()->CreatureRelocation(me, target->GetPositionX(), target->GetPositionY(), me->GetPositionZ()+15.0f, 0.0f); + target->SetPosition(target->GetPositionX(), target->GetPositionY(), me->GetPositionZ()+15.0f, 0.0f); summoned->CastSpell(target, SPELL_RIBBON_OF_SOULS, false); } @@ -187,7 +187,7 @@ public: { me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); me->SendMonsterMoveWithSpeed(me->GetPositionX(), me->GetPositionY(), HIGHBORNE_LOC_Y_NEW, 5000); - me->GetMap()->CreatureRelocation(me, me->GetPositionX(), me->GetPositionY(), HIGHBORNE_LOC_Y_NEW, me->GetOrientation()); + me->SetPosition(me->GetPositionX(), me->GetPositionY(), HIGHBORNE_LOC_Y_NEW, me->GetOrientation()); EventMove = false; } else EventMove_Timer -= diff; } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp index 6186369a3a0..187ff9b9dd7 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp @@ -459,7 +459,9 @@ void hyjalAI::SummonCreature(uint32 entry, float Base[4][3]) creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_NEAR_TOWER][0]+irand(-20, 20), SpawnPointSpecial[SPAWN_NEAR_TOWER][1]+irand(-20, 20), SpawnPointSpecial[SPAWN_NEAR_TOWER][2]+irand(-10, 10), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); if (creature) CAST_AI(hyjal_trashAI, creature->AI())->useFlyPath = true; - }else{//summon at gate + } + else + {//summon at gate creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_GARG_GATE][0]+irand(-10, 10), SpawnPointSpecial[SPAWN_GARG_GATE][1]+irand(-10, 10), SpawnPointSpecial[SPAWN_GARG_GATE][2]+irand(-10, 10), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); } break; @@ -910,6 +912,7 @@ void hyjalAI::UpdateAI(const uint32 diff) DoMeleeAttackIfReady(); } + void hyjalAI::JustDied(Unit* /*killer*/) { if (IsDummy)return; @@ -932,23 +935,20 @@ void hyjalAI::JustDied(Unit* /*killer*/) instance->SetData(DATA_RESET_RAIDDAMAGE, 0);//reset damage on die } } + void hyjalAI::HideNearPos(float x, float y) { - CellPair pair(Trinity::ComputeCellPair(x, y)); + CellCoord pair(Trinity::ComputeCellCoord(x, y)); Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); // First get all creatures. std::list<Creature*> creatures; Trinity::AllFriendlyCreaturesInGrid creature_check(me); Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid> creature_searcher(me, creatures, creature_check); - TypeContainerVisitor - <Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>, - GridTypeMapContainer> creature_visitor(creature_searcher); - // Get Creatures - cell.Visit(pair, creature_visitor, *(me->GetMap())); + TypeContainerVisitor <Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>, GridTypeMapContainer> creature_visitor(creature_searcher); + cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange()); if (!creatures.empty()) { @@ -959,18 +959,19 @@ void hyjalAI::HideNearPos(float x, float y) } } } + void hyjalAI::RespawnNearPos(float x, float y) { - CellPair p(Trinity::ComputeCellPair(x, y)); + CellCoord p(Trinity::ComputeCellCoord(x, y)); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::RespawnDo u_do; Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(me, u_do); TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker); - cell.Visit(p, obj_worker, *me->GetMap()); + cell.Visit(p, obj_worker, *me->GetMap(), *me, me->GetGridActivationRange()); } + void hyjalAI::WaypointReached(uint32 i) { if (i == 1 || (i == 0 && me->GetEntry() == THRALL)) @@ -992,9 +993,8 @@ void hyjalAI::WaypointReached(uint32 i) } //do some talking //all alive guards walk near here - CellPair pair(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); + CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); // First get all creatures. @@ -1005,7 +1005,7 @@ void hyjalAI::WaypointReached(uint32 i) <Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>, GridTypeMapContainer> creature_visitor(creature_searcher); - cell.Visit(pair, creature_visitor, *(me->GetMap())); + cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange()); if (!creatures.empty()) { @@ -1034,9 +1034,8 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff) { if (TeleportTimer <= diff) { - CellPair pair(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); + CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); std::list<Creature*> creatures; @@ -1046,7 +1045,7 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff) <Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>, GridTypeMapContainer> creature_visitor(creature_searcher); - cell.Visit(pair, creature_visitor, *(me->GetMap())); + cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange()); if (!creatures.empty()) { diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp index ef75307c625..748d0dfa071 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp @@ -1202,7 +1202,7 @@ public: me->GetPosition(x, y, z); z = me->GetMap()->GetHeight(x, y, z); me->GetMotionMaster()->MovePoint(0, x, y, z); - me->GetMap()->CreatureRelocation(me, x, y, z, 0); + me->SetPosition(x, y, z, 0); } void EnterCombat(Unit* /*who*/) {} @@ -1321,7 +1321,7 @@ public: me->GetPosition(x, y, z); z = me->GetMap()->GetHeight(x, y, z); me->GetMotionMaster()->MovePoint(0, x, y, z); - me->GetMap()->CreatureRelocation(me, x, y, z, 0); + me->SetPosition(x, y, z, 0); hyjal_trashAI::JustDied(victim); } diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp index dd2531d5aad..4cc1069b838 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp @@ -1073,7 +1073,7 @@ public: if (!target->HasAura(SPELL_DIGESTIVE_ACID)) { - me->GetMap()->CreatureRelocation(me, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); + me->SetPosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); if (Creature* pPortal = me->SummonCreature(MOB_SMALL_PORTAL, *me, TEMPSUMMON_CORPSE_DESPAWN)) { pPortal->SetReactState(REACT_PASSIVE); @@ -1185,7 +1185,7 @@ public: if (!target->HasAura(SPELL_DIGESTIVE_ACID)) { - me->GetMap()->CreatureRelocation(me, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); + me->SetPosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); if (Creature* pPortal = me->SummonCreature(MOB_GIANT_PORTAL, *me, TEMPSUMMON_CORPSE_DESPAWN)) { pPortal->SetReactState(REACT_PASSIVE); diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp index b0033aa582a..0ba6bdb1154 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp @@ -157,15 +157,15 @@ public: switch (urand(0, 2)) { case 0: - me->GetMap()->CreatureRelocation(me, -8340.782227f, 2083.814453f, 125.648788f, 0.0f); + me->SetPosition(-8340.782227f, 2083.814453f, 125.648788f, 0.0f); DoResetThreat(); break; case 1: - me->GetMap()->CreatureRelocation(me, -8341.546875f, 2118.504639f, 133.058151f, 0.0f); + me->SetPosition(-8341.546875f, 2118.504639f, 133.058151f, 0.0f); DoResetThreat(); break; case 2: - me->GetMap()->CreatureRelocation(me, -8318.822266f, 2058.231201f, 133.058151f, 0.0f); + me->SetPosition(-8318.822266f, 2058.231201f, 133.058151f, 0.0f); DoResetThreat(); break; } @@ -252,7 +252,7 @@ public: me->RemoveAllAuras(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetVisible(false); - me->GetMap()->CreatureRelocation(me, bossc->x, bossc->y, bossc->z, bossc->r); + me->SetPosition(bossc->x, bossc->y, bossc->z, bossc->r); Invisible = true; DoResetThreat(); DoStopAttack(); diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp index c501a060194..29b92957ace 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp @@ -216,15 +216,12 @@ struct boss_twinemperorsAI : public ScriptedAI if (pOtherBoss) { //me->MonsterYell("Teleporting ...", LANG_UNIVERSAL, 0); - float other_x = pOtherBoss->GetPositionX(); - float other_y = pOtherBoss->GetPositionY(); - float other_z = pOtherBoss->GetPositionZ(); - float other_o = pOtherBoss->GetOrientation(); - - Map* thismap = me->GetMap(); - thismap->CreatureRelocation(pOtherBoss, me->GetPositionX(), - me->GetPositionY(), me->GetPositionZ(), me->GetOrientation()); - thismap->CreatureRelocation(me, other_x, other_y, other_z, other_o); + Position thisPos; + thisPos.Relocate(me); + Position otherPos; + otherPos.Relocate(pOtherBoss); + pOtherBoss->SetPosition(thisPos); + me->SetPosition(otherPos); SetAfterTeleport(); CAST_AI(boss_twinemperorsAI, pOtherBoss->AI())->SetAfterTeleport(); diff --git a/src/server/scripts/Kalimdor/azshara.cpp b/src/server/scripts/Kalimdor/azshara.cpp index 88e46e7fb26..6fbc424f3d4 100644 --- a/src/server/scripts/Kalimdor/azshara.cpp +++ b/src/server/scripts/Kalimdor/azshara.cpp @@ -357,7 +357,7 @@ public: Map* map = me->GetMap(); if (map) { - map->CreatureRelocation(me, 3706.39f, -3969.15f, 35.9118f, 0); + me->SetPosition(3706.39f, -3969.15f, 35.9118f, 0); me->AI_SendMoveToPacket(3706.39f, -3969.15f, 35.9118f, 0, 0, 0); } //begin swimming and summon depth charges diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/ahnkahet.h b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/ahnkahet.h index e19054d2f46..e19054d2f46 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/ahnkahet.h +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/ahnkahet.h diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_amanitar.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_amanitar.cpp index cde97f8d37b..cde97f8d37b 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_amanitar.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_amanitar.cpp diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_elder_nadox.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp index a2371fa0121..a2371fa0121 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_elder_nadox.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp index bc4d4ba5eea..bc4d4ba5eea 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp index b2975797a02..b2975797a02 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_prince_taldaram.cpp index 9a7dc2f2cc9..9a7dc2f2cc9 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_prince_taldaram.cpp diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp index 5ba11dd5353..5ba11dd5353 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp index dea3d6eaede..605f3a11c8a 100644 --- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp @@ -118,7 +118,7 @@ public: return; float x=0.0f, y=0.0f, z=0.0f; - me->GetRespawnCoord(x, y, z); + me->GetRespawnPosition(x, y, z); if (uiCheckDistanceTimer <= uiDiff) uiCheckDistanceTimer = 5*IN_MILLISECONDS; diff --git a/src/server/scripts/Northrend/CMakeLists.txt b/src/server/scripts/Northrend/CMakeLists.txt index 63e714d17aa..53b47884e57 100644 --- a/src/server/scripts/Northrend/CMakeLists.txt +++ b/src/server/scripts/Northrend/CMakeLists.txt @@ -18,23 +18,23 @@ set(scripts_STAT_SRCS Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp Northrend/Ulduar/HallsOfLightning/boss_loken.cpp - Northrend/Ulduar/ulduar/boss_general_vezax.cpp - Northrend/Ulduar/ulduar/ulduar_teleporter.cpp - Northrend/Ulduar/ulduar/boss_thorim.cpp - Northrend/Ulduar/ulduar/boss_ignis.cpp - Northrend/Ulduar/ulduar/boss_algalon.cpp - Northrend/Ulduar/ulduar/instance_ulduar.cpp - Northrend/Ulduar/ulduar/boss_auriaya.cpp - Northrend/Ulduar/ulduar/boss_yoggsaron.cpp - Northrend/Ulduar/ulduar/boss_hodir.cpp - Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp - Northrend/Ulduar/ulduar/boss_flame_leviathan.cpp - Northrend/Ulduar/ulduar/boss_xt002.cpp - Northrend/Ulduar/ulduar/boss_mimiron.cpp - Northrend/Ulduar/ulduar/ulduar.h - Northrend/Ulduar/ulduar/boss_freya.cpp - Northrend/Ulduar/ulduar/boss_razorscale.cpp - Northrend/Ulduar/ulduar/boss_kologarn.cpp + Northrend/Ulduar/Ulduar/boss_general_vezax.cpp + Northrend/Ulduar/Ulduar/ulduar_teleporter.cpp + Northrend/Ulduar/Ulduar/boss_thorim.cpp + Northrend/Ulduar/Ulduar/boss_ignis.cpp + Northrend/Ulduar/Ulduar/boss_algalon.cpp + Northrend/Ulduar/Ulduar/instance_ulduar.cpp + Northrend/Ulduar/Ulduar/boss_auriaya.cpp + Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp + Northrend/Ulduar/Ulduar/boss_hodir.cpp + Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp + Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp + Northrend/Ulduar/Ulduar/boss_xt002.cpp + Northrend/Ulduar/Ulduar/boss_mimiron.cpp + Northrend/Ulduar/Ulduar/ulduar.h + Northrend/Ulduar/Ulduar/boss_freya.cpp + Northrend/Ulduar/Ulduar/boss_razorscale.cpp + Northrend/Ulduar/Ulduar/boss_kologarn.cpp Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp Northrend/Ulduar/HallsOfStone/halls_of_stone.h Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp @@ -142,13 +142,13 @@ set(scripts_STAT_SRCS Northrend/AzjolNerub/AzjolNerub/boss_krikthir_the_gatewatcher.cpp Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp - Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp - Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp - Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp - Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp - Northrend/AzjolNerub/ahnkahet/boss_elder_nadox.cpp - Northrend/AzjolNerub/ahnkahet/boss_amanitar.cpp - Northrend/AzjolNerub/ahnkahet/ahnkahet.h + Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp + Northrend/AzjolNerub/Ahnkahet/boss_prince_taldaram.cpp + Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp + Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp + Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp + Northrend/AzjolNerub/Ahnkahet/boss_amanitar.cpp + Northrend/AzjolNerub/Ahnkahet/ahnkahet.h Northrend/VioletHold/boss_zuramat.cpp Northrend/VioletHold/instance_violet_hold.cpp Northrend/VioletHold/boss_lavanthor.cpp diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp index 1ca1c69831c..be83c4d326a 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp @@ -284,7 +284,7 @@ public: if (m_uiPenetratingColdTimer <= uiDiff) { - me->CastCustomSpell(SPELL_PENETRATING_COLD, SPELLVALUE_MAX_TARGETS, RAID_MODE(2, 5)); + me->CastCustomSpell(SPELL_PENETRATING_COLD, SPELLVALUE_MAX_TARGETS, RAID_MODE(2, 5, 2, 5)); m_uiPenetratingColdTimer = 20*IN_MILLISECONDS; } else m_uiPenetratingColdTimer -= uiDiff; @@ -577,7 +577,7 @@ public: me->SetReactState(REACT_PASSIVE); me->SetFlying(true); me->SetDisplayId(25144); - me->SetSpeed(MOVE_RUN, 0.5, false); + me->SetSpeed(MOVE_RUN, 0.5f, false); me->GetMotionMaster()->MoveRandom(20.0f); DoCast(SPELL_FROST_SPHERE); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp index ec573f75bc6..df166c1bf04 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp @@ -490,11 +490,14 @@ public: void UpdateAI(const uint32 uiDiff) { - if (!UpdateVictim()) - return; - if (m_instance && m_instance->GetData(TYPE_JARAXXUS) != IN_PROGRESS) + { me->DespawnOrUnsummon(); + return; + } + + if (!UpdateVictim()) + return; if (m_uiShivanSlashTimer <= uiDiff) { diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp index adbe59555b6..68223f170c5 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp @@ -114,6 +114,8 @@ struct outroPosition { { 0, 0 }, { 0.0f, 0.0f, 0.0f, 0.0f } } }; +Position const CrucibleSummonPos = {5672.294f,2520.686f, 713.4386f, 0.9599311f}; + #define DATA_THREE_FACED 1 class boss_devourer_of_souls : public CreatureScript @@ -154,6 +156,8 @@ class boss_devourer_of_souls : public CreatureScript { DoScriptText(RAND(SAY_FACE_ANGER_AGGRO, SAY_FACE_DESIRE_AGGRO), me); + if (!me->FindNearestCreature(NPC_CRUCIBLE_OF_SOULS, 60)) // Prevent double spawn + instance->instance->SummonCreature(NPC_CRUCIBLE_OF_SOULS, CrucibleSummonPos); events.ScheduleEvent(EVENT_PHANTOM_BLAST, 5000); events.ScheduleEvent(EVENT_MIRRORED_SOUL, 8000); events.ScheduleEvent(EVENT_WELL_OF_SOULS, 30000); diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.h b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.h index 85062cc2901..9f34e412847 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.h +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.h @@ -46,5 +46,6 @@ enum Creatures NPC_CHAMPION_3_HORDE = 37588, NPC_CHAMPION_1_ALLIANCE = 37496, NPC_CHAMPION_2_ALLIANCE = 37497, + NPC_CRUCIBLE_OF_SOULS = 37094, }; #endif diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp index 4c74488b6a6..d8fddad41dc 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp @@ -270,7 +270,7 @@ class spell_garfrost_permafrost : public SpellScriptLoader { for (std::list<GameObject*>::const_iterator itr = blockList.begin(); itr != blockList.end(); ++itr) { - if ((*itr)->isVisibleForInState(target)) + if (!(*itr)->IsInvisibleDueToDespawn()) { if ((*itr)->IsInBetween(caster, target, 4.0f)) { diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp index b351d7de9d7..4a5d609eb67 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -239,25 +239,6 @@ class boss_blood_council_controller : public CreatureScript _invocationOrder[1] = InvocationData(instance->GetData64(DATA_PRINCE_KELESETH_GUID), SPELL_INVOCATION_OF_BLOOD_KELESETH, EMOTE_KELESETH_INVOCATION, 71080); _invocationOrder[2] = InvocationData(instance->GetData64(DATA_PRINCE_TALDARAM_GUID), SPELL_INVOCATION_OF_BLOOD_TALDARAM, EMOTE_TALDARAM_INVOCATION, 71081); } - - if (IsHeroic()) - { - Map::PlayerList const &PlList = me->GetMap()->GetPlayers(); - if (PlList.isEmpty()) - return; - - for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i) - { - if (Player* player = i->getSource()) - { - if (player->isGameMaster()) - continue; - - if (player->isAlive()) - player->AddAura(SPELL_SHADOW_PRISON_DUMMY, player); - } - } - } } void SetData(uint32 /*type*/, uint32 data) @@ -297,8 +278,6 @@ class boss_blood_council_controller : public CreatureScript killer->Kill(prince); } } - - instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_SHADOW_PRISON_DUMMY); } void UpdateAI(uint32 const diff) @@ -409,8 +388,6 @@ class boss_prince_keleseth_icc : public CreatureScript me->SetHealth(_spawnHealth); instance->SetData(DATA_ORB_WHISPERER_ACHIEVEMENT, uint32(true)); me->SetReactState(REACT_DEFENSIVE); - if (IsHeroic()) - DoCast(me, SPELL_SHADOW_PRISON); } void EnterCombat(Unit* /*who*/) @@ -421,6 +398,12 @@ class boss_prince_keleseth_icc : public CreatureScript events.ScheduleEvent(EVENT_BERSERK, 600000); events.ScheduleEvent(EVENT_SHADOW_RESONANCE, urand(10000, 15000)); events.ScheduleEvent(EVENT_SHADOW_LANCE, 2000); + + if (IsHeroic()) + { + me->AddAura(SPELL_SHADOW_PRISON, me); + DoCast(me, SPELL_SHADOW_PRISON_DUMMY); + } } void JustDied(Unit* /*killer*/) @@ -629,8 +612,6 @@ class boss_prince_taldaram_icc : public CreatureScript me->SetHealth(_spawnHealth); instance->SetData(DATA_ORB_WHISPERER_ACHIEVEMENT, uint32(true)); me->SetReactState(REACT_DEFENSIVE); - if (IsHeroic()) - DoCast(me, SPELL_SHADOW_PRISON); } void MoveInLineOfSight(Unit* /*who*/) @@ -645,6 +626,8 @@ class boss_prince_taldaram_icc : public CreatureScript events.ScheduleEvent(EVENT_BERSERK, 600000); events.ScheduleEvent(EVENT_GLITTERING_SPARKS, urand(12000, 15000)); events.ScheduleEvent(EVENT_CONJURE_FLAME, 20000); + if (IsHeroic()) + me->AddAura(SPELL_SHADOW_PRISON, me); } void JustDied(Unit* /*killer*/) @@ -852,8 +835,6 @@ class boss_prince_valanar_icc : public CreatureScript me->SetHealth(me->GetMaxHealth()); instance->SetData(DATA_ORB_WHISPERER_ACHIEVEMENT, uint32(true)); me->SetReactState(REACT_DEFENSIVE); - if (IsHeroic()) - DoCast(me, SPELL_SHADOW_PRISON); } void MoveInLineOfSight(Unit* /*who*/) @@ -868,6 +849,8 @@ class boss_prince_valanar_icc : public CreatureScript events.ScheduleEvent(EVENT_BERSERK, 600000); events.ScheduleEvent(EVENT_KINETIC_BOMB, urand(18000, 24000)); events.ScheduleEvent(EVENT_SHOCK_VORTEX, urand(15000, 20000)); + if (IsHeroic()) + me->AddAura(SPELL_SHADOW_PRISON, me); } void JustDied(Unit* /*killer*/) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp index b117dadf045..fd693789064 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp @@ -291,6 +291,10 @@ class npc_stinky_icc : public CreatureScript _events.Reset(); _events.ScheduleEvent(EVENT_DECIMATE, urand(20000, 25000)); _events.ScheduleEvent(EVENT_MORTAL_WOUND, urand(3000, 7000)); + } + + void EnterCombat(Unit* /*target*/) + { DoCast(me, SPELL_PLAGUE_STENCH); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp index 9e4079a7a15..ae6f3feb57f 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp @@ -375,7 +375,7 @@ class boss_lady_deathwhisper : public CreatureScript { me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true); - events.ScheduleEvent(EVENT_P2_SUMMON_WAVE, urand(30000, 60000), 0, PHASE_TWO); + events.ScheduleEvent(EVENT_P2_SUMMON_WAVE, 45000, 0, PHASE_TWO); } } } @@ -438,7 +438,7 @@ class boss_lady_deathwhisper : public CreatureScript case EVENT_DEATH_AND_DECAY: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM)) DoCast(target, SPELL_DEATH_AND_DECAY); - events.ScheduleEvent(EVENT_DEATH_AND_DECAY, urand(10000, 12000)); + events.ScheduleEvent(EVENT_DEATH_AND_DECAY, urand(22000, 30000)); break; case EVENT_DOMINATE_MIND_H: Talk(SAY_DOMINATE_MIND); @@ -449,7 +449,7 @@ class boss_lady_deathwhisper : public CreatureScript break; case EVENT_P1_SUMMON_WAVE: SummonWaveP1(); - events.ScheduleEvent(EVENT_P1_SUMMON_WAVE, 60000, 0, PHASE_ONE); + events.ScheduleEvent(EVENT_P1_SUMMON_WAVE, IsHeroic() ? 45000 : 60000, 0, PHASE_ONE); break; case EVENT_P1_SHADOW_BOLT: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM)) @@ -485,7 +485,7 @@ class boss_lady_deathwhisper : public CreatureScript break; case EVENT_P2_SUMMON_WAVE: SummonWaveP2(); - events.ScheduleEvent(EVENT_P2_SUMMON_WAVE, 60000, 0, PHASE_TWO); + events.ScheduleEvent(EVENT_P2_SUMMON_WAVE, 45000, 0, PHASE_TWO); break; case EVENT_BERSERK: DoCast(me, SPELL_BERSERK); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index a6e3e78c96a..a84471d132b 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -78,6 +78,7 @@ enum Spells // Slime Puddle SPELL_GROW_STACKER = 70345, + SPELL_GROW = 70347, SPELL_SLIME_PUDDLE_AURA = 70343, // Gas Cloud @@ -253,6 +254,9 @@ class boss_professor_putricide : public CreatureScript case NPC_GROWING_OOZE_PUDDLE: summon->CastSpell(summon, SPELL_GROW_STACKER, true); summon->CastSpell(summon, SPELL_SLIME_PUDDLE_AURA, true); + // blizzard casts this spell 7 times initially (confirmed in sniff) + for (uint8 i = 0; i < 7; ++i) + summon->CastSpell(summon, SPELL_GROW, true); break; case NPC_GAS_CLOUD: // no possible aura seen in sniff adding the aurastate @@ -811,38 +815,45 @@ class spell_putricide_ooze_channel : public SpellScriptLoader } }; +class ExactDistanceCheck +{ + public: + ExactDistanceCheck(Unit* source, float dist) : _source(source), _dist(dist) {} + + bool operator()(Unit* unit) + { + return _source->GetExactDist2d(unit) > _dist; + } + + private: + Unit* _source; + float _dist; +}; + class spell_putricide_slime_puddle : public SpellScriptLoader { public: spell_putricide_slime_puddle() : SpellScriptLoader("spell_putricide_slime_puddle") { } - class spell_putricide_slime_puddle_AuraScript : public AuraScript + class spell_putricide_slime_puddle_SpellScript : public SpellScript { - PrepareAuraScript(spell_putricide_slime_puddle_AuraScript); + PrepareSpellScript(spell_putricide_slime_puddle_SpellScript); - void HandleTriggerSpell(AuraEffect const* aurEff) + void ScaleRange(std::list<Unit*>& targets) { - PreventDefaultAction(); - if (Unit* caster = GetCaster()) - { - int32 radiusMod = 4; - if (Aura* size = caster->GetAura(70347)) - radiusMod += size->GetStackAmount(); - - uint32 triggerSpellId = GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell; - caster->CastCustomSpell(triggerSpellId, SPELLVALUE_RADIUS_MOD, radiusMod * 100, caster, true); - } + targets.remove_if(ExactDistanceCheck(GetCaster(), 2.5f * GetCaster()->GetFloatValue(OBJECT_FIELD_SCALE_X))); } void Register() { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_putricide_slime_puddle_AuraScript::HandleTriggerSpell, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + OnUnitTargetSelect += SpellUnitTargetFn(spell_putricide_slime_puddle_SpellScript::ScaleRange, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); + OnUnitTargetSelect += SpellUnitTargetFn(spell_putricide_slime_puddle_SpellScript::ScaleRange, EFFECT_1, TARGET_UNIT_DEST_AREA_ENTRY); } }; - AuraScript* GetAuraScript() const + SpellScript* GetSpellScript() const { - return new spell_putricide_slime_puddle_AuraScript(); + return new spell_putricide_slime_puddle_SpellScript(); } }; @@ -1047,7 +1058,6 @@ class spell_putricide_unbound_plague : public SpellScriptLoader return; uint32 plagueId = sSpellMgr->GetSpellIdForDifficulty(SPELL_UNBOUND_PLAGUE, GetCaster()); - uint32 searcherId = sSpellMgr->GetSpellIdForDifficulty(SPELL_UNBOUND_PLAGUE_SEARCHER, GetCaster()); if (!GetHitUnit()->HasAura(plagueId)) { @@ -1057,10 +1067,10 @@ class spell_putricide_unbound_plague : public SpellScriptLoader { if (Aura* newPlague = professor->AddAura(plagueId, GetHitUnit())) { - newPlague->SetMaxDuration(oldPlague->GetDuration()); + newPlague->SetMaxDuration(oldPlague->GetMaxDuration()); newPlague->SetDuration(oldPlague->GetDuration()); oldPlague->Remove(); - GetCaster()->RemoveAurasDueToSpell(searcherId); + GetCaster()->RemoveAurasDueToSpell(SPELL_UNBOUND_PLAGUE_SEARCHER); GetCaster()->CastSpell(GetCaster(), SPELL_PLAGUE_SICKNESS, true); GetCaster()->CastSpell(GetCaster(), SPELL_UNBOUND_PLAGUE_PROTECTION, true); professor->CastSpell(GetHitUnit(), SPELL_UNBOUND_PLAGUE_SEARCHER, true); @@ -1110,14 +1120,14 @@ class spell_putricide_eat_ooze : public SpellScriptLoader if (Aura* grow = target->GetAura(uint32(GetEffectValue()))) { - if (grow->GetStackAmount() < 4) + if (grow->GetStackAmount() < 3) { target->RemoveAurasDueToSpell(SPELL_GROW_STACKER); target->RemoveAura(grow); - target->DespawnOrUnsummon(); + target->DespawnOrUnsummon(1); } else - grow->ModStackAmount(-4); + grow->ModStackAmount(-3); } } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index dca53f1a5e7..29c3276467b 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -242,6 +242,9 @@ class boss_sindragosa : public CreatureScript { if (action == ACTION_START_FROSTWYRM) { + if (TempSummon* summon = me->ToTempSummon()) + summon->SetTempSummonType(TEMPSUMMON_DEAD_DESPAWN); + instance->SetData(DATA_SINDRAGOSA_FROSTWYRMS, 255); if (me->isDead()) return; @@ -968,10 +971,10 @@ class spell_sindragosa_s_fury : public SpellScriptLoader { PreventHitDefaultEffect(effIndex); - if (!GetHitUnit()->isAlive()) + if (!GetHitUnit()->isAlive() || !_targetCount) return; - float resistance = float(GetHitUnit()->GetResistance(GetFirstSchoolInMask(SpellSchoolMask(GetSpellInfo()->SchoolMask)))); + float resistance = float(GetHitUnit()->GetResistance(SpellSchoolMask(GetSpellInfo()->SchoolMask))); uint32 minResistFactor = uint32((resistance / (resistance + 510.0f))* 10.0f) * 2; uint32 randomResist = urand(0, (9 - minResistFactor) * 100)/100 + minResistFactor; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index 1688624be91..38f334058b8 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -1227,7 +1227,7 @@ class npc_tirion_fordring_tft : public CreatureScript SetEquipmentSlots(true); // remove glow on ashbringer } - void sGossipSelect(Player* player, uint32 sender, uint32 action) + void sGossipSelect(Player* /*player*/, uint32 sender, uint32 action) { if (me->GetCreatureInfo()->GossipMenuId == sender && !action) { @@ -1407,14 +1407,14 @@ class npc_raging_spirit : public CreatureScript DoCast(me, SPELL_BOSS_HITTIN_YA, true); } - void IsSummonedBy(Unit* summoner) + void IsSummonedBy(Unit* /*summoner*/) { // player is the spellcaster so register summon manually if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) lichKing->AI()->JustSummoned(me); } - void JustDied(Unit* killer) + void JustDied(Unit* /*killer*/) { if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING))) lichKing->AI()->SummonedCreatureDespawn(me); @@ -1931,7 +1931,7 @@ class npc_spirit_bomb : public CreatureScript { } - void IsSummonedBy(Unit* summoner) + void IsSummonedBy(Unit* /*summoner*/) { float destX, destY, destZ; me->GetPosition(destX, destY); @@ -1954,7 +1954,7 @@ class npc_spirit_bomb : public CreatureScript { } - void UpdateAI(uint32 const diff) + void UpdateAI(uint32 const /*diff*/) { UpdateVictim(); // no melee attacks @@ -1983,7 +1983,7 @@ class npc_broken_frostmourne : public CreatureScript _events.Reset(); } - void IsSummonedBy(Unit* summoner) + void IsSummonedBy(Unit* /*summoner*/) { _events.SetPhase(PHASE_OUTRO); _events.ScheduleEvent(EVENT_OUTRO_KNOCK_BACK, 3000, 0, PHASE_OUTRO); @@ -2087,7 +2087,6 @@ class spell_the_lich_king_necrotic_plague : public SpellScriptLoader void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - Unit* newCaster = GetTarget(); switch (GetTargetApplication()->GetRemoveMode()) { case AURA_REMOVE_BY_ENEMY_SPELL: @@ -2250,7 +2249,7 @@ class spell_the_lich_king_shadow_trap_visual : public SpellScriptLoader { PrepareAuraScript(spell_the_lich_king_shadow_trap_visual_AuraScript); - void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes mode) + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE) GetTarget()->CastSpell(GetTarget(), SPELL_SHADOW_TRAP_AURA, TRIGGERED_NONE); @@ -2633,7 +2632,7 @@ class spell_the_lich_king_cast_back_to_caster : public SpellScriptLoader { PrepareSpellScript(spell_the_lich_king_cast_back_to_caster_SpellScript); - void HandleScript(SpellEffIndex effIndex) + void HandleScript(SpellEffIndex /*effIndex*/) { GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp index 41bed882166..1242e90c2f3 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp @@ -78,6 +78,13 @@ class at_frozen_throne_teleport : public AreaTriggerScript bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) { + if (player->isInCombat()) + { + if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(FROZEN_THRONE_TELEPORT)) + Spell::SendCastResult(player, spell, 0, SPELL_FAILED_AFFECTING_COMBAT); + return true; + } + if (InstanceScript* instance = player->GetInstanceScript()) if (instance->GetBossState(DATA_PROFESSOR_PUTRICIDE) == DONE && instance->GetBossState(DATA_BLOOD_QUEEN_LANA_THEL) == DONE && diff --git a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp index 9c3c9156d63..96c061f4c98 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp @@ -683,7 +683,7 @@ public: // Note: summon must be done by trigger and not by KT. // Otherwise, they attack immediately as KT is in combat. - for (uint8 i = 0; i <= MAX_ABOMINATIONS; ++i) + for (uint8 i = 0; i < MAX_ABOMINATIONS; ++i) { if (Creature* sum = trigger->SummonCreature(NPC_ABOMINATION, PosAbominations[i])) { @@ -692,7 +692,7 @@ public: sum->SetReactState(REACT_DEFENSIVE); } } - for (uint8 i = 0; i <= MAX_WASTES; ++i) + for (uint8 i = 0; i < MAX_WASTES; ++i) { if (Creature* sum = trigger->SummonCreature(NPC_WASTE, PosWastes[i])) { @@ -701,7 +701,7 @@ public: sum->SetReactState(REACT_DEFENSIVE); } } - for (uint8 i = 0; i <= MAX_WEAVERS; ++i) + for (uint8 i = 0; i < MAX_WEAVERS; ++i) { if (Creature* sum = trigger->SummonCreature(NPC_WEAVER, PosWeavers[i])) { diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp index 09fe37d140c..4d4b8e90e7b 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp @@ -86,6 +86,7 @@ public: return true; } + //TODO: this should be handled in map, maybe add a summon function in map // There is no other way afaik... void SpawnGameObject(uint32 entry, Position& pos) { @@ -98,7 +99,7 @@ public: return; } - instance->Add(go); + instance->AddToMap(go); } void OnGameObjectCreate(GameObject* go) diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp index 1c7b538eb02..a8edd40d6b5 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp @@ -238,7 +238,7 @@ public: for (uint8 n = 0; n < 3; ++n) time[n] = 0; me->GetMotionMaster()->Clear(); - me->GetMap()->CreatureRelocation(me, CenterOfRoom.GetPositionX(), CenterOfRoom.GetPositionY(), CenterOfRoom.GetPositionZ(), CenterOfRoom.GetOrientation()); + me->SetPosition(CenterOfRoom.GetPositionX(), CenterOfRoom.GetPositionY(), CenterOfRoom.GetPositionZ(), CenterOfRoom.GetOrientation()); DoCast(me, SPELL_TELESTRA_BACK); me->SetVisible(true); if (Phase == 1) diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_algalon.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon.cpp index 3888cc43bc9..3888cc43bc9 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_algalon.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon.cpp diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp index 2e2ca25385c..a8a4fad5e4e 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp @@ -56,8 +56,9 @@ enum AssemblySpells SPELL_CHAIN_LIGHTNING = 61879, SPELL_OVERLOAD = 61869, SPELL_LIGHTNING_WHIRL = 61915, - SPELL_LIGHTNING_TENDRILS = 61887, - SPELL_LIGHTNING_TENDRILS_SELF_VISUAL = 61883, + SPELL_LIGHTNING_TENDRILS_10M = 61887, + SPELL_LIGHTNING_TENDRILS_25M = 63486, + SPELL_LIGHTNING_TENDRILS_VISUAL = 61883, SPELL_STORMSHIELD = 64187, }; @@ -215,7 +216,6 @@ class boss_steelbreaker : public CreatureScript { _Reset(); phase = 0; - me->ResetLootMode(); me->RemoveAllAuras(); RespawnEncounter(instance, me); } @@ -342,7 +342,6 @@ class boss_runemaster_molgeim : public CreatureScript { _Reset(); phase = 0; - me->ResetLootMode(); me->RemoveAllAuras(); RespawnEncounter(instance, me); } @@ -575,9 +574,10 @@ class boss_stormcaller_brundir : public CreatureScript { _Reset(); phase = 0; - me->ResetLootMode(); me->RemoveAllAuras(); me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_INTERRUPT, false); // Should be interruptable unless overridden by spell (Overload) + me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_STUN, false); // Reset immumity, Brundir should be stunnable by default RespawnEncounter(instance, me); } @@ -609,6 +609,7 @@ class boss_stormcaller_brundir : public CreatureScript { DoCast(me, SPELL_STORMSHIELD); events.RescheduleEvent(EVENT_LIGHTNING_TENDRILS, urand(50000, 60000)); + me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_STUN, true); // Apply immumity to stuns } break; @@ -677,10 +678,10 @@ class boss_stormcaller_brundir : public CreatureScript break; case EVENT_LIGHTNING_TENDRILS: DoScriptText(SAY_BRUNDIR_FLIGHT, me); - DoCast(SPELL_LIGHTNING_TENDRILS); + DoCast(RAID_MODE(SPELL_LIGHTNING_TENDRILS_10M, SPELL_LIGHTNING_TENDRILS_25M)); + DoCast(SPELL_LIGHTNING_TENDRILS_VISUAL); me->AttackStop(); - me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); - DoCast(SPELL_LIGHTNING_TENDRILS_SELF_VISUAL); + //me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); me->GetMotionMaster()->Initialize(); me->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), FINAL_FLIGHT_Z); events.DelayEvents(35000); @@ -707,11 +708,12 @@ class boss_stormcaller_brundir : public CreatureScript events.ScheduleEvent(EVENT_GROUND, 2500); break; case EVENT_GROUND: - me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); - me->RemoveAurasDueToSpell(SPELL_LIGHTNING_TENDRILS); - me->RemoveAurasDueToSpell(SPELL_LIGHTNING_TENDRILS_SELF_VISUAL); + //me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + me->RemoveAurasDueToSpell(RAID_MODE(SPELL_LIGHTNING_TENDRILS_10M, SPELL_LIGHTNING_TENDRILS_25M)); + me->RemoveAurasDueToSpell(SPELL_LIGHTNING_TENDRILS_VISUAL); DoStartMovement(me->getVictim()); events.CancelEvent(EVENT_GROUND); + me->getThreatManager().resetAllAggro(); break; case EVENT_MOVE_POSITION: if (me->IsWithinMeleeRange(me->getVictim())) diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_auriaya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp index bcc417c50cd..bcc417c50cd 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_auriaya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp index ec336d3402c..ad79d1b56cc 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp @@ -757,7 +757,7 @@ class boss_flame_leviathan_safety_container : public CreatureScript me->GetPosition(x, y, z); z = me->GetMap()->GetHeight(x, y, z); me->GetMotionMaster()->MovePoint(0, x, y, z); - me->GetMap()->CreatureRelocation(me, x, y, z, 0); + me->SetPosition(x, y, z, 0); } void UpdateAI(uint32 const /*diff*/) @@ -1680,7 +1680,8 @@ class spell_pursue : public SpellScriptLoader void FilterTargetsSubsequently(std::list<Unit*>& targets) { targets.clear(); - targets.push_back(_target); + if(_target) + targets.push_back(_target); } void HandleScript(SpellEffIndex /*eff*/) diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp index 86ea898e6ee..e7d8b070e53 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_freya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp @@ -24,11 +24,6 @@ #include "GridNotifiersImpl.h" #include "ulduar.h" -/* - * **** TODO **** - * Achievements * - */ - enum FreyaYells { // Freya @@ -188,6 +183,7 @@ enum FreyaNpcs enum FreyaActions { ACTION_ELDER_DEATH = 1, + ACTION_ELDER_FREYA_KILLED = 2, }; enum FreyaEvents @@ -286,7 +282,6 @@ class boss_freya : public CreatureScript uint32 deforestation[6][2]; uint32 elementalTimer[2]; uint32 diffTimer; - uint32 waveTime; uint8 trioWaveCount; uint8 trioWaveController; uint8 waveCount; @@ -295,14 +290,12 @@ class boss_freya : public CreatureScript bool checkElementalAlive[2]; bool trioDefeated[2]; - bool waveInProgress; bool random[3]; void Reset() { _Reset(); summons.clear(); - waveTime = 0; trioWaveCount = 0; trioWaveController = 0; waveCount = 0; @@ -319,7 +312,6 @@ class boss_freya : public CreatureScript checkElementalAlive[n] = true; trioDefeated[n] = false; } - waveInProgress = false; for (uint8 n = 0; n < 3; ++n) random[n] = false; } @@ -329,35 +321,12 @@ class boss_freya : public CreatureScript DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), me); } - void DamageTaken(Unit* /*who*/, uint32& damage) + void DamageTaken(Unit* who, uint32& damage) { - if (damage >= me->GetHealth() && instance) + if (damage >= me->GetHealth()) { damage = 0; - DoScriptText(SAY_DEATH, me); - me->SetReactState(REACT_PASSIVE); - _JustDied(); - me->RemoveAllAuras(); - me->AttackStop(); - me->setFaction(35); - me->DeleteThreatList(); - me->CombatStop(true); - me->DespawnOrUnsummon(7500); - me->CastSpell(me, SPELL_KNOCK_ON_WOOD_CREDIT, true); - - Creature* Elder[3]; - for (uint8 n = 0; n < 3; ++n) - { - Elder[n] = ObjectAccessor::GetCreature(*me, instance->GetData64(BOSS_BRIGHTLEAF + n)); - if (Elder[n] && Elder[n]->isAlive()) - { - Elder[n]->setFaction(35); - Elder[n]->RemoveAllAuras(); - Elder[n]->AttackStop(); - Elder[n]->CombatStop(true); - Elder[n]->DeleteThreatList(); - } - } + JustDied(who); } } @@ -466,8 +435,6 @@ class boss_freya : public CreatureScript events.ScheduleEvent(EVENT_UNSTABLE_ENERGY, urand(15000, 20000)); break; case EVENT_WAVE: - waveTime = 0; - waveInProgress = true; SpawnWave(); if (waveCount < 6) events.ScheduleEvent(EVENT_WAVE, WAVE_TIME); @@ -501,9 +468,6 @@ class boss_freya : public CreatureScript diffTimer += diff; // For getting time difference for Deforestation achievement - if (waveInProgress) - waveTime += diff; // Time from the last wave - // Elementals must be killed within 12 seconds of each other, or they will all revive and heal Creature* Elemental[3][2]; for (uint8 i = 0; i < 2; ++i) @@ -547,7 +511,6 @@ class boss_freya : public CreatureScript trioDefeated[i] = true; Elemental[n][i]->CastSpell(me, SPELL_REMOVE_10STACK, true); } - TimeCheck(); } } } @@ -637,9 +600,32 @@ class boss_freya : public CreatureScript /* 25N */ {62952, 62954, 62956, 62958} }; - who->CastSpell((Unit*)NULL, summonSpell[me->GetMap()->GetDifficulty()][elderCount], true); + me->CastSpell((Unit*)NULL, summonSpell[me->GetMap()->GetDifficulty()][elderCount], true); + DoScriptText(SAY_DEATH, me); + me->SetReactState(REACT_PASSIVE); _JustDied(); + me->RemoveAllAuras(); + me->AttackStop(); + me->setFaction(35); + me->DeleteThreatList(); + me->CombatStop(true); + me->DespawnOrUnsummon(7500); + me->CastSpell(me, SPELL_KNOCK_ON_WOOD_CREDIT, true); + + Creature* Elder[3]; + for (uint8 n = 0; n < 3; ++n) + { + Elder[n] = ObjectAccessor::GetCreature(*me, instance->GetData64(BOSS_BRIGHTLEAF + n)); + if (Elder[n] && Elder[n]->isAlive()) + { + Elder[n]->RemoveAllAuras(); + Elder[n]->AttackStop(); + Elder[n]->CombatStop(true); + Elder[n]->DeleteThreatList(); + Elder[n]->GetAI()->DoAction(ACTION_ELDER_FREYA_KILLED); + } + } } void JustSummoned(Creature* summoned) @@ -657,6 +643,7 @@ class boss_freya : public CreatureScript break; case NPC_DETONATING_LASHER: case NPC_ANCIENT_CONSERVATOR: + default: summons.push_back(summoned->GetGUID()); break; } @@ -679,29 +666,14 @@ class boss_freya : public CreatureScript summoned->CastSpell(who, SPELL_DETONATE, true); summoned->ForcedDespawn(5000); summons.remove(summoned->GetGUID()); - TimeCheck(); break; case NPC_ANCIENT_CONSERVATOR: summoned->CastSpell(me, SPELL_REMOVE_25STACK, true); summoned->ForcedDespawn(5000); summons.remove(summoned->GetGUID()); - TimeCheck(); break; } } - - void TimeCheck() - { - if (waveCount >= 6) - return; - - waveInProgress = false; - uint32 timeDifference = WAVE_TIME - waveTime; - if (timeDifference <= TIME_DIFFERENCE) - events.RescheduleEvent(EVENT_WAVE, timeDifference); - else - events.RescheduleEvent(EVENT_WAVE, TIME_DIFFERENCE); - } }; CreatureAI* GetAI(Creature* creature) const @@ -811,6 +783,10 @@ class boss_elder_brightleaf : public CreatureScript ++elderCount; lumberjack = true; break; + case ACTION_ELDER_FREYA_KILLED: + me->DespawnOrUnsummon(10000); + _JustDied(); + break; } } @@ -933,6 +909,10 @@ class boss_elder_stonebark : public CreatureScript ++elderCount; lumberjack = true; break; + case ACTION_ELDER_FREYA_KILLED: + me->DespawnOrUnsummon(10000); + _JustDied(); + break; } } @@ -1042,6 +1022,10 @@ class boss_elder_ironbranch : public CreatureScript ++elderCount; lumberjack = true; break; + case ACTION_ELDER_FREYA_KILLED: + me->DespawnOrUnsummon(10000); + _JustDied(); + break; } } diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_general_vezax.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp index 7d00c0e59fc..7d00c0e59fc 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_general_vezax.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_hodir.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp index bb21da94bc5..bb21da94bc5 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_hodir.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_ignis.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp index b8876ae577a..b8876ae577a 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_ignis.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp index 5da1c485986..5da1c485986 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_kologarn.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index 11b7c54975e..11b7c54975e 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_razorscale.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp index 0e3a8926203..0e3a8926203 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_razorscale.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_thorim.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp index f993c419b8c..f993c419b8c 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_thorim.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_xt002.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp index ae803b24642..ae803b24642 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_xt002.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_yoggsaron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp index e4b21e1f66e..e4b21e1f66e 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_yoggsaron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp index 3c5697a7995..3c5697a7995 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/instance_ulduar.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/ulduar.h b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h index f11212d535e..f11212d535e 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/ulduar.h +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/ulduar_teleporter.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar_teleporter.cpp index 05b1e395d1e..05b1e395d1e 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/ulduar_teleporter.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar_teleporter.cpp diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp index 55211f3f047..dc2d34326a7 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp @@ -130,7 +130,7 @@ public: me->SetHealth(0); me->InterruptNonMeleeSpells(true); me->RemoveAllAuras(); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->GetMotionMaster()->MovementExpired(false); me->GetMotionMaster()->MoveIdle(); me->SetStandState(UNIT_STAND_STATE_DEAD); @@ -152,7 +152,7 @@ public: { bIsUndead = true; bEventInProgress = false; - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->UpdateEntry(MOB_INGVAR_UNDEAD); me->SetInCombatWith(me->getVictim()); me->GetMotionMaster()->MoveChase(me->getVictim()); diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp index 1b70de6244e..45534824860 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp @@ -48,7 +48,7 @@ enum Yells }; enum Creatures { - CREATURE_ARTHAS = 24266, // Image of Arthas + CREATURE_ARTHAS = 29280, // Image of Arthas CREATURE_SVALA_SORROWGRAVE = 26668, // Svala after transformation CREATURE_SVALA = 29281, // Svala before transformation CREATURE_RITUAL_CHANNELER = 27281 @@ -136,7 +136,6 @@ public: if (Creature* pArthas = me->SummonCreature(CREATURE_ARTHAS, ArthasPos, TEMPSUMMON_MANUAL_DESPAWN)) { pArthas->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - pArthas->SetFloatValue(OBJECT_FIELD_SCALE_X, 5); uiArthasGUID = pArthas->GetGUID(); } } diff --git a/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp b/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp index 41d43a08f5d..41e80b1b777 100644 --- a/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp +++ b/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp @@ -260,7 +260,7 @@ class mob_frozen_orb_stalker : public CreatureScript { Position pos; me->GetNearPoint(toravon, pos.m_positionX, pos.m_positionY, pos.m_positionZ, 0.0f, 10.0f, 0.0f); - me->SetPosition(pos, true); + me->SetPosition(pos); DoCast(me, SPELL_FROZEN_ORB_SUMMON); } } diff --git a/src/server/scripts/Northrend/dalaran.cpp b/src/server/scripts/Northrend/dalaran.cpp index be9e9308f4f..8ff5a314dcc 100644 --- a/src/server/scripts/Northrend/dalaran.cpp +++ b/src/server/scripts/Northrend/dalaran.cpp @@ -70,8 +70,9 @@ public: return; Player* player = who->GetCharmerOrOwnerPlayerOrPlayerItself(); - - if (!player || player->isGameMaster() || player->IsBeingTeleported()) + + // If player has Disguise aura for quest A Meeting With The Magister or An Audience With The Arcanist, do not teleport it away but let it pass + if (!player || player->isGameMaster() || player->IsBeingTeleported() || player->HasAura(70973) || player->HasAura(70971)) return; switch (me->GetEntry()) diff --git a/src/server/scripts/Northrend/zuldrak.cpp b/src/server/scripts/Northrend/zuldrak.cpp index 5dab265617e..aa3b696f5fd 100644 --- a/src/server/scripts/Northrend/zuldrak.cpp +++ b/src/server/scripts/Northrend/zuldrak.cpp @@ -1219,9 +1219,9 @@ public: { if (uiMissleTimer <= uiDiff) { - DoCast(me, uiSpell); // this spell is not supported ... YET! + if (uiSpell) // Sometimes it is 0, why? + DoCast(me, uiSpell); // this spell (what spell) is not supported ... YET! uiMissleTimer = urand(2000, 7000); - } else uiMissleTimer -= uiDiff; } diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp index c081f0970f2..9b0a4a469ae 100755 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp @@ -384,7 +384,7 @@ bool OPvPCapturePointNA::HandleCustomSpell(Player* player, uint32 spellId, GameO int32 count = 10; uint32 itemid = 24538; // bomb id count - uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemid, count, &noSpaceForCount); + InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemid, count, &noSpaceForCount); if (msg != EQUIP_ERR_OK) // convert to possible store amount count -= noSpaceForCount; diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp index 7727f761588..23477741ba1 100755 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp @@ -170,7 +170,7 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId) else { go->SetRespawnTime(0); - map->Add(go); + map->AddToMap(go); } } } @@ -199,7 +199,7 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId) else { go->SetRespawnTime(0); - map->Add(go); + map->AddToMap(go); } } } diff --git a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp index 7b0c8fc017e..a9f84016a04 100644 --- a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp +++ b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp @@ -193,7 +193,7 @@ public: void MoveInLineOfSight(Unit* who) { - if (!HasTaunted && me->IsWithinDistInMap(who, 150.0)) + if (!HasTaunted && me->IsWithinDistInMap(who, 150.0f)) { DoScriptText(SAY_INTRO, me); HasTaunted = true; diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp index 9b985d6d93e..6d3a5f181d4 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp @@ -291,7 +291,7 @@ public: if (i_pl->isAlive() && !i_pl->HasAura(SPELL_BANISH)) i_pl->TeleportTo(me->GetMapId(), VorpilPosition[0], VorpilPosition[1], VorpilPosition[2], 0, TELE_TO_NOT_LEAVE_COMBAT); - me->GetMap()->CreatureRelocation(me, VorpilPosition[0], VorpilPosition[1], VorpilPosition[2], 0.0f); + me->SetPosition(VorpilPosition[0], VorpilPosition[1], VorpilPosition[2], 0.0f); DoCast(me, SPELL_DRAW_SHADOWS, true); DoCast(me, SPELL_RAIN_OF_FIRE); diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index 60845ae6365..a690f3cbd9b 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -66,69 +66,71 @@ const char* SAY_KILL2 = "This is too easy!"; #define SAY_ENRAGE "You've wasted too much time mortals, now you shall fall!" #define SOUND_ENRAGE 11474 -/************** Spells *************/ +enum Spells // Normal Form -#define SPELL_SHEAR 37335 // 41032 is bugged, cannot be block/dodge/parry// Reduces Max. Health by 60% for 7 seconds. Can stack 19 times. 1.5f second cast -#define SPELL_FLAME_CRASH 40832 // Summons an invis/unselect passive mob that has an aura of flame in a circle around him. -#define SPELL_DRAW_SOUL 40904 // 5k Shadow Damage in front of him. Heals Illidan for 100k health (script effect) -#define SPELL_PARASITIC_SHADOWFIEND 41917 // DoT of 3k Shadow every 2 seconds. Lasts 10 seconds. (Script effect: Summon 2 parasites once the debuff has ticked off) -#define SPELL_PARASITIC_SHADOWFIEND2 41914 // Used by Parasitic -#define SPELL_SUMMON_PARASITICS 41915 // Summons 2 Parasitic Shadowfiends on the target. It's supposed to be cast as soon as the Parasitic Shadowfiend debuff is gone, but the spells aren't linked :( -#define SPELL_AGONIZING_FLAMES 40932 // 4k fire damage initial to target and anyone w/i 5 yards. PHASE 3 ONLY -#define SPELL_ENRAGE 40683 // Increases damage by 50% and attack speed by 30%. 20 seconds, PHASE 5 ONLY +{ + SPELL_SHEAR = 37335, // 41032 is bugged, cannot be block/dodge/parry// Reduces Max. Health by 60% for 7 seconds. Can stack 19 times. 1.5f second cast + SPELL_FLAME_CRASH = 40832, + SPELL_DRAW_SOUL = 40904, + SPELL_PARASITIC_SHADOWFIEND = 41917, + SPELL_PARASITIC_SHADOWFIEND2 = 41914, + SPELL_SUMMON_PARASITICS = 41915, + SPELL_AGONIZING_FLAMES = 40932, + SPELL_ENRAGE = 40683, // Flying (Phase 2) -#define SPELL_THROW_GLAIVE 39635 // Throws a glaive on the ground -#define SPELL_THROW_GLAIVE2 39849 // Animation for the above spell -#define SPELL_GLAIVE_RETURNS 39873 // Glaive flies back to Illidan -#define SPELL_FIREBALL 40598 // 2.5fk-3.5fk damage in 10 yard radius. 2 second cast time. -#define SPELL_DARK_BARRAGE 40585 // 10 second channeled spell, 3k shadow damage per second. + SPELL_THROW_GLAIVE = 39635, + SPELL_THROW_GLAIVE2 = 39849, // Animation for the spell above + SPELL_GLAIVE_RETURNS = 39873, + SPELL_FIREBALL = 40598, + SPELL_DARK_BARRAGE = 40585, // Demon Form -#define SPELL_DEMON_TRANSFORM_1 40511 // First phase of animations for transforming into Dark Illidan (fall to ground) -#define SPELL_DEMON_TRANSFORM_2 40398 // Second phase of animations (kneel) -#define SPELL_DEMON_TRANSFORM_3 40510 // Final phase of animations (stand up and roar) -#define SPELL_DEMON_FORM 40506 // Transforms into Demon Illidan. Has an Aura of Dread on him. -#define SPELL_SHADOW_BLAST 41078 // 8k - 11k Shadow Damage. Targets highest threat. Has a splash effect, damaging anyone in 20 yards of the target. -#define SPELL_FLAME_BURST 41126 // Hurls fire at entire raid for ~3.5fk damage every 10 seconds. Resistable. (Does not work: Script effect) -#define SPELL_FLAME_BURST_EFFECT 41131 // The actual damage. Have each player cast it on itself (workaround) + SPELL_DEMON_TRANSFORM_1 = 40511, + SPELL_DEMON_TRANSFORM_2 = 40398, + SPELL_DEMON_TRANSFORM_3 = 40510, + SPELL_DEMON_FORM = 40506, + SPELL_SHADOW_BLAST = 41078, + SPELL_FLAME_BURST = 41126, + SPELL_FLAME_BURST_EFFECT = 41131, // The actual damage. Have each player cast it on itself (workaround) // Other Illidan spells -#define SPELL_KNEEL 39656 // Before beginning encounter, this is how he appears (talking to skully). -#define SPELL_SHADOW_PRISON 40647 // Illidan casts this spell to immobilize entire raid when he summons Maiev. -#define SPELL_DEATH 41220 // This spell doesn't do anything except stun Illidan and set him on his knees. -#define SPELL_BERSERK 45078 // Damage increased by 500%, attack speed by 150% -#define SPELL_DUAL_WIELD 42459 -//Phase Normal spells -#define SPELL_FLAME_CRASH_EFFECT 40836 // Firey blue ring of circle that the other flame crash summons -#define SPELL_SUMMON_SHADOWDEMON 41117 // Summon four shadowfiends -#define SPELL_SHADOWFIEND_PASSIVE 41913 // Passive aura for shadowfiends -#define SPELL_SHADOW_DEMON_PASSIVE 41079 // Adds the "shadowform" aura to Shadow Demons. -#define SPELL_CONSUME_SOUL 41080 // Once the Shadow Demons reach their target, they use this to kill them -#define SPELL_PARALYZE 41083 // Shadow Demons cast this on their target -#define SPELL_PURPLE_BEAM 39123 // Purple Beam connecting Shadow Demon to their target -//Phase Flight spells -#define SPELL_AZZINOTH_CHANNEL 39857 // Glaives cast it on Flames. Not sure if this is the right spell. -#define SPELL_EYE_BLAST_TRIGGER 40017 // This summons Demon Form every few seconds and deals ~20k damage in its radius -#define SPELL_EYE_BLAST 39908 // This does the blue flamey animation. -#define SPELL_BLAZE_EFFECT 40610 // Green flame on the ground, triggers damage (5k) every few seconds -#define SPELL_BLAZE_SUMMON 40637 // Summons the Blaze creature -#define SPELL_DEMON_FIRE 40029 // Blue fire trail left by Eye Blast. Deals 2k per second if players stand on it. -#define SPELL_FLAME_BLAST 40631 // Flames of Azzinoth use this. Frontal cone AoE 7k-9k damage. -#define SPELL_CHARGE 41581 //40602 // Flames of Azzinoth charges whoever is too far from them. They enrage after this. For simplicity, we'll use the same enrage as Illidan. -#define SPELL_FLAME_ENRAGE 45078 -//Akama spells -#define SPELL_AKAMA_DOOR_CHANNEL 41268 // Akama's channel spell on the door before the Temple Summit -#define SPELL_DEATHSWORN_DOOR_CHANNEL 41269 // Olum and Udalo's channel spell on the door before the Temple Summit -#define SPELL_AKAMA_DOOR_FAIL 41271 // Not sure where this is really used... -#define SPELL_HEALING_POTION 40535 // Akama uses this to heal himself to full. -#define SPELL_CHAIN_LIGHTNING 40536 // 6938 to 8062 for 5 targets -//Maiev spells -#define SPELL_CAGE_TRAP_DUMMY 40761 // Put this in DB for cage trap GO. -#define SPELL_CAGED 40695 // Caged Trap triggers will cast this on Illidan if he is within 3 yards -#define SPELL_CAGE_TRAP_SUMMON 40694 // Summons a Cage Trap GO (bugged) on the ground along with a Cage Trap Disturb Trigger mob (working) -#define SPELL_CAGE_TRAP_BEAM 40713 // 8 Triggers on the ground in an octagon cast spells like this on Illidan 'caging him' -#define SPELL_TELEPORT_VISUAL 41232 // Teleport visual for Maiev -#define SPELL_SHADOW_STRIKE 40685 // 4375 to 5625 every 3 seconds for 12 seconds -#define SPELL_THROW_DAGGER 41152 // 5400 to 6600 damage, need dagger -#define SPELL_FAN_BLADES 39954 // bugged visual + SPELL_KNEEL = 39656, // Before beginning encounter, this is how he appears (talking to skully). + SPELL_SHADOW_PRISON = 40647, + SPELL_DEATH = 41220, + SPELL_BERSERK = 45078, + SPELL_DUAL_WIELD = 42459, +// Phase Normal spells + SPELL_FLAME_CRASH_EFFECT = 40836, + SPELL_SUMMON_SHADOWDEMON = 41117, + SPELL_SHADOWFIEND_PASSIVE = 41913, + SPELL_SHADOW_DEMON_PASSIVE = 41079, + SPELL_CONSUME_SOUL = 41080, + SPELL_PARALYZE = 41083, + SPELL_PURPLE_BEAM = 39123, +// Phase Flight spells + SPELL_AZZINOTH_CHANNEL = 39857, // Glaives cast it on Flames. Not sure if this is the right spell. + SPELL_EYE_BLAST_TRIGGER = 40017, + SPELL_EYE_BLAST = 39908, + SPELL_BLAZE_EFFECT = 40610, + SPELL_BLAZE_SUMMON = 40637, + SPELL_DEMON_FIRE = 40029, + SPELL_FLAME_BLAST = 40631, + SPELL_CHARGE = 41581, + SPELL_FLAME_ENRAGE = 45078, +// Akama spells + SPELL_AKAMA_DOOR_CHANNEL = 41268, + SPELL_DEATHSWORN_DOOR_CHANNEL = 41269, + SPELL_AKAMA_DOOR_FAIL = 41271, // Not sure where this is really used... + SPELL_HEALING_POTION = 40535, + SPELL_CHAIN_LIGHTNING = 40536, +// Maiev spells + SPELL_CAGE_TRAP_DUMMY = 40761, // Put this in DB for cage trap GO. + SPELL_CAGED = 40695, + SPELL_CAGE_TRAP_SUMMON = 40694, // Summons a Cage Trap GO (bugged) on the ground along with a Cage Trap Disturb Trigger mob (working) + SPELL_CAGE_TRAP_BEAM = 40713, + SPELL_TELEPORT_VISUAL = 41232, + SPELL_SHADOW_STRIKE = 40685, + SPELL_THROW_DAGGER = 41152, + SPELL_FAN_BLADES = 39954, // bugged visual +}; // Other defines #define CENTER_X 676.740f @@ -174,7 +176,7 @@ enum PhaseIllidan PHASE_FLIGHT_SEQUENCE = 7, PHASE_TRANSFORM_SEQUENCE = 8, PHASE_ILLIDAN_MAX = 9, -};//Maiev uses the same phase +}; // Maiev uses the same phase enum PhaseAkama { @@ -191,7 +193,7 @@ enum EventIllidan { EVENT_NULL = 0, EVENT_BERSERK = 1, - //normal phase + // normal phase EVENT_TAUNT = 2, EVENT_SHEAR = 3, EVENT_FLAME_CRASH = 4, @@ -201,17 +203,17 @@ enum EventIllidan EVENT_AGONIZING_FLAMES = 8, EVENT_TRANSFORM_NORMAL = 9, EVENT_ENRAGE = 10, - //flight phase + // flight phase EVENT_FIREBALL = 2, EVENT_DARK_BARRAGE = 3, EVENT_EYE_BLAST = 4, EVENT_MOVE_POINT = 5, - //demon phase + // demon phase EVENT_SHADOW_BLAST = 2, EVENT_FLAME_BURST = 3, EVENT_SHADOWDEMON = 4, EVENT_TRANSFORM_DEMON = 5, - //sequence phase + // sequence phase EVENT_TALK_SEQUENCE = 2, EVENT_FLIGHT_SEQUENCE = 2, EVENT_TRANSFORM_SEQUENCE = 2, @@ -249,6 +251,7 @@ struct Yells }; static const Yells Conversation[22] = + { {11463, "Akama... your duplicity is hardly surprising. I should have slaughtered you and your malformed brethren long ago.", ILLIDAN_STORMRAGE, 8000, 0, true}, {0, "", ILLIDAN_STORMRAGE, 5000, 396, true}, @@ -259,19 +262,20 @@ static const Yells Conversation[22] = {0, "", AKAMA, 2000, 15, true}, {11466, "You are not prepared!", ILLIDAN_STORMRAGE, 3000, 406, true}, {0, "", EMPTY, 1000, 0, true}, - {0, "", EMPTY, 0, 0, false}, //9 + {0, "", EMPTY, 0, 0, false}, // 9 {11476, "Is this it, mortals? Is this all the fury you can muster?", ILLIDAN_STORMRAGE, 8000, 0, true}, {11491, "Their fury pales before mine, Illidan. We have some unsettled business between us.", MAIEV_SHADOWSONG, 8000, 5, true}, {11477, "Maiev... How is this even possible?", ILLIDAN_STORMRAGE, 5000, 1, true}, {11492, "Ah... my long hunt is finally over. Today, Justice will be done!", MAIEV_SHADOWSONG, 8000, 15, true}, - {11470, "Feel the hatred of ten thousand years!", ILLIDAN_STORMRAGE, 1000, 0, false}, //14 - {11496, "Ahh... It is finished. You are beaten.", MAIEV_SHADOWSONG, 6000, 0, true}, //15 + {11470, "Feel the hatred of ten thousand years!", ILLIDAN_STORMRAGE, 1000, 0, false}, // 14 + {11496, "Ahh... It is finished. You are beaten.", MAIEV_SHADOWSONG, 6000, 0, true}, // 15 + {11478, "You have won... Maiev...but the huntress... is nothing...without the hunt... you... are nothing... without me..", ILLIDAN_STORMRAGE, 30000, 65, true}, // Emote dead for now. Kill him later {11497, "He is right. I feel nothing... I am nothing... Farewell, champions.", MAIEV_SHADOWSONG, 9000, 0, true}, {11498, "", MAIEV_SHADOWSONG, 5000, 0, true}, - {11498, "", EMPTY, 1000, 0, true}, //19 Maiev disappear + {11498, "", EMPTY, 1000, 0, true}, // 19 Maiev disappear {11387, "The Light will fill these dismal halls once again. I swear it.", AKAMA, 8000, 0, true}, - {0, "", EMPTY, 1000, 0, false}//21 + {0, "", EMPTY, 1000, 0, false} // 21 }; static const Yells RandomTaunts[4]= @@ -306,14 +310,14 @@ static const Locations HoverPosition[4]= static const Locations GlaivePosition[4]= { {695.105f, 305.303f, 354.256f}, - {659.338f, 305.303f, 354.256f}, //the distance between two glaives is 36 + {659.338f, 305.303f, 354.256f}, // the distance between two glaives is 36 {700.105f, 305.303f, 354.256f}, {664.338f, 305.303f, 354.256f} }; static const Locations EyeBlast[2]= { - {677.0f, 350.0f, 354.0f}, //start point, pass through glaive point + {677.0f, 350.0f, 354.0f}, // start point, pass through glaive point {677.0f, 260.0f, 354.0f} }; @@ -350,7 +354,7 @@ static const Animation DemonTransformation[10]= { {SPELL_DEMON_TRANSFORM_1, 0, 1000, 0, 0, 6, true}, {SPELL_DEMON_TRANSFORM_2, SPELL_DEMON_TRANSFORM_1, 4000, 0, 0, 6, true}, - {0, 0, 3000, 1073741824, 21322, 6, false}, //stunned, cannot cast demon form + {0, 0, 3000, 1073741824, 21322, 6, false}, // stunned, cannot cast demon form {SPELL_DEMON_TRANSFORM_3, SPELL_DEMON_TRANSFORM_2, 3500, 0, 0, 6, false}, {SPELL_DEMON_FORM, SPELL_DEMON_TRANSFORM_3, 0, 0, 0, 4, false}, {SPELL_DEMON_TRANSFORM_1, 0, 1000, 0, 0, 6, false}, @@ -435,10 +439,10 @@ public: if (FlameBlastTimer <= diff) { - DoCast(me->getVictim(), SPELL_BLAZE_SUMMON, true); //appear at victim + DoCast(me->getVictim(), SPELL_BLAZE_SUMMON, true); // appear at victim DoCast(me->getVictim(), SPELL_FLAME_BLAST); - FlameBlastTimer = 15000; //10000 is official-like? - DoZoneInCombat(); //in case someone is revived + FlameBlastTimer = 15000; // 10000 is official-like? + DoZoneInCombat(); // in case someone is revived } else FlameBlastTimer -= diff; if (CheckTimer <= diff) @@ -515,7 +519,7 @@ public: void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) { - if (FlightCount == 7) //change hover point + if (FlightCount == 7) // change hover point { if (me->getVictim()) { @@ -678,7 +682,7 @@ public: me->AttackStop(); break; case PHASE_FLIGHT_SEQUENCE: - if (Phase == PHASE_NORMAL) //lift off + if (Phase == PHASE_NORMAL) // lift off { FlightCount = 1; Timer[EVENT_FLIGHT_SEQUENCE] = 1; @@ -688,7 +692,7 @@ public: me->GetMotionMaster()->Clear(false); me->AttackStop(); } - else //land + else // land Timer[EVENT_FLIGHT_SEQUENCE] = 2000; break; case PHASE_TRANSFORM_SEQUENCE: @@ -749,7 +753,7 @@ public: Trigger->AddUnitMovementFlag(MOVEMENTFLAG_WALKING); Trigger->GetMotionMaster()->MovePoint(0, final.x, final.y, final.z); - //Trigger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + // Trigger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetTarget(Trigger->GetGUID()); DoCast(Trigger, SPELL_EYE_BLAST); } @@ -792,7 +796,7 @@ public: { switch (FlightCount) { - case 1://lift off + case 1: // lift off me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); me->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING); me->StopMoving(); @@ -800,11 +804,11 @@ public: DoPlaySoundToSet(me, SOUND_TAKEOFF); Timer[EVENT_FLIGHT_SEQUENCE] = 3000; break; - case 2://move to center - me->GetMotionMaster()->MovePoint(0, CENTER_X + 5, CENTER_Y, CENTER_Z); //+5, for SPELL_THROW_GLAIVE bug + case 2: // move to center + me->GetMotionMaster()->MovePoint(0, CENTER_X + 5, CENTER_Y, CENTER_Z); // +5, for SPELL_THROW_GLAIVE bug Timer[EVENT_FLIGHT_SEQUENCE] = 0; break; - case 3://throw one glaive + case 3: // throw one glaive { uint8 i=1; Creature* Glaive = me->SummonCreature(BLADE_OF_AZZINOTH, GlaivePosition[i].x, GlaivePosition[i].y, GlaivePosition[i].z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); @@ -819,7 +823,7 @@ public: } Timer[EVENT_FLIGHT_SEQUENCE] = 700; break; - case 4://throw another + case 4: // throw another SetEquipmentSlots(false, EQUIP_UNEQUIP, EQUIP_UNEQUIP, EQUIP_NO_CHANGE); { uint8 i=0; @@ -835,19 +839,19 @@ public: } Timer[EVENT_FLIGHT_SEQUENCE] = 5000; break; - case 5://summon flames + case 5: // summon flames SummonFlamesOfAzzinoth(); Timer[EVENT_FLIGHT_SEQUENCE] = 3000; break; - case 6://fly to hover point + case 6: // fly to hover point me->GetMotionMaster()->MovePoint(0, HoverPosition[HoverPoint].x, HoverPosition[HoverPoint].y, HoverPosition[HoverPoint].z); Timer[EVENT_FLIGHT_SEQUENCE] = 0; break; - case 7://return to center + case 7: // return to center me->GetMotionMaster()->MovePoint(0, CENTER_X, CENTER_Y, CENTER_Z); Timer[EVENT_FLIGHT_SEQUENCE] = 0; break; - case 8://glaive return + case 8: // glaive return for (uint8 i = 0; i < 2; ++i) { if (GlaiveGUID[i]) @@ -862,7 +866,7 @@ public: } Timer[EVENT_FLIGHT_SEQUENCE] = 2000; break; - case 9://land + case 9: // land me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); me->StopMoving(); me->HandleEmoteCommand(EMOTE_ONESHOT_LAND); @@ -880,7 +884,7 @@ public: } Timer[EVENT_FLIGHT_SEQUENCE] = 2000; break; - case 10://attack + case 10: // attack DoResetThreat(); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE); me->SetByteValue(UNIT_FIELD_BYTES_2, 0, SHEATH_STATE_MELEE); @@ -1001,12 +1005,12 @@ public: { switch (Event) { - //PHASE_NORMAL + // PHASE_NORMAL case EVENT_BERSERK: me->MonsterYell(SAY_ENRAGE, LANG_UNIVERSAL, 0); DoPlaySoundToSet(me, SOUND_ENRAGE); DoCast(me, SPELL_BERSERK, true); - Timer[EVENT_BERSERK] = 5000;//The buff actually lasts forever. + Timer[EVENT_BERSERK] = 5000; // The buff actually lasts forever. break; case EVENT_TAUNT: @@ -1023,7 +1027,7 @@ public: case EVENT_SHEAR: // no longer exists in 3.0f.2 - //DoCast(me->getVictim(), SPELL_SHEAR); + // DoCast(me->getVictim(), SPELL_SHEAR); Timer[EVENT_SHEAR] = 25000 + (rand()%16 * 1000); break; @@ -1049,7 +1053,7 @@ public: Timer[EVENT_DRAW_SOUL] = 50000 + rand()%10000; break; - //PHASE_NORMAL_2 + // PHASE_NORMAL_2 case EVENT_AGONIZING_FLAMES: DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0), SPELL_AGONIZING_FLAMES); Timer[EVENT_AGONIZING_FLAMES] = 0; @@ -1059,7 +1063,7 @@ public: EnterPhase(PHASE_TRANSFORM_SEQUENCE); break; - //PHASE_NORMAL_MAIEV + // PHASE_NORMAL_MAIEV case EVENT_ENRAGE: DoCast(me, SPELL_ENRAGE); Timer[EVENT_ENRAGE] = 0; @@ -1092,7 +1096,7 @@ public: case EVENT_MOVE_POINT: Phase = PHASE_FLIGHT_SEQUENCE; - Timer[EVENT_FLIGHT_SEQUENCE] = 0;//do not start Event when changing hover point + Timer[EVENT_FLIGHT_SEQUENCE] = 0; // do not start Event when changing hover point HoverPoint += (rand()%3 + 1); if (HoverPoint > 3) HoverPoint -= 4; @@ -1204,7 +1208,7 @@ public: { GETUNIT(Illidan, IllidanGUID); if (Illidan && me->IsWithinDistInMap(Illidan, 25)) - BlinkToPlayer();//Do not let dread aura hurt her. + BlinkToPlayer();// Do not let dread aura hurt her. AttackStartNoMove(who); } else @@ -1217,7 +1221,7 @@ public: EnterPhase(PhaseIllidan(param)); } - void EnterPhase(PhaseIllidan NextPhase)//This is in fact Illidan's phase. + void EnterPhase(PhaseIllidan NextPhase) // This is in fact Illidan's phase. { switch (NextPhase) { @@ -1350,7 +1354,7 @@ public: if (GETCRE(Illidan, IllidanGUID)) CAST_AI(boss_illidan_stormrage::boss_illidan_stormrageAI, Illidan->AI())->DeleteFromThreatList(me->GetGUID()); me->AttackStop(); - Timer[EVENT_MAIEV_STEALTH] = 60000; //reappear after 1 minute + Timer[EVENT_MAIEV_STEALTH] = 60000; // reappear after 1 minute MaxTimer = 1; } @@ -1403,17 +1407,18 @@ public: DoorGUID[0] = instance->GetData64(DATA_GAMEOBJECT_ILLIDAN_DOOR_R); DoorGUID[1] = instance->GetData64(DATA_GAMEOBJECT_ILLIDAN_DOOR_L); - if (JustCreated)//close all doors at create + if (JustCreated) // close all doors at create { instance->HandleGameObject(GateGUID, false); for (uint8 i = 0; i < 2; ++i) instance->HandleGameObject(DoorGUID[i], false); - //JustCreated = false; - }else - {//open all doors, raid wiped + } + else // open all doors, raid wiped + { instance->HandleGameObject(GateGUID, true); - WalkCount = 1;//skip first wp + WalkCount = 1; // skip first wp + for (uint8 i = 0; i < 2; ++i) instance->HandleGameObject(DoorGUID[i], true); } @@ -1513,7 +1518,7 @@ public: if (GETGO(Gate, GateGUID)) Gate->GetPosition(x, y, z); else - return;//if door not spawned, don't crash server + return; // if door not spawned, don't crash server if (Creature* Channel = me->SummonCreature(ILLIDAN_DOOR_TRIGGER, x, y, z+5, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 360000)) { @@ -1581,11 +1586,11 @@ public: me->AddThreat(Illidan, 10000000.0f); me->GetMotionMaster()->MoveChase(Illidan); } - Timer = 30000; //chain lightning + Timer = 30000; // chain lightning break; case PHASE_FIGHT_MINIONS: me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - Timer = 10000 + rand()%6000;//summon minion + Timer = 10000 + rand()%6000; // summon minion break; case PHASE_RETURN: me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -1655,7 +1660,7 @@ public: Spirit[1]->CastSpell(Channel, SPELL_DEATHSWORN_DOOR_CHANNEL, false); Timer = 5000; break; - case 3: //open the gate + case 3: // open the gate me->InterruptNonMeleeSpells(true); Spirit[0]->InterruptNonMeleeSpells(true); Spirit[1]->InterruptNonMeleeSpells(true); @@ -1767,7 +1772,7 @@ public: float x, y, z; me->GetPosition(x, y, z); Creature* Elite = me->SummonCreature(ILLIDARI_ELITE, x+rand()%10, y+rand()%10, z, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000); - //Creature* Elite = me->SummonCreature(ILLIDARI_ELITE, x, y, z, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000); + // Creature* Elite = me->SummonCreature(ILLIDARI_ELITE, x, y, z, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000); if (Elite) { Elite->AI()->AttackStart(me); @@ -1967,7 +1972,7 @@ void boss_illidan_stormrage::boss_illidan_stormrageAI::HandleTalkSequence() Summons.DespawnAll(); break; case 17: - if (GETUNIT(Akama, AkamaGUID)) + if (GETCRE(Akama, AkamaGUID)) { if (!me->IsWithinDistInMap(Akama, 15)) { @@ -1975,10 +1980,11 @@ void boss_illidan_stormrage::boss_illidan_stormrageAI::HandleTalkSequence() me->GetPosition(x, y, z); x += 10; y += 10; Akama->GetMotionMaster()->Clear(false); - //Akama->GetMotionMaster()->MoveIdle(); - Akama->GetMap()->CreatureRelocation(me, x, y, z, 0.0f); - Akama->SendMonsterMove(x, y, z, 0, MOVEMENTFLAG_NONE, 0);//Illidan must not die until Akama arrives. + // Akama->GetMotionMaster()->MoveIdle(); + Akama->SetPosition(x, y, z, 0.0f); + Akama->SendMonsterMove(x, y, z, 0, MOVEMENTFLAG_NONE, 0); // Illidan must not die until Akama arrives. Akama->GetMotionMaster()->MoveChase(me); + } } break; @@ -2051,7 +2057,8 @@ public: DespawnTimer = 5000; if (who->HasAura(SPELL_ENRAGE)) who->RemoveAurasDueToSpell(SPELL_ENRAGE); // Dispel his enrage - //if (GameObject* CageTrap = instance->instance->GetGameObject(instance->GetData64(CageTrapGUID))) + // if (GameObject* CageTrap = instance->instance->GetGameObject(instance->GetData64(CageTrapGUID))) + // CageTrap->SetLootState(GO_JUST_DEACTIVATED); } } @@ -2067,13 +2074,13 @@ public: else DespawnTimer -= diff; } - //if (IllidanGUID && !SummonedBeams) - //{ + // if (IllidanGUID && !SummonedBeams) + // { // if (Unit* Illidan = Unit::GetUnit(*me, IllidanGUID) // { - // //TODO: Find proper spells and properly apply 'caged' Illidan effect + // // TODO: Find proper spells and properly apply 'caged' Illidan effect // } - //} + // } } }; @@ -2166,7 +2173,7 @@ public: void SpellHit(Unit* /*caster*/, const SpellInfo* spell) { if (spell->Id == SPELL_THROW_GLAIVE2 || spell->Id == SPELL_THROW_GLAIVE) - me->SetDisplayId(21431);//appear when hit by Illidan's glaive + me->SetDisplayId(21431);// appear when hit by Illidan's glaive } }; @@ -2214,9 +2221,9 @@ public: if (!me->getVictim()->HasAura(SPELL_PARASITIC_SHADOWFIEND) && !me->getVictim()->HasAura(SPELL_PARASITIC_SHADOWFIEND2)) { - if (Creature* illidan = Unit::GetCreature((*me), IllidanGUID))//summon only in 1. phase + if (Creature* illidan = Unit::GetCreature((*me), IllidanGUID))// summon only in 1. phase if (CAST_AI(boss_illidan_stormrage::boss_illidan_stormrageAI, illidan->AI())->Phase == PHASE_NORMAL) - me->CastSpell(me->getVictim(), SPELL_PARASITIC_SHADOWFIEND2, true, 0, 0, IllidanGUID); //do not stack + me->CastSpell(me->getVictim(), SPELL_PARASITIC_SHADOWFIEND2, true, 0, 0, IllidanGUID); // do not stack } me->AttackerStateUpdate(me->getVictim()); me->resetAttackTimer(); diff --git a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp index ce1f8739493..58585d0028e 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp @@ -641,7 +641,7 @@ public: void EnterCombat(Unit* /*who*/) {} - void BeginEvent(Player* pl) + void BeginEvent(Player* player) { if (!instance) return; @@ -662,7 +662,7 @@ public: me->CombatStart(Shade); Shade->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); Shade->SetTarget(me->GetGUID()); - if (pl) Shade->AddThreat(pl, 1.0f); + if (player) Shade->AddThreat(player, 1.0f); DoZoneInCombat(Shade); EventBegun = true; } diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp index 19280bd71f5..dcbc2832f27 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp @@ -291,7 +291,7 @@ class boss_alar : public CreatureScript if (me->IsWithinDist3d(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 5.0f)) dist = 5.0f; WaitTimer = 1000 + uint32(floor(dist / 80 * 1000.0f)); - me->GetMap()->CreatureRelocation(me, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f); + me->SetPosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f); me->StopMoving(); WaitEvent = WE_LAND; } diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp index f079f68d943..6fac13aa8ad 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp @@ -278,7 +278,7 @@ class boss_high_astromancer_solarian : public CreatureScript Phase1_Timer = 50000; //After these 50 seconds she portals to the middle of the room and disappears, leaving 3 light portals behind. me->GetMotionMaster()->Clear(); - me->GetMap()->CreatureRelocation(me, CENTER_X, CENTER_Y, CENTER_Z, CENTER_O); + me->SetPosition(CENTER_X, CENTER_Y, CENTER_Z, CENTER_O); for (uint8 i=0; i <= 2; ++i) { if (!i) @@ -346,7 +346,7 @@ class boss_high_astromancer_solarian : public CreatureScript //15 seconds later Solarian reappears out of one of the 3 portals. Simultaneously, 2 healers appear in the two other portals. int i = rand()%3; me->GetMotionMaster()->Clear(); - me->GetMap()->CreatureRelocation(me, Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O); + me->SetPosition(Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O); for (int j=0; j <= 2; j++) if (j != i) diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index 52a23196ee0..d987601c5bd 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -819,7 +819,7 @@ class boss_kaelthas : public CreatureScript me->StopMoving(); me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveIdle(); - me->GetMap()->CreatureRelocation(me, afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); + me->SetPosition(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); me->SendMonsterMove(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0, 0, 0); me->InterruptNonMeleeSpells(false); @@ -886,7 +886,7 @@ class boss_kaelthas : public CreatureScript me->StopMoving(); me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveIdle(); - me->GetMap()->CreatureRelocation(me, afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); + me->SetPosition(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); me->SendMonsterMove(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0, MOVEMENTFLAG_NONE, 0); // 1) Kael'thas will portal the whole raid right into his body diff --git a/src/server/scripts/Outland/nagrand.cpp b/src/server/scripts/Outland/nagrand.cpp index b639050320c..c556253ecf1 100644 --- a/src/server/scripts/Outland/nagrand.cpp +++ b/src/server/scripts/Outland/nagrand.cpp @@ -19,330 +19,20 @@ /* ScriptData SDName: Nagrand SD%Complete: 90 -SDComment: Quest support: 9849, 9868, 9918, 9874, 9991, 10107, 10108, 10044, 10172, 10646, 10085, 10987. TextId's unknown for altruis_the_sufferer and greatmother_geyah (npc_text) +SDComment: Quest support: 9868, 9874, 10044, 10172, 10085. TextId's unknown for altruis_the_sufferer and greatmother_geyah (npc_text) SDCategory: Nagrand EndScriptData */ /* ContentData -mob_shattered_rumbler -mob_lump -npc_altruis_the_sufferer npc_greatmother_geyah -npc_lantresor_of_the_blade npc_maghar_captive npc_creditmarker_visit_with_ancestors -mob_sparrowhawk EndContentData */ #include "ScriptPCH.h" #include "ScriptedEscortAI.h" /*###### -## mob_shattered_rumbler - this should be done with ACID -######*/ - -class mob_shattered_rumbler : public CreatureScript -{ -public: - mob_shattered_rumbler() : CreatureScript("mob_shattered_rumbler") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_shattered_rumblerAI (creature); - } - - struct mob_shattered_rumblerAI : public ScriptedAI - { - bool Spawn; - - mob_shattered_rumblerAI(Creature* c) : ScriptedAI(c) {} - - void Reset() - { - Spawn = false; - } - - void EnterCombat(Unit* /*who*/) {} - - void SpellHit(Unit* Hitter, const SpellInfo* Spellkind) - { - if (Spellkind->Id == 32001 && !Spawn) - { - float x = me->GetPositionX(); - float y = me->GetPositionY(); - float z = me->GetPositionZ(); - - Hitter->SummonCreature(18181, x+(0.7f * (rand()%30)), y+(rand()%5), z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); - Hitter->SummonCreature(18181, x+(rand()%5), y-(rand()%5), z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); - Hitter->SummonCreature(18181, x-(rand()%5), y+(0.5f *(rand()%60)), z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); - me->setDeathState(CORPSE); - Spawn = true; - } - return; - } - }; - -}; - -/*###### -## mob_lump -######*/ - -#define SPELL_VISUAL_SLEEP 16093 -#define SPELL_SPEAR_THROW 32248 - -#define LUMP_SAY0 -1000190 -#define LUMP_SAY1 -1000191 - -#define LUMP_DEFEAT -1000192 - -#define GOSSIP_HL "I need answers, ogre!" -#define GOSSIP_SL1 "Why are Boulderfist out this far? You know that this is Kurenai territory." -#define GOSSIP_SL2 "And you think you can just eat anything you want? You're obviously trying to eat the Broken of Telaar." -#define GOSSIP_SL3 "This means war, Lump! War I say!" - -class mob_lump : public CreatureScript -{ -public: - mob_lump() : CreatureScript("mob_lump") { } - - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction) - { - player->PlayerTalkClass->ClearMenus(); - switch (uiAction) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SL1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(9353, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SL2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(9354, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SL3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(9355, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->SEND_GOSSIP_MENU(9356, creature->GetGUID()); - player->TalkedToCreature(18354, creature->GetGUID()); - break; - } - return true; - } - - bool OnGossipHello(Player* player, Creature* creature) - { - if (player->GetQuestStatus(9918) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(9352, creature->GetGUID()); - - return true; - } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_lumpAI(creature); - } - - struct mob_lumpAI : public ScriptedAI - { - mob_lumpAI(Creature* c) : ScriptedAI(c) - { - bReset = false; - } - - uint32 Reset_Timer; - uint32 Spear_Throw_Timer; - bool bReset; - - void Reset() - { - Reset_Timer = 60000; - Spear_Throw_Timer = 2000; - - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - - void AttackedBy(Unit* pAttacker) - { - if (me->getVictim()) - return; - - if (me->IsFriendlyTo(pAttacker)) - return; - - AttackStart(pAttacker); - } - - void DamageTaken(Unit* done_by, uint32 & damage) - { - if (done_by->GetTypeId() == TYPEID_PLAYER && me->HealthBelowPctDamaged(30, damage)) - { - if (!bReset && CAST_PLR(done_by)->GetQuestStatus(9918) == QUEST_STATUS_INCOMPLETE) - { - //Take 0 damage - damage = 0; - - CAST_PLR(done_by)->AttackStop(); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - me->RemoveAllAuras(); - me->DeleteThreatList(); - me->CombatStop(true); - me->setFaction(1080); //friendly - me->SetStandState(UNIT_STAND_STATE_SIT); - DoScriptText(LUMP_DEFEAT, me); - - bReset = true; - } - } - } - - void EnterCombat(Unit* /*who*/) - { - if (me->HasAura(SPELL_VISUAL_SLEEP)) - me->RemoveAura(SPELL_VISUAL_SLEEP); - - if (!me->IsStandState()) - me->SetStandState(UNIT_STAND_STATE_STAND); - - DoScriptText(RAND(LUMP_SAY0, LUMP_SAY1), me); - } - - void UpdateAI(const uint32 diff) - { - //check if we waiting for a reset - if (bReset) - { - if (Reset_Timer <= diff) - { - EnterEvadeMode(); - bReset = false; - me->setFaction(1711); //hostile - return; - } - else Reset_Timer -= diff; - } - - //Return since we have no target - if (!UpdateVictim()) - return; - - //Spear_Throw_Timer - if (Spear_Throw_Timer <= diff) - { - DoCast(me->getVictim(), SPELL_SPEAR_THROW); - Spear_Throw_Timer = 20000; - } else Spear_Throw_Timer -= diff; - - DoMeleeAttackIfReady(); - } - }; - -}; - -/*###### -## npc_altruis_the_sufferer -######*/ - -#define GOSSIP_HATS1 "I see twisted steel and smell sundered earth." -#define GOSSIP_HATS2 "Well...?" -#define GOSSIP_HATS3 "[PH] Story about Illidan's Pupil" - -#define GOSSIP_SATS1 "Legion?" -#define GOSSIP_SATS2 "And now?" -#define GOSSIP_SATS3 "How do you see them now?" -#define GOSSIP_SATS4 "Forge camps?" -#define GOSSIP_SATS5 "Ok." -#define GOSSIP_SATS6 "[PH] Story done" - -class npc_altruis_the_sufferer : public CreatureScript -{ -public: - npc_altruis_the_sufferer() : CreatureScript("npc_altruis_the_sufferer") { } - - bool OnQuestAccept(Player* player, Creature* /*creature*/, Quest const* /*quest*/) - { - if (!player->GetQuestRewardStatus(9991)) //Survey the Land, q-id 9991 - { - player->CLOSE_GOSSIP_MENU(); - player->ActivateTaxiPathTo(532); //TaxiPath 532 - } - return true; - } - - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction) - { - player->PlayerTalkClass->ClearMenus(); - switch (uiAction) - { - case GOSSIP_ACTION_INFO_DEF+10: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(9420, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+11: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(9421, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+12: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); - player->SEND_GOSSIP_MENU(9422, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+13: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14); - player->SEND_GOSSIP_MENU(9423, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+14: - player->SEND_GOSSIP_MENU(9424, creature->GetGUID()); - break; - - case GOSSIP_ACTION_INFO_DEF+20: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21); - player->SEND_GOSSIP_MENU(9427, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+21: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(9991); - break; - - case GOSSIP_ACTION_INFO_DEF+30: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 31); - player->SEND_GOSSIP_MENU(384, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+31: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(10646); - break; - } - return true; - } - - bool OnGossipHello(Player* player, Creature* creature) - { - if (creature->isQuestGiver()) - player->PrepareQuestMenu(creature->GetGUID()); - - //gossip before obtaining Survey the Land - if (player->GetQuestStatus(9991) == QUEST_STATUS_NONE) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HATS1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+10); - - //gossip when Survey the Land is incomplete (technically, after the flight) - if (player->GetQuestStatus(9991) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HATS2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+20); - - //wowwiki.com/Varedis - if (player->GetQuestStatus(10646) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HATS3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+30); - - player->SEND_GOSSIP_MENU(9419, creature->GetGUID()); - - return true; - } - -}; - -/*###### ## npc_greatmother_geyah ######*/ @@ -453,83 +143,6 @@ public: }; -/*###### -## npc_lantresor_of_the_blade -######*/ - -#define GOSSIP_HLB "I have killed many of your ogres, Lantresor. I have no fear." -#define GOSSIP_SLB1 "Should I know? You look like an orc to me." -#define GOSSIP_SLB2 "And the other half?" -#define GOSSIP_SLB3 "I have heard of your kind, but I never thought to see the day when I would meet a half-breed." -#define GOSSIP_SLB4 "My apologies. I did not mean to offend. I am here on behalf of my people." -#define GOSSIP_SLB5 "My people ask that you pull back your Boulderfist ogres and cease all attacks on our territories. In return, we will also pull back our forces." -#define GOSSIP_SLB6 "We will fight you until the end, then, Lantresor. We will not stand idly by as you pillage our towns and kill our people." -#define GOSSIP_SLB7 "What do I need to do?" - -class npc_lantresor_of_the_blade : public CreatureScript -{ -public: - npc_lantresor_of_the_blade() : CreatureScript("npc_lantresor_of_the_blade") { } - - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction) - { - player->PlayerTalkClass->ClearMenus(); - switch (uiAction) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(9362, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(9363, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(9364, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->SEND_GOSSIP_MENU(9365, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(9366, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->SEND_GOSSIP_MENU(9367, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+6: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB7, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(9368, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+7: - player->SEND_GOSSIP_MENU(9369, creature->GetGUID()); - if (player->GetQuestStatus(10107) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(10107); - if (player->GetQuestStatus(10108) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(10108); - break; - } - return true; - } - - bool OnGossipHello(Player* player, Creature* creature) - { - if (creature->isQuestGiver()) - player->PrepareQuestMenu(creature->GetGUID()); - - if (player->GetQuestStatus(10107) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10108) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HLB, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(9361, creature->GetGUID()); - - return true; - } - -}; - /*##### ## npc_maghar_captive #####*/ @@ -747,113 +360,9 @@ public: }; /*###### -## mob_sparrowhawk +## go_corkis_prison and npc_corki ######*/ -#define SPELL_SPARROWHAWK_NET 39810 -#define SPELL_ITEM_CAPTIVE_SPARROWHAWK 39812 - -class mob_sparrowhawk : public CreatureScript -{ -public: - mob_sparrowhawk() : CreatureScript("mob_sparrowhawk") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_sparrowhawkAI (creature); - } - - struct mob_sparrowhawkAI : public ScriptedAI - { - - mob_sparrowhawkAI(Creature* c) : ScriptedAI(c) {} - - uint32 Check_Timer; - uint64 PlayerGUID; - bool fleeing; - - void Reset() - { - me->RemoveAurasDueToSpell(SPELL_SPARROWHAWK_NET); - Check_Timer = 1000; - PlayerGUID = 0; - fleeing = false; - } - void AttackStart(Unit* who) - { - if (PlayerGUID) - return; - - ScriptedAI::AttackStart(who); - } - - void EnterCombat(Unit* /*who*/) {} - - void MoveInLineOfSight(Unit* who) - { - if (!who || PlayerGUID) - return; - - if (!PlayerGUID && who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 30) && CAST_PLR(who)->GetQuestStatus(10987) == QUEST_STATUS_INCOMPLETE) - { - PlayerGUID = who->GetGUID(); - return; - } - - ScriptedAI::MoveInLineOfSight(who); - } - - void UpdateAI(const uint32 diff) - { - if (Check_Timer <= diff) - { - if (PlayerGUID) - { - if (fleeing && me->GetMotionMaster()->GetCurrentMovementGeneratorType() != FLEEING_MOTION_TYPE) - fleeing = false; - - Player* player = Unit::GetPlayer(*me, PlayerGUID); - if (player && me->IsWithinDistInMap(player, 30)) - { - if (!fleeing) - { - me->DeleteThreatList(); - me->GetMotionMaster()->MoveFleeing(player); - fleeing = true; - } - } - else if (fleeing) - { - me->GetMotionMaster()->MovementExpired(false); - PlayerGUID = 0; - fleeing = false; - } - } - Check_Timer = 1000; - } else Check_Timer -= diff; - - if (PlayerGUID) - return; - - ScriptedAI::UpdateAI(diff); - } - - void SpellHit(Unit* caster, const SpellInfo* spell) - { - if (caster->GetTypeId() == TYPEID_PLAYER) - { - if (spell->Id == SPELL_SPARROWHAWK_NET && CAST_PLR(caster)->GetQuestStatus(10987) == QUEST_STATUS_INCOMPLETE) - { - DoCast(caster, SPELL_ITEM_CAPTIVE_SPARROWHAWK, true); - me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); - } - } - return; - } - }; -}; - enum CorkiData { // first quest @@ -916,10 +425,6 @@ public: } }; -/*###### -## npc_corki -######*/ - class npc_corki : public CreatureScript { public: @@ -970,16 +475,237 @@ public: }; }; +/*##### +## npc_kurenai_captive +#####*/ + +enum KurenaiCaptive +{ + SAY_KUR_START = 0, + SAY_KUR_NO_ESCAPE = 1, + SAY_KUR_MORE = 2, + SAY_KUR_MORE_TWO = 3, + SAY_KUR_LIGHTNING = 4, + SAY_KUR_SHOCK = 5, + SAY_KUR_COMPLETE = 6, + + SPELL_KUR_CHAIN_LIGHTNING = 16006, + SPELL_KUR_EARTHBIND_TOTEM = 15786, + SPELL_KUR_FROST_SHOCK = 12548, + SPELL_KUR_HEALING_WAVE = 12491, + + QUEST_TOTEM_KARDASH_A = 9879, + + NPC_KUR_MURK_RAIDER = 18203, + NPC_KUR_MURK_BRUTE = 18211, + NPC_KUR_MURK_SCAVENGER = 18207, + NPC_KUR_MURK_PUTRIFIER = 18202, +}; + +static float kurenaiAmbushA[]= {-1568.805786f, 8533.873047f, 1.958f}; +static float kurenaiAmbushB[]= {-1491.554321f, 8506.483398f, 1.248f}; + +class npc_kurenai_captive : public CreatureScript +{ +public: + npc_kurenai_captive() : CreatureScript("npc_kurenai_captive") { } + + bool OnQuestAccept(Player* player, Creature* creature, const Quest* quest) + { + if (quest->GetQuestId() == QUEST_TOTEM_KARDASH_A) + { + if (npc_kurenai_captiveAI* EscortAI = dynamic_cast<npc_kurenai_captiveAI*>(creature->AI())) + { + creature->SetStandState(UNIT_STAND_STATE_STAND); + EscortAI->Start(true, false, player->GetGUID(), quest); + DoScriptText(SAY_KUR_START, creature); + + creature->SummonCreature(NPC_KUR_MURK_RAIDER, kurenaiAmbushA[0]+2.5f, kurenaiAmbushA[1]-2.5f, kurenaiAmbushA[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); + creature->SummonCreature(NPC_KUR_MURK_BRUTE, kurenaiAmbushA[0]-2.5f, kurenaiAmbushA[1]+2.5f, kurenaiAmbushA[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); + creature->SummonCreature(NPC_KUR_MURK_SCAVENGER, kurenaiAmbushA[0], kurenaiAmbushA[1], kurenaiAmbushA[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); + } + } + return true; + } + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_kurenai_captiveAI(creature); + } + + struct npc_kurenai_captiveAI : public npc_escortAI + { + npc_kurenai_captiveAI(Creature* creature) : npc_escortAI(creature) { } + + uint32 ChainLightningTimer; + uint32 HealTimer; + uint32 FrostShockTimer; + + void Reset() + { + ChainLightningTimer = 1000; + HealTimer = 0; + FrostShockTimer = 6000; + } + + void EnterCombat(Unit* /*who*/) + { + DoCast(me, SPELL_KUR_EARTHBIND_TOTEM, false); + } + + void JustDied(Unit* /*killer*/) + { + if (!HasEscortState(STATE_ESCORT_ESCORTING)) + return; + + if (Player* player = GetPlayerForEscort()) + { + if (player->GetQuestStatus(QUEST_TOTEM_KARDASH_A) != QUEST_STATUS_COMPLETE) + player->FailQuest(QUEST_TOTEM_KARDASH_A); + } + } + + void WaypointReached(uint32 PointId) + { + switch(PointId) + { + case 3: + { + Talk(SAY_KUR_MORE); + + if (Creature* temp = me->SummonCreature(NPC_KUR_MURK_PUTRIFIER, kurenaiAmbushB[0], kurenaiAmbushB[1], kurenaiAmbushB[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000)) + Talk(SAY_KUR_MORE_TWO); + + me->SummonCreature(NPC_KUR_MURK_PUTRIFIER, kurenaiAmbushB[0]-2.5f, kurenaiAmbushB[1]-2.5f, kurenaiAmbushB[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); + me->SummonCreature(NPC_KUR_MURK_SCAVENGER, kurenaiAmbushB[0]+2.5f, kurenaiAmbushB[1]+2.5f, kurenaiAmbushB[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); + me->SummonCreature(NPC_KUR_MURK_SCAVENGER, kurenaiAmbushB[0]+2.5f, kurenaiAmbushB[1]-2.5f, kurenaiAmbushB[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); + break; + } + case 7: + { + Talk(SAY_KUR_COMPLETE); + + if (Player* player = GetPlayerForEscort()) + player->GroupEventHappens(QUEST_TOTEM_KARDASH_A, me); + + SetRun(); + break; + } + } + } + + void JustSummoned(Creature* summoned) + { + if (summoned->GetEntry() == NPC_KUR_MURK_BRUTE) + Talk(SAY_KUR_NO_ESCAPE); + + // This function is for when we summoned enemies to fight - so that does NOT mean we should make our totem count in this! + if (summoned->isTotem()) + return; + + summoned->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); + summoned->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()); + summoned->AI()->AttackStart(me); + } + + void SpellHitTarget(Unit* /*target*/, const SpellInfo* spell) + { + if (spell->Id == SPELL_KUR_CHAIN_LIGHTNING) + { + if (rand()%30) + return; + + Talk(SAY_KUR_LIGHTNING); + } + + if (spell->Id == SPELL_KUR_FROST_SHOCK) + { + if (rand()%30) + return; + + Talk(SAY_KUR_SHOCK); + } + } + + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; + + if (me->HasUnitState(UNIT_STAT_CASTING)) + return; + + if (ChainLightningTimer <= diff) + { + DoCast(me->getVictim(), SPELL_KUR_CHAIN_LIGHTNING); + ChainLightningTimer = urand(7000,14000); + } else ChainLightningTimer -= diff; + + if (HealthBelowPct(30)) + { + if (HealTimer <= diff) + { + DoCast(me, SPELL_KUR_HEALING_WAVE); + HealTimer = 5000; + } else HealTimer -= diff; + } + + if (FrostShockTimer <= diff) + { + DoCast(me->getVictim(), SPELL_KUR_FROST_SHOCK); + FrostShockTimer = urand(7500,15000); + } else FrostShockTimer -= diff; + + DoMeleeAttackIfReady(); + } + }; +}; + +/*###### +## go_warmaul_prison +######*/ + +enum FindingTheSurvivorsData +{ + QUEST_FINDING_THE_SURVIVORS = 9948, + NPC_MAGHAR_PRISONER = 18428, + + SAY_FREE = 0, +}; + +class go_warmaul_prison : public GameObjectScript +{ + public: + go_warmaul_prison() : GameObjectScript("go_warmaul_prison") { } + + bool OnGossipHello(Player* player, GameObject* go) + { + if (player->GetQuestStatus(QUEST_FINDING_THE_SURVIVORS) != QUEST_STATUS_INCOMPLETE) + return false; + + if (Creature* prisoner = go->FindNearestCreature(NPC_MAGHAR_PRISONER, 5.0f)) + { + if (prisoner) + { + go->UseDoorOrButton(); + if (player) + player->KilledMonsterCredit(NPC_MAGHAR_PRISONER, 0); + + prisoner->AI()->Talk(SAY_FREE, player->GetGUID()); + prisoner->ForcedDespawn(6000); + } + } + return true; + } +}; + void AddSC_nagrand() { - new mob_shattered_rumbler(); - new mob_lump(); - new npc_altruis_the_sufferer(); new npc_greatmother_geyah(); - new npc_lantresor_of_the_blade(); new npc_maghar_captive(); new npc_creditmarker_visit_with_ancestors(); - new mob_sparrowhawk(); new npc_corki(); new go_corkis_prison(); + new npc_kurenai_captive(); + new go_warmaul_prison(); } diff --git a/src/server/scripts/Outland/shattrath_city.cpp b/src/server/scripts/Outland/shattrath_city.cpp index f2aa9fe5786..6ac60e2086b 100644 --- a/src/server/scripts/Outland/shattrath_city.cpp +++ b/src/server/scripts/Outland/shattrath_city.cpp @@ -369,7 +369,7 @@ public: { if (CAST_PLR(who)->GetQuestStatus(10211) == QUEST_STATUS_INCOMPLETE) { - float Radius = 10.0; + float Radius = 10.0f; if (me->IsWithinDistInMap(who, Radius)) { Start(false, false, who->GetGUID()); diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index 6ae9577070e..3b2cc5f5e00 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -899,7 +899,6 @@ class spell_q9874_liquid_fire : public SpellScriptLoader }; }; - enum SalvagingLifesStength { NPC_SHARD_KILL_CREDIT = 29303, @@ -950,6 +949,7 @@ enum eBattleStandard { NPC_KING_OF_THE_MOUNTAINT_KC = 31766, }; + class spell_q13280_13283_plant_battle_standard: public SpellScriptLoader { public: @@ -978,6 +978,54 @@ public: } }; +enum ChumTheWaterSummons +{ + SUMMON_ANGRY_KVALDIR = 66737, + SUMMON_NORTH_SEA_MAKO = 66738, + SUMMON_NORTH_SEA_THRESHER = 66739, + SUMMON_NORTH_SEA_BLUE_SHARK = 66740 +}; + +class spell_q14112_14145_chum_the_water: public SpellScriptLoader +{ +public: + spell_q14112_14145_chum_the_water() : SpellScriptLoader("spell_q14112_14145_chum_the_water") { } + + class spell_q14112_14145_chum_the_water_SpellScript : public SpellScript + { + PrepareSpellScript(spell_q14112_14145_chum_the_water_SpellScript); + + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SUMMON_ANGRY_KVALDIR)) + return false; + if (!sSpellMgr->GetSpellInfo(SUMMON_NORTH_SEA_MAKO)) + return false; + if (!sSpellMgr->GetSpellInfo(SUMMON_NORTH_SEA_THRESHER)) + return false; + if (!sSpellMgr->GetSpellInfo(SUMMON_NORTH_SEA_BLUE_SHARK)) + return false; + return true; + } + + void HandleScriptEffect(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + caster->CastSpell(caster, RAND(SUMMON_ANGRY_KVALDIR, SUMMON_NORTH_SEA_MAKO, SUMMON_NORTH_SEA_THRESHER, SUMMON_NORTH_SEA_BLUE_SHARK)); + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_q14112_14145_chum_the_water_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_q14112_14145_chum_the_water_SpellScript(); + } +}; + void AddSC_quest_spell_scripts() { new spell_q55_sacred_cleansing(); @@ -1001,4 +1049,5 @@ void AddSC_quest_spell_scripts() new spell_q9874_liquid_fire(); new spell_q12805_lifeblood_dummy(); new spell_q13280_13283_plant_battle_standard(); + new spell_q14112_14145_chum_the_water(); } diff --git a/src/server/scripts/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp index a9ed794ab45..517746dac55 100644 --- a/src/server/scripts/World/areatrigger_scripts.cpp +++ b/src/server/scripts/World/areatrigger_scripts.cpp @@ -24,14 +24,8 @@ SDCategory: Areatrigger EndScriptData */ /* ContentData -at_aldurthar_gate q13315/q13351 at_coilfang_waterfall 4591 at_legion_teleporter 4560 Teleporter TO Invasion Point: Cataclysm -at_ravenholdt -at_warsong_slaughterhouse -at_warsong_grainery -at_torp_farm -at_warsong_farms q11686 at_stormwright_shelf q12741 at_last_rites q12019 at_sholazar_waygate q12548 @@ -40,46 +34,6 @@ EndContentData */ #include "ScriptPCH.h" /*###### -## AreaTrigger_at_aldurthar_gate -######*/ - -enum eAldurtharGate -{ - TRIGGER_SOUTH = 5284, - - TRIGGER_CENTRAL = 5285, - TRIGGER_NORTH = 5286, - TRIGGER_NORTHWEST = 5287, - - NPC_SOUTH_GATE = 32195, - NPC_CENTRAL_GATE = 32196, - NPC_NORTH_GATE = 32197, - NPC_NORTHWEST_GATE = 32199 -}; - -class AreaTrigger_at_aldurthar_gate : public AreaTriggerScript -{ - public: - - AreaTrigger_at_aldurthar_gate() - : AreaTriggerScript("at_aldurthar_gate") - { - } - - bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) - { - switch (trigger->id) - { - case TRIGGER_SOUTH: player->KilledMonsterCredit(NPC_SOUTH_GATE, 0); break; - case TRIGGER_CENTRAL: player->KilledMonsterCredit(NPC_CENTRAL_GATE, 0); break; - case TRIGGER_NORTH: player->KilledMonsterCredit(NPC_NORTH_GATE, 0); break; - case TRIGGER_NORTHWEST: player->KilledMonsterCredit(NPC_NORTHWEST_GATE, 0); break; - } - return true; - } -}; - -/*###### ## at_coilfang_waterfall ######*/ @@ -151,71 +105,6 @@ class AreaTrigger_at_legion_teleporter : public AreaTriggerScript } }; -enum eRavenholdt -{ - QUEST_MANOR_RAVENHOLDT = 6681, - NPC_RAVENHOLDT = 13936 -}; - -class AreaTrigger_at_ravenholdt : public AreaTriggerScript -{ - public: - - AreaTrigger_at_ravenholdt() - : AreaTriggerScript("at_ravenholdt") - { - } - - bool OnTrigger(Player* player, AreaTriggerEntry const* /*trigger*/) - { - if (player->GetQuestStatus(QUEST_MANOR_RAVENHOLDT) == QUEST_STATUS_INCOMPLETE) - player->KilledMonsterCredit(NPC_RAVENHOLDT, 0); - - return false; - } -}; - -/*###### -## at_warsong_farms -######*/ - -enum eWarsongFarms -{ - QUEST_THE_WARSONG_FARMS = 11686, - - NPC_CREDIT_SLAUGHTERHOUSE = 25672, - NPC_CREDIT_GRAINERY = 25669, - NPC_CREDIT_TORP_FARM = 25671, - - AT_SLAUGHTERHOUSE = 4873, - AT_GRAINERY = 4871, - AT_TORP_FARM = 4872 -}; - -class AreaTrigger_at_warsong_farms : public AreaTriggerScript -{ - public: - - AreaTrigger_at_warsong_farms() - : AreaTriggerScript("at_warsong_farms") - { - } - - bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) - { - if (!player->isDead() && player->GetQuestStatus(QUEST_THE_WARSONG_FARMS) == QUEST_STATUS_INCOMPLETE) - { - switch (trigger->id) - { - case AT_SLAUGHTERHOUSE: player->KilledMonsterCredit(NPC_CREDIT_SLAUGHTERHOUSE, 0); break; - case AT_GRAINERY: player->KilledMonsterCredit(NPC_CREDIT_GRAINERY, 0); break; - case AT_TORP_FARM: player->KilledMonsterCredit(NPC_CREDIT_TORP_FARM, 0); break; - } - } - return true; - } -}; - /*###### ## at_stormwright_shelf ######*/ @@ -370,11 +259,8 @@ class AreaTrigger_at_sholazar_waygate : public AreaTriggerScript void AddSC_areatrigger_scripts() { - new AreaTrigger_at_aldurthar_gate(); new AreaTrigger_at_coilfang_waterfall(); new AreaTrigger_at_legion_teleporter(); - new AreaTrigger_at_ravenholdt(); - new AreaTrigger_at_warsong_farms(); new AreaTrigger_at_stormwright_shelf(); new AreaTrigger_at_scent_larkorwi(); new AreaTrigger_at_last_rites(); diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index cdeac03d76e..f83b728ee01 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -165,7 +165,7 @@ public: bool OnGossipHello(Player* player, GameObject* /*pGO*/) { - if (player->HasSkill(SKILL_ENGINERING) && player->GetBaseSkillValue(SKILL_ENGINERING) >= 300 && !player->HasSpell(22704)) + if (player->HasSkill(SKILL_ENGINEERING) && player->GetBaseSkillValue(SKILL_ENGINEERING) >= 300 && !player->HasSpell(22704)) { player->CastSpell(player, 22864, false); } @@ -1176,14 +1176,79 @@ public: class go_massive_seaforium_charge : public GameObjectScript { -public: - go_massive_seaforium_charge() : GameObjectScript("go_massive_seaforium_charge") { } + public: + go_massive_seaforium_charge() : GameObjectScript("go_massive_seaforium_charge") { } - bool OnGossipHello(Player* /*player*/, GameObject* go) - { - go->SetLootState(GO_JUST_DEACTIVATED); - return true; - } + bool OnGossipHello(Player* /*player*/, GameObject* go) + { + go->SetLootState(GO_JUST_DEACTIVATED); + return true; + } +}; + +/*###### +## go_gjalerbron_cage +######*/ + +enum OfKeysAndCages +{ + QUEST_ALLIANCE_OF_KEYS_AND_CAGES = 11231, + QUEST_HORDE_OF_KEYS_AND_CAGES = 11265, + NPC_GJALERBRON_PRISONER = 24035, + SAY_FREE = 0, +}; + +class go_gjalerbron_cage : public GameObjectScript +{ + public: + go_gjalerbron_cage() : GameObjectScript("go_gjalerbron_cage") { } + + bool OnGossipHello(Player* player, GameObject* go) + { + if ((player->GetTeamId() == TEAM_ALLIANCE && player->GetQuestStatus(QUEST_ALLIANCE_OF_KEYS_AND_CAGES) == QUEST_STATUS_INCOMPLETE) || + (player->GetTeamId() == TEAM_HORDE && player->GetQuestStatus(QUEST_HORDE_OF_KEYS_AND_CAGES) == QUEST_STATUS_INCOMPLETE)) + { + if (Creature* prisoner = go->FindNearestCreature(NPC_GJALERBRON_PRISONER, 5.0f)) + { + go->UseDoorOrButton(); + + if (player) + player->KilledMonsterCredit(NPC_GJALERBRON_PRISONER, 0); + + prisoner->AI()->Talk(SAY_FREE); + prisoner->ForcedDespawn(6000); + } + } + return true; + } +}; + +/*######## +## go_large_gjalerbron_cage +#####*/ + +class go_large_gjalerbron_cage : public GameObjectScript +{ + public: + go_large_gjalerbron_cage() : GameObjectScript("go_large_gjalerbron_cage") { } + + bool OnGossipHello(Player* player, GameObject* go) + { + if ((player->GetTeamId() == TEAM_ALLIANCE && player->GetQuestStatus(QUEST_ALLIANCE_OF_KEYS_AND_CAGES) == QUEST_STATUS_INCOMPLETE) || + (player->GetTeamId() == TEAM_HORDE && player->GetQuestStatus(QUEST_HORDE_OF_KEYS_AND_CAGES) == QUEST_STATUS_INCOMPLETE)) + { + std::list<Creature*> prisonerList; + GetCreatureListWithEntryInGrid(prisonerList, go, NPC_GJALERBRON_PRISONER, INTERACTION_DISTANCE); + for (std::list<Creature*>::const_iterator itr = prisonerList.begin(); itr != prisonerList.end(); ++itr) + { + go->UseDoorOrButton(); + player->KilledMonsterCredit(NPC_GJALERBRON_PRISONER, (*itr)->GetGUID()); + (*itr)->ForcedDespawn(6000); + (*itr)->AI()->Talk(SAY_FREE); + } + } + return false; + } }; void AddSC_go_scripts() @@ -1224,4 +1289,6 @@ void AddSC_go_scripts() new go_amberpine_outhouse; new go_hive_pod; new go_massive_seaforium_charge; + new go_gjalerbron_cage; + new go_large_gjalerbron_cage; } diff --git a/src/server/scripts/World/npc_professions.cpp b/src/server/scripts/World/npc_professions.cpp index 149e1e455aa..01f12086477 100644 --- a/src/server/scripts/World/npc_professions.cpp +++ b/src/server/scripts/World/npc_professions.cpp @@ -774,7 +774,7 @@ public: { bool res = false; npcTextId = textId; - if (player->GetBaseSkillValue(SKILL_ENGINERING) >= skillValue && player->HasSpell(reqSpellId)) + if (player->GetBaseSkillValue(SKILL_ENGINEERING) >= skillValue && player->HasSpell(reqSpellId)) { if (!player->HasSpell(spellId)) res = true; @@ -790,7 +790,7 @@ public: std::string gossipItem; bool canLearn = false; - if (player->HasSkill(SKILL_ENGINERING)) + if (player->HasSkill(SKILL_ENGINEERING)) { switch (creature->GetEntry()) { diff --git a/src/server/shared/Common.h b/src/server/shared/Common.h index ffecf020d24..bc9c0c62ccc 100755 --- a/src/server/shared/Common.h +++ b/src/server/shared/Common.h @@ -146,12 +146,12 @@ inline float finiteAlways(float f) { return finite(f) ? f : 0.0f; } enum TimeConstants { - MINUTE = 60, - HOUR = MINUTE*60, - DAY = HOUR*24, - WEEK = DAY*7, - MONTH = DAY*30, - YEAR = MONTH*12, + MINUTE = 60, + HOUR = MINUTE*60, + DAY = HOUR*24, + WEEK = DAY*7, + MONTH = DAY*30, + YEAR = MONTH*12, IN_MILLISECONDS = 1000 }; @@ -203,4 +203,17 @@ typedef std::vector<std::string> StringVector; #endif #define MAX_QUERY_LEN 32*1024 + +#define TRINITY_GUARD(MUTEX, LOCK) \ + ACE_Guard< MUTEX > TRINITY_GUARD_OBJECT (LOCK); \ + if (TRINITY_GUARD_OBJECT.locked() == 0) ASSERT(false); + +# define TRINITY_WRITE_GUARD(MUTEX, LOCK) \ + ACE_Write_Guard< MUTEX > TRINITY_GUARD_OBJECT (LOCK); \ + if (TRINITY_GUARD_OBJECT.locked() == 0) ASSERT(false); + +# define TRINITY_READ_GUARD(MUTEX, LOCK) \ + ACE_Read_Guard< MUTEX > TRINITY_GUARD_OBJECT (LOCK); \ + if (TRINITY_GUARD_OBJECT.locked() == 0) ASSERT(false); + #endif diff --git a/src/server/shared/Cryptography/ARC4.h b/src/server/shared/Cryptography/ARC4.h index 777dbb8cb99..abf753be02f 100755 --- a/src/server/shared/Cryptography/ARC4.h +++ b/src/server/shared/Cryptography/ARC4.h @@ -19,7 +19,7 @@ #ifndef _AUTH_SARC4_H #define _AUTH_SARC4_H -#include "Common.h" +#include "Define.h" #include <openssl/evp.h> class ARC4 diff --git a/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp b/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp index 146f4e992b7..a2db02dfbe3 100755 --- a/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp +++ b/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp @@ -18,12 +18,11 @@ #include "AuthCrypt.h" #include "Cryptography/HMACSHA1.h" -#include "Logging/Log.h" #include "Cryptography/BigNumber.h" AuthCrypt::AuthCrypt() : _clientDecrypt(SHA_DIGEST_LENGTH), _serverEncrypt(SHA_DIGEST_LENGTH) + , _initialized(false) { - _initialized = false; } AuthCrypt::~AuthCrypt() diff --git a/src/server/shared/Cryptography/Authentication/AuthCrypt.h b/src/server/shared/Cryptography/Authentication/AuthCrypt.h index 0304ef6b69e..e7463b0d962 100755 --- a/src/server/shared/Cryptography/Authentication/AuthCrypt.h +++ b/src/server/shared/Cryptography/Authentication/AuthCrypt.h @@ -19,7 +19,6 @@ #ifndef _AUTHCRYPT_H #define _AUTHCRYPT_H -#include <Common.h> #include "Cryptography/ARC4.h" class BigNumber; diff --git a/src/server/shared/Cryptography/BigNumber.cpp b/src/server/shared/Cryptography/BigNumber.cpp index 6149a680594..76cb74d5e13 100755 --- a/src/server/shared/Cryptography/BigNumber.cpp +++ b/src/server/shared/Cryptography/BigNumber.cpp @@ -18,31 +18,30 @@ #include "Cryptography/BigNumber.h" #include <openssl/bn.h> +#include <openssl/crypto.h> #include <algorithm> BigNumber::BigNumber() -{ - _bn = BN_new(); - _array = NULL; -} + : _bn(BN_new()) + , _array(NULL) +{ } BigNumber::BigNumber(const BigNumber &bn) -{ - _bn = BN_dup(bn._bn); - _array = NULL; -} + : _bn(BN_dup(bn._bn)) + , _array(NULL) +{ } BigNumber::BigNumber(uint32 val) + : _bn(BN_new()) + , _array(NULL) { - _bn = BN_new(); BN_set_word(_bn, val); - _array = NULL; } BigNumber::~BigNumber() { BN_free(_bn); - if (_array) delete[] _array; + delete[] _array; } void BigNumber::SetDword(uint32 val) @@ -76,6 +75,8 @@ void BigNumber::SetRand(int numbits) BigNumber BigNumber::operator=(const BigNumber &bn) { + if (this == &bn) + return *this; BN_copy(_bn, bn._bn); return *this; } diff --git a/src/server/shared/Cryptography/BigNumber.h b/src/server/shared/Cryptography/BigNumber.h index 485d4ced470..eb450c27777 100755 --- a/src/server/shared/Cryptography/BigNumber.h +++ b/src/server/shared/Cryptography/BigNumber.h @@ -19,7 +19,7 @@ #ifndef _AUTH_BIGNUMBER_H #define _AUTH_BIGNUMBER_H -#include "Common.h" +#include "Define.h" struct bignum_st; diff --git a/src/server/shared/Cryptography/HMACSHA1.h b/src/server/shared/Cryptography/HMACSHA1.h index 180ac6f4262..2d6e0c276a8 100755 --- a/src/server/shared/Cryptography/HMACSHA1.h +++ b/src/server/shared/Cryptography/HMACSHA1.h @@ -19,7 +19,8 @@ #ifndef _AUTH_HMAC_H #define _AUTH_HMAC_H -#include "Common.h" +#include "Define.h" +#include <string> #include <openssl/hmac.h> #include <openssl/sha.h> diff --git a/src/server/shared/Cryptography/SHA1.h b/src/server/shared/Cryptography/SHA1.h index 27e2d3290d0..9cb9b7b90f9 100755 --- a/src/server/shared/Cryptography/SHA1.h +++ b/src/server/shared/Cryptography/SHA1.h @@ -19,9 +19,9 @@ #ifndef _AUTH_SHA1_H #define _AUTH_SHA1_H -#include "Common.h" +#include "Define.h" +#include <string> #include <openssl/sha.h> -#include <openssl/crypto.h> class BigNumber; diff --git a/src/server/shared/Dynamic/TypeContainer.h b/src/server/shared/Dynamic/TypeContainer.h index 0fb3eb25347..7f6f5fa661c 100755 --- a/src/server/shared/Dynamic/TypeContainer.h +++ b/src/server/shared/Dynamic/TypeContainer.h @@ -108,11 +108,11 @@ class TypeMapContainer } /// Removes the object from the container, and returns the removed object - template<class SPECIFIC_TYPE> bool remove(SPECIFIC_TYPE* obj) - { - SPECIFIC_TYPE* t = Trinity::Remove(i_elements, obj); - return (t != NULL); - } + //template<class SPECIFIC_TYPE> bool remove(SPECIFIC_TYPE* obj) + //{ + // SPECIFIC_TYPE* t = Trinity::Remove(i_elements, obj); + // return (t != NULL); + //} ContainerMapList<OBJECT_TYPES> & GetElements(void) { return i_elements; } const ContainerMapList<OBJECT_TYPES> & GetElements(void) const { return i_elements;} diff --git a/src/server/shared/Dynamic/TypeContainerFunctions.h b/src/server/shared/Dynamic/TypeContainerFunctions.h index 981cd82197f..9bfbf47da93 100755 --- a/src/server/shared/Dynamic/TypeContainerFunctions.h +++ b/src/server/shared/Dynamic/TypeContainerFunctions.h @@ -62,7 +62,7 @@ namespace Trinity template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Insert(ContainerMapList<SPECIFIC_TYPE> &elements, SPECIFIC_TYPE *obj) { //elements._element[hdl] = obj; - obj->GetGridRef().link(&elements._element, obj); + obj->AddToGrid(elements._element); return obj; }; @@ -84,31 +84,30 @@ namespace Trinity return (t != NULL ? t : Insert(elements._TailElements, obj)); } - // non-const remove method - template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<SPECIFIC_TYPE> & /*elements*/, SPECIFIC_TYPE *obj) - { - obj->GetGridRef().unlink(); - return obj; - } - - template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<TypeNull> &/*elements*/, SPECIFIC_TYPE * /*obj*/) - { - return NULL; - } - - // this is a missed - template<class SPECIFIC_TYPE, class T> SPECIFIC_TYPE* Remove(ContainerMapList<T> &/*elements*/, SPECIFIC_TYPE * /*obj*/) - { - return NULL; // a missed - } - - template<class SPECIFIC_TYPE, class T, class H> SPECIFIC_TYPE* Remove(ContainerMapList<TypeList<H, T> > &elements, SPECIFIC_TYPE *obj) - { - // The head element is bad - SPECIFIC_TYPE* t = Remove(elements._elements, obj); - return ( t != NULL ? t : Remove(elements._TailElements, obj) ); - } - + //// non-const remove method + //template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<SPECIFIC_TYPE> & /*elements*/, SPECIFIC_TYPE *obj) + //{ + // obj->GetGridRef().unlink(); + // return obj; + //} + + //template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<TypeNull> &/*elements*/, SPECIFIC_TYPE * /*obj*/) + //{ + // return NULL; + //} + + //// this is a missed + //template<class SPECIFIC_TYPE, class T> SPECIFIC_TYPE* Remove(ContainerMapList<T> &/*elements*/, SPECIFIC_TYPE * /*obj*/) + //{ + // return NULL; // a missed + //} + + //template<class SPECIFIC_TYPE, class T, class H> SPECIFIC_TYPE* Remove(ContainerMapList<TypeList<H, T> > &elements, SPECIFIC_TYPE *obj) + //{ + // // The head element is bad + // SPECIFIC_TYPE* t = Remove(elements._elements, obj); + // return ( t != NULL ? t : Remove(elements._TailElements, obj) ); + //} } #endif diff --git a/src/server/shared/Dynamic/UnorderedMap.h b/src/server/shared/Dynamic/UnorderedMap.h index c698cc0a823..92a7dddf8a8 100755 --- a/src/server/shared/Dynamic/UnorderedMap.h +++ b/src/server/shared/Dynamic/UnorderedMap.h @@ -71,4 +71,3 @@ namespace __gnu_cxx using std::hash_map; #endif #endif - diff --git a/src/server/shared/Logging/Log.cpp b/src/server/shared/Logging/Log.cpp index 56c02a8e77b..15008f13c10 100755 --- a/src/server/shared/Logging/Log.cpp +++ b/src/server/shared/Logging/Log.cpp @@ -139,7 +139,7 @@ void Log::Initialize() { bool m_gmlog_timestamp = ConfigMgr::GetBoolDefault("GmLogTimestamp", false); - size_t dot_pos = m_gmlog_filename_format.find_last_of("."); + size_t dot_pos = m_gmlog_filename_format.find_last_of('.'); if (dot_pos!=m_gmlog_filename_format.npos) { if (m_gmlog_timestamp) diff --git a/src/server/shared/Logging/Log.h b/src/server/shared/Logging/Log.h index 5c23616ac5c..5b2eb6aafb6 100755 --- a/src/server/shared/Logging/Log.h +++ b/src/server/shared/Logging/Log.h @@ -102,8 +102,10 @@ const int Colors = int(WHITE)+1; class Log { friend class ACE_Singleton<Log, ACE_Thread_Mutex>; - Log(); - ~Log(); + + private: + Log(); + ~Log(); public: void Initialize(); diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index 187258e41b3..5919529c6bf 100755 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -17,7 +17,6 @@ */ #include "Util.h" - #include "utf8.h" #ifdef USE_SFMT_FOR_RNG #include "SFMT.h" @@ -162,13 +161,13 @@ std::string secsToTimeString(uint64 timeInSecs, bool shortText, bool hoursOnly) std::ostringstream ss; if (days) - ss << days << (shortText ? "d " : " Day(s) "); + ss << days << (shortText ? "d" : " Day(s) "); if (hours || hoursOnly) - ss << hours << (shortText ? "h " : " Hour(s) "); + ss << hours << (shortText ? "h" : " Hour(s) "); if (!hoursOnly) { if (minutes) - ss << minutes << (shortText ? "m " : " Minute(s) "); + ss << minutes << (shortText ? "m" : " Minute(s) "); if (secs || (!days && !hours && !minutes) ) ss << secs << (shortText ? "s" : " Second(s)."); } diff --git a/src/server/worldserver/CommandLine/CliRunnable.cpp b/src/server/worldserver/CommandLine/CliRunnable.cpp index cf5ad79f878..564f6028eca 100755 --- a/src/server/worldserver/CommandLine/CliRunnable.cpp +++ b/src/server/worldserver/CommandLine/CliRunnable.cpp @@ -115,6 +115,7 @@ void commandFinished(void*, bool /*success*/) printf("TC> "); fflush(stdout); } + /** * Collects all GUIDs (and related info) from deleted characters which are still in the database. * @@ -562,10 +563,11 @@ void CliRunnable::run() { ///- Display the list of available CLI functions then beep //sLog->outString(""); - #if PLATFORM != PLATFORM_WINDOWS +#if PLATFORM != PLATFORM_WINDOWS rl_attempted_completion_function = cli_completion; rl_event_hook = cli_hook_func; - #endif +#endif + if (ConfigMgr::GetBoolDefault("BeepAtStart", true)) printf("\a"); // \a = Alert @@ -580,49 +582,49 @@ void CliRunnable::run() char *command_str ; // = fgets(commandbuf, sizeof(commandbuf), stdin); - #if PLATFORM == PLATFORM_WINDOWS +#if PLATFORM == PLATFORM_WINDOWS char commandbuf[256]; command_str = fgets(commandbuf, sizeof(commandbuf), stdin); - #else +#else command_str = readline("TC>"); rl_bind_key('\t', rl_complete); - #endif +#endif + if (command_str != NULL) { - for (int x=0; command_str[x]; x++) - if (command_str[x]=='\r'||command_str[x]=='\n') + for (int x=0; command_str[x]; ++x) + if (command_str[x] == '\r' || command_str[x] == '\n') { - command_str[x]=0; + command_str[x] = 0; break; } if (!*command_str) { - #if PLATFORM == PLATFORM_WINDOWS +#if PLATFORM == PLATFORM_WINDOWS printf("TC>"); - #endif +#endif continue; } std::string command; if (!consoleToUtf8(command_str, command)) // convert from console encoding to utf8 { - #if PLATFORM == PLATFORM_WINDOWS +#if PLATFORM == PLATFORM_WINDOWS printf("TC>"); - #endif +#endif continue; } + fflush(stdout); sWorld->QueueCliCommand(new CliCommandHolder(NULL, command.c_str(), &utf8print, &commandFinished)); - #if PLATFORM != PLATFORM_WINDOWS +#if PLATFORM != PLATFORM_WINDOWS add_history(command.c_str()); - #endif - +#endif } else if (feof(stdin)) { World::StopNow(SHUTDOWN_EXIT_CODE); } - } } diff --git a/src/server/worldserver/Master.cpp b/src/server/worldserver/Master.cpp index 5260140fef0..42d72aa2c6f 100755 --- a/src/server/worldserver/Master.cpp +++ b/src/server/worldserver/Master.cpp @@ -462,7 +462,6 @@ bool Master::_StartDB() sWorld->LoadDBVersion(); sLog->outString("Using World DB: %s", sWorld->GetDBVersion()); - sLog->outString("Using creature EventAI: %s", sWorld->GetCreatureEventAIVersion()); return true; } diff --git a/src/server/worldserver/RemoteAccess/RARunnable.cpp b/src/server/worldserver/RemoteAccess/RARunnable.cpp index d7cee88b994..60145cf99aa 100644 --- a/src/server/worldserver/RemoteAccess/RARunnable.cpp +++ b/src/server/worldserver/RemoteAccess/RARunnable.cpp @@ -33,22 +33,17 @@ #include "RASocket.h" -RARunnable::RARunnable() : m_Reactor(NULL) +RARunnable::RARunnable() { - ACE_Reactor_Impl* imp = 0; + ACE_Reactor_Impl* imp = NULL; #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 - imp = new ACE_TP_Reactor(); imp->max_notify_iterations (128); - #endif m_Reactor = new ACE_Reactor (imp, 1); @@ -68,7 +63,6 @@ void RARunnable::run() uint16 raport = ConfigMgr::GetIntDefault("Ra.Port", 3443); std::string stringip = ConfigMgr::GetStringDefault("Ra.IP", "0.0.0.0"); - ACE_INET_Addr listen_addr(raport, stringip.c_str()); if (acceptor.open(listen_addr, m_Reactor) == -1) @@ -84,7 +78,6 @@ void RARunnable::run() // don't be too smart to move this outside the loop // the run_reactor_event_loop will modify interval ACE_Time_Value interval(0, 100000); - if (m_Reactor->run_reactor_event_loop(interval) == -1) break; } |