Advertisement
Guest User

CrossFactionBG.patch

a guest
Sep 11th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 79.36 KB | None | 0 0
  1. From 09f13547c1321ba9badd004d52ba4cfb639759f8 Mon Sep 17 00:00:00 2001
  2. From: Bodeguero <joaocarlos.jc.souza@gmail.com>
  3. Date: Tue, 26 Jul 2016 12:34:53 -0400
  4. Subject: [PATCH] Core/Fixes: Added System CFBG
  5.  
  6. * Update and Fixed All Bugs
  7. ---
  8. src/server/game/Battlegrounds/Arena.cpp | 6 +-
  9. src/server/game/Battlegrounds/Battleground.cpp | 52 +--
  10. src/server/game/Battlegrounds/Battleground.h | 4 +-
  11. src/server/game/Battlegrounds/BattlegroundMgr.cpp | 3 +-
  12. .../game/Battlegrounds/BattlegroundQueue.cpp | 84 +++--
  13. src/server/game/Battlegrounds/BattlegroundQueue.h | 13 +-
  14. .../game/Battlegrounds/Zones/BattlegroundAB.cpp | 4 +-
  15. .../game/Battlegrounds/Zones/BattlegroundAV.cpp | 21 +-
  16. .../game/Battlegrounds/Zones/BattlegroundWS.cpp | 7 +-
  17. src/server/game/CrossFactionBG/Cfbg.cpp | 356 +++++++++++++++++++++
  18. src/server/game/CrossFactionBG/Cfbg.h | 61 ++++
  19. src/server/game/Entities/Player/Player.cpp | 118 +++++--
  20. src/server/game/Entities/Player/Player.h | 40 ++-
  21. src/server/game/Entities/Unit/Unit.cpp | 17 +-
  22. src/server/game/Entities/Unit/Unit.h | 12 +-
  23. src/server/game/Handlers/BattleGroundHandler.cpp | 4 +-
  24. src/server/game/Handlers/CharacterHandler.cpp | 5 +-
  25. src/server/game/Handlers/ChatHandler.cpp | 18 +-
  26. src/server/game/Handlers/MiscHandler.cpp | 17 +-
  27. src/server/game/Handlers/QueryHandler.cpp | 4 +-
  28. src/server/game/World/World.cpp | 4 +-
  29. src/server/game/World/World.h | 3 +-
  30. src/server/worldserver/worldserver.conf.dist | 13 +
  31. 23 files changed, 750 insertions(+), 116 deletions(-)
  32. create mode 100644 src/server/game/CrossFactionBG/Cfbg.cpp
  33. create mode 100644 src/server/game/CrossFactionBG/Cfbg.h
  34.  
  35. diff --git a/src/server/game/Battlegrounds/Arena.cpp b/src/server/game/Battlegrounds/Arena.cpp
  36. index 861df5f..4f220ea 100644
  37. --- a/src/server/game/Battlegrounds/Arena.cpp
  38. +++ b/src/server/game/Battlegrounds/Arena.cpp
  39. @@ -40,9 +40,9 @@ Arena::Arena()
  40. void Arena::AddPlayer(Player* player)
  41. {
  42. Battleground::AddPlayer(player);
  43. - PlayerScores[player->GetGUID().GetCounter()] = new ArenaScore(player->GetGUID(), player->GetBGTeam());
  44. + PlayerScores[player->GetGUID().GetCounter()] = new ArenaScore(player->GetGUID(), player->GetTeam());
  45.  
  46. - if (player->GetBGTeam() == ALLIANCE) // gold
  47. + if (player->GetTeam() == ALLIANCE) // gold
  48. {
  49. if (player->GetTeam() == HORDE)
  50. player->CastSpell(player, SPELL_HORDE_GOLD_FLAG, true);
  51. @@ -249,4 +249,4 @@ void Arena::EndBattleground(uint32 winner)
  52.  
  53. // end battleground
  54. Battleground::EndBattleground(winner);
  55. -}
  56. +}
  57. \ No newline at end of file
  58. diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
  59. index 12a40e3..ee9509f 100644
  60. --- a/src/server/game/Battlegrounds/Battleground.cpp
  61. +++ b/src/server/game/Battlegrounds/Battleground.cpp
  62. @@ -286,7 +286,7 @@ inline void Battleground::_CheckSafePositions(uint32 diff)
  63. if (Player* player = ObjectAccessor::FindPlayer(itr->first))
  64. {
  65. Position pos = player->GetPosition();
  66. - Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam()));
  67. + Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetTeam()));
  68. if (pos.GetExactDistSq(startPos) > maxDist)
  69. {
  70. TC_LOG_DEBUG("bg.battleground", "BATTLEGROUND: Sending %s back to start location (map: %u) (possible exploit)", player->GetName().c_str(), GetMapId());
  71. @@ -501,7 +501,7 @@ inline void Battleground::_ProcessJoin(uint32 diff)
  72. WorldPacket status;
  73. BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(m_TypeID, GetArenaType());
  74. uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId);
  75. - sBattlegroundMgr->BuildBattlegroundStatusPacket(&status, this, queueSlot, STATUS_IN_PROGRESS, 0, GetStartTime(), GetArenaType(), player->GetBGTeam());
  76. + sBattlegroundMgr->BuildBattlegroundStatusPacket(&status, this, queueSlot, STATUS_IN_PROGRESS, 0, GetStartTime(), GetArenaType(), player->GetTeam());
  77. player->SendDirectMessage(&status);
  78.  
  79. player->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
  80. @@ -670,22 +670,36 @@ void Battleground::RewardHonorToTeam(uint32 Honor, uint32 TeamID)
  81. UpdatePlayerScore(player, SCORE_BONUS_HONOR, Honor);
  82. }
  83.  
  84. -void Battleground::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID)
  85. +void Battleground::RewardReputationToTeam(uint32 a_faction_id, uint32 h_faction_id, uint32 Reputation, uint32 TeamID)
  86. {
  87. - FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id);
  88. - if (!factionEntry)
  89. - return;
  90. + FactionEntry const* a_factionEntry = sFactionStore.LookupEntry(a_faction_id);
  91. + FactionEntry const* h_factionEntry = sFactionStore.LookupEntry(h_faction_id);
  92.  
  93. for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
  94. {
  95. Player* player = _GetPlayerForTeam(TeamID, itr, "RewardReputationToTeam");
  96. - if (!player)
  97. - continue;
  98. + if (!a_factionEntry || !h_factionEntry)
  99. + return;
  100.  
  101. - uint32 repGain = Reputation;
  102. - AddPct(repGain, player->GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN));
  103. - AddPct(repGain, player->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, faction_id));
  104. - player->GetReputationMgr().ModifyReputation(factionEntry, repGain);
  105. + for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
  106. + {
  107. + if (itr->second.OfflineRemoveTime)
  108. + continue;
  109. +
  110. + Player* player = ObjectAccessor::FindPlayer(itr->first);
  111. +
  112. + if (!player)
  113. + {
  114. + TC_LOG_ERROR("bg.battleground", "BattleGround:RewardReputationToTeam: %u not found!", itr->first);
  115. + continue;
  116. + }
  117. + uint32 team = player->GetTeam();
  118. + if (team == TeamID)
  119. + if (Player* player = _GetPlayerForTeam(TeamID, itr, "RewardReputationToTeam"))
  120. + {
  121. + player->GetReputationMgr().ModifyReputation(player->GetCFSTeam() == ALLIANCE ? a_factionEntry : h_factionEntry, Reputation);
  122. + }
  123. + }
  124. }
  125. }
  126.  
  127. @@ -839,7 +853,7 @@ void Battleground::EndBattleground(uint32 winner)
  128. player->SendDirectMessage(&pvpLogData);
  129.  
  130. WorldPacket data;
  131. - sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType(), player->GetBGTeam());
  132. + sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType(), player->GetTeam());
  133. player->SendDirectMessage(&data);
  134. player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, 1);
  135. }
  136. @@ -958,6 +972,7 @@ void Battleground::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool Sen
  137.  
  138. if (player)
  139. {
  140. + player->FitPlayerInTeam(false, this);
  141. // Do next only if found in battleground
  142. player->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG.
  143. // reset destination bg team
  144. @@ -1026,7 +1041,7 @@ void Battleground::AddPlayer(Player* player)
  145.  
  146. // score struct must be created in inherited class
  147.  
  148. - uint32 team = player->GetBGTeam();
  149. + uint32 team = player->GetTeam();
  150.  
  151. BattlegroundPlayer bp;
  152. bp.OfflineRemoveTime = 0;
  153. @@ -1077,6 +1092,7 @@ void Battleground::AddPlayer(Player* player)
  154. // setup BG group membership
  155. PlayerAddedToBGCheckIfBGIsRunning(player);
  156. AddOrSetPlayerToCorrectBgGroup(player, team);
  157. + player->FitPlayerInTeam(true, this);
  158. }
  159.  
  160. // this method adds player to his team's bg group, or sets his correct group if player is already in bg group
  161. @@ -1146,8 +1162,8 @@ void Battleground::EventPlayerLoggedOut(Player* player)
  162.  
  163. // 1 player is logging out, if it is the last, then end arena!
  164. if (isArena())
  165. - if (GetAlivePlayersCountByTeam(player->GetBGTeam()) <= 1 && GetPlayersCountByTeam(GetOtherTeam(player->GetBGTeam())))
  166. - EndBattleground(GetOtherTeam(player->GetBGTeam()));
  167. + if (GetAlivePlayersCountByTeam(player->GetTeam()) <= 1 && GetPlayersCountByTeam(GetOtherTeam(player->GetTeam())))
  168. + EndBattleground(GetOtherTeam(player->GetTeam()));
  169. }
  170. }
  171.  
  172. @@ -1770,7 +1786,7 @@ void Battleground::PlayerAddedToBGCheckIfBGIsRunning(Player* player)
  173. BuildPvPLogDataPacket(data);
  174. player->SendDirectMessage(&data);
  175.  
  176. - sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType(), player->GetBGTeam());
  177. + sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType(), player->GetTeam());
  178. player->SendDirectMessage(&data);
  179. }
  180.  
  181. @@ -1862,4 +1878,4 @@ bool Battleground::CheckAchievementCriteriaMeet(uint32 criteriaId, Player const*
  182. uint8 Battleground::GetUniqueBracketId() const
  183. {
  184. return GetMinLevel() / 10;
  185. -}
  186. +}
  187. \ No newline at end of file
  188. diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h
  189. index ec17b94..2c95a42 100644
  190. --- a/src/server/game/Battlegrounds/Battleground.h
  191. +++ b/src/server/game/Battlegrounds/Battleground.h
  192. @@ -365,7 +365,7 @@ class TC_GAME_API Battleground
  193. void CastSpellOnTeam(uint32 SpellID, uint32 TeamID);
  194. void RemoveAuraOnTeam(uint32 SpellID, uint32 TeamID);
  195. void RewardHonorToTeam(uint32 Honor, uint32 TeamID);
  196. - void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID);
  197. + void RewardReputationToTeam(uint32 a_faction_id, uint32 h_faction_id, uint32 Reputation, uint32 TeamID);
  198. void UpdateWorldState(uint32 Field, uint32 Value);
  199. void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player* player);
  200. virtual void EndBattleground(uint32 winner);
  201. @@ -610,4 +610,4 @@ class TC_GAME_API Battleground
  202. float m_StartMaxDist;
  203. uint32 ScriptId;
  204. };
  205. -#endif
  206. +#endif
  207. \ No newline at end of file
  208. diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
  209. index 745322f..bebfec5 100644
  210. --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp
  211. +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
  212. @@ -699,7 +699,7 @@ void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, Batt
  213. if (Battleground* bg = GetBattleground(instanceId, bgTypeId))
  214. {
  215. uint32 mapid = bg->GetMapId();
  216. - uint32 team = player->GetBGTeam();
  217. + uint32 team = player->GetTeam();
  218. if (team == 0)
  219. team = player->GetTeam();
  220.  
  221. @@ -1029,4 +1029,3 @@ void BattlegroundMgr::RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 ins
  222. {
  223. bgDataStore[bgTypeId].m_Battlegrounds.erase(instanceId);
  224. }
  225. -
  226. diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
  227. index ceda30d..c06de1e 100644
  228. --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp
  229. +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
  230. @@ -154,6 +154,10 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr
  231. index += BG_TEAMS_COUNT;
  232. if (ginfo->Team == HORDE)
  233. index++;
  234. +
  235. + if (sWorld->getBoolConfig(CROSSFACTION_SYSTEM_BATTLEGROUNDS) && ArenaType == 0)
  236. + index = BG_QUEUE_CROSSFACTION;
  237. +
  238. TC_LOG_DEBUG("bg.battleground", "Adding Group to BattlegroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracketId, index);
  239.  
  240. uint32 lastOnlineTime = getMSTime();
  241. @@ -198,30 +202,58 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr
  242. {
  243. if (Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(ginfo->BgTypeId))
  244. {
  245. - uint32 MinPlayers = bg->GetMinPlayersPerTeam();
  246. - uint32 qHorde = 0;
  247. - uint32 qAlliance = 0;
  248. - uint32 q_min_level = bracketEntry->minLevel;
  249. - uint32 q_max_level = bracketEntry->maxLevel;
  250. - GroupsQueueType::const_iterator itr;
  251. - for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].end(); ++itr)
  252. - if (!(*itr)->IsInvitedToBGInstanceGUID)
  253. - qAlliance += (*itr)->Players.size();
  254. - for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].end(); ++itr)
  255. - if (!(*itr)->IsInvitedToBGInstanceGUID)
  256. - qHorde += (*itr)->Players.size();
  257. -
  258. - // Show queue status to player only (when joining queue)
  259. - if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
  260. + if (sWorld->getBoolConfig(CROSSFACTION_SYSTEM_BATTLEGROUNDS))
  261. {
  262. - ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bg->GetName().c_str(), q_min_level, q_max_level,
  263. - qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
  264. + char const* bgName = bg->GetName().c_str();
  265. + uint32 MinPlayers = bg->GetMinPlayersPerTeam() * 2;
  266. + uint32 qPlayers = 0;
  267. + uint32 q_min_level = bracketEntry->minLevel;
  268. + uint32 q_max_level = bracketEntry->maxLevel;
  269. + for (GroupsQueueType::const_iterator itr = m_QueuedGroups[bracketId][BG_QUEUE_CROSSFACTION].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_CROSSFACTION].end(); ++itr)
  270. + if (!(*itr)->IsInvitedToBGInstanceGUID)
  271. + qPlayers += (*itr)->Players.size();
  272. +
  273. + if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
  274. + {
  275. + 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);
  276. + }
  277. + else
  278. + {
  279. + std::ostringstream ss;
  280. + ss << "|cffff0000[BG Queue Announcer]:|r " << bgName << " -- [" << q_min_level << "-" << q_max_level << "] " << qPlayers << "/" << MinPlayers;
  281. + sWorld->SendGlobalText(ss.str().c_str(), NULL);
  282. + }
  283. }
  284. // System message
  285. else
  286. {
  287. - sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bg->GetName().c_str(), q_min_level, q_max_level,
  288. - qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
  289. + // std::string bgName = bg->GetName().c_str();
  290. + char const* bgName = bg->GetName().c_str();
  291. + uint32 MinPlayers = bg->GetMinPlayersPerTeam();
  292. + uint32 qHorde = 0;
  293. + uint32 qAlliance = 0;
  294. + uint32 q_min_level = bracketEntry->minLevel;
  295. + uint32 q_max_level = bracketEntry->maxLevel;
  296. + GroupsQueueType::const_iterator itr;
  297. + for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].end(); ++itr)
  298. + if (!(*itr)->IsInvitedToBGInstanceGUID)
  299. + qAlliance += (*itr)->Players.size();
  300. + for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].end(); ++itr)
  301. + if (!(*itr)->IsInvitedToBGInstanceGUID)
  302. + qHorde += (*itr)->Players.size();
  303. +
  304. + // Show queue status to player only (when joining queue)
  305. + if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
  306. + {
  307. + ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level, //******
  308. + qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
  309. + }
  310. + // System message
  311. + else
  312. + {
  313. + sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level, //*******
  314. + qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
  315. + }
  316. }
  317. }
  318. }
  319. @@ -309,7 +341,7 @@ void BattlegroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount)
  320. {
  321. //we must check premade and normal team's queue - because when players from premade are joining bg,
  322. //they leave groupinfo so we can't use its players size to find out index
  323. - for (uint32 j = index; j < BG_QUEUE_GROUP_TYPES_COUNT; j += BG_TEAMS_COUNT)
  324. + for (uint8 j = 0; j < BG_QUEUE_GROUP_TYPES_COUNT; ++j)
  325. {
  326. GroupsQueueType::iterator k = m_QueuedGroups[bracket_id_tmp][j].begin();
  327. for (; k != m_QueuedGroups[bracket_id_tmp][j].end(); ++k)
  328. @@ -500,6 +532,10 @@ void BattlegroundQueue::FillPlayersToBG(Battleground* bg, BattlegroundBracketId
  329. uint32 aliCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].size();
  330. uint32 hordeCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].size();
  331.  
  332. + if (!bg->isArena())
  333. + if (FillXPlayersToBG(bracket_id, bg, false))
  334. + return;
  335. +
  336. // try to get even teams
  337. if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == BG_QUEUE_INVITATION_TYPE_EVEN)
  338. {
  339. @@ -773,7 +809,8 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
  340. if (m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].empty() &&
  341. m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].empty() &&
  342. m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].empty() &&
  343. - m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].empty())
  344. + m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].empty() &&
  345. + m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].empty())
  346. return;
  347.  
  348. // battleground with free slot for player should be always in the beggining of the queue
  349. @@ -864,7 +901,8 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
  350. {
  351. // if there are enough players in pools, start new battleground or non rated arena
  352. if (CheckNormalMatch(bg_template, bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam)
  353. - || (bg_template->isArena() && CheckSkirmishForSameFaction(bracket_id, MinPlayersPerTeam)))
  354. + || (bg_template->isArena() && CheckSkirmishForSameFaction(bracket_id, MinPlayersPerTeam))
  355. + || CheckCrossFactionMatch(bracket_id, bg_template))
  356. {
  357. // we successfully created a pool
  358. Battleground* bg2 = sBattlegroundMgr->CreateNewBattleground(bgTypeId, bracketEntry, arenaType, false);
  359. @@ -1099,4 +1137,4 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
  360. void BGQueueRemoveEvent::Abort(uint64 /*e_time*/)
  361. {
  362. //do nothing
  363. -}
  364. +}
  365. \ No newline at end of file
  366. diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h
  367. index 600c5f3..b561414 100644
  368. --- a/src/server/game/Battlegrounds/BattlegroundQueue.h
  369. +++ b/src/server/game/Battlegrounds/BattlegroundQueue.h
  370. @@ -42,6 +42,7 @@ struct GroupQueueInfo // stores informatio
  371. {
  372. std::map<ObjectGuid, PlayerQueueInfo*> Players; // player queue info map
  373. uint32 Team; // Player team (ALLIANCE/HORDE)
  374. + uint32 CFSTeam;
  375. BattlegroundTypeId BgTypeId; // battleground type id
  376. bool IsRated; // rated
  377. uint8 ArenaType; // 2v2, 3v3, 5v5 or 0 when BG
  378. @@ -60,9 +61,10 @@ enum BattlegroundQueueGroupTypes
  379. BG_QUEUE_PREMADE_ALLIANCE = 0,
  380. BG_QUEUE_PREMADE_HORDE = 1,
  381. BG_QUEUE_NORMAL_ALLIANCE = 2,
  382. - BG_QUEUE_NORMAL_HORDE = 3
  383. + BG_QUEUE_NORMAL_HORDE = 3,
  384. + BG_QUEUE_CROSSFACTION = 4
  385. };
  386. -#define BG_QUEUE_GROUP_TYPES_COUNT 4
  387. +#define BG_QUEUE_GROUP_TYPES_COUNT 5
  388.  
  389. enum BattlegroundQueueInvitationType
  390. {
  391. @@ -81,6 +83,11 @@ class TC_GAME_API BattlegroundQueue
  392. void BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id, uint8 arenaType = 0, bool isRated = false, uint32 minRating = 0);
  393. void UpdateEvents(uint32 diff);
  394.  
  395. + bool FillXPlayersToBG(BattlegroundBracketId bracket_id, Battleground* bg, bool start = false);
  396. + typedef std::multimap<int32, GroupQueueInfo*> QueuedGroupMap;
  397. + int32 PreAddPlayers(QueuedGroupMap m_PreGroupMap, int32 MaxAdd, uint32 MaxInTeam);
  398. + bool CheckCrossFactionMatch(BattlegroundBracketId bracket_id, Battleground* bg);
  399. +
  400. void FillPlayersToBG(Battleground* bg, BattlegroundBracketId bracket_id);
  401. bool CheckPremadeMatch(BattlegroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam);
  402. bool CheckNormalMatch(Battleground* bg_template, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers);
  403. @@ -184,4 +191,4 @@ class TC_GAME_API BGQueueRemoveEvent : public BasicEvent
  404. BattlegroundQueueTypeId m_BgQueueTypeId;
  405. };
  406.  
  407. -#endif
  408. +#endif
  409. \ No newline at end of file
  410. diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
  411. index 12cb99d..c8a2833 100644
  412. --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
  413. +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
  414. @@ -139,7 +139,7 @@ void BattlegroundAB::PostUpdateImpl(uint32 diff)
  415.  
  416. if (m_ReputationScoreTics[team] >= m_ReputationTics)
  417. {
  418. - (team == TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE);
  419. + RewardReputationToTeam(509, 510, 10, team == ALLIANCE ? ALLIANCE : HORDE);
  420. m_ReputationScoreTics[team] -= m_ReputationTics;
  421. }
  422.  
  423. @@ -729,4 +729,4 @@ bool BattlegroundAB::CheckAchievementCriteriaMeet(uint32 criteriaId, Player cons
  424. }
  425.  
  426. return Battleground::CheckAchievementCriteriaMeet(criteriaId, player, target, miscvalue);
  427. -}
  428. +}
  429. \ No newline at end of file
  430. diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
  431. index 90d30fb..eb05915 100644
  432. --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
  433. +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
  434. @@ -87,7 +87,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
  435. if (entry == BG_AV_CreatureInfo[AV_NPC_A_BOSS])
  436. {
  437. CastSpellOnTeam(23658, HORDE); //this is a spell which finishes a quest where a player has to kill the boss
  438. - RewardReputationToTeam(729, BG_AV_REP_BOSS, HORDE);
  439. + RewardReputationToTeam(729, 730, BG_AV_REP_BOSS, killer->GetTeam() == ALLIANCE ? ALLIANCE : HORDE);
  440. RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_BOSS), HORDE);
  441. EndBattleground(HORDE);
  442. DelCreature(AV_CPLACE_TRIGGER17);
  443. @@ -95,7 +95,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
  444. else if (entry == BG_AV_CreatureInfo[AV_NPC_H_BOSS])
  445. {
  446. CastSpellOnTeam(23658, ALLIANCE); //this is a spell which finishes a quest where a player has to kill the boss
  447. - RewardReputationToTeam(730, BG_AV_REP_BOSS, ALLIANCE);
  448. + RewardReputationToTeam(729, 730, BG_AV_REP_BOSS, killer->GetTeam() == ALLIANCE ? ALLIANCE : HORDE);
  449. RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_BOSS), ALLIANCE);
  450. EndBattleground(ALLIANCE);
  451. DelCreature(AV_CPLACE_TRIGGER19);
  452. @@ -108,7 +108,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
  453. return;
  454. }
  455. m_CaptainAlive[0]=false;
  456. - RewardReputationToTeam(729, BG_AV_REP_CAPTAIN, HORDE);
  457. + RewardReputationToTeam(729, 730, BG_AV_REP_CAPTAIN, killer->GetTeam() == ALLIANCE ? ALLIANCE : HORDE);
  458. RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_CAPTAIN), HORDE);
  459. UpdateScore(ALLIANCE, (-1)*BG_AV_RES_CAPTAIN);
  460. //spawn destroyed aura
  461. @@ -127,7 +127,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
  462. return;
  463. }
  464. m_CaptainAlive[1]=false;
  465. - RewardReputationToTeam(730, BG_AV_REP_CAPTAIN, ALLIANCE);
  466. + RewardReputationToTeam(729, 730, BG_AV_REP_CAPTAIN, killer->GetTeam() == ALLIANCE ? ALLIANCE : HORDE);
  467. RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_CAPTAIN), ALLIANCE);
  468. UpdateScore(HORDE, (-1)*BG_AV_RES_CAPTAIN);
  469. //spawn destroyed aura
  470. @@ -149,6 +149,7 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player)
  471. if (GetStatus() != STATUS_IN_PROGRESS)
  472. return;//maybe we should log this, cause this must be a cheater or a big bug
  473. uint8 team = GetTeamIndexByTeamId(player->GetTeam());
  474. + uint8 CFSteam = GetTeamIndexByTeamId(GetOtherTeam(player->GetTeam()));
  475. /// @todo add reputation, events (including quest not available anymore, next quest available, go/npc de/spawning)and maybe honor
  476. TC_LOG_DEBUG("bg.battleground", "BG_AV Quest %i completed", questid);
  477. switch (questid)
  478. @@ -173,21 +174,21 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player)
  479. case AV_QUEST_A_COMMANDER1:
  480. case AV_QUEST_H_COMMANDER1:
  481. m_Team_QuestStatus[team][1]++;
  482. - RewardReputationToTeam(team, 1, player->GetTeam());
  483. + RewardReputationToTeam(team, CFSteam, 1, player->GetTeam());
  484. if (m_Team_QuestStatus[team][1] == 30)
  485. TC_LOG_DEBUG("bg.battleground", "BG_AV Quest %i completed (need to implement some events here", questid);
  486. break;
  487. case AV_QUEST_A_COMMANDER2:
  488. case AV_QUEST_H_COMMANDER2:
  489. m_Team_QuestStatus[team][2]++;
  490. - RewardReputationToTeam(team, 1, player->GetTeam());
  491. + RewardReputationToTeam(team, CFSteam, 1, player->GetTeam());
  492. if (m_Team_QuestStatus[team][2] == 60)
  493. TC_LOG_DEBUG("bg.battleground", "BG_AV Quest %i completed (need to implement some events here", questid);
  494. break;
  495. case AV_QUEST_A_COMMANDER3:
  496. case AV_QUEST_H_COMMANDER3:
  497. m_Team_QuestStatus[team][3]++;
  498. - RewardReputationToTeam(team, 1, player->GetTeam());
  499. + RewardReputationToTeam(team, CFSteam, 1, player->GetTeam());
  500. if (m_Team_QuestStatus[team][3] == 120)
  501. TC_LOG_DEBUG("bg.battleground", "BG_AV Quest %i completed (need to implement some events here", questid);
  502. break;
  503. @@ -469,7 +470,7 @@ void BattlegroundAV::EndBattleground(uint32 winner)
  504. rep[i] += BG_AV_REP_SURVIVING_CAPTAIN;
  505. }
  506. if (rep[i] != 0)
  507. - RewardReputationToTeam(i == 0 ? 730 : 729, rep[i], i == 0 ? ALLIANCE : HORDE);
  508. + RewardReputationToTeam(729, 730, 10, i == ALLIANCE ? ALLIANCE : HORDE);
  509. if (kills[i] != 0)
  510. RewardHonorToTeam(GetBonusHonorFromKill(kills[i]), i == 0 ? ALLIANCE : HORDE);
  511. }
  512. @@ -574,7 +575,7 @@ void BattlegroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node)
  513. SpawnBGObject(BG_AV_OBJECT_BURN_DUNBALDAR_SOUTH + i + (tmp * 10), RESPAWN_IMMEDIATELY);
  514.  
  515. UpdateScore((owner == ALLIANCE) ? HORDE : ALLIANCE, -1 * BG_AV_RES_TOWER);
  516. - RewardReputationToTeam(owner == ALLIANCE ? 730 : 729, BG_AV_REP_TOWER, owner);
  517. + RewardReputationToTeam(729, 730, BG_AV_REP_TOWER, owner);
  518. RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_TOWER), owner);
  519.  
  520. SpawnBGObject(BG_AV_OBJECT_TAURA_A_DUNBALDAR_SOUTH+GetTeamIndexByTeamId(owner)+(2*tmp), RESPAWN_ONE_DAY);
  521. @@ -1566,4 +1567,4 @@ uint32 BattlegroundAV::GetPrematureWinner()
  522. return HORDE;
  523.  
  524. return Battleground::GetPrematureWinner();
  525. -}
  526. +}
  527. \ No newline at end of file
  528. diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
  529. index 950d2b5..d37e7f9 100644
  530. --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
  531. +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
  532. @@ -307,7 +307,7 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* player)
  533. if (GetTeamScore(TEAM_ALLIANCE) < BG_WS_MAX_TEAM_SCORE)
  534. AddPoint(ALLIANCE, 1);
  535. PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE);
  536. - RewardReputationToTeam(890, m_ReputationCapture, ALLIANCE);
  537. +
  538. }
  539. else
  540. {
  541. @@ -326,8 +326,9 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* player)
  542. if (GetTeamScore(TEAM_HORDE) < BG_WS_MAX_TEAM_SCORE)
  543. AddPoint(HORDE, 1);
  544. PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE);
  545. - RewardReputationToTeam(889, m_ReputationCapture, HORDE);
  546. +
  547. }
  548. + RewardReputationToTeam(890, 889, m_ReputationCapture, player->GetTeam());
  549. //for flag capture is reward 2 honorable kills
  550. RewardHonorToTeam(GetBonusHonorFromKill(2), player->GetTeam());
  551.  
  552. @@ -889,4 +890,4 @@ bool BattlegroundWS::CheckAchievementCriteriaMeet(uint32 criteriaId, Player cons
  553. }
  554.  
  555. return Battleground::CheckAchievementCriteriaMeet(criteriaId, player, target, miscValue);
  556. -}
  557. +}
  558. \ No newline at end of file
  559. diff --git a/src/server/game/CrossFactionBG/Cfbg.cpp b/src/server/game/CrossFactionBG/Cfbg.cpp
  560. new file mode 100644
  561. index 0000000..3143177
  562. --- /dev/null
  563. +++ b/src/server/game/CrossFactionBG/Cfbg.cpp
  564. @@ -0,0 +1,356 @@
  565. +/*
  566. + * Copyright (C) 2008-2016 FineWoWCore <http://www.finewow.com.br/>
  567. + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
  568. + *
  569. + * This program is free software; you can redistribute it and/or modify it
  570. + * under the terms of the GNU General Public License as published by the
  571. + * Free Software Foundation; either version 2 of the License, or (at your
  572. + * option) any later version.
  573. + *
  574. + * This program is distributed in the hope that it will be useful, but WITHOUT
  575. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  576. + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  577. + * more details.
  578. + *
  579. + * You should have received a copy of the GNU General Public License along
  580. + * with this program. If not, see <http://www.gnu.org/licenses/>.
  581. + */
  582. +
  583. +#include "Cfbg.h"
  584. +#include "Battleground.h"
  585. +#include "BattlegroundMgr.h"
  586. +#include "Player.h"
  587. +#include "Chat.h"
  588. +#include "BattlegroundQueue.h"
  589. +
  590. +/*####################################################################################
  591. +###############################CROSSFACTION BATTLEGROUNDS#############################
  592. +####################################################################################*/
  593. +uint8 Unit::getRace(bool forceoriginal) const
  594. +{
  595. + if (GetTypeId() == TYPEID_PLAYER)
  596. + {
  597. + Player* pPlayer = ((Player*)this);
  598. +
  599. + if (forceoriginal)
  600. + return pPlayer->getCFSRace();
  601. +
  602. + if (pPlayer->InArena())
  603. + return GetByteValue(UNIT_FIELD_BYTES_0, 0);
  604. +
  605. + if (!pPlayer->IsPlayingNative())
  606. + return pPlayer->getFRace();
  607. + }
  608. +
  609. + return GetByteValue(UNIT_FIELD_BYTES_0, 0);
  610. +}
  611. +
  612. +bool Player::SendRealNameQuery()
  613. +{
  614. + if (IsPlayingNative())
  615. + return false;
  616. +
  617. + WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + 1 + 1 + 1 + 1 + 1 + 10));
  618. + data.appendPackGUID(GetGUID()); // player guid
  619. + data << uint8(0); // added in 3.1; if > 1, then end of packet
  620. + data << GetName(); // played name
  621. + data << uint8(0); // realm name for cross realm BG usage
  622. + data << uint8(getCFSRace());
  623. + data << uint8(getGender());
  624. + data << uint8(getClass());
  625. + data << uint8(0); // is not declined
  626. + GetSession()->SendPacket(&data);
  627. +
  628. + return true;
  629. +}
  630. +
  631. +void Player::SetFakeRaceAndMorph()
  632. +{
  633. + if (getClass() == CLASS_DRUID)
  634. + {
  635. + if (GetCFSTeam() == ALLIANCE)
  636. + {
  637. + m_FakeMorph = getGender() == GENDER_MALE ? FAKE_M_TAUREN : FAKE_F_TAUREN;
  638. + m_FakeRace = RACE_TAUREN;
  639. + }
  640. + else if (getGender() == GENDER_MALE) // HORDE PLAYER, ONLY HAVE MALE NELF ID
  641. + {
  642. + m_FakeMorph = FAKE_M_NELF;
  643. + m_FakeRace = RACE_NIGHTELF;
  644. + }
  645. + else
  646. + m_FakeRace = GetCFSTeam() == ALLIANCE ? RACE_BLOODELF : RACE_HUMAN;
  647. + }
  648. + else if (getClass() == CLASS_SHAMAN && GetCFSTeam() == HORDE && getGender() == GENDER_FEMALE)
  649. + {
  650. + m_FakeMorph = FAKE_F_DRAENEI; // Female Draenei
  651. + m_FakeRace = RACE_DRAENEI;
  652. + }
  653. + else
  654. + {
  655. + m_FakeRace = GetCFSTeam() == ALLIANCE ? RACE_BLOODELF : RACE_HUMAN;
  656. +
  657. + if (GetCFSTeam() == HORDE)
  658. + {
  659. + if (getGender() == GENDER_MALE)
  660. + m_FakeMorph = 19723;
  661. + else
  662. + m_FakeMorph = 19724;
  663. + }
  664. + else
  665. + {
  666. + if (getGender() == GENDER_MALE)
  667. + m_FakeMorph = 20578;
  668. + else
  669. + m_FakeMorph = 20579;
  670. + }
  671. + }
  672. +}
  673. +
  674. +bool Player::SendBattleGroundChat(uint32 msgtype, std::string message)
  675. +{
  676. + // Select distance to broadcast to.
  677. + float distance = msgtype == CHAT_MSG_SAY ? sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY) : sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL);
  678. +
  679. + if (Battleground* bg = GetBattleground())
  680. + {
  681. + if (bg->isArena()) // Only fake chat in BG's. CFBG should not interfere with arenas.
  682. + return false;
  683. +
  684. + for (Battleground::BattlegroundPlayerMap::const_iterator itr = bg->GetPlayers().begin(); itr != bg->GetPlayers().end(); ++itr)
  685. + {
  686. + if (Player* player = ObjectAccessor::FindPlayer(itr->first))
  687. + {
  688. + if (GetDistance2d(player->GetPositionX(), player->GetPositionY()) <= distance)
  689. + {
  690. + WorldPacket data(SMSG_MESSAGECHAT, 200);
  691. +
  692. + if (GetTeam() == player->GetTeam())
  693. + BuildPlayerChat(&data, msgtype, message, LANG_UNIVERSAL);
  694. + else if (msgtype != CHAT_MSG_EMOTE)
  695. + BuildPlayerChat(&data, msgtype, message, player->GetTeam() == ALLIANCE ? LANG_ORCISH : LANG_COMMON);
  696. +
  697. + player->GetSession()->SendPacket(&data);
  698. + }
  699. + }
  700. + }
  701. + return true;
  702. + }
  703. + else
  704. + return false;
  705. +}
  706. +
  707. +void Player::MorphFit(bool value)
  708. +{
  709. + if (!IsPlayingNative() && value)
  710. + {
  711. + SetDisplayId(GetFakeMorph());
  712. + SetNativeDisplayId(GetFakeMorph());
  713. + }
  714. + else
  715. + InitDisplayIds();
  716. +}
  717. +
  718. +void Player::FitPlayerInTeam(bool action, Battleground* pBattleGround)
  719. +{
  720. + if (!pBattleGround)
  721. + pBattleGround = GetBattleground();
  722. +
  723. + if ((!pBattleGround || pBattleGround->isArena()) && action)
  724. + return;
  725. +
  726. + if (!IsPlayingNative() && action)
  727. + setFactionForRace(getRace());
  728. + else
  729. + setFactionForRace(getCFSRace());
  730. +
  731. + if (action)
  732. + SetForgetBGPlayers(true);
  733. + else
  734. + SetForgetInListPlayers(true);
  735. +
  736. + MorphFit(action);
  737. +
  738. + if (pBattleGround && action)
  739. + 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());
  740. +}
  741. +
  742. +void Player::DoForgetPlayersInList()
  743. +{
  744. + // m_FakePlayers is filled from a vector within the battleground
  745. + // they were in previously so all players that have been in that BG will be invalidated.
  746. + for (FakePlayers::const_iterator itr = m_FakePlayers.begin(); itr != m_FakePlayers.end(); ++itr)
  747. + {
  748. + WorldPacket data(SMSG_INVALIDATE_PLAYER, 8);
  749. + data << *itr;
  750. + GetSession()->SendPacket(&data);
  751. + if (Player* pPlayer = ObjectAccessor::FindPlayer(ObjectGuid(*itr)))
  752. + // if (Player* pPlayer = ObjectAccessor::FindPlayer(*itr))
  753. + GetSession()->SendNameQueryOpcode(pPlayer->GetGUID());
  754. + }
  755. + m_FakePlayers.clear();
  756. +}
  757. +
  758. +void Player::DoForgetPlayersInBG(Battleground* pBattleGround)
  759. +{
  760. + for (Battleground::BattlegroundPlayerMap::const_iterator itr = pBattleGround->GetPlayers().begin(); itr != pBattleGround->GetPlayers().end(); ++itr)
  761. + {
  762. + // Here we invalidate players in the bg to the added player
  763. + WorldPacket data1(SMSG_INVALIDATE_PLAYER, 8);
  764. + data1 << itr->first;
  765. + GetSession()->SendPacket(&data1);
  766. +
  767. + if (Player* pPlayer = ObjectAccessor::FindPlayer(itr->first))
  768. + {
  769. + GetSession()->SendNameQueryOpcode(pPlayer->GetGUID()); // Send namequery answer instantly if player is available
  770. + // Here we invalidate the player added to players in the bg
  771. + WorldPacket data2(SMSG_INVALIDATE_PLAYER, 8);
  772. + data2 << GetGUID();
  773. + pPlayer->GetSession()->SendPacket(&data2);
  774. + pPlayer->GetSession()->SendNameQueryOpcode(GetGUID());
  775. + }
  776. + }
  777. +}
  778. +
  779. +bool BattlegroundQueue::CheckCrossFactionMatch(BattlegroundBracketId bracket_id, Battleground* bg)
  780. +{
  781. + if (!sWorld->getBoolConfig(CROSSFACTION_SYSTEM_BATTLEGROUNDS) || bg->isArena())
  782. + return false; // Only do this if crossbg's are enabled.
  783. +
  784. + // Here we will add all players to selectionpool, later we check if there are enough and launch a bg.
  785. + FillXPlayersToBG(bracket_id, bg, true);
  786. +
  787. + if (sBattlegroundMgr->isTesting() && (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() || m_SelectionPools[TEAM_HORDE].GetPlayerCount()))
  788. + return true;
  789. +
  790. + uint8 MPT = bg->GetMinPlayersPerTeam();
  791. + if (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() < MPT || m_SelectionPools[TEAM_HORDE].GetPlayerCount() < MPT)
  792. + return false;
  793. +
  794. + return true;
  795. +}
  796. +
  797. +// This function will invite players in the least populated faction, which makes battleground queues much faster.
  798. +// This function will return true if cross faction battlegrounds are enabled, otherwise return false,
  799. +// which is useful in FillPlayersToBG. Because then we can interrupt the regular invitation if cross faction bg's are enabled.
  800. +bool BattlegroundQueue::FillXPlayersToBG(BattlegroundBracketId bracket_id, Battleground* bg, bool start)
  801. +{
  802. + uint8 queuedPeople = 0;
  803. + for (GroupsQueueType::const_iterator itr = m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].end(); ++itr)
  804. + if (!(*itr)->IsInvitedToBGInstanceGUID)
  805. + queuedPeople += (*itr)->Players.size();
  806. +
  807. + if (sWorld->getBoolConfig(CROSSFACTION_SYSTEM_BATTLEGROUNDS) && (sBattlegroundMgr->isTesting() || queuedPeople >= bg->GetMinPlayersPerTeam() * 2 || !start))
  808. + {
  809. + int32 aliFree = start ? bg->GetMaxPlayersPerTeam() : bg->GetFreeSlotsForTeam(ALLIANCE);
  810. + int32 hordeFree = start ? bg->GetMaxPlayersPerTeam() : bg->GetFreeSlotsForTeam(HORDE);
  811. + // Empty selection pools. They will be refilled from queued groups.
  812. + m_SelectionPools[TEAM_ALLIANCE].Init();
  813. + m_SelectionPools[TEAM_HORDE].Init();
  814. + int32 valiFree = aliFree;
  815. + int32 vhordeFree = hordeFree;
  816. + int32 diff = 0;
  817. +
  818. +
  819. + // Add teams to their own factions as far as possible.
  820. + if (start)
  821. + {
  822. + QueuedGroupMap m_PreGroupMap_a, m_PreGroupMap_h;
  823. + int32 m_SmallestOfTeams = 0;
  824. + int32 queuedAlliance = 0;
  825. + int32 queuedHorde = 0;
  826. +
  827. + for (GroupsQueueType::const_iterator itr = m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].end(); ++itr)
  828. + {
  829. + if ((*itr)->IsInvitedToBGInstanceGUID)
  830. + continue;
  831. +
  832. + bool alliance = (*itr)->CFSTeam == ALLIANCE;
  833. +
  834. + if (alliance)
  835. + {
  836. + m_PreGroupMap_a.insert(std::make_pair((*itr)->Players.size(), *itr));
  837. + queuedAlliance += (*itr)->Players.size();
  838. + }
  839. + else
  840. + {
  841. + m_PreGroupMap_h.insert(std::make_pair((*itr)->Players.size(), *itr));
  842. + queuedHorde += (*itr)->Players.size();
  843. + }
  844. + }
  845. +
  846. + m_SmallestOfTeams = std::min(std::min(aliFree, queuedAlliance), std::min(hordeFree, queuedHorde));
  847. +
  848. + valiFree -= PreAddPlayers(m_PreGroupMap_a, m_SmallestOfTeams, aliFree);
  849. + vhordeFree -= PreAddPlayers(m_PreGroupMap_h, m_SmallestOfTeams, hordeFree);
  850. + }
  851. + QueuedGroupMap m_QueuedGroupMap;
  852. +
  853. + for (GroupsQueueType::const_iterator itr = m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_CROSSFACTION].end(); ++itr)
  854. + m_QueuedGroupMap.insert(std::make_pair((*itr)->Players.size(), *itr));
  855. +
  856. + for (QueuedGroupMap::reverse_iterator itr = m_QueuedGroupMap.rbegin(); itr != m_QueuedGroupMap.rend(); ++itr)
  857. + {
  858. + GroupsQueueType allypool = m_SelectionPools[TEAM_ALLIANCE].SelectedGroups;
  859. + GroupsQueueType hordepool = m_SelectionPools[TEAM_HORDE].SelectedGroups;
  860. +
  861. + GroupQueueInfo* ginfo = itr->second;
  862. +
  863. + // If player already was invited via pre adding (add to own team first) or he was already invited to a bg, skip.
  864. + if (ginfo->IsInvitedToBGInstanceGUID ||
  865. + std::find(allypool.begin(), allypool.end(), ginfo) != allypool.end() ||
  866. + std::find(hordepool.begin(), hordepool.end(), ginfo) != hordepool.end() ||
  867. + (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= bg->GetMinPlayersPerTeam() &&
  868. + m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= bg->GetMinPlayersPerTeam()))
  869. + continue;
  870. +
  871. + diff = abs(valiFree - vhordeFree);
  872. + bool moreAli = valiFree < vhordeFree;
  873. +
  874. + if (diff > 0)
  875. + ginfo->Team = moreAli ? HORDE : ALLIANCE;
  876. +
  877. + bool alliance = ginfo->Team == ALLIANCE;
  878. +
  879. + if (m_SelectionPools[alliance ? TEAM_ALLIANCE : TEAM_HORDE].AddGroup(ginfo, alliance ? aliFree : hordeFree))
  880. + alliance ? valiFree -= ginfo->Players.size() : vhordeFree -= ginfo->Players.size();
  881. + }
  882. +
  883. + return true;
  884. + }
  885. + return false;
  886. +}
  887. +
  888. +int32 BattlegroundQueue::PreAddPlayers(QueuedGroupMap m_PreGroupMap, int32 MaxAdd, uint32 MaxInTeam)
  889. +{
  890. + int32 LeftToAdd = MaxAdd;
  891. + uint32 Added = 0;
  892. +
  893. + for (QueuedGroupMap::reverse_iterator itr = m_PreGroupMap.rbegin(); itr != m_PreGroupMap.rend(); ++itr)
  894. + {
  895. + int32 PlayerSize = itr->first;
  896. + bool alliance = itr->second->CFSTeam == ALLIANCE;
  897. +
  898. + if (PlayerSize <= LeftToAdd && m_SelectionPools[alliance ? TEAM_ALLIANCE : TEAM_HORDE].AddGroup(itr->second, MaxInTeam))
  899. + LeftToAdd -= PlayerSize, Added -= PlayerSize;
  900. + }
  901. +
  902. + return LeftToAdd;
  903. +}
  904. +
  905. +void Player::SendChatMessage(const char *format, ...)
  906. +{
  907. + if (!IsInWorld())
  908. + return;
  909. +
  910. + if (format)
  911. + {
  912. + va_list ap;
  913. + char str[2048];
  914. + va_start(ap, format);
  915. + vsnprintf(str, 2048, format, ap);
  916. + va_end(ap);
  917. +
  918. + ChatHandler(GetSession()).SendSysMessage(str);
  919. + }
  920. +}
  921. \ No newline at end of file
  922. diff --git a/src/server/game/CrossFactionBG/Cfbg.h b/src/server/game/CrossFactionBG/Cfbg.h
  923. new file mode 100644
  924. index 0000000..ffb0f81
  925. --- /dev/null
  926. +++ b/src/server/game/CrossFactionBG/Cfbg.h
  927. @@ -0,0 +1,61 @@
  928. +/*
  929. + * Copyright (C) 2008-2016 FineWoWCore <http://www.finewow.com.br/>
  930. + *
  931. + * This program is free software; you can redistribute it and/or modify it
  932. + * under the terms of the GNU General Public License as published by the
  933. + * Free Software Foundation; either version 2 of the License, or (at your
  934. + * option) any later version.
  935. + *
  936. + * This program is distributed in the hope that it will be useful, but WITHOUT
  937. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  938. + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  939. + * more details.
  940. + *
  941. + * You should have received a copy of the GNU General Public License along
  942. + * with this program. If not, see <http://www.gnu.org/licenses/>.
  943. + */
  944. +
  945. +
  946. +#ifndef _CUSTOM_H
  947. +#define _CUSTOM_H
  948. +
  949. +#define MSG_COLOR_LIGHTRED "|cffff6060"
  950. +#define MSG_COLOR_LIGHTBLUE "|cff00ccff"
  951. +#define MSG_COLOR_ANN_GREEN "|c1f40af20"
  952. +#define MSG_COLOR_RED "|cffff0000"
  953. +#define MSG_COLOR_GOLD "|cffffcc00"
  954. +#define MSG_COLOR_SUBWHITE "|cffbbbbbb"
  955. +#define MSG_COLOR_MAGENTA "|cffff00ff"
  956. +#define MSG_COLOR_YELLOW "|cffffff00"
  957. +#define MSG_COLOR_CYAN "|cff00ffff"
  958. +#define MSG_COLOR_DARKBLUE "|cff0000ff"
  959. +
  960. +#define MSG_COLOR_GREY "|cff9d9d9d"
  961. +#define MSG_COLOR_WHITE "|cffffffff"
  962. +#define MSG_COLOR_GREEN "|cff1eff00"
  963. +#define MSG_COLOR_BLUE "|cff0080ff"
  964. +#define MSG_COLOR_PURPLE "|cffb048f8"
  965. +#define MSG_COLOR_ORANGE "|cffff8000"
  966. +
  967. +#define MSG_COLOR_DRUID "|cffff7d0a"
  968. +#define MSG_COLOR_HUNTER "|cffabd473"
  969. +#define MSG_COLOR_MAGE "|cff69ccf0"
  970. +#define MSG_COLOR_PALADIN "|cfff58cba"
  971. +#define MSG_COLOR_PRIEST "|cffffffff"
  972. +#define MSG_COLOR_ROGUE "|cfffff569"
  973. +#define MSG_COLOR_SHAMAN "|cff0070de"
  974. +#define MSG_COLOR_WARLOCK "|cff9482c9"
  975. +#define MSG_COLOR_WARRIOR "|cffc79c6e"
  976. +#define MSG_COLOR_DEATH_KNIGHT "|cffc41f3b"
  977. +#define MSG_COLOR_MONK "|cff00ff96"
  978. +
  979. +#define LIMIT_UINT32 2147483647
  980. +
  981. +enum FakeMorphs
  982. +{
  983. + FAKE_F_TAUREN = 20584,
  984. + FAKE_M_TAUREN = 20585,
  985. + FAKE_M_NELF = 20318,
  986. + FAKE_F_DRAENEI = 20323,
  987. +};
  988. +#endif
  989. \ No newline at end of file
  990. diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
  991. index d0ddec7..c5f2d94 100644
  992. --- a/src/server/game/Entities/Player/Player.cpp
  993. +++ b/src/server/game/Entities/Player/Player.cpp
  994. @@ -292,6 +292,12 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi)
  995.  
  996. Player::Player(WorldSession* session): Unit(true)
  997. {
  998. + m_FakeRace = 0;
  999. + m_RealRace = 0;
  1000. + m_FakeMorph = 0;
  1001. + m_ForgetBGPlayers = false;
  1002. + m_ForgetInListPlayers = false;
  1003. +
  1004. m_speakTime = 0;
  1005. m_speakCount = 0;
  1006.  
  1007. @@ -641,6 +647,12 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo
  1008. SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, createInfo->Class);
  1009. SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, createInfo->Gender);
  1010. SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE, powertype);
  1011. +
  1012. + SetCFSRace();
  1013. + m_team = TeamForRace(getCFSRace());
  1014. + SetFakeRaceAndMorph(); // m_team must be set before this can be used.
  1015. + setFactionForRace(getCFSRace());
  1016. +
  1017. InitDisplayIds();
  1018. if (sWorld->getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_PVP || sWorld->getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_RPPVP)
  1019. {
  1020. @@ -2744,10 +2756,10 @@ void Player::GiveLevel(uint8 level)
  1021. guild->UpdateMemberData(this, GUILD_MEMBER_DATA_LEVEL, level);
  1022.  
  1023. PlayerLevelInfo info;
  1024. - sObjectMgr->GetPlayerLevelInfo(getRace(), getClass(), level, &info);
  1025. + sObjectMgr->GetPlayerLevelInfo(getCFSRace(), getClass(), level, &info);
  1026.  
  1027. PlayerClassLevelInfo classInfo;
  1028. - sObjectMgr->GetPlayerClassLevelInfo(getClass(), level, &classInfo);
  1029. + sObjectMgr->GetPlayerClassLevelInfo(getClass(), level, &classInfo);
  1030.  
  1031. // send levelup info to client
  1032. WorldPacket data(SMSG_LEVELUP_INFO, (4+4+MAX_POWERS*4+MAX_STATS*4));
  1033. @@ -2882,7 +2894,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
  1034. sObjectMgr->GetPlayerClassLevelInfo(getClass(), getLevel(), &classInfo);
  1035.  
  1036. PlayerLevelInfo info;
  1037. - sObjectMgr->GetPlayerLevelInfo(getRace(), getClass(), getLevel(), &info);
  1038. + sObjectMgr->GetPlayerLevelInfo(getCFSRace(), getClass(), getLevel(), &info);
  1039.  
  1040. SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
  1041. SetUInt32Value(PLAYER_NEXT_LEVEL_XP, sObjectMgr->GetXPForLevel(getLevel()));
  1042. @@ -4792,7 +4804,7 @@ Corpse* Player::CreateCorpse()
  1043. // prevent the existence of 2 corpses for one player
  1044. SpawnCorpseBones();
  1045.  
  1046. - uint32 _cfb1, _cfb2;
  1047. + uint32 _uf, _pb, _pb2, _cfb1, _cfb2;
  1048.  
  1049. Corpse* corpse = new Corpse((m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH) ? CORPSE_RESURRECTABLE_PVP : CORPSE_RESURRECTABLE_PVE);
  1050. SetPvPDeath(false);
  1051. @@ -4804,6 +4816,9 @@ Corpse* Player::CreateCorpse()
  1052. }
  1053.  
  1054. _corpseLocation.WorldRelocate(*this);
  1055. +
  1056. + _uf = getCFSRace();
  1057. + uint8 race = (uint8) (_uf);
  1058.  
  1059. uint8 skin = GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID);
  1060. uint8 face = GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID);
  1061. @@ -4811,6 +4826,10 @@ Corpse* Player::CreateCorpse()
  1062. uint8 haircolor = GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_COLOR_ID);
  1063. uint8 facialhair = GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE);
  1064.  
  1065. + _uf = getCFSRace();
  1066. + _pb = GetUInt32Value(PLAYER_BYTES);
  1067. + _pb2 = GetUInt32Value(PLAYER_BYTES_2);
  1068. +
  1069. _cfb1 = ((0x00) | (getRace() << 8) | (GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER) << 16) | (skin << 24));
  1070. _cfb2 = ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24));
  1071.  
  1072. @@ -6502,10 +6521,10 @@ uint32 Player::TeamForRace(uint8 race)
  1073.  
  1074. void Player::setFactionForRace(uint8 race)
  1075. {
  1076. - m_team = TeamForRace(race);
  1077. + SetBGTeam(TeamForRace(race));
  1078.  
  1079. ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race);
  1080. - setFaction(rEntry ? rEntry->FactionID : 0);
  1081. + setFaction(rEntry ? rEntry->FactionID : getFaction());
  1082. }
  1083.  
  1084. ReputationRank Player::GetReputationRank(uint32 faction) const
  1085. @@ -6607,6 +6626,27 @@ void Player::RewardReputation(Unit* victim, float rate)
  1086. if (!Rep)
  1087. return;
  1088.  
  1089. + uint32 repfaction1 = Rep->RepFaction1;
  1090. + uint32 repfaction2 = Rep->RepFaction2;
  1091. +
  1092. + if (!IsPlayingNative())
  1093. + {
  1094. + if (GetCFSTeam() == ALLIANCE)
  1095. + {
  1096. + if (repfaction1 == 729)
  1097. + repfaction1 = 730;
  1098. + if (repfaction2 == 729)
  1099. + repfaction2 = 730;
  1100. + }
  1101. + else
  1102. + {
  1103. + if (repfaction1 == 730)
  1104. + repfaction1 = 729;
  1105. + if (repfaction2 == 730)
  1106. + repfaction2 = 729;
  1107. + }
  1108. + }
  1109. +
  1110. uint32 ChampioningFaction = 0;
  1111.  
  1112. if (GetChampioningFaction())
  1113. @@ -6621,9 +6661,9 @@ void Player::RewardReputation(Unit* victim, float rate)
  1114.  
  1115. uint32 team = GetTeam();
  1116.  
  1117. - if (Rep->RepFaction1 && (!Rep->TeamDependent || team == ALLIANCE))
  1118. + if (repfaction1 && (!Rep->TeamDependent || team == ALLIANCE))
  1119. {
  1120. - int32 donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->getLevel(), Rep->RepValue1, ChampioningFaction ? ChampioningFaction : Rep->RepFaction1);
  1121. + int32 donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->getLevel(), Rep->RepValue1, ChampioningFaction ? ChampioningFaction : repfaction1);
  1122. donerep1 = int32(donerep1 * rate);
  1123.  
  1124. FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->RepFaction1);
  1125. @@ -6632,12 +6672,12 @@ void Player::RewardReputation(Unit* victim, float rate)
  1126. GetReputationMgr().ModifyReputation(factionEntry1, donerep1);
  1127. }
  1128.  
  1129. - if (Rep->RepFaction2 && (!Rep->TeamDependent || team == HORDE))
  1130. + if (repfaction2 && (!Rep->TeamDependent || team == HORDE))
  1131. {
  1132. - int32 donerep2 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->getLevel(), Rep->RepValue2, ChampioningFaction ? ChampioningFaction : Rep->RepFaction2);
  1133. + int32 donerep2 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->getLevel(), Rep->RepValue2, ChampioningFaction ? ChampioningFaction : repfaction2);
  1134. donerep2 = int32(donerep2 * rate);
  1135.  
  1136. - FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->RepFaction2);
  1137. + FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : repfaction2);
  1138. uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2);
  1139. if (factionEntry2 && current_reputation_rank2 <= Rep->ReputationMaxCap2)
  1140. GetReputationMgr().ModifyReputation(factionEntry2, donerep2);
  1141. @@ -6732,7 +6772,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto
  1142. if (!victim || victim == this || victim->GetTypeId() != TYPEID_PLAYER)
  1143. return false;
  1144.  
  1145. - if (GetBGTeam() == victim->ToPlayer()->GetBGTeam())
  1146. + if (GetTeam() == victim->ToPlayer()->GetTeam())
  1147. return false;
  1148.  
  1149. return true;
  1150. @@ -11577,13 +11617,13 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
  1151. if (!proto)
  1152. return EQUIP_ERR_ITEM_NOT_FOUND;
  1153.  
  1154. - if ((proto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && GetTeam() != HORDE)
  1155. + if ((proto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && GetCFSTeam() != HORDE)
  1156. return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
  1157.  
  1158. - if ((proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && GetTeam() != ALLIANCE)
  1159. + if ((proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && GetCFSTeam() != ALLIANCE)
  1160. return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
  1161.  
  1162. - if ((proto->AllowableClass & getClassMask()) == 0 || (proto->AllowableRace & getRaceMask()) == 0)
  1163. + if ((proto->AllowableClass & getClassMask()) == 0 || (proto->AllowableRace & getCFSRaceMask()) == 0)
  1164. return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
  1165.  
  1166. if (proto->RequiredSkill != 0)
  1167. @@ -16927,6 +16967,11 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
  1168. SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, fields[4].GetUInt8());
  1169. SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, gender);
  1170.  
  1171. + SetCFSRace(); //**** umisteni ****
  1172. + m_team = TeamForRace(getCFSRace());
  1173. + SetFakeRaceAndMorph(); // m_team must be set before this can be used.
  1174. + setFactionForRace(getCFSRace());//Need to call it to initialize m_team (m_team can be calculated from race)
  1175. +
  1176. // check if race/class combination is valid
  1177. PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass());
  1178. if (!info)
  1179. @@ -17001,9 +17046,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
  1180. TC_LOG_DEBUG("entities.player.loading", "Player::LoadFromDB: Load Basic value of player '%s' is: ", m_name.c_str());
  1181. outDebugValues();
  1182.  
  1183. - //Need to call it to initialize m_team (m_team can be calculated from race)
  1184. - //Other way is to saves m_team into characters table.
  1185. - setFactionForRace(getRace());
  1186. +
  1187.  
  1188. // load home bind and check in same time class/race pair, it used later for restore broken positions
  1189. if (!_LoadHomeBind(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_HOME_BIND)))
  1190. @@ -18915,7 +18958,7 @@ void Player::AddInstanceEnterTime(uint32 instanceId, time_t enterTime)
  1191.  
  1192. bool Player::_LoadHomeBind(PreparedQueryResult result)
  1193. {
  1194. - PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass());
  1195. + PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getCFSRace(), getClass());
  1196. if (!info)
  1197. {
  1198. TC_LOG_ERROR("entities.player", "Player::_LoadHomeBind: Player '%s' (%s) has incorrect race/class (%u/%u) pair. Can't load.",
  1199. @@ -19009,7 +19052,7 @@ void Player::SaveToDB(bool create /*=false*/)
  1200. stmt->setUInt32(index++, GetGUID().GetCounter());
  1201. stmt->setUInt32(index++, GetSession()->GetAccountId());
  1202. stmt->setString(index++, GetName());
  1203. - stmt->setUInt8(index++, getRace());
  1204. + stmt->setUInt8(index++, getCFSRace());
  1205. stmt->setUInt8(index++, getClass());
  1206. 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
  1207. stmt->setUInt8(index++, getLevel());
  1208. @@ -19119,7 +19162,7 @@ void Player::SaveToDB(bool create /*=false*/)
  1209. // Update query
  1210. stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER);
  1211. stmt->setString(index++, GetName());
  1212. - stmt->setUInt8(index++, getRace());
  1213. + stmt->setUInt8(index++, getCFSRace());
  1214. stmt->setUInt8(index++, getClass());
  1215. 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
  1216. stmt->setUInt8(index++, getLevel());
  1217. @@ -20365,6 +20408,18 @@ void Player::StopCastingCharm()
  1218. }
  1219. }
  1220.  
  1221. +void Player::BuildPlayerChat(WorldPacket* data, uint8 msgtype, const std::string& text, uint32 language) const
  1222. +{
  1223. + *data << uint8(msgtype);
  1224. + *data << uint32(language);
  1225. + *data << uint64(GetGUID());
  1226. + *data << uint32(0); // constant unknown time
  1227. + *data << uint64(GetGUID());
  1228. + *data << uint32(text.length() + 1);
  1229. + *data << text;
  1230. + *data << uint8(GetChatTag());
  1231. +}
  1232. +
  1233. void Player::Say(std::string const& text, Language language, WorldObject const* /*= nullptr*/)
  1234. {
  1235. std::string _text(text);
  1236. @@ -21322,7 +21377,7 @@ void Player::InitDataForForm(bool reapplyMods)
  1237.  
  1238. void Player::InitDisplayIds()
  1239. {
  1240. - PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass());
  1241. + PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getCFSRace(), getClass());
  1242. if (!info)
  1243. {
  1244. 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());
  1245. @@ -21330,14 +21385,18 @@ void Player::InitDisplayIds()
  1246. }
  1247.  
  1248. uint8 gender = GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER);
  1249. + bool isMorphed = GetNativeDisplayId() != GetDisplayId();
  1250. +
  1251. switch (gender)
  1252. {
  1253. case GENDER_FEMALE:
  1254. - SetDisplayId(info->displayId_f);
  1255. + if (!isMorphed)
  1256. + SetDisplayId(info->displayId_f);
  1257. SetNativeDisplayId(info->displayId_f);
  1258. break;
  1259. case GENDER_MALE:
  1260. - SetDisplayId(info->displayId_m);
  1261. + if (!isMorphed)
  1262. + SetDisplayId(info->displayId_m);
  1263. SetNativeDisplayId(info->displayId_m);
  1264. break;
  1265. default:
  1266. @@ -21940,11 +21999,6 @@ void Player::SetBGTeam(uint32 team)
  1267. SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_ARENA_FACTION, uint8(team == ALLIANCE ? 1 : 0));
  1268. }
  1269.  
  1270. -uint32 Player::GetBGTeam() const
  1271. -{
  1272. - return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam();
  1273. -}
  1274. -
  1275. void Player::LeaveBattleground(bool teleportToEntryPoint)
  1276. {
  1277. if (Battleground* bg = GetBattleground())
  1278. @@ -22030,7 +22084,7 @@ void Player::ReportedAfkBy(Player* reporter)
  1279.  
  1280. WorldLocation Player::GetStartPosition() const
  1281. {
  1282. - PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass());
  1283. + PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getCFSRace(), getClass());
  1284. uint32 mapId = info->mapId;
  1285. if (getClass() == CLASS_DEATH_KNIGHT && HasSpell(50977))
  1286. mapId = 0;
  1287. @@ -22717,7 +22771,7 @@ void Player::LearnCustomSpells()
  1288. {
  1289. uint32 tspell = *itr;
  1290. TC_LOG_DEBUG("entities.player.loading", "Player::LearnCustomSpells: Player '%s' (%s, Class: %u Race: %u): Adding initial spell (SpellID: %u)",
  1291. - GetName().c_str(), GetGUID().ToString().c_str(), uint32(getClass()), uint32(getRace()), tspell);
  1292. + GetName().c_str(), GetGUID().ToString().c_str(), uint32(getClass()), uint32(getCFSRace()), tspell);
  1293. if (!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add
  1294. AddSpell(tspell, true, true, true, false);
  1295. else // but send in normal spell in game learn case
  1296. @@ -26578,4 +26632,4 @@ uint32 Player::DoRandomRoll(uint32 minimum, uint32 maximum)
  1297. SendDirectMessage(&data);
  1298.  
  1299. return roll;
  1300. -}
  1301. +}
  1302. \ No newline at end of file
  1303. diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
  1304. index 2b7780a..828e9db 100644
  1305. --- a/src/server/game/Entities/Player/Player.h
  1306. +++ b/src/server/game/Entities/Player/Player.h
  1307. @@ -1038,6 +1038,36 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
  1308.  
  1309. PlayerAI* AI() const { return reinterpret_cast<PlayerAI*>(i_AI); }
  1310.  
  1311. + private:
  1312. + bool m_ForgetBGPlayers;
  1313. + bool m_ForgetInListPlayers;
  1314. + uint8 m_FakeRace;
  1315. + uint8 m_RealRace;
  1316. + uint32 m_FakeMorph;
  1317. + public:
  1318. + typedef std::vector<uint64> FakePlayers;
  1319. + void SendChatMessage(const char *format, ...);
  1320. + void FitPlayerInTeam(bool action, Battleground* pBattleGround = NULL); // void FitPlayerInTeam(bool action, Battleground* bg = NULL);
  1321. + void DoForgetPlayersInList();
  1322. + void DoForgetPlayersInBG(Battleground* pBattleGround); // void DoForgetPlayersInBG(Battleground* bg);
  1323. + uint8 getCFSRace() const { return m_RealRace; }
  1324. + void SetCFSRace() { m_RealRace = GetByteValue(UNIT_FIELD_BYTES_0, 0); }; // SHOULD ONLY BE CALLED ON LOGIN
  1325. + void SetFakeRace(); // SHOULD ONLY BE CALLED ON LOGIN
  1326. + void SetFakeRaceAndMorph(); // SHOULD ONLY BE CALLED ON LOGIN
  1327. + uint32 GetFakeMorph() { return m_FakeMorph; };
  1328. + uint8 getFRace() const { return m_FakeRace; }
  1329. + void SetForgetBGPlayers(bool value) { m_ForgetBGPlayers = value; }
  1330. + bool ShouldForgetBGPlayers() { return m_ForgetBGPlayers; }
  1331. + void SetForgetInListPlayers(bool value) { m_ForgetInListPlayers = value; }
  1332. + bool ShouldForgetInListPlayers() { return m_ForgetInListPlayers; }
  1333. + bool SendBattleGroundChat(uint32 msgtype, std::string message);
  1334. + void MorphFit(bool value);
  1335. + bool IsPlayingNative() const { return GetTeam() == m_team; }
  1336. + uint32 GetCFSTeam() const { return m_team; }
  1337. + uint32 GetTeam() const { return m_bgData.bgTeam && GetBattleground() ? m_bgData.bgTeam : m_team; }
  1338. + bool SendRealNameQuery();
  1339. + FakePlayers m_FakePlayers;
  1340. +
  1341. void CleanupsBeforeDelete(bool finalCleanup = true) override;
  1342.  
  1343. void AddToWorld() override;
  1344. @@ -1096,7 +1126,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
  1345. PlayerSocial *GetSocial() const { return m_social; }
  1346.  
  1347. PlayerTaxi m_taxi;
  1348. - void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
  1349. + void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getCFSRace(), getClass(), getLevel()); }
  1350. bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc = nullptr, uint32 spellid = 0);
  1351. bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0);
  1352. void CleanupAfterTaxiFlight();
  1353. @@ -1151,6 +1181,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
  1354. void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
  1355. uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
  1356.  
  1357. + /// Constructs the player Chat data for the specific functions to use
  1358. + void BuildPlayerChat(WorldPacket* data, uint8 msgtype, std::string const& text, uint32 language) const;
  1359. /// Handles said message in regular chat based on declared language and in config pre-defined Range.
  1360. void Say(std::string const& text, Language language, WorldObject const* = nullptr) override;
  1361. void Say(uint32 textId, WorldObject const* target = nullptr) override;
  1362. @@ -1874,8 +1906,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
  1363. void CheckAreaExploreAndOutdoor(void);
  1364.  
  1365. static uint32 TeamForRace(uint8 race);
  1366. - uint32 GetTeam() const { return m_team; }
  1367. - TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }
  1368. + TeamId GetTeamId() const { return GetTeam() == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }
  1369. void setFactionForRace(uint8 race);
  1370.  
  1371. void InitDisplayIds();
  1372. @@ -2024,7 +2055,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
  1373. void SetBattlegroundEntryPoint();
  1374.  
  1375. void SetBGTeam(uint32 team);
  1376. - uint32 GetBGTeam() const;
  1377.  
  1378. void LeaveBattleground(bool teleportToEntryPoint = true);
  1379. bool CanJoinToBattleground(Battleground const* bg) const;
  1380. @@ -2656,4 +2686,4 @@ void Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* s
  1381. basevalue = T(float(basevalue + totalflat) * totalmul);
  1382. }
  1383.  
  1384. -#endif
  1385. +#endif
  1386. \ No newline at end of file
  1387. diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
  1388. index d324eb3..c864ae1 100644
  1389. --- a/src/server/game/Entities/Unit/Unit.cpp
  1390. +++ b/src/server/game/Entities/Unit/Unit.cpp
  1391. @@ -16540,6 +16540,21 @@ uint32 Unit::GetModelForTotem(PlayerTotemType totemType)
  1392. }
  1393. break;
  1394. }
  1395. + default: // One standard for other races.
  1396. + {
  1397. + switch (totemType)
  1398. + {
  1399. + case SUMMON_TYPE_TOTEM_FIRE: // fire
  1400. + return 4589;
  1401. + case SUMMON_TYPE_TOTEM_EARTH: // earth
  1402. + return 4588;
  1403. + case SUMMON_TYPE_TOTEM_WATER: // water
  1404. + return 4587;
  1405. + case SUMMON_TYPE_TOTEM_AIR: // air
  1406. + return 4590;
  1407. + }
  1408. + break;
  1409. + }
  1410. }
  1411. return 0;
  1412. }
  1413. @@ -17667,4 +17682,4 @@ void Unit::Whisper(uint32 textId, Player* target, bool isBossWhisper /*= false*/
  1414. WorldPacket data;
  1415. ChatHandler::BuildChatPacket(data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, bct->GetText(locale, getGender()), 0, "", locale);
  1416. target->SendDirectMessage(&data);
  1417. -}
  1418. +}
  1419. \ No newline at end of file
  1420. diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
  1421. index d4ff575..b9f16c3 100644
  1422. --- a/src/server/game/Entities/Unit/Unit.h
  1423. +++ b/src/server/game/Entities/Unit/Unit.h
  1424. @@ -1337,9 +1337,15 @@ class TC_GAME_API Unit : public WorldObject
  1425. uint8 getLevel() const { return uint8(GetUInt32Value(UNIT_FIELD_LEVEL)); }
  1426. uint8 getLevelForTarget(WorldObject const* /*target*/) const override { return getLevel(); }
  1427. void SetLevel(uint8 lvl);
  1428. - uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE); }
  1429. - uint32 getRaceMask() const { return 1 << (getRace()-1); }
  1430. +
  1431. + uint8 getRace(bool forceoriginal = false) const;
  1432. + uint8 getCFSRace() { return getRace(true); }
  1433. +
  1434. + uint32 getRaceMask() const { return 1 << (getRace() - 1); }
  1435. +
  1436. + uint32 getCFSRaceMask() const { return 1 << (getRace(true) - 1); }
  1437. uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS); }
  1438. +
  1439. uint32 getClassMask() const { return 1 << (getClass()-1); }
  1440. uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER); }
  1441.  
  1442. @@ -2358,4 +2364,4 @@ namespace Trinity
  1443. bool const _ascending;
  1444. };
  1445. }
  1446. -#endif
  1447. +#endif
  1448. \ No newline at end of file
  1449. diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp
  1450. index 8723fff..b87b9fc 100644
  1451. --- a/src/server/game/Handlers/BattleGroundHandler.cpp
  1452. +++ b/src/server/game/Handlers/BattleGroundHandler.cpp
  1453. @@ -561,7 +561,7 @@ void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket & /*recvData*/)
  1454. {
  1455. // this line is checked, i only don't know if GetStartTime is changing itself after bg end!
  1456. // send status in Battleground
  1457. - sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, i, STATUS_IN_PROGRESS, bg->GetEndTime(), bg->GetStartTime(), arenaType, _player->GetBGTeam());
  1458. + sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, i, STATUS_IN_PROGRESS, bg->GetEndTime(), bg->GetStartTime(), arenaType, _player->GetTeam());
  1459. SendPacket(&data);
  1460. continue;
  1461. }
  1462. @@ -784,4 +784,4 @@ void WorldSession::HandleReportPvPAFK(WorldPacket& recvData)
  1463. TC_LOG_DEBUG("bg.battleground", "WorldSession::HandleReportPvPAFK: %s reported %s", _player->GetName().c_str(), reportedPlayer->GetName().c_str());
  1464.  
  1465. reportedPlayer->ReportedAfkBy(_player);
  1466. -}
  1467. +}
  1468. \ No newline at end of file
  1469. diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
  1470. index b5adceb..b08bcef 100644
  1471. --- a/src/server/game/Handlers/CharacterHandler.cpp
  1472. +++ b/src/server/game/Handlers/CharacterHandler.cpp
  1473. @@ -1005,6 +1005,9 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
  1474. TC_METRIC_EVENT("player_events", "Login", pCurrChar->GetName());
  1475.  
  1476. delete holder;
  1477. +
  1478. + if (pCurrChar->GetTeam() != pCurrChar->GetCFSTeam())
  1479. + pCurrChar->FitPlayerInTeam(pCurrChar->GetBattleground() && !pCurrChar->GetBattleground()->isArena() ? true : false, pCurrChar->GetBattleground());
  1480. }
  1481.  
  1482. void WorldSession::HandleSetFactionAtWar(WorldPacket& recvData)
  1483. @@ -2190,4 +2193,4 @@ void WorldSession::SendBarberShopResult(BarberShopResult result)
  1484. WorldPacket data(SMSG_BARBER_SHOP_RESULT, 4);
  1485. data << uint32(result);
  1486. SendPacket(&data);
  1487. -}
  1488. +}
  1489. \ No newline at end of file
  1490. diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp
  1491. index 0328a54..0c491f3 100644
  1492. --- a/src/server/game/Handlers/ChatHandler.cpp
  1493. +++ b/src/server/game/Handlers/ChatHandler.cpp
  1494. @@ -62,6 +62,18 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
  1495. return;
  1496. }
  1497.  
  1498. + if (sWorld->getBoolConfig(CROSSFACTION_SYSTEM_BATTLEGROUNDS) && lang != LANG_ADDON)
  1499. + {
  1500. + switch (type)
  1501. + {
  1502. + case CHAT_MSG_BATTLEGROUND:
  1503. + case CHAT_MSG_BATTLEGROUND_LEADER:
  1504. + lang = LANG_UNIVERSAL;
  1505. + default:
  1506. + break;
  1507. + }
  1508. + }
  1509. +
  1510. Player* sender = GetPlayer();
  1511.  
  1512. //TC_LOG_DEBUG("CHAT: packet received. type %u, lang %u", type, lang);
  1513. @@ -251,6 +263,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
  1514. SendNotification(GetTrinityString(LANG_SAY_REQ), sWorld->getIntConfig(CONFIG_CHAT_SAY_LEVEL_REQ));
  1515. return;
  1516. }
  1517. +
  1518. + if (!GetPlayer()->IsGameMaster())
  1519. + if (GetPlayer()->SendBattleGroundChat(type, msg))
  1520. + return;
  1521.  
  1522. if (type == CHAT_MSG_SAY)
  1523. sender->Say(msg, Language(lang));
  1524. @@ -643,4 +659,4 @@ void WorldSession::SendChatRestrictedNotice(ChatRestrictionType restriction)
  1525. WorldPacket data(SMSG_CHAT_RESTRICTED, 1);
  1526. data << uint8(restriction);
  1527. SendPacket(&data);
  1528. -}
  1529. +}
  1530. \ No newline at end of file
  1531. diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
  1532. index d89b717..771789d 100644
  1533. --- a/src/server/game/Handlers/MiscHandler.cpp
  1534. +++ b/src/server/game/Handlers/MiscHandler.cpp
  1535. @@ -1442,6 +1442,21 @@ void WorldSession::HandleSetTitleOpcode(WorldPacket& recvData)
  1536.  
  1537. void WorldSession::HandleTimeSyncResp(WorldPacket& recvData)
  1538. {
  1539. + Battleground* bg = _player->GetBattleground();
  1540. + if (bg)
  1541. + {
  1542. + if (_player->ShouldForgetBGPlayers() && bg)
  1543. + {
  1544. + _player->DoForgetPlayersInBG(bg);
  1545. + _player->SetForgetBGPlayers(false);
  1546. + }
  1547. + }
  1548. + else if (_player->ShouldForgetInListPlayers())
  1549. + {
  1550. + _player->DoForgetPlayersInList();
  1551. + _player->SetForgetInListPlayers(false);
  1552. + }
  1553. +
  1554. TC_LOG_DEBUG("network", "CMSG_TIME_SYNC_RESP");
  1555.  
  1556. uint32 counter, clientTicks;
  1557. @@ -1820,4 +1835,4 @@ void WorldSession::HandleUpdateMissileTrajectory(WorldPacket& recvPacket)
  1558. recvPacket.SetOpcode(opcode);
  1559. HandleMovementOpcodes(recvPacket);
  1560. }
  1561. -}
  1562. +}
  1563. \ No newline at end of file
  1564. diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp
  1565. index 43e01d1..8bb3ffb 100644
  1566. --- a/src/server/game/Handlers/QueryHandler.cpp
  1567. +++ b/src/server/game/Handlers/QueryHandler.cpp
  1568. @@ -45,7 +45,7 @@ void WorldSession::SendNameQueryOpcode(ObjectGuid guid)
  1569. data << uint8(0); // name known
  1570. data << nameData->Name; // played name
  1571. data << uint8(0); // realm name - only set for cross realm interaction (such as Battlegrounds)
  1572. - data << uint8(nameData->Race);
  1573. + data << uint8(player ? player->getRace() : nameData->Race);
  1574. data << uint8(nameData->Sex);
  1575. data << uint8(nameData->Class);
  1576.  
  1577. @@ -477,4 +477,4 @@ void WorldSession::HandleQuestPOIQuery(WorldPacket& recvData)
  1578. }
  1579.  
  1580. SendPacket(&data);
  1581. -}
  1582. +}
  1583. \ No newline at end of file
  1584. diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
  1585. index 78359fc..5a473dd 100644
  1586. --- a/src/server/game/World/World.cpp
  1587. +++ b/src/server/game/World/World.cpp
  1588. @@ -1083,6 +1083,8 @@ void World::LoadConfigSettings(bool reload)
  1589.  
  1590. m_bool_configs[CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN] = sConfigMgr->GetBoolDefault("OffhandCheckAtSpellUnlearn", true);
  1591.  
  1592. + m_bool_configs[CROSSFACTION_SYSTEM_BATTLEGROUNDS] = sConfigMgr->GetBoolDefault("CrossfactionBG.enable", true);
  1593. +
  1594. m_int_configs[CONFIG_CREATURE_PICKPOCKET_REFILL] = sConfigMgr->GetIntDefault("Creature.PickPocketRefillDelay", 10 * MINUTE);
  1595. m_int_configs[CONFIG_CREATURE_STOP_FOR_PLAYER] = sConfigMgr->GetIntDefault("Creature.MovingStopTimeForPlayer", 3 * MINUTE * IN_MILLISECONDS);
  1596.  
  1597. @@ -3357,4 +3359,4 @@ void World::RemoveOldCorpses()
  1598. m_timers[WUPDATE_CORPSES].SetCurrent(m_timers[WUPDATE_CORPSES].GetInterval());
  1599. }
  1600.  
  1601. -Realm realm;
  1602. +Realm realm;
  1603. \ No newline at end of file
  1604. diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
  1605. index fcbbca1..d89edec 100644
  1606. --- a/src/server/game/World/World.h
  1607. +++ b/src/server/game/World/World.h
  1608. @@ -90,6 +90,7 @@ enum WorldTimers
  1609. enum WorldBoolConfigs
  1610. {
  1611. CONFIG_DURABILITY_LOSS_IN_PVP = 0,
  1612. + CROSSFACTION_SYSTEM_BATTLEGROUNDS,
  1613. CONFIG_ADDON_CHANNEL,
  1614. CONFIG_ALLOW_PLAYER_COMMANDS,
  1615. CONFIG_CLEAN_CHARACTER_DB,
  1616. @@ -883,4 +884,4 @@ TC_GAME_API extern Realm realm;
  1617. #define sWorld World::instance()
  1618.  
  1619. #endif
  1620. -/// @}
  1621. +/// @}
  1622. \ No newline at end of file
  1623. diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
  1624. index 8d5f018..781ec30 100644
  1625. --- a/src/server/worldserver/worldserver.conf.dist
  1626. +++ b/src/server/worldserver/worldserver.conf.dist
  1627. @@ -35,6 +35,7 @@
  1628. # LOGGING SYSTEM SETTINGS
  1629. # PACKET SPOOF PROTECTION SETTINGS
  1630. # METRIC SETTINGS
  1631. +# CROSSFACTION BG CONFIG
  1632. #
  1633. ###################################################################################################
  1634.  
  1635. @@ -3756,3 +3757,15 @@ Metric.OverallStatusInterval = 1
  1636.  
  1637. #
  1638. ###################################################################################################
  1639. +
  1640. +###################################################################################################
  1641. +# CROSSFACTION BG CONFIG
  1642. +#
  1643. +#
  1644. +# CrossfactionBG.enable = 1 - Mixed battleground enabled.
  1645. +# CrossfactionBG.enable = 0 - Mixed battleground disabled.
  1646. +
  1647. +CrossfactionBG.enable = 1
  1648. +
  1649. +#
  1650. +###################################################################################################
  1651. \ No newline at end of file
  1652. --
  1653. 1.9.5.msysgit.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement