diff --git a/src/game/BattleGround/BattleGroundMgr.cpp b/src/game/BattleGround/BattleGroundMgr.cpp index a9376bd8d7d..97931e6255e 100644 --- a/src/game/BattleGround/BattleGroundMgr.cpp +++ b/src/game/BattleGround/BattleGroundMgr.cpp @@ -2488,7 +2488,7 @@ void BattleGroundMgr::ScheduleQueueUpdate(uint32 arenaRating, ArenaType arenaTyp { // std::lock_guard guard(SchedulerLock); // we will use only 1 number created of bgTypeId and bracket_id - uint64 schedule_id = ((uint64)arenaRating << 32) | (arenaType << 24) | (bgQueueTypeId << 16) | (bgTypeId << 8) | bracketId; + uint64 schedule_id = (uint64(arenaRating) << 32) | (uint64(arenaType) << 24) | (uint64(bgQueueTypeId) << 16) | (uint64(bgTypeId) << 8) | bracketId; bool found = false; for (unsigned long long i : m_queueUpdateScheduler) { diff --git a/src/game/Entities/GameObject.cpp b/src/game/Entities/GameObject.cpp index 126f8209e78..8bb721875d6 100644 --- a/src/game/Entities/GameObject.cpp +++ b/src/game/Entities/GameObject.cpp @@ -1539,10 +1539,10 @@ void GameObject::Use(Unit* user, SpellEntry const* spellInfo) if (goInfo->trap.charges > 0) AddUse(); - if (IsBattleGroundTrap && user->GetTypeId() == TYPEID_PLAYER) + if (IsBattleGroundTrap && user->IsPlayer()) { // BattleGround gameobjects case - if (BattleGround* bg = ((Player*)user)->GetBattleGround()) + if (BattleGround* bg = static_cast(user)->GetBattleGround()) bg->HandleTriggerBuff(GetObjectGuid()); } @@ -1553,7 +1553,6 @@ void GameObject::Use(Unit* user, SpellEntry const* spellInfo) if (goInfo->ExtraFlags & GAMEOBJECT_EXTRA_FLAG_CUSTOM_ANIM_ON_USE) SendGameObjectCustomAnim(GetObjectGuid()); - // TODO: Despawning of traps? (Also related to code in ::Update) return; } case GAMEOBJECT_TYPE_CHAIR: // 7 Sitting: Wooden bench, chairs diff --git a/src/game/Entities/Player.cpp b/src/game/Entities/Player.cpp index 558a1fad6e7..d8efbf3daaa 100644 --- a/src/game/Entities/Player.cpp +++ b/src/game/Entities/Player.cpp @@ -20022,7 +20022,7 @@ BattleGround* Player::GetBattleGround() const if (GetBattleGroundId() == 0) return nullptr; - return sBattleGroundMgr.GetBattleGround(GetBattleGroundId(), m_bgData.bgTypeID); + return GetMap()->GetBG(); } bool Player::InArena() const diff --git a/src/game/Entities/Unit.cpp b/src/game/Entities/Unit.cpp index f0642db0e0d..7a3f9c56c62 100644 --- a/src/game/Entities/Unit.cpp +++ b/src/game/Entities/Unit.cpp @@ -1025,12 +1025,12 @@ uint32 Unit::DealDamage(Unit* dealer, Unit* victim, uint32 damage, CleanDamage c duel_hasEnded = true; } - if (dealer->GetTypeId() == TYPEID_PLAYER && dealer != victim) + if (dealer->IsPlayer() && dealer != victim) { Player* killer = static_cast(dealer); // in bg, count dmg if victim is also a player - if (victim->GetTypeId() == TYPEID_PLAYER) + if (victim->IsPlayer()) { if (BattleGround* bg = killer->GetBattleGround()) { @@ -7206,10 +7206,10 @@ int32 Unit::DealHeal(Unit* pVictim, uint32 addhealth, SpellEntry const* spellPro unit->SendHealSpellLog(pVictim, spellProto->Id, addhealth, critical); - if (unit->GetTypeId() == TYPEID_PLAYER) + if (unit->IsPlayer()) { - if (BattleGround* bg = ((Player*)unit)->GetBattleGround()) - bg->UpdatePlayerScore((Player*)unit, SCORE_HEALING_DONE, gain); + if (BattleGround* bg = static_cast(unit)->GetBattleGround()) + bg->UpdatePlayerScore(static_cast(unit), SCORE_HEALING_DONE, gain); } // Script Event HealedBy diff --git a/src/game/Grids/ObjectGridLoader.cpp b/src/game/Grids/ObjectGridLoader.cpp index e49edbba009..bbab44e43ac 100644 --- a/src/game/Grids/ObjectGridLoader.cpp +++ b/src/game/Grids/ObjectGridLoader.cpp @@ -114,7 +114,7 @@ template<> void addUnitState(Creature* obj, CellPair const& cell_pair) template void LoadHelper(CellGuidSet const& guid_set, CellPair& cell, GridRefManager& /*m*/, uint32& count, Map* map, GridType& grid) { - BattleGround* bg = map->IsBattleGroundOrArena() ? ((BattleGroundMap*)map)->GetBG() : nullptr; + BattleGround* bg = map->GetBG(); for (uint32 guid : guid_set) { diff --git a/src/game/Maps/Map.h b/src/game/Maps/Map.h index dce640727d2..41796401b04 100644 --- a/src/game/Maps/Map.h +++ b/src/game/Maps/Map.h @@ -417,6 +417,8 @@ class Map : public GridRefManager WorldStateVariableManager& GetVariableManager() { return m_variableManager; } WorldStateVariableManager const& GetVariableManager() const { return m_variableManager; } + virtual BattleGround* GetBG() const { return nullptr; } + // debug std::set m_objRemoveList; // this will eventually eat up too much memory - only used for debugging VisibleNotifier::Notify() customlog leak @@ -622,7 +624,7 @@ class BattleGroundMap : public Map void UnloadAll(bool pForce) override; virtual void InitVisibilityDistance() override; - BattleGround* GetBG() const { return m_bg; } + BattleGround* GetBG() const override { return m_bg; } void SetBG(BattleGround* bg) { m_bg = bg; } // can't be nullptr for loaded map diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp index 07c8504121b..28abad40ce9 100644 --- a/src/game/Spells/Spell.cpp +++ b/src/game/Spells/Spell.cpp @@ -4871,8 +4871,8 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_NOT_STANDING; // only allow triggered spells if at an ended battleground - if (!m_IsTriggeredSpell && m_caster->GetTypeId() == TYPEID_PLAYER) - if (BattleGround* bg = ((Player*)m_caster)->GetBattleGround()) + if (!m_IsTriggeredSpell && m_caster->IsPlayer()) + if (BattleGround* bg = static_cast(m_caster)->GetBattleGround()) if (bg->GetStatus() == STATUS_WAIT_LEAVE) return SPELL_FAILED_DONT_REPORT; diff --git a/src/game/Spells/SpellAuras.cpp b/src/game/Spells/SpellAuras.cpp index 892ae684c2f..e0cd982ef3c 100644 --- a/src/game/Spells/SpellAuras.cpp +++ b/src/game/Spells/SpellAuras.cpp @@ -6916,9 +6916,9 @@ void Aura::PeriodicTick() uint32 procEx = PROC_EX_NORMAL_HIT | PROC_EX_INTERNAL_HOT; // add HoTs to amount healed in bgs - if (pCaster->GetTypeId() == TYPEID_PLAYER) - if (BattleGround* bg = ((Player*)pCaster)->GetBattleGround()) - bg->UpdatePlayerScore(((Player*)pCaster), SCORE_HEALING_DONE, gain); + if (pCaster->IsPlayer()) + if (BattleGround* bg = static_cast(pCaster)->GetBattleGround()) + bg->UpdatePlayerScore(static_cast(pCaster), SCORE_HEALING_DONE, gain); if (pCaster->IsInCombat() && !pCaster->IsCrowdControlled()) target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto, false, true); diff --git a/src/game/Spells/SpellEffects.cpp b/src/game/Spells/SpellEffects.cpp index c3fdcc500a0..feac42afb4d 100644 --- a/src/game/Spells/SpellEffects.cpp +++ b/src/game/Spells/SpellEffects.cpp @@ -2461,8 +2461,8 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) if (m_caster->GetTypeId() != TYPEID_PLAYER) return; - if (BattleGround* bg = ((Player*)m_caster)->GetBattleGround()) - bg->HandlePlayerDroppedFlag((Player*)m_caster); + if (BattleGround* bg = static_cast(m_caster)->GetBattleGround()) + bg->HandlePlayerDroppedFlag(static_cast(m_caster)); m_caster->CastSpell(m_caster, 30452, TRIGGERED_OLD_TRIGGERED, nullptr); return; diff --git a/src/game/Spells/SpellMgr.cpp b/src/game/Spells/SpellMgr.cpp index 4dfb07023e3..f3ce7db38ec 100644 --- a/src/game/Spells/SpellMgr.cpp +++ b/src/game/Spells/SpellMgr.cpp @@ -2473,8 +2473,7 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell if (!player) return SPELL_FAILED_REQUIRES_AREA; BattleGround* bg = player->GetBattleGround(); - return map_id == 30 && bg - && bg->GetStatus() != STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA; + return map_id == 30 && bg && bg->GetStatus() != STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA; } case 2584: // Waiting to Resurrect case 42792: // Recently Dropped Flag