diff options
Diffstat (limited to 'src/server/game/Battlegrounds/Battleground.cpp')
-rw-r--r-- | src/server/game/Battlegrounds/Battleground.cpp | 79 |
1 files changed, 39 insertions, 40 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 6f6d1b66308..020ff3d397c 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -327,10 +327,10 @@ inline void Battleground::_ProcessResurrect(uint32 diff) { if (GetReviveQueueSize()) { - for (std::map<uint64, std::vector<uint64> >::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr) + for (std::map<ObjectGuid, GuidVector>::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr) { Creature* sh = NULL; - for (std::vector<uint64>::const_iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2) + for (GuidVector::const_iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2) { Player* player = ObjectAccessor::FindPlayer(*itr2); if (!player) @@ -361,7 +361,7 @@ inline void Battleground::_ProcessResurrect(uint32 diff) } else if (m_LastResurrectTime > 500) // Resurrect players only half a second later, to see spirit heal effect on NPC { - for (std::vector<uint64>::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr) + for (GuidVector::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr) { Player* player = ObjectAccessor::FindPlayer(*itr); if (!player) @@ -560,7 +560,7 @@ inline void Battleground::_ProcessLeave(uint32 diff) } } -Player* Battleground::_GetPlayer(uint64 guid, bool offlineRemove, char const* context) const +Player* Battleground::_GetPlayer(ObjectGuid guid, bool offlineRemove, char const* context) const { Player* player = NULL; if (!offlineRemove) @@ -568,7 +568,7 @@ Player* Battleground::_GetPlayer(uint64 guid, bool offlineRemove, char const* co player = ObjectAccessor::FindPlayer(guid); if (!player) TC_LOG_ERROR("bg.battleground", "Battleground::%s: player (GUID: %u) not found for BG (map: %u, instance id: %u)!", - context, GUID_LOPART(guid), m_MapId, m_InstanceID); + context, guid.GetCounter(), m_MapId, m_InstanceID); } return player; } @@ -851,7 +851,7 @@ void Battleground::BlockMovement(Player* player) 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) +void Battleground::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool SendPacket) { uint32 team = GetPlayerTeam(guid); bool participant = false; @@ -865,7 +865,7 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac participant = true; } - BattlegroundScoreMap::iterator itr2 = PlayerScores.find(GUID_LOPART(guid)); + BattlegroundScoreMap::iterator itr2 = PlayerScores.find(guid.GetCounter()); if (itr2 != PlayerScores.end()) { delete itr2->second; // delete player's score @@ -1014,7 +1014,6 @@ void Battleground::AddPlayer(Player* player) // score struct must be created in inherited class - uint64 guid = player->GetGUID(); uint32 team = player->GetBGTeam(); BattlegroundPlayer bp; @@ -1022,7 +1021,7 @@ void Battleground::AddPlayer(Player* player) bp.Team = team; // Add to list/maps - m_Players[guid] = bp; + m_Players[player->GetGUID()] = bp; UpdatePlayersCountByTeam(team, false); // +1 player @@ -1071,7 +1070,7 @@ void Battleground::AddPlayer(Player* player) // this method adds player to his team's bg group, or sets his correct group if player is already in bg group void Battleground::AddOrSetPlayerToCorrectBgGroup(Player* player, uint32 team) { - uint64 playerGuid = player->GetGUID(); + ObjectGuid playerGuid = player->GetGUID(); Group* group = GetBgRaid(team); if (!group) // first player joined { @@ -1102,9 +1101,9 @@ void Battleground::AddOrSetPlayerToCorrectBgGroup(Player* player, uint32 team) // This method should be called when player logs into running battleground void Battleground::EventPlayerLoggedIn(Player* player) { - uint64 guid = player->GetGUID(); + ObjectGuid guid = player->GetGUID(); // player is correct pointer - for (std::deque<uint64>::iterator itr = m_OfflineQueue.begin(); itr != m_OfflineQueue.end(); ++itr) + for (GuidDeque::iterator itr = m_OfflineQueue.begin(); itr != m_OfflineQueue.end(); ++itr) { if (*itr == guid) { @@ -1121,7 +1120,7 @@ void Battleground::EventPlayerLoggedIn(Player* player) // This method should be called when player logs out from running battleground void Battleground::EventPlayerLoggedOut(Player* player) { - uint64 guid = player->GetGUID(); + ObjectGuid guid = player->GetGUID(); if (!IsPlayerInBattleground(guid)) // Check if this player really is in battleground (might be a GM who teleported inside) return; @@ -1265,7 +1264,7 @@ bool Battleground::UpdatePlayerScore(Player* player, uint32 type, uint32 value, return true; } -void Battleground::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid) +void Battleground::AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid) { m_ReviveQueue[npc_guid].push_back(player_guid); @@ -1276,15 +1275,15 @@ void Battleground::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid player->CastSpell(player, SPELL_WAITING_FOR_RESURRECT, true); } -void Battleground::RemovePlayerFromResurrectQueue(uint64 player_guid) +void Battleground::RemovePlayerFromResurrectQueue(ObjectGuid player_guid) { - for (std::map<uint64, std::vector<uint64> >::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr) + for (std::map<ObjectGuid, GuidVector>::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr) { - for (std::vector<uint64>::iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2) + for (GuidVector::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) { if (*itr2 == player_guid) { - (itr->second).erase(itr2); + itr->second.erase(itr2); if (Player* player = ObjectAccessor::FindPlayer(player_guid)) player->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT); return; @@ -1293,14 +1292,14 @@ void Battleground::RemovePlayerFromResurrectQueue(uint64 player_guid) } } -void Battleground::RelocateDeadPlayers(uint64 queueIndex) +void Battleground::RelocateDeadPlayers(ObjectGuid guideGuid) { // 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]; + GuidVector& ghostList = m_ReviveQueue[guideGuid]; if (!ghostList.empty()) { WorldSafeLocsEntry const* closestGrave = NULL; - for (std::vector<uint64>::const_iterator itr = ghostList.begin(); itr != ghostList.end(); ++itr) + for (GuidVector::const_iterator itr = ghostList.begin(); itr != ghostList.end(); ++itr) { Player* player = ObjectAccessor::FindPlayer(*itr); if (!player) @@ -1388,7 +1387,7 @@ void Battleground::DoorClose(uint32 type) } else TC_LOG_ERROR("bg.battleground", "Battleground::DoorClose: door gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID); + type, BgObjects[type].GetCounter(), m_MapId, m_InstanceID); } void Battleground::DoorOpen(uint32 type) @@ -1400,7 +1399,7 @@ void Battleground::DoorOpen(uint32 type) } else TC_LOG_ERROR("bg.battleground", "Battleground::DoorOpen: door gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID); + type, BgObjects[type].GetCounter(), m_MapId, m_InstanceID); } GameObject* Battleground::GetBGObject(uint32 type, bool logError) @@ -1410,10 +1409,10 @@ GameObject* Battleground::GetBGObject(uint32 type, bool logError) { if (logError) TC_LOG_ERROR("bg.battleground", "Battleground::GetBGObject: gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID); + type, BgObjects[type].GetCounter(), m_MapId, m_InstanceID); else TC_LOG_INFO("bg.battleground", "Battleground::GetBGObject: gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID); + type, BgObjects[type].GetCounter(), m_MapId, m_InstanceID); } return obj; } @@ -1425,10 +1424,10 @@ Creature* Battleground::GetBGCreature(uint32 type, bool logError) { if (logError) TC_LOG_ERROR("bg.battleground", "Battleground::GetBGCreature: creature (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID); + type, BgCreatures[type].GetCounter(), m_MapId, m_InstanceID); else TC_LOG_INFO("bg.battleground", "Battleground::GetBGCreature: creature (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID); + type, BgCreatures[type].GetCounter(), m_MapId, m_InstanceID); } return creature; } @@ -1505,13 +1504,13 @@ bool Battleground::DelCreature(uint32 type) if (Creature* creature = GetBgMap()->GetCreature(BgCreatures[type])) { creature->AddObjectToRemoveList(); - BgCreatures[type] = 0; + BgCreatures[type].Clear(); return true; } TC_LOG_ERROR("bg.battleground", "Battleground::DelCreature: creature (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID); - BgCreatures[type] = 0; + type, BgCreatures[type].GetCounter(), m_MapId, m_InstanceID); + BgCreatures[type].Clear(); return false; } @@ -1524,12 +1523,12 @@ bool Battleground::DelObject(uint32 type) { obj->SetRespawnTime(0); // not save respawn time obj->Delete(); - BgObjects[type] = 0; + BgObjects[type].Clear(); return true; } TC_LOG_ERROR("bg.battleground", "Battleground::DelObject: gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!", - type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID); - BgObjects[type] = 0; + type, BgObjects[type].GetCounter(), m_MapId, m_InstanceID); + BgObjects[type].Clear(); return false; } @@ -1540,7 +1539,7 @@ bool Battleground::AddSpiritGuide(uint32 type, float x, float y, float z, float if (Creature* creature = AddCreature(entry, type, x, y, z, o, teamId)) { creature->setDeathState(DEAD); - creature->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, creature->GetGUID()); + creature->SetChannelObjectGuid(creature->GetGUID()); // aura /// @todo Fix display here // creature->SetVisibleAura(0, SPELL_SPIRIT_HEAL_CHANNEL); @@ -1637,7 +1636,7 @@ char const* Battleground::GetTrinityString(int32 entry) // IMPORTANT NOTICE: // buffs aren't spawned/despawned when players captures anything // buffs are in their positions when battleground starts -void Battleground::HandleTriggerBuff(uint64 go_guid) +void Battleground::HandleTriggerBuff(ObjectGuid go_guid) { GameObject* obj = GetBgMap()->GetGameObject(go_guid); if (!obj || obj->GetGoType() != GAMEOBJECT_TYPE_TRAP || !obj->isSpawned()) @@ -1650,7 +1649,7 @@ void Battleground::HandleTriggerBuff(uint64 go_guid) if (index < 0) { TC_LOG_ERROR("bg.battleground", "Battleground::HandleTriggerBuff: cannot find buff gameobject (GUID: %u, entry: %u, type: %u) in internal data for BG (map: %u, instance id: %u)!", - GUID_LOPART(go_guid), obj->GetEntry(), obj->GetGoType(), m_MapId, m_InstanceID); + go_guid.GetCounter(), obj->GetEntry(), obj->GetGoType(), m_MapId, m_InstanceID); return; } @@ -1710,7 +1709,7 @@ void Battleground::HandleKillPlayer(Player* victim, Player* killer) // Return the player's team based on battlegroundplayer info // Used in same faction arena matches mainly -uint32 Battleground::GetPlayerTeam(uint64 guid) const +uint32 Battleground::GetPlayerTeam(ObjectGuid guid) const { BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid); if (itr != m_Players.end()) @@ -1723,7 +1722,7 @@ uint32 Battleground::GetOtherTeam(uint32 teamId) const return teamId ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0; } -bool Battleground::IsPlayerInBattleground(uint64 guid) const +bool Battleground::IsPlayerInBattleground(ObjectGuid guid) const { BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid); if (itr != m_Players.end()) @@ -1768,13 +1767,13 @@ void Battleground::SetHoliday(bool is_holiday) m_HonorMode = is_holiday ? BG_HOLIDAY : BG_NORMAL; } -int32 Battleground::GetObjectType(uint64 guid) +int32 Battleground::GetObjectType(ObjectGuid guid) { for (uint32 i = 0; i < BgObjects.size(); ++i) if (BgObjects[i] == guid) return i; TC_LOG_ERROR("bg.battleground", "Battleground::GetObjectType: player used gameobject (GUID: %u) which is not in internal data for BG (map: %u, instance id: %u), cheating?", - GUID_LOPART(guid), m_MapId, m_InstanceID); + guid.GetCounter(), m_MapId, m_InstanceID); return -1; } |