Core/Misc: Implement reinterpret casts for all battleground classes and use them.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class achievement_resilient_victory : public AchievementCriteriaScript
|
||||
if (bg->GetTypeID(true) != BATTLEGROUND_AB)
|
||||
return false;
|
||||
|
||||
if (!static_cast<BattlegroundAB*>(bg)->IsTeamScores500Disadvantage(source->GetTeam()))
|
||||
if (!bg->ToBattlegroundAB()->IsTeamScores500Disadvantage(source->GetTeam()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -84,7 +84,7 @@ class achievement_save_the_day : public AchievementCriteriaScript
|
||||
if (bg->GetTypeID(true) != BATTLEGROUND_WS)
|
||||
return false;
|
||||
|
||||
if (static_cast<BattlegroundWS*>(bg)->GetFlagState(player->GetTeam()) == BG_WS_FLAG_STATE_ON_BASE)
|
||||
if (bg->ToBattlegroundWS()->GetFlagState(player->GetTeam()) == BG_WS_FLAG_STATE_ON_BASE)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -209,7 +209,7 @@ class achievement_everything_counts : public AchievementCriteriaScript
|
||||
if (bg->GetTypeID(true) != BATTLEGROUND_AV)
|
||||
return false;
|
||||
|
||||
if (static_cast<BattlegroundAV*>(bg)->IsBothMinesControlledByTeam(source->GetTeam()))
|
||||
if (bg->ToBattlegroundAV()->IsBothMinesControlledByTeam(source->GetTeam()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -230,7 +230,7 @@ class achievement_bg_av_perfection : public AchievementCriteriaScript
|
||||
if (bg->GetTypeID(true) != BATTLEGROUND_AV)
|
||||
return false;
|
||||
|
||||
if (static_cast<BattlegroundAV*>(bg)->IsAllTowersControlledAndCaptainAlive(source->GetTeam()))
|
||||
if (bg->ToBattlegroundAV()->IsAllTowersControlledAndCaptainAlive(source->GetTeam()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -253,10 +253,10 @@ class achievement_bg_sa_defense_of_ancients : public AchievementCriteriaScript
|
||||
if (!battleground)
|
||||
return false;
|
||||
|
||||
if (player->GetTeamId() == static_cast<BattlegroundSA*>(battleground)->Attackers)
|
||||
if (player->GetTeamId() == battleground->ToBattlegroundSA()->Attackers)
|
||||
return false;
|
||||
|
||||
if (!static_cast<BattlegroundSA*>(battleground)->gateDestroyed)
|
||||
if (!battleground->ToBattlegroundSA()->gateDestroyed)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -308,7 +308,7 @@ class achievement_not_even_a_scratch : public AchievementCriteriaScript
|
||||
if (!battleground)
|
||||
return false;
|
||||
|
||||
if (static_cast<BattlegroundSA*>(battleground)->notEvenAScratch(source->GetTeam()))
|
||||
if (battleground->ToBattlegroundSA()->notEvenAScratch(source->GetTeam()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user