diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index a70579d66..2a076b3d0 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -943,7 +943,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui { if (bg->GetTypeID() != BATTLEGROUND_AB) continue; - if(!((BattleGroundAB*)bg)->IsTeamScores500Disadvantage(GetPlayer()->GetTeam())) + if (!((BattleGroundAB*)bg)->IsTeamScores500Disadvantage(GetPlayer()->GetTeam())) continue; break; } @@ -1178,7 +1178,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; // 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; change = 1; diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index eb9624f18..22476dd56 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -360,7 +360,7 @@ void BattleGround::Update(uint32 diff) else if (m_PrematureCountDownTimer < diff) { // time's up! - uint32 winner = 0; + Team winner = TEAM_NONE; if (GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam()) winner = ALLIANCE; else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam()) @@ -507,9 +507,9 @@ void BattleGround::Update(uint32 diff) m_StartTime += diff; } -void BattleGround::SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O) +void BattleGround::SetTeamStartLoc(Team team, float X, float Y, float Z, float O) { - BattleGroundTeamIndex teamIdx = GetTeamIndexByTeamId(TeamID); + BattleGroundTeamIndex teamIdx = GetTeamIndexByTeamId(team); m_TeamStartLocX[teamIdx] = X; m_TeamStartLocY[teamIdx] = Y; m_TeamStartLocZ[teamIdx] = Z; @@ -530,7 +530,7 @@ void BattleGround::SendPacketToAll(WorldPacket *packet) } } -void BattleGround::SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *sender, bool self) +void BattleGround::SendPacketToTeam(Team teamId, WorldPacket *packet, Player *sender, bool self) { for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { @@ -546,10 +546,10 @@ void BattleGround::SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player * if (!self && sender == plr) continue; - uint32 team = itr->second.Team; - if(!team) team = plr->GetTeam(); + Team team = itr->second.PlayerTeam; + if (!team) team = plr->GetTeam(); - if (team == TeamID) + if (team == teamId) plr->GetSession()->SendPacket(packet); } } @@ -561,7 +561,7 @@ void BattleGround::PlaySoundToAll(uint32 SoundID) SendPacketToAll(&data); } -void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID) +void BattleGround::PlaySoundToTeam(uint32 SoundID, Team teamId) { WorldPacket data; @@ -577,10 +577,10 @@ void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID) continue; } - uint32 team = itr->second.Team; + Team team = itr->second.PlayerTeam; if(!team) team = plr->GetTeam(); - if (team == TeamID) + if (team == teamId) { sBattleGroundMgr.BuildPlaySoundPacket(&data, SoundID); plr->GetSession()->SendPacket(&data); @@ -588,7 +588,7 @@ void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID) } } -void BattleGround::CastSpellOnTeam(uint32 SpellID, uint32 TeamID) +void BattleGround::CastSpellOnTeam(uint32 SpellID, Team teamId) { for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { @@ -602,15 +602,15 @@ void BattleGround::CastSpellOnTeam(uint32 SpellID, uint32 TeamID) continue; } - uint32 team = itr->second.Team; + Team team = itr->second.PlayerTeam; if(!team) team = plr->GetTeam(); - if (team == TeamID) + if (team == teamId) plr->CastSpell(plr, SpellID, true); } } -void BattleGround::RewardHonorToTeam(uint32 Honor, uint32 TeamID) +void BattleGround::RewardHonorToTeam(uint32 Honor, Team teamId) { for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { @@ -624,15 +624,15 @@ void BattleGround::RewardHonorToTeam(uint32 Honor, uint32 TeamID) continue; } - uint32 team = itr->second.Team; + Team team = itr->second.PlayerTeam; if(!team) team = plr->GetTeam(); - if (team == TeamID) + if (team == teamId) UpdatePlayerScore(plr, SCORE_BONUS_HONOR, Honor); } } -void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID) +void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, Team teamId) { FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id); @@ -651,10 +651,10 @@ void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, continue; } - uint32 team = itr->second.Team; + Team team = itr->second.PlayerTeam; if(!team) team = plr->GetTeam(); - if (team == TeamID) + if (team == teamId) plr->GetReputationMgr().ModifyReputation(factionEntry, Reputation); } } @@ -673,7 +673,7 @@ void BattleGround::UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player Source->GetSession()->SendPacket(&data); } -void BattleGround::EndBattleGround(uint32 winner) +void BattleGround::EndBattleGround(Team winner) { this->RemoveFromBGFreeSlotQueue(); @@ -733,7 +733,7 @@ void BattleGround::EndBattleGround(uint32 winner) for(BattleGroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { - uint32 team = itr->second.Team; + Team team = itr->second.PlayerTeam; if (itr->second.OfflineRemoveTime) { @@ -995,7 +995,7 @@ void BattleGround::BlockMovement(Player *plr) void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket) { - uint32 team = GetPlayerTeam(guid); + Team team = GetPlayerTeam(guid); bool participant = false; // Remove from lists/maps BattleGroundPlayerMap::iterator itr = m_Players.find(guid); @@ -1036,7 +1036,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac { plr->ClearAfkReports(); - if(!team) team = plr->GetTeam(); + if (!team) team = plr->GetTeam(); // if arena, remove the specific arena auras if (isArena()) @@ -1109,7 +1109,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac // Do next only if found in battleground plr->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG. // reset destination bg team - plr->SetBGTeam(0); + plr->SetBGTeam(TEAM_NONE); if (Transport) plr->TeleportToBGEntryPoint(); @@ -1176,11 +1176,11 @@ void BattleGround::AddPlayer(Player *plr) // score struct must be created in inherited class ObjectGuid guid = plr->GetObjectGuid(); - uint32 team = plr->GetBGTeam(); + Team team = plr->GetBGTeam(); BattleGroundPlayer bp; bp.OfflineRemoveTime = 0; - bp.Team = team; + bp.PlayerTeam = team; // Add to list/maps m_Players[guid.GetRawValue()] = bp; @@ -1197,7 +1197,7 @@ void BattleGround::AddPlayer(Player *plr) plr->RemoveArenaSpellCooldowns(); plr->RemoveArenaAuras(); plr->RemoveAllEnchantments(TEMP_ENCHANTMENT_SLOT); - if(team == ALLIANCE) // gold + if (team == ALLIANCE) // gold { if (plr->GetTeam() == HORDE) plr->CastSpell(plr, SPELL_HORDE_GOLD_FLAG,true); @@ -1241,7 +1241,7 @@ void BattleGround::AddPlayer(Player *plr) } /* this method adds player to his team's bg group, or sets his correct group if player is already in bg group */ -void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player *plr, ObjectGuid plr_guid, uint32 team) +void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player *plr, ObjectGuid plr_guid, Team team) { if (Group* group = GetBgRaid(team)) // raid already exist { @@ -1330,11 +1330,11 @@ void BattleGround::RemoveFromBGFreeSlotQueue() // get the number of free slots for team // returns the number how many players can join battleground to MaxPlayersPerTeam -uint32 BattleGround::GetFreeSlotsForTeam(uint32 Team) const +uint32 BattleGround::GetFreeSlotsForTeam(Team team) const { //return free slot count to MaxPlayerPerTeam if (GetStatus() == STATUS_WAIT_JOIN || GetStatus() == STATUS_IN_PROGRESS) - return (GetInvitedCount(Team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(Team) : 0; + return (GetInvitedCount(team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(team) : 0; return 0; } @@ -1751,12 +1751,12 @@ void BattleGround::HandleKillPlayer( Player *player, Player *killer ) // return the player's team based on battlegroundplayer info // used in same faction arena matches mainly -uint32 BattleGround::GetPlayerTeam(uint64 guid) +Team BattleGround::GetPlayerTeam(uint64 guid) { BattleGroundPlayerMap::const_iterator itr = m_Players.find(guid); - if (itr!=m_Players.end()) - return itr->second.Team; - return 0; + if (itr != m_Players.end()) + return itr->second.PlayerTeam; + return TEAM_NONE; } bool BattleGround::IsPlayerInBattleGround(uint64 guid) @@ -1784,12 +1784,12 @@ void BattleGround::PlayerAddedToBGCheckIfBGIsRunning(Player* plr) plr->GetSession()->SendPacket(&data); } -uint32 BattleGround::GetAlivePlayersCountByTeam(uint32 Team) const +uint32 BattleGround::GetAlivePlayersCountByTeam(Team team) const { int count = 0; for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { - if (itr->second.Team == Team) + if (itr->second.PlayerTeam == team) { Player * pl = sObjectMgr.GetPlayer(itr->first); if (pl && pl->isAlive()) @@ -1807,20 +1807,25 @@ void BattleGround::CheckArenaWinConditions() EndBattleGround(ALLIANCE); } -void BattleGround::SetBgRaid( uint32 TeamID, Group *bg_raid ) +void BattleGround::SetBgRaid(Team team, Group *bg_raid) { - Group* &old_raid = TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; - if(old_raid) old_raid->SetBattlegroundGroup(NULL); - if(bg_raid) bg_raid->SetBattlegroundGroup(this); + Group* &old_raid = m_BgRaids[GetTeamIndexByTeamId(team)]; + + if (old_raid) + old_raid->SetBattlegroundGroup(NULL); + + if (bg_raid) + bg_raid->SetBattlegroundGroup(this); + old_raid = bg_raid; } WorldSafeLocsEntry const* BattleGround::GetClosestGraveYard( Player* player ) { - return sObjectMgr.GetClosestGraveYard( player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam() ); + return sObjectMgr.GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam()); } -bool BattleGround::IsTeamScoreInRange(uint32 team, uint32 minScore, uint32 maxScore) const +bool BattleGround::IsTeamScoreInRange(Team team, uint32 minScore, uint32 maxScore) const { BattleGroundTeamIndex team_idx = GetTeamIndexByTeamId(team); uint32 score = (m_TeamScores[team_idx] < 0) ? 0 : uint32(m_TeamScores[team_idx]); diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index d35472779..e4c9e1f15 100644 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -143,7 +143,7 @@ enum BattleGroundStatus struct BattleGroundPlayer { 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 @@ -303,8 +303,8 @@ class BattleGround virtual void StartingEventOpenDoors() {} /* achievement req. */ - virtual bool IsAllNodesConrolledByTeam(uint32 /*team*/) const { return false; } - bool IsTeamScoreInRange(uint32 team, uint32 minScore, uint32 maxScore) const; + virtual bool IsAllNodesConrolledByTeam(Team /*team*/) const { return false; } + bool IsTeamScoreInRange(Team team, uint32 minScore, uint32 maxScore) const; /* Battleground */ // Get methods: @@ -359,9 +359,9 @@ class BattleGround 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 DecreaseInvitedCount(uint32 team) { (team == ALLIANCE) ? --m_InvitedAlliance : --m_InvitedHorde; } - void IncreaseInvitedCount(uint32 team) { (team == ALLIANCE) ? ++m_InvitedAlliance : ++m_InvitedHorde; } - uint32 GetInvitedCount(uint32 team) const + void DecreaseInvitedCount(Team team) { (team == ALLIANCE) ? --m_InvitedAlliance : --m_InvitedHorde; } + void IncreaseInvitedCount(Team team) { (team == ALLIANCE) ? ++m_InvitedAlliance : ++m_InvitedHorde; } + uint32 GetInvitedCount(Team team) const { if (team == ALLIANCE) return m_InvitedAlliance; @@ -369,7 +369,7 @@ class BattleGround return m_InvitedHorde; } bool HasFreeSlots() const; - uint32 GetFreeSlotsForTeam(uint32 Team) const; + uint32 GetFreeSlotsForTeam(Team team) const; bool isArena() const { return m_IsArena; } bool isBattleGround() const { return !m_IsArena; } @@ -398,10 +398,10 @@ class BattleGround return m_Map; } - void SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O); - void GetTeamStartLoc(uint32 TeamID, float &X, float &Y, float &Z, float &O) const + void SetTeamStartLoc(Team team, float X, float Y, float Z, float O); + 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]; Y = m_TeamStartLocY[idx]; Z = m_TeamStartLocZ[idx]; @@ -411,17 +411,17 @@ class BattleGround /* Packet Transfer */ // method that should fill worldpacket with actual world states (not yet implemented for all battlegrounds!) 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); template void BroadcastWorker(Do& _do); - void PlaySoundToTeam(uint32 SoundID, uint32 TeamID); + void PlaySoundToTeam(uint32 SoundID, Team team); void PlaySoundToAll(uint32 SoundID); - void CastSpellOnTeam(uint32 SpellID, uint32 TeamID); - void RewardHonorToTeam(uint32 Honor, uint32 TeamID); - void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID); + void CastSpellOnTeam(uint32 SpellID, Team team); + void RewardHonorToTeam(uint32 Honor, Team team); + void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, Team team); void RewardMark(Player *plr,uint32 count); void SendRewardMarkByMail(Player *plr,uint32 mark, 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 UpdateWorldState(uint32 Field, uint32 Value); void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source); - void EndBattleGround(uint32 winner); + virtual void EndBattleGround(Team winner); void BlockMovement(Player *plr); 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); /* Raid Group */ - Group *GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; } - void SetBgRaid(uint32 TeamID, Group *bg_raid); + Group *GetBgRaid(Team team) const { return m_BgRaids[GetTeamIndexByTeamId(team)]; } + void SetBgRaid(Team team, Group *bg_raid); virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); - static BattleGroundTeamIndex GetTeamIndexByTeamId(uint32 Team) { return Team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE; } - uint32 GetPlayersCountByTeam(uint32 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 - void UpdatePlayersCountByTeam(uint32 Team, bool remove) + static BattleGroundTeamIndex GetTeamIndexByTeamId(Team team) { return team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE; } + uint32 GetPlayersCountByTeam(Team team) const { return m_PlayersCount[GetTeamIndexByTeamId(team)]; } + uint32 GetAlivePlayersCountByTeam(Team team) const; // used in arenas to correctly handle death in spirit of redemption / last stand etc. (killer = killed) cases + void UpdatePlayersCountByTeam(Team team, bool remove) { if (remove) - --m_PlayersCount[GetTeamIndexByTeamId(Team)]; + --m_PlayersCount[GetTeamIndexByTeamId(team)]; else - ++m_PlayersCount[GetTeamIndexByTeamId(Team)]; + ++m_PlayersCount[GetTeamIndexByTeamId(team)]; } // used for rated arena battles - void SetArenaTeamIdForTeam(uint32 Team, uint32 ArenaTeamId) { m_ArenaTeamIds[GetTeamIndexByTeamId(Team)] = ArenaTeamId; } - uint32 GetArenaTeamIdForTeam(uint32 Team) const { return m_ArenaTeamIds[GetTeamIndexByTeamId(Team)]; } - void SetArenaTeamRatingChangeForTeam(uint32 Team, int32 RatingChange) { m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)] = RatingChange; } - int32 GetArenaTeamRatingChangeForTeam(uint32 Team) const { return m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)]; } + void SetArenaTeamIdForTeam(Team team, uint32 ArenaTeamId) { m_ArenaTeamIds[GetTeamIndexByTeamId(team)] = ArenaTeamId; } + uint32 GetArenaTeamIdForTeam(Team team) const { return m_ArenaTeamIds[GetTeamIndexByTeamId(team)]; } + void SetArenaTeamRatingChangeForTeam(Team team, int32 RatingChange) { m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(team)] = RatingChange; } + int32 GetArenaTeamRatingChangeForTeam(Team team) const { return m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(team)]; } void CheckArenaWinConditions(); /* Triggers handle */ @@ -483,7 +483,7 @@ class BattleGround 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); // can be extended in in BG subclass @@ -524,8 +524,8 @@ class BattleGround virtual bool HandlePlayerUnderMap(Player * /*plr*/) { return false; } // since arenas can be AvA or Hvh, we have to get the "temporary" team of a player - uint32 GetPlayerTeam(uint64 guid); - static uint32 GetOtherTeam(uint32 teamId){ return (teamId) ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0; } + Team GetPlayerTeam(uint64 guid); + 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; } bool IsPlayerInBattleGround(uint64 guid); diff --git a/src/game/BattleGroundAB.cpp b/src/game/BattleGroundAB.cpp index 7e333fcf3..a39c223db 100644 --- a/src/game/BattleGroundAB.cpp +++ b/src/game/BattleGroundAB.cpp @@ -484,7 +484,7 @@ void BattleGroundAB::Reset() } -void BattleGroundAB::EndBattleGround(uint32 winner) +void BattleGroundAB::EndBattleGround(Team winner) { //win reward 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; for (int i = 0; i < BG_AB_NODES_MAX; ++i) diff --git a/src/game/BattleGroundAB.h b/src/game/BattleGroundAB.h index 4ecdd9526..debe1738d 100644 --- a/src/game/BattleGroundAB.h +++ b/src/game/BattleGroundAB.h @@ -188,7 +188,7 @@ class BattleGroundAB : public BattleGround void HandleAreaTrigger(Player *Source, uint32 Trigger); virtual bool SetupBattleGround(); virtual void Reset(); - void EndBattleGround(uint32 winner); + void EndBattleGround(Team winner); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); /* Scorekeeping */ @@ -200,8 +200,8 @@ class BattleGroundAB : public BattleGround virtual void EventPlayerClickedOnFlag(Player *source, GameObject* target_obj); /* achievement req. */ - bool IsAllNodesConrolledByTeam(uint32 team) const; // overwrited - bool IsTeamScores500Disadvantage(uint32 team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; } + bool IsAllNodesConrolledByTeam(Team team) const; // overwrited + bool IsTeamScores500Disadvantage(Team team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; } private: /* Gameobject spawning/despawning */ void _CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay); diff --git a/src/game/BattleGroundAV.cpp b/src/game/BattleGroundAV.cpp index 8dfb8870b..ea8fed33d 100644 --- a/src/game/BattleGroundAV.cpp +++ b/src/game/BattleGroundAV.cpp @@ -290,7 +290,7 @@ void BattleGroundAV::AddPlayer(Player *plr) m_PlayerScores[plr->GetGUID()] = sc; } -void BattleGroundAV::EndBattleGround(uint32 winner) +void BattleGroundAV::EndBattleGround(Team winner) { // calculate bonuskills for both teams: uint32 tower_survived[BG_TEAMS_COUNT] = {0, 0}; @@ -316,7 +316,7 @@ void BattleGroundAV::EndBattleGround(uint32 winner) ++mines_owned[m_Mine_Owner[i]]; // 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 }; 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) { - MANGOS_ASSERT(m_Nodes[node].Owner != BG_AV_TEAM_NEUTRAL) - 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 DestroyNode(node); @@ -433,14 +433,14 @@ void BattleGroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node) // despawn marshal (one of those guys protecting the boss) SpawnEvent(BG_AV_MARSHAL_A_SOUTH + tmp, 0, false); - UpdateScore(GetOtherTeamIndex(owner), (-1) * BG_AV_RES_TOWER); - RewardReputationToTeam((owner == BG_TEAM_ALLIANCE) ? BG_AV_FACTION_A : BG_AV_FACTION_H, m_RepTowerDestruction, owner); - RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_TOWER), owner); - 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); + UpdateScore(GetOtherTeamIndex(ownerTeamIdx), (-1) * BG_AV_RES_TOWER); + RewardReputationToTeam((ownerTeam == ALLIANCE) ? BG_AV_FACTION_A : BG_AV_FACTION_H, m_RepTowerDestruction, ownerTeam); + RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_TOWER), ownerTeam); + SendYell2ToAll(LANG_BG_AV_TOWER_TAKEN, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), (ownerTeam == ALLIANCE) ? LANG_BG_ALLY : LANG_BG_HORDE); } 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) return (m_Mine_Owner[BG_AV_NORTH_MINE] == GetTeamIndexByTeamId(team)); diff --git a/src/game/BattleGroundAV.h b/src/game/BattleGroundAV.h index c24807c43..d0b58dd60 100644 --- a/src/game/BattleGroundAV.h +++ b/src/game/BattleGroundAV.h @@ -339,13 +339,13 @@ class BattleGroundAV : public BattleGround void HandleKillPlayer(Player* player, Player *killer); void HandleKillUnit(Creature *creature, Player *killer); 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); - static BattleGroundAVTeamIndex GetAVTeamIndexByTeamId(uint32 Team) { return BattleGroundAVTeamIndex(GetTeamIndexByTeamId(Team)); } + static BattleGroundAVTeamIndex GetAVTeamIndexByTeamId(Team team) { return BattleGroundAVTeamIndex(GetTeamIndexByTeamId(team)); } private: /* Nodes occupying */ void EventPlayerAssaultsPoint(Player* player, BG_AV_Nodes node); diff --git a/src/game/BattleGroundEY.cpp b/src/game/BattleGroundEY.cpp index 2f7697f52..a8be71d28 100644 --- a/src/game/BattleGroundEY.cpp +++ b/src/game/BattleGroundEY.cpp @@ -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_HonorScoreTics[team_index] += Points; if (m_HonorScoreTics[team_index] >= m_HonorTics ) { - RewardHonorToTeam(GetBonusHonorFromKill(1), Team); + RewardHonorToTeam(GetBonusHonorFromKill(1), team); m_HonorScoreTics[team_index] -= m_HonorTics; } - UpdateTeamScore(Team); + UpdateTeamScore(team); } void BattleGroundEY::CheckSomeoneJoinedPoint() @@ -211,14 +211,14 @@ void BattleGroundEY::UpdatePointStatuses() //point is fully horde's m_PointBarStatus[point] = BG_EY_PROGRESS_BAR_HORDE_CONTROLLED; - uint32 pointOwnerTeamId = 0; + Team pointOwnerTeamId; //find which team should own this point if (m_PointBarStatus[point] <= BG_EY_PROGRESS_BAR_NEUTRAL_LOW) pointOwnerTeamId = HORDE; else if (m_PointBarStatus[point] >= BG_EY_PROGRESS_BAR_NEUTRAL_HIGH) pointOwnerTeamId = ALLIANCE; else - pointOwnerTeamId = EY_POINT_NO_OWNER; + pointOwnerTeamId = TEAM_NONE; 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) { score = BG_EY_MAX_TEAM_SCORE; - EndBattleGround(Team); + EndBattleGround(team); } - if (Team == ALLIANCE) + if (team == ALLIANCE) UpdateWorldState(EY_ALLIANCE_RESOURCES, score); else UpdateWorldState(EY_HORDE_RESOURCES, score); } -void BattleGroundEY::EndBattleGround(uint32 winner) +void BattleGroundEY::EndBattleGround(Team winner) { //win reward if (winner == ALLIANCE) @@ -272,28 +272,28 @@ void BattleGroundEY::EndBattleGround(uint32 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]); else 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!!! if (m_PointState[Point] == EY_POINT_UNDER_CONTROL) { UpdateWorldState(PointsIconStruct[Point].WorldStateControlIndex, 0); - if (Team == ALLIANCE) + if (team == ALLIANCE) UpdateWorldState(PointsIconStruct[Point].WorldStateAllianceControlledIndex, 1); else UpdateWorldState(PointsIconStruct[Point].WorldStateHordeControlledIndex, 1); } else { - if (Team == ALLIANCE) + if (team == ALLIANCE) UpdateWorldState(PointsIconStruct[Point].WorldStateAllianceControlledIndex, 0); else UpdateWorldState(PointsIconStruct[Point].WorldStateHordeControlledIndex, 0); @@ -427,7 +427,7 @@ void BattleGroundEY::Reset() 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_PointBarStatus[i] = BG_EY_PROGRESS_BAR_STATE_MIDDLE; m_PlayersNearPoint[i].clear(); @@ -554,32 +554,32 @@ void BattleGroundEY::EventTeamLostPoint(Player *Source, uint32 Point) return; // neutral node - uint32 Team = m_PointOwnedByTeam[Point]; + Team team = m_PointOwnedByTeam[Point]; - if (!Team) + if (!team) return; - if (Team == ALLIANCE) - m_TeamPointsCount[BG_TEAM_ALLIANCE]--; + if (team == ALLIANCE) + --m_TeamPointsCount[BG_TEAM_ALLIANCE]; else - m_TeamPointsCount[BG_TEAM_HORDE]--; + --m_TeamPointsCount[BG_TEAM_HORDE]; // it's important to set the OwnedBy before despawning spiritguides, else // 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; SpawnEvent(Point, BG_EYE_NEUTRAL_TEAM, true); // will despawn alliance/horde //buff isn't despawned - if (Team == ALLIANCE) + if (team == ALLIANCE) SendMessageToAll(LoosingPointTypes[Point].MessageIdAlliance,CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); else SendMessageToAll(LoosingPointTypes[Point].MessageIdHorde,CHAT_MSG_BG_SYSTEM_HORDE, Source); - UpdatePointsIcons(Team, Point); - UpdatePointsCount(Team); + UpdatePointsIcons(team, Point); + UpdatePointsCount(team); } void BattleGroundEY::EventTeamCapturedPoint(Player *Source, uint32 Point) @@ -587,23 +587,23 @@ void BattleGroundEY::EventTeamCapturedPoint(Player *Source, uint32 Point) if (GetStatus() != STATUS_IN_PROGRESS) return; - uint32 Team = Source->GetTeam(); + Team team = Source->GetTeam(); - m_TeamPointsCount[GetTeamIndexByTeamId(Team)]++; - SpawnEvent(Point, GetTeamIndexByTeamId(Team), true); + ++m_TeamPointsCount[GetTeamIndexByTeamId(team)]; + SpawnEvent(Point, GetTeamIndexByTeamId(team), true); //buff isn't respawned - m_PointOwnedByTeam[Point] = Team; + m_PointOwnedByTeam[Point] = team; m_PointState[Point] = EY_POINT_UNDER_CONTROL; - if (Team == ALLIANCE) + if (team == ALLIANCE) SendMessageToAll(CapturingPointTypes[Point].MessageIdAlliance,CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); else SendMessageToAll(CapturingPointTypes[Point].MessageIdHorde,CHAT_MSG_BG_SYSTEM_HORDE, Source); - UpdatePointsIcons(Team, Point); - UpdatePointsCount(Team); + UpdatePointsIcons(team, Point); + UpdatePointsCount(team); } 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; - uint8 team_id = 0; + BattleGroundTeamIndex team_id; if (Source->GetTeam() == ALLIANCE) { team_id = BG_TEAM_ALLIANCE; @@ -752,7 +752,7 @@ WorldSafeLocsEntry const *BattleGroundEY::GetClosestGraveYard(Player* player) return nearestEntry; } -bool BattleGroundEY::IsAllNodesConrolledByTeam(uint32 team) const +bool BattleGroundEY::IsAllNodesConrolledByTeam(Team team) const { for(int i = 0; i < BG_EY_NODES_MAX; ++i) if (m_PointState[i] != EY_POINT_UNDER_CONTROL || m_PointOwnedByTeam[i] != team) diff --git a/src/game/BattleGroundEY.h b/src/game/BattleGroundEY.h index 5fbdae64b..6f2403de2 100644 --- a/src/game/BattleGroundEY.h +++ b/src/game/BattleGroundEY.h @@ -268,8 +268,8 @@ class BattleGroundEY : public BattleGround virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); virtual bool SetupBattleGround(); virtual void Reset(); - void UpdateTeamScore(uint32 Team); - void EndBattleGround(uint32 winner); + void UpdateTeamScore(Team team); + void EndBattleGround(Team winner); void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); virtual void FillInitialWorldStates(WorldPacket& data, uint32& count); void SetDroppedFlagGUID(uint64 guid) { m_DroppedFlagGUID = guid;} @@ -280,14 +280,14 @@ class BattleGroundEY : public BattleGround virtual void EventPlayerDroppedFlag(Player *Source); /* achievement req. */ - bool IsAllNodesConrolledByTeam(uint32 team) const; + bool IsAllNodesConrolledByTeam(Team team) const; private: void EventPlayerCapturedFlag(Player *Source, BG_EY_Nodes node); void EventTeamCapturedPoint(Player *Source, uint32 Point); void EventTeamLostPoint(Player *Source, uint32 Point); - void UpdatePointsCount(uint32 Team); - void UpdatePointsIcons(uint32 Team, uint32 Point); + void UpdatePointsCount(Team team); + void UpdatePointsIcons(Team team, uint32 Point); /* Point status updating procedures */ void CheckSomeoneLeftPoint(); @@ -295,14 +295,14 @@ class BattleGroundEY : public BattleGround void UpdatePointStatuses(); /* Scorekeeping */ - uint32 GetTeamScore(uint32 Team) const { return m_TeamScores[GetTeamIndexByTeamId(Team)]; } - void AddPoints(uint32 Team, uint32 Points); + uint32 GetTeamScore(Team team) const { return m_TeamScores[GetTeamIndexByTeamId(team)]; } + void AddPoints(Team team, uint32 Points); - void RemovePoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] -= Points; } - void SetTeamPoint(uint32 TeamID, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] = Points; } + void RemovePoint(Team team, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(team)] -= Points; } + void SetTeamPoint(Team team, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(team)] = Points; } uint32 m_HonorScoreTics[2]; - uint32 m_TeamPointsCount[2]; + uint32 m_TeamPointsCount[BG_TEAMS_COUNT]; uint32 m_Points_Trigger[BG_EY_NODES_MAX]; @@ -312,7 +312,7 @@ class BattleGroundEY : public BattleGround int32 m_FlagsTimer; int32 m_TowerCapCheckTimer; - uint32 m_PointOwnedByTeam[BG_EY_NODES_MAX]; + Team m_PointOwnedByTeam[BG_EY_NODES_MAX]; uint8 m_PointState[BG_EY_NODES_MAX]; int32 m_PointBarStatus[BG_EY_NODES_MAX]; typedef std::vector PlayersNearPointType; diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index 6f5b2c808..77be7c0b8 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -435,7 +435,7 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data ) // set the destination instance id _player->SetBattleGroundId(bg->GetInstanceID(), bgTypeId); // set the destination team - _player->SetBGTeam(ginfo.Team); + _player->SetBGTeam(ginfo.GroupTeam); // bg->HandleBeforeTeleportToBattleGround(_player); sBattleGroundMgr.SendToBattleGround(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId); // 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 (ginfo.IsRated) { - ArenaTeam * at = sObjectMgr.GetArenaTeamById(ginfo.Team); + ArenaTeam * at = sObjectMgr.GetArenaTeamById(ginfo.ArenaTeamId); 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); @@ -605,7 +605,6 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) uint8 arenaslot; // 2v2, 3v3 or 5v5 uint8 asGroup; // asGroup uint8 isRated; // isRated - Group * grp; recv_data >> guid >> arenaslot >> asGroup >> isRated; @@ -655,9 +654,15 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) GroupJoinBattlegroundResult err; + Group * grp = NULL; + // check queue conditions if (!asGroup) { + // you can't join in this way by client + if (isRated) + return; + // check if already in queue if (_player->GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES) //player is already in this queue diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp index 92a20af0d..fc1c96e39 100644 --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -160,7 +160,7 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleG ginfo->IsInvitedToBGInstanceGUID = 0; ginfo->JoinTime = getMSTime(); ginfo->RemoveInviteTime = 0; - ginfo->Team = leader->GetTeam(); + ginfo->GroupTeam = leader->GetTeam(); ginfo->ArenaTeamRating = arenaRating; ginfo->OpponentsTeamRating = 0; @@ -171,7 +171,7 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleG if (!isRated && !isPremade) 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 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! if (!ginfo->ArenaType) { - if (ginfo->Team == HORDE) + if (ginfo->GroupTeam == HORDE) team_index = BG_TEAM_HORDE; } 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! if (!ginfo->ArenaType) { - if (ginfo->Team == HORDE) + if (ginfo->GroupTeam == HORDE) team_index = BG_TEAM_HORDE; } else @@ -322,7 +322,7 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou // mostly people with the highest levels are in battlegrounds, thats why // we count from MAX_BATTLEGROUND_QUEUES - 1 to 0 // 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) { @@ -366,7 +366,7 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou { BattleGround* bg = sBattleGroundMgr.GetBattleGround(group->IsInvitedToBGInstanceGUID, group->BgTypeId); if (bg) - bg->DecreaseInvitedCount(group->Team); + bg->DecreaseInvitedCount(group->GroupTeam); } // remove player queue info @@ -441,11 +441,11 @@ bool BattleGroundQueue::GetPlayerGroupInfoData(const uint64& guid, GroupQueueInf return true; } -bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * bg, uint32 side) +bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * bg, Team side) { // set side if needed if (side) - ginfo->Team = side; + ginfo->GroupTeam = side; if (!ginfo->IsInvitedToBGInstanceGUID) { @@ -458,7 +458,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b // set ArenaTeamId for rated matches if (bg->isArena() && bg->isRated()) - bg->SetArenaTeamIdForTeam(ginfo->Team, ginfo->ArenaTeamId); + bg->SetArenaTeamIdForTeam(ginfo->GroupTeam, ginfo->ArenaTeamId); ginfo->RemoveInviteTime = getMSTime() + INVITE_ACCEPT_WAIT_TIME; @@ -476,7 +476,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b //sBattleGroundMgr.InvitePlayer(plr, bg, ginfo->Team); // set invited player counters - bg->IncreaseInvitedCount(ginfo->Team); + bg->IncreaseInvitedCount(ginfo->GroupTeam); 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) return false; - uint32 teamIndex = BG_TEAM_ALLIANCE; - uint32 otherTeam = BG_TEAM_HORDE; - uint32 otherTeamId = HORDE; + BattleGroundTeamIndex teamIdx = BG_TEAM_ALLIANCE; + BattleGroundTeamIndex otherTeamIdx = BG_TEAM_HORDE; + Team otherTeamId = HORDE; if (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() == minPlayersPerTeam ) { - teamIndex = BG_TEAM_HORDE; - otherTeam = BG_TEAM_ALLIANCE; + teamIdx = BG_TEAM_HORDE; + otherTeamIdx = BG_TEAM_ALLIANCE; otherTeamId = ALLIANCE; } //clear other team's selection - m_SelectionPools[otherTeam].Init(); + m_SelectionPools[otherTeamIdx].Init(); //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 - GroupsQueueType::iterator itr_team = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].begin(); - for(; itr_team != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].end(); ++itr_team) + 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 + teamIdx].end(); ++itr_team) if (ginfo == *itr_team) 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; GroupsQueueType::iterator itr_team2 = itr_team; ++itr_team2; //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 (!(*itr_team2)->IsInvitedToBGInstanceGUID && !m_SelectionPools[otherTeam].AddGroup(*itr_team2, minPlayersPerTeam)) + if (!(*itr_team2)->IsInvitedToBGInstanceGUID && !m_SelectionPools[otherTeamIdx].AddGroup(*itr_team2, minPlayersPerTeam)) break; } - if (m_SelectionPools[otherTeam].GetPlayerCount() != minPlayersPerTeam) + if (m_SelectionPools[otherTeamIdx].GetPlayerCount() != minPlayersPerTeam) 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 - 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 - (*itr)->Team = otherTeamId; + (*itr)->GroupTeam = otherTeamId; //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 GroupsQueueType::iterator itr2 = itr_team; ++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) { - m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIndex].erase(itr2); + m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].erase(itr2); break; } } @@ -783,9 +783,9 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI // 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) - 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) - InviteGroupToBG((*citr), bg, (*citr)->Team); + InviteGroupToBG((*citr), bg, (*citr)->GroupTeam); if (!bg->HasFreeSlots()) { @@ -864,7 +864,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI //invite those selection pools 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) - InviteGroupToBG((*citr), bg2, (*citr)->Team); + InviteGroupToBG((*citr), bg2, (*citr)->GroupTeam); //start bg bg2->StartBattleGround(); //clear structures @@ -891,7 +891,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI // invite those selection pools 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) - InviteGroupToBG((*citr), bg2, (*citr)->Team); + InviteGroupToBG((*citr), bg2, (*citr)->GroupTeam); // start bg bg2->StartBattleGround(); } @@ -1007,7 +1007,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI (*(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); // 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 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]); 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_ALLIANCE].erase(itr_team[BG_TEAM_HORDE]); @@ -1314,7 +1314,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg) else { Player *plr = sObjectMgr.GetPlayer(itr->first); - uint32 team = bg->GetPlayerTeam(itr->first); + Team team = bg->GetPlayerTeam(itr->first); if (!team && plr) team = plr->GetTeam(); 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(); float x, y, z, O; - uint32 team = pl->GetBGTeam(); + Team team = pl->GetBGTeam(); if (team==0) team = pl->GetTeam(); bg->GetTeamStartLoc(team, x, y, z, O); diff --git a/src/game/BattleGroundMgr.h b/src/game/BattleGroundMgr.h index 39d1bcc00..d89fdf94e 100644 --- a/src/game/BattleGroundMgr.h +++ b/src/game/BattleGroundMgr.h @@ -48,7 +48,7 @@ struct PlayerQueueInfo // stores informatio struct GroupQueueInfo // stores information about the group in queue (also used when joined as solo!) { std::map Players; // player queue info map - uint32 Team; // Player team (ALLIANCE/HORDE) + Team GroupTeam; // Player team (ALLIANCE/HORDE) BattleGroundTypeId BgTypeId; // battleground type id bool IsRated; // rated uint8 ArenaType; // 2v2, 3v3, 5v5 or 0 when BG @@ -128,7 +128,7 @@ class BattleGroundQueue //one selection pool for horde, other one for alliance 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_WaitTimeLastPlayer[BG_TEAMS_COUNT][MAX_BATTLEGROUND_BRACKETS]; uint32 m_SumOfWaitTimes[BG_TEAMS_COUNT][MAX_BATTLEGROUND_BRACKETS]; diff --git a/src/game/BattleGroundWS.cpp b/src/game/BattleGroundWS.cpp index 88d25a72a..43ea99e7c 100644 --- a/src/game/BattleGroundWS.cpp +++ b/src/game/BattleGroundWS.cpp @@ -138,9 +138,9 @@ void BattleGroundWS::AddPlayer(Player *plr) 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"); 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) return; @@ -192,7 +192,7 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source) m_LastCapturedFlagTeam = Source->GetTeam(); - uint32 winner = 0; + Team winner = TEAM_NONE; Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); if (Source->GetTeam() == ALLIANCE) @@ -257,7 +257,7 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source) } 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)); } - 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) 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); } -void BattleGroundWS::UpdateTeamScore(uint32 team) +void BattleGroundWS::UpdateTeamScore(Team team) { if (team == ALLIANCE) UpdateWorldState(BG_WS_FLAG_CAPTURES_ALLIANCE, GetTeamScore(team)); @@ -554,10 +554,10 @@ void BattleGroundWS::Reset() m_HonorEndKills = (isBGWeekend) ? 4 : 2; 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 if (winner == ALLIANCE) diff --git a/src/game/BattleGroundWS.h b/src/game/BattleGroundWS.h index 7fe71e060..334d65782 100644 --- a/src/game/BattleGroundWS.h +++ b/src/game/BattleGroundWS.h @@ -115,9 +115,9 @@ class BattleGroundWS : public BattleGround void SetHordeFlagPicker(uint64 guid) { m_FlagKeepers[BG_TEAM_HORDE] = guid; } bool IsAllianceFlagPickedup() const { return m_FlagKeepers[BG_TEAM_ALLIANCE] != 0; } bool IsHordeFlagPickedup() const { return m_FlagKeepers[BG_TEAM_HORDE] != 0; } - void RespawnFlag(uint32 Team, bool captured); - void RespawnFlagAfterDrop(uint32 Team); - uint8 GetFlagState(uint32 team) { return m_FlagState[GetTeamIndexByTeamId(team)]; } + void RespawnFlag(Team team, bool captured); + void RespawnFlagAfterDrop(Team team); + uint8 GetFlagState(Team team) { return m_FlagState[GetTeamIndexByTeamId(team)]; } /* Battleground Events */ virtual void EventPlayerDroppedFlag(Player *Source); @@ -129,22 +129,22 @@ class BattleGroundWS : public BattleGround void HandleKillPlayer(Player *player, Player *killer); bool SetupBattleGround(); virtual void Reset(); - void EndBattleGround(uint32 winner); + void EndBattleGround(Team winner); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); uint32 GetRemainingTimeInMinutes() { return m_EndTimer ? (m_EndTimer-1) / (MINUTE * IN_MILLISECONDS) + 1 : 0; } - void UpdateFlagState(uint32 team, uint32 value); - void UpdateTeamScore(uint32 team); + void UpdateFlagState(Team team, uint32 value); + void UpdateTeamScore(Team team); void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); - void SetDroppedFlagGUID(uint64 guid, uint32 TeamID) { m_DroppedFlagGUID[GetTeamIndexByTeamId(TeamID)] = guid;} - uint64 GetDroppedFlagGUID(uint32 TeamID) { return m_DroppedFlagGUID[GetTeamIndexByTeamId(TeamID)];} + void SetDroppedFlagGUID(uint64 guid, Team team) { m_DroppedFlagGUID[GetTeamIndexByTeamId(team)] = guid;} + uint64 GetDroppedFlagGUID(Team team) { return m_DroppedFlagGUID[GetTeamIndexByTeamId(team)];} virtual void FillInitialWorldStates(WorldPacket& data, uint32& count); /* Scorekeeping */ - uint32 GetTeamScore(uint32 TeamID) const { return m_TeamScores[GetTeamIndexByTeamId(TeamID)]; } - void AddPoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] += Points; } - void SetTeamPoint(uint32 TeamID, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] = Points; } - void RemovePoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] -= Points; } + uint32 GetTeamScore(Team team) const { return m_TeamScores[GetTeamIndexByTeamId(team)]; } + void AddPoint(Team team, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(team)] += Points; } + void SetTeamPoint(Team team, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(team)] = Points; } + void RemovePoint(Team team, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(team)] -= Points; } private: uint64 m_FlagKeepers[BG_TEAMS_COUNT]; @@ -157,6 +157,6 @@ class BattleGroundWS : public BattleGround uint32 m_HonorWinKills; uint32 m_HonorEndKills; uint32 m_EndTimer; - uint32 m_LastCapturedFlagTeam; + Team m_LastCapturedFlagTeam; }; #endif diff --git a/src/game/ChannelMgr.cpp b/src/game/ChannelMgr.cpp index ce5fda782..dd1e05603 100644 --- a/src/game/ChannelMgr.cpp +++ b/src/game/ChannelMgr.cpp @@ -23,7 +23,7 @@ INSTANTIATE_SINGLETON_1( AllianceChannelMgr ); INSTANTIATE_SINGLETON_1( HordeChannelMgr ); -ChannelMgr* channelMgr(uint32 team) +ChannelMgr* channelMgr(Team team) { if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) return &MaNGOS::Singleton::Instance(); // cross-faction diff --git a/src/game/ChannelMgr.h b/src/game/ChannelMgr.h index c0def7d94..29bfc05bd 100644 --- a/src/game/ChannelMgr.h +++ b/src/game/ChannelMgr.h @@ -43,6 +43,6 @@ class ChannelMgr class AllianceChannelMgr : public ChannelMgr {}; class HordeChannelMgr : public ChannelMgr {}; -ChannelMgr* channelMgr(uint32 team); +ChannelMgr* channelMgr(Team team); #endif diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index eea04b777..90740cb1f 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -210,7 +210,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ) { bool disabled = false; - uint32 team = Player::TeamForRace(race_); + Team team = Player::TeamForRace(race_); switch(team) { 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"); if(result2) { - uint32 team_= Player::TeamForRace(race_); + Team team_= Player::TeamForRace(race_); Field* field = result2->Fetch(); 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? if (!AllowTwoSideAccounts) { - uint32 acc_team = 0; - if(acc_race > 0) - acc_team = Player::TeamForRace(acc_race); - - if(acc_team != team_) + if (acc_race == 0 || Player::TeamForRace(acc_race) != team_) { data << (uint8)CHAR_CREATE_PVP_TEAMS_VIOLATION; SendPacket( &data ); diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp index 69888fb94..d010dd902 100644 --- a/src/game/ChatHandler.cpp +++ b/src/game/ChatHandler.cpp @@ -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 ) { - uint32 sidea = GetPlayer()->GetTeam(); - uint32 sideb = player->GetTeam(); - if( sidea != sideb ) + if (GetPlayer()->GetTeam() != player->GetTeam()) { SendWrongFactionNotice(); return; diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 1de4c829c..be412a6bb 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -196,7 +196,7 @@ void Creature::RemoveCorpse() /** * 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); if(!normalInfo) @@ -294,9 +294,9 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data ) 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; m_regenHealth = GetCreatureInfo()->RegenHealth; @@ -682,7 +682,7 @@ bool Creature::AIM_Initialize() 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); 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); if(!cinfo) @@ -1221,8 +1221,7 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map) else guidlow = sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT); - uint16 team = 0; - if (!Create(guidlow, map, data->phaseMask, data->id, team, data)) + if (!Create(guidlow, map, data->phaseMask, data->id, TEAM_NONE, data)) return false; 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 void Creature::SendZoneUnderAttackMessage(Player* attacker) { - uint32 enemy_team = attacker->GetTeam(); + Team enemy_team = attacker->GetTeam(); WorldPacket data(SMSG_ZONE_UNDER_ATTACK, 4); data << uint32(GetZoneId()); diff --git a/src/game/Creature.h b/src/game/Creature.h index 10628e935..931bbdcd6 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -23,6 +23,7 @@ #include "Unit.h" #include "UpdateMask.h" #include "ItemPrototype.h" +#include "SharedDefines.h" #include "LootMgr.h" #include "DBCEnums.h" #include "Database/DatabaseEnv.h" @@ -394,7 +395,7 @@ class MANGOS_DLL_SPEC Creature : public Unit void AddToWorld(); 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); void SelectLevel(const CreatureInfo *cinfo, float percentHealth = 100.0f, float percentMana = 100.0f); 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 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 UpdateAllStats(); void UpdateResistances(uint32 school); @@ -635,8 +636,8 @@ class MANGOS_DLL_SPEC Creature : public Unit void SendAreaSpiritHealerQueryOpcode(Player *pl); protected: - bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL); - bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL); + bool CreateFromProto(uint32 guidlow,uint32 Entry, Team team, const CreatureData *data = NULL); + bool InitEntry(uint32 entry, const CreatureData* data=NULL); void RelocationNotify(); uint32 m_groupLootTimer; // (msecs)timer used for group loot diff --git a/src/game/Group.cpp b/src/game/Group.cpp index 8ce8ecf37..0b9973fd0 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -1589,7 +1589,7 @@ GroupJoinBattlegroundResult Group::CanJoinBattleGroundQueue(BattleGround const* return ERR_BATTLEGROUND_JOIN_FAILED; uint32 arenaTeamId = reference->GetArenaTeamId(arenaSlot); - uint32 team = reference->GetTeam(); + Team team = reference->GetTeam(); // check every member of the group to be able to join for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next()) diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 27bbe8d9d..04a1a9177 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -1551,10 +1551,6 @@ bool ChatHandler::HandleNpcAddCommand(char* args) if (!ExtractUint32KeyFromLink(&args, "Hcreature_entry", id)) return false; - uint32 team; - if (!ExtractOptUInt32(&args, team, 0)) - return false; - Player *chr = m_session->GetPlayer(); float x = chr->GetPositionX(); float y = chr->GetPositionY(); @@ -1563,7 +1559,7 @@ bool ChatHandler::HandleNpcAddCommand(char* args) Map *map = chr->GetMap(); 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; return false; @@ -3191,7 +3187,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args) // create the waypoint creature wpGuid = 0; 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); delete wpCreature; @@ -3311,7 +3307,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args) wpCreature->AddObjectToRemoveList(); // re-create 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); delete wpCreature2; @@ -3615,7 +3611,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) float o = chr->GetOrientation(); 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); delete wpCreature; @@ -3673,7 +3669,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) Map *map = chr->GetMap(); 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); delete pCreature; @@ -3733,7 +3729,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) Map *map = chr->GetMap(); 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); delete pCreature; diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 07ddda67f..bad15139d 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -3892,9 +3892,9 @@ bool ChatHandler::HandleLinkGraveCommand(char* args) char* teamStr = ExtractLiteralArg(&args); - uint32 g_team; + Team g_team; if (!teamStr) - g_team = 0; + g_team = TEAM_NONE; else if (strncmp(teamStr, "horde", strlen(teamStr))==0) g_team = HORDE; else if (strncmp(teamStr, "alliance", strlen(teamStr))==0) @@ -3923,22 +3923,22 @@ bool ChatHandler::HandleLinkGraveCommand(char* args) return false; } - if (sObjectMgr.AddGraveYardLink(g_id,zoneId,g_team)) - PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, g_id,zoneId); + if (sObjectMgr.AddGraveYardLink(g_id, zoneId, g_team)) + PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, g_id, zoneId); else - PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, g_id,zoneId); + PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, g_id, zoneId); return true; } bool ChatHandler::HandleNearGraveCommand(char* args) { - uint32 g_team; + Team g_team; size_t argslen = strlen(args); if(!*args) - g_team = 0; + g_team = TEAM_NONE; else if (strncmp(args, "horde", argslen) == 0) g_team = HORDE; else if (strncmp(args, "alliance", argslen) == 0) @@ -3950,7 +3950,7 @@ bool ChatHandler::HandleNearGraveCommand(char* args) uint32 zone_id = player->GetZoneId(); 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) { diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 1a8d9b2f6..0a5e0c7cd 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -139,7 +139,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) 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 if (receive) diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index b3ad57357..b8990bc36 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -132,7 +132,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) if(level_max >= MAX_LEVEL) level_max = STRONG_MAX_LEVEL; - uint32 team = _player->GetTeam(); + Team team = _player->GetTeam(); uint32 security = GetSecurity(); bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_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(); ObjectGuid friendGuid = ObjectGuid(HIGHGUID_PLAYER, friendLowGuid); - uint32 team = Player::TeamForRace((*result)[1].GetUInt8()); + Team team = Player::TeamForRace((*result)[1].GetUInt8()); delete result; WorldSession * session = sWorld.FindSession(accountId); - if(!session || !session->GetPlayer()) + if (!session || !session->GetPlayer()) return; FriendsResult friendResult = FRIEND_NOT_FOUND; diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index f347cb6b1..b4f632ab2 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -98,7 +98,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() // We're not in BG _player->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE); // reset destination bg team - _player->SetBGTeam(0); + _player->SetBGTeam(TEAM_NONE); } // join to bg case else if(BattleGround *bg = _player->GetBattleGround()) diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index bed56f0b1..791c8cea4 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -384,7 +384,7 @@ void WorldSession::SendSpiritResurrect() Corpse *corpse = _player->GetCorpse(); if(corpse) 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 _player->SpawnCorpseBones(); @@ -393,7 +393,7 @@ void WorldSession::SendSpiritResurrect() if(corpseGrave) { 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) _player->TeleportTo(corpseGrave->map_id, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation()); diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 372c01ee7..c334551cf 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1735,7 +1735,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa { TemporarySummon* pCreature = new TemporarySummon(GetObjectGuid()); - uint32 team = 0; + Team team = TEAM_NONE; if (GetTypeId()==TYPEID_PLAYER) team = ((Player*)this)->GetTeam(); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 91c96398d..4b7670069 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1724,7 +1724,7 @@ bool ObjectMgr::GetPlayerNameByGUID(ObjectGuid guid, std::string &name) const return false; } -uint32 ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const +Team ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const { // prevent DB access for online player if (Player* player = GetPlayer(guid)) @@ -1741,7 +1741,7 @@ uint32 ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const return Player::TeamForRace(race); } - return 0; + return TEAM_NONE; } uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const @@ -5771,7 +5771,7 @@ void ObjectMgr::LoadEventIdScripts() 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; float dist; @@ -5834,7 +5834,7 @@ void ObjectMgr::GetTaxiPath( uint32 source, uint32 destination, uint32 &path, ui 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; @@ -5904,33 +5904,33 @@ void ObjectMgr::LoadGraveyardZones() uint32 team = fields[2].GetUInt32(); 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); continue; } 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; } - 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; } - 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; } - if(!AddGraveYardLink(safeLocId,zoneId,team,false)) - sLog.outErrorDb("Table `game_graveyard_zone` has a duplicate record for Graveyard (ID: %u) and Zone (ID: %u), skipped.",safeLocId,zoneId); + 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); } while( result->NextRow() ); delete result; @@ -5939,7 +5939,7 @@ void ObjectMgr::LoadGraveyardZones() 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 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) { - 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; } @@ -5987,7 +5987,7 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float // skip enemy faction graveyard // 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; // find now nearest graveyard at other (continent) map @@ -6065,7 +6065,7 @@ GraveYardData const* ObjectMgr::FindGraveYardData(uint32 id, uint32 zoneId) cons 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)) return false; @@ -6081,7 +6081,7 @@ bool ObjectMgr::AddGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool inD if(inDB) { 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; @@ -8235,7 +8235,7 @@ bool PlayerCondition::Meets(Player const * player) const return faction && player->GetReputationMgr().GetRank(faction) >= ReputationRank(value2); } case CONDITION_TEAM: - return player->GetTeam() == value1; + return uint32(player->GetTeam()) == value1; case CONDITION_SKILL: return player->HasSkill(value1) && player->GetBaseSkillValue(value1) >= value2; case CONDITION_QUESTREWARDED: diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 1740d80f4..ab56405c1 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -586,7 +586,7 @@ struct WeatherZoneChances struct GraveYardData { uint32 safeLocId; - uint32 team; + Team team; }; typedef std::multimap GraveYardMap; typedef std::pair GraveYardMapBounds; @@ -799,13 +799,13 @@ class ObjectMgr uint64 GetPlayerGUIDByName(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 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); - 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 { @@ -833,8 +833,8 @@ class ObjectMgr GossipText const* GetGossipText(uint32 Text_ID) const; - WorldSafeLocsEntry const *GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team); - bool AddGraveYardLink(uint32 id, uint32 zone, uint32 team, bool inDB = true); + WorldSafeLocsEntry const *GetClosestGraveYard(float x, float y, float z, uint32 MapId, Team team); + bool AddGraveYardLink(uint32 id, uint32 zone, Team team, bool inDB = true); void LoadGraveyardZones(); GraveYardData const* FindGraveYardData(uint32 id, uint32 zone) const; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 9021f4688..444cf998c 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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(); @@ -226,13 +226,13 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString( const std::string& values, uint { uint32 cost; uint32 path; - sObjectMgr.GetTaxiPath(m_TaxiDestinations[i-1],m_TaxiDestinations[i],path,cost); - if(!path) + sObjectMgr.GetTaxiPath(m_TaxiDestinations[i-1],m_TaxiDestinations[i], path, cost); + if (!path) return false; } // 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 true; @@ -6205,10 +6205,10 @@ void Player::CheckAreaExploreAndOutdoor() } } -uint32 Player::TeamForRace(uint8 race) +Team Player::TeamForRace(uint8 race) { ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race); - if(!rEntry) + if (!rEntry) { sLog.outError("Race %u not found in DBC: wrong DBC files?",uint32(race)); 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); - return ALLIANCE; + return TEAM_NONE; } uint32 Player::getFactionForRace(uint8 race) @@ -6239,7 +6239,7 @@ uint32 Player::getFactionForRace(uint8 race) void Player::setFactionForRace(uint8 race) { m_team = TeamForRace(race); - setFaction( getFactionForRace(race) ); + setFaction(getFactionForRace(race)); } ReputationRank Player::GetReputationRank(uint32 faction) const @@ -15022,7 +15022,7 @@ void Player::_LoadBGData(QueryResult* result) Field *fields = result->Fetch(); /* bgInstanceID, bgTeam, x, y, z, o, map, taxi[0], taxi[1], mountSpell */ 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 fields[2].GetFloat(), // X fields[3].GetFloat(), // Y @@ -15537,20 +15537,20 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) SetUInt32Value(PLAYER_CHOSEN_TITLE, curTitle); // Not finish taxi flight path - if(m_bgData.HasTaxiPath()) + if (m_bgData.HasTaxiPath()) { m_taxi.ClearTaxiDestinations(); for (int i = 0; i < 2; ++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 TaxiNodesEntry const* nodeEntry = NULL; - if(uint32 node_id = m_taxi.GetTaxiSource()) + if (uint32 node_id = m_taxi.GetTaxiSource()) 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()); RelocateToHomebind(); @@ -18488,7 +18488,7 @@ void Player::ContinueTaxiFlight() 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(); // 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 */ 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); } } diff --git a/src/game/Player.h b/src/game/Player.h index 67daa22d9..132546090 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -982,7 +982,7 @@ class MANGOS_DLL_SPEC PlayerTaxi void AppendTaximaskTo(ByteBuffer& data, bool all); // Destinations - bool LoadTaxiDestinationsFromString(const std::string& values, uint32 team); + bool LoadTaxiDestinationsFromString(const std::string& values, Team team); std::string SaveTaxiDestinationsToString(); void ClearTaxiDestinations() { m_TaxiDestinations.clear(); } @@ -1009,7 +1009,7 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi); struct BGData { 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, @@ -1020,7 +1020,7 @@ struct BGData uint8 bgAfkReportedCount; 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; @@ -1984,8 +1984,8 @@ class MANGOS_DLL_SPEC Player : public Unit void CheckAreaExploreAndOutdoor(void); - static uint32 TeamForRace(uint8 race); - uint32 GetTeam() const { return m_team; } + static Team TeamForRace(uint8 race); + Team GetTeam() const { return m_team; } static uint32 getFactionForRace(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; } void SetBattleGroundEntryPoint(); - void SetBGTeam(uint32 team) { m_bgData.bgTeam = team; } - uint32 GetBGTeam() const { return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam(); } + void SetBGTeam(Team team) { m_bgData.bgTeam = team; } + Team GetBGTeam() const { return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam(); } void LeaveBattleground(bool teleportToEntryPoint = true); bool CanJoinToBattleground() const; @@ -2497,7 +2497,7 @@ class MANGOS_DLL_SPEC Player : public Unit void outDebugStatsValues() const; ObjectGuid m_lootGuid; - uint32 m_team; + Team m_team; uint32 m_nextSave; time_t m_speakTime; uint32 m_speakCount; diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 0d0fb8427..16399c04a 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -519,16 +519,12 @@ enum Language #define LANGUAGES_COUNT 19 +// In fact !=0 values is alliance/horde root faction ids 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, 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 diff --git a/src/game/SocialMgr.cpp b/src/game/SocialMgr.cpp index 7d216e85c..de2f3d6be 100644 --- a/src/game/SocialMgr.cpp +++ b/src/game/SocialMgr.cpp @@ -186,7 +186,7 @@ void SocialMgr::GetFriendInfo(Player *player, uint32 friend_lowguid, FriendInfo Player *pFriend = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, friend_lowguid)); - uint32 team = player->GetTeam(); + Team team = player->GetTeam(); AccountTypes security = player->GetSession()->GetSecurity(); bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_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) return; - uint32 team = player->GetTeam(); + Team team = player->GetTeam(); AccountTypes security = player->GetSession()->GetSecurity(); uint32 guid = player->GetGUIDLow(); AccountTypes gmLevelInWhoList = AccountTypes(sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST)); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 88b31a042..1785cc189 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -5627,12 +5627,9 @@ void Spell::EffectSummonObjectWild(SpellEffectIndex eff_idx) { 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) - team = HORDE; - - ((BattleGroundWS*)bg)->SetDroppedFlagGUID(pGameObj->GetGUID(),team); + ((BattleGroundWS*)bg)->SetDroppedFlagGUID(pGameObj->GetGUID(), team); } break; } @@ -7031,7 +7028,7 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc) if (Totem *OldTotem = m_caster->GetTotem(TotemSlot(slot))) OldTotem->UnSummon(); - uint32 team = 0; + Team team = TEAM_NONE; if (m_caster->GetTypeId()==TYPEID_PLAYER) team = ((Player*)m_caster)->GetTeam(); diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp index 21db9ab8b..4c7f3da25 100644 --- a/src/game/Vehicle.cpp +++ b/src/game/Vehicle.cpp @@ -61,13 +61,13 @@ void Vehicle::Update(uint32 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); Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE); - if(!InitEntry(Entry, team)) + if(!InitEntry(Entry)) return false; m_defaultMovementType = IDLE_MOTION_TYPE; diff --git a/src/game/Vehicle.h b/src/game/Vehicle.h index c191c094f..50bb6296e 100644 --- a/src/game/Vehicle.h +++ b/src/game/Vehicle.h @@ -23,6 +23,7 @@ #include "ObjectGuid.h" #include "Creature.h" #include "Unit.h" +#include "SharedDefines.h" class Vehicle : public Creature { @@ -33,7 +34,7 @@ class Vehicle : public Creature void AddToWorld(); 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 Update(uint32 diff); // overwrite virtual Creature::Update and Unit::Update diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4864eea3c..85afd169e 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10781" + #define REVISION_NR "10782" #endif // __REVISION_NR_H__