chore(Core/OutdoorPvP): cleanup ptr's, rename private fields (#17778)

chore(Game/OutdoorPvP): cleanup ptr's, private fields
This commit is contained in:
Winfidonarleyan
2023-11-18 23:51:02 +07:00
committed by GitHub
parent 164dfb27a8
commit 18d3940145
11 changed files with 565 additions and 511 deletions
+237 -165
View File
@@ -26,41 +26,46 @@
#include "OutdoorPvPMgr.h"
#include "WorldPacket.h"
OPvPCapturePoint::OPvPCapturePoint(OutdoorPvP* pvp):
m_capturePointSpawnId(0), m_capturePoint(nullptr), m_maxValue(0.0f), m_minValue(0.0f), m_maxSpeed(0),
m_value(0), m_team(TEAM_NEUTRAL), m_OldState(OBJECTIVESTATE_NEUTRAL),
m_State(OBJECTIVESTATE_NEUTRAL), m_neutralValuePct(0), m_PvP(pvp)
{ }
OPvPCapturePoint::OPvPCapturePoint(OutdoorPvP* pvp) :
_pvp(pvp)
{
}
bool OPvPCapturePoint::HandlePlayerEnter(Player* player)
{
if (m_capturePoint)
if (_capturePoint)
{
player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f));
player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct);
player->SendUpdateWorldState(_capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
player->SendUpdateWorldState(_capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32)std::ceil((_value + _maxValue) / (2 * _maxValue) * 100.0f));
player->SendUpdateWorldState(_capturePoint->GetGOInfo()->capturePoint.worldstate3, _neutralValuePct);
}
return m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second;
return _activePlayers[player->GetTeamId()].insert(player->GetGUID()).second;
}
void OPvPCapturePoint::HandlePlayerLeave(Player* player)
{
if (m_capturePoint)
player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 0);
m_activePlayers[player->GetTeamId()].erase(player->GetGUID());
if (_capturePoint)
{
player->SendUpdateWorldState(_capturePoint->GetGOInfo()->capturePoint.worldState1, 0);
}
_activePlayers[player->GetTeamId()].erase(player->GetGUID());
}
void OPvPCapturePoint::SendChangePhase()
{
if (!m_capturePoint)
if (!_capturePoint)
return;
// send this too, sometimes the slider disappears, dunno why :(
SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
SendUpdateWorldState(_capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
// send these updates to only the ones in this objective
SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f));
SendUpdateWorldState(_capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32)std::ceil((_value + _maxValue) / (2 * _maxValue) * 100.0f));
// send this too, sometimes it resets :S
SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct);
SendUpdateWorldState(_capturePoint->GetGOInfo()->capturePoint.worldstate3, _neutralValuePct);
}
void OPvPCapturePoint::AddGO(uint32 type, ObjectGuid::LowType guid, uint32 entry)
@@ -69,11 +74,15 @@ void OPvPCapturePoint::AddGO(uint32 type, ObjectGuid::LowType guid, uint32 entry
{
const GameObjectData* data = sObjectMgr->GetGameObjectData(guid);
if (!data)
{
return;
}
entry = data->id;
}
m_Objects[type] = guid;
m_ObjectTypes[m_Objects[type]] = type;
_objects[type] = guid;
_objectTypes[_objects[type]] = type;
}
void OPvPCapturePoint::AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entry)
@@ -82,11 +91,15 @@ void OPvPCapturePoint::AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entr
{
const CreatureData* data = sObjectMgr->GetCreatureData(guid);
if (!data)
{
return;
}
entry = data->id1;
}
m_Creatures[type] = guid;
m_CreatureTypes[m_Creatures[type]] = type;
_creatures[type] = guid;
_creatureTypes[_creatures[type]] = type;
}
bool OPvPCapturePoint::AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3)
@@ -100,9 +113,9 @@ bool OPvPCapturePoint::AddObject(uint32 type, uint32 entry, uint32 map, float x,
return false;
}
bool OPvPCapturePoint::AddCreature(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay)
bool OPvPCapturePoint::AddCreature(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimeDelay)
{
if (ObjectGuid::LowType guid = sObjectMgr->AddCreData(entry, map, x, y, z, o, spawntimedelay))
if (ObjectGuid::LowType guid = sObjectMgr->AddCreData(entry, map, x, y, z, o, spawntimeDelay))
{
AddCre(type, guid, entry);
return true;
@@ -128,34 +141,37 @@ bool OPvPCapturePoint::SetCapturePointData(uint32 entry, uint32 map, float x, fl
return false;
// get the needed values from goinfo
m_maxValue = (float)goinfo->capturePoint.maxTime;
m_maxSpeed = m_maxValue / (goinfo->capturePoint.minTime ? goinfo->capturePoint.minTime : 60);
m_neutralValuePct = goinfo->capturePoint.neutralPercent;
m_minValue = CalculatePct(m_maxValue, m_neutralValuePct);
_maxValue = (float)goinfo->capturePoint.maxTime;
_maxSpeed = _maxValue / float(goinfo->capturePoint.minTime ? goinfo->capturePoint.minTime : 60);
_neutralValuePct = goinfo->capturePoint.neutralPercent;
_minValue = CalculatePct(_maxValue, _neutralValuePct);
return true;
}
bool OPvPCapturePoint::DelCreature(uint32 type)
{
ObjectGuid::LowType spawnId = m_Creatures[type];
ObjectGuid::LowType spawnId = _creatures[type];
if (!spawnId)
{
LOG_DEBUG("outdoorpvp", "opvp creature type {} was already deleted", type);
LOG_DEBUG("outdoorpvp", "OutdoorPvP: Creature type {} was already deleted", type);
return false;
}
auto bounds = m_PvP->GetMap()->GetCreatureBySpawnIdStore().equal_range(spawnId);
auto bounds = _pvp->GetMap()->GetCreatureBySpawnIdStore().equal_range(spawnId);
for (auto itr = bounds.first; itr != bounds.second;)
{
// can happen when closing the core
Creature* c = itr->second;
++itr;
// Don't save respawn time
c->SetRespawnTime(0);
c->RemoveCorpse();
c->AddObjectToRemoveList();
}
LOG_DEBUG("outdoorpvp", "deleting opvp creature type {}", type);
LOG_DEBUG("outdoorpvp", "OutdoorPvP: Deleting creature type {}", type);
// explicit removal from map
// beats me why this is needed, but with the recent removal "cleanup" some creatures stay in the map if "properly" deleted
// so this is a big fat workaround, if AddObjectToRemoveList and DoDelayedMovesAndRemoves worked correctly, this wouldn't be needed
@@ -164,23 +180,23 @@ bool OPvPCapturePoint::DelCreature(uint32 type)
// delete respawn time for this creature
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CREATURE_RESPAWN);
stmt->SetData(0, spawnId);
stmt->SetData(1, m_PvP->GetMap()->GetId());
stmt->SetData(1, _pvp->GetMap()->GetId());
stmt->SetData(2, 0); // instance id, always 0 for world maps
CharacterDatabase.Execute(stmt);
sObjectMgr->DeleteCreatureData(spawnId);
m_CreatureTypes[m_Creatures[type]] = 0;
m_Creatures[type] = 0;
_creatureTypes[_creatures[type]] = 0;
_creatures[type] = 0;
return true;
}
bool OPvPCapturePoint::DelObject(uint32 type)
{
ObjectGuid::LowType spawnId = m_Objects[type];
ObjectGuid::LowType spawnId = _objects[type];
if (!spawnId)
return false;
auto bounds = m_PvP->GetMap()->GetGameObjectBySpawnIdStore().equal_range(spawnId);
auto bounds = _pvp->GetMap()->GetGameObjectBySpawnIdStore().equal_range(spawnId);
for (auto itr = bounds.first; itr != bounds.second;)
{
GameObject* go = itr->second;
@@ -191,8 +207,8 @@ bool OPvPCapturePoint::DelObject(uint32 type)
}
sObjectMgr->DeleteGOData(spawnId);
m_ObjectTypes[m_Objects[type]] = 0;
m_Objects[type] = 0;
_objectTypes[_objects[type]] = 0;
_objects[type] = 0;
return true;
}
@@ -201,10 +217,10 @@ bool OPvPCapturePoint::DelCapturePoint()
sObjectMgr->DeleteGOData(m_capturePointSpawnId);
m_capturePointSpawnId = 0;
if (m_capturePoint)
if (_capturePoint)
{
m_capturePoint->SetRespawnTime(0); // not save respawn time
m_capturePoint->Delete();
_capturePoint->SetRespawnTime(0); // not save respawn time
_capturePoint->Delete();
}
return true;
@@ -212,39 +228,46 @@ bool OPvPCapturePoint::DelCapturePoint()
void OPvPCapturePoint::DeleteSpawns()
{
for (std::map<uint32, ObjectGuid::LowType>::iterator i = m_Objects.begin(); i != m_Objects.end(); ++i)
DelObject(i->first);
for (std::map<uint32, ObjectGuid::LowType>::iterator i = m_Creatures.begin(); i != m_Creatures.end(); ++i)
DelCreature(i->first);
for (auto const& [type, guid] : _objects)
{
DelObject(type);
}
for (auto const& [type, guid] : _creatures)
{
DelCreature(type);
}
DelCapturePoint();
}
void OutdoorPvP::DeleteSpawns()
{
// Remove script from any registered gameobjects/creatures
for (auto itr = m_GoScriptStore.begin(); itr != m_GoScriptStore.end(); ++itr)
for (auto& itr : _goScriptStore)
{
if (GameObject* go = itr->second)
if (GameObject* go = itr.second)
go->ClearZoneScript();
}
m_GoScriptStore.clear();
for (auto itr = m_CreatureScriptStore.begin(); itr != m_CreatureScriptStore.end(); ++itr)
_goScriptStore.clear();
for (auto& itr : _creatureScriptStore)
{
if (Creature* creature = itr->second)
if (Creature* creature = itr.second)
creature->ClearZoneScript();
}
m_CreatureScriptStore.clear();
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
_creatureScriptStore.clear();
for (auto& capturePoint : _capturePoints)
{
itr->second->DeleteSpawns();
delete itr->second;
capturePoint.second->DeleteSpawns();
delete capturePoint.second;
}
m_capturePoints.clear();
}
OutdoorPvP::OutdoorPvP() : m_TypeId(0), m_sendUpdate(true), m_map(nullptr) { }
_capturePoints.clear();
}
OutdoorPvP::~OutdoorPvP()
{
@@ -253,149 +276,173 @@ OutdoorPvP::~OutdoorPvP()
void OutdoorPvP::HandlePlayerEnterZone(Player* player, uint32 /*zone*/)
{
m_players[player->GetTeamId()].insert(player->GetGUID());
_players[player->GetTeamId()].insert(player->GetGUID());
}
void OutdoorPvP::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/)
{
// inform the objectives of the leaving
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
itr->second->HandlePlayerLeave(player);
for (auto& _capturePoint : _capturePoints)
{
_capturePoint.second->HandlePlayerLeave(player);
}
// remove the world state information from the player (we can't keep everyone up to date, so leave out those who are not in the concerning zones)
if (!player->GetSession()->PlayerLogout())
{
SendRemoveWorldStates(player);
m_players[player->GetTeamId()].erase(player->GetGUID());
LOG_DEBUG("outdoorpvp", "Player {} left an outdoorpvp zone", player->GetName());
}
_players[player->GetTeamId()].erase(player->GetGUID());
LOG_DEBUG("outdoorpvp", "OutdoorPvP: Player {} left an outdoorpvp zone", player->GetName());
}
void OutdoorPvP::HandlePlayerResurrects(Player* /*player*/, uint32 /*zone*/)
{
}
bool OutdoorPvP::Update(uint32 diff)
{
bool objective_changed = false;
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
for (auto& capturePoint : _capturePoints)
{
if (itr->second->Update(diff))
if (capturePoint.second->Update(diff))
objective_changed = true;
}
return objective_changed;
}
bool OPvPCapturePoint::Update(uint32 diff)
{
if (!m_capturePoint)
if (!_capturePoint)
return false;
float radius = (float)m_capturePoint->GetGOInfo()->capturePoint.radius;
auto radius = (float)_capturePoint->GetGOInfo()->capturePoint.radius;
for (uint32 team = 0; team < 2; ++team)
for (auto const& activePlayer : _activePlayers)
{
for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();)
for (auto itr = activePlayer.begin(); itr != activePlayer.end();)
{
ObjectGuid playerGuid = *itr;
++itr;
if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
if (!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive())
if (!_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive())
HandlePlayerLeave(player);
}
}
std::list<Player*> players;
Acore::AnyPlayerInObjectRangeCheck checker(m_capturePoint, radius);
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(m_capturePoint, players, checker);
Cell::VisitWorldObjects(m_capturePoint, searcher, radius);
Acore::AnyPlayerInObjectRangeCheck checker(_capturePoint, radius);
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(_capturePoint, players, checker);
Cell::VisitWorldObjects(_capturePoint, searcher, radius);
for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr)
for (auto& itr : players)
{
Player* const player = *itr;
Player* const player = itr;
if (player->IsOutdoorPvPActive())
{
if (m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second)
HandlePlayerEnter(*itr);
if (_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second)
HandlePlayerEnter(itr);
}
}
// get the difference of numbers
float fact_diff = ((float)m_activePlayers[0].size() - (float)m_activePlayers[1].size()) * diff / OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL;
if (!fact_diff)
float factDiff = ((float)_activePlayers[0].size() - (float)_activePlayers[1].size()) * float(diff) / OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL;
if (factDiff == 0.f)
return false;
TeamId ChallengerId = TEAM_NEUTRAL;
float maxDiff = m_maxSpeed * diff;
float maxDiff = _maxSpeed * float(diff);
if (fact_diff < 0)
if (factDiff < 0.f)
{
// horde is in majority, but it's already horde-controlled -> no change
if (m_State == OBJECTIVESTATE_HORDE && m_value <= -m_maxValue)
if (_state == OBJECTIVESTATE_HORDE && _value <= -_maxValue)
return false;
if (fact_diff < -maxDiff)
fact_diff = -maxDiff;
if (factDiff < -maxDiff)
factDiff = -maxDiff;
ChallengerId = TEAM_HORDE;
}
else
{
// ally is in majority, but it's already ally-controlled -> no change
if (m_State == OBJECTIVESTATE_ALLIANCE && m_value >= m_maxValue)
if (_state == OBJECTIVESTATE_ALLIANCE && _value >= _maxValue)
return false;
if (fact_diff > maxDiff)
fact_diff = maxDiff;
if (factDiff > maxDiff)
factDiff = maxDiff;
ChallengerId = TEAM_ALLIANCE;
}
float oldValue = m_value;
TeamId oldTeam = m_team;
float oldValue = _value;
TeamId oldTeam = _team;
m_OldState = m_State;
_oldState = _state;
_value += factDiff;
m_value += fact_diff;
if (m_value < -m_minValue) // red
if (_value < -_minValue) // red
{
if (m_value < -m_maxValue)
m_value = -m_maxValue;
m_State = OBJECTIVESTATE_HORDE;
m_team = TEAM_HORDE;
if (_value < -_maxValue)
{
_value = -_maxValue;
}
_state = OBJECTIVESTATE_HORDE;
_team = TEAM_HORDE;
}
else if (m_value > m_minValue) // blue
else if (_value > _minValue) // blue
{
if (m_value > m_maxValue)
m_value = m_maxValue;
m_State = OBJECTIVESTATE_ALLIANCE;
m_team = TEAM_ALLIANCE;
if (_value > _maxValue)
{
_value = _maxValue;
}
_state = OBJECTIVESTATE_ALLIANCE;
_team = TEAM_ALLIANCE;
}
else if (oldValue * m_value <= 0) // grey, go through mid point
else if (oldValue * _value <= 0) // grey, go through mid-point
{
// if challenger is ally, then n->a challenge
if (ChallengerId == TEAM_ALLIANCE)
m_State = OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE;
// if challenger is horde, then n->h challenge
else if (ChallengerId == TEAM_HORDE)
m_State = OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE;
m_team = TEAM_NEUTRAL;
{
_state = OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE;
}
else if (ChallengerId == TEAM_HORDE) // if challenger is horde, then n->h challenge
{
_state = OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE;
}
_team = TEAM_NEUTRAL;
}
else // grey, did not go through mid point
else // grey, did not go through mid-point
{
// old phase and current are on the same side, so one team challenges the other
if (ChallengerId == TEAM_ALLIANCE && (m_OldState == OBJECTIVESTATE_HORDE || m_OldState == OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE))
m_State = OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE;
else if (ChallengerId == TEAM_HORDE && (m_OldState == OBJECTIVESTATE_ALLIANCE || m_OldState == OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE))
m_State = OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE;
m_team = TEAM_NEUTRAL;
if (ChallengerId == TEAM_ALLIANCE && (_oldState == OBJECTIVESTATE_HORDE || _oldState == OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE))
{
_state = OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE;
}
else if (ChallengerId == TEAM_HORDE && (_oldState == OBJECTIVESTATE_ALLIANCE || _oldState == OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE))
{
_state = OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE;
}
_team = TEAM_NEUTRAL;
}
if (m_value != oldValue)
SendChangePhase();
if (m_OldState != m_State)
if (_value != oldValue)
{
if (oldTeam != m_team)
SendChangePhase();
}
if (_oldState != _state)
{
if (oldTeam != _team)
{
ChangeTeam(oldTeam);
}
@@ -409,20 +456,20 @@ bool OPvPCapturePoint::Update(uint32 diff)
void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value)
{
if (m_sendUpdate)
for (int i = 0; i < 2; ++i)
for (PlayerSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
if (Player* const player = ObjectAccessor::FindPlayer(*itr))
if (_sendUpdate)
for (auto const& _player : _players)
for (auto itr : _player)
if (Player* const player = ObjectAccessor::FindPlayer(itr))
player->SendUpdateWorldState(field, value);
}
void OPvPCapturePoint::SendUpdateWorldState(uint32 field, uint32 value)
{
for (uint32 team = 0; team < 2; ++team)
for (auto const& activePlayer : _activePlayers)
{
// send to all players present in the area
for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr)
if (Player* const player = ObjectAccessor::FindPlayer(*itr))
for (auto itr : activePlayer)
if (Player* const player = ObjectAccessor::FindPlayer(itr))
player->SendUpdateWorldState(field, value);
}
}
@@ -430,7 +477,7 @@ void OPvPCapturePoint::SendUpdateWorldState(uint32 field, uint32 value)
void OPvPCapturePoint::SendObjectiveComplete(uint32 id, ObjectGuid guid)
{
uint32 team;
switch (m_State)
switch (_state)
{
case OBJECTIVESTATE_ALLIANCE:
team = 0;
@@ -443,19 +490,20 @@ void OPvPCapturePoint::SendObjectiveComplete(uint32 id, ObjectGuid guid)
}
// send to all players present in the area
for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr)
if (Player* const player = ObjectAccessor::FindPlayer(*itr))
for (auto itr : _activePlayers[team])
if (Player* const player = ObjectAccessor::FindPlayer(itr))
player->KilledMonsterCredit(id, guid);
}
void OutdoorPvP::HandleKill(Player* killer, Unit* killed)
{
ASSERT(killer);
if (Group* group = killer->GetGroup())
{
for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* groupGuy = itr->GetSource();
if (!groupGuy)
continue;
@@ -474,7 +522,7 @@ void OutdoorPvP::HandleKill(Player* killer, Unit* killed)
else
{
// creature kills must be notified, even if not inside objective / not outdoor pvp active
if (killer && ((killer->IsOutdoorPvPActive() && IsInsideObjective(killer)) || killed->GetTypeId() == TYPEID_UNIT))
if ((killer->IsOutdoorPvPActive() && IsInsideObjective(killer)) || killed->GetTypeId() == TYPEID_UNIT)
{
HandleKillImpl(killer, killed);
}
@@ -483,8 +531,8 @@ void OutdoorPvP::HandleKill(Player* killer, Unit* killed)
bool OutdoorPvP::IsInsideObjective(Player* player) const
{
for (OPvPCapturePointMap::const_iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
if (itr->second->IsInsideObjective(player))
for (auto& capturePoint : _capturePoints)
if (capturePoint.second->IsInsideObjective(player))
return true;
return false;
@@ -492,14 +540,14 @@ bool OutdoorPvP::IsInsideObjective(Player* player) const
bool OPvPCapturePoint::IsInsideObjective(Player* player) const
{
PlayerSet const& plSet = m_activePlayers[player->GetTeamId()];
PlayerSet const& plSet = _activePlayers[player->GetTeamId()];
return plSet.find(player->GetGUID()) != plSet.end();
}
bool OutdoorPvP::HandleCustomSpell(Player* player, uint32 spellId, GameObject* go)
{
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
if (itr->second->HandleCustomSpell(player, spellId, go))
for (auto& capturePoint : _capturePoints)
if (capturePoint.second->HandleCustomSpell(player, spellId, go))
return true;
return false;
@@ -507,15 +555,13 @@ bool OutdoorPvP::HandleCustomSpell(Player* player, uint32 spellId, GameObject* g
bool OPvPCapturePoint::HandleCustomSpell(Player* player, uint32 /*spellId*/, GameObject* /*go*/)
{
if (!player->IsOutdoorPvPActive())
return false;
return false;
return player->IsOutdoorPvPActive();
}
bool OutdoorPvP::HandleOpenGo(Player* player, GameObject* go)
{
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
if (itr->second->HandleOpenGo(player, go) >= 0)
for (auto& capturePoint : _capturePoints)
if (capturePoint.second->HandleOpenGo(player, go) >= 0)
return true;
return false;
@@ -523,8 +569,8 @@ bool OutdoorPvP::HandleOpenGo(Player* player, GameObject* go)
bool OutdoorPvP::HandleGossipOption(Player* player, Creature* creature, uint32 id)
{
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
if (itr->second->HandleGossipOption(player, creature, id))
for (auto& capturePoint : _capturePoints)
if (capturePoint.second->HandleGossipOption(player, creature, id))
return true;
return false;
@@ -532,8 +578,8 @@ bool OutdoorPvP::HandleGossipOption(Player* player, Creature* creature, uint32 i
bool OutdoorPvP::CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso)
{
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
if (itr->second->CanTalkTo(player, c, gso))
for (auto& capturePoint : _capturePoints)
if (capturePoint.second->CanTalkTo(player, c, gso))
return true;
return false;
@@ -541,8 +587,8 @@ bool OutdoorPvP::CanTalkTo(Player* player, Creature* c, GossipMenuItems const& g
bool OutdoorPvP::HandleDropFlag(Player* player, uint32 id)
{
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
if (itr->second->HandleDropFlag(player, id))
for (auto& capturePoint : _capturePoints)
if (capturePoint.second->HandleDropFlag(player, id))
return true;
return false;
@@ -565,14 +611,20 @@ bool OPvPCapturePoint::HandleDropFlag(Player* /*player*/, uint32 /*id*/)
int32 OPvPCapturePoint::HandleOpenGo(Player* /*player*/, GameObject* go)
{
std::map<ObjectGuid::LowType, uint32>::iterator itr = m_ObjectTypes.find(go->GetSpawnId());
if (itr != m_ObjectTypes.end())
auto const itr = _objectTypes.find(go->GetSpawnId());
if (itr != _objectTypes.end())
{
return itr->second;
return (int32)itr->second;
}
return -1;
}
void OPvPCapturePoint::SetSlider(float slider)
{
_value = std::clamp<float>(slider, -_maxValue, _maxValue);
}
bool OutdoorPvP::HandleAreaTrigger(Player* /*player*/, uint32 /*trigger*/)
{
return false;
@@ -581,9 +633,9 @@ bool OutdoorPvP::HandleAreaTrigger(Player* /*player*/, uint32 /*trigger*/)
void OutdoorPvP::BroadcastPacket(WorldPacket& data) const
{
// This is faster than sWorld->SendZoneMessage
for (uint32 team = 0; team < 2; ++team)
for (PlayerSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if (Player* const player = ObjectAccessor::FindPlayer(*itr))
for (auto const& playerSet : _players)
for (auto itr : playerSet)
if (Player* const player = ObjectAccessor::FindPlayer(itr))
player->GetSession()->SendPacket(&data);
}
@@ -594,7 +646,7 @@ void OutdoorPvP::RegisterZone(uint32 zoneId)
bool OutdoorPvP::HasPlayer(Player const* player) const
{
PlayerSet const& plSet = m_players[player->GetTeamId()];
PlayerSet const& plSet = _players[player->GetTeamId()];
return plSet.find(player->GetGUID()) != plSet.end();
}
@@ -602,15 +654,15 @@ void OutdoorPvP::TeamCastSpell(TeamId team, int32 spellId, Player* sameMapPlr)
{
if (spellId > 0)
{
for (PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if (Player* const player = ObjectAccessor::FindPlayer(*itr))
for (auto itr : _players[team])
if (Player* const player = ObjectAccessor::FindPlayer(itr))
if (!sameMapPlr || sameMapPlr->FindMap() == player->FindMap())
player->CastSpell(player, (uint32)spellId, true);
}
else
{
for (PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if (Player* const player = ObjectAccessor::FindPlayer(*itr))
for (auto itr : _players[team])
if (Player* const player = ObjectAccessor::FindPlayer(itr))
if (!sameMapPlr || sameMapPlr->FindMap() == player->FindMap())
player->RemoveAura((uint32) - spellId); // by stack?
}
@@ -618,49 +670,69 @@ void OutdoorPvP::TeamCastSpell(TeamId team, int32 spellId, Player* sameMapPlr)
void OutdoorPvP::TeamApplyBuff(TeamId teamId, uint32 spellId, uint32 spellId2, Player* sameMapPlr)
{
TeamCastSpell(teamId, spellId, sameMapPlr);
TeamCastSpell(teamId, (int32)spellId, sameMapPlr);
TeamCastSpell(teamId == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE, spellId2 ? -(int32)spellId2 : -(int32)spellId, sameMapPlr);
}
void OutdoorPvP::OnGameObjectCreate(GameObject* go)
{
GoScriptPair sp(go->GetGUID().GetCounter(), go);
m_GoScriptStore.insert(sp);
_goScriptStore.insert(sp);
if (go->GetGoType() != GAMEOBJECT_TYPE_CAPTURE_POINT)
{
return;
}
if (OPvPCapturePoint* cp = GetCapturePoint(go->GetSpawnId()))
cp->m_capturePoint = go;
{
cp->_capturePoint = go;
}
}
void OutdoorPvP::OnGameObjectRemove(GameObject* go)
{
m_GoScriptStore.erase(go->GetGUID().GetCounter());
_goScriptStore.erase(go->GetGUID().GetCounter());
if (go->GetGoType() != GAMEOBJECT_TYPE_CAPTURE_POINT)
{
return;
}
if (OPvPCapturePoint* cp = GetCapturePoint(go->GetSpawnId()))
cp->m_capturePoint = nullptr;
{
cp->_capturePoint = nullptr;
}
}
void OutdoorPvP::OnCreatureCreate(Creature* creature)
{
CreatureScriptPair sp(creature->GetGUID().GetCounter(), creature);
m_CreatureScriptStore.insert(sp);
_creatureScriptStore.insert(sp);
}
void OutdoorPvP::OnCreatureRemove(Creature* creature)
{
m_CreatureScriptStore.erase(creature->GetGUID().GetCounter());
_creatureScriptStore.erase(creature->GetGUID().GetCounter());
}
void OutdoorPvP::SetMapFromZone(uint32 zone)
{
AreaTableEntry const* areaTable = sAreaTableStore.LookupEntry(zone);
ASSERT(areaTable);
Map* map = sMapMgr->CreateBaseMap(areaTable->mapid);
ASSERT(!map->Instanceable());
m_map = map;
_map = map;
}
OPvPCapturePoint* OutdoorPvP::GetCapturePoint(ObjectGuid::LowType spawnId) const
{
auto const itr = _capturePoints.find(spawnId);
if (itr != _capturePoints.end())
{
return itr->second;
}
return nullptr;
}
+44 -75
View File
@@ -21,6 +21,7 @@
#include "SharedDefines.h"
#include "Util.h"
#include "ZoneScript.h"
#include <array>
class GameObject;
@@ -80,17 +81,17 @@ class GameObject;
class WorldPacket;
class Creature;
class Unit;
struct GossipMenuItems;
class OutdoorPvP;
struct GossipMenuItems;
typedef GuidSet PlayerSet;
class OPvPCapturePoint
{
public:
OPvPCapturePoint(OutdoorPvP* pvp);
virtual ~OPvPCapturePoint() {}
explicit OPvPCapturePoint(OutdoorPvP* pvp);
virtual ~OPvPCapturePoint() = default;
virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
@@ -113,24 +114,16 @@ public:
// returns true if the state of the objective has changed, in this case, the OutdoorPvP must send a world state ui update.
virtual bool Update(uint32 diff);
virtual void ChangeState() = 0;
virtual void ChangeTeam(TeamId /*oldTeam*/) {}
virtual void SendChangePhase();
virtual bool HandleGossipOption(Player* player, Creature* creature, uint32 gossipid);
virtual bool HandleGossipOption(Player* player, Creature* creature, uint32 gossipId);
virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso);
virtual bool HandleDropFlag(Player* player, uint32 spellId);
virtual void DeleteSpawns();
ObjectGuid::LowType m_capturePointSpawnId;
GameObject* m_capturePoint;
ObjectGuid::LowType m_capturePointSpawnId{};
GameObject* _capturePoint{};
void AddGO(uint32 type, ObjectGuid::LowType guid, uint32 entry = 0);
void AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entry = 0);
@@ -138,58 +131,54 @@ public:
bool SetCapturePointData(uint32 entry, uint32 map, float x, float y, float z, float o = 0,
float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0);
void SetSlider(float slider)
{
m_value = std::clamp<float>(slider, -m_maxValue, m_maxValue);
}
void SetSlider(float slider);
float GetSlider()
[[nodiscard]] float GetSlider() const
{
return m_value;
return _value;
}
protected:
bool AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o,
float rotation0, float rotation1, float rotation2, float rotation3);
bool AddCreature(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0);
bool AddCreature(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimeDelay = 0);
bool DelCreature(uint32 type);
bool DelObject(uint32 type);
bool DelCapturePoint();
protected:
// active players in the area of the objective, 0 - alliance, 1 - horde
PlayerSet m_activePlayers[2];
std::array<PlayerSet, 2> _activePlayers;
// total shift needed to capture the objective
float m_maxValue;
float m_minValue;
float _maxValue{};
float _minValue{};
// maximum speed of capture
float m_maxSpeed;
float _maxSpeed{};
// the status of the objective
float m_value;
float _value{};
TeamId m_team;
TeamId _team{ TEAM_NEUTRAL };
// objective states
ObjectiveStates m_OldState;
ObjectiveStates m_State;
ObjectiveStates _oldState{ OBJECTIVESTATE_NEUTRAL };
ObjectiveStates _state{ OBJECTIVESTATE_NEUTRAL };
// neutral value on capture bar
uint32 m_neutralValuePct;
uint32 _neutralValuePct{};
// pointer to the OutdoorPvP this objective belongs to
OutdoorPvP* m_PvP;
OutdoorPvP* _pvp{};
// map to store the various gameobjects and creatures spawned by the objective
// map to store the various game objects and creatures
// spawned by the objective
// type, guid
std::map<uint32, ObjectGuid::LowType> m_Objects;
std::map<uint32, ObjectGuid::LowType> m_Creatures;
std::map<ObjectGuid::LowType, uint32> m_ObjectTypes;
std::map<ObjectGuid::LowType, uint32> m_CreatureTypes;
std::unordered_map<uint32, ObjectGuid::LowType> _objects;
std::unordered_map<uint32, ObjectGuid::LowType> _creatures;
std::unordered_map<ObjectGuid::LowType, uint32> _objectTypes;
std::unordered_map<ObjectGuid::LowType, uint32> _creatureTypes;
};
// base class for specific outdoor pvp handlers
@@ -199,7 +188,7 @@ class OutdoorPvP : public ZoneScript
public:
// ctor
OutdoorPvP();
OutdoorPvP() = default;
// dtor
~OutdoorPvP() override;
@@ -213,7 +202,7 @@ public:
virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
// called when a player triggers an areatrigger
// called when a player triggers an area trigger
virtual bool HandleAreaTrigger(Player* player, uint32 trigger);
// called on custom spell
@@ -246,63 +235,43 @@ public:
// awards rewards for player kill
virtual void AwardKillBonus(Player* /*player*/) {}
uint32 GetTypeId() {return m_TypeId;}
uint32 GetTypeId() const { return _typeId; }
virtual bool HandleDropFlag(Player* player, uint32 spellId);
virtual bool HandleGossipOption(Player* player, Creature* creature, uint32 gossipid);
virtual bool HandleGossipOption(Player* player, Creature* creature, uint32 gossipId);
virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso);
void TeamApplyBuff(TeamId teamId, uint32 spellId, uint32 spellId2 = 0, Player* sameMapPlr = nullptr);
Map* GetMap() const { return m_map; }
Map* GetMap() const { return _map; }
protected:
// the map of the objectives belonging to this outdoorpvp
OPvPCapturePointMap m_capturePoints;
PlayerSet m_players[2];
uint32 m_TypeId;
bool m_sendUpdate;
// world state stuff
virtual void SendRemoveWorldStates(Player* /*player*/) {}
void BroadcastPacket(WorldPacket& data) const;
virtual void SendRemoveWorldStates(Player* /*player*/) {} // world state stuff
virtual void HandlePlayerEnterZone(Player* player, uint32 zone);
virtual void HandlePlayerLeaveZone(Player* player, uint32 zone);
virtual void HandlePlayerResurrects(Player* player, uint32 zone);
void AddCapturePoint(OPvPCapturePoint* cp)
{
m_capturePoints[cp->m_capturePointSpawnId] = cp;
}
OPvPCapturePoint* GetCapturePoint(ObjectGuid::LowType spawnId) const
{
OutdoorPvP::OPvPCapturePointMap::const_iterator itr = m_capturePoints.find(spawnId);
if (itr != m_capturePoints.end())
return itr->second;
return nullptr;
_capturePoints[cp->m_capturePointSpawnId] = cp;
}
OPvPCapturePoint* GetCapturePoint(ObjectGuid::LowType spawnId) const;
void RegisterZone(uint32 zoneid);
bool HasPlayer(Player const* player) const;
void TeamCastSpell(TeamId team, int32 spellId, Player* sameMapPlr = nullptr);
// Hack to store map
void SetMapFromZone(uint32 zone);
std::map<ObjectGuid::LowType, GameObject*> m_GoScriptStore;
std::map<ObjectGuid::LowType, Creature*> m_CreatureScriptStore;
Map* m_map;
// the map of the objectives belonging to this outdoor pvp
OPvPCapturePointMap _capturePoints;
std::array<PlayerSet, 2> _players;
uint32 _typeId{};
bool _sendUpdate{ true };
Map* _map{};
std::unordered_map<ObjectGuid::LowType, GameObject*> _goScriptStore;
std::unordered_map<ObjectGuid::LowType, Creature*> _creatureScriptStore;
};
#endif /*OUTDOOR_PVP_H_*/
+53 -37
View File
@@ -35,12 +35,8 @@ OutdoorPvPMgr* OutdoorPvPMgr::instance()
void OutdoorPvPMgr::Die()
{
//LOG_DEBUG("outdoorpvp", "Deleting OutdoorPvPMgr");
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
delete *itr;
for (OutdoorPvPDataMap::iterator itr = m_OutdoorPvPDatas.begin(); itr != m_OutdoorPvPDatas.end(); ++itr)
delete itr->second;
m_OutdoorPvPSet.clear();
m_OutdoorPvPDatas.clear();
}
void OutdoorPvPMgr::InitOutdoorPvP()
@@ -60,10 +56,8 @@ void OutdoorPvPMgr::InitOutdoorPvP()
uint32 count = 0;
uint32 typeId = 0;
do
for (auto const& fields : *result)
{
Field* fields = result->Fetch();
typeId = fields[0].Get<uint8>();
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_OUTDOORPVP, typeId, nullptr))
@@ -75,26 +69,25 @@ void OutdoorPvPMgr::InitOutdoorPvP()
continue;
}
OutdoorPvPData* data = new OutdoorPvPData();
OutdoorPvPTypes realTypeId = OutdoorPvPTypes(typeId);
auto data = std::make_unique<OutdoorPvPData>();
auto realTypeId = OutdoorPvPTypes(typeId);
data->TypeId = realTypeId;
data->ScriptId = sObjectMgr->GetScriptId(fields[1].Get<std::string>());
m_OutdoorPvPDatas[realTypeId] = data;
m_OutdoorPvPDatas[realTypeId] = std::move(data);
++count;
} while (result->NextRow());
}
OutdoorPvP* pvp;
for (uint8 i = 1; i < MAX_OUTDOORPVP_TYPES; ++i)
{
OutdoorPvPDataMap::iterator iter = m_OutdoorPvPDatas.find(OutdoorPvPTypes(i));
auto iter = m_OutdoorPvPDatas.find(OutdoorPvPTypes(i));
if (iter == m_OutdoorPvPDatas.end())
{
LOG_ERROR("sql.sql", "Could not initialize OutdoorPvP object for type ID {}; no entry in database.", uint32(i));
continue;
}
pvp = sScriptMgr->CreateOutdoorPvP(iter->second);
auto pvp = std::unique_ptr<OutdoorPvP>(sScriptMgr->CreateOutdoorPvP(iter->second.get()));
if (!pvp)
{
LOG_ERROR("outdoorpvp", "Could not initialize OutdoorPvP object for type ID {}; got nullptr pointer from script.", uint32(i));
@@ -104,11 +97,10 @@ void OutdoorPvPMgr::InitOutdoorPvP()
if (!pvp->SetupOutdoorPvP())
{
LOG_ERROR("outdoorpvp", "Could not initialize OutdoorPvP object for type ID {}; SetupOutdoorPvP failed.", uint32(i));
delete pvp;
continue;
}
m_OutdoorPvPSet.push_back(pvp);
m_OutdoorPvPSet.emplace_back(std::move(pvp));
}
LOG_INFO("server.loading", ">> Loaded {} outdoor PvP definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
@@ -122,7 +114,7 @@ void OutdoorPvPMgr::AddZone(uint32 zoneid, OutdoorPvP* handle)
void OutdoorPvPMgr::HandlePlayerEnterZone(Player* player, uint32 zoneid)
{
OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
auto itr = m_OutdoorPvPMap.find(zoneid);
if (itr == m_OutdoorPvPMap.end())
return;
@@ -137,7 +129,7 @@ void OutdoorPvPMgr::HandlePlayerEnterZone(Player* player, uint32 zoneid)
void OutdoorPvPMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneid)
{
OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
auto itr = m_OutdoorPvPMap.find(zoneid);
if (itr == m_OutdoorPvPMap.end())
return;
@@ -153,22 +145,27 @@ void OutdoorPvPMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneid)
OutdoorPvP* OutdoorPvPMgr::GetOutdoorPvPToZoneId(uint32 zoneid)
{
OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
auto itr = m_OutdoorPvPMap.find(zoneid);
if (itr == m_OutdoorPvPMap.end())
{
// no handle for this zone, return
return nullptr;
}
return itr->second;
}
void OutdoorPvPMgr::Update(uint32 diff)
{
m_UpdateTimer += diff;
if (m_UpdateTimer > OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL)
{
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
(*itr)->Update(m_UpdateTimer);
for (auto const& itr : m_OutdoorPvPSet)
{
itr->Update(m_UpdateTimer);
}
m_UpdateTimer = 0;
}
}
@@ -176,72 +173,91 @@ void OutdoorPvPMgr::Update(uint32 diff)
bool OutdoorPvPMgr::HandleCustomSpell(Player* player, uint32 spellId, GameObject* go)
{
// pussywizard: no mutex because not affecting other players
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
for (auto& itr : m_OutdoorPvPSet)
{
if ((*itr)->HandleCustomSpell(player, spellId, go))
if (itr->HandleCustomSpell(player, spellId, go))
{
return true;
}
}
return false;
}
ZoneScript* OutdoorPvPMgr::GetZoneScript(uint32 zoneId)
{
OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneId);
auto itr = m_OutdoorPvPMap.find(zoneId);
if (itr != m_OutdoorPvPMap.end())
{
return itr->second;
else
return nullptr;
}
return nullptr;
}
bool OutdoorPvPMgr::HandleOpenGo(Player* player, GameObject* go)
{
std::lock_guard<std::mutex> guard(_lock); // pussywizard
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
for (auto& itr : m_OutdoorPvPSet)
{
if ((*itr)->HandleOpenGo(player, go))
if (itr->HandleOpenGo(player, go))
{
return true;
}
}
return false;
}
void OutdoorPvPMgr::HandleGossipOption(Player* player, Creature* creature, uint32 gossipid)
{
std::lock_guard<std::mutex> guard(_lock); // pussywizard
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
for (auto& itr : m_OutdoorPvPSet)
{
if ((*itr)->HandleGossipOption(player, creature, gossipid))
if (itr->HandleGossipOption(player, creature, gossipid))
{
return;
}
}
}
bool OutdoorPvPMgr::CanTalkTo(Player* player, Creature* creature, GossipMenuItems const& gso)
{
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
for (auto& itr : m_OutdoorPvPSet)
{
if ((*itr)->CanTalkTo(player, creature, gso))
if (itr->CanTalkTo(player, creature, gso))
{
return true;
}
}
return false;
}
void OutdoorPvPMgr::HandleDropFlag(Player* player, uint32 spellId)
{
// pussywizard: no mutex because not affecting other players
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
for (auto& itr : m_OutdoorPvPSet)
{
if ((*itr)->HandleDropFlag(player, spellId))
if (itr->HandleDropFlag(player, spellId))
{
return;
}
}
}
void OutdoorPvPMgr::HandlePlayerResurrects(Player* player, uint32 zoneid)
{
OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
auto itr = m_OutdoorPvPMap.find(zoneid);
if (itr == m_OutdoorPvPMap.end())
return;
// pussywizard: no mutex because not affecting other players
if (itr->second->HasPlayer(player))
{
itr->second->HandlePlayerResurrects(player, zoneid);
}
}
+6 -9
View File
@@ -21,6 +21,7 @@
#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL 1000
#include "OutdoorPvP.h"
#include <memory>
class Player;
class GameObject;
@@ -39,7 +40,7 @@ class OutdoorPvPMgr
{
private:
OutdoorPvPMgr();
~OutdoorPvPMgr() {};
~OutdoorPvPMgr() = default;
public:
static OutdoorPvPMgr* instance();
@@ -80,24 +81,20 @@ public:
void HandleDropFlag(Player* player, uint32 spellId);
// pussywizard: lock required because different functions affect m_players
// pussywizard: lock required because different functions affect _players
std::mutex _lock;
private:
typedef std::vector<OutdoorPvP*> OutdoorPvPSet;
typedef std::map<uint32 /* zoneid */, OutdoorPvP*> OutdoorPvPMap;
typedef std::map<OutdoorPvPTypes, OutdoorPvPData*> OutdoorPvPDataMap;
// contains all initiated outdoor pvp events
// used when initing / cleaning up
OutdoorPvPSet m_OutdoorPvPSet;
std::vector<std::unique_ptr<OutdoorPvP>> m_OutdoorPvPSet;
// maps the zone ids to an outdoor pvp event
// used in player event handling
OutdoorPvPMap m_OutdoorPvPMap;
std::map<uint32/*zoneid*/, OutdoorPvP*> m_OutdoorPvPMap;
// Holds the outdoor PvP templates
OutdoorPvPDataMap m_OutdoorPvPDatas;
std::map<OutdoorPvPTypes, std::unique_ptr<OutdoorPvPData>> m_OutdoorPvPDatas;
// update interval
uint32 m_UpdateTimer;