From 191d465eee626365ad37192c848333c3e7709d3c Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 9 Jan 2020 11:30:07 -0500 Subject: [PATCH] Core/Battleground: Check battlegrounds disabled in db2 files Port From (https://github.com/TrinityCore/TrinityCore/commit/5d57415951c4b6f7b86c97922c94b571a178f35a) --- Source/Framework/Constants/CliDBConst.cs | 11 +++++++++++ Source/Game/DataStorage/Structs/B_Records.cs | 3 ++- Source/Game/Handlers/BattleGroundHandler.cs | 10 +++++----- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Source/Framework/Constants/CliDBConst.cs b/Source/Framework/Constants/CliDBConst.cs index beac51afd..e4d804ab0 100644 --- a/Source/Framework/Constants/CliDBConst.cs +++ b/Source/Framework/Constants/CliDBConst.cs @@ -986,6 +986,17 @@ namespace Framework.Constants Max } + public enum BattlemasterListFlags : sbyte + { + Disabled = 0x01, + SkipRoleCheck = 0x02, + Unk4 = 0x04, + CanInitWarGame = 0x08, + CanSpecificQueue = 0x10, + Brawl = 0x20, + Factional = 0x40 + } + public enum ChrSpecializationFlag { Caster = 0x01, diff --git a/Source/Game/DataStorage/Structs/B_Records.cs b/Source/Game/DataStorage/Structs/B_Records.cs index 7e5095299..7ae58a67f 100644 --- a/Source/Game/DataStorage/Structs/B_Records.cs +++ b/Source/Game/DataStorage/Structs/B_Records.cs @@ -14,6 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +using Framework.Constants; namespace Game.DataStorage { @@ -97,7 +98,7 @@ namespace Game.DataStorage public sbyte GroupsAllowed; public sbyte MaxGroupSize; public ushort HolidayWorldState; - public sbyte Flags; + public BattlemasterListFlags Flags; public int IconFileDataID; public short RequiredPlayerConditionID; public short[] MapId = new short[16]; diff --git a/Source/Game/Handlers/BattleGroundHandler.cs b/Source/Game/Handlers/BattleGroundHandler.cs index e5f0b3cb3..d03059de1 100644 --- a/Source/Game/Handlers/BattleGroundHandler.cs +++ b/Source/Game/Handlers/BattleGroundHandler.cs @@ -64,19 +64,19 @@ namespace Game return; } - uint bgTypeId_ = (uint)(battlemasterJoin.QueueIDs[0] & 0xFFFF); - if (!CliDB.BattlemasterListStorage.ContainsKey(bgTypeId_)) + BattlegroundTypeId bgTypeId = (BattlegroundTypeId)(battlemasterJoin.QueueIDs[0] & 0xFFFF); + BattlemasterListRecord battlemasterListEntry = CliDB.BattlemasterListStorage.LookupByKey(bgTypeId); + if (battlemasterListEntry == null) { - Log.outError(LogFilter.Network, "Battleground: invalid bgtype ({0}) received. possible cheater? player guid {1}", bgTypeId_, GetPlayer().GetGUID().ToString()); + Log.outError(LogFilter.Network, "Battleground: invalid bgtype ({0}) received. possible cheater? player guid {1}", bgTypeId, GetPlayer().GetGUID().ToString()); return; } - if (Global.DisableMgr.IsDisabledFor(DisableType.Battleground, bgTypeId_, null)) + if (Global.DisableMgr.IsDisabledFor(DisableType.Battleground, (uint)bgTypeId, null) || battlemasterListEntry.Flags.HasAnyFlag(BattlemasterListFlags.Disabled)) { GetPlayer().SendSysMessage(CypherStrings.BgDisabled); return; } - BattlegroundTypeId bgTypeId = (BattlegroundTypeId)bgTypeId_; // can do this, since it's Battleground, not arena BattlegroundQueueTypeId bgQueueTypeId = Global.BattlegroundMgr.BGQueueTypeId(bgTypeId, 0);