Core/Misc: ported missing capture point refactors from master branch
This commit is contained in:
1 parent
ab85cc0948
commit
bbe49972a2
4 files changed
+44
-52
No files matched your search
@@ -448,6 +448,25 @@ void Battlefield::SendWarning(uint8 id, WorldObject const* target /*= nullptr*/)
|
||||
sCreatureTextMgr->SendChat(stalker, id, target);
|
||||
}
|
||||
|
||||
void Battlefield::AddCapturePoint(BfCapturePoint* cp)
|
||||
{
|
||||
Battlefield::BfCapturePointMap::iterator i = m_capturePoints.find(cp->GetCapturePointEntry());
|
||||
if (i != m_capturePoints.end())
|
||||
{
|
||||
TC_LOG_ERROR("bg.battlefield", "Battlefield::AddCapturePoint: CapturePoint %s already exists!", cp->GetCapturePointEntry());
|
||||
delete i->second;
|
||||
}
|
||||
m_capturePoints[cp->GetCapturePointEntry()] = cp;
|
||||
}
|
||||
|
||||
BfCapturePoint* Battlefield::GetCapturePoint(uint32 entry) const
|
||||
{
|
||||
Battlefield::BfCapturePointMap::const_iterator itr = m_capturePoints.find(entry);
|
||||
if (itr != m_capturePoints.end())
|
||||
return itr->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Battlefield::RegisterZone(uint32 zoneId)
|
||||
{
|
||||
sBattlefieldMgr->AddZone(zoneId, this);
|
||||
@@ -810,7 +829,7 @@ GameObject* Battlefield::GetGameObject(ObjectGuid guid)
|
||||
// ******************* CapturePoint **********************
|
||||
// *******************************************************
|
||||
|
||||
BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_capturePointSpawnId()
|
||||
BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_capturePointGUID()
|
||||
{
|
||||
m_team = TEAM_NEUTRAL;
|
||||
m_value = 0;
|
||||
@@ -825,9 +844,9 @@ BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_
|
||||
|
||||
bool BfCapturePoint::HandlePlayerEnter(Player* player)
|
||||
{
|
||||
if (m_capturePointSpawnId)
|
||||
if (!m_capturePointGUID.IsEmpty())
|
||||
{
|
||||
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointSpawnId))
|
||||
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID))
|
||||
{
|
||||
player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
|
||||
player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldstate2, uint32(ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)));
|
||||
@@ -840,8 +859,8 @@ bool BfCapturePoint::HandlePlayerEnter(Player* player)
|
||||
|
||||
GuidSet::iterator BfCapturePoint::HandlePlayerLeave(Player* player)
|
||||
{
|
||||
if (m_capturePointSpawnId)
|
||||
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointSpawnId))
|
||||
if (!m_capturePointGUID.IsEmpty())
|
||||
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID))
|
||||
player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldState1, 0);
|
||||
|
||||
GuidSet::iterator current = m_activePlayers[player->GetTeamId()].find(player->GetGUID());
|
||||
@@ -855,10 +874,10 @@ GuidSet::iterator BfCapturePoint::HandlePlayerLeave(Player* player)
|
||||
|
||||
void BfCapturePoint::SendChangePhase()
|
||||
{
|
||||
if (!m_capturePointSpawnId)
|
||||
if (!m_capturePointGUID)
|
||||
return;
|
||||
|
||||
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointSpawnId))
|
||||
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID))
|
||||
{
|
||||
// send this too, sometimes the slider disappears, dunno why :(
|
||||
SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
|
||||
@@ -875,7 +894,8 @@ bool BfCapturePoint::SetCapturePointData(GameObject* capturePoint)
|
||||
|
||||
TC_LOG_DEBUG("bg.battlefield", "Creating capture point %u", capturePoint->GetEntry());
|
||||
|
||||
m_capturePointSpawnId = ObjectGuid(HighGuid::GameObject, capturePoint->GetEntry(), capturePoint->GetGUID().GetCounter());
|
||||
m_capturePointGUID = capturePoint->GetGUID();
|
||||
m_capturePointEntry = capturePoint->GetEntry();
|
||||
|
||||
// check info existence
|
||||
GameObjectTemplate const* goinfo = capturePoint->GetGOInfo();
|
||||
@@ -890,7 +910,6 @@ bool BfCapturePoint::SetCapturePointData(GameObject* capturePoint)
|
||||
m_maxSpeed = m_maxValue / (goinfo->capturePoint.minTime ? goinfo->capturePoint.minTime : 60);
|
||||
m_neutralValuePct = goinfo->capturePoint.neutralPercent;
|
||||
m_minValue = m_maxValue * goinfo->capturePoint.neutralPercent / 100;
|
||||
m_capturePointEntry = capturePoint->GetEntry();
|
||||
if (m_team == TEAM_ALLIANCE)
|
||||
{
|
||||
m_value = m_maxValue;
|
||||
@@ -907,20 +926,20 @@ bool BfCapturePoint::SetCapturePointData(GameObject* capturePoint)
|
||||
|
||||
GameObject* BfCapturePoint::GetCapturePointGo()
|
||||
{
|
||||
return m_Bf->GetGameObject(m_capturePointSpawnId);
|
||||
return m_Bf->GetGameObject(m_capturePointGUID);
|
||||
}
|
||||
|
||||
bool BfCapturePoint::DelCapturePoint()
|
||||
{
|
||||
if (m_capturePointSpawnId)
|
||||
if (!m_capturePointGUID.IsEmpty())
|
||||
{
|
||||
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointSpawnId))
|
||||
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID))
|
||||
{
|
||||
capturePoint->SetRespawnTime(0); // not save respawn time
|
||||
capturePoint->Delete();
|
||||
capturePoint = nullptr;
|
||||
}
|
||||
m_capturePointSpawnId.Clear();
|
||||
m_capturePointGUID.Clear();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -928,10 +947,10 @@ bool BfCapturePoint::DelCapturePoint()
|
||||
|
||||
bool BfCapturePoint::Update(uint32 diff)
|
||||
{
|
||||
if (!m_capturePointSpawnId)
|
||||
if (!m_capturePointGUID)
|
||||
return false;
|
||||
|
||||
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointSpawnId))
|
||||
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID))
|
||||
{
|
||||
float radius = capturePoint->GetGOInfo()->capturePoint.radius;
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ class TC_GAME_API BfCapturePoint
|
||||
uint32 m_capturePointEntry;
|
||||
|
||||
// Gameobject related to that capture point
|
||||
ObjectGuid m_capturePointSpawnId;
|
||||
ObjectGuid m_capturePointGUID;
|
||||
};
|
||||
|
||||
class TC_GAME_API BfGraveyard
|
||||
@@ -419,15 +419,8 @@ class TC_GAME_API Battlefield : public ZoneScript
|
||||
void BroadcastPacketToWar(WorldPacket const* data) const;
|
||||
|
||||
// CapturePoint system
|
||||
void AddCapturePoint(BfCapturePoint* cp) { m_capturePoints[cp->GetCapturePointEntry()] = cp; }
|
||||
|
||||
BfCapturePoint* GetCapturePoint(ObjectGuid::LowType 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);
|
||||
BfCapturePoint* GetCapturePoint(uint32 entry) const;
|
||||
|
||||
void RegisterZone(uint32 zoneid);
|
||||
bool HasPlayer(Player* player) const;
|
||||
|
||||
@@ -400,38 +400,18 @@ bool OutdoorPvP::HandleDropFlag(Player* player, uint32 id)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OPvPCapturePoint::HandleGossipOption(Player* /*player*/, Creature* /*creature*/, uint32 /*id*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OPvPCapturePoint::CanTalkTo(Player* /*player*/, Creature* /*c*/, GossipMenuItems const& /*gso*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OPvPCapturePoint::HandleDropFlag(Player* /*player*/, uint32 /*id*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 OPvPCapturePoint::HandleOpenGo(Player* /*player*/, GameObject* /*go*/)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool OutdoorPvP::HandleAreaTrigger(Player* /*player*/, uint32 /*trigger*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void OutdoorPvP::BroadcastPacket(WorldPacket &data) const
|
||||
void OutdoorPvP::BroadcastPacket(WorldPacket const* data) const
|
||||
{
|
||||
// This is faster than sWorld->SendZoneMessage
|
||||
for (uint32 team = 0; team < BG_TEAMS_COUNT; ++team)
|
||||
for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
|
||||
if (Player* const player = ObjectAccessor::FindPlayer(*itr))
|
||||
player->SendDirectMessage(&data);
|
||||
player->SendDirectMessage(data);
|
||||
}
|
||||
|
||||
void OutdoorPvP::AddCapturePoint(OPvPCapturePoint* cp)
|
||||
|
||||
@@ -117,11 +117,11 @@ class TC_GAME_API OPvPCapturePoint
|
||||
|
||||
virtual void SendChangePhase();
|
||||
|
||||
virtual bool HandleGossipOption(Player* player, Creature* creature, uint32 gossipid);
|
||||
virtual bool HandleGossipOption(Player* /*player*/, Creature* /*creature*/, uint32 /*gossipId*/) { return false; }
|
||||
|
||||
virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso);
|
||||
virtual bool CanTalkTo(Player* /*player*/, Creature* /*creature*/, GossipMenuItems const& /*gso*/) { return false; }
|
||||
|
||||
virtual bool HandleDropFlag(Player* player, uint32 spellId);
|
||||
virtual bool HandleDropFlag(Player* /*player*/, uint32 /*spellId*/) { return false; }
|
||||
|
||||
ObjectGuid::LowType m_capturePointSpawnId;
|
||||
|
||||
@@ -176,7 +176,7 @@ class TC_GAME_API OutdoorPvP : public ZoneScript
|
||||
typedef std::pair<ObjectGuid::LowType, Creature*> CreatureScriptPair;
|
||||
|
||||
// called when a player triggers an areatrigger
|
||||
virtual bool HandleAreaTrigger(Player* player, uint32 trigger);
|
||||
virtual bool HandleAreaTrigger(Player* /*player*/, uint32 /*trigger*/) { return false; }
|
||||
|
||||
// called on custom spell
|
||||
virtual bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go);
|
||||
@@ -246,7 +246,7 @@ class TC_GAME_API OutdoorPvP : public ZoneScript
|
||||
// world state stuff
|
||||
virtual void SendRemoveWorldStates(Player* /*player*/) { }
|
||||
|
||||
void BroadcastPacket(WorldPacket & data) const;
|
||||
void BroadcastPacket(WorldPacket const* data) const;
|
||||
|
||||
virtual void HandlePlayerEnterZone(Player* player, uint32 zone);
|
||||
virtual void HandlePlayerLeaveZone(Player* player, uint32 zone);
|
||||
|
||||
Reference in new issue
Block a user