diff options
author | Nay <dnpd.dd@gmail.com> | 2013-07-22 16:27:10 -0700 |
---|---|---|
committer | Nay <dnpd.dd@gmail.com> | 2013-07-22 16:27:10 -0700 |
commit | f5a44b19a83f6c7c06ddd0c988ffadc84ce87bbb (patch) | |
tree | 8ae9c7f1745f307d493b87c0563eeccbb62dbc5b /src | |
parent | cd2c33c4ebbacbac3a230d5d040b936d600d308a (diff) | |
parent | ddb1183f6adc3f5333e5e34203c7c3939880c067 (diff) |
Merge pull request #10320 from joschiwald/battleground
Core/Battleground: use generic function to relocate players to closest g...
Diffstat (limited to 'src')
6 files changed, 30 insertions, 61 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 4c2fc571ee3..ca9f8f5891b 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -1425,6 +1425,29 @@ void Battleground::RemovePlayerFromResurrectQueue(uint64 player_guid) } } +void Battleground::RelocateDeadPlayers(uint32 queueIndex) +{ + // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard + std::vector<uint64>& ghostList = m_ReviveQueue[queueIndex]; + if (!ghostList.empty()) + { + WorldSafeLocsEntry const* closestGrave = NULL; + for (std::vector<uint64>::const_iterator itr = ghostList.begin(); itr != ghostList.end(); ++itr) + { + Player* player = ObjectAccessor::FindPlayer(*itr); + if (!player) + continue; + + if (!closestGrave) + closestGrave = GetClosestGraveYard(player); + + if (closestGrave) + player->TeleportTo(GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation()); + } + ghostList.clear(); + } +} + bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 /*respawnTime*/) { // If the assert is called, means that BgObjects must be resized! diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index dd8fbb6710c..8bcd5d8683c 100644 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -375,6 +375,9 @@ class Battleground void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid); void RemovePlayerFromResurrectQueue(uint64 player_guid); + /// Relocate all players in ReviveQueue to the closest graveyard + void RelocateDeadPlayers(uint32 queueIndex); + void StartBattleground(); GameObject* GetBGObject(uint32 type); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp index f986a52e3c9..bef0e995988 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp @@ -397,24 +397,7 @@ void BattlegroundAB::_NodeDeOccupied(uint8 node) if (node < BG_AB_DYNAMIC_NODES_COUNT)//only dynamic nodes, no start points DelCreature(node+7);//NULL checks are in DelCreature! 0-6 spirit guides - // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard - std::vector<uint64> ghost_list = m_ReviveQueue[BgCreatures[node]]; - if (!ghost_list.empty()) - { - WorldSafeLocsEntry const* ClosestGrave = NULL; - for (std::vector<uint64>::const_iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr) - { - Player* player = ObjectAccessor::FindPlayer(*itr); - if (!player) - continue; - - if (!ClosestGrave) // cache - ClosestGrave = GetClosestGraveYard(player); - - if (ClosestGrave) - player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation()); - } - } + RelocateDeadPlayers(BgCreatures[node]); if (BgCreatures[node]) DelCreature(node); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index 5dc20ab8f07..a72b1eb4eb1 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -1049,25 +1049,8 @@ void BattlegroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object) //spawning/despawning of aura SpawnBGObject(BG_AV_OBJECT_AURA_N_FIRSTAID_STATION+3*node, RESPAWN_IMMEDIATELY); //neutral aura spawn SpawnBGObject(BG_AV_OBJECT_AURA_A_FIRSTAID_STATION+GetTeamIndexByTeamId(owner)+3*node, RESPAWN_ONE_DAY); //teeamaura despawn - // Those who are waiting to resurrect at this object are taken to the closest own object's graveyard - std::vector<uint64> ghost_list = m_ReviveQueue[BgCreatures[node]]; - if (!ghost_list.empty()) - { - Player* waitingPlayer; // player waiting at graveyard for resurrection - WorldSafeLocsEntry const* closestGrave = NULL; - for (std::vector<uint64>::iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr) - { - waitingPlayer = ObjectAccessor::FindPlayer(*ghost_list.begin()); - if (!waitingPlayer) - continue; - - if (!closestGrave) - closestGrave = GetClosestGraveYard(waitingPlayer); - else - waitingPlayer->TeleportTo(GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation()); - } - m_ReviveQueue[BgCreatures[node]].clear(); - } + + RelocateDeadPlayers(BgCreatures[node]); } DePopulateNode(node); } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp index 983c690523e..d9708ac5d84 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp @@ -481,28 +481,6 @@ void BattlegroundIC::EndBattleground(uint32 winner) Battleground::EndBattleground(winner); } -void BattlegroundIC::RealocatePlayers(ICNodePointType nodeType) -{ - // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard - std::vector<uint64> ghost_list = m_ReviveQueue[BgCreatures[BG_IC_NPC_SPIRIT_GUIDE_1+nodeType-2]]; - if (!ghost_list.empty()) - { - WorldSafeLocsEntry const* ClosestGrave = NULL; - for (std::vector<uint64>::const_iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr) - { - Player* player = ObjectAccessor::FindPlayer(*itr); - if (!player) - continue; - - if (!ClosestGrave) // cache - ClosestGrave = GetClosestGraveYard(player); - - if (ClosestGrave) - player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation()); - } - } -} - void BattlegroundIC::EventPlayerClickedOnFlag(Player* player, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS) @@ -531,7 +509,7 @@ void BattlegroundIC::EventPlayerClickedOnFlag(Player* player, GameObject* target nodePoint[i].timer = BANNER_STATE_CHANGE_TIME; // 1 minute for last change (real faction banner) nodePoint[i].needChange = true; - RealocatePlayers(nodePoint[i].nodeType); + RelocateDeadPlayers(BgCreatures[BG_IC_NPC_SPIRIT_GUIDE_1 + nodePoint[i].nodeType - 2]); // if we are here means that the point has been lost, or it is the first capture diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h index 7845c002155..f25fbe297b3 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h @@ -950,7 +950,6 @@ class BattlegroundIC : public Battleground return uws; } - void RealocatePlayers(ICNodePointType nodeType); void UpdateNodeWorldState(ICNodePoint* nodePoint); void HandleCapturedNodes(ICNodePoint* nodePoint, bool recapture); void HandleContestedNodes(ICNodePoint* nodePoint); |