[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:
VladimirMangos 2010-11-24 23:25:53 +03:00
parent c2331f58bc
commit cc0655a402
38 changed files with 315 additions and 321 deletions

View file

@ -943,7 +943,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
{ {
if (bg->GetTypeID() != BATTLEGROUND_AB) if (bg->GetTypeID() != BATTLEGROUND_AB)
continue; continue;
if(!((BattleGroundAB*)bg)->IsTeamScores500Disadvantage(GetPlayer()->GetTeam())) if (!((BattleGroundAB*)bg)->IsTeamScores500Disadvantage(GetPlayer()->GetTeam()))
continue; continue;
break; break;
} }
@ -1178,7 +1178,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
continue; continue;
// if team check required: must kill by opposition faction // if team check required: must kill by opposition faction
if(achievement->ID==318 && miscvalue2==GetPlayer()->GetTeam()) if(achievement->ID==318 && miscvalue2==uint32(GetPlayer()->GetTeam()))
continue; continue;
change = 1; change = 1;

View file

@ -360,7 +360,7 @@ void BattleGround::Update(uint32 diff)
else if (m_PrematureCountDownTimer < diff) else if (m_PrematureCountDownTimer < diff)
{ {
// time's up! // time's up!
uint32 winner = 0; Team winner = TEAM_NONE;
if (GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam()) if (GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam())
winner = ALLIANCE; winner = ALLIANCE;
else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam()) else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam())
@ -507,9 +507,9 @@ void BattleGround::Update(uint32 diff)
m_StartTime += 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_TeamStartLocX[teamIdx] = X;
m_TeamStartLocY[teamIdx] = Y; m_TeamStartLocY[teamIdx] = Y;
m_TeamStartLocZ[teamIdx] = Z; 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) 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) if (!self && sender == plr)
continue; continue;
uint32 team = itr->second.Team; Team team = itr->second.PlayerTeam;
if(!team) team = plr->GetTeam(); if (!team) team = plr->GetTeam();
if (team == TeamID) if (team == teamId)
plr->GetSession()->SendPacket(packet); plr->GetSession()->SendPacket(packet);
} }
} }
@ -561,7 +561,7 @@ void BattleGround::PlaySoundToAll(uint32 SoundID)
SendPacketToAll(&data); SendPacketToAll(&data);
} }
void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID) void BattleGround::PlaySoundToTeam(uint32 SoundID, Team teamId)
{ {
WorldPacket data; WorldPacket data;
@ -577,10 +577,10 @@ void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID)
continue; continue;
} }
uint32 team = itr->second.Team; Team team = itr->second.PlayerTeam;
if(!team) team = plr->GetTeam(); if(!team) team = plr->GetTeam();
if (team == TeamID) if (team == teamId)
{ {
sBattleGroundMgr.BuildPlaySoundPacket(&data, SoundID); sBattleGroundMgr.BuildPlaySoundPacket(&data, SoundID);
plr->GetSession()->SendPacket(&data); 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) 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; continue;
} }
uint32 team = itr->second.Team; Team team = itr->second.PlayerTeam;
if(!team) team = plr->GetTeam(); if(!team) team = plr->GetTeam();
if (team == TeamID) if (team == teamId)
plr->CastSpell(plr, SpellID, true); 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) 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; continue;
} }
uint32 team = itr->second.Team; Team team = itr->second.PlayerTeam;
if(!team) team = plr->GetTeam(); if(!team) team = plr->GetTeam();
if (team == TeamID) if (team == teamId)
UpdatePlayerScore(plr, SCORE_BONUS_HONOR, Honor); 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); FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id);
@ -651,10 +651,10 @@ void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation,
continue; continue;
} }
uint32 team = itr->second.Team; Team team = itr->second.PlayerTeam;
if(!team) team = plr->GetTeam(); if(!team) team = plr->GetTeam();
if (team == TeamID) if (team == teamId)
plr->GetReputationMgr().ModifyReputation(factionEntry, Reputation); plr->GetReputationMgr().ModifyReputation(factionEntry, Reputation);
} }
} }
@ -673,7 +673,7 @@ void BattleGround::UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player
Source->GetSession()->SendPacket(&data); Source->GetSession()->SendPacket(&data);
} }
void BattleGround::EndBattleGround(uint32 winner) void BattleGround::EndBattleGround(Team winner)
{ {
this->RemoveFromBGFreeSlotQueue(); this->RemoveFromBGFreeSlotQueue();
@ -733,7 +733,7 @@ void BattleGround::EndBattleGround(uint32 winner)
for(BattleGroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) 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) if (itr->second.OfflineRemoveTime)
{ {
@ -995,7 +995,7 @@ void BattleGround::BlockMovement(Player *plr)
void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket) void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket)
{ {
uint32 team = GetPlayerTeam(guid); Team team = GetPlayerTeam(guid);
bool participant = false; bool participant = false;
// Remove from lists/maps // Remove from lists/maps
BattleGroundPlayerMap::iterator itr = m_Players.find(guid); BattleGroundPlayerMap::iterator itr = m_Players.find(guid);
@ -1036,7 +1036,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
{ {
plr->ClearAfkReports(); plr->ClearAfkReports();
if(!team) team = plr->GetTeam(); if (!team) team = plr->GetTeam();
// if arena, remove the specific arena auras // if arena, remove the specific arena auras
if (isArena()) if (isArena())
@ -1109,7 +1109,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
// Do next only if found in battleground // Do next only if found in battleground
plr->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG. plr->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG.
// reset destination bg team // reset destination bg team
plr->SetBGTeam(0); plr->SetBGTeam(TEAM_NONE);
if (Transport) if (Transport)
plr->TeleportToBGEntryPoint(); plr->TeleportToBGEntryPoint();
@ -1176,11 +1176,11 @@ void BattleGround::AddPlayer(Player *plr)
// score struct must be created in inherited class // score struct must be created in inherited class
ObjectGuid guid = plr->GetObjectGuid(); ObjectGuid guid = plr->GetObjectGuid();
uint32 team = plr->GetBGTeam(); Team team = plr->GetBGTeam();
BattleGroundPlayer bp; BattleGroundPlayer bp;
bp.OfflineRemoveTime = 0; bp.OfflineRemoveTime = 0;
bp.Team = team; bp.PlayerTeam = team;
// Add to list/maps // Add to list/maps
m_Players[guid.GetRawValue()] = bp; m_Players[guid.GetRawValue()] = bp;
@ -1197,7 +1197,7 @@ void BattleGround::AddPlayer(Player *plr)
plr->RemoveArenaSpellCooldowns(); plr->RemoveArenaSpellCooldowns();
plr->RemoveArenaAuras(); plr->RemoveArenaAuras();
plr->RemoveAllEnchantments(TEMP_ENCHANTMENT_SLOT); plr->RemoveAllEnchantments(TEMP_ENCHANTMENT_SLOT);
if(team == ALLIANCE) // gold if (team == ALLIANCE) // gold
{ {
if (plr->GetTeam() == HORDE) if (plr->GetTeam() == HORDE)
plr->CastSpell(plr, SPELL_HORDE_GOLD_FLAG,true); 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 */ /* 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 if (Group* group = GetBgRaid(team)) // raid already exist
{ {
@ -1330,11 +1330,11 @@ void BattleGround::RemoveFromBGFreeSlotQueue()
// get the number of free slots for team // get the number of free slots for team
// returns the number how many players can join battleground to MaxPlayersPerTeam // 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 //return free slot count to MaxPlayerPerTeam
if (GetStatus() == STATUS_WAIT_JOIN || GetStatus() == STATUS_IN_PROGRESS) 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; return 0;
} }
@ -1751,12 +1751,12 @@ void BattleGround::HandleKillPlayer( Player *player, Player *killer )
// return the player's team based on battlegroundplayer info // return the player's team based on battlegroundplayer info
// used in same faction arena matches mainly // 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); BattleGroundPlayerMap::const_iterator itr = m_Players.find(guid);
if (itr!=m_Players.end()) if (itr != m_Players.end())
return itr->second.Team; return itr->second.PlayerTeam;
return 0; return TEAM_NONE;
} }
bool BattleGround::IsPlayerInBattleGround(uint64 guid) bool BattleGround::IsPlayerInBattleGround(uint64 guid)
@ -1784,12 +1784,12 @@ void BattleGround::PlayerAddedToBGCheckIfBGIsRunning(Player* plr)
plr->GetSession()->SendPacket(&data); plr->GetSession()->SendPacket(&data);
} }
uint32 BattleGround::GetAlivePlayersCountByTeam(uint32 Team) const uint32 BattleGround::GetAlivePlayersCountByTeam(Team team) const
{ {
int count = 0; int count = 0;
for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) 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); Player * pl = sObjectMgr.GetPlayer(itr->first);
if (pl && pl->isAlive()) if (pl && pl->isAlive())
@ -1807,20 +1807,25 @@ void BattleGround::CheckArenaWinConditions()
EndBattleGround(ALLIANCE); 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]; Group* &old_raid = m_BgRaids[GetTeamIndexByTeamId(team)];
if(old_raid) old_raid->SetBattlegroundGroup(NULL);
if(bg_raid) bg_raid->SetBattlegroundGroup(this); if (old_raid)
old_raid->SetBattlegroundGroup(NULL);
if (bg_raid)
bg_raid->SetBattlegroundGroup(this);
old_raid = bg_raid; old_raid = bg_raid;
} }
WorldSafeLocsEntry const* BattleGround::GetClosestGraveYard( Player* player ) 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); BattleGroundTeamIndex team_idx = GetTeamIndexByTeamId(team);
uint32 score = (m_TeamScores[team_idx] < 0) ? 0 : uint32(m_TeamScores[team_idx]); uint32 score = (m_TeamScores[team_idx] < 0) ? 0 : uint32(m_TeamScores[team_idx]);

View file

@ -143,7 +143,7 @@ enum BattleGroundStatus
struct BattleGroundPlayer struct BattleGroundPlayer
{ {
time_t OfflineRemoveTime; // for tracking and removing offline players from queue after 5 minutes time_t OfflineRemoveTime; // for tracking and removing offline players from queue after 5 minutes
uint32 Team; // Player's team Team PlayerTeam; // Player's team
}; };
struct BattleGroundObjectInfo struct BattleGroundObjectInfo
@ -303,8 +303,8 @@ class BattleGround
virtual void StartingEventOpenDoors() {} virtual void StartingEventOpenDoors() {}
/* achievement req. */ /* achievement req. */
virtual bool IsAllNodesConrolledByTeam(uint32 /*team*/) const { return false; } virtual bool IsAllNodesConrolledByTeam(Team /*team*/) const { return false; }
bool IsTeamScoreInRange(uint32 team, uint32 minScore, uint32 maxScore) const; bool IsTeamScoreInRange(Team team, uint32 minScore, uint32 maxScore) const;
/* Battleground */ /* Battleground */
// Get methods: // Get methods:
@ -359,9 +359,9 @@ class BattleGround
void AddToBGFreeSlotQueue(); //this queue will be useful when more battlegrounds instances will be available void AddToBGFreeSlotQueue(); //this queue will be useful when more battlegrounds instances will be available
void RemoveFromBGFreeSlotQueue(); //this method could delete whole BG instance, if another free is available void RemoveFromBGFreeSlotQueue(); //this method could delete whole BG instance, if another free is available
void DecreaseInvitedCount(uint32 team) { (team == ALLIANCE) ? --m_InvitedAlliance : --m_InvitedHorde; } void DecreaseInvitedCount(Team team) { (team == ALLIANCE) ? --m_InvitedAlliance : --m_InvitedHorde; }
void IncreaseInvitedCount(uint32 team) { (team == ALLIANCE) ? ++m_InvitedAlliance : ++m_InvitedHorde; } void IncreaseInvitedCount(Team team) { (team == ALLIANCE) ? ++m_InvitedAlliance : ++m_InvitedHorde; }
uint32 GetInvitedCount(uint32 team) const uint32 GetInvitedCount(Team team) const
{ {
if (team == ALLIANCE) if (team == ALLIANCE)
return m_InvitedAlliance; return m_InvitedAlliance;
@ -369,7 +369,7 @@ class BattleGround
return m_InvitedHorde; return m_InvitedHorde;
} }
bool HasFreeSlots() const; bool HasFreeSlots() const;
uint32 GetFreeSlotsForTeam(uint32 Team) const; uint32 GetFreeSlotsForTeam(Team team) const;
bool isArena() const { return m_IsArena; } bool isArena() const { return m_IsArena; }
bool isBattleGround() const { return !m_IsArena; } bool isBattleGround() const { return !m_IsArena; }
@ -398,10 +398,10 @@ class BattleGround
return m_Map; return m_Map;
} }
void SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O); void SetTeamStartLoc(Team team, float X, float Y, float Z, float O);
void GetTeamStartLoc(uint32 TeamID, float &X, float &Y, float &Z, float &O) const void GetTeamStartLoc(Team team, float &X, float &Y, float &Z, float &O) const
{ {
BattleGroundTeamIndex idx = GetTeamIndexByTeamId(TeamID); BattleGroundTeamIndex idx = GetTeamIndexByTeamId(team);
X = m_TeamStartLocX[idx]; X = m_TeamStartLocX[idx];
Y = m_TeamStartLocY[idx]; Y = m_TeamStartLocY[idx];
Z = m_TeamStartLocZ[idx]; Z = m_TeamStartLocZ[idx];
@ -411,17 +411,17 @@ class BattleGround
/* Packet Transfer */ /* Packet Transfer */
// method that should fill worldpacket with actual world states (not yet implemented for all battlegrounds!) // method that should fill worldpacket with actual world states (not yet implemented for all battlegrounds!)
virtual void FillInitialWorldStates(WorldPacket& /*data*/, uint32& /*count*/) {} virtual void FillInitialWorldStates(WorldPacket& /*data*/, uint32& /*count*/) {}
void SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *sender = NULL, bool self = true); void SendPacketToTeam(Team team, WorldPacket *packet, Player *sender = NULL, bool self = true);
void SendPacketToAll(WorldPacket *packet); void SendPacketToAll(WorldPacket *packet);
template<class Do> template<class Do>
void BroadcastWorker(Do& _do); void BroadcastWorker(Do& _do);
void PlaySoundToTeam(uint32 SoundID, uint32 TeamID); void PlaySoundToTeam(uint32 SoundID, Team team);
void PlaySoundToAll(uint32 SoundID); void PlaySoundToAll(uint32 SoundID);
void CastSpellOnTeam(uint32 SpellID, uint32 TeamID); void CastSpellOnTeam(uint32 SpellID, Team team);
void RewardHonorToTeam(uint32 Honor, uint32 TeamID); void RewardHonorToTeam(uint32 Honor, Team team);
void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID); void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, Team team);
void RewardMark(Player *plr,uint32 count); void RewardMark(Player *plr,uint32 count);
void SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count); void SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count);
void RewardItem(Player *plr, uint32 item_id, uint32 count); void RewardItem(Player *plr, uint32 item_id, uint32 count);
@ -429,7 +429,7 @@ class BattleGround
void RewardSpellCast(Player *plr, uint32 spell_id); void RewardSpellCast(Player *plr, uint32 spell_id);
void UpdateWorldState(uint32 Field, uint32 Value); void UpdateWorldState(uint32 Field, uint32 Value);
void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source); void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source);
void EndBattleGround(uint32 winner); virtual void EndBattleGround(Team winner);
void BlockMovement(Player *plr); void BlockMovement(Player *plr);
void SendMessageToAll(int32 entry, ChatMsg type, Player const* source = NULL); void SendMessageToAll(int32 entry, ChatMsg type, Player const* source = NULL);
@ -441,27 +441,27 @@ class BattleGround
void SendYell2ToAll(int32 entry, uint32 language, uint64 const& guid, int32 arg1, int32 arg2); void SendYell2ToAll(int32 entry, uint32 language, uint64 const& guid, int32 arg1, int32 arg2);
/* Raid Group */ /* Raid Group */
Group *GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; } Group *GetBgRaid(Team team) const { return m_BgRaids[GetTeamIndexByTeamId(team)]; }
void SetBgRaid(uint32 TeamID, Group *bg_raid); void SetBgRaid(Team team, Group *bg_raid);
virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
static BattleGroundTeamIndex GetTeamIndexByTeamId(uint32 Team) { return Team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE; } static BattleGroundTeamIndex GetTeamIndexByTeamId(Team team) { return team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE; }
uint32 GetPlayersCountByTeam(uint32 Team) const { return m_PlayersCount[GetTeamIndexByTeamId(Team)]; } uint32 GetPlayersCountByTeam(Team team) const { return m_PlayersCount[GetTeamIndexByTeamId(team)]; }
uint32 GetAlivePlayersCountByTeam(uint32 Team) const; // used in arenas to correctly handle death in spirit of redemption / last stand etc. (killer = killed) cases uint32 GetAlivePlayersCountByTeam(Team team) const; // used in arenas to correctly handle death in spirit of redemption / last stand etc. (killer = killed) cases
void UpdatePlayersCountByTeam(uint32 Team, bool remove) void UpdatePlayersCountByTeam(Team team, bool remove)
{ {
if (remove) if (remove)
--m_PlayersCount[GetTeamIndexByTeamId(Team)]; --m_PlayersCount[GetTeamIndexByTeamId(team)];
else else
++m_PlayersCount[GetTeamIndexByTeamId(Team)]; ++m_PlayersCount[GetTeamIndexByTeamId(team)];
} }
// used for rated arena battles // used for rated arena battles
void SetArenaTeamIdForTeam(uint32 Team, uint32 ArenaTeamId) { m_ArenaTeamIds[GetTeamIndexByTeamId(Team)] = ArenaTeamId; } void SetArenaTeamIdForTeam(Team team, uint32 ArenaTeamId) { m_ArenaTeamIds[GetTeamIndexByTeamId(team)] = ArenaTeamId; }
uint32 GetArenaTeamIdForTeam(uint32 Team) const { return m_ArenaTeamIds[GetTeamIndexByTeamId(Team)]; } uint32 GetArenaTeamIdForTeam(Team team) const { return m_ArenaTeamIds[GetTeamIndexByTeamId(team)]; }
void SetArenaTeamRatingChangeForTeam(uint32 Team, int32 RatingChange) { m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)] = RatingChange; } void SetArenaTeamRatingChangeForTeam(Team team, int32 RatingChange) { m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(team)] = RatingChange; }
int32 GetArenaTeamRatingChangeForTeam(uint32 Team) const { return m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)]; } int32 GetArenaTeamRatingChangeForTeam(Team team) const { return m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(team)]; }
void CheckArenaWinConditions(); void CheckArenaWinConditions();
/* Triggers handle */ /* Triggers handle */
@ -483,7 +483,7 @@ class BattleGround
virtual void AddPlayer(Player *plr); // must be implemented in BG subclass virtual void AddPlayer(Player *plr); // must be implemented in BG subclass
void AddOrSetPlayerToCorrectBgGroup(Player *plr, ObjectGuid plr_guid, uint32 team); void AddOrSetPlayerToCorrectBgGroup(Player *plr, ObjectGuid plr_guid, Team team);
virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket); virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket);
// can be extended in in BG subclass // can be extended in in BG subclass
@ -524,8 +524,8 @@ class BattleGround
virtual bool HandlePlayerUnderMap(Player * /*plr*/) { return false; } virtual bool HandlePlayerUnderMap(Player * /*plr*/) { return false; }
// since arenas can be AvA or Hvh, we have to get the "temporary" team of a player // since arenas can be AvA or Hvh, we have to get the "temporary" team of a player
uint32 GetPlayerTeam(uint64 guid); Team GetPlayerTeam(uint64 guid);
static uint32 GetOtherTeam(uint32 teamId){ return (teamId) ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0; } static Team GetOtherTeam(Team team){ return team ? ((team == ALLIANCE) ? HORDE : ALLIANCE) : TEAM_NONE; }
static BattleGroundTeamIndex GetOtherTeamIndex(BattleGroundTeamIndex teamIdx){ return teamIdx == BG_TEAM_ALLIANCE ? BG_TEAM_HORDE : BG_TEAM_ALLIANCE; } static BattleGroundTeamIndex GetOtherTeamIndex(BattleGroundTeamIndex teamIdx){ return teamIdx == BG_TEAM_ALLIANCE ? BG_TEAM_HORDE : BG_TEAM_ALLIANCE; }
bool IsPlayerInBattleGround(uint64 guid); bool IsPlayerInBattleGround(uint64 guid);

View file

@ -484,7 +484,7 @@ void BattleGroundAB::Reset()
} }
void BattleGroundAB::EndBattleGround(uint32 winner) void BattleGroundAB::EndBattleGround(Team winner)
{ {
//win reward //win reward
if (winner == ALLIANCE) if (winner == ALLIANCE)
@ -557,7 +557,7 @@ void BattleGroundAB::UpdatePlayerScore(Player *Source, uint32 type, uint32 value
} }
} }
bool BattleGroundAB::IsAllNodesConrolledByTeam(uint32 team) const bool BattleGroundAB::IsAllNodesConrolledByTeam(Team team) const
{ {
uint32 count = 0; uint32 count = 0;
for (int i = 0; i < BG_AB_NODES_MAX; ++i) for (int i = 0; i < BG_AB_NODES_MAX; ++i)

View file

@ -188,7 +188,7 @@ class BattleGroundAB : public BattleGround
void HandleAreaTrigger(Player *Source, uint32 Trigger); void HandleAreaTrigger(Player *Source, uint32 Trigger);
virtual bool SetupBattleGround(); virtual bool SetupBattleGround();
virtual void Reset(); virtual void Reset();
void EndBattleGround(uint32 winner); void EndBattleGround(Team winner);
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
/* Scorekeeping */ /* Scorekeeping */
@ -200,8 +200,8 @@ class BattleGroundAB : public BattleGround
virtual void EventPlayerClickedOnFlag(Player *source, GameObject* target_obj); virtual void EventPlayerClickedOnFlag(Player *source, GameObject* target_obj);
/* achievement req. */ /* achievement req. */
bool IsAllNodesConrolledByTeam(uint32 team) const; // overwrited bool IsAllNodesConrolledByTeam(Team team) const; // overwrited
bool IsTeamScores500Disadvantage(uint32 team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; } bool IsTeamScores500Disadvantage(Team team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; }
private: private:
/* Gameobject spawning/despawning */ /* Gameobject spawning/despawning */
void _CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay); void _CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay);

View file

@ -290,7 +290,7 @@ void BattleGroundAV::AddPlayer(Player *plr)
m_PlayerScores[plr->GetGUID()] = sc; m_PlayerScores[plr->GetGUID()] = sc;
} }
void BattleGroundAV::EndBattleGround(uint32 winner) void BattleGroundAV::EndBattleGround(Team winner)
{ {
// calculate bonuskills for both teams: // calculate bonuskills for both teams:
uint32 tower_survived[BG_TEAMS_COUNT] = {0, 0}; uint32 tower_survived[BG_TEAMS_COUNT] = {0, 0};
@ -316,7 +316,7 @@ void BattleGroundAV::EndBattleGround(uint32 winner)
++mines_owned[m_Mine_Owner[i]]; ++mines_owned[m_Mine_Owner[i]];
// now we have the values give the honor/reputation to the teams: // now we have the values give the honor/reputation to the teams:
uint32 team[BG_TEAMS_COUNT] = { ALLIANCE, HORDE }; Team team[BG_TEAMS_COUNT] = { ALLIANCE, HORDE };
uint32 faction[BG_TEAMS_COUNT] = { BG_AV_FACTION_A, BG_AV_FACTION_H }; uint32 faction[BG_TEAMS_COUNT] = { BG_AV_FACTION_A, BG_AV_FACTION_H };
for (uint32 i = 0; i < BG_TEAMS_COUNT; i++) for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
{ {
@ -416,11 +416,11 @@ void BattleGroundAV::UpdatePlayerScore(Player* Source, uint32 type, uint32 value
void BattleGroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node) void BattleGroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node)
{ {
MANGOS_ASSERT(m_Nodes[node].Owner != BG_AV_TEAM_NEUTRAL)
DEBUG_LOG("BattleGroundAV: player destroyed point node %i", node); DEBUG_LOG("BattleGroundAV: player destroyed point node %i", node);
BattleGroundTeamIndex owner = BattleGroundTeamIndex(m_Nodes[node].Owner); MANGOS_ASSERT(m_Nodes[node].Owner != BG_AV_TEAM_NEUTRAL)
BattleGroundTeamIndex ownerTeamIdx = BattleGroundTeamIndex(m_Nodes[node].Owner);
Team ownerTeam = ownerTeamIdx == BG_TEAM_ALLIANCE ? ALLIANCE : HORDE;
// despawn banner // despawn banner
DestroyNode(node); DestroyNode(node);
@ -433,14 +433,14 @@ void BattleGroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node)
// despawn marshal (one of those guys protecting the boss) // despawn marshal (one of those guys protecting the boss)
SpawnEvent(BG_AV_MARSHAL_A_SOUTH + tmp, 0, false); SpawnEvent(BG_AV_MARSHAL_A_SOUTH + tmp, 0, false);
UpdateScore(GetOtherTeamIndex(owner), (-1) * BG_AV_RES_TOWER); UpdateScore(GetOtherTeamIndex(ownerTeamIdx), (-1) * BG_AV_RES_TOWER);
RewardReputationToTeam((owner == BG_TEAM_ALLIANCE) ? BG_AV_FACTION_A : BG_AV_FACTION_H, m_RepTowerDestruction, owner); RewardReputationToTeam((ownerTeam == ALLIANCE) ? BG_AV_FACTION_A : BG_AV_FACTION_H, m_RepTowerDestruction, ownerTeam);
RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_TOWER), owner); RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_TOWER), ownerTeam);
SendYell2ToAll(LANG_BG_AV_TOWER_TAKEN, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), ( owner == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY : LANG_BG_HORDE); SendYell2ToAll(LANG_BG_AV_TOWER_TAKEN, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), (ownerTeam == ALLIANCE) ? LANG_BG_ALLY : LANG_BG_HORDE);
} }
else else
{ {
SendYell2ToAll(LANG_BG_AV_GRAVE_TAKEN, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), ( owner == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY : LANG_BG_HORDE); SendYell2ToAll(LANG_BG_AV_GRAVE_TAKEN, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), (ownerTeam == ALLIANCE) ? LANG_BG_ALLY : LANG_BG_HORDE);
} }
} }
@ -472,7 +472,7 @@ void BattleGroundAV::ChangeMineOwner(uint8 mine, BattleGroundAVTeamIndex teamIdx
} }
} }
bool BattleGroundAV::PlayerCanDoMineQuest(int32 GOId, uint32 team) bool BattleGroundAV::PlayerCanDoMineQuest(int32 GOId, Team team)
{ {
if (GOId == BG_AV_OBJECTID_MINE_N) if (GOId == BG_AV_OBJECTID_MINE_N)
return (m_Mine_Owner[BG_AV_NORTH_MINE] == GetTeamIndexByTeamId(team)); return (m_Mine_Owner[BG_AV_NORTH_MINE] == GetTeamIndexByTeamId(team));

View file

@ -339,13 +339,13 @@ class BattleGroundAV : public BattleGround
void HandleKillPlayer(Player* player, Player *killer); void HandleKillPlayer(Player* player, Player *killer);
void HandleKillUnit(Creature *creature, Player *killer); void HandleKillUnit(Creature *creature, Player *killer);
void HandleQuestComplete(uint32 questid, Player *player); void HandleQuestComplete(uint32 questid, Player *player);
bool PlayerCanDoMineQuest(int32 GOId,uint32 team); bool PlayerCanDoMineQuest(int32 GOId, Team team);
void EndBattleGround(uint32 winner); void EndBattleGround(Team winner);
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player *plr); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player *plr);
static BattleGroundAVTeamIndex GetAVTeamIndexByTeamId(uint32 Team) { return BattleGroundAVTeamIndex(GetTeamIndexByTeamId(Team)); } static BattleGroundAVTeamIndex GetAVTeamIndexByTeamId(Team team) { return BattleGroundAVTeamIndex(GetTeamIndexByTeamId(team)); }
private: private:
/* Nodes occupying */ /* Nodes occupying */
void EventPlayerAssaultsPoint(Player* player, BG_AV_Nodes node); void EventPlayerAssaultsPoint(Player* player, BG_AV_Nodes node);

View file

@ -111,17 +111,17 @@ void BattleGroundEY::StartingEventOpenDoors()
} }
} }
void BattleGroundEY::AddPoints(uint32 Team, uint32 Points) void BattleGroundEY::AddPoints(Team team, uint32 Points)
{ {
BattleGroundTeamIndex team_index = GetTeamIndexByTeamId(Team); BattleGroundTeamIndex team_index = GetTeamIndexByTeamId(team);
m_TeamScores[team_index] += Points; m_TeamScores[team_index] += Points;
m_HonorScoreTics[team_index] += Points; m_HonorScoreTics[team_index] += Points;
if (m_HonorScoreTics[team_index] >= m_HonorTics ) if (m_HonorScoreTics[team_index] >= m_HonorTics )
{ {
RewardHonorToTeam(GetBonusHonorFromKill(1), Team); RewardHonorToTeam(GetBonusHonorFromKill(1), team);
m_HonorScoreTics[team_index] -= m_HonorTics; m_HonorScoreTics[team_index] -= m_HonorTics;
} }
UpdateTeamScore(Team); UpdateTeamScore(team);
} }
void BattleGroundEY::CheckSomeoneJoinedPoint() void BattleGroundEY::CheckSomeoneJoinedPoint()
@ -211,14 +211,14 @@ void BattleGroundEY::UpdatePointStatuses()
//point is fully horde's //point is fully horde's
m_PointBarStatus[point] = BG_EY_PROGRESS_BAR_HORDE_CONTROLLED; m_PointBarStatus[point] = BG_EY_PROGRESS_BAR_HORDE_CONTROLLED;
uint32 pointOwnerTeamId = 0; Team pointOwnerTeamId;
//find which team should own this point //find which team should own this point
if (m_PointBarStatus[point] <= BG_EY_PROGRESS_BAR_NEUTRAL_LOW) if (m_PointBarStatus[point] <= BG_EY_PROGRESS_BAR_NEUTRAL_LOW)
pointOwnerTeamId = HORDE; pointOwnerTeamId = HORDE;
else if (m_PointBarStatus[point] >= BG_EY_PROGRESS_BAR_NEUTRAL_HIGH) else if (m_PointBarStatus[point] >= BG_EY_PROGRESS_BAR_NEUTRAL_HIGH)
pointOwnerTeamId = ALLIANCE; pointOwnerTeamId = ALLIANCE;
else else
pointOwnerTeamId = EY_POINT_NO_OWNER; pointOwnerTeamId = TEAM_NONE;
for (uint8 i = 0; i < m_PlayersNearPoint[point].size(); ++i) for (uint8 i = 0; i < m_PlayersNearPoint[point].size(); ++i)
{ {
@ -242,23 +242,23 @@ void BattleGroundEY::UpdatePointStatuses()
} }
} }
void BattleGroundEY::UpdateTeamScore(uint32 Team) void BattleGroundEY::UpdateTeamScore(Team team)
{ {
uint32 score = GetTeamScore(Team); uint32 score = GetTeamScore(team);
if (score >= BG_EY_MAX_TEAM_SCORE) if (score >= BG_EY_MAX_TEAM_SCORE)
{ {
score = BG_EY_MAX_TEAM_SCORE; score = BG_EY_MAX_TEAM_SCORE;
EndBattleGround(Team); EndBattleGround(team);
} }
if (Team == ALLIANCE) if (team == ALLIANCE)
UpdateWorldState(EY_ALLIANCE_RESOURCES, score); UpdateWorldState(EY_ALLIANCE_RESOURCES, score);
else else
UpdateWorldState(EY_HORDE_RESOURCES, score); UpdateWorldState(EY_HORDE_RESOURCES, score);
} }
void BattleGroundEY::EndBattleGround(uint32 winner) void BattleGroundEY::EndBattleGround(Team winner)
{ {
//win reward //win reward
if (winner == ALLIANCE) if (winner == ALLIANCE)
@ -272,28 +272,28 @@ void BattleGroundEY::EndBattleGround(uint32 winner)
BattleGround::EndBattleGround(winner); BattleGround::EndBattleGround(winner);
} }
void BattleGroundEY::UpdatePointsCount(uint32 Team) void BattleGroundEY::UpdatePointsCount(Team team)
{ {
if (Team == ALLIANCE) if (team == ALLIANCE)
UpdateWorldState(EY_ALLIANCE_BASE, m_TeamPointsCount[BG_TEAM_ALLIANCE]); UpdateWorldState(EY_ALLIANCE_BASE, m_TeamPointsCount[BG_TEAM_ALLIANCE]);
else else
UpdateWorldState(EY_HORDE_BASE, m_TeamPointsCount[BG_TEAM_HORDE]); UpdateWorldState(EY_HORDE_BASE, m_TeamPointsCount[BG_TEAM_HORDE]);
} }
void BattleGroundEY::UpdatePointsIcons(uint32 Team, uint32 Point) void BattleGroundEY::UpdatePointsIcons(Team team, uint32 Point)
{ {
//we MUST firstly send 0, after that we can send 1!!! //we MUST firstly send 0, after that we can send 1!!!
if (m_PointState[Point] == EY_POINT_UNDER_CONTROL) if (m_PointState[Point] == EY_POINT_UNDER_CONTROL)
{ {
UpdateWorldState(PointsIconStruct[Point].WorldStateControlIndex, 0); UpdateWorldState(PointsIconStruct[Point].WorldStateControlIndex, 0);
if (Team == ALLIANCE) if (team == ALLIANCE)
UpdateWorldState(PointsIconStruct[Point].WorldStateAllianceControlledIndex, 1); UpdateWorldState(PointsIconStruct[Point].WorldStateAllianceControlledIndex, 1);
else else
UpdateWorldState(PointsIconStruct[Point].WorldStateHordeControlledIndex, 1); UpdateWorldState(PointsIconStruct[Point].WorldStateHordeControlledIndex, 1);
} }
else else
{ {
if (Team == ALLIANCE) if (team == ALLIANCE)
UpdateWorldState(PointsIconStruct[Point].WorldStateAllianceControlledIndex, 0); UpdateWorldState(PointsIconStruct[Point].WorldStateAllianceControlledIndex, 0);
else else
UpdateWorldState(PointsIconStruct[Point].WorldStateHordeControlledIndex, 0); UpdateWorldState(PointsIconStruct[Point].WorldStateHordeControlledIndex, 0);
@ -427,7 +427,7 @@ void BattleGroundEY::Reset()
for(uint8 i = 0; i < BG_EY_NODES_MAX; ++i) for(uint8 i = 0; i < BG_EY_NODES_MAX; ++i)
{ {
m_PointOwnedByTeam[i] = EY_POINT_NO_OWNER; m_PointOwnedByTeam[i] = TEAM_NONE;
m_PointState[i] = EY_POINT_STATE_UNCONTROLLED; m_PointState[i] = EY_POINT_STATE_UNCONTROLLED;
m_PointBarStatus[i] = BG_EY_PROGRESS_BAR_STATE_MIDDLE; m_PointBarStatus[i] = BG_EY_PROGRESS_BAR_STATE_MIDDLE;
m_PlayersNearPoint[i].clear(); m_PlayersNearPoint[i].clear();
@ -554,32 +554,32 @@ void BattleGroundEY::EventTeamLostPoint(Player *Source, uint32 Point)
return; return;
// neutral node // neutral node
uint32 Team = m_PointOwnedByTeam[Point]; Team team = m_PointOwnedByTeam[Point];
if (!Team) if (!team)
return; return;
if (Team == ALLIANCE) if (team == ALLIANCE)
m_TeamPointsCount[BG_TEAM_ALLIANCE]--; --m_TeamPointsCount[BG_TEAM_ALLIANCE];
else else
m_TeamPointsCount[BG_TEAM_HORDE]--; --m_TeamPointsCount[BG_TEAM_HORDE];
// it's important to set the OwnedBy before despawning spiritguides, else // it's important to set the OwnedBy before despawning spiritguides, else
// player won't get teleported away // player won't get teleported away
m_PointOwnedByTeam[Point] = EY_POINT_NO_OWNER; m_PointOwnedByTeam[Point] = TEAM_NONE;
m_PointState[Point] = EY_POINT_NO_OWNER; m_PointState[Point] = EY_POINT_NO_OWNER;
SpawnEvent(Point, BG_EYE_NEUTRAL_TEAM, true); // will despawn alliance/horde SpawnEvent(Point, BG_EYE_NEUTRAL_TEAM, true); // will despawn alliance/horde
//buff isn't despawned //buff isn't despawned
if (Team == ALLIANCE) if (team == ALLIANCE)
SendMessageToAll(LoosingPointTypes[Point].MessageIdAlliance,CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); SendMessageToAll(LoosingPointTypes[Point].MessageIdAlliance,CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
else else
SendMessageToAll(LoosingPointTypes[Point].MessageIdHorde,CHAT_MSG_BG_SYSTEM_HORDE, Source); SendMessageToAll(LoosingPointTypes[Point].MessageIdHorde,CHAT_MSG_BG_SYSTEM_HORDE, Source);
UpdatePointsIcons(Team, Point); UpdatePointsIcons(team, Point);
UpdatePointsCount(Team); UpdatePointsCount(team);
} }
void BattleGroundEY::EventTeamCapturedPoint(Player *Source, uint32 Point) void BattleGroundEY::EventTeamCapturedPoint(Player *Source, uint32 Point)
@ -587,23 +587,23 @@ void BattleGroundEY::EventTeamCapturedPoint(Player *Source, uint32 Point)
if (GetStatus() != STATUS_IN_PROGRESS) if (GetStatus() != STATUS_IN_PROGRESS)
return; return;
uint32 Team = Source->GetTeam(); Team team = Source->GetTeam();
m_TeamPointsCount[GetTeamIndexByTeamId(Team)]++; ++m_TeamPointsCount[GetTeamIndexByTeamId(team)];
SpawnEvent(Point, GetTeamIndexByTeamId(Team), true); SpawnEvent(Point, GetTeamIndexByTeamId(team), true);
//buff isn't respawned //buff isn't respawned
m_PointOwnedByTeam[Point] = Team; m_PointOwnedByTeam[Point] = team;
m_PointState[Point] = EY_POINT_UNDER_CONTROL; m_PointState[Point] = EY_POINT_UNDER_CONTROL;
if (Team == ALLIANCE) if (team == ALLIANCE)
SendMessageToAll(CapturingPointTypes[Point].MessageIdAlliance,CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); SendMessageToAll(CapturingPointTypes[Point].MessageIdAlliance,CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
else else
SendMessageToAll(CapturingPointTypes[Point].MessageIdHorde,CHAT_MSG_BG_SYSTEM_HORDE, Source); SendMessageToAll(CapturingPointTypes[Point].MessageIdHorde,CHAT_MSG_BG_SYSTEM_HORDE, Source);
UpdatePointsIcons(Team, Point); UpdatePointsIcons(team, Point);
UpdatePointsCount(Team); UpdatePointsCount(team);
} }
void BattleGroundEY::EventPlayerCapturedFlag(Player *Source, BG_EY_Nodes node) void BattleGroundEY::EventPlayerCapturedFlag(Player *Source, BG_EY_Nodes node)
@ -626,7 +626,7 @@ void BattleGroundEY::EventPlayerCapturedFlag(Player *Source, BG_EY_Nodes node)
m_FlagsTimer = BG_EY_FLAG_RESPAWN_TIME; m_FlagsTimer = BG_EY_FLAG_RESPAWN_TIME;
uint8 team_id = 0; BattleGroundTeamIndex team_id;
if (Source->GetTeam() == ALLIANCE) if (Source->GetTeam() == ALLIANCE)
{ {
team_id = BG_TEAM_ALLIANCE; team_id = BG_TEAM_ALLIANCE;
@ -752,7 +752,7 @@ WorldSafeLocsEntry const *BattleGroundEY::GetClosestGraveYard(Player* player)
return nearestEntry; return nearestEntry;
} }
bool BattleGroundEY::IsAllNodesConrolledByTeam(uint32 team) const bool BattleGroundEY::IsAllNodesConrolledByTeam(Team team) const
{ {
for(int i = 0; i < BG_EY_NODES_MAX; ++i) for(int i = 0; i < BG_EY_NODES_MAX; ++i)
if (m_PointState[i] != EY_POINT_UNDER_CONTROL || m_PointOwnedByTeam[i] != team) if (m_PointState[i] != EY_POINT_UNDER_CONTROL || m_PointOwnedByTeam[i] != team)

View file

@ -268,8 +268,8 @@ class BattleGroundEY : public BattleGround
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
virtual bool SetupBattleGround(); virtual bool SetupBattleGround();
virtual void Reset(); virtual void Reset();
void UpdateTeamScore(uint32 Team); void UpdateTeamScore(Team team);
void EndBattleGround(uint32 winner); void EndBattleGround(Team winner);
void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
virtual void FillInitialWorldStates(WorldPacket& data, uint32& count); virtual void FillInitialWorldStates(WorldPacket& data, uint32& count);
void SetDroppedFlagGUID(uint64 guid) { m_DroppedFlagGUID = guid;} void SetDroppedFlagGUID(uint64 guid) { m_DroppedFlagGUID = guid;}
@ -280,14 +280,14 @@ class BattleGroundEY : public BattleGround
virtual void EventPlayerDroppedFlag(Player *Source); virtual void EventPlayerDroppedFlag(Player *Source);
/* achievement req. */ /* achievement req. */
bool IsAllNodesConrolledByTeam(uint32 team) const; bool IsAllNodesConrolledByTeam(Team team) const;
private: private:
void EventPlayerCapturedFlag(Player *Source, BG_EY_Nodes node); void EventPlayerCapturedFlag(Player *Source, BG_EY_Nodes node);
void EventTeamCapturedPoint(Player *Source, uint32 Point); void EventTeamCapturedPoint(Player *Source, uint32 Point);
void EventTeamLostPoint(Player *Source, uint32 Point); void EventTeamLostPoint(Player *Source, uint32 Point);
void UpdatePointsCount(uint32 Team); void UpdatePointsCount(Team team);
void UpdatePointsIcons(uint32 Team, uint32 Point); void UpdatePointsIcons(Team team, uint32 Point);
/* Point status updating procedures */ /* Point status updating procedures */
void CheckSomeoneLeftPoint(); void CheckSomeoneLeftPoint();
@ -295,14 +295,14 @@ class BattleGroundEY : public BattleGround
void UpdatePointStatuses(); void UpdatePointStatuses();
/* Scorekeeping */ /* Scorekeeping */
uint32 GetTeamScore(uint32 Team) const { return m_TeamScores[GetTeamIndexByTeamId(Team)]; } uint32 GetTeamScore(Team team) const { return m_TeamScores[GetTeamIndexByTeamId(team)]; }
void AddPoints(uint32 Team, uint32 Points); void AddPoints(Team team, uint32 Points);
void RemovePoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] -= Points; } void RemovePoint(Team team, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(team)] -= Points; }
void SetTeamPoint(uint32 TeamID, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] = Points; } void SetTeamPoint(Team team, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(team)] = Points; }
uint32 m_HonorScoreTics[2]; uint32 m_HonorScoreTics[2];
uint32 m_TeamPointsCount[2]; uint32 m_TeamPointsCount[BG_TEAMS_COUNT];
uint32 m_Points_Trigger[BG_EY_NODES_MAX]; uint32 m_Points_Trigger[BG_EY_NODES_MAX];
@ -312,7 +312,7 @@ class BattleGroundEY : public BattleGround
int32 m_FlagsTimer; int32 m_FlagsTimer;
int32 m_TowerCapCheckTimer; int32 m_TowerCapCheckTimer;
uint32 m_PointOwnedByTeam[BG_EY_NODES_MAX]; Team m_PointOwnedByTeam[BG_EY_NODES_MAX];
uint8 m_PointState[BG_EY_NODES_MAX]; uint8 m_PointState[BG_EY_NODES_MAX];
int32 m_PointBarStatus[BG_EY_NODES_MAX]; int32 m_PointBarStatus[BG_EY_NODES_MAX];
typedef std::vector<uint64> PlayersNearPointType; typedef std::vector<uint64> PlayersNearPointType;

View file

@ -435,7 +435,7 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
// set the destination instance id // set the destination instance id
_player->SetBattleGroundId(bg->GetInstanceID(), bgTypeId); _player->SetBattleGroundId(bg->GetInstanceID(), bgTypeId);
// set the destination team // set the destination team
_player->SetBGTeam(ginfo.Team); _player->SetBGTeam(ginfo.GroupTeam);
// bg->HandleBeforeTeleportToBattleGround(_player); // bg->HandleBeforeTeleportToBattleGround(_player);
sBattleGroundMgr.SendToBattleGround(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId); sBattleGroundMgr.SendToBattleGround(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
// add only in HandleMoveWorldPortAck() // add only in HandleMoveWorldPortAck()
@ -446,7 +446,7 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
// if player leaves rated arena match before match start, it is counted as he played but he lost // if player leaves rated arena match before match start, it is counted as he played but he lost
if (ginfo.IsRated) if (ginfo.IsRated)
{ {
ArenaTeam * at = sObjectMgr.GetArenaTeamById(ginfo.Team); ArenaTeam * at = sObjectMgr.GetArenaTeamById(ginfo.ArenaTeamId);
if (at) if (at)
{ {
DEBUG_LOG("UPDATING memberLost's personal arena rating for %u by opponents rating: %u, because he has left queue!", GUID_LOPART(_player->GetGUID()), ginfo.OpponentsTeamRating); DEBUG_LOG("UPDATING memberLost's personal arena rating for %u by opponents rating: %u, because he has left queue!", GUID_LOPART(_player->GetGUID()), ginfo.OpponentsTeamRating);
@ -605,7 +605,6 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
uint8 arenaslot; // 2v2, 3v3 or 5v5 uint8 arenaslot; // 2v2, 3v3 or 5v5
uint8 asGroup; // asGroup uint8 asGroup; // asGroup
uint8 isRated; // isRated uint8 isRated; // isRated
Group * grp;
recv_data >> guid >> arenaslot >> asGroup >> isRated; recv_data >> guid >> arenaslot >> asGroup >> isRated;
@ -655,9 +654,15 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
GroupJoinBattlegroundResult err; GroupJoinBattlegroundResult err;
Group * grp = NULL;
// check queue conditions // check queue conditions
if (!asGroup) if (!asGroup)
{ {
// you can't join in this way by client
if (isRated)
return;
// check if already in queue // check if already in queue
if (_player->GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES) if (_player->GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
//player is already in this queue //player is already in this queue

View file

@ -160,7 +160,7 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleG
ginfo->IsInvitedToBGInstanceGUID = 0; ginfo->IsInvitedToBGInstanceGUID = 0;
ginfo->JoinTime = getMSTime(); ginfo->JoinTime = getMSTime();
ginfo->RemoveInviteTime = 0; ginfo->RemoveInviteTime = 0;
ginfo->Team = leader->GetTeam(); ginfo->GroupTeam = leader->GetTeam();
ginfo->ArenaTeamRating = arenaRating; ginfo->ArenaTeamRating = arenaRating;
ginfo->OpponentsTeamRating = 0; ginfo->OpponentsTeamRating = 0;
@ -171,7 +171,7 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleG
if (!isRated && !isPremade) if (!isRated && !isPremade)
index += BG_TEAMS_COUNT; // BG_QUEUE_PREMADE_* -> BG_QUEUE_NORMAL_* index += BG_TEAMS_COUNT; // BG_QUEUE_PREMADE_* -> BG_QUEUE_NORMAL_*
if (ginfo->Team == HORDE) if (ginfo->GroupTeam == HORDE)
index++; // BG_QUEUE_*_ALLIANCE -> BG_QUEUE_*_HORDE index++; // BG_QUEUE_*_ALLIANCE -> BG_QUEUE_*_HORDE
DEBUG_LOG("Adding Group to BattleGroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracketId, index); DEBUG_LOG("Adding Group to BattleGroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracketId, index);
@ -257,7 +257,7 @@ void BattleGroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* g
uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas! uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas!
if (!ginfo->ArenaType) if (!ginfo->ArenaType)
{ {
if (ginfo->Team == HORDE) if (ginfo->GroupTeam == HORDE)
team_index = BG_TEAM_HORDE; team_index = BG_TEAM_HORDE;
} }
else else
@ -284,7 +284,7 @@ uint32 BattleGroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattleG
uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas! uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas!
if (!ginfo->ArenaType) if (!ginfo->ArenaType)
{ {
if (ginfo->Team == HORDE) if (ginfo->GroupTeam == HORDE)
team_index = BG_TEAM_HORDE; team_index = BG_TEAM_HORDE;
} }
else else
@ -322,7 +322,7 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
// mostly people with the highest levels are in battlegrounds, thats why // mostly people with the highest levels are in battlegrounds, thats why
// we count from MAX_BATTLEGROUND_QUEUES - 1 to 0 // we count from MAX_BATTLEGROUND_QUEUES - 1 to 0
// variable index removes useless searching in other team's queue // variable index removes useless searching in other team's queue
uint32 index = (group->Team == HORDE) ? BG_TEAM_HORDE : BG_TEAM_ALLIANCE; uint32 index = BattleGround::GetTeamIndexByTeamId(group->GroupTeam);
for (int32 bracket_id_tmp = MAX_BATTLEGROUND_BRACKETS - 1; bracket_id_tmp >= 0 && bracket_id == -1; --bracket_id_tmp) for (int32 bracket_id_tmp = MAX_BATTLEGROUND_BRACKETS - 1; bracket_id_tmp >= 0 && bracket_id == -1; --bracket_id_tmp)
{ {
@ -366,7 +366,7 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
{ {
BattleGround* bg = sBattleGroundMgr.GetBattleGround(group->IsInvitedToBGInstanceGUID, group->BgTypeId); BattleGround* bg = sBattleGroundMgr.GetBattleGround(group->IsInvitedToBGInstanceGUID, group->BgTypeId);
if (bg) if (bg)
bg->DecreaseInvitedCount(group->Team); bg->DecreaseInvitedCount(group->GroupTeam);
} }
// remove player queue info // remove player queue info
@ -441,11 +441,11 @@ bool BattleGroundQueue::GetPlayerGroupInfoData(const uint64& guid, GroupQueueInf
return true; return true;
} }
bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * bg, uint32 side) bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * bg, Team side)
{ {
// set side if needed // set side if needed
if (side) if (side)
ginfo->Team = side; ginfo->GroupTeam = side;
if (!ginfo->IsInvitedToBGInstanceGUID) if (!ginfo->IsInvitedToBGInstanceGUID)
{ {
@ -458,7 +458,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b
// set ArenaTeamId for rated matches // set ArenaTeamId for rated matches
if (bg->isArena() && bg->isRated()) if (bg->isArena() && bg->isRated())
bg->SetArenaTeamIdForTeam(ginfo->Team, ginfo->ArenaTeamId); bg->SetArenaTeamIdForTeam(ginfo->GroupTeam, ginfo->ArenaTeamId);
ginfo->RemoveInviteTime = getMSTime() + INVITE_ACCEPT_WAIT_TIME; ginfo->RemoveInviteTime = getMSTime() + INVITE_ACCEPT_WAIT_TIME;
@ -476,7 +476,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b
//sBattleGroundMgr.InvitePlayer(plr, bg, ginfo->Team); //sBattleGroundMgr.InvitePlayer(plr, bg, ginfo->Team);
// set invited player counters // set invited player counters
bg->IncreaseInvitedCount(ginfo->Team); bg->IncreaseInvitedCount(ginfo->GroupTeam);
plr->SetInviteForBattleGroundQueueType(bgQueueTypeId, ginfo->IsInvitedToBGInstanceGUID); plr->SetInviteForBattleGroundQueueType(bgQueueTypeId, ginfo->IsInvitedToBGInstanceGUID);
@ -691,53 +691,53 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BattleGroundBracketId bracke
{ {
if (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() < minPlayersPerTeam && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() < minPlayersPerTeam) if (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() < minPlayersPerTeam && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() < minPlayersPerTeam)
return false; return false;
uint32 teamIndex = BG_TEAM_ALLIANCE; BattleGroundTeamIndex teamIdx = BG_TEAM_ALLIANCE;
uint32 otherTeam = BG_TEAM_HORDE; BattleGroundTeamIndex otherTeamIdx = BG_TEAM_HORDE;
uint32 otherTeamId = HORDE; Team otherTeamId = HORDE;
if (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() == minPlayersPerTeam ) if (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() == minPlayersPerTeam )
{ {
teamIndex = BG_TEAM_HORDE; teamIdx = BG_TEAM_HORDE;
otherTeam = BG_TEAM_ALLIANCE; otherTeamIdx = BG_TEAM_ALLIANCE;
otherTeamId = ALLIANCE; otherTeamId = ALLIANCE;
} }
//clear other team's selection //clear other team's selection
m_SelectionPools[otherTeam].Init(); m_SelectionPools[otherTeamIdx].Init();
//store last ginfo pointer //store last ginfo pointer
GroupQueueInfo* ginfo = m_SelectionPools[teamIndex].SelectedGroups.back(); GroupQueueInfo* ginfo = m_SelectionPools[teamIdx].SelectedGroups.back();
//set itr_team to group that was added to selection pool latest //set itr_team to group that was added to selection pool latest
GroupsQueueType::iterator itr_team = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].begin(); GroupsQueueType::iterator itr_team = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].begin();
for(; itr_team != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end(); ++itr_team) for(; itr_team != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].end(); ++itr_team)
if (ginfo == *itr_team) if (ginfo == *itr_team)
break; break;
if (itr_team == m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end()) if (itr_team == m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].end())
return false; return false;
GroupsQueueType::iterator itr_team2 = itr_team; GroupsQueueType::iterator itr_team2 = itr_team;
++itr_team2; ++itr_team2;
//invite players to other selection pool //invite players to other selection pool
for(; itr_team2 != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end(); ++itr_team2) for(; itr_team2 != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].end(); ++itr_team2)
{ {
//if selection pool is full then break; //if selection pool is full then break;
if (!(*itr_team2)->IsInvitedToBGInstanceGUID && !m_SelectionPools[otherTeam].AddGroup(*itr_team2, minPlayersPerTeam)) if (!(*itr_team2)->IsInvitedToBGInstanceGUID && !m_SelectionPools[otherTeamIdx].AddGroup(*itr_team2, minPlayersPerTeam))
break; break;
} }
if (m_SelectionPools[otherTeam].GetPlayerCount() != minPlayersPerTeam) if (m_SelectionPools[otherTeamIdx].GetPlayerCount() != minPlayersPerTeam)
return false; return false;
//here we have correct 2 selections and we need to change one teams team and move selection pool teams to other team's queue //here we have correct 2 selections and we need to change one teams team and move selection pool teams to other team's queue
for(GroupsQueueType::iterator itr = m_SelectionPools[otherTeam].SelectedGroups.begin(); itr != m_SelectionPools[otherTeam].SelectedGroups.end(); ++itr) for(GroupsQueueType::iterator itr = m_SelectionPools[otherTeamIdx].SelectedGroups.begin(); itr != m_SelectionPools[otherTeamIdx].SelectedGroups.end(); ++itr)
{ {
//set correct team //set correct team
(*itr)->Team = otherTeamId; (*itr)->GroupTeam = otherTeamId;
//add team to other queue //add team to other queue
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + otherTeam].push_front(*itr); m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + otherTeamIdx].push_front(*itr);
//remove team from old queue //remove team from old queue
GroupsQueueType::iterator itr2 = itr_team; GroupsQueueType::iterator itr2 = itr_team;
++itr2; ++itr2;
for(; itr2 != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end(); ++itr2) for(; itr2 != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].end(); ++itr2)
{ {
if (*itr2 == *itr) if (*itr2 == *itr)
{ {
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].erase(itr2); m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].erase(itr2);
break; break;
} }
} }
@ -783,9 +783,9 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
// now everything is set, invite players // now everything is set, invite players
for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.end(); ++citr) for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.end(); ++citr)
InviteGroupToBG((*citr), bg, (*citr)->Team); InviteGroupToBG((*citr), bg, (*citr)->GroupTeam);
for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.end(); ++citr) for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.end(); ++citr)
InviteGroupToBG((*citr), bg, (*citr)->Team); InviteGroupToBG((*citr), bg, (*citr)->GroupTeam);
if (!bg->HasFreeSlots()) if (!bg->HasFreeSlots())
{ {
@ -864,7 +864,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
//invite those selection pools //invite those selection pools
for(uint32 i = 0; i < BG_TEAMS_COUNT; i++) for(uint32 i = 0; i < BG_TEAMS_COUNT; i++)
for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr) for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr)
InviteGroupToBG((*citr), bg2, (*citr)->Team); InviteGroupToBG((*citr), bg2, (*citr)->GroupTeam);
//start bg //start bg
bg2->StartBattleGround(); bg2->StartBattleGround();
//clear structures //clear structures
@ -891,7 +891,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
// invite those selection pools // invite those selection pools
for(uint32 i = 0; i < BG_TEAMS_COUNT; i++) for(uint32 i = 0; i < BG_TEAMS_COUNT; i++)
for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr) for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr)
InviteGroupToBG((*citr), bg2, (*citr)->Team); InviteGroupToBG((*citr), bg2, (*citr)->GroupTeam);
// start bg // start bg
bg2->StartBattleGround(); bg2->StartBattleGround();
} }
@ -1007,7 +1007,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
(*(itr_team[BG_TEAM_HORDE]))->OpponentsTeamRating = (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaTeamRating; (*(itr_team[BG_TEAM_HORDE]))->OpponentsTeamRating = (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaTeamRating;
DEBUG_LOG("setting oposite teamrating for team %u to %u", (*(itr_team[BG_TEAM_HORDE]))->ArenaTeamId, (*(itr_team[BG_TEAM_HORDE]))->OpponentsTeamRating); DEBUG_LOG("setting oposite teamrating for team %u to %u", (*(itr_team[BG_TEAM_HORDE]))->ArenaTeamId, (*(itr_team[BG_TEAM_HORDE]))->OpponentsTeamRating);
// now we must move team if we changed its faction to another faction queue, because then we will spam log by errors in Queue::RemovePlayer // now we must move team if we changed its faction to another faction queue, because then we will spam log by errors in Queue::RemovePlayer
if ((*(itr_team[BG_TEAM_ALLIANCE]))->Team != ALLIANCE) if ((*(itr_team[BG_TEAM_ALLIANCE]))->GroupTeam != ALLIANCE)
{ {
// add to alliance queue // add to alliance queue
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].push_front(*(itr_team[BG_TEAM_ALLIANCE])); m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].push_front(*(itr_team[BG_TEAM_ALLIANCE]));
@ -1015,7 +1015,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].erase(itr_team[BG_TEAM_ALLIANCE]); m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].erase(itr_team[BG_TEAM_ALLIANCE]);
itr_team[BG_TEAM_ALLIANCE] = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].begin(); itr_team[BG_TEAM_ALLIANCE] = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].begin();
} }
if ((*(itr_team[BG_TEAM_HORDE]))->Team != HORDE) if ((*(itr_team[BG_TEAM_HORDE]))->GroupTeam != HORDE)
{ {
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].push_front(*(itr_team[BG_TEAM_HORDE])); m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].push_front(*(itr_team[BG_TEAM_HORDE]));
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_team[BG_TEAM_HORDE]); m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_team[BG_TEAM_HORDE]);
@ -1314,7 +1314,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg)
else else
{ {
Player *plr = sObjectMgr.GetPlayer(itr->first); Player *plr = sObjectMgr.GetPlayer(itr->first);
uint32 team = bg->GetPlayerTeam(itr->first); Team team = bg->GetPlayerTeam(itr->first);
if (!team && plr) if (!team && plr)
team = plr->GetTeam(); team = plr->GetTeam();
if (( bg->GetWinner()==0 && team == ALLIANCE ) || ( bg->GetWinner()==1 && team==HORDE )) if (( bg->GetWinner()==0 && team == ALLIANCE ) || ( bg->GetWinner()==1 && team==HORDE ))
@ -1845,7 +1845,7 @@ void BattleGroundMgr::SendToBattleGround(Player *pl, uint32 instanceId, BattleGr
{ {
uint32 mapid = bg->GetMapId(); uint32 mapid = bg->GetMapId();
float x, y, z, O; float x, y, z, O;
uint32 team = pl->GetBGTeam(); Team team = pl->GetBGTeam();
if (team==0) if (team==0)
team = pl->GetTeam(); team = pl->GetTeam();
bg->GetTeamStartLoc(team, x, y, z, O); bg->GetTeamStartLoc(team, x, y, z, O);

View file

@ -48,7 +48,7 @@ struct PlayerQueueInfo // stores informatio
struct GroupQueueInfo // stores information about the group in queue (also used when joined as solo!) struct GroupQueueInfo // stores information about the group in queue (also used when joined as solo!)
{ {
std::map<uint64, PlayerQueueInfo*> Players; // player queue info map std::map<uint64, PlayerQueueInfo*> Players; // player queue info map
uint32 Team; // Player team (ALLIANCE/HORDE) Team GroupTeam; // Player team (ALLIANCE/HORDE)
BattleGroundTypeId BgTypeId; // battleground type id BattleGroundTypeId BgTypeId; // battleground type id
bool IsRated; // rated bool IsRated; // rated
uint8 ArenaType; // 2v2, 3v3, 5v5 or 0 when BG uint8 ArenaType; // 2v2, 3v3, 5v5 or 0 when BG
@ -128,7 +128,7 @@ class BattleGroundQueue
//one selection pool for horde, other one for alliance //one selection pool for horde, other one for alliance
SelectionPool m_SelectionPools[BG_TEAMS_COUNT]; SelectionPool m_SelectionPools[BG_TEAMS_COUNT];
bool InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * bg, uint32 side); bool InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * bg, Team side);
uint32 m_WaitTimes[BG_TEAMS_COUNT][MAX_BATTLEGROUND_BRACKETS][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME]; uint32 m_WaitTimes[BG_TEAMS_COUNT][MAX_BATTLEGROUND_BRACKETS][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME];
uint32 m_WaitTimeLastPlayer[BG_TEAMS_COUNT][MAX_BATTLEGROUND_BRACKETS]; uint32 m_WaitTimeLastPlayer[BG_TEAMS_COUNT][MAX_BATTLEGROUND_BRACKETS];
uint32 m_SumOfWaitTimes[BG_TEAMS_COUNT][MAX_BATTLEGROUND_BRACKETS]; uint32 m_SumOfWaitTimes[BG_TEAMS_COUNT][MAX_BATTLEGROUND_BRACKETS];

View file

@ -138,9 +138,9 @@ void BattleGroundWS::AddPlayer(Player *plr)
m_PlayerScores[plr->GetGUID()] = sc; m_PlayerScores[plr->GetGUID()] = sc;
} }
void BattleGroundWS::RespawnFlag(uint32 Team, bool captured) void BattleGroundWS::RespawnFlag(Team team, bool captured)
{ {
if (Team == ALLIANCE) if (team == ALLIANCE)
{ {
DEBUG_LOG("Respawn Alliance flag"); DEBUG_LOG("Respawn Alliance flag");
m_FlagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_BASE; m_FlagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_BASE;
@ -163,7 +163,7 @@ void BattleGroundWS::RespawnFlag(uint32 Team, bool captured)
} }
} }
void BattleGroundWS::RespawnFlagAfterDrop(uint32 team) void BattleGroundWS::RespawnFlagAfterDrop(Team team)
{ {
if (GetStatus() != STATUS_IN_PROGRESS) if (GetStatus() != STATUS_IN_PROGRESS)
return; return;
@ -192,7 +192,7 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
m_LastCapturedFlagTeam = Source->GetTeam(); m_LastCapturedFlagTeam = Source->GetTeam();
uint32 winner = 0; Team winner = TEAM_NONE;
Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
if (Source->GetTeam() == ALLIANCE) if (Source->GetTeam() == ALLIANCE)
@ -257,7 +257,7 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
} }
else else
{ {
m_FlagsTimer[GetTeamIndexByTeamId(Source->GetTeam()) ? 0 : 1] = BG_WS_FLAG_RESPAWN_TIME; m_FlagsTimer[GetOtherTeamIndex(GetTeamIndexByTeamId(Source->GetTeam()))] = BG_WS_FLAG_RESPAWN_TIME;
} }
} }
@ -335,7 +335,7 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player *Source)
UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, uint32(-1)); UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, uint32(-1));
} }
m_FlagsDropTimer[GetTeamIndexByTeamId(Source->GetTeam()) ? 0 : 1] = BG_WS_FLAG_DROP_TIME; m_FlagsDropTimer[GetOtherTeamIndex(GetTeamIndexByTeamId(Source->GetTeam()))] = BG_WS_FLAG_DROP_TIME;
} }
} }
@ -471,7 +471,7 @@ void BattleGroundWS::RemovePlayer(Player *plr, uint64 guid)
} }
} }
void BattleGroundWS::UpdateFlagState(uint32 team, uint32 value) void BattleGroundWS::UpdateFlagState(Team team, uint32 value)
{ {
if (team == ALLIANCE) if (team == ALLIANCE)
UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE, value); UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE, value);
@ -479,7 +479,7 @@ void BattleGroundWS::UpdateFlagState(uint32 team, uint32 value)
UpdateWorldState(BG_WS_FLAG_STATE_HORDE, value); UpdateWorldState(BG_WS_FLAG_STATE_HORDE, value);
} }
void BattleGroundWS::UpdateTeamScore(uint32 team) void BattleGroundWS::UpdateTeamScore(Team team)
{ {
if (team == ALLIANCE) if (team == ALLIANCE)
UpdateWorldState(BG_WS_FLAG_CAPTURES_ALLIANCE, GetTeamScore(team)); UpdateWorldState(BG_WS_FLAG_CAPTURES_ALLIANCE, GetTeamScore(team));
@ -554,10 +554,10 @@ void BattleGroundWS::Reset()
m_HonorEndKills = (isBGWeekend) ? 4 : 2; m_HonorEndKills = (isBGWeekend) ? 4 : 2;
m_EndTimer = BG_WS_TIME_LIMIT; m_EndTimer = BG_WS_TIME_LIMIT;
m_LastCapturedFlagTeam = 0; m_LastCapturedFlagTeam = TEAM_NONE;
} }
void BattleGroundWS::EndBattleGround(uint32 winner) void BattleGroundWS::EndBattleGround(Team winner)
{ {
//win reward //win reward
if (winner == ALLIANCE) if (winner == ALLIANCE)

View file

@ -115,9 +115,9 @@ class BattleGroundWS : public BattleGround
void SetHordeFlagPicker(uint64 guid) { m_FlagKeepers[BG_TEAM_HORDE] = guid; } void SetHordeFlagPicker(uint64 guid) { m_FlagKeepers[BG_TEAM_HORDE] = guid; }
bool IsAllianceFlagPickedup() const { return m_FlagKeepers[BG_TEAM_ALLIANCE] != 0; } bool IsAllianceFlagPickedup() const { return m_FlagKeepers[BG_TEAM_ALLIANCE] != 0; }
bool IsHordeFlagPickedup() const { return m_FlagKeepers[BG_TEAM_HORDE] != 0; } bool IsHordeFlagPickedup() const { return m_FlagKeepers[BG_TEAM_HORDE] != 0; }
void RespawnFlag(uint32 Team, bool captured); void RespawnFlag(Team team, bool captured);
void RespawnFlagAfterDrop(uint32 Team); void RespawnFlagAfterDrop(Team team);
uint8 GetFlagState(uint32 team) { return m_FlagState[GetTeamIndexByTeamId(team)]; } uint8 GetFlagState(Team team) { return m_FlagState[GetTeamIndexByTeamId(team)]; }
/* Battleground Events */ /* Battleground Events */
virtual void EventPlayerDroppedFlag(Player *Source); virtual void EventPlayerDroppedFlag(Player *Source);
@ -129,22 +129,22 @@ class BattleGroundWS : public BattleGround
void HandleKillPlayer(Player *player, Player *killer); void HandleKillPlayer(Player *player, Player *killer);
bool SetupBattleGround(); bool SetupBattleGround();
virtual void Reset(); virtual void Reset();
void EndBattleGround(uint32 winner); void EndBattleGround(Team winner);
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
uint32 GetRemainingTimeInMinutes() { return m_EndTimer ? (m_EndTimer-1) / (MINUTE * IN_MILLISECONDS) + 1 : 0; } uint32 GetRemainingTimeInMinutes() { return m_EndTimer ? (m_EndTimer-1) / (MINUTE * IN_MILLISECONDS) + 1 : 0; }
void UpdateFlagState(uint32 team, uint32 value); void UpdateFlagState(Team team, uint32 value);
void UpdateTeamScore(uint32 team); void UpdateTeamScore(Team team);
void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
void SetDroppedFlagGUID(uint64 guid, uint32 TeamID) { m_DroppedFlagGUID[GetTeamIndexByTeamId(TeamID)] = guid;} void SetDroppedFlagGUID(uint64 guid, Team team) { m_DroppedFlagGUID[GetTeamIndexByTeamId(team)] = guid;}
uint64 GetDroppedFlagGUID(uint32 TeamID) { return m_DroppedFlagGUID[GetTeamIndexByTeamId(TeamID)];} uint64 GetDroppedFlagGUID(Team team) { return m_DroppedFlagGUID[GetTeamIndexByTeamId(team)];}
virtual void FillInitialWorldStates(WorldPacket& data, uint32& count); virtual void FillInitialWorldStates(WorldPacket& data, uint32& count);
/* Scorekeeping */ /* Scorekeeping */
uint32 GetTeamScore(uint32 TeamID) const { return m_TeamScores[GetTeamIndexByTeamId(TeamID)]; } uint32 GetTeamScore(Team team) const { return m_TeamScores[GetTeamIndexByTeamId(team)]; }
void AddPoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] += Points; } void AddPoint(Team team, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(team)] += Points; }
void SetTeamPoint(uint32 TeamID, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] = Points; } void SetTeamPoint(Team team, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(team)] = Points; }
void RemovePoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] -= Points; } void RemovePoint(Team team, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(team)] -= Points; }
private: private:
uint64 m_FlagKeepers[BG_TEAMS_COUNT]; uint64 m_FlagKeepers[BG_TEAMS_COUNT];
@ -157,6 +157,6 @@ class BattleGroundWS : public BattleGround
uint32 m_HonorWinKills; uint32 m_HonorWinKills;
uint32 m_HonorEndKills; uint32 m_HonorEndKills;
uint32 m_EndTimer; uint32 m_EndTimer;
uint32 m_LastCapturedFlagTeam; Team m_LastCapturedFlagTeam;
}; };
#endif #endif

View file

@ -23,7 +23,7 @@
INSTANTIATE_SINGLETON_1( AllianceChannelMgr ); INSTANTIATE_SINGLETON_1( AllianceChannelMgr );
INSTANTIATE_SINGLETON_1( HordeChannelMgr ); INSTANTIATE_SINGLETON_1( HordeChannelMgr );
ChannelMgr* channelMgr(uint32 team) ChannelMgr* channelMgr(Team team)
{ {
if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
return &MaNGOS::Singleton<AllianceChannelMgr>::Instance(); // cross-faction return &MaNGOS::Singleton<AllianceChannelMgr>::Instance(); // cross-faction

View file

@ -43,6 +43,6 @@ class ChannelMgr
class AllianceChannelMgr : public ChannelMgr {}; class AllianceChannelMgr : public ChannelMgr {};
class HordeChannelMgr : public ChannelMgr {}; class HordeChannelMgr : public ChannelMgr {};
ChannelMgr* channelMgr(uint32 team); ChannelMgr* channelMgr(Team team);
#endif #endif

View file

@ -210,7 +210,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
{ {
bool disabled = false; bool disabled = false;
uint32 team = Player::TeamForRace(race_); Team team = Player::TeamForRace(race_);
switch(team) switch(team)
{ {
case ALLIANCE: disabled = mask & (1 << 0); break; case ALLIANCE: disabled = mask & (1 << 0); break;
@ -350,7 +350,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
GetAccountId(), (skipCinematics == CINEMATICS_SKIP_SAME_RACE || class_ == CLASS_DEATH_KNIGHT) ? "" : "LIMIT 1"); GetAccountId(), (skipCinematics == CINEMATICS_SKIP_SAME_RACE || class_ == CLASS_DEATH_KNIGHT) ? "" : "LIMIT 1");
if(result2) if(result2)
{ {
uint32 team_= Player::TeamForRace(race_); Team team_= Player::TeamForRace(race_);
Field* field = result2->Fetch(); Field* field = result2->Fetch();
uint8 acc_race = field[1].GetUInt32(); uint8 acc_race = field[1].GetUInt32();
@ -384,11 +384,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
// TODO: what to if account already has characters of both races? // TODO: what to if account already has characters of both races?
if (!AllowTwoSideAccounts) if (!AllowTwoSideAccounts)
{ {
uint32 acc_team = 0; if (acc_race == 0 || Player::TeamForRace(acc_race) != team_)
if(acc_race > 0)
acc_team = Player::TeamForRace(acc_race);
if(acc_team != team_)
{ {
data << (uint8)CHAR_CREATE_PVP_TEAMS_VIOLATION; data << (uint8)CHAR_CREATE_PVP_TEAMS_VIOLATION;
SendPacket( &data ); SendPacket( &data );

View file

@ -215,9 +215,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT) && tSecurity == SEC_PLAYER && pSecurity == SEC_PLAYER ) if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT) && tSecurity == SEC_PLAYER && pSecurity == SEC_PLAYER )
{ {
uint32 sidea = GetPlayer()->GetTeam(); if (GetPlayer()->GetTeam() != player->GetTeam())
uint32 sideb = player->GetTeam();
if( sidea != sideb )
{ {
SendWrongFactionNotice(); SendWrongFactionNotice();
return; return;

View file

@ -196,7 +196,7 @@ void Creature::RemoveCorpse()
/** /**
* change the entry of creature until respawn * change the entry of creature until respawn
*/ */
bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data ) bool Creature::InitEntry(uint32 Entry, const CreatureData *data )
{ {
CreatureInfo const *normalInfo = ObjectMgr::GetCreatureTemplate(Entry); CreatureInfo const *normalInfo = ObjectMgr::GetCreatureTemplate(Entry);
if(!normalInfo) if(!normalInfo)
@ -294,9 +294,9 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
return true; return true;
} }
bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data, bool preserveHPAndPower) bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData *data, bool preserveHPAndPower)
{ {
if (!InitEntry(Entry, team, data)) if (!InitEntry(Entry, data))
return false; return false;
m_regenHealth = GetCreatureInfo()->RegenHealth; m_regenHealth = GetCreatureInfo()->RegenHealth;
@ -682,7 +682,7 @@ bool Creature::AIM_Initialize()
return true; return true;
} }
bool Creature::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, const CreatureData *data) bool Creature::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, Team team, const CreatureData *data)
{ {
MANGOS_ASSERT(map); MANGOS_ASSERT(map);
SetMap(map); SetMap(map);
@ -1180,7 +1180,7 @@ float Creature::GetSpellDamageMod(int32 Rank)
} }
} }
bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const CreatureData *data) bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, Team team, const CreatureData *data)
{ {
CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(Entry); CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(Entry);
if(!cinfo) if(!cinfo)
@ -1221,8 +1221,7 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
else else
guidlow = sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT); guidlow = sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT);
uint16 team = 0; if (!Create(guidlow, map, data->phaseMask, data->id, TEAM_NONE, data))
if (!Create(guidlow, map, data->phaseMask, data->id, team, data))
return false; return false;
Relocate(data->posX, data->posY, data->posZ, data->orientation); Relocate(data->posX, data->posY, data->posZ, data->orientation);
@ -1924,7 +1923,7 @@ bool Creature::LoadCreatureAddon(bool reload)
/// Send a message to LocalDefense channel for players opposition team in the zone /// Send a message to LocalDefense channel for players opposition team in the zone
void Creature::SendZoneUnderAttackMessage(Player* attacker) void Creature::SendZoneUnderAttackMessage(Player* attacker)
{ {
uint32 enemy_team = attacker->GetTeam(); Team enemy_team = attacker->GetTeam();
WorldPacket data(SMSG_ZONE_UNDER_ATTACK, 4); WorldPacket data(SMSG_ZONE_UNDER_ATTACK, 4);
data << uint32(GetZoneId()); data << uint32(GetZoneId());

View file

@ -23,6 +23,7 @@
#include "Unit.h" #include "Unit.h"
#include "UpdateMask.h" #include "UpdateMask.h"
#include "ItemPrototype.h" #include "ItemPrototype.h"
#include "SharedDefines.h"
#include "LootMgr.h" #include "LootMgr.h"
#include "DBCEnums.h" #include "DBCEnums.h"
#include "Database/DatabaseEnv.h" #include "Database/DatabaseEnv.h"
@ -394,7 +395,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
void AddToWorld(); void AddToWorld();
void RemoveFromWorld(); void RemoveFromWorld();
bool Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, const CreatureData *data = NULL); bool Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, Team team = TEAM_NONE, const CreatureData *data = NULL);
bool LoadCreatureAddon(bool reload = false); bool LoadCreatureAddon(bool reload = false);
void SelectLevel(const CreatureInfo *cinfo, float percentHealth = 100.0f, float percentMana = 100.0f); void SelectLevel(const CreatureInfo *cinfo, float percentHealth = 100.0f, float percentMana = 100.0f);
void LoadEquipment(uint32 equip_entry, bool force=false); void LoadEquipment(uint32 equip_entry, bool force=false);
@ -496,7 +497,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
bool HasSpell(uint32 spellID) const; bool HasSpell(uint32 spellID) const;
bool UpdateEntry(uint32 entry, uint32 team = ALLIANCE, const CreatureData* data = NULL, bool preserveHPAndPower = true); bool UpdateEntry(uint32 entry, Team team = ALLIANCE, const CreatureData* data = NULL, bool preserveHPAndPower = true);
bool UpdateStats(Stats stat); bool UpdateStats(Stats stat);
bool UpdateAllStats(); bool UpdateAllStats();
void UpdateResistances(uint32 school); void UpdateResistances(uint32 school);
@ -635,8 +636,8 @@ class MANGOS_DLL_SPEC Creature : public Unit
void SendAreaSpiritHealerQueryOpcode(Player *pl); void SendAreaSpiritHealerQueryOpcode(Player *pl);
protected: protected:
bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL); bool CreateFromProto(uint32 guidlow,uint32 Entry, Team team, const CreatureData *data = NULL);
bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL); bool InitEntry(uint32 entry, const CreatureData* data=NULL);
void RelocationNotify(); void RelocationNotify();
uint32 m_groupLootTimer; // (msecs)timer used for group loot uint32 m_groupLootTimer; // (msecs)timer used for group loot

View file

@ -1589,7 +1589,7 @@ GroupJoinBattlegroundResult Group::CanJoinBattleGroundQueue(BattleGround const*
return ERR_BATTLEGROUND_JOIN_FAILED; return ERR_BATTLEGROUND_JOIN_FAILED;
uint32 arenaTeamId = reference->GetArenaTeamId(arenaSlot); uint32 arenaTeamId = reference->GetArenaTeamId(arenaSlot);
uint32 team = reference->GetTeam(); Team team = reference->GetTeam();
// check every member of the group to be able to join // check every member of the group to be able to join
for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next()) for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next())

View file

@ -1551,10 +1551,6 @@ bool ChatHandler::HandleNpcAddCommand(char* args)
if (!ExtractUint32KeyFromLink(&args, "Hcreature_entry", id)) if (!ExtractUint32KeyFromLink(&args, "Hcreature_entry", id))
return false; return false;
uint32 team;
if (!ExtractOptUInt32(&args, team, 0))
return false;
Player *chr = m_session->GetPlayer(); Player *chr = m_session->GetPlayer();
float x = chr->GetPositionX(); float x = chr->GetPositionX();
float y = chr->GetPositionY(); float y = chr->GetPositionY();
@ -1563,7 +1559,7 @@ bool ChatHandler::HandleNpcAddCommand(char* args)
Map *map = chr->GetMap(); Map *map = chr->GetMap();
Creature* pCreature = new Creature; Creature* pCreature = new Creature;
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, team)) if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id))
{ {
delete pCreature; delete pCreature;
return false; return false;
@ -3191,7 +3187,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
// create the waypoint creature // create the waypoint creature
wpGuid = 0; wpGuid = 0;
Creature* wpCreature = new Creature; Creature* wpCreature = new Creature;
if (!wpCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT,0)) if (!wpCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT))
{ {
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
delete wpCreature; delete wpCreature;
@ -3311,7 +3307,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
wpCreature->AddObjectToRemoveList(); wpCreature->AddObjectToRemoveList();
// re-create // re-create
Creature* wpCreature2 = new Creature; Creature* wpCreature2 = new Creature;
if (!wpCreature2->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0)) if (!wpCreature2->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT))
{ {
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
delete wpCreature2; delete wpCreature2;
@ -3615,7 +3611,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
float o = chr->GetOrientation(); float o = chr->GetOrientation();
Creature* wpCreature = new Creature; Creature* wpCreature = new Creature;
if (!wpCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0)) if (!wpCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id))
{ {
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete wpCreature; delete wpCreature;
@ -3673,7 +3669,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
Map *map = chr->GetMap(); Map *map = chr->GetMap();
Creature* pCreature = new Creature; Creature* pCreature = new Creature;
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT),map, chr->GetPhaseMaskForSpawn(), id, 0)) if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT),map, chr->GetPhaseMaskForSpawn(), id))
{ {
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete pCreature; delete pCreature;
@ -3733,7 +3729,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
Map *map = chr->GetMap(); Map *map = chr->GetMap();
Creature* pCreature = new Creature; Creature* pCreature = new Creature;
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0)) if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id))
{ {
PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id); PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);
delete pCreature; delete pCreature;

View file

@ -3892,9 +3892,9 @@ bool ChatHandler::HandleLinkGraveCommand(char* args)
char* teamStr = ExtractLiteralArg(&args); char* teamStr = ExtractLiteralArg(&args);
uint32 g_team; Team g_team;
if (!teamStr) if (!teamStr)
g_team = 0; g_team = TEAM_NONE;
else if (strncmp(teamStr, "horde", strlen(teamStr))==0) else if (strncmp(teamStr, "horde", strlen(teamStr))==0)
g_team = HORDE; g_team = HORDE;
else if (strncmp(teamStr, "alliance", strlen(teamStr))==0) else if (strncmp(teamStr, "alliance", strlen(teamStr))==0)
@ -3923,22 +3923,22 @@ bool ChatHandler::HandleLinkGraveCommand(char* args)
return false; return false;
} }
if (sObjectMgr.AddGraveYardLink(g_id,zoneId,g_team)) if (sObjectMgr.AddGraveYardLink(g_id, zoneId, g_team))
PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, g_id,zoneId); PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, g_id, zoneId);
else else
PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, g_id,zoneId); PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, g_id, zoneId);
return true; return true;
} }
bool ChatHandler::HandleNearGraveCommand(char* args) bool ChatHandler::HandleNearGraveCommand(char* args)
{ {
uint32 g_team; Team g_team;
size_t argslen = strlen(args); size_t argslen = strlen(args);
if(!*args) if(!*args)
g_team = 0; g_team = TEAM_NONE;
else if (strncmp(args, "horde", argslen) == 0) else if (strncmp(args, "horde", argslen) == 0)
g_team = HORDE; g_team = HORDE;
else if (strncmp(args, "alliance", argslen) == 0) else if (strncmp(args, "alliance", argslen) == 0)
@ -3950,7 +3950,7 @@ bool ChatHandler::HandleNearGraveCommand(char* args)
uint32 zone_id = player->GetZoneId(); uint32 zone_id = player->GetZoneId();
WorldSafeLocsEntry const* graveyard = sObjectMgr.GetClosestGraveYard( WorldSafeLocsEntry const* graveyard = sObjectMgr.GetClosestGraveYard(
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(),player->GetMapId(),g_team); player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), g_team);
if(graveyard) if(graveyard)
{ {

View file

@ -139,7 +139,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
Player *receive = sObjectMgr.GetPlayer(rc); Player *receive = sObjectMgr.GetPlayer(rc);
uint32 rc_team = 0; Team rc_team;
uint8 mails_count = 0; // do not allow to send to one player more than 100 mails uint8 mails_count = 0; // do not allow to send to one player more than 100 mails
if (receive) if (receive)

View file

@ -132,7 +132,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
if(level_max >= MAX_LEVEL) if(level_max >= MAX_LEVEL)
level_max = STRONG_MAX_LEVEL; level_max = STRONG_MAX_LEVEL;
uint32 team = _player->GetTeam(); Team team = _player->GetTeam();
uint32 security = GetSecurity(); uint32 security = GetSecurity();
bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST); bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST);
AccountTypes gmLevelInWhoList = (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST); AccountTypes gmLevelInWhoList = (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST);
@ -459,12 +459,12 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 acc
uint32 friendLowGuid = (*result)[0].GetUInt32(); uint32 friendLowGuid = (*result)[0].GetUInt32();
ObjectGuid friendGuid = ObjectGuid(HIGHGUID_PLAYER, friendLowGuid); ObjectGuid friendGuid = ObjectGuid(HIGHGUID_PLAYER, friendLowGuid);
uint32 team = Player::TeamForRace((*result)[1].GetUInt8()); Team team = Player::TeamForRace((*result)[1].GetUInt8());
delete result; delete result;
WorldSession * session = sWorld.FindSession(accountId); WorldSession * session = sWorld.FindSession(accountId);
if(!session || !session->GetPlayer()) if (!session || !session->GetPlayer())
return; return;
FriendsResult friendResult = FRIEND_NOT_FOUND; FriendsResult friendResult = FRIEND_NOT_FOUND;

View file

@ -98,7 +98,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// We're not in BG // We're not in BG
_player->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE); _player->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE);
// reset destination bg team // reset destination bg team
_player->SetBGTeam(0); _player->SetBGTeam(TEAM_NONE);
} }
// join to bg case // join to bg case
else if(BattleGround *bg = _player->GetBattleGround()) else if(BattleGround *bg = _player->GetBattleGround())

View file

@ -384,7 +384,7 @@ void WorldSession::SendSpiritResurrect()
Corpse *corpse = _player->GetCorpse(); Corpse *corpse = _player->GetCorpse();
if(corpse) if(corpse)
corpseGrave = sObjectMgr.GetClosestGraveYard( corpseGrave = sObjectMgr.GetClosestGraveYard(
corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetMapId(), _player->GetTeam() ); corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetMapId(), _player->GetTeam());
// now can spawn bones // now can spawn bones
_player->SpawnCorpseBones(); _player->SpawnCorpseBones();
@ -393,7 +393,7 @@ void WorldSession::SendSpiritResurrect()
if(corpseGrave) if(corpseGrave)
{ {
WorldSafeLocsEntry const *ghostGrave = sObjectMgr.GetClosestGraveYard( WorldSafeLocsEntry const *ghostGrave = sObjectMgr.GetClosestGraveYard(
_player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeam() ); _player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeam());
if(corpseGrave != ghostGrave) if(corpseGrave != ghostGrave)
_player->TeleportTo(corpseGrave->map_id, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation()); _player->TeleportTo(corpseGrave->map_id, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation());

View file

@ -1735,7 +1735,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
{ {
TemporarySummon* pCreature = new TemporarySummon(GetObjectGuid()); TemporarySummon* pCreature = new TemporarySummon(GetObjectGuid());
uint32 team = 0; Team team = TEAM_NONE;
if (GetTypeId()==TYPEID_PLAYER) if (GetTypeId()==TYPEID_PLAYER)
team = ((Player*)this)->GetTeam(); team = ((Player*)this)->GetTeam();

View file

@ -1724,7 +1724,7 @@ bool ObjectMgr::GetPlayerNameByGUID(ObjectGuid guid, std::string &name) const
return false; return false;
} }
uint32 ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const Team ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const
{ {
// prevent DB access for online player // prevent DB access for online player
if (Player* player = GetPlayer(guid)) if (Player* player = GetPlayer(guid))
@ -1741,7 +1741,7 @@ uint32 ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const
return Player::TeamForRace(race); return Player::TeamForRace(race);
} }
return 0; return TEAM_NONE;
} }
uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const
@ -5771,7 +5771,7 @@ void ObjectMgr::LoadEventIdScripts()
sLog.outString( ">> Loaded %u scripted event id", count ); sLog.outString( ">> Loaded %u scripted event id", count );
} }
uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid, uint32 team ) uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid, Team team )
{ {
bool found = false; bool found = false;
float dist; float dist;
@ -5834,7 +5834,7 @@ void ObjectMgr::GetTaxiPath( uint32 source, uint32 destination, uint32 &path, ui
path = dest_i->second.ID; path = dest_i->second.ID;
} }
uint32 ObjectMgr::GetTaxiMountDisplayId( uint32 id, uint32 team, bool allowed_alt_team /* = false */) uint32 ObjectMgr::GetTaxiMountDisplayId( uint32 id, Team team, bool allowed_alt_team /* = false */)
{ {
uint16 mount_entry = 0; uint16 mount_entry = 0;
@ -5904,33 +5904,33 @@ void ObjectMgr::LoadGraveyardZones()
uint32 team = fields[2].GetUInt32(); uint32 team = fields[2].GetUInt32();
WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(safeLocId); WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(safeLocId);
if(!entry) if (!entry)
{ {
sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing graveyard (WorldSafeLocs.dbc id) %u, skipped.",safeLocId); sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing graveyard (WorldSafeLocs.dbc id) %u, skipped.",safeLocId);
continue; continue;
} }
AreaTableEntry const *areaEntry = GetAreaEntryByAreaID(zoneId); AreaTableEntry const *areaEntry = GetAreaEntryByAreaID(zoneId);
if(!areaEntry) if (!areaEntry)
{ {
sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing zone id (%u), skipped.",zoneId); sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing zone id (%u), skipped.", zoneId);
continue; continue;
} }
if(areaEntry->zone != 0) if (areaEntry->zone != 0)
{ {
sLog.outErrorDb("Table `game_graveyard_zone` has record subzone id (%u) instead of zone, skipped.",zoneId); sLog.outErrorDb("Table `game_graveyard_zone` has record subzone id (%u) instead of zone, skipped.", zoneId);
continue; continue;
} }
if(team!=0 && team!=HORDE && team!=ALLIANCE) if (team != TEAM_NONE && team != HORDE && team != ALLIANCE)
{ {
sLog.outErrorDb("Table `game_graveyard_zone` has record for non player faction (%u), skipped.",team); sLog.outErrorDb("Table `game_graveyard_zone` has record for non player faction (%u), skipped.", team);
continue; continue;
} }
if(!AddGraveYardLink(safeLocId,zoneId,team,false)) if(!AddGraveYardLink(safeLocId, zoneId, Team(team), false))
sLog.outErrorDb("Table `game_graveyard_zone` has a duplicate record for Graveyard (ID: %u) and Zone (ID: %u), skipped.",safeLocId,zoneId); sLog.outErrorDb("Table `game_graveyard_zone` has a duplicate record for Graveyard (ID: %u) and Zone (ID: %u), skipped.", safeLocId, zoneId);
} while( result->NextRow() ); } while( result->NextRow() );
delete result; delete result;
@ -5939,7 +5939,7 @@ void ObjectMgr::LoadGraveyardZones()
sLog.outString( ">> Loaded %u graveyard-zone links", count ); sLog.outString( ">> Loaded %u graveyard-zone links", count );
} }
WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team) WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float z, uint32 MapId, Team team)
{ {
// search for zone associated closest graveyard // search for zone associated closest graveyard
uint32 zoneId = sTerrainMgr.GetZoneId(MapId,x,y,z); uint32 zoneId = sTerrainMgr.GetZoneId(MapId,x,y,z);
@ -5955,7 +5955,7 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float
if (bounds.first == bounds.second) if (bounds.first == bounds.second)
{ {
sLog.outErrorDb("Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.",zoneId,team); sLog.outErrorDb("Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.", zoneId, uint32(team));
return NULL; return NULL;
} }
@ -5987,7 +5987,7 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float
// skip enemy faction graveyard // skip enemy faction graveyard
// team == 0 case can be at call from .neargrave // team == 0 case can be at call from .neargrave
if(data.team != 0 && team != 0 && data.team != team) if (data.team != TEAM_NONE && team != TEAM_NONE && data.team != team)
continue; continue;
// find now nearest graveyard at other (continent) map // find now nearest graveyard at other (continent) map
@ -6065,7 +6065,7 @@ GraveYardData const* ObjectMgr::FindGraveYardData(uint32 id, uint32 zoneId) cons
return NULL; return NULL;
} }
bool ObjectMgr::AddGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool inDB) bool ObjectMgr::AddGraveYardLink(uint32 id, uint32 zoneId, Team team, bool inDB)
{ {
if(FindGraveYardData(id,zoneId)) if(FindGraveYardData(id,zoneId))
return false; return false;
@ -6081,7 +6081,7 @@ bool ObjectMgr::AddGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool inD
if(inDB) if(inDB)
{ {
WorldDatabase.PExecuteLog("INSERT INTO game_graveyard_zone ( id,ghost_zone,faction) " WorldDatabase.PExecuteLog("INSERT INTO game_graveyard_zone ( id,ghost_zone,faction) "
"VALUES ('%u', '%u','%u')",id,zoneId,team); "VALUES ('%u', '%u','%u')", id, zoneId, uint32(team));
} }
return true; return true;
@ -8235,7 +8235,7 @@ bool PlayerCondition::Meets(Player const * player) const
return faction && player->GetReputationMgr().GetRank(faction) >= ReputationRank(value2); return faction && player->GetReputationMgr().GetRank(faction) >= ReputationRank(value2);
} }
case CONDITION_TEAM: case CONDITION_TEAM:
return player->GetTeam() == value1; return uint32(player->GetTeam()) == value1;
case CONDITION_SKILL: case CONDITION_SKILL:
return player->HasSkill(value1) && player->GetBaseSkillValue(value1) >= value2; return player->HasSkill(value1) && player->GetBaseSkillValue(value1) >= value2;
case CONDITION_QUESTREWARDED: case CONDITION_QUESTREWARDED:

View file

@ -586,7 +586,7 @@ struct WeatherZoneChances
struct GraveYardData struct GraveYardData
{ {
uint32 safeLocId; uint32 safeLocId;
uint32 team; Team team;
}; };
typedef std::multimap<uint32, GraveYardData> GraveYardMap; typedef std::multimap<uint32, GraveYardData> GraveYardMap;
typedef std::pair<GraveYardMap::const_iterator, GraveYardMap::const_iterator> GraveYardMapBounds; typedef std::pair<GraveYardMap::const_iterator, GraveYardMap::const_iterator> GraveYardMapBounds;
@ -799,13 +799,13 @@ class ObjectMgr
uint64 GetPlayerGUIDByName(std::string name) const; uint64 GetPlayerGUIDByName(std::string name) const;
bool GetPlayerNameByGUID(ObjectGuid guid, std::string &name) const; bool GetPlayerNameByGUID(ObjectGuid guid, std::string &name) const;
uint32 GetPlayerTeamByGUID(ObjectGuid guid) const; Team GetPlayerTeamByGUID(ObjectGuid guid) const;
uint32 GetPlayerAccountIdByGUID(ObjectGuid guid) const; uint32 GetPlayerAccountIdByGUID(ObjectGuid guid) const;
uint32 GetPlayerAccountIdByPlayerName(const std::string& name) const; uint32 GetPlayerAccountIdByPlayerName(const std::string& name) const;
uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid, uint32 team ); uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid, Team team );
void GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost); void GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost);
uint32 GetTaxiMountDisplayId( uint32 id, uint32 team, bool allowed_alt_team = false); uint32 GetTaxiMountDisplayId( uint32 id, Team team, bool allowed_alt_team = false);
Quest const* GetQuestTemplate(uint32 quest_id) const Quest const* GetQuestTemplate(uint32 quest_id) const
{ {
@ -833,8 +833,8 @@ class ObjectMgr
GossipText const* GetGossipText(uint32 Text_ID) const; GossipText const* GetGossipText(uint32 Text_ID) const;
WorldSafeLocsEntry const *GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team); WorldSafeLocsEntry const *GetClosestGraveYard(float x, float y, float z, uint32 MapId, Team team);
bool AddGraveYardLink(uint32 id, uint32 zone, uint32 team, bool inDB = true); bool AddGraveYardLink(uint32 id, uint32 zone, Team team, bool inDB = true);
void LoadGraveyardZones(); void LoadGraveyardZones();
GraveYardData const* FindGraveYardData(uint32 id, uint32 zone) const; GraveYardData const* FindGraveYardData(uint32 id, uint32 zone) const;

View file

@ -203,7 +203,7 @@ void PlayerTaxi::AppendTaximaskTo( ByteBuffer& data, bool all )
} }
} }
bool PlayerTaxi::LoadTaxiDestinationsFromString( const std::string& values, uint32 team ) bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, Team team)
{ {
ClearTaxiDestinations(); ClearTaxiDestinations();
@ -226,13 +226,13 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString( const std::string& values, uint
{ {
uint32 cost; uint32 cost;
uint32 path; uint32 path;
sObjectMgr.GetTaxiPath(m_TaxiDestinations[i-1],m_TaxiDestinations[i],path,cost); sObjectMgr.GetTaxiPath(m_TaxiDestinations[i-1],m_TaxiDestinations[i], path, cost);
if(!path) if (!path)
return false; return false;
} }
// can't load taxi path without mount set (quest taxi path?) // can't load taxi path without mount set (quest taxi path?)
if(!sObjectMgr.GetTaxiMountDisplayId(GetTaxiSource(),team,true)) if (!sObjectMgr.GetTaxiMountDisplayId(GetTaxiSource(), team, true))
return false; return false;
return true; return true;
@ -6205,10 +6205,10 @@ void Player::CheckAreaExploreAndOutdoor()
} }
} }
uint32 Player::TeamForRace(uint8 race) Team Player::TeamForRace(uint8 race)
{ {
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race); ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race);
if(!rEntry) if (!rEntry)
{ {
sLog.outError("Race %u not found in DBC: wrong DBC files?",uint32(race)); sLog.outError("Race %u not found in DBC: wrong DBC files?",uint32(race));
return ALLIANCE; return ALLIANCE;
@ -6221,7 +6221,7 @@ uint32 Player::TeamForRace(uint8 race)
} }
sLog.outError("Race %u have wrong teamid %u in DBC: wrong DBC files?",uint32(race),rEntry->TeamID); sLog.outError("Race %u have wrong teamid %u in DBC: wrong DBC files?",uint32(race),rEntry->TeamID);
return ALLIANCE; return TEAM_NONE;
} }
uint32 Player::getFactionForRace(uint8 race) uint32 Player::getFactionForRace(uint8 race)
@ -6239,7 +6239,7 @@ uint32 Player::getFactionForRace(uint8 race)
void Player::setFactionForRace(uint8 race) void Player::setFactionForRace(uint8 race)
{ {
m_team = TeamForRace(race); m_team = TeamForRace(race);
setFaction( getFactionForRace(race) ); setFaction(getFactionForRace(race));
} }
ReputationRank Player::GetReputationRank(uint32 faction) const ReputationRank Player::GetReputationRank(uint32 faction) const
@ -15022,7 +15022,7 @@ void Player::_LoadBGData(QueryResult* result)
Field *fields = result->Fetch(); Field *fields = result->Fetch();
/* bgInstanceID, bgTeam, x, y, z, o, map, taxi[0], taxi[1], mountSpell */ /* bgInstanceID, bgTeam, x, y, z, o, map, taxi[0], taxi[1], mountSpell */
m_bgData.bgInstanceID = fields[0].GetUInt32(); m_bgData.bgInstanceID = fields[0].GetUInt32();
m_bgData.bgTeam = fields[1].GetUInt32(); m_bgData.bgTeam = Team(fields[1].GetUInt32());
m_bgData.joinPos = WorldLocation(fields[6].GetUInt32(), // Map m_bgData.joinPos = WorldLocation(fields[6].GetUInt32(), // Map
fields[2].GetFloat(), // X fields[2].GetFloat(), // X
fields[3].GetFloat(), // Y fields[3].GetFloat(), // Y
@ -15537,20 +15537,20 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
SetUInt32Value(PLAYER_CHOSEN_TITLE, curTitle); SetUInt32Value(PLAYER_CHOSEN_TITLE, curTitle);
// Not finish taxi flight path // Not finish taxi flight path
if(m_bgData.HasTaxiPath()) if (m_bgData.HasTaxiPath())
{ {
m_taxi.ClearTaxiDestinations(); m_taxi.ClearTaxiDestinations();
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
m_taxi.AddTaxiDestination(m_bgData.taxiPath[i]); m_taxi.AddTaxiDestination(m_bgData.taxiPath[i]);
} }
else if(!m_taxi.LoadTaxiDestinationsFromString(taxi_nodes,GetTeam())) else if (!m_taxi.LoadTaxiDestinationsFromString(taxi_nodes, GetTeam()))
{ {
// problems with taxi path loading // problems with taxi path loading
TaxiNodesEntry const* nodeEntry = NULL; TaxiNodesEntry const* nodeEntry = NULL;
if(uint32 node_id = m_taxi.GetTaxiSource()) if (uint32 node_id = m_taxi.GetTaxiSource())
nodeEntry = sTaxiNodesStore.LookupEntry(node_id); nodeEntry = sTaxiNodesStore.LookupEntry(node_id);
if(!nodeEntry) // don't know taxi start node, to homebind if (!nodeEntry) // don't know taxi start node, to homebind
{ {
sLog.outError("Character %u have wrong data in taxi destination list, teleport to homebind.",GetGUIDLow()); sLog.outError("Character %u have wrong data in taxi destination list, teleport to homebind.",GetGUIDLow());
RelocateToHomebind(); RelocateToHomebind();
@ -18488,7 +18488,7 @@ void Player::ContinueTaxiFlight()
DEBUG_LOG( "WORLD: Restart character %u taxi flight", GetGUIDLow() ); DEBUG_LOG( "WORLD: Restart character %u taxi flight", GetGUIDLow() );
uint32 mountDisplayId = sObjectMgr.GetTaxiMountDisplayId(sourceNode, GetTeam(),true); uint32 mountDisplayId = sObjectMgr.GetTaxiMountDisplayId(sourceNode, GetTeam(), true);
uint32 path = m_taxi.GetCurrentTaxiPath(); uint32 path = m_taxi.GetCurrentTaxiPath();
// search appropriate start path node // search appropriate start path node
@ -22118,7 +22118,7 @@ void Player::_SaveBGData()
{ {
/* guid, bgInstanceID, bgTeam, x, y, z, o, map, taxi[0], taxi[1], mountSpell */ /* guid, bgInstanceID, bgTeam, x, y, z, o, map, taxi[0], taxi[1], mountSpell */
CharacterDatabase.PExecute("INSERT INTO character_battleground_data VALUES ('%u', '%u', '%u', '%f', '%f', '%f', '%f', '%u', '%u', '%u', '%u')", CharacterDatabase.PExecute("INSERT INTO character_battleground_data VALUES ('%u', '%u', '%u', '%f', '%f', '%f', '%f', '%u', '%u', '%u', '%u')",
GetGUIDLow(), m_bgData.bgInstanceID, m_bgData.bgTeam, m_bgData.joinPos.coord_x, m_bgData.joinPos.coord_y, m_bgData.joinPos.coord_z, GetGUIDLow(), m_bgData.bgInstanceID, uint32(m_bgData.bgTeam), m_bgData.joinPos.coord_x, m_bgData.joinPos.coord_y, m_bgData.joinPos.coord_z,
m_bgData.joinPos.orientation, m_bgData.joinPos.mapid, m_bgData.taxiPath[0], m_bgData.taxiPath[1], m_bgData.mountSpell); m_bgData.joinPos.orientation, m_bgData.joinPos.mapid, m_bgData.taxiPath[0], m_bgData.taxiPath[1], m_bgData.mountSpell);
} }
} }

View file

@ -982,7 +982,7 @@ class MANGOS_DLL_SPEC PlayerTaxi
void AppendTaximaskTo(ByteBuffer& data, bool all); void AppendTaximaskTo(ByteBuffer& data, bool all);
// Destinations // Destinations
bool LoadTaxiDestinationsFromString(const std::string& values, uint32 team); bool LoadTaxiDestinationsFromString(const std::string& values, Team team);
std::string SaveTaxiDestinationsToString(); std::string SaveTaxiDestinationsToString();
void ClearTaxiDestinations() { m_TaxiDestinations.clear(); } void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
@ -1009,7 +1009,7 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
struct BGData struct BGData
{ {
BGData() : bgInstanceID(0), bgTypeID(BATTLEGROUND_TYPE_NONE), bgAfkReportedCount(0), bgAfkReportedTimer(0), BGData() : bgInstanceID(0), bgTypeID(BATTLEGROUND_TYPE_NONE), bgAfkReportedCount(0), bgAfkReportedTimer(0),
bgTeam(0), mountSpell(0) { ClearTaxiPath(); } bgTeam(TEAM_NONE), mountSpell(0) { ClearTaxiPath(); }
uint32 bgInstanceID; ///< This variable is set to bg->m_InstanceID, uint32 bgInstanceID; ///< This variable is set to bg->m_InstanceID,
@ -1020,7 +1020,7 @@ struct BGData
uint8 bgAfkReportedCount; uint8 bgAfkReportedCount;
time_t bgAfkReportedTimer; time_t bgAfkReportedTimer;
uint32 bgTeam; ///< What side the player will be added to Team bgTeam; ///< What side the player will be added to
uint32 mountSpell; uint32 mountSpell;
@ -1984,8 +1984,8 @@ class MANGOS_DLL_SPEC Player : public Unit
void CheckAreaExploreAndOutdoor(void); void CheckAreaExploreAndOutdoor(void);
static uint32 TeamForRace(uint8 race); static Team TeamForRace(uint8 race);
uint32 GetTeam() const { return m_team; } Team GetTeam() const { return m_team; }
static uint32 getFactionForRace(uint8 race); static uint32 getFactionForRace(uint8 race);
void setFactionForRace(uint8 race); void setFactionForRace(uint8 race);
@ -2183,8 +2183,8 @@ class MANGOS_DLL_SPEC Player : public Unit
WorldLocation const& GetBattleGroundEntryPoint() const { return m_bgData.joinPos; } WorldLocation const& GetBattleGroundEntryPoint() const { return m_bgData.joinPos; }
void SetBattleGroundEntryPoint(); void SetBattleGroundEntryPoint();
void SetBGTeam(uint32 team) { m_bgData.bgTeam = team; } void SetBGTeam(Team team) { m_bgData.bgTeam = team; }
uint32 GetBGTeam() const { return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam(); } Team GetBGTeam() const { return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam(); }
void LeaveBattleground(bool teleportToEntryPoint = true); void LeaveBattleground(bool teleportToEntryPoint = true);
bool CanJoinToBattleground() const; bool CanJoinToBattleground() const;
@ -2497,7 +2497,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void outDebugStatsValues() const; void outDebugStatsValues() const;
ObjectGuid m_lootGuid; ObjectGuid m_lootGuid;
uint32 m_team; Team m_team;
uint32 m_nextSave; uint32 m_nextSave;
time_t m_speakTime; time_t m_speakTime;
uint32 m_speakCount; uint32 m_speakCount;

View file

@ -519,16 +519,12 @@ enum Language
#define LANGUAGES_COUNT 19 #define LANGUAGES_COUNT 19
// In fact !=0 values is alliance/horde root faction ids
enum Team enum Team
{ {
TEAM_NONE = 0, // used when team value unknown or not set, 0 is also meaning that can be used !team check
HORDE = 67, HORDE = 67,
ALLIANCE = 469, ALLIANCE = 469,
//TEAM_STEAMWHEEDLE_CARTEL = 169, // not used in code
//TEAM_ALLIANCE_FORCES = 891,
//TEAM_HORDE_FORCES = 892,
//TEAM_SANCTUARY = 936,
//TEAM_OUTLAND = 980,
//TEAM_OTHER = 0, // if ReputationListId > 0 && Flags != FACTION_FLAG_TEAM_HEADER
}; };
enum SpellEffects enum SpellEffects

View file

@ -186,7 +186,7 @@ void SocialMgr::GetFriendInfo(Player *player, uint32 friend_lowguid, FriendInfo
Player *pFriend = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, friend_lowguid)); Player *pFriend = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, friend_lowguid));
uint32 team = player->GetTeam(); Team team = player->GetTeam();
AccountTypes security = player->GetSession()->GetSecurity(); AccountTypes security = player->GetSession()->GetSecurity();
bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST); bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST);
AccountTypes gmLevelInWhoList = AccountTypes (sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST)); AccountTypes gmLevelInWhoList = AccountTypes (sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST));
@ -268,7 +268,7 @@ void SocialMgr::BroadcastToFriendListers(Player *player, WorldPacket *packet)
if(!player) if(!player)
return; return;
uint32 team = player->GetTeam(); Team team = player->GetTeam();
AccountTypes security = player->GetSession()->GetSecurity(); AccountTypes security = player->GetSession()->GetSecurity();
uint32 guid = player->GetGUIDLow(); uint32 guid = player->GetGUIDLow();
AccountTypes gmLevelInWhoList = AccountTypes(sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST)); AccountTypes gmLevelInWhoList = AccountTypes(sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST));

View file

@ -5627,12 +5627,9 @@ void Spell::EffectSummonObjectWild(SpellEffectIndex eff_idx)
{ {
if(bg && bg->GetTypeID()==BATTLEGROUND_WS && bg->GetStatus() == STATUS_IN_PROGRESS) if(bg && bg->GetTypeID()==BATTLEGROUND_WS && bg->GetStatus() == STATUS_IN_PROGRESS)
{ {
uint32 team = ALLIANCE; Team team = pl->GetTeam() == ALLIANCE ? HORDE : ALLIANCE;
if(pl->GetTeam() == team) ((BattleGroundWS*)bg)->SetDroppedFlagGUID(pGameObj->GetGUID(), team);
team = HORDE;
((BattleGroundWS*)bg)->SetDroppedFlagGUID(pGameObj->GetGUID(),team);
} }
break; break;
} }
@ -7031,7 +7028,7 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc)
if (Totem *OldTotem = m_caster->GetTotem(TotemSlot(slot))) if (Totem *OldTotem = m_caster->GetTotem(TotemSlot(slot)))
OldTotem->UnSummon(); OldTotem->UnSummon();
uint32 team = 0; Team team = TEAM_NONE;
if (m_caster->GetTypeId()==TYPEID_PLAYER) if (m_caster->GetTypeId()==TYPEID_PLAYER)
team = ((Player*)m_caster)->GetTeam(); team = ((Player*)m_caster)->GetTeam();

View file

@ -61,13 +61,13 @@ void Vehicle::Update(uint32 diff)
Creature::Update(diff); Creature::Update(diff);
} }
bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, uint32 team) bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, Team team)
{ {
SetMap(map); SetMap(map);
Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE); Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE);
if(!InitEntry(Entry, team)) if(!InitEntry(Entry))
return false; return false;
m_defaultMovementType = IDLE_MOTION_TYPE; m_defaultMovementType = IDLE_MOTION_TYPE;

View file

@ -23,6 +23,7 @@
#include "ObjectGuid.h" #include "ObjectGuid.h"
#include "Creature.h" #include "Creature.h"
#include "Unit.h" #include "Unit.h"
#include "SharedDefines.h"
class Vehicle : public Creature class Vehicle : public Creature
{ {
@ -33,7 +34,7 @@ class Vehicle : public Creature
void AddToWorld(); void AddToWorld();
void RemoveFromWorld(); void RemoveFromWorld();
bool Create (uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, uint32 team); bool Create (uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, Team team);
void SetDeathState(DeathState s); // overwrite virtual Creature::SetDeathState and Unit::SetDeathState void SetDeathState(DeathState s); // overwrite virtual Creature::SetDeathState and Unit::SetDeathState
void Update(uint32 diff); // overwrite virtual Creature::Update and Unit::Update void Update(uint32 diff); // overwrite virtual Creature::Update and Unit::Update

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10781" #define REVISION_NR "10782"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__