mirror of
https://github.com/mangosfour/server.git
synced 2025-12-26 16:37:06 +00:00
[10782] Use Team enum types in all appropriate cases and catches bug in result fix.
* Fixed wrong arenaid use at leave arena queue. * Fixed memory lost and etc at not virtual EndBattleground call * Fixed crash at arena join with fake data from client. * Code cleanups.
This commit is contained in:
parent
c2331f58bc
commit
cc0655a402
38 changed files with 315 additions and 321 deletions
|
|
@ -360,7 +360,7 @@ void BattleGround::Update(uint32 diff)
|
|||
else if (m_PrematureCountDownTimer < diff)
|
||||
{
|
||||
// time's up!
|
||||
uint32 winner = 0;
|
||||
Team winner = TEAM_NONE;
|
||||
if (GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam())
|
||||
winner = ALLIANCE;
|
||||
else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam())
|
||||
|
|
@ -507,9 +507,9 @@ void BattleGround::Update(uint32 diff)
|
|||
m_StartTime += diff;
|
||||
}
|
||||
|
||||
void BattleGround::SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O)
|
||||
void BattleGround::SetTeamStartLoc(Team team, float X, float Y, float Z, float O)
|
||||
{
|
||||
BattleGroundTeamIndex teamIdx = GetTeamIndexByTeamId(TeamID);
|
||||
BattleGroundTeamIndex teamIdx = GetTeamIndexByTeamId(team);
|
||||
m_TeamStartLocX[teamIdx] = X;
|
||||
m_TeamStartLocY[teamIdx] = Y;
|
||||
m_TeamStartLocZ[teamIdx] = Z;
|
||||
|
|
@ -530,7 +530,7 @@ void BattleGround::SendPacketToAll(WorldPacket *packet)
|
|||
}
|
||||
}
|
||||
|
||||
void BattleGround::SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *sender, bool self)
|
||||
void BattleGround::SendPacketToTeam(Team teamId, WorldPacket *packet, Player *sender, bool self)
|
||||
{
|
||||
for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
||||
{
|
||||
|
|
@ -546,10 +546,10 @@ void BattleGround::SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *
|
|||
if (!self && sender == plr)
|
||||
continue;
|
||||
|
||||
uint32 team = itr->second.Team;
|
||||
if(!team) team = plr->GetTeam();
|
||||
Team team = itr->second.PlayerTeam;
|
||||
if (!team) team = plr->GetTeam();
|
||||
|
||||
if (team == TeamID)
|
||||
if (team == teamId)
|
||||
plr->GetSession()->SendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
|
@ -561,7 +561,7 @@ void BattleGround::PlaySoundToAll(uint32 SoundID)
|
|||
SendPacketToAll(&data);
|
||||
}
|
||||
|
||||
void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID)
|
||||
void BattleGround::PlaySoundToTeam(uint32 SoundID, Team teamId)
|
||||
{
|
||||
WorldPacket data;
|
||||
|
||||
|
|
@ -577,10 +577,10 @@ void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID)
|
|||
continue;
|
||||
}
|
||||
|
||||
uint32 team = itr->second.Team;
|
||||
Team team = itr->second.PlayerTeam;
|
||||
if(!team) team = plr->GetTeam();
|
||||
|
||||
if (team == TeamID)
|
||||
if (team == teamId)
|
||||
{
|
||||
sBattleGroundMgr.BuildPlaySoundPacket(&data, SoundID);
|
||||
plr->GetSession()->SendPacket(&data);
|
||||
|
|
@ -588,7 +588,7 @@ void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID)
|
|||
}
|
||||
}
|
||||
|
||||
void BattleGround::CastSpellOnTeam(uint32 SpellID, uint32 TeamID)
|
||||
void BattleGround::CastSpellOnTeam(uint32 SpellID, Team teamId)
|
||||
{
|
||||
for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
||||
{
|
||||
|
|
@ -602,15 +602,15 @@ void BattleGround::CastSpellOnTeam(uint32 SpellID, uint32 TeamID)
|
|||
continue;
|
||||
}
|
||||
|
||||
uint32 team = itr->second.Team;
|
||||
Team team = itr->second.PlayerTeam;
|
||||
if(!team) team = plr->GetTeam();
|
||||
|
||||
if (team == TeamID)
|
||||
if (team == teamId)
|
||||
plr->CastSpell(plr, SpellID, true);
|
||||
}
|
||||
}
|
||||
|
||||
void BattleGround::RewardHonorToTeam(uint32 Honor, uint32 TeamID)
|
||||
void BattleGround::RewardHonorToTeam(uint32 Honor, Team teamId)
|
||||
{
|
||||
for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
||||
{
|
||||
|
|
@ -624,15 +624,15 @@ void BattleGround::RewardHonorToTeam(uint32 Honor, uint32 TeamID)
|
|||
continue;
|
||||
}
|
||||
|
||||
uint32 team = itr->second.Team;
|
||||
Team team = itr->second.PlayerTeam;
|
||||
if(!team) team = plr->GetTeam();
|
||||
|
||||
if (team == TeamID)
|
||||
if (team == teamId)
|
||||
UpdatePlayerScore(plr, SCORE_BONUS_HONOR, Honor);
|
||||
}
|
||||
}
|
||||
|
||||
void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID)
|
||||
void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, Team teamId)
|
||||
{
|
||||
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id);
|
||||
|
||||
|
|
@ -651,10 +651,10 @@ void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation,
|
|||
continue;
|
||||
}
|
||||
|
||||
uint32 team = itr->second.Team;
|
||||
Team team = itr->second.PlayerTeam;
|
||||
if(!team) team = plr->GetTeam();
|
||||
|
||||
if (team == TeamID)
|
||||
if (team == teamId)
|
||||
plr->GetReputationMgr().ModifyReputation(factionEntry, Reputation);
|
||||
}
|
||||
}
|
||||
|
|
@ -673,7 +673,7 @@ void BattleGround::UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player
|
|||
Source->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
void BattleGround::EndBattleGround(uint32 winner)
|
||||
void BattleGround::EndBattleGround(Team winner)
|
||||
{
|
||||
this->RemoveFromBGFreeSlotQueue();
|
||||
|
||||
|
|
@ -733,7 +733,7 @@ void BattleGround::EndBattleGround(uint32 winner)
|
|||
|
||||
for(BattleGroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
||||
{
|
||||
uint32 team = itr->second.Team;
|
||||
Team team = itr->second.PlayerTeam;
|
||||
|
||||
if (itr->second.OfflineRemoveTime)
|
||||
{
|
||||
|
|
@ -995,7 +995,7 @@ void BattleGround::BlockMovement(Player *plr)
|
|||
|
||||
void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket)
|
||||
{
|
||||
uint32 team = GetPlayerTeam(guid);
|
||||
Team team = GetPlayerTeam(guid);
|
||||
bool participant = false;
|
||||
// Remove from lists/maps
|
||||
BattleGroundPlayerMap::iterator itr = m_Players.find(guid);
|
||||
|
|
@ -1036,7 +1036,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
|
|||
{
|
||||
plr->ClearAfkReports();
|
||||
|
||||
if(!team) team = plr->GetTeam();
|
||||
if (!team) team = plr->GetTeam();
|
||||
|
||||
// if arena, remove the specific arena auras
|
||||
if (isArena())
|
||||
|
|
@ -1109,7 +1109,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
|
|||
// Do next only if found in battleground
|
||||
plr->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG.
|
||||
// reset destination bg team
|
||||
plr->SetBGTeam(0);
|
||||
plr->SetBGTeam(TEAM_NONE);
|
||||
|
||||
if (Transport)
|
||||
plr->TeleportToBGEntryPoint();
|
||||
|
|
@ -1176,11 +1176,11 @@ void BattleGround::AddPlayer(Player *plr)
|
|||
// score struct must be created in inherited class
|
||||
|
||||
ObjectGuid guid = plr->GetObjectGuid();
|
||||
uint32 team = plr->GetBGTeam();
|
||||
Team team = plr->GetBGTeam();
|
||||
|
||||
BattleGroundPlayer bp;
|
||||
bp.OfflineRemoveTime = 0;
|
||||
bp.Team = team;
|
||||
bp.PlayerTeam = team;
|
||||
|
||||
// Add to list/maps
|
||||
m_Players[guid.GetRawValue()] = bp;
|
||||
|
|
@ -1197,7 +1197,7 @@ void BattleGround::AddPlayer(Player *plr)
|
|||
plr->RemoveArenaSpellCooldowns();
|
||||
plr->RemoveArenaAuras();
|
||||
plr->RemoveAllEnchantments(TEMP_ENCHANTMENT_SLOT);
|
||||
if(team == ALLIANCE) // gold
|
||||
if (team == ALLIANCE) // gold
|
||||
{
|
||||
if (plr->GetTeam() == HORDE)
|
||||
plr->CastSpell(plr, SPELL_HORDE_GOLD_FLAG,true);
|
||||
|
|
@ -1241,7 +1241,7 @@ void BattleGround::AddPlayer(Player *plr)
|
|||
}
|
||||
|
||||
/* this method adds player to his team's bg group, or sets his correct group if player is already in bg group */
|
||||
void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player *plr, ObjectGuid plr_guid, uint32 team)
|
||||
void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player *plr, ObjectGuid plr_guid, Team team)
|
||||
{
|
||||
if (Group* group = GetBgRaid(team)) // raid already exist
|
||||
{
|
||||
|
|
@ -1330,11 +1330,11 @@ void BattleGround::RemoveFromBGFreeSlotQueue()
|
|||
|
||||
// get the number of free slots for team
|
||||
// returns the number how many players can join battleground to MaxPlayersPerTeam
|
||||
uint32 BattleGround::GetFreeSlotsForTeam(uint32 Team) const
|
||||
uint32 BattleGround::GetFreeSlotsForTeam(Team team) const
|
||||
{
|
||||
//return free slot count to MaxPlayerPerTeam
|
||||
if (GetStatus() == STATUS_WAIT_JOIN || GetStatus() == STATUS_IN_PROGRESS)
|
||||
return (GetInvitedCount(Team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(Team) : 0;
|
||||
return (GetInvitedCount(team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(team) : 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1751,12 +1751,12 @@ void BattleGround::HandleKillPlayer( Player *player, Player *killer )
|
|||
|
||||
// return the player's team based on battlegroundplayer info
|
||||
// used in same faction arena matches mainly
|
||||
uint32 BattleGround::GetPlayerTeam(uint64 guid)
|
||||
Team BattleGround::GetPlayerTeam(uint64 guid)
|
||||
{
|
||||
BattleGroundPlayerMap::const_iterator itr = m_Players.find(guid);
|
||||
if (itr!=m_Players.end())
|
||||
return itr->second.Team;
|
||||
return 0;
|
||||
if (itr != m_Players.end())
|
||||
return itr->second.PlayerTeam;
|
||||
return TEAM_NONE;
|
||||
}
|
||||
|
||||
bool BattleGround::IsPlayerInBattleGround(uint64 guid)
|
||||
|
|
@ -1784,12 +1784,12 @@ void BattleGround::PlayerAddedToBGCheckIfBGIsRunning(Player* plr)
|
|||
plr->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
uint32 BattleGround::GetAlivePlayersCountByTeam(uint32 Team) const
|
||||
uint32 BattleGround::GetAlivePlayersCountByTeam(Team team) const
|
||||
{
|
||||
int count = 0;
|
||||
for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
||||
{
|
||||
if (itr->second.Team == Team)
|
||||
if (itr->second.PlayerTeam == team)
|
||||
{
|
||||
Player * pl = sObjectMgr.GetPlayer(itr->first);
|
||||
if (pl && pl->isAlive())
|
||||
|
|
@ -1807,20 +1807,25 @@ void BattleGround::CheckArenaWinConditions()
|
|||
EndBattleGround(ALLIANCE);
|
||||
}
|
||||
|
||||
void BattleGround::SetBgRaid( uint32 TeamID, Group *bg_raid )
|
||||
void BattleGround::SetBgRaid(Team team, Group *bg_raid)
|
||||
{
|
||||
Group* &old_raid = TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE];
|
||||
if(old_raid) old_raid->SetBattlegroundGroup(NULL);
|
||||
if(bg_raid) bg_raid->SetBattlegroundGroup(this);
|
||||
Group* &old_raid = m_BgRaids[GetTeamIndexByTeamId(team)];
|
||||
|
||||
if (old_raid)
|
||||
old_raid->SetBattlegroundGroup(NULL);
|
||||
|
||||
if (bg_raid)
|
||||
bg_raid->SetBattlegroundGroup(this);
|
||||
|
||||
old_raid = bg_raid;
|
||||
}
|
||||
|
||||
WorldSafeLocsEntry const* BattleGround::GetClosestGraveYard( Player* player )
|
||||
{
|
||||
return sObjectMgr.GetClosestGraveYard( player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam() );
|
||||
return sObjectMgr.GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam());
|
||||
}
|
||||
|
||||
bool BattleGround::IsTeamScoreInRange(uint32 team, uint32 minScore, uint32 maxScore) const
|
||||
bool BattleGround::IsTeamScoreInRange(Team team, uint32 minScore, uint32 maxScore) const
|
||||
{
|
||||
BattleGroundTeamIndex team_idx = GetTeamIndexByTeamId(team);
|
||||
uint32 score = (m_TeamScores[team_idx] < 0) ? 0 : uint32(m_TeamScores[team_idx]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue