diff options
| author | Discover- <amort11@hotmail.com> | 2013-08-06 13:25:22 +0200 |
|---|---|---|
| committer | Discover- <amort11@hotmail.com> | 2013-08-06 13:26:52 +0200 |
| commit | 7f744de746de3d91fea576cd9ff352851be0436a (patch) | |
| tree | b49f82dd814b1b85696ee4f12e06d76b5d31e80f /src/server/game | |
| parent | 5164caa9ffb436ce5a3cbd9c344311eca5d95175 (diff) | |
Core/Misc: Implement reinterpret casts for all battleground classes and use them.
Diffstat (limited to 'src/server/game')
| -rw-r--r-- | src/server/game/Battlegrounds/Battleground.h | 44 | ||||
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 8 | ||||
| -rw-r--r-- | src/server/game/Handlers/QuestHandler.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 2 |
5 files changed, 54 insertions, 4 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index 52f86b98b79..ae095f0f740 100644 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -29,6 +29,17 @@ class Group; class Player; class WorldPacket; class BattlegroundMap; +class BattlegroundAV; +class BattlegroundWS; +class BattlegroundAB; +class BattlegroundNA; +class BattlegroundBE; +class BattlegroundEY; +class BattlegroundRL; +class BattlegroundSA; +class BattlegroundDS; +class BattlegroundRV; +class BattlegroundIC; struct PvPDifficultyEntry; struct WorldSafeLocsEntry; @@ -534,6 +545,39 @@ class Battleground virtual uint32 GetPrematureWinner(); + BattlegroundAV* ToBattlegroundAV() { if (GetTypeID() == BATTLEGROUND_AV) return reinterpret_cast<BattlegroundAV*>(this); else return NULL; } + BattlegroundAV const* ToBattlegroundAV() const { if (GetTypeID() == BATTLEGROUND_AV) return (BattlegroundAV const*)((BattlegroundAV*)this); else return NULL; } + + BattlegroundWS* ToBattlegroundWS() { if (GetTypeID() == BATTLEGROUND_WS) return reinterpret_cast<BattlegroundWS*>(this); else return NULL; } + BattlegroundWS const* ToBattlegroundWS() const { if (GetTypeID() == BATTLEGROUND_WS) return (BattlegroundWS const*)((BattlegroundWS*)this); else return NULL; } + + BattlegroundAB* ToBattlegroundAB() { if (GetTypeID() == BATTLEGROUND_AB) return reinterpret_cast<BattlegroundAB*>(this); else return NULL; } + BattlegroundAB const* ToBattlegroundAB() const { if (GetTypeID() == BATTLEGROUND_AB) return (BattlegroundAB const*)((BattlegroundAB*)this); else return NULL; } + + BattlegroundNA* ToBattlegroundNA() { if (GetTypeID() == BATTLEGROUND_NA) return reinterpret_cast<BattlegroundNA*>(this); else return NULL; } + BattlegroundNA const* ToBattlegroundNA() const { if (GetTypeID() == BATTLEGROUND_NA) return (BattlegroundNA const*)((BattlegroundNA*)this); else return NULL; } + + BattlegroundBE* ToBattlegroundBE() { if (GetTypeID() == BATTLEGROUND_BE) return reinterpret_cast<BattlegroundBE*>(this); else return NULL; } + BattlegroundBE const* ToBattlegroundBE() const { if (GetTypeID() == BATTLEGROUND_BE) return (BattlegroundBE const*)((BattlegroundBE*)this); else return NULL; } + + BattlegroundEY* ToBattlegroundEY() { if (GetTypeID() == BATTLEGROUND_EY) return reinterpret_cast<BattlegroundEY*>(this); else return NULL; } + BattlegroundEY const* ToBattlegroundEY() const { if (GetTypeID() == BATTLEGROUND_EY) return (BattlegroundEY const*)((BattlegroundEY*)this); else return NULL; } + + BattlegroundRL* ToBattlegroundRL() { if (GetTypeID() == BATTLEGROUND_RL) return reinterpret_cast<BattlegroundRL*>(this); else return NULL; } + BattlegroundRL const* ToBattlegroundRL() const { if (GetTypeID() == BATTLEGROUND_RL) return (BattlegroundRL const*)((BattlegroundRL*)this); else return NULL; } + + BattlegroundSA* ToBattlegroundSA() { if (GetTypeID() == BATTLEGROUND_SA) return reinterpret_cast<BattlegroundSA*>(this); else return NULL; } + BattlegroundSA const* ToBattlegroundSA() const { if (GetTypeID() == BATTLEGROUND_SA) return (BattlegroundSA const*)((BattlegroundSA*)this); else return NULL; } + + BattlegroundDS* ToBattlegroundDS() { if (GetTypeID() == BATTLEGROUND_DS) return reinterpret_cast<BattlegroundDS*>(this); else return NULL; } + BattlegroundDS const* ToBattlegroundDS() const { if (GetTypeID() == BATTLEGROUND_DS) return (BattlegroundDS const*)((BattlegroundDS*)this); else return NULL; } + + BattlegroundRV* ToBattlegroundRV() { if (GetTypeID() == BATTLEGROUND_RV) return reinterpret_cast<BattlegroundRV*>(this); else return NULL; } + BattlegroundRV const* ToBattlegroundRV() const { if (GetTypeID() == BATTLEGROUND_RV) return (BattlegroundRV const*)((BattlegroundRV*)this); else return NULL; } + + BattlegroundIC* ToBattlegroundIC() { if (GetTypeID() == BATTLEGROUND_IC) return reinterpret_cast<BattlegroundIC*>(this); else return NULL; } + BattlegroundIC const* ToBattlegroundIC() const { if (GetTypeID() == BATTLEGROUND_IC) return (BattlegroundIC const*)((BattlegroundIC*)this); else return NULL; } + protected: // this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends Battleground void EndNow(); diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 0915d19cdfa..31e625ae3e1 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -952,7 +952,7 @@ bool GameObject::ActivateToQuest(Player* target) const //look for battlegroundAV for some objects which are only activated after mine gots captured by own team if (GetEntry() == BG_AV_OBJECTID_MINE_N || GetEntry() == BG_AV_OBJECTID_MINE_S) if (Battleground* bg = target->GetBattleground()) - if (bg->GetTypeID(true) == BATTLEGROUND_AV && !(((BattlegroundAV*)bg)->PlayerCanDoMineQuest(GetEntry(), target->GetTeam()))) + if (bg->GetTypeID(true) == BATTLEGROUND_AV && !bg->ToBattlegroundAV()->PlayerCanDoMineQuest(GetEntry(), target->GetTeam())) return false; return true; } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 8f1669910e7..3572222b74d 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -8773,13 +8773,19 @@ void Player::SendLoot(uint64 guid, LootType loot_type) /// @todo fix this big hack if ((go->GetEntry() == BG_AV_OBJECTID_MINE_N || go->GetEntry() == BG_AV_OBJECTID_MINE_S)) + { if (Battleground* bg = GetBattleground()) + { if (bg->GetTypeID(true) == BATTLEGROUND_AV) - if (!(((BattlegroundAV*)bg)->PlayerCanDoMineQuest(go->GetEntry(), GetTeam()))) + { + if (!bg->ToBattlegroundAV()->PlayerCanDoMineQuest(go->GetEntry(), GetTeam())) { SendLootRelease(guid); return; } + } + } + } if (lootid) { diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 6cd999bc496..cee5b3d1164 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -530,7 +530,7 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recvData) if (_player->InBattleground()) if (Battleground* bg = _player->GetBattleground()) if (bg->GetTypeID() == BATTLEGROUND_AV) - ((BattlegroundAV*)bg)->HandleQuestComplete(questId, _player); + bg->ToBattlegroundAV()->HandleQuestComplete(questId, _player); if (_player->GetQuestStatus(questId) != QUEST_STATUS_COMPLETE) { diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 42d408ebbad..db0102f4307 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -1136,7 +1136,7 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32 uint8 nodeType = spellId == 68719 ? NODE_TYPE_REFINERY : NODE_TYPE_QUARRY; uint8 nodeState = player->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H; - BattlegroundIC* pIC = static_cast<BattlegroundIC*>(player->GetBattleground()); + BattlegroundIC* pIC = player->GetBattleground()->ToBattlegroundIC(); if (pIC->GetNodeState(nodeType) == nodeState) return true; |
