Skip to content

Commit

Permalink
Core/Battleground: Removed _CheckSafePositions. This is handled by Ar…
Browse files Browse the repository at this point in the history
…eatriggers now
  • Loading branch information
Golrag committed May 4, 2015
1 parent 007ab5b commit ef14a12
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 60 deletions.
2 changes: 2 additions & 0 deletions sql/updates/world/2015_05_03_00_world.sql
@@ -0,0 +1,2 @@
ALTER TABLE `battleground_template` DROP COLUMN `StartMaxDist`;
UPDATE `battleground_template` SET `MaxLvl`=100;
29 changes: 0 additions & 29 deletions src/server/game/Battlegrounds/Battleground.cpp
Expand Up @@ -156,7 +156,6 @@ Battleground::Battleground()

m_MapId = 0;
m_Map = NULL;
m_StartMaxDist = 0.0f;
ScriptId = 0;

m_ArenaTeamIds[TEAM_ALLIANCE] = 0;
Expand Down Expand Up @@ -248,10 +247,7 @@ void Battleground::Update(uint32 diff)
{
case STATUS_WAIT_JOIN:
if (GetPlayersSize())
{
_ProcessJoin(diff);
_CheckSafePositions(diff);
}
break;
case STATUS_IN_PROGRESS:
_ProcessOfflineQueue();
Expand Down Expand Up @@ -292,31 +288,6 @@ void Battleground::Update(uint32 diff)
PostUpdateImpl(diff);
}

inline void Battleground::_CheckSafePositions(uint32 diff)
{
float maxDist = GetStartMaxDist();
if (!maxDist)
return;

m_ValidStartPositionTimer += diff;
if (m_ValidStartPositionTimer >= CHECK_PLAYER_POSITION_INVERVAL)
{
m_ValidStartPositionTimer = 0;

for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(itr->first))
{
Position pos = player->GetPosition();
Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam()));
if (pos.GetExactDistSq(startPos) > maxDist)
{
TC_LOG_DEBUG("bg.battleground", "BATTLEGROUND: Sending %s back to start location (map: %u) (possible exploit)", player->GetName().c_str(), GetMapId());
player->TeleportTo(GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation());
}
}
}
}

void Battleground::_ProcessPlayerPositionBroadcast(uint32 diff)
{
m_LastPlayerPositionBroadcast += diff;
Expand Down
5 changes: 0 additions & 5 deletions src/server/game/Battlegrounds/Battleground.h
Expand Up @@ -358,9 +358,6 @@ class Battleground
void SetTeamStartPosition(TeamId teamId, Position const& pos);
Position const* GetTeamStartPosition(TeamId teamId) const;

void SetStartMaxDist(float startMaxDist) { m_StartMaxDist = startMaxDist; }
float GetStartMaxDist() const { return m_StartMaxDist; }

// Packet Transfer
// method that should fill worldpacket with actual world states (not yet implemented for all battlegrounds!)
virtual void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& /*data*/) { }
Expand Down Expand Up @@ -534,7 +531,6 @@ class Battleground
void _ProcessProgress(uint32 diff);
void _ProcessLeave(uint32 diff);
void _ProcessJoin(uint32 diff);
void _CheckSafePositions(uint32 diff);
void _ProcessPlayerPositionBroadcast(uint32 diff);
virtual void GetPlayerPositionData(std::vector<WorldPackets::Battleground::BattlegroundPlayerPosition>* /*positions*/) const { }

Expand Down Expand Up @@ -622,7 +618,6 @@ class Battleground
uint32 m_MapId;
BattlegroundMap* m_Map;
Position StartPosition[BG_TEAMS_COUNT];
float m_StartMaxDist;
uint32 ScriptId;
};
#endif
11 changes: 4 additions & 7 deletions src/server/game/Battlegrounds/BattlegroundMgr.cpp
Expand Up @@ -454,7 +454,6 @@ bool BattlegroundMgr::CreateBattleground(BattlegroundTemplate const* bgTemplate)
bg->SetMaxPlayers(bgTemplate->MaxPlayersPerTeam * 2);
bg->SetTeamStartPosition(TEAM_ALLIANCE, bgTemplate->StartLocation[TEAM_ALLIANCE]);
bg->SetTeamStartPosition(TEAM_HORDE, bgTemplate->StartLocation[TEAM_HORDE]);
bg->SetStartMaxDist(bgTemplate->MaxStartDistSq);
bg->SetLevelRange(bgTemplate->MinLevel, bgTemplate->MaxLevel);
bg->SetScriptId(bgTemplate->ScriptId);
bg->SetQueueId(uint64(bgTemplate->Id) | UI64LIT(0x1F10000000000000));
Expand All @@ -471,8 +470,8 @@ void BattlegroundMgr::LoadBattlegroundTemplates()
_battlegroundMapTemplates.clear();
_battlegroundTemplates.clear();

// 0 1 2 3 4 5 6 7 8 9
QueryResult result = WorldDatabase.Query("SELECT ID, MinPlayersPerTeam, MaxPlayersPerTeam, MinLvl, MaxLvl, AllianceStartLoc, HordeStartLoc, StartMaxDist, Weight, ScriptName FROM battleground_template");
// 0 1 2 3 4 5 6 7 8
QueryResult result = WorldDatabase.Query("SELECT ID, MinPlayersPerTeam, MaxPlayersPerTeam, MinLvl, MaxLvl, AllianceStartLoc, HordeStartLoc, Weight, ScriptName FROM battleground_template");
if (!result)
{
TC_LOG_ERROR("server.loading", ">> Loaded 0 battlegrounds. DB table `battleground_template` is empty.");
Expand Down Expand Up @@ -504,10 +503,8 @@ void BattlegroundMgr::LoadBattlegroundTemplates()
bgTemplate.MaxPlayersPerTeam = fields[2].GetUInt16();
bgTemplate.MinLevel = fields[3].GetUInt8();
bgTemplate.MaxLevel = fields[4].GetUInt8();
float dist = fields[7].GetFloat();
bgTemplate.MaxStartDistSq = dist * dist;
bgTemplate.Weight = fields[8].GetUInt8();
bgTemplate.ScriptId = sObjectMgr->GetScriptId(fields[9].GetCString());
bgTemplate.Weight = fields[7].GetUInt8();
bgTemplate.ScriptId = sObjectMgr->GetScriptId(fields[8].GetCString());
bgTemplate.BattlemasterEntry = bl;

if (bgTemplate.MaxPlayersPerTeam == 0 || bgTemplate.MinPlayersPerTeam > bgTemplate.MaxPlayersPerTeam)
Expand Down
1 change: 0 additions & 1 deletion src/server/game/Battlegrounds/BattlegroundMgr.h
Expand Up @@ -46,7 +46,6 @@ struct BattlegroundTemplate
uint8 MinLevel;
uint8 MaxLevel;
Position StartLocation[BG_TEAMS_COUNT];
float MaxStartDistSq;
uint8 Weight;
uint32 ScriptId;
BattlemasterListEntry const* BattlemasterEntry;
Expand Down
13 changes: 9 additions & 4 deletions src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
Expand Up @@ -233,9 +233,6 @@ void BattlegroundAB::RemovePlayer(Player* /*player*/, ObjectGuid /*guid*/, uint3

void BattlegroundAB::HandleAreaTrigger(Player* player, uint32 trigger, bool entered)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;

switch (trigger)
{
case 3948: // Arathi Basin Alliance Exit.
Expand All @@ -258,7 +255,15 @@ void BattlegroundAB::HandleAreaTrigger(Player* player, uint32 trigger, bool ente
case 4020: // Unk1
case 4021: // Unk2
case 4674: // Unk3
//break;
break;
case 6635: // Horde Start
case 6634: // Alliance Start
if (!entered && GetStatus() == STATUS_WAIT_JOIN)
{
Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam()));
player->TeleportTo(GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation());
}
break;
default:
Battleground::HandleAreaTrigger(player, trigger, entered);
break;
Expand Down
11 changes: 8 additions & 3 deletions src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
Expand Up @@ -495,9 +495,6 @@ void BattlegroundAV::RemovePlayer(Player* player, ObjectGuid /*guid*/, uint32 /*

void BattlegroundAV::HandleAreaTrigger(Player* player, uint32 trigger, bool entered)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;

switch (trigger)
{
case 95:
Expand All @@ -521,6 +518,14 @@ void BattlegroundAV::HandleAreaTrigger(Player* player, uint32 trigger, bool ente
case 3331:
//Source->Unmount();
break;
case 6633: // Horde Start
case 6632: // Alliance Start
if (entered && GetStatus() == STATUS_WAIT_JOIN)
{
Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam()));
player->TeleportTo(GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation());
}
break;
default:
Battleground::HandleAreaTrigger(player, trigger, entered);
break;
Expand Down
18 changes: 18 additions & 0 deletions src/server/game/Battlegrounds/Zones/BattlegroundBFG.cpp
Expand Up @@ -34,3 +34,21 @@ BattlegroundBFG::BattlegroundBFG()
BattlegroundBFG::~BattlegroundBFG()
{
}

void BattlegroundBFG::HandleAreaTrigger(Player* player, uint32 trigger, bool entered)
{
switch (trigger)
{
case 6448: // Horde Start
case 6447: // Alliance Start
if (!entered && GetStatus() == STATUS_WAIT_JOIN)
{
Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam()));
player->TeleportTo(GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation());
}
break;
default:
Battleground::HandleAreaTrigger(player, trigger, entered);
break;
}
}
2 changes: 2 additions & 0 deletions src/server/game/Battlegrounds/Zones/BattlegroundBFG.h
Expand Up @@ -60,6 +60,8 @@ class BattlegroundBFG : public Battleground
public:
BattlegroundBFG();
~BattlegroundBFG();

void HandleAreaTrigger(Player* player, uint32 trigger, bool entered) override;
};

#endif
13 changes: 8 additions & 5 deletions src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp
Expand Up @@ -408,9 +408,6 @@ void BattlegroundEY::RemovePlayer(Player* player, ObjectGuid guid, uint32 /*team

void BattlegroundEY::HandleAreaTrigger(Player* player, uint32 trigger, bool entered)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;

if (!player->IsAlive()) //hack code, must be removed later
return;

Expand Down Expand Up @@ -440,14 +437,20 @@ void BattlegroundEY::HandleAreaTrigger(Player* player, uint32 trigger, bool ente
case 4515:
case 4517:
case 4519:
case 4530:
case 4531:
case 4568:
case 4569:
case 4570:
case 4571:
case 5866:
break;
case 4530: // Horde Start
case 4531: // Alliance Start
if (!entered && GetStatus() == STATUS_WAIT_JOIN)
{
Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam()));
player->TeleportTo(GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation());
}
break;
default:
Battleground::HandleAreaTrigger(player, trigger, entered);
break;
Expand Down
14 changes: 13 additions & 1 deletion src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp
Expand Up @@ -264,8 +264,20 @@ void BattlegroundIC::RemovePlayer(Player* player, ObjectGuid /*guid*/, uint32 /*
}
}

void BattlegroundIC::HandleAreaTrigger(Player* player, uint32 trigger, bool /*entered*/)
void BattlegroundIC::HandleAreaTrigger(Player* player, uint32 trigger, bool entered)
{
if (trigger == 9176 && GetStatus() == STATUS_WAIT_JOIN && !entered) // Horde Start
{
Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam()));
player->TeleportTo(GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation());
}

if (trigger == 9178 && GetStatus() == STATUS_WAIT_JOIN && !entered) // Alliance Start
{
Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam()));
player->TeleportTo(GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation());
}

// this is wrong way to implement these things. On official it done by gameobject spell cast.
if (GetStatus() != STATUS_IN_PROGRESS)
return;
Expand Down
18 changes: 18 additions & 0 deletions src/server/game/Battlegrounds/Zones/BattlegroundTP.cpp
Expand Up @@ -34,3 +34,21 @@ BattlegroundTP::BattlegroundTP()
BattlegroundTP::~BattlegroundTP()
{
}

void BattlegroundTP::HandleAreaTrigger(Player* player, uint32 trigger, bool entered)
{
switch (trigger)
{
case 8968: // Horde Start
case 8969: // Alliance Start
if (!entered && GetStatus() == STATUS_WAIT_JOIN)
{
Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam()));
player->TeleportTo(GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation());
}
break;
default:
Battleground::HandleAreaTrigger(player, trigger, entered);
break;
}
}
2 changes: 2 additions & 0 deletions src/server/game/Battlegrounds/Zones/BattlegroundTP.h
Expand Up @@ -60,6 +60,8 @@ class BattlegroundTP : public Battleground
public:
BattlegroundTP();
~BattlegroundTP();

void HandleAreaTrigger(Player* player, uint32 trigger, bool entered) override;
};

#endif
11 changes: 8 additions & 3 deletions src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
Expand Up @@ -653,9 +653,6 @@ void BattlegroundWS::UpdateTeamScore(uint32 team)

void BattlegroundWS::HandleAreaTrigger(Player* player, uint32 trigger, bool entered)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;

//uint32 SpellId = 0;
//uint64 buff_guid = 0;
switch (trigger)
Expand Down Expand Up @@ -693,6 +690,14 @@ void BattlegroundWS::HandleAreaTrigger(Player* player, uint32 trigger, bool ente
case 4628: // unk3
case 4629: // unk4
break;
case 8965: // Horde Start
case 8966: // Alliance Start
if (!entered && GetStatus() == STATUS_WAIT_JOIN)
{
Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam()));
player->TeleportTo(GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation());
}
break;
default:
Battleground::HandleAreaTrigger(player, trigger, entered);
break;
Expand Down
3 changes: 1 addition & 2 deletions src/server/game/Handlers/MiscHandler.cpp
Expand Up @@ -572,8 +572,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPackets::Misc::AreaTrigger& pack
}

if (Battleground* bg = player->GetBattleground())
if (bg->GetStatus() == STATUS_IN_PROGRESS)
bg->HandleAreaTrigger(player, packet.AreaTriggerID, packet.Entered);
bg->HandleAreaTrigger(player, packet.AreaTriggerID, packet.Entered);

if (OutdoorPvP* pvp = player->GetOutdoorPvP())
if (pvp->HandleAreaTrigger(_player, packet.AreaTriggerID, packet.Entered))
Expand Down

0 comments on commit ef14a12

Please sign in to comment.