feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)

This commit is contained in:
UltraNix
2021-04-25 22:18:03 +02:00
committed by GitHub
parent 91081f4ad8
commit f4c226423d
568 changed files with 10655 additions and 11019 deletions

View File

@@ -30,6 +30,7 @@ Battlefield::Battlefield()
m_TypeId = 0;
m_BattleId = 0;
m_ZoneId = 0;
m_Map = nullptr;
m_MapId = 0;
m_MaxPlayer = 0;
m_MinPlayer = 0;
@@ -45,13 +46,12 @@ Battlefield::Battlefield()
m_LastResurectTimer = RESURRECTION_INTERVAL;
m_StartGroupingTimer = 0;
m_StartGrouping = false;
StalkerGuid = 0;
}
Battlefield::~Battlefield()
{
for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
delete itr->second;
for (BfCapturePointVector::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
delete *itr;
for (GraveyardVect::const_iterator itr = m_GraveyardList.begin(); itr != m_GraveyardList.end(); ++itr)
delete *itr;
@@ -110,8 +110,8 @@ void Battlefield::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/)
}
}
for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
itr->second->HandlePlayerLeave(player);
for (BfCapturePointVector::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
(*itr)->HandlePlayerLeave(player);
m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID());
m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID());
@@ -182,8 +182,8 @@ bool Battlefield::Update(uint32 diff)
else
m_uiKickDontAcceptTimer -= diff;
for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
if (itr->second->Update(diff))
for (BfCapturePointVector::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
if ((*itr)->Update(diff))
objective_changed = true;
}
@@ -203,7 +203,7 @@ bool Battlefield::Update(uint32 diff)
void Battlefield::InvitePlayersInZoneToQueue()
{
for (uint8 team = 0; team < 2; ++team)
for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
InvitePlayerToQueue(player);
}
@@ -221,8 +221,8 @@ void Battlefield::InvitePlayersInQueueToWar()
{
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
{
GuidSet copy(m_PlayersInQueue[team]);
for (GuidSet::const_iterator itr = copy.begin(); itr != copy.end(); ++itr)
GuidUnorderedSet copy(m_PlayersInQueue[team]);
for (GuidUnorderedSet::const_iterator itr = copy.begin(); itr != copy.end(); ++itr)
{
if (Player* player = ObjectAccessor::FindPlayer(*itr))
{
@@ -241,7 +241,7 @@ void Battlefield::InvitePlayersInQueueToWar()
void Battlefield::InvitePlayersInZoneToWar()
{
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
{
if (Player* player = ObjectAccessor::FindPlayer(*itr))
{
@@ -299,13 +299,13 @@ void Battlefield::KickAfkPlayers()
{
// xinef: optimization, dont lookup player twice
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
if (player->isAFK() && player->GetZoneId() == GetZoneId() && !player->IsGameMaster())
player->TeleportTo(KickPosition);
}
void Battlefield::KickPlayerFromBattlefield(uint64 guid)
void Battlefield::KickPlayerFromBattlefield(ObjectGuid guid)
{
if (Player* player = ObjectAccessor::FindPlayer(guid))
{
@@ -367,7 +367,7 @@ void Battlefield::DoPlaySoundToAll(uint32 SoundID)
data << uint32(SoundID);
for (int team = 0; team < BG_TEAMS_COUNT; team++)
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->GetSession()->SendPacket(&data);
}
@@ -423,13 +423,13 @@ void Battlefield::TeamCastSpell(TeamId team, int32 spellId)
{
if (spellId > 0)
{
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->CastSpell(player, uint32(spellId), true);
}
else
{
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->RemoveAuraFromStack(uint32(-spellId));
}
@@ -438,7 +438,7 @@ void Battlefield::TeamCastSpell(TeamId team, int32 spellId)
void Battlefield::BroadcastPacketToZone(WorldPacket& data) const
{
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->GetSession()->SendPacket(&data);
}
@@ -446,7 +446,7 @@ void Battlefield::BroadcastPacketToZone(WorldPacket& data) const
void Battlefield::BroadcastPacketToQueue(WorldPacket& data) const
{
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
for (GuidSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->GetSession()->SendPacket(&data);
}
@@ -454,22 +454,23 @@ void Battlefield::BroadcastPacketToQueue(WorldPacket& data) const
void Battlefield::BroadcastPacketToWar(WorldPacket& data) const
{
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->GetSession()->SendPacket(&data);
}
void Battlefield::SendWarningToAllInZone(uint32 entry)
{
if (Unit* unit = ObjectAccessor::FindUnit(StalkerGuid))
if (Creature* stalker = unit->ToCreature())
sCreatureTextMgr->SendChat(stalker, (uint8)entry, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE);
if (Map* map = sMapMgr->CreateBaseMap(m_MapId))
if (Unit* unit = map->GetCreature(StalkerGuid))
if (Creature* stalker = unit->ToCreature())
sCreatureTextMgr->SendChat(stalker, (uint8)entry, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE);
}
void Battlefield::SendWarningToPlayer(Player* player, uint32 entry)
{
if (player)
if (Unit* unit = ObjectAccessor::FindUnit(StalkerGuid))
if (Unit* unit = ObjectAccessor::GetCreature(*player, StalkerGuid))
if (Creature* stalker = unit->ToCreature())
sCreatureTextMgr->SendChat(stalker, (uint8)entry, player);
}
@@ -477,7 +478,7 @@ void Battlefield::SendWarningToPlayer(Player* player, uint32 entry)
void Battlefield::SendUpdateWorldState(uint32 field, uint32 value)
{
for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i)
for (GuidSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
for (GuidUnorderedSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->SendUpdateWorldState(field, value);
}
@@ -518,18 +519,18 @@ void Battlefield::ShowNpc(Creature* creature, bool aggressive)
// ****************************************************
Group* Battlefield::GetFreeBfRaid(TeamId TeamId)
{
for (GuidSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
for (GuidUnorderedSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter()))
if (!group->IsFull())
return group;
return nullptr;
}
Group* Battlefield::GetGroupPlayer(uint64 guid, TeamId TeamId)
Group* Battlefield::GetGroupPlayer(ObjectGuid guid, TeamId TeamId)
{
for (GuidSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
for (GuidUnorderedSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter()))
if (group->IsMember(guid))
return group;
@@ -617,7 +618,7 @@ GraveyardStruct const* Battlefield::GetClosestGraveyard(Player* player)
return nullptr;
}
void Battlefield::AddPlayerToResurrectQueue(uint64 npcGuid, uint64 playerGuid)
void Battlefield::AddPlayerToResurrectQueue(ObjectGuid npcGuid, ObjectGuid playerGuid)
{
for (uint8 i = 0; i < m_GraveyardList.size(); i++)
{
@@ -632,7 +633,7 @@ void Battlefield::AddPlayerToResurrectQueue(uint64 npcGuid, uint64 playerGuid)
}
}
void Battlefield::RemovePlayerFromResurrectQueue(uint64 playerGuid)
void Battlefield::RemovePlayerFromResurrectQueue(ObjectGuid playerGuid)
{
for (uint8 i = 0; i < m_GraveyardList.size(); i++)
{
@@ -647,7 +648,7 @@ void Battlefield::RemovePlayerFromResurrectQueue(uint64 playerGuid)
}
}
void Battlefield::SendAreaSpiritHealerQueryOpcode(Player* player, const uint64& guid)
void Battlefield::SendAreaSpiritHealerQueryOpcode(Player* player, const ObjectGuid& guid)
{
WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12);
uint32 time = m_LastResurectTimer; // resurrect every 30 seconds
@@ -665,8 +666,6 @@ BfGraveyard::BfGraveyard(Battlefield* battlefield)
m_Bf = battlefield;
m_GraveyardId = 0;
m_ControlTeam = TEAM_NEUTRAL;
m_SpiritGuide[0] = 0;
m_SpiritGuide[1] = 0;
m_ResurrectQueue.clear();
}
@@ -694,7 +693,7 @@ float BfGraveyard::GetDistance(Player* player)
return player->GetDistance2d(safeLoc->x, safeLoc->y);
}
void BfGraveyard::AddPlayer(uint64 playerGuid)
void BfGraveyard::AddPlayer(ObjectGuid playerGuid)
{
if (!m_ResurrectQueue.count(playerGuid))
{
@@ -705,7 +704,7 @@ void BfGraveyard::AddPlayer(uint64 playerGuid)
}
}
void BfGraveyard::RemovePlayer(uint64 playerGuid)
void BfGraveyard::RemovePlayer(ObjectGuid playerGuid)
{
m_ResurrectQueue.erase(m_ResurrectQueue.find(playerGuid));
@@ -718,7 +717,7 @@ void BfGraveyard::Resurrect()
if (m_ResurrectQueue.empty())
return;
for (GuidSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
{
// Get player object from his guid
Player* player = ObjectAccessor::FindPlayer(*itr);
@@ -727,7 +726,7 @@ void BfGraveyard::Resurrect()
// Check if the player is in world and on the good graveyard
if (player->IsInWorld())
if (Unit* spirit = ObjectAccessor::FindUnit(m_SpiritGuide[m_ControlTeam]))
if (Unit* spirit = ObjectAccessor::GetCreature(*player, m_SpiritGuide[m_ControlTeam]))
spirit->CastSpell(spirit, SPELL_SPIRIT_HEAL, true);
// Resurect player
@@ -736,7 +735,7 @@ void BfGraveyard::Resurrect()
player->CastSpell(player, 6962, true);
player->CastSpell(player, SPELL_SPIRIT_HEAL_MANA, true);
sObjectAccessor->ConvertCorpseForPlayer(player->GetGUID());
player->SpawnCorpseBones(false);
}
m_ResurrectQueue.clear();
@@ -753,7 +752,7 @@ void BfGraveyard::GiveControlTo(TeamId team)
void BfGraveyard::RelocateDeadPlayers()
{
GraveyardStruct const* closestGrave = nullptr;
for (GuidSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
{
Player* player = ObjectAccessor::FindPlayer(*itr);
if (!player)
@@ -792,7 +791,7 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
}
Creature* creature = new Creature(true);
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, 0, x, y, z, o))
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, PHASEMASK_NORMAL, entry, 0, x, y, z, o))
{
LOG_ERROR("server", "Battlefield::SpawnCreature: Can't create creature entry: %u", entry);
delete creature;
@@ -828,7 +827,7 @@ GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z
// Create gameobject
GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject();
if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, PHASEMASK_NORMAL, x, y, z, o, G3D::Quat(), 100, GO_STATE_READY))
if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, PHASEMASK_NORMAL, x, y, z, o, G3D::Quat(), 100, GO_STATE_READY))
{
LOG_ERROR("sql.sql", "Battlefield::SpawnGameObject: Gameobject template %u not found in database! Battlefield not created!", entry);
LOG_ERROR("server", "Battlefield::SpawnGameObject: Cannot create gameobject template %u! Battlefield not created!", entry);
@@ -843,11 +842,27 @@ GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z
return go;
}
Creature* Battlefield::GetCreature(ObjectGuid const guid)
{
if (!m_Map)
return nullptr;
return m_Map->GetCreature(guid);
}
GameObject* Battlefield::GetGameObject(ObjectGuid const guid)
{
if (!m_Map)
return nullptr;
return m_Map->GetGameObject(guid);
}
// *******************************************************
// ******************* CapturePoint **********************
// *******************************************************
BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_capturePoint(0)
BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield)
{
m_team = TEAM_NEUTRAL;
m_value = 0;
@@ -871,12 +886,12 @@ bool BfCapturePoint::HandlePlayerEnter(Player* player)
return m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second;
}
GuidSet::iterator BfCapturePoint::HandlePlayerLeave(Player* player)
GuidUnorderedSet::iterator BfCapturePoint::HandlePlayerLeave(Player* player)
{
if (GameObject* go = GetCapturePointGo(player))
player->SendUpdateWorldState(go->GetGOInfo()->capturePoint.worldState1, 0);
GuidSet::iterator current = m_activePlayers[player->GetTeamId()].find(player->GetGUID());
GuidUnorderedSet::iterator current = m_activePlayers[player->GetTeamId()].find(player->GetGUID());
if (current == m_activePlayers[player->GetTeamId()].end())
return current; // return end()
@@ -892,7 +907,7 @@ void BfCapturePoint::SendChangePhase()
return;
for (uint8 team = 0; team < 2; ++team)
for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) // send to all players present in the area
for (GuidUnorderedSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) // send to all players present in the area
if (Player* player = ObjectAccessor::FindPlayer(*itr))
{
// send this too, sometimes the slider disappears, dunno why :(
@@ -948,12 +963,22 @@ bool BfCapturePoint::DelCapturePoint()
{
capturePoint->SetRespawnTime(0); // not save respawn time
capturePoint->Delete();
m_capturePoint = 0;
m_capturePoint.Clear();
}
return true;
}
GameObject* BfCapturePoint::GetCapturePointGo()
{
return m_Bf->GetGameObject(m_capturePoint);
}
GameObject* BfCapturePoint::GetCapturePointGo(WorldObject* obj)
{
return ObjectAccessor::GetGameObject(*obj, m_capturePoint);
}
bool BfCapturePoint::Update(uint32 diff)
{
GameObject* capturePoint = GetCapturePointGo();
@@ -964,7 +989,7 @@ bool BfCapturePoint::Update(uint32 diff)
for (uint8 team = 0; team < 2; ++team)
{
for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();)
for (GuidUnorderedSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();)
{
if (Player* player = ObjectAccessor::FindPlayer(*itr))
if (!capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive())
@@ -1076,12 +1101,12 @@ bool BfCapturePoint::Update(uint32 diff)
void BfCapturePoint::SendUpdateWorldState(uint32 field, uint32 value)
{
for (uint8 team = 0; team < 2; ++team)
for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) // send to all players present in the area
for (GuidUnorderedSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) // send to all players present in the area
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->SendUpdateWorldState(field, value);
}
void BfCapturePoint::SendObjectiveComplete(uint32 id, uint64 guid)
void BfCapturePoint::SendObjectiveComplete(uint32 id, ObjectGuid guid)
{
uint8 team;
switch (m_State)
@@ -1097,7 +1122,7 @@ void BfCapturePoint::SendObjectiveComplete(uint32 id, uint64 guid)
}
// send to all players present in the area
for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr)
for (GuidUnorderedSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->KilledMonsterCredit(id, guid);
}

View File

@@ -65,9 +65,8 @@ class Unit;
class Battlefield;
class BfGraveyard;
typedef std::unordered_set<uint64> GuidSet;
typedef std::vector<BfGraveyard*> GraveyardVect;
typedef std::map<uint64, time_t> PlayerTimerMap;
typedef std::map<ObjectGuid, time_t> PlayerTimerMap;
class BfCapturePoint
{
@@ -82,11 +81,11 @@ public:
void SendUpdateWorldState(uint32 field, uint32 value);
// Send kill notify to players in the controlling faction
void SendObjectiveComplete(uint32 id, uint64 guid);
void SendObjectiveComplete(uint32 id, ObjectGuid guid);
// Used when player is activated/inactivated in the area
virtual bool HandlePlayerEnter(Player* player);
virtual GuidSet::iterator HandlePlayerLeave(Player* player);
virtual GuidUnorderedSet::iterator HandlePlayerLeave(Player* player);
//virtual void HandlePlayerActivityChanged(Player* player);
// Checks if player is in range of a capture credit marker
@@ -98,15 +97,15 @@ public:
virtual void SendChangePhase();
bool SetCapturePointData(GameObject* capturePoint);
GameObject* GetCapturePointGo() { return ObjectAccessor::GetObjectInWorld(m_capturePoint, (GameObject*)nullptr); }
GameObject* GetCapturePointGo(WorldObject* obj) { return ObjectAccessor::GetGameObject(*obj, m_capturePoint); }
GameObject* GetCapturePointGo();
GameObject* GetCapturePointGo(WorldObject* obj);
TeamId GetTeamId() { return m_team; }
protected:
bool DelCapturePoint();
// active Players in the area of the objective, 0 - alliance, 1 - horde
GuidSet m_activePlayers[2];
GuidUnorderedSet m_activePlayers[2];
// Total shift needed to capture the objective
float m_maxValue;
@@ -133,7 +132,7 @@ protected:
uint32 m_capturePointEntry;
// Gameobject related to that capture point
uint64 m_capturePoint;
ObjectGuid m_capturePoint;
};
class BfGraveyard
@@ -155,10 +154,10 @@ public:
void SetSpirit(Creature* spirit, TeamId team);
// Add a player to the graveyard
void AddPlayer(uint64 player_guid);
void AddPlayer(ObjectGuid player_guid);
// Remove a player from the graveyard
void RemovePlayer(uint64 player_guid);
void RemovePlayer(ObjectGuid player_guid);
// Resurrect players
void Resurrect();
@@ -167,7 +166,7 @@ public:
void RelocateDeadPlayers();
// Check if this graveyard has a spirit guide
bool HasNpc(uint64 guid)
bool HasNpc(ObjectGuid guid)
{
if (!m_SpiritGuide[0] && !m_SpiritGuide[1])
return false;
@@ -181,7 +180,7 @@ public:
}
// Check if a player is in this graveyard's resurrect queue
bool HasPlayer(uint64 guid) const { return m_ResurrectQueue.find(guid) != m_ResurrectQueue.end(); }
bool HasPlayer(ObjectGuid guid) const { return m_ResurrectQueue.find(guid) != m_ResurrectQueue.end(); }
// Get the graveyard's ID.
uint32 GetGraveyardId() const { return m_GraveyardId; }
@@ -189,8 +188,8 @@ public:
protected:
TeamId m_ControlTeam;
uint32 m_GraveyardId;
uint64 m_SpiritGuide[2];
GuidSet m_ResurrectQueue;
ObjectGuid m_SpiritGuide[2];
GuidUnorderedSet m_ResurrectQueue;
Battlefield* m_Bf;
};
@@ -205,7 +204,7 @@ public:
~Battlefield() override;
/// typedef of map witch store capturepoint and the associate gameobject entry
typedef std::map<uint32 /*lowguid */, BfCapturePoint*> BfCapturePointMap;
typedef std::vector<BfCapturePoint*> BfCapturePointVector;
/// Call this to init the Battlefield
virtual bool SetupBattlefield() { return true; }
@@ -249,7 +248,7 @@ public:
* \brief Kick player from battlefield and teleport him to kick-point location
* \param guid : guid of player who must be kick
*/
void KickPlayerFromBattlefield(uint64 guid);
void KickPlayerFromBattlefield(ObjectGuid guid);
/// Called when player (player) enter in zone
void HandlePlayerEnterZone(Player* player, uint32 zone);
@@ -278,7 +277,7 @@ public:
*/
Group* GetFreeBfRaid(TeamId TeamId);
/// Return battlefield group where player is.
Group* GetGroupPlayer(uint64 guid, TeamId TeamId);
Group* GetGroupPlayer(ObjectGuid guid, TeamId TeamId);
/// Force player to join a battlefield group
bool AddOrSetPlayerToCorrectBfGroup(Player* player);
@@ -286,8 +285,8 @@ public:
// Find which graveyard the player must be teleported to to be resurrected by spiritguide
GraveyardStruct const* GetClosestGraveyard(Player* player);
virtual void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid);
void RemovePlayerFromResurrectQueue(uint64 player_guid);
virtual void AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid);
void RemovePlayerFromResurrectQueue(ObjectGuid player_guid);
void SetGraveyardNumber(uint32 number) { m_GraveyardList.resize(number); }
BfGraveyard* GetGraveyardById(uint32 id) const;
@@ -296,6 +295,9 @@ public:
Creature* SpawnCreature(uint32 entry, Position pos, TeamId teamId);
GameObject* SpawnGameObject(uint32 entry, float x, float y, float z, float o);
Creature* GetCreature(ObjectGuid const guid);
GameObject* GetGameObject(ObjectGuid const guid);
// Script-methods
/// Called on start
@@ -331,7 +333,7 @@ public:
/// Return if we can use mount in battlefield
bool CanFlyIn() { return !m_isActive; }
void SendAreaSpiritHealerQueryOpcode(Player* player, const uint64& guid);
void SendAreaSpiritHealerQueryOpcode(Player* player, const ObjectGuid& guid);
void StartBattle();
void EndBattle(bool endByTimer);
@@ -352,19 +354,19 @@ public:
void InitStalker(uint32 entry, float x, float y, float z, float o);
protected:
uint64 StalkerGuid;
ObjectGuid StalkerGuid;
uint32 m_Timer; // Global timer for event
bool m_IsEnabled;
bool m_isActive;
TeamId m_DefenderTeam;
// Map of the objectives belonging to this OutdoorPvP
BfCapturePointMap m_capturePoints;
BfCapturePointVector m_capturePoints;
// Players info maps
GuidSet m_players[BG_TEAMS_COUNT]; // Players in zone
GuidSet m_PlayersInQueue[BG_TEAMS_COUNT]; // Players in the queue
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]; // Players in WG combat
GuidUnorderedSet m_players[BG_TEAMS_COUNT]; // Players in zone
GuidUnorderedSet m_PlayersInQueue[BG_TEAMS_COUNT]; // Players in the queue
GuidUnorderedSet m_PlayersInWar[BG_TEAMS_COUNT]; // Players in WG combat
PlayerTimerMap m_InvitedPlayers[BG_TEAMS_COUNT];
PlayerTimerMap m_PlayersWillBeKick[BG_TEAMS_COUNT];
@@ -373,6 +375,7 @@ protected:
uint32 m_BattleId; // BattleID (for packet)
uint32 m_ZoneId; // ZoneID of Wintergrasp = 4197
uint32 m_MapId; // MapId where is Battlefield
Map* m_Map;
uint32 m_MaxPlayer; // Maximum number of player that participated to Battlefield
uint32 m_MinPlayer; // Minimum number of player for Battlefield start
uint32 m_MinLevel; // Required level to participate at Battlefield
@@ -392,7 +395,7 @@ protected:
uint32 m_StartGroupingTimer; // Timer for invite players in area 15 minute before start battle
bool m_StartGrouping; // bool for know if all players in area has been invited
GuidSet m_Groups[BG_TEAMS_COUNT]; // Contain different raid group
GuidUnorderedSet m_Groups[BG_TEAMS_COUNT]; // Contain different raid group
std::vector<uint64> m_Data64;
std::vector<uint32> m_Data32;
@@ -408,15 +411,7 @@ protected:
void BroadcastPacketToWar(WorldPacket& data) const;
// CapturePoint system
void AddCapturePoint(BfCapturePoint* cp, GameObject* go) { m_capturePoints[go->GetEntry()] = cp; }
BfCapturePoint* GetCapturePoint(uint32 lowguid) const
{
Battlefield::BfCapturePointMap::const_iterator itr = m_capturePoints.find(lowguid);
if (itr != m_capturePoints.end())
return itr->second;
return nullptr;
}
void AddCapturePoint(BfCapturePoint* cp) { m_capturePoints.push_back(cp); }
void RegisterZone(uint32 zoneid);
bool HasPlayer(Player* player) const;

View File

@@ -82,7 +82,7 @@ void BattlefieldMgr::HandlePlayerEnterZone(Player* player, uint32 zoneid)
itr->second->HandlePlayerEnterZone(player, zoneid);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("bg.battlefield", "Player %u entered outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId());
LOG_DEBUG("bg.battlefield", "Player %s entered outdoorpvp id %u", player->GetGUID().ToString().c_str(), itr->second->GetTypeId());
#endif
}
@@ -97,7 +97,7 @@ void BattlefieldMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneid)
return;
itr->second->HandlePlayerLeaveZone(player, zoneid);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("bg.battlefield", "Player %u left outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId());
LOG_DEBUG("bg.battlefield", "Player %s left outdoorpvp id %u", player->GetGUID().ToString().c_str(), itr->second->GetTypeId());
#endif
}

View File

@@ -44,7 +44,7 @@ public:
void Update(uint32 diff);
void HandleGossipOption(Player* player, uint64 guid, uint32 gossipid);
void HandleGossipOption(Player* player, ObjectGuid guid, uint32 gossipid);
bool CanTalkTo(Player* player, Creature* creature, GossipMenuItems gso);

View File

@@ -9,6 +9,7 @@
// TODO: Add proper implement of achievement
#include "BattlefieldWG.h"
#include "MapManager.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "Player.h"
@@ -32,6 +33,7 @@ bool BattlefieldWG::SetupBattlefield()
m_BattleId = BATTLEFIELD_BATTLEID_WG;
m_ZoneId = BATTLEFIELD_WG_ZONEID;
m_MapId = BATTLEFIELD_WG_MAPID;
m_Map = sMapMgr->FindMap(m_MapId, 0);
// init stalker AFTER setting map id... we spawn it at map=random memory value?...
InitStalker(BATTLEFIELD_WG_NPC_STALKER, WintergraspStalkerPos[0], WintergraspStalkerPos[1], WintergraspStalkerPos[2], WintergraspStalkerPos[3]);
@@ -49,7 +51,7 @@ bool BattlefieldWG::SetupBattlefield()
m_StartGrouping = false;
m_tenacityStack = 0;
m_titansRelic = 0;
m_titansRelic.Clear();
KickPosition.Relocate(5728.117f, 2714.346f, 697.733f, 0);
KickPosition.m_mapId = m_MapId;
@@ -121,10 +123,9 @@ bool BattlefieldWG::SetupBattlefield()
}
// Hide NPCs from the Attacker's team in the keep
for (GuidSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = unit->ToCreature())
HideNpc(creature);
for (GuidUnorderedSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
if (Creature* creature = GetCreature(*itr))
HideNpc(creature);
// Spawn Horde NPCs outside the keep
for (uint8 i = 0; i < WG_OUTSIDE_ALLIANCE_NPC; i++)
@@ -137,10 +138,9 @@ bool BattlefieldWG::SetupBattlefield()
OutsideCreature[TEAM_ALLIANCE].insert(creature->GetGUID());
// Hide units outside the keep that are defenders
for (GuidSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = unit->ToCreature())
HideNpc(creature);
for (GuidUnorderedSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
if (Creature* creature = GetCreature(*itr))
HideNpc(creature);
// Spawn turrets and hide them per default
for (uint8 i = 0; i < WG_MAX_TURRET; i++)
@@ -223,15 +223,12 @@ void BattlefieldWG::OnBattleStart()
LOG_ERROR("server", "WG: Failed to spawn titan relic.");
// Update tower visibility and update faction
for (GuidSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr)
{
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = GetCreature(*itr))
{
if (Creature* creature = unit->ToCreature())
{
ShowNpc(creature, true);
creature->setFaction(WintergraspFaction[GetDefenderTeam()]);
}
ShowNpc(creature, true);
creature->setFaction(WintergraspFaction[GetDefenderTeam()]);
}
}
@@ -255,7 +252,7 @@ void BattlefieldWG::OnBattleStart()
(*itr)->UpdateGraveyardAndWorkshop();
for (uint8 team = 0; team < 2; ++team)
for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
{
// Kick player in orb room, TODO: offline player ?
if (Player* player = ObjectAccessor::FindPlayer(*itr))
@@ -308,7 +305,7 @@ void BattlefieldWG::UpdateCounterVehicle(bool init)
void BattlefieldWG::UpdateVehicleCountWG()
{
for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i)
for (GuidSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
for (GuidUnorderedSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
{
player->SendUpdateWorldState(BATTLEFIELD_WG_WORLD_STATE_VEHICLE_H, GetData(BATTLEFIELD_WG_DATA_VEHICLE_H));
@@ -321,7 +318,7 @@ void BattlefieldWG::UpdateVehicleCountWG()
void BattlefieldWG::CapturePointTaken(uint32 areaId)
{
for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i)
for (GuidSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
for (GuidUnorderedSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
if (player->GetAreaId() == areaId)
player->UpdateAreaDependentAuras(areaId);
@@ -332,43 +329,37 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer)
// Remove relic
if (GameObject* go = GetRelic())
go->RemoveFromWorld();
m_titansRelic = 0;
m_titansRelic.Clear();
// Remove turret
for (GuidSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr)
{
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = GetCreature(*itr))
{
if (Creature* creature = unit->ToCreature())
{
if (!endByTimer)
creature->setFaction(WintergraspFaction[GetDefenderTeam()]);
HideNpc(creature);
}
if (!endByTimer)
creature->setFaction(WintergraspFaction[GetDefenderTeam()]);
HideNpc(creature);
}
}
// Change all npc in keep
for (GuidSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = unit->ToCreature())
HideNpc(creature);
for (GuidUnorderedSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
if (Creature* creature = GetCreature(*itr))
HideNpc(creature);
for (GuidSet::const_iterator itr = KeepCreature[GetDefenderTeam()].begin(); itr != KeepCreature[GetDefenderTeam()].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = unit->ToCreature())
ShowNpc(creature, true);
for (GuidUnorderedSet::const_iterator itr = KeepCreature[GetDefenderTeam()].begin(); itr != KeepCreature[GetDefenderTeam()].end(); ++itr)
if (Creature* creature = GetCreature(*itr))
ShowNpc(creature, true);
// Change all npc out of keep
for (GuidSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = unit->ToCreature())
HideNpc(creature);
for (GuidUnorderedSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
if (Creature* creature = GetCreature(*itr))
HideNpc(creature);
for (GuidSet::const_iterator itr = OutsideCreature[GetAttackerTeam()].begin(); itr != OutsideCreature[GetAttackerTeam()].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = unit->ToCreature())
ShowNpc(creature, true);
for (GuidUnorderedSet::const_iterator itr = OutsideCreature[GetAttackerTeam()].begin(); itr != OutsideCreature[GetAttackerTeam()].end(); ++itr)
if (Creature* creature = GetCreature(*itr))
ShowNpc(creature, true);
// Update all graveyard, control is to defender when no wartime
for (uint8 i = 0; i < BATTLEFIELD_WG_GY_HORDE; i++)
@@ -398,10 +389,9 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer)
for (uint8 team = 0; team < 2; ++team)
{
for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = unit->ToCreature())
creature->DespawnOrUnsummon(1);
for (GuidUnorderedSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
if (Creature* creature = GetCreature(*itr))
creature->DespawnOrUnsummon(1);
m_vehicles[team].clear();
}
@@ -425,7 +415,7 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer)
spellFullAtt = SPELL_DESTROYED_TOWER;
}
for (GuidSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr)
{
if (Player* player = ObjectAccessor::FindPlayer(*itr))
{
@@ -443,7 +433,7 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer)
}
}
for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
{
player->CastSpell(player, SPELL_DEFEAT_REWARD, true);
@@ -459,7 +449,7 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer)
{
for (uint8 team = 0; team < 2; ++team)
{
for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
{
if (Player* player = ObjectAccessor::FindPlayer(*itr))
{
@@ -682,7 +672,7 @@ void BattlefieldWG::OnGameObjectCreate(GameObject* go)
capturePoint->SetCapturePointData(go);
capturePoint->LinkToWorkshop(workshop);
AddCapturePoint(capturePoint, go);
AddCapturePoint(capturePoint);
break;
}
}
@@ -700,7 +690,7 @@ void BattlefieldWG::HandleKill(Player* killer, Unit* victim)
// xinef: tower cannons also grant rank
if (victim->GetTypeId() == TYPEID_PLAYER || IsKeepNpc(victim->GetEntry()) || victim->GetEntry() == NPC_WINTERGRASP_TOWER_CANNON)
{
for (GuidSet::const_iterator itr = m_PlayersInWar[killerTeam].begin(); itr != m_PlayersInWar[killerTeam].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[killerTeam].begin(); itr != m_PlayersInWar[killerTeam].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
if (player->GetDistance2d(killer) < 40)
PromotePlayer(player);
@@ -712,10 +702,10 @@ void BattlefieldWG::HandleKill(Player* killer, Unit* victim)
else if (victim->IsVehicle() && !killer->IsFriendlyTo(victim))
{
// Quest - Wintergrasp - PvP Kill - Vehicle
for (GuidSet::const_iterator itr = m_PlayersInWar[killerTeam].begin(); itr != m_PlayersInWar[killerTeam].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[killerTeam].begin(); itr != m_PlayersInWar[killerTeam].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
if (player->GetDistance2d(killer) < 40)
player->KilledMonsterCredit(NPC_QUEST_PVP_KILL_VEHICLE, 0);
player->KilledMonsterCredit(NPC_QUEST_PVP_KILL_VEHICLE);
}
}
@@ -918,7 +908,7 @@ void BattlefieldWG::SendInitWorldStatesTo(Player* player)
void BattlefieldWG::SendInitWorldStatesToAll()
{
for (uint8 team = 0; team < 2; team++)
for (GuidSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
for (GuidUnorderedSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
SendInitWorldStatesTo(player);
}
@@ -928,7 +918,7 @@ void BattlefieldWG::BrokenWallOrTower(TeamId /*team*/)
// might be some use for this in the future. old code commented out below. KL
/* if (team == GetDefenderTeam())
{
for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
{
if (Player* player = ObjectAccessor::FindPlayer(*itr))
IncrementQuest(player, WGQuest[player->GetTeamId()][2], true);
@@ -947,17 +937,17 @@ void BattlefieldWG::UpdatedDestroyedTowerCount(TeamId team, GameObject* go)
UpdateData(BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT, 1);
// Remove buff stack on attackers
for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->RemoveAuraFromStack(SPELL_TOWER_CONTROL);
// Add buff stack to defenders
for (GuidSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
{
// Quest - Wintergrasp - Southern Tower Kill
if (go && player->GetDistance2d(go) < 200.0f)
player->KilledMonsterCredit(NPC_QUEST_SOUTHERN_TOWER_KILL, 0);
player->KilledMonsterCredit(NPC_QUEST_SOUTHERN_TOWER_KILL);
player->CastSpell(player, SPELL_TOWER_CONTROL, true);
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_LEANING_TOWER_ACHIEVEMENT, 0, 0);
@@ -976,12 +966,12 @@ void BattlefieldWG::UpdatedDestroyedTowerCount(TeamId team, GameObject* go)
else
{
// Xinef: rest of structures, quest credit
for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
{
// Quest - Wintergrasp - Vehicle Protected
if (go && player->GetDistance2d(go) < 100.0f)
player->KilledMonsterCredit(NPC_QUEST_VEHICLE_PROTECTED, 0);
player->KilledMonsterCredit(NPC_QUEST_VEHICLE_PROTECTED);
}
}
}
@@ -1053,7 +1043,7 @@ void BattlefieldWG::AddUpdateTenacity(Player* player)
void BattlefieldWG::RemoveUpdateTenacity(Player* player)
{
m_updateTenacityList.erase(player->GetGUID());
m_updateTenacityList.insert(0);
m_updateTenacityList.insert(ObjectGuid::Empty);
}
void BattlefieldWG::UpdateTenacity()
@@ -1074,7 +1064,7 @@ void BattlefieldWG::UpdateTenacity()
// Return if no change in stack and apply tenacity to new player
if (newStack == m_tenacityStack)
{
for (GuidSet::const_iterator itr = m_updateTenacityList.begin(); itr != m_updateTenacityList.end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_updateTenacityList.begin(); itr != m_updateTenacityList.end(); ++itr)
if (Player* newPlayer = ObjectAccessor::FindPlayer(*itr))
if ((newPlayer->GetTeamId() == TEAM_ALLIANCE && m_tenacityStack > 0) || (newPlayer->GetTeamId() == TEAM_HORDE && m_tenacityStack < 0))
{
@@ -1099,13 +1089,13 @@ void BattlefieldWG::UpdateTenacity()
// Remove old buff
if (team != TEAM_NEUTRAL)
{
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->RemoveAurasDueToSpell(SPELL_TENACITY);
for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
unit->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE);
for (GuidUnorderedSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
if (Creature* creature = GetCreature(*itr))
creature->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE);
}
// Apply new buff
@@ -1115,7 +1105,7 @@ void BattlefieldWG::UpdateTenacity()
newStack = std::min(abs(newStack), 20);
uint32 buff_honor = GetHonorBuff(newStack);
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
{
player->SetAuraStack(SPELL_TENACITY, player, newStack);
@@ -1123,12 +1113,12 @@ void BattlefieldWG::UpdateTenacity()
player->CastSpell(player, buff_honor, true);
}
for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
for (GuidUnorderedSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
if (Creature* creature = GetCreature(*itr))
{
unit->SetAuraStack(SPELL_TENACITY_VEHICLE, unit, newStack);
creature->SetAuraStack(SPELL_TENACITY_VEHICLE, creature, newStack);
if (buff_honor)
unit->CastSpell(unit, buff_honor, true);
creature->CastSpell(creature, buff_honor, true);
}
}
}

View File

@@ -373,7 +373,7 @@ public:
bool SetupBattlefield() override;
/// Return pointer to relic object
GameObject* GetRelic() { return ObjectAccessor::GetObjectInWorld(m_titansRelic, (GameObject*)nullptr); }
GameObject* GetRelic() { return GetGameObject(m_titansRelic); }
/// Define relic object
//void SetRelic(GameObject* relic) { m_titansRelic = relic; }
@@ -450,17 +450,17 @@ protected:
GameObjectSet m_KeepGameObject[2];
GameObjectBuilding BuildingsInZone;
GuidSet m_vehicles[2];
GuidSet CanonList;
GuidSet KeepCreature[2];
GuidSet OutsideCreature[2];
GuidSet m_updateTenacityList;
GuidUnorderedSet m_vehicles[2];
GuidUnorderedSet CanonList;
GuidUnorderedSet KeepCreature[2];
GuidUnorderedSet OutsideCreature[2];
GuidUnorderedSet m_updateTenacityList;
int32 m_tenacityStack;
uint32 m_tenacityUpdateTimer;
uint32 m_saveTimer;
uint64 m_titansRelic;
ObjectGuid m_titansRelic;
};
const uint8 WG_MAX_OBJ = 32;
@@ -1079,7 +1079,6 @@ struct BfWGGameObjectBuilding
{
m_WG = WG;
m_Team = TEAM_ALLIANCE;
m_Build = 0;
m_Type = 0;
m_WorldState = 0;
m_State = 0;
@@ -1094,7 +1093,7 @@ struct BfWGGameObjectBuilding
BattlefieldWG* m_WG;
// Linked gameobject
uint64 m_Build;
ObjectGuid m_Build;
// eWGGameObjectBuildingType
uint32 m_Type;
@@ -1113,10 +1112,10 @@ struct BfWGGameObjectBuilding
GameObjectSet m_GameObjectList[2];
// Creature associations
GuidSet m_CreatureBottomList[2];
GuidSet m_CreatureTopList[2];
GuidSet m_TowerCannonBottomList;
GuidSet m_TurretTopList;
GuidUnorderedSet m_CreatureBottomList[2];
GuidUnorderedSet m_CreatureTopList[2];
GuidUnorderedSet m_TowerCannonBottomList;
GuidUnorderedSet m_TurretTopList;
void Rebuild()
{
@@ -1136,7 +1135,7 @@ struct BfWGGameObjectBuilding
break;
}
GameObject* go = ObjectAccessor::GetObjectInWorld(m_Build, (GameObject*)nullptr);
GameObject* go = m_WG->GetGameObject(m_Build);
if (go)
{
// Rebuild gameobject
@@ -1161,15 +1160,13 @@ struct BfWGGameObjectBuilding
if (m_damagedText) // tower damage + name
m_WG->SendWarningToAllInZone(m_damagedText);
for (GuidSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = unit->ToCreature())
m_WG->HideNpc(creature);
for (GuidUnorderedSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr)
if (Creature* creature = m_WG->GetCreature(*itr))
m_WG->HideNpc(creature);
for (GuidSet::const_iterator itr = m_TurretTopList.begin(); itr != m_TurretTopList.end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = unit->ToCreature())
m_WG->HideNpc(creature);
for (GuidUnorderedSet::const_iterator itr = m_TurretTopList.begin(); itr != m_TurretTopList.end(); ++itr)
if (Creature* creature = m_WG->GetCreature(*itr))
m_WG->HideNpc(creature);
if (m_Type == BATTLEFIELD_WG_OBJECTTYPE_TOWER)
m_WG->UpdateDamagedTowerCount(m_WG->GetAttackerTeam());
@@ -1190,7 +1187,7 @@ struct BfWGGameObjectBuilding
{
// Inform the global wintergrasp script of the destruction of this object
case BATTLEFIELD_WG_OBJECTTYPE_TOWER:
m_WG->UpdatedDestroyedTowerCount(TeamId(m_Team), ObjectAccessor::GetObjectInWorld(m_Build, (GameObject*)nullptr));
m_WG->UpdatedDestroyedTowerCount(TeamId(m_Team), m_WG->GetGameObject(m_Build));
break;
case BATTLEFIELD_WG_OBJECTTYPE_DOOR_LAST:
m_WG->SetRelicInteractible(true);
@@ -1202,7 +1199,7 @@ struct BfWGGameObjectBuilding
case BATTLEFIELD_WG_OBJECTTYPE_DOOR:
case BATTLEFIELD_WG_OBJECTTYPE_WALL:
case BATTLEFIELD_WG_OBJECTTYPE_KEEP_TOWER:
m_WG->UpdatedDestroyedTowerCount(TeamId(m_Team), ObjectAccessor::GetObjectInWorld(m_Build, (GameObject*)nullptr));
m_WG->UpdatedDestroyedTowerCount(TeamId(m_Team), m_WG->GetGameObject(m_Build));
break;
}
@@ -1355,25 +1352,21 @@ struct BfWGGameObjectBuilding
void UpdateCreatureAndGo()
{
for (GuidSet::const_iterator itr = m_CreatureTopList[m_WG->GetDefenderTeam()].begin(); itr != m_CreatureTopList[m_WG->GetDefenderTeam()].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = unit->ToCreature())
m_WG->HideNpc(creature);
for (GuidUnorderedSet::const_iterator itr = m_CreatureTopList[m_WG->GetDefenderTeam()].begin(); itr != m_CreatureTopList[m_WG->GetDefenderTeam()].end(); ++itr)
if (Creature* creature = m_WG->GetCreature(*itr))
m_WG->HideNpc(creature);
for (GuidSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = unit->ToCreature())
m_WG->ShowNpc(creature, true);
for (GuidUnorderedSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr)
if (Creature* creature = m_WG->GetCreature(*itr))
m_WG->ShowNpc(creature, true);
for (GuidSet::const_iterator itr = m_CreatureBottomList[m_WG->GetDefenderTeam()].begin(); itr != m_CreatureBottomList[m_WG->GetDefenderTeam()].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = unit->ToCreature())
m_WG->HideNpc(creature);
for (GuidUnorderedSet::const_iterator itr = m_CreatureBottomList[m_WG->GetDefenderTeam()].begin(); itr != m_CreatureBottomList[m_WG->GetDefenderTeam()].end(); ++itr)
if (Creature* creature = m_WG->GetCreature(*itr))
m_WG->HideNpc(creature);
for (GuidSet::const_iterator itr = m_CreatureBottomList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureBottomList[m_WG->GetAttackerTeam()].end(); ++itr)
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = unit->ToCreature())
m_WG->ShowNpc(creature, true);
for (GuidUnorderedSet::const_iterator itr = m_CreatureBottomList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureBottomList[m_WG->GetAttackerTeam()].end(); ++itr)
if (Creature* creature = m_WG->GetCreature(*itr))
m_WG->ShowNpc(creature, true);
for (GameObjectSet::const_iterator itr = m_GameObjectList[m_WG->GetDefenderTeam()].begin(); itr != m_GameObjectList[m_WG->GetDefenderTeam()].end(); ++itr)
(*itr)->SetRespawnTime(RESPAWN_ONE_DAY);
@@ -1384,7 +1377,7 @@ struct BfWGGameObjectBuilding
void UpdateTurretAttack(bool disable)
{
GameObject* build = ObjectAccessor::GetObjectInWorld(m_Build, (GameObject*)nullptr);
GameObject* build = m_WG->GetGameObject(m_Build);
if (!build)
return;
@@ -1404,33 +1397,27 @@ struct BfWGGameObjectBuilding
break;
}
for (GuidSet::const_iterator itr = m_TowerCannonBottomList.begin(); itr != m_TowerCannonBottomList.end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_TowerCannonBottomList.begin(); itr != m_TowerCannonBottomList.end(); ++itr)
{
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = m_WG->GetCreature(*itr))
{
if (Creature* creature = unit->ToCreature())
{
creature->setFaction(faction);
if (disable)
m_WG->HideNpc(creature);
else
m_WG->ShowNpc(creature, true);
}
creature->setFaction(faction);
if (disable)
m_WG->HideNpc(creature);
else
m_WG->ShowNpc(creature, true);
}
}
for (GuidSet::const_iterator itr = m_TurretTopList.begin(); itr != m_TurretTopList.end(); ++itr)
for (GuidUnorderedSet::const_iterator itr = m_TurretTopList.begin(); itr != m_TurretTopList.end(); ++itr)
{
if (Unit* unit = ObjectAccessor::FindUnit(*itr))
if (Creature* creature = m_WG->GetCreature(*itr))
{
if (Creature* creature = unit->ToCreature())
{
creature->setFaction(faction);
if (disable)
m_WG->HideNpc(creature);
else
m_WG->ShowNpc(creature, true);
}
creature->setFaction(faction);
if (disable)
m_WG->HideNpc(creature);
else
m_WG->ShowNpc(creature, true);
}
}
}