Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 09f13547c1321ba9badd004d52ba4cfb639759f8 Mon Sep 17 00:00:00 2001
- From: Bodeguero <joaocarlos.jc.souza@gmail.com>
- Date: Tue, 26 Jul 2016 12:34:53 -0400
- Subject: [PATCH] Core/Fixes: Added System CFBG
- * Update and Fixed All Bugs
- ---
- src/server/game/Battlegrounds/Arena.cpp | 6 +-
- src/server/game/Battlegrounds/Battleground.cpp | 52 +--
- src/server/game/Battlegrounds/Battleground.h | 4 +-
- src/server/game/Battlegrounds/BattlegroundMgr.cpp | 3 +-
- .../game/Battlegrounds/BattlegroundQueue.cpp | 84 +++--
- src/server/game/Battlegrounds/BattlegroundQueue.h | 13 +-
- .../game/Battlegrounds/Zones/BattlegroundAB.cpp | 4 +-
- .../game/Battlegrounds/Zones/BattlegroundAV.cpp | 21 +-
- .../game/Battlegrounds/Zones/BattlegroundWS.cpp | 7 +-
- src/server/game/CrossFactionBG/Cfbg.cpp | 356 +++++++++++++++++++++
- src/server/game/CrossFactionBG/Cfbg.h | 61 ++++
- src/server/game/Entities/Player/Player.cpp | 118 +++++--
- src/server/game/Entities/Player/Player.h | 40 ++-
- src/server/game/Entities/Unit/Unit.cpp | 17 +-
- src/server/game/Entities/Unit/Unit.h | 12 +-
- src/server/game/Handlers/BattleGroundHandler.cpp | 4 +-
- src/server/game/Handlers/CharacterHandler.cpp | 5 +-
- src/server/game/Handlers/ChatHandler.cpp | 18 +-
- src/server/game/Handlers/MiscHandler.cpp | 17 +-
- src/server/game/Handlers/QueryHandler.cpp | 4 +-
- src/server/game/World/World.cpp | 4 +-
- src/server/game/World/World.h | 3 +-
- src/server/worldserver/worldserver.conf.dist | 13 +
- 23 files changed, 750 insertions(+), 116 deletions(-)
- create mode 100644 src/server/game/CrossFactionBG/Cfbg.cpp
- create mode 100644 src/server/game/CrossFactionBG/Cfbg.h
- diff --git a/src/server/game/Battlegrounds/Arena.cpp b/src/server/game/Battlegrounds/Arena.cpp
- index 861df5f..4f220ea 100644
- --- a/src/server/game/Battlegrounds/Arena.cpp
- +++ b/src/server/game/Battlegrounds/Arena.cpp
- @@ -40,9 +40,9 @@ Arena::Arena()
- void Arena::AddPlayer(Player* player)
- {
- Battleground::AddPlayer(player);
- - PlayerScores[player->GetGUID().GetCounter()] = new ArenaScore(player->GetGUID(), player->GetBGTeam());
- + PlayerScores[player->GetGUID().GetCounter()] = new ArenaScore(player->GetGUID(), player->GetTeam());
- - if (player->GetBGTeam() == ALLIANCE) // gold
- + if (player->GetTeam() == ALLIANCE) // gold
- {
- if (player->GetTeam() == HORDE)
- player->CastSpell(player, SPELL_HORDE_GOLD_FLAG, true);
- @@ -249,4 +249,4 @@ void Arena::EndBattleground(uint32 winner)
- // end battleground
- Battleground::EndBattleground(winner);
- -}
- +}
- \ No newline at end of file
- diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
- index 12a40e3..ee9509f 100644
- --- a/src/server/game/Battlegrounds/Battleground.cpp
- +++ b/src/server/game/Battlegrounds/Battleground.cpp
- @@ -286,7 +286,7 @@ inline void Battleground::_CheckSafePositions(uint32 diff)
- if (Player* player = ObjectAccessor::FindPlayer(itr->first))
- {
- Position pos = player->GetPosition();
- - Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam()));
- + Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetTeam()));
- if (pos.GetExactDistSq(startPos) > maxDist)
- {
- TC_LOG_DEBUG("bg.battleground", "BATTLEGROUND: Sending %s back to start location (map: %u) (possible exploit)", player->GetName().c_str(), GetMapId());
- @@ -501,7 +501,7 @@ inline void Battleground::_ProcessJoin(uint32 diff)
- WorldPacket status;
- BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(m_TypeID, GetArenaType());
- uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId);
- - sBattlegroundMgr->BuildBattlegroundStatusPacket(&status, this, queueSlot, STATUS_IN_PROGRESS, 0, GetStartTime(), GetArenaType(), player->GetBGTeam());
- + sBattlegroundMgr->BuildBattlegroundStatusPacket(&status, this, queueSlot, STATUS_IN_PROGRESS, 0, GetStartTime(), GetArenaType(), player->GetTeam());
- player->SendDirectMessage(&status);
- player->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
- @@ -670,22 +670,36 @@ void Battleground::RewardHonorToTeam(uint32 Honor, uint32 TeamID)
- UpdatePlayerScore(player, SCORE_BONUS_HONOR, Honor);
- }
- -void Battleground::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID)
- +void Battleground::RewardReputationToTeam(uint32 a_faction_id, uint32 h_faction_id, uint32 Reputation, uint32 TeamID)
- {
- - FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id);
- - if (!factionEntry)
- - return;
- + FactionEntry const* a_factionEntry = sFactionStore.LookupEntry(a_faction_id);
- + FactionEntry const* h_factionEntry = sFactionStore.LookupEntry(h_faction_id);
- for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
- {
- Player* player = _GetPlayerForTeam(TeamID, itr, "RewardReputationToTeam");
- - if (!player)
- - continue;
- + if (!a_factionEntry || !h_factionEntry)
- + return;
- - uint32 repGain = Reputation;
- - AddPct(repGain, player->GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN));
- - AddPct(repGain, player->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, faction_id));
- - player->GetReputationMgr().ModifyReputation(factionEntry, repGain);
- + for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
- + {
- + if (itr->second.OfflineRemoveTime)
- + continue;
- +
- + Player* player = ObjectAccessor::FindPlayer(itr->first);
- +
- + if (!player)
- + {
- + TC_LOG_ERROR("bg.battleground", "BattleGround:RewardReputationToTeam: %u not found!", itr->first);
- + continue;
- + }
- + uint32 team = player->GetTeam();
- + if (team == TeamID)
- + if (Player* player = _GetPlayerForTeam(TeamID, itr, "RewardReputationToTeam"))
- + {
- + player->GetReputationMgr().ModifyReputation(player->GetCFSTeam() == ALLIANCE ? a_factionEntry : h_factionEntry, Reputation);
- + }
- + }
- }
- }
- @@ -839,7 +853,7 @@ void Battleground::EndBattleground(uint32 winner)
- player->SendDirectMessage(&pvpLogData);
- WorldPacket data;
- - sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType(), player->GetBGTeam());
- + sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType(), player->GetTeam());
- player->SendDirectMessage(&data);
- player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, 1);
- }
- @@ -958,6 +972,7 @@ void Battleground::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool Sen
- if (player)
- {
- + player->FitPlayerInTeam(false, this);
- // Do next only if found in battleground
- player->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG.
- // reset destination bg team
- @@ -1026,7 +1041,7 @@ void Battleground::AddPlayer(Player* player)
- // score struct must be created in inherited class
- - uint32 team = player->GetBGTeam();
- + uint32 team = player->GetTeam();
- BattlegroundPlayer bp;
- bp.OfflineRemoveTime = 0;
- @@ -1077,6 +1092,7 @@ void Battleground::AddPlayer(Player* player)
- // setup BG group membership
- PlayerAddedToBGCheckIfBGIsRunning(player);
- AddOrSetPlayerToCorrectBgGroup(player, team);
- + player->FitPlayerInTeam(true, this);
- }
- // this method adds player to his team's bg group, or sets his correct group if player is already in bg group
- @@ -1146,8 +1162,8 @@ void Battleground::EventPlayerLoggedOut(Player* player)
- // 1 player is logging out, if it is the last, then end arena!
- if (isArena())
- - if (GetAlivePlayersCountByTeam(player->GetBGTeam()) <= 1 && GetPlayersCountByTeam(GetOtherTeam(player->GetBGTeam())))
- - EndBattleground(GetOtherTeam(player->GetBGTeam()));
- + if (GetAlivePlayersCountByTeam(player->GetTeam()) <= 1 && GetPlayersCountByTeam(GetOtherTeam(player->GetTeam())))
- + EndBattleground(GetOtherTeam(player->GetTeam()));
- }
- }
- @@ -1770,7 +1786,7 @@ void Battleground::PlayerAddedToBGCheckIfBGIsRunning(Player* player)
- BuildPvPLogDataPacket(data);
- player->SendDirectMessage(&data);
- - sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType(), player->GetBGTeam());
- + sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType(), player->GetTeam());
- player->SendDirectMessage(&data);
- }
- @@ -1862,4 +1878,4 @@ bool Battleground::CheckAchievementCriteriaMeet(uint32 criteriaId, Player const*
- uint8 Battleground::GetUniqueBracketId() const
- {
- return GetMinLevel() / 10;
- -}
- +}
- \ No newline at end of file
- diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h
- index ec17b94..2c95a42 100644
- --- a/src/server/game/Battlegrounds/Battleground.h
- +++ b/src/server/game/Battlegrounds/Battleground.h
- @@ -365,7 +365,7 @@ class TC_GAME_API Battleground
- void CastSpellOnTeam(uint32 SpellID, uint32 TeamID);
- void RemoveAuraOnTeam(uint32 SpellID, uint32 TeamID);
- void RewardHonorToTeam(uint32 Honor, uint32 TeamID);
- - void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID);
- + void RewardReputationToTeam(uint32 a_faction_id, uint32 h_faction_id, uint32 Reputation, uint32 TeamID);
- void UpdateWorldState(uint32 Field, uint32 Value);
- void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player* player);
- virtual void EndBattleground(uint32 winner);
- @@ -610,4 +610,4 @@ class TC_GAME_API Battleground
- float m_StartMaxDist;
- uint32 ScriptId;
- };
- -#endif
- +#endif
- \ No newline at end of file
- diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
- index 745322f..bebfec5 100644
- --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp
- +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
- @@ -699,7 +699,7 @@ void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, Batt
- if (Battleground* bg = GetBattleground(instanceId, bgTypeId))
- {
- uint32 mapid = bg->GetMapId();
- - uint32 team = player->GetBGTeam();
- + uint32 team = player->GetTeam();
- if (team == 0)
- team = player->GetTeam();
- @@ -1029,4 +1029,3 @@ void BattlegroundMgr::RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 ins
- {
- bgDataStore[bgTypeId].m_Battlegrounds.erase(instanceId);
- }
- -
- diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
- index ceda30d..c06de1e 100644
- --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp
- +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
- @@ -154,6 +154,10 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr
- index += BG_TEAMS_COUNT;
- if (ginfo->Team == HORDE)
- index++;
- +
- + if (sWorld->getBoolConfig(CROSSFACTION_SYSTEM_BATTLEGROUNDS) && ArenaType == 0)
- + index = BG_QUEUE_CROSSFACTION;
- +
- TC_LOG_DEBUG("bg.battleground", "Adding Group to BattlegroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracketId, index);
- uint32 lastOnlineTime = getMSTime();
- @@ -198,30 +202,58 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr
- {
- if (Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(ginfo->BgTypeId))
- {
- - uint32 MinPlayers = bg->GetMinPlayersPerTeam();
- - uint32 qHorde = 0;
- - uint32 qAlliance = 0;
- - uint32 q_min_level = bracketEntry->minLevel;
- - uint32 q_max_level = bracketEntry->maxLevel;
- - GroupsQueueType::const_iterator itr;
- - for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].end(); ++itr)
- - if (!(*itr)->IsInvitedToBGInstanceGUID)
- - qAlliance += (*itr)->Players.size();
- - for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].end(); ++itr)
- - if (!(*itr)->IsInvitedToBGInstanceGUID)
- - qHorde += (*itr)->Players.size();
- -
- - // Show queue status to player only (when joining queue)
- - if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
- + if (sWorld->getBoolConfig(CROSSFACTION_SYSTEM_BATTLEGROUNDS))
- {
- - ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bg->GetName().c_str(), q_min_level, q_max_level,
- - qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
- + char const* bgName = bg->GetName().c_str();
- + uint32 MinPlayers = bg->GetMinPlayersPerTeam() * 2;
- + uint32 qPlayers = 0;
- + uint32 q_min_level = bracketEntry->minLevel;
- + uint32 q_max_level = bracketEntry->maxLevel;
- + for (GroupsQueueType::const_iterator itr = m_QueuedGroups[bracketId][BG_QUEUE_CROSSFACTION].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_CROSSFACTION].end(); ++itr)
- + if (!(*itr)->IsInvitedToBGInstanceGUID)
- + qPlayers += (*itr)->Players.size();
- +
- + if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
- + {
- + ChatHandler(leader->GetSession()).PSendSysMessage("Queue status for %s (Lvl: %u to %u) Queued players: %u (Need at least %u more)", bgName, q_min_level, q_max_level, qPlayers, MinPlayers - qPlayers);
- + }
- + else
- + {
- + std::ostringstream ss;
- + ss << "|cffff0000[BG Queue Announcer]:|r " << bgName << " -- [" << q_min_level << "-" << q_max_level << "] " << qPlayers << "/" << MinPlayers;
- + sWorld->SendGlobalText(ss.str().c_str(), NULL);
- + }
- }
- // System message
- else
- {
- - sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bg->GetName().c_str(), q_min_level, q_max_level,
- - qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
- + // std::string bgName = bg->GetName().c_str();
- + char const* bgName = bg->GetName().c_str();
- + uint32 MinPlayers = bg->GetMinPlayersPerTeam();
- + uint32 qHorde = 0;
- + uint32 qAlliance = 0;
- + uint32 q_min_level = bracketEntry->minLevel;
- + uint32 q_max_level = bracketEntry->maxLevel;
- + GroupsQueueType::const_iterator itr;
- + for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].end(); ++itr)
- + if (!(*itr)->IsInvitedToBGInstanceGUID)
- + qAlliance += (*itr)->Players.size();
- + for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].end(); ++itr)
- + if (!(*itr)->IsInvitedToBGInstanceGUID)
- + qHorde += (*itr)->Players.size();
- +
- + // Show queue status to player only (when joining queue)
- + if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
- + {
- + ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level, //******
- + qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
- + }
- + // System message
- + else
- + {
- + sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level, //*******
- + qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
- + }
- }
- }
- }
- @@ -309,7 +341,7 @@ void BattlegroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount)
- {
- //we must check premade and normal team's queue - because when players from premade are joining bg,
- //they leave groupinfo so we can't use its players size to find out index
- - for (uint32 j = index; j < BG_QUEUE_GROUP_TYPES_COUNT; j += BG_TEAMS_COUNT)
- + for (uint8 j = 0; j < BG_QUEUE_GROUP_TYPES_COUNT; ++j)
- {
- GroupsQueueType::iterator k = m_QueuedGroups[bracket_id_tmp][j].begin();
- for (; k != m_QueuedGroups[bracket_id_tmp][j].end(); ++k)
- @@ -500,6 +532,10 @@ void BattlegroundQueue::FillPlayersToBG(Battleground* bg, BattlegroundBracketId
- uint32 aliCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].size();
- uint32 hordeCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].size();
- + if (!bg->isArena())
- + if (FillXPlayersToBG(bracket_id, bg, false))
- + return;
- +
- // try to get even teams
- if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == BG_QUEUE_INVITATION_TYPE_EVEN)
- {
- @@ -773,7 +809,8 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
- if (m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].empty() &&
- m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].empty() &&
- m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].empty() &&
- - m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].empty())
- + m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].empty() &&
- + m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].empty())
- return;
- // battleground with free slot for player should be always in the beggining of the queue
- @@ -864,7 +901,8 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
- {
- // if there are enough players in pools, start new battleground or non rated arena
- if (CheckNormalMatch(bg_template, bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam)
- - || (bg_template->isArena() && CheckSkirmishForSameFaction(bracket_id, MinPlayersPerTeam)))
- + || (bg_template->isArena() && CheckSkirmishForSameFaction(bracket_id, MinPlayersPerTeam))
- + || CheckCrossFactionMatch(bracket_id, bg_template))
- {
- // we successfully created a pool
- Battleground* bg2 = sBattlegroundMgr->CreateNewBattleground(bgTypeId, bracketEntry, arenaType, false);
- @@ -1099,4 +1137,4 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
- void BGQueueRemoveEvent::Abort(uint64 /*e_time*/)
- {
- //do nothing
- -}
- +}
- \ No newline at end of file
- diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h
- index 600c5f3..b561414 100644
- --- a/src/server/game/Battlegrounds/BattlegroundQueue.h
- +++ b/src/server/game/Battlegrounds/BattlegroundQueue.h
- @@ -42,6 +42,7 @@ struct GroupQueueInfo // stores informatio
- {
- std::map<ObjectGuid, PlayerQueueInfo*> Players; // player queue info map
- uint32 Team; // Player team (ALLIANCE/HORDE)
- + uint32 CFSTeam;
- BattlegroundTypeId BgTypeId; // battleground type id
- bool IsRated; // rated
- uint8 ArenaType; // 2v2, 3v3, 5v5 or 0 when BG
- @@ -60,9 +61,10 @@ enum BattlegroundQueueGroupTypes
- BG_QUEUE_PREMADE_ALLIANCE = 0,
- BG_QUEUE_PREMADE_HORDE = 1,
- BG_QUEUE_NORMAL_ALLIANCE = 2,
- - BG_QUEUE_NORMAL_HORDE = 3
- + BG_QUEUE_NORMAL_HORDE = 3,
- + BG_QUEUE_CROSSFACTION = 4
- };
- -#define BG_QUEUE_GROUP_TYPES_COUNT 4
- +#define BG_QUEUE_GROUP_TYPES_COUNT 5
- enum BattlegroundQueueInvitationType
- {
- @@ -81,6 +83,11 @@ class TC_GAME_API BattlegroundQueue
- void BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id, uint8 arenaType = 0, bool isRated = false, uint32 minRating = 0);
- void UpdateEvents(uint32 diff);
- + bool FillXPlayersToBG(BattlegroundBracketId bracket_id, Battleground* bg, bool start = false);
- + typedef std::multimap<int32, GroupQueueInfo*> QueuedGroupMap;
- + int32 PreAddPlayers(QueuedGroupMap m_PreGroupMap, int32 MaxAdd, uint32 MaxInTeam);
- + bool CheckCrossFactionMatch(BattlegroundBracketId bracket_id, Battleground* bg);
- +
- void FillPlayersToBG(Battleground* bg, BattlegroundBracketId bracket_id);
- bool CheckPremadeMatch(BattlegroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam);
- bool CheckNormalMatch(Battleground* bg_template, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers);
- @@ -184,4 +191,4 @@ class TC_GAME_API BGQueueRemoveEvent : public BasicEvent
- BattlegroundQueueTypeId m_BgQueueTypeId;
- };
- -#endif
- +#endif
- \ No newline at end of file
- diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
- index 12cb99d..c8a2833 100644
- --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
- +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
- @@ -139,7 +139,7 @@ void BattlegroundAB::PostUpdateImpl(uint32 diff)
- if (m_ReputationScoreTics[team] >= m_ReputationTics)
- {
- - (team == TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE);
- + RewardReputationToTeam(509, 510, 10, team == ALLIANCE ? ALLIANCE : HORDE);
- m_ReputationScoreTics[team] -= m_ReputationTics;
- }
- @@ -729,4 +729,4 @@ bool BattlegroundAB::CheckAchievementCriteriaMeet(uint32 criteriaId, Player cons
- }
- return Battleground::CheckAchievementCriteriaMeet(criteriaId, player, target, miscvalue);
- -}
- +}
- \ No newline at end of file
- diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
- index 90d30fb..eb05915 100644
- --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
- +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
- @@ -87,7 +87,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
- if (entry == BG_AV_CreatureInfo[AV_NPC_A_BOSS])
- {
- CastSpellOnTeam(23658, HORDE); //this is a spell which finishes a quest where a player has to kill the boss
- - RewardReputationToTeam(729, BG_AV_REP_BOSS, HORDE);
- + RewardReputationToTeam(729, 730, BG_AV_REP_BOSS, killer->GetTeam() == ALLIANCE ? ALLIANCE : HORDE);
- RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_BOSS), HORDE);
- EndBattleground(HORDE);
- DelCreature(AV_CPLACE_TRIGGER17);
- @@ -95,7 +95,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
- else if (entry == BG_AV_CreatureInfo[AV_NPC_H_BOSS])
- {
- CastSpellOnTeam(23658, ALLIANCE); //this is a spell which finishes a quest where a player has to kill the boss
- - RewardReputationToTeam(730, BG_AV_REP_BOSS, ALLIANCE);
- + RewardReputationToTeam(729, 730, BG_AV_REP_BOSS, killer->GetTeam() == ALLIANCE ? ALLIANCE : HORDE);
- RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_BOSS), ALLIANCE);
- EndBattleground(ALLIANCE);
- DelCreature(AV_CPLACE_TRIGGER19);
- @@ -108,7 +108,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
- return;
- }
- m_CaptainAlive[0]=false;
- - RewardReputationToTeam(729, BG_AV_REP_CAPTAIN, HORDE);
- + RewardReputationToTeam(729, 730, BG_AV_REP_CAPTAIN, killer->GetTeam() == ALLIANCE ? ALLIANCE : HORDE);
- RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_CAPTAIN), HORDE);
- UpdateScore(ALLIANCE, (-1)*BG_AV_RES_CAPTAIN);
- //spawn destroyed aura
- @@ -127,7 +127,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
- return;
- }
- m_CaptainAlive[1]=false;
- - RewardReputationToTeam(730, BG_AV_REP_CAPTAIN, ALLIANCE);
- + RewardReputationToTeam(729, 730, BG_AV_REP_CAPTAIN, killer->GetTeam() == ALLIANCE ? ALLIANCE : HORDE);
- RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_CAPTAIN), ALLIANCE);
- UpdateScore(HORDE, (-1)*BG_AV_RES_CAPTAIN);
- //spawn destroyed aura
- @@ -149,6 +149,7 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player)
- if (GetStatus() != STATUS_IN_PROGRESS)
- return;//maybe we should log this, cause this must be a cheater or a big bug
- uint8 team = GetTeamIndexByTeamId(player->GetTeam());
- + uint8 CFSteam = GetTeamIndexByTeamId(GetOtherTeam(player->GetTeam()));
- /// @todo add reputation, events (including quest not available anymore, next quest available, go/npc de/spawning)and maybe honor
- TC_LOG_DEBUG("bg.battleground", "BG_AV Quest %i completed", questid);
- switch (questid)
- @@ -173,21 +174,21 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player)
- case AV_QUEST_A_COMMANDER1:
- case AV_QUEST_H_COMMANDER1:
- m_Team_QuestStatus[team][1]++;
- - RewardReputationToTeam(team, 1, player->GetTeam());
- + RewardReputationToTeam(team, CFSteam, 1, player->GetTeam());
- if (m_Team_QuestStatus[team][1] == 30)
- TC_LOG_DEBUG("bg.battleground", "BG_AV Quest %i completed (need to implement some events here", questid);
- break;
- case AV_QUEST_A_COMMANDER2:
- case AV_QUEST_H_COMMANDER2:
- m_Team_QuestStatus[team][2]++;
- - RewardReputationToTeam(team, 1, player->GetTeam());
- + RewardReputationToTeam(team, CFSteam, 1, player->GetTeam());
- if (m_Team_QuestStatus[team][2] == 60)
- TC_LOG_DEBUG("bg.battleground", "BG_AV Quest %i completed (need to implement some events here", questid);
- break;
- case AV_QUEST_A_COMMANDER3:
- case AV_QUEST_H_COMMANDER3:
- m_Team_QuestStatus[team][3]++;
- - RewardReputationToTeam(team, 1, player->GetTeam());
- + RewardReputationToTeam(team, CFSteam, 1, player->GetTeam());
- if (m_Team_QuestStatus[team][3] == 120)
- TC_LOG_DEBUG("bg.battleground", "BG_AV Quest %i completed (need to implement some events here", questid);
- break;
- @@ -469,7 +470,7 @@ void BattlegroundAV::EndBattleground(uint32 winner)
- rep[i] += BG_AV_REP_SURVIVING_CAPTAIN;
- }
- if (rep[i] != 0)
- - RewardReputationToTeam(i == 0 ? 730 : 729, rep[i], i == 0 ? ALLIANCE : HORDE);
- + RewardReputationToTeam(729, 730, 10, i == ALLIANCE ? ALLIANCE : HORDE);
- if (kills[i] != 0)
- RewardHonorToTeam(GetBonusHonorFromKill(kills[i]), i == 0 ? ALLIANCE : HORDE);
- }
- @@ -574,7 +575,7 @@ void BattlegroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node)
- SpawnBGObject(BG_AV_OBJECT_BURN_DUNBALDAR_SOUTH + i + (tmp * 10), RESPAWN_IMMEDIATELY);
- UpdateScore((owner == ALLIANCE) ? HORDE : ALLIANCE, -1 * BG_AV_RES_TOWER);
- - RewardReputationToTeam(owner == ALLIANCE ? 730 : 729, BG_AV_REP_TOWER, owner);
- + RewardReputationToTeam(729, 730, BG_AV_REP_TOWER, owner);
- RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_TOWER), owner);
- SpawnBGObject(BG_AV_OBJECT_TAURA_A_DUNBALDAR_SOUTH+GetTeamIndexByTeamId(owner)+(2*tmp), RESPAWN_ONE_DAY);
- @@ -1566,4 +1567,4 @@ uint32 BattlegroundAV::GetPrematureWinner()
- return HORDE;
- return Battleground::GetPrematureWinner();
- -}
- +}
- \ No newline at end of file
- diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
- index 950d2b5..d37e7f9 100644
- --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
- +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
- @@ -307,7 +307,7 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* player)
- if (GetTeamScore(TEAM_ALLIANCE) < BG_WS_MAX_TEAM_SCORE)
- AddPoint(ALLIANCE, 1);
- PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE);
- - RewardReputationToTeam(890, m_ReputationCapture, ALLIANCE);
- +
- }
- else
- {
- @@ -326,8 +326,9 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* player)
- if (GetTeamScore(TEAM_HORDE) < BG_WS_MAX_TEAM_SCORE)
- AddPoint(HORDE, 1);
- PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE);
- - RewardReputationToTeam(889, m_ReputationCapture, HORDE);
- +
- }
- + RewardReputationToTeam(890, 889, m_ReputationCapture, player->GetTeam());
- //for flag capture is reward 2 honorable kills
- RewardHonorToTeam(GetBonusHonorFromKill(2), player->GetTeam());
- @@ -889,4 +890,4 @@ bool BattlegroundWS::CheckAchievementCriteriaMeet(uint32 criteriaId, Player cons
- }
- return Battleground::CheckAchievementCriteriaMeet(criteriaId, player, target, miscValue);
- -}
- +}
- \ No newline at end of file
- diff --git a/src/server/game/CrossFactionBG/Cfbg.cpp b/src/server/game/CrossFactionBG/Cfbg.cpp
- new file mode 100644
- index 0000000..3143177
- --- /dev/null
- +++ b/src/server/game/CrossFactionBG/Cfbg.cpp
- @@ -0,0 +1,356 @@
- +/*
- + * Copyright (C) 2008-2016 FineWoWCore <http://www.finewow.com.br/>
- + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
- + *
- + * This program is free software; you can redistribute it and/or modify it
- + * under the terms of the GNU General Public License as published by the
- + * Free Software Foundation; either version 2 of the License, or (at your
- + * option) any later version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- + * more details.
- + *
- + * You should have received a copy of the GNU General Public License along
- + * with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +#include "Cfbg.h"
- +#include "Battleground.h"
- +#include "BattlegroundMgr.h"
- +#include "Player.h"
- +#include "Chat.h"
- +#include "BattlegroundQueue.h"
- +
- +/*####################################################################################
- +###############################CROSSFACTION BATTLEGROUNDS#############################
- +####################################################################################*/
- +uint8 Unit::getRace(bool forceoriginal) const
- +{
- + if (GetTypeId() == TYPEID_PLAYER)
- + {
- + Player* pPlayer = ((Player*)this);
- +
- + if (forceoriginal)
- + return pPlayer->getCFSRace();
- +
- + if (pPlayer->InArena())
- + return GetByteValue(UNIT_FIELD_BYTES_0, 0);
- +
- + if (!pPlayer->IsPlayingNative())
- + return pPlayer->getFRace();
- + }
- +
- + return GetByteValue(UNIT_FIELD_BYTES_0, 0);
- +}
- +
- +bool Player::SendRealNameQuery()
- +{
- + if (IsPlayingNative())
- + return false;
- +
- + WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + 1 + 1 + 1 + 1 + 1 + 10));
- + data.appendPackGUID(GetGUID()); // player guid
- + data << uint8(0); // added in 3.1; if > 1, then end of packet
- + data << GetName(); // played name
- + data << uint8(0); // realm name for cross realm BG usage
- + data << uint8(getCFSRace());
- + data << uint8(getGender());
- + data << uint8(getClass());
- + data << uint8(0); // is not declined
- + GetSession()->SendPacket(&data);
- +
- + return true;
- +}
- +
- +void Player::SetFakeRaceAndMorph()
- +{
- + if (getClass() == CLASS_DRUID)
- + {
- + if (GetCFSTeam() == ALLIANCE)
- + {
- + m_FakeMorph = getGender() == GENDER_MALE ? FAKE_M_TAUREN : FAKE_F_TAUREN;
- + m_FakeRace = RACE_TAUREN;
- + }
- + else if (getGender() == GENDER_MALE) // HORDE PLAYER, ONLY HAVE MALE NELF ID
- + {
- + m_FakeMorph = FAKE_M_NELF;
- + m_FakeRace = RACE_NIGHTELF;
- + }
- + else
- + m_FakeRace = GetCFSTeam() == ALLIANCE ? RACE_BLOODELF : RACE_HUMAN;
- + }
- + else if (getClass() == CLASS_SHAMAN && GetCFSTeam() == HORDE && getGender() == GENDER_FEMALE)
- + {
- + m_FakeMorph = FAKE_F_DRAENEI; // Female Draenei
- + m_FakeRace = RACE_DRAENEI;
- + }
- + else
- + {
- + m_FakeRace = GetCFSTeam() == ALLIANCE ? RACE_BLOODELF : RACE_HUMAN;
- +
- + if (GetCFSTeam() == HORDE)
- + {
- + if (getGender() == GENDER_MALE)
- + m_FakeMorph = 19723;
- + else
- + m_FakeMorph = 19724;
- + }
- + else
- + {
- + if (getGender() == GENDER_MALE)
- + m_FakeMorph = 20578;
- + else
- + m_FakeMorph = 20579;
- + }
- + }
- +}
- +
- +bool Player::SendBattleGroundChat(uint32 msgtype, std::string message)
- +{
- + // Select distance to broadcast to.
- + float distance = msgtype == CHAT_MSG_SAY ? sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY) : sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL);
- +
- + if (Battleground* bg = GetBattleground())
- + {
- + if (bg->isArena()) // Only fake chat in BG's. CFBG should not interfere with arenas.
- + return false;
- +
- + for (Battleground::BattlegroundPlayerMap::const_iterator itr = bg->GetPlayers().begin(); itr != bg->GetPlayers().end(); ++itr)
- + {
- + if (Player* player = ObjectAccessor::FindPlayer(itr->first))
- + {
- + if (GetDistance2d(player->GetPositionX(), player->GetPositionY()) <= distance)
- + {
- + WorldPacket data(SMSG_MESSAGECHAT, 200);
- +
- + if (GetTeam() == player->GetTeam())
- + BuildPlayerChat(&data, msgtype, message, LANG_UNIVERSAL);
- + else if (msgtype != CHAT_MSG_EMOTE)
- + BuildPlayerChat(&data, msgtype, message, player->GetTeam() == ALLIANCE ? LANG_ORCISH : LANG_COMMON);
- +
- + player->GetSession()->SendPacket(&data);
- + }
- + }
- + }
- + return true;
- + }
- + else
- + return false;
- +}
- +
- +void Player::MorphFit(bool value)
- +{
- + if (!IsPlayingNative() && value)
- + {
- + SetDisplayId(GetFakeMorph());
- + SetNativeDisplayId(GetFakeMorph());
- + }
- + else
- + InitDisplayIds();
- +}
- +
- +void Player::FitPlayerInTeam(bool action, Battleground* pBattleGround)
- +{
- + if (!pBattleGround)
- + pBattleGround = GetBattleground();
- +
- + if ((!pBattleGround || pBattleGround->isArena()) && action)
- + return;
- +
- + if (!IsPlayingNative() && action)
- + setFactionForRace(getRace());
- + else
- + setFactionForRace(getCFSRace());
- +
- + if (action)
- + SetForgetBGPlayers(true);
- + else
- + SetForgetInListPlayers(true);
- +
- + MorphFit(action);
- +
- + if (pBattleGround && action)
- + SendChatMessage("%sYou are playing for the %s%s in this %s", MSG_COLOR_WHITE, GetTeam() == ALLIANCE ? MSG_COLOR_DARKBLUE"alliance" : MSG_COLOR_RED"horde", MSG_COLOR_WHITE, pBattleGround->GetName().c_str());
- +}
- +
- +void Player::DoForgetPlayersInList()
- +{
- + // m_FakePlayers is filled from a vector within the battleground
- + // they were in previously so all players that have been in that BG will be invalidated.
- + for (FakePlayers::const_iterator itr = m_FakePlayers.begin(); itr != m_FakePlayers.end(); ++itr)
- + {
- + WorldPacket data(SMSG_INVALIDATE_PLAYER, 8);
- + data << *itr;
- + GetSession()->SendPacket(&data);
- + if (Player* pPlayer = ObjectAccessor::FindPlayer(ObjectGuid(*itr)))
- + // if (Player* pPlayer = ObjectAccessor::FindPlayer(*itr))
- + GetSession()->SendNameQueryOpcode(pPlayer->GetGUID());
- + }
- + m_FakePlayers.clear();
- +}
- +
- +void Player::DoForgetPlayersInBG(Battleground* pBattleGround)
- +{
- + for (Battleground::BattlegroundPlayerMap::const_iterator itr = pBattleGround->GetPlayers().begin(); itr != pBattleGround->GetPlayers().end(); ++itr)
- + {
- + // Here we invalidate players in the bg to the added player
- + WorldPacket data1(SMSG_INVALIDATE_PLAYER, 8);
- + data1 << itr->first;
- + GetSession()->SendPacket(&data1);
- +
- + if (Player* pPlayer = ObjectAccessor::FindPlayer(itr->first))
- + {
- + GetSession()->SendNameQueryOpcode(pPlayer->GetGUID()); // Send namequery answer instantly if player is available
- + // Here we invalidate the player added to players in the bg
- + WorldPacket data2(SMSG_INVALIDATE_PLAYER, 8);
- + data2 << GetGUID();
- + pPlayer->GetSession()->SendPacket(&data2);
- + pPlayer->GetSession()->SendNameQueryOpcode(GetGUID());
- + }
- + }
- +}
- +
- +bool BattlegroundQueue::CheckCrossFactionMatch(BattlegroundBracketId bracket_id, Battleground* bg)
- +{
- + if (!sWorld->getBoolConfig(CROSSFACTION_SYSTEM_BATTLEGROUNDS) || bg->isArena())
- + return false; // Only do this if crossbg's are enabled.
- +
- + // Here we will add all players to selectionpool, later we check if there are enough and launch a bg.
- + FillXPlayersToBG(bracket_id, bg, true);
- +
- + if (sBattlegroundMgr->isTesting() && (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() || m_SelectionPools[TEAM_HORDE].GetPlayerCount()))
- + return true;
- +
- + uint8 MPT = bg->GetMinPlayersPerTeam();
- + if (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() < MPT || m_SelectionPools[TEAM_HORDE].GetPlayerCount() < MPT)
- + return false;
- +
- + return true;
- +}
- +
- +// This function will invite players in the least populated faction, which makes battleground queues much faster.
- +// This function will return true if cross faction battlegrounds are enabled, otherwise return false,
- +// which is useful in FillPlayersToBG. Because then we can interrupt the regular invitation if cross faction bg's are enabled.
- +bool BattlegroundQueue::FillXPlayersToBG(BattlegroundBracketId bracket_id, Battleground* bg, bool start)
- +{
- + uint8 queuedPeople = 0;
- + for (GroupsQueueType::const_iterator itr = m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].end(); ++itr)
- + if (!(*itr)->IsInvitedToBGInstanceGUID)
- + queuedPeople += (*itr)->Players.size();
- +
- + if (sWorld->getBoolConfig(CROSSFACTION_SYSTEM_BATTLEGROUNDS) && (sBattlegroundMgr->isTesting() || queuedPeople >= bg->GetMinPlayersPerTeam() * 2 || !start))
- + {
- + int32 aliFree = start ? bg->GetMaxPlayersPerTeam() : bg->GetFreeSlotsForTeam(ALLIANCE);
- + int32 hordeFree = start ? bg->GetMaxPlayersPerTeam() : bg->GetFreeSlotsForTeam(HORDE);
- + // Empty selection pools. They will be refilled from queued groups.
- + m_SelectionPools[TEAM_ALLIANCE].Init();
- + m_SelectionPools[TEAM_HORDE].Init();
- + int32 valiFree = aliFree;
- + int32 vhordeFree = hordeFree;
- + int32 diff = 0;
- +
- +
- + // Add teams to their own factions as far as possible.
- + if (start)
- + {
- + QueuedGroupMap m_PreGroupMap_a, m_PreGroupMap_h;
- + int32 m_SmallestOfTeams = 0;
- + int32 queuedAlliance = 0;
- + int32 queuedHorde = 0;
- +
- + for (GroupsQueueType::const_iterator itr = m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].end(); ++itr)
- + {
- + if ((*itr)->IsInvitedToBGInstanceGUID)
- + continue;
- +
- + bool alliance = (*itr)->CFSTeam == ALLIANCE;
- +
- + if (alliance)
- + {
- + m_PreGroupMap_a.insert(std::make_pair((*itr)->Players.size(), *itr));
- + queuedAlliance += (*itr)->Players.size();
- + }
- + else
- + {
- + m_PreGroupMap_h.insert(std::make_pair((*itr)->Players.size(), *itr));
- + queuedHorde += (*itr)->Players.size();
- + }
- + }
- +
- + m_SmallestOfTeams = std::min(std::min(aliFree, queuedAlliance), std::min(hordeFree, queuedHorde));
- +
- + valiFree -= PreAddPlayers(m_PreGroupMap_a, m_SmallestOfTeams, aliFree);
- + vhordeFree -= PreAddPlayers(m_PreGroupMap_h, m_SmallestOfTeams, hordeFree);
- + }
- + QueuedGroupMap m_QueuedGroupMap;
- +
- + for (GroupsQueueType::const_iterator itr = m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].end(); ++itr)
- + m_QueuedGroupMap.insert(std::make_pair((*itr)->Players.size(), *itr));
- +
- + for (QueuedGroupMap::reverse_iterator itr = m_QueuedGroupMap.rbegin(); itr != m_QueuedGroupMap.rend(); ++itr)
- + {
- + GroupsQueueType allypool = m_SelectionPools[TEAM_ALLIANCE].SelectedGroups;
- + GroupsQueueType hordepool = m_SelectionPools[TEAM_HORDE].SelectedGroups;
- +
- + GroupQueueInfo* ginfo = itr->second;
- +
- + // If player already was invited via pre adding (add to own team first) or he was already invited to a bg, skip.
- + if (ginfo->IsInvitedToBGInstanceGUID ||
- + std::find(allypool.begin(), allypool.end(), ginfo) != allypool.end() ||
- + std::find(hordepool.begin(), hordepool.end(), ginfo) != hordepool.end() ||
- + (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= bg->GetMinPlayersPerTeam() &&
- + m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= bg->GetMinPlayersPerTeam()))
- + continue;
- +
- + diff = abs(valiFree - vhordeFree);
- + bool moreAli = valiFree < vhordeFree;
- +
- + if (diff > 0)
- + ginfo->Team = moreAli ? HORDE : ALLIANCE;
- +
- + bool alliance = ginfo->Team == ALLIANCE;
- +
- + if (m_SelectionPools[alliance ? TEAM_ALLIANCE : TEAM_HORDE].AddGroup(ginfo, alliance ? aliFree : hordeFree))
- + alliance ? valiFree -= ginfo->Players.size() : vhordeFree -= ginfo->Players.size();
- + }
- +
- + return true;
- + }
- + return false;
- +}
- +
- +int32 BattlegroundQueue::PreAddPlayers(QueuedGroupMap m_PreGroupMap, int32 MaxAdd, uint32 MaxInTeam)
- +{
- + int32 LeftToAdd = MaxAdd;
- + uint32 Added = 0;
- +
- + for (QueuedGroupMap::reverse_iterator itr = m_PreGroupMap.rbegin(); itr != m_PreGroupMap.rend(); ++itr)
- + {
- + int32 PlayerSize = itr->first;
- + bool alliance = itr->second->CFSTeam == ALLIANCE;
- +
- + if (PlayerSize <= LeftToAdd && m_SelectionPools[alliance ? TEAM_ALLIANCE : TEAM_HORDE].AddGroup(itr->second, MaxInTeam))
- + LeftToAdd -= PlayerSize, Added -= PlayerSize;
- + }
- +
- + return LeftToAdd;
- +}
- +
- +void Player::SendChatMessage(const char *format, ...)
- +{
- + if (!IsInWorld())
- + return;
- +
- + if (format)
- + {
- + va_list ap;
- + char str[2048];
- + va_start(ap, format);
- + vsnprintf(str, 2048, format, ap);
- + va_end(ap);
- +
- + ChatHandler(GetSession()).SendSysMessage(str);
- + }
- +}
- \ No newline at end of file
- diff --git a/src/server/game/CrossFactionBG/Cfbg.h b/src/server/game/CrossFactionBG/Cfbg.h
- new file mode 100644
- index 0000000..ffb0f81
- --- /dev/null
- +++ b/src/server/game/CrossFactionBG/Cfbg.h
- @@ -0,0 +1,61 @@
- +/*
- + * Copyright (C) 2008-2016 FineWoWCore <http://www.finewow.com.br/>
- + *
- + * This program is free software; you can redistribute it and/or modify it
- + * under the terms of the GNU General Public License as published by the
- + * Free Software Foundation; either version 2 of the License, or (at your
- + * option) any later version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- + * more details.
- + *
- + * You should have received a copy of the GNU General Public License along
- + * with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +
- +#ifndef _CUSTOM_H
- +#define _CUSTOM_H
- +
- +#define MSG_COLOR_LIGHTRED "|cffff6060"
- +#define MSG_COLOR_LIGHTBLUE "|cff00ccff"
- +#define MSG_COLOR_ANN_GREEN "|c1f40af20"
- +#define MSG_COLOR_RED "|cffff0000"
- +#define MSG_COLOR_GOLD "|cffffcc00"
- +#define MSG_COLOR_SUBWHITE "|cffbbbbbb"
- +#define MSG_COLOR_MAGENTA "|cffff00ff"
- +#define MSG_COLOR_YELLOW "|cffffff00"
- +#define MSG_COLOR_CYAN "|cff00ffff"
- +#define MSG_COLOR_DARKBLUE "|cff0000ff"
- +
- +#define MSG_COLOR_GREY "|cff9d9d9d"
- +#define MSG_COLOR_WHITE "|cffffffff"
- +#define MSG_COLOR_GREEN "|cff1eff00"
- +#define MSG_COLOR_BLUE "|cff0080ff"
- +#define MSG_COLOR_PURPLE "|cffb048f8"
- +#define MSG_COLOR_ORANGE "|cffff8000"
- +
- +#define MSG_COLOR_DRUID "|cffff7d0a"
- +#define MSG_COLOR_HUNTER "|cffabd473"
- +#define MSG_COLOR_MAGE "|cff69ccf0"
- +#define MSG_COLOR_PALADIN "|cfff58cba"
- +#define MSG_COLOR_PRIEST "|cffffffff"
- +#define MSG_COLOR_ROGUE "|cfffff569"
- +#define MSG_COLOR_SHAMAN "|cff0070de"
- +#define MSG_COLOR_WARLOCK "|cff9482c9"
- +#define MSG_COLOR_WARRIOR "|cffc79c6e"
- +#define MSG_COLOR_DEATH_KNIGHT "|cffc41f3b"
- +#define MSG_COLOR_MONK "|cff00ff96"
- +
- +#define LIMIT_UINT32 2147483647
- +
- +enum FakeMorphs
- +{
- + FAKE_F_TAUREN = 20584,
- + FAKE_M_TAUREN = 20585,
- + FAKE_M_NELF = 20318,
- + FAKE_F_DRAENEI = 20323,
- +};
- +#endif
- \ No newline at end of file
- diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
- index d0ddec7..c5f2d94 100644
- --- a/src/server/game/Entities/Player/Player.cpp
- +++ b/src/server/game/Entities/Player/Player.cpp
- @@ -292,6 +292,12 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi)
- Player::Player(WorldSession* session): Unit(true)
- {
- + m_FakeRace = 0;
- + m_RealRace = 0;
- + m_FakeMorph = 0;
- + m_ForgetBGPlayers = false;
- + m_ForgetInListPlayers = false;
- +
- m_speakTime = 0;
- m_speakCount = 0;
- @@ -641,6 +647,12 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo
- SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, createInfo->Class);
- SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, createInfo->Gender);
- SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE, powertype);
- +
- + SetCFSRace();
- + m_team = TeamForRace(getCFSRace());
- + SetFakeRaceAndMorph(); // m_team must be set before this can be used.
- + setFactionForRace(getCFSRace());
- +
- InitDisplayIds();
- if (sWorld->getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_PVP || sWorld->getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_RPPVP)
- {
- @@ -2744,10 +2756,10 @@ void Player::GiveLevel(uint8 level)
- guild->UpdateMemberData(this, GUILD_MEMBER_DATA_LEVEL, level);
- PlayerLevelInfo info;
- - sObjectMgr->GetPlayerLevelInfo(getRace(), getClass(), level, &info);
- + sObjectMgr->GetPlayerLevelInfo(getCFSRace(), getClass(), level, &info);
- PlayerClassLevelInfo classInfo;
- - sObjectMgr->GetPlayerClassLevelInfo(getClass(), level, &classInfo);
- + sObjectMgr->GetPlayerClassLevelInfo(getClass(), level, &classInfo);
- // send levelup info to client
- WorldPacket data(SMSG_LEVELUP_INFO, (4+4+MAX_POWERS*4+MAX_STATS*4));
- @@ -2882,7 +2894,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
- sObjectMgr->GetPlayerClassLevelInfo(getClass(), getLevel(), &classInfo);
- PlayerLevelInfo info;
- - sObjectMgr->GetPlayerLevelInfo(getRace(), getClass(), getLevel(), &info);
- + sObjectMgr->GetPlayerLevelInfo(getCFSRace(), getClass(), getLevel(), &info);
- SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
- SetUInt32Value(PLAYER_NEXT_LEVEL_XP, sObjectMgr->GetXPForLevel(getLevel()));
- @@ -4792,7 +4804,7 @@ Corpse* Player::CreateCorpse()
- // prevent the existence of 2 corpses for one player
- SpawnCorpseBones();
- - uint32 _cfb1, _cfb2;
- + uint32 _uf, _pb, _pb2, _cfb1, _cfb2;
- Corpse* corpse = new Corpse((m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH) ? CORPSE_RESURRECTABLE_PVP : CORPSE_RESURRECTABLE_PVE);
- SetPvPDeath(false);
- @@ -4804,6 +4816,9 @@ Corpse* Player::CreateCorpse()
- }
- _corpseLocation.WorldRelocate(*this);
- +
- + _uf = getCFSRace();
- + uint8 race = (uint8) (_uf);
- uint8 skin = GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID);
- uint8 face = GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID);
- @@ -4811,6 +4826,10 @@ Corpse* Player::CreateCorpse()
- uint8 haircolor = GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_COLOR_ID);
- uint8 facialhair = GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE);
- + _uf = getCFSRace();
- + _pb = GetUInt32Value(PLAYER_BYTES);
- + _pb2 = GetUInt32Value(PLAYER_BYTES_2);
- +
- _cfb1 = ((0x00) | (getRace() << 8) | (GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER) << 16) | (skin << 24));
- _cfb2 = ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24));
- @@ -6502,10 +6521,10 @@ uint32 Player::TeamForRace(uint8 race)
- void Player::setFactionForRace(uint8 race)
- {
- - m_team = TeamForRace(race);
- + SetBGTeam(TeamForRace(race));
- ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race);
- - setFaction(rEntry ? rEntry->FactionID : 0);
- + setFaction(rEntry ? rEntry->FactionID : getFaction());
- }
- ReputationRank Player::GetReputationRank(uint32 faction) const
- @@ -6607,6 +6626,27 @@ void Player::RewardReputation(Unit* victim, float rate)
- if (!Rep)
- return;
- + uint32 repfaction1 = Rep->RepFaction1;
- + uint32 repfaction2 = Rep->RepFaction2;
- +
- + if (!IsPlayingNative())
- + {
- + if (GetCFSTeam() == ALLIANCE)
- + {
- + if (repfaction1 == 729)
- + repfaction1 = 730;
- + if (repfaction2 == 729)
- + repfaction2 = 730;
- + }
- + else
- + {
- + if (repfaction1 == 730)
- + repfaction1 = 729;
- + if (repfaction2 == 730)
- + repfaction2 = 729;
- + }
- + }
- +
- uint32 ChampioningFaction = 0;
- if (GetChampioningFaction())
- @@ -6621,9 +6661,9 @@ void Player::RewardReputation(Unit* victim, float rate)
- uint32 team = GetTeam();
- - if (Rep->RepFaction1 && (!Rep->TeamDependent || team == ALLIANCE))
- + if (repfaction1 && (!Rep->TeamDependent || team == ALLIANCE))
- {
- - int32 donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->getLevel(), Rep->RepValue1, ChampioningFaction ? ChampioningFaction : Rep->RepFaction1);
- + int32 donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->getLevel(), Rep->RepValue1, ChampioningFaction ? ChampioningFaction : repfaction1);
- donerep1 = int32(donerep1 * rate);
- FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->RepFaction1);
- @@ -6632,12 +6672,12 @@ void Player::RewardReputation(Unit* victim, float rate)
- GetReputationMgr().ModifyReputation(factionEntry1, donerep1);
- }
- - if (Rep->RepFaction2 && (!Rep->TeamDependent || team == HORDE))
- + if (repfaction2 && (!Rep->TeamDependent || team == HORDE))
- {
- - int32 donerep2 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->getLevel(), Rep->RepValue2, ChampioningFaction ? ChampioningFaction : Rep->RepFaction2);
- + int32 donerep2 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->getLevel(), Rep->RepValue2, ChampioningFaction ? ChampioningFaction : repfaction2);
- donerep2 = int32(donerep2 * rate);
- - FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->RepFaction2);
- + FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : repfaction2);
- uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2);
- if (factionEntry2 && current_reputation_rank2 <= Rep->ReputationMaxCap2)
- GetReputationMgr().ModifyReputation(factionEntry2, donerep2);
- @@ -6732,7 +6772,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto
- if (!victim || victim == this || victim->GetTypeId() != TYPEID_PLAYER)
- return false;
- - if (GetBGTeam() == victim->ToPlayer()->GetBGTeam())
- + if (GetTeam() == victim->ToPlayer()->GetTeam())
- return false;
- return true;
- @@ -11577,13 +11617,13 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
- if (!proto)
- return EQUIP_ERR_ITEM_NOT_FOUND;
- - if ((proto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && GetTeam() != HORDE)
- + if ((proto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && GetCFSTeam() != HORDE)
- return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
- - if ((proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && GetTeam() != ALLIANCE)
- + if ((proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && GetCFSTeam() != ALLIANCE)
- return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
- - if ((proto->AllowableClass & getClassMask()) == 0 || (proto->AllowableRace & getRaceMask()) == 0)
- + if ((proto->AllowableClass & getClassMask()) == 0 || (proto->AllowableRace & getCFSRaceMask()) == 0)
- return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
- if (proto->RequiredSkill != 0)
- @@ -16927,6 +16967,11 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
- SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, fields[4].GetUInt8());
- SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, gender);
- + SetCFSRace(); //**** umisteni ****
- + m_team = TeamForRace(getCFSRace());
- + SetFakeRaceAndMorph(); // m_team must be set before this can be used.
- + setFactionForRace(getCFSRace());//Need to call it to initialize m_team (m_team can be calculated from race)
- +
- // check if race/class combination is valid
- PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass());
- if (!info)
- @@ -17001,9 +17046,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
- TC_LOG_DEBUG("entities.player.loading", "Player::LoadFromDB: Load Basic value of player '%s' is: ", m_name.c_str());
- outDebugValues();
- - //Need to call it to initialize m_team (m_team can be calculated from race)
- - //Other way is to saves m_team into characters table.
- - setFactionForRace(getRace());
- +
- // load home bind and check in same time class/race pair, it used later for restore broken positions
- if (!_LoadHomeBind(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_HOME_BIND)))
- @@ -18915,7 +18958,7 @@ void Player::AddInstanceEnterTime(uint32 instanceId, time_t enterTime)
- bool Player::_LoadHomeBind(PreparedQueryResult result)
- {
- - PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass());
- + PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getCFSRace(), getClass());
- if (!info)
- {
- TC_LOG_ERROR("entities.player", "Player::_LoadHomeBind: Player '%s' (%s) has incorrect race/class (%u/%u) pair. Can't load.",
- @@ -19009,7 +19052,7 @@ void Player::SaveToDB(bool create /*=false*/)
- stmt->setUInt32(index++, GetGUID().GetCounter());
- stmt->setUInt32(index++, GetSession()->GetAccountId());
- stmt->setString(index++, GetName());
- - stmt->setUInt8(index++, getRace());
- + stmt->setUInt8(index++, getCFSRace());
- stmt->setUInt8(index++, getClass());
- stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect
- stmt->setUInt8(index++, getLevel());
- @@ -19119,7 +19162,7 @@ void Player::SaveToDB(bool create /*=false*/)
- // Update query
- stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER);
- stmt->setString(index++, GetName());
- - stmt->setUInt8(index++, getRace());
- + stmt->setUInt8(index++, getCFSRace());
- stmt->setUInt8(index++, getClass());
- stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect
- stmt->setUInt8(index++, getLevel());
- @@ -20365,6 +20408,18 @@ void Player::StopCastingCharm()
- }
- }
- +void Player::BuildPlayerChat(WorldPacket* data, uint8 msgtype, const std::string& text, uint32 language) const
- +{
- + *data << uint8(msgtype);
- + *data << uint32(language);
- + *data << uint64(GetGUID());
- + *data << uint32(0); // constant unknown time
- + *data << uint64(GetGUID());
- + *data << uint32(text.length() + 1);
- + *data << text;
- + *data << uint8(GetChatTag());
- +}
- +
- void Player::Say(std::string const& text, Language language, WorldObject const* /*= nullptr*/)
- {
- std::string _text(text);
- @@ -21322,7 +21377,7 @@ void Player::InitDataForForm(bool reapplyMods)
- void Player::InitDisplayIds()
- {
- - PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass());
- + PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getCFSRace(), getClass());
- if (!info)
- {
- TC_LOG_ERROR("entities.player", "Player::InitDisplayIds: Player '%s' (%s) has incorrect race/class pair. Can't init display ids.", GetName().c_str(), GetGUID().ToString().c_str());
- @@ -21330,14 +21385,18 @@ void Player::InitDisplayIds()
- }
- uint8 gender = GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER);
- + bool isMorphed = GetNativeDisplayId() != GetDisplayId();
- +
- switch (gender)
- {
- case GENDER_FEMALE:
- - SetDisplayId(info->displayId_f);
- + if (!isMorphed)
- + SetDisplayId(info->displayId_f);
- SetNativeDisplayId(info->displayId_f);
- break;
- case GENDER_MALE:
- - SetDisplayId(info->displayId_m);
- + if (!isMorphed)
- + SetDisplayId(info->displayId_m);
- SetNativeDisplayId(info->displayId_m);
- break;
- default:
- @@ -21940,11 +21999,6 @@ void Player::SetBGTeam(uint32 team)
- SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_ARENA_FACTION, uint8(team == ALLIANCE ? 1 : 0));
- }
- -uint32 Player::GetBGTeam() const
- -{
- - return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam();
- -}
- -
- void Player::LeaveBattleground(bool teleportToEntryPoint)
- {
- if (Battleground* bg = GetBattleground())
- @@ -22030,7 +22084,7 @@ void Player::ReportedAfkBy(Player* reporter)
- WorldLocation Player::GetStartPosition() const
- {
- - PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass());
- + PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getCFSRace(), getClass());
- uint32 mapId = info->mapId;
- if (getClass() == CLASS_DEATH_KNIGHT && HasSpell(50977))
- mapId = 0;
- @@ -22717,7 +22771,7 @@ void Player::LearnCustomSpells()
- {
- uint32 tspell = *itr;
- TC_LOG_DEBUG("entities.player.loading", "Player::LearnCustomSpells: Player '%s' (%s, Class: %u Race: %u): Adding initial spell (SpellID: %u)",
- - GetName().c_str(), GetGUID().ToString().c_str(), uint32(getClass()), uint32(getRace()), tspell);
- + GetName().c_str(), GetGUID().ToString().c_str(), uint32(getClass()), uint32(getCFSRace()), tspell);
- if (!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add
- AddSpell(tspell, true, true, true, false);
- else // but send in normal spell in game learn case
- @@ -26578,4 +26632,4 @@ uint32 Player::DoRandomRoll(uint32 minimum, uint32 maximum)
- SendDirectMessage(&data);
- return roll;
- -}
- +}
- \ No newline at end of file
- diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
- index 2b7780a..828e9db 100644
- --- a/src/server/game/Entities/Player/Player.h
- +++ b/src/server/game/Entities/Player/Player.h
- @@ -1038,6 +1038,36 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
- PlayerAI* AI() const { return reinterpret_cast<PlayerAI*>(i_AI); }
- + private:
- + bool m_ForgetBGPlayers;
- + bool m_ForgetInListPlayers;
- + uint8 m_FakeRace;
- + uint8 m_RealRace;
- + uint32 m_FakeMorph;
- + public:
- + typedef std::vector<uint64> FakePlayers;
- + void SendChatMessage(const char *format, ...);
- + void FitPlayerInTeam(bool action, Battleground* pBattleGround = NULL); // void FitPlayerInTeam(bool action, Battleground* bg = NULL);
- + void DoForgetPlayersInList();
- + void DoForgetPlayersInBG(Battleground* pBattleGround); // void DoForgetPlayersInBG(Battleground* bg);
- + uint8 getCFSRace() const { return m_RealRace; }
- + void SetCFSRace() { m_RealRace = GetByteValue(UNIT_FIELD_BYTES_0, 0); }; // SHOULD ONLY BE CALLED ON LOGIN
- + void SetFakeRace(); // SHOULD ONLY BE CALLED ON LOGIN
- + void SetFakeRaceAndMorph(); // SHOULD ONLY BE CALLED ON LOGIN
- + uint32 GetFakeMorph() { return m_FakeMorph; };
- + uint8 getFRace() const { return m_FakeRace; }
- + void SetForgetBGPlayers(bool value) { m_ForgetBGPlayers = value; }
- + bool ShouldForgetBGPlayers() { return m_ForgetBGPlayers; }
- + void SetForgetInListPlayers(bool value) { m_ForgetInListPlayers = value; }
- + bool ShouldForgetInListPlayers() { return m_ForgetInListPlayers; }
- + bool SendBattleGroundChat(uint32 msgtype, std::string message);
- + void MorphFit(bool value);
- + bool IsPlayingNative() const { return GetTeam() == m_team; }
- + uint32 GetCFSTeam() const { return m_team; }
- + uint32 GetTeam() const { return m_bgData.bgTeam && GetBattleground() ? m_bgData.bgTeam : m_team; }
- + bool SendRealNameQuery();
- + FakePlayers m_FakePlayers;
- +
- void CleanupsBeforeDelete(bool finalCleanup = true) override;
- void AddToWorld() override;
- @@ -1096,7 +1126,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
- PlayerSocial *GetSocial() const { return m_social; }
- PlayerTaxi m_taxi;
- - void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
- + void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getCFSRace(), getClass(), getLevel()); }
- bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc = nullptr, uint32 spellid = 0);
- bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0);
- void CleanupAfterTaxiFlight();
- @@ -1151,6 +1181,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
- void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
- uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
- + /// Constructs the player Chat data for the specific functions to use
- + void BuildPlayerChat(WorldPacket* data, uint8 msgtype, std::string const& text, uint32 language) const;
- /// Handles said message in regular chat based on declared language and in config pre-defined Range.
- void Say(std::string const& text, Language language, WorldObject const* = nullptr) override;
- void Say(uint32 textId, WorldObject const* target = nullptr) override;
- @@ -1874,8 +1906,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
- void CheckAreaExploreAndOutdoor(void);
- static uint32 TeamForRace(uint8 race);
- - uint32 GetTeam() const { return m_team; }
- - TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }
- + TeamId GetTeamId() const { return GetTeam() == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }
- void setFactionForRace(uint8 race);
- void InitDisplayIds();
- @@ -2024,7 +2055,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
- void SetBattlegroundEntryPoint();
- void SetBGTeam(uint32 team);
- - uint32 GetBGTeam() const;
- void LeaveBattleground(bool teleportToEntryPoint = true);
- bool CanJoinToBattleground(Battleground const* bg) const;
- @@ -2656,4 +2686,4 @@ void Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* s
- basevalue = T(float(basevalue + totalflat) * totalmul);
- }
- -#endif
- +#endif
- \ No newline at end of file
- diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
- index d324eb3..c864ae1 100644
- --- a/src/server/game/Entities/Unit/Unit.cpp
- +++ b/src/server/game/Entities/Unit/Unit.cpp
- @@ -16540,6 +16540,21 @@ uint32 Unit::GetModelForTotem(PlayerTotemType totemType)
- }
- break;
- }
- + default: // One standard for other races.
- + {
- + switch (totemType)
- + {
- + case SUMMON_TYPE_TOTEM_FIRE: // fire
- + return 4589;
- + case SUMMON_TYPE_TOTEM_EARTH: // earth
- + return 4588;
- + case SUMMON_TYPE_TOTEM_WATER: // water
- + return 4587;
- + case SUMMON_TYPE_TOTEM_AIR: // air
- + return 4590;
- + }
- + break;
- + }
- }
- return 0;
- }
- @@ -17667,4 +17682,4 @@ void Unit::Whisper(uint32 textId, Player* target, bool isBossWhisper /*= false*/
- WorldPacket data;
- ChatHandler::BuildChatPacket(data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, bct->GetText(locale, getGender()), 0, "", locale);
- target->SendDirectMessage(&data);
- -}
- +}
- \ No newline at end of file
- diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
- index d4ff575..b9f16c3 100644
- --- a/src/server/game/Entities/Unit/Unit.h
- +++ b/src/server/game/Entities/Unit/Unit.h
- @@ -1337,9 +1337,15 @@ class TC_GAME_API Unit : public WorldObject
- uint8 getLevel() const { return uint8(GetUInt32Value(UNIT_FIELD_LEVEL)); }
- uint8 getLevelForTarget(WorldObject const* /*target*/) const override { return getLevel(); }
- void SetLevel(uint8 lvl);
- - uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE); }
- - uint32 getRaceMask() const { return 1 << (getRace()-1); }
- +
- + uint8 getRace(bool forceoriginal = false) const;
- + uint8 getCFSRace() { return getRace(true); }
- +
- + uint32 getRaceMask() const { return 1 << (getRace() - 1); }
- +
- + uint32 getCFSRaceMask() const { return 1 << (getRace(true) - 1); }
- uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS); }
- +
- uint32 getClassMask() const { return 1 << (getClass()-1); }
- uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER); }
- @@ -2358,4 +2364,4 @@ namespace Trinity
- bool const _ascending;
- };
- }
- -#endif
- +#endif
- \ No newline at end of file
- diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp
- index 8723fff..b87b9fc 100644
- --- a/src/server/game/Handlers/BattleGroundHandler.cpp
- +++ b/src/server/game/Handlers/BattleGroundHandler.cpp
- @@ -561,7 +561,7 @@ void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket & /*recvData*/)
- {
- // this line is checked, i only don't know if GetStartTime is changing itself after bg end!
- // send status in Battleground
- - sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, i, STATUS_IN_PROGRESS, bg->GetEndTime(), bg->GetStartTime(), arenaType, _player->GetBGTeam());
- + sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, i, STATUS_IN_PROGRESS, bg->GetEndTime(), bg->GetStartTime(), arenaType, _player->GetTeam());
- SendPacket(&data);
- continue;
- }
- @@ -784,4 +784,4 @@ void WorldSession::HandleReportPvPAFK(WorldPacket& recvData)
- TC_LOG_DEBUG("bg.battleground", "WorldSession::HandleReportPvPAFK: %s reported %s", _player->GetName().c_str(), reportedPlayer->GetName().c_str());
- reportedPlayer->ReportedAfkBy(_player);
- -}
- +}
- \ No newline at end of file
- diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
- index b5adceb..b08bcef 100644
- --- a/src/server/game/Handlers/CharacterHandler.cpp
- +++ b/src/server/game/Handlers/CharacterHandler.cpp
- @@ -1005,6 +1005,9 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
- TC_METRIC_EVENT("player_events", "Login", pCurrChar->GetName());
- delete holder;
- +
- + if (pCurrChar->GetTeam() != pCurrChar->GetCFSTeam())
- + pCurrChar->FitPlayerInTeam(pCurrChar->GetBattleground() && !pCurrChar->GetBattleground()->isArena() ? true : false, pCurrChar->GetBattleground());
- }
- void WorldSession::HandleSetFactionAtWar(WorldPacket& recvData)
- @@ -2190,4 +2193,4 @@ void WorldSession::SendBarberShopResult(BarberShopResult result)
- WorldPacket data(SMSG_BARBER_SHOP_RESULT, 4);
- data << uint32(result);
- SendPacket(&data);
- -}
- +}
- \ No newline at end of file
- diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp
- index 0328a54..0c491f3 100644
- --- a/src/server/game/Handlers/ChatHandler.cpp
- +++ b/src/server/game/Handlers/ChatHandler.cpp
- @@ -62,6 +62,18 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
- return;
- }
- + if (sWorld->getBoolConfig(CROSSFACTION_SYSTEM_BATTLEGROUNDS) && lang != LANG_ADDON)
- + {
- + switch (type)
- + {
- + case CHAT_MSG_BATTLEGROUND:
- + case CHAT_MSG_BATTLEGROUND_LEADER:
- + lang = LANG_UNIVERSAL;
- + default:
- + break;
- + }
- + }
- +
- Player* sender = GetPlayer();
- //TC_LOG_DEBUG("CHAT: packet received. type %u, lang %u", type, lang);
- @@ -251,6 +263,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
- SendNotification(GetTrinityString(LANG_SAY_REQ), sWorld->getIntConfig(CONFIG_CHAT_SAY_LEVEL_REQ));
- return;
- }
- +
- + if (!GetPlayer()->IsGameMaster())
- + if (GetPlayer()->SendBattleGroundChat(type, msg))
- + return;
- if (type == CHAT_MSG_SAY)
- sender->Say(msg, Language(lang));
- @@ -643,4 +659,4 @@ void WorldSession::SendChatRestrictedNotice(ChatRestrictionType restriction)
- WorldPacket data(SMSG_CHAT_RESTRICTED, 1);
- data << uint8(restriction);
- SendPacket(&data);
- -}
- +}
- \ No newline at end of file
- diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
- index d89b717..771789d 100644
- --- a/src/server/game/Handlers/MiscHandler.cpp
- +++ b/src/server/game/Handlers/MiscHandler.cpp
- @@ -1442,6 +1442,21 @@ void WorldSession::HandleSetTitleOpcode(WorldPacket& recvData)
- void WorldSession::HandleTimeSyncResp(WorldPacket& recvData)
- {
- + Battleground* bg = _player->GetBattleground();
- + if (bg)
- + {
- + if (_player->ShouldForgetBGPlayers() && bg)
- + {
- + _player->DoForgetPlayersInBG(bg);
- + _player->SetForgetBGPlayers(false);
- + }
- + }
- + else if (_player->ShouldForgetInListPlayers())
- + {
- + _player->DoForgetPlayersInList();
- + _player->SetForgetInListPlayers(false);
- + }
- +
- TC_LOG_DEBUG("network", "CMSG_TIME_SYNC_RESP");
- uint32 counter, clientTicks;
- @@ -1820,4 +1835,4 @@ void WorldSession::HandleUpdateMissileTrajectory(WorldPacket& recvPacket)
- recvPacket.SetOpcode(opcode);
- HandleMovementOpcodes(recvPacket);
- }
- -}
- +}
- \ No newline at end of file
- diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp
- index 43e01d1..8bb3ffb 100644
- --- a/src/server/game/Handlers/QueryHandler.cpp
- +++ b/src/server/game/Handlers/QueryHandler.cpp
- @@ -45,7 +45,7 @@ void WorldSession::SendNameQueryOpcode(ObjectGuid guid)
- data << uint8(0); // name known
- data << nameData->Name; // played name
- data << uint8(0); // realm name - only set for cross realm interaction (such as Battlegrounds)
- - data << uint8(nameData->Race);
- + data << uint8(player ? player->getRace() : nameData->Race);
- data << uint8(nameData->Sex);
- data << uint8(nameData->Class);
- @@ -477,4 +477,4 @@ void WorldSession::HandleQuestPOIQuery(WorldPacket& recvData)
- }
- SendPacket(&data);
- -}
- +}
- \ No newline at end of file
- diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
- index 78359fc..5a473dd 100644
- --- a/src/server/game/World/World.cpp
- +++ b/src/server/game/World/World.cpp
- @@ -1083,6 +1083,8 @@ void World::LoadConfigSettings(bool reload)
- m_bool_configs[CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN] = sConfigMgr->GetBoolDefault("OffhandCheckAtSpellUnlearn", true);
- + m_bool_configs[CROSSFACTION_SYSTEM_BATTLEGROUNDS] = sConfigMgr->GetBoolDefault("CrossfactionBG.enable", true);
- +
- m_int_configs[CONFIG_CREATURE_PICKPOCKET_REFILL] = sConfigMgr->GetIntDefault("Creature.PickPocketRefillDelay", 10 * MINUTE);
- m_int_configs[CONFIG_CREATURE_STOP_FOR_PLAYER] = sConfigMgr->GetIntDefault("Creature.MovingStopTimeForPlayer", 3 * MINUTE * IN_MILLISECONDS);
- @@ -3357,4 +3359,4 @@ void World::RemoveOldCorpses()
- m_timers[WUPDATE_CORPSES].SetCurrent(m_timers[WUPDATE_CORPSES].GetInterval());
- }
- -Realm realm;
- +Realm realm;
- \ No newline at end of file
- diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
- index fcbbca1..d89edec 100644
- --- a/src/server/game/World/World.h
- +++ b/src/server/game/World/World.h
- @@ -90,6 +90,7 @@ enum WorldTimers
- enum WorldBoolConfigs
- {
- CONFIG_DURABILITY_LOSS_IN_PVP = 0,
- + CROSSFACTION_SYSTEM_BATTLEGROUNDS,
- CONFIG_ADDON_CHANNEL,
- CONFIG_ALLOW_PLAYER_COMMANDS,
- CONFIG_CLEAN_CHARACTER_DB,
- @@ -883,4 +884,4 @@ TC_GAME_API extern Realm realm;
- #define sWorld World::instance()
- #endif
- -/// @}
- +/// @}
- \ No newline at end of file
- diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
- index 8d5f018..781ec30 100644
- --- a/src/server/worldserver/worldserver.conf.dist
- +++ b/src/server/worldserver/worldserver.conf.dist
- @@ -35,6 +35,7 @@
- # LOGGING SYSTEM SETTINGS
- # PACKET SPOOF PROTECTION SETTINGS
- # METRIC SETTINGS
- +# CROSSFACTION BG CONFIG
- #
- ###################################################################################################
- @@ -3756,3 +3757,15 @@ Metric.OverallStatusInterval = 1
- #
- ###################################################################################################
- +
- +###################################################################################################
- +# CROSSFACTION BG CONFIG
- +#
- +#
- +# CrossfactionBG.enable = 1 - Mixed battleground enabled.
- +# CrossfactionBG.enable = 0 - Mixed battleground disabled.
- +
- +CrossfactionBG.enable = 1
- +
- +#
- +###################################################################################################
- \ No newline at end of file
- --
- 1.9.5.msysgit.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement