From ef250e0400f6ae6470326cbde08730875374106e Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 23 May 2023 08:07:33 -0400 Subject: [PATCH] Core/Areas: Update AreaFlags Port From (https://github.com/TrinityCore/TrinityCore/commit/f8f1c3b4f0ca631e76101f8492b9688c6d2dca01) --- Source/Framework/Constants/CliDBConst.cs | 98 ++++++++++++-------- Source/Game/Achievements/CriteriaHandler.cs | 10 +- Source/Game/DataStorage/Structs/A_Records.cs | 21 +---- Source/Game/Entities/Player/Player.Map.cs | 16 ++-- Source/Game/Entities/Player/Player.PvP.cs | 2 +- Source/Game/Entities/Player/Player.cs | 8 +- Source/Game/Entities/Unit/Unit.Movement.cs | 8 +- Source/Game/Handlers/BattleGroundHandler.cs | 2 +- Source/Game/Maps/TerrainManager.cs | 2 +- Source/Game/Spells/Spell.cs | 8 +- Source/Game/Spells/SpellEffects.cs | 4 +- Source/Game/Spells/SpellInfo.cs | 8 +- Source/Scripts/Spells/Items.cs | 3 +- 13 files changed, 95 insertions(+), 95 deletions(-) diff --git a/Source/Framework/Constants/CliDBConst.cs b/Source/Framework/Constants/CliDBConst.cs index 0437bba44..b15192f41 100644 --- a/Source/Framework/Constants/CliDBConst.cs +++ b/Source/Framework/Constants/CliDBConst.cs @@ -887,45 +887,69 @@ namespace Framework.Constants } [Flags] - public enum AreaFlags + public enum AreaFlags : uint { - Snow = 0x01, // Snow (Only Dun Morogh, Naxxramas, Razorfen Downs And Winterspring) - Unk1 = 0x02, // Razorfen Downs, Naxxramas And Acherus: The Ebon Hold (3.3.5a) - Unk2 = 0x04, // Only Used For Areas On Map 571 (Development Before) - SlaveCapital = 0x08, // City And City Subzones - Unk3 = 0x10, // Can'T Find Common Meaning - SlaveCapital2 = 0x20, // Slave Capital City Flag? - AllowDuels = 0x40, // Allow To Duel Here - Arena = 0x80, // Arena, Both Instanced And World Arenas - Capital = 0x100, // Main Capital City Flag - City = 0x200, // Only For One Zone Named "City" (Where It Located?) - Outland = 0x400, // Expansion Zones? (Only Eye Of The Storm Not Have This Flag, But Have 0x4000 Flag) - Sanctuary = 0x800, // Sanctuary Area (Pvp Disabled) - NeedFly = 0x1000, // Unknown - Unused1 = 0x2000, // Unused In 3.3.5a - Outland2 = 0x4000, // Expansion Zones? (Only Circle Of Blood Arena Not Have This Flag, But Have 0x400 Flag) - OutdoorPvp = 0x8000, // Pvp Objective Area? (Death'S Door Also Has This Flag Although It'S No Pvp Object Area) - ArenaInstance = 0x10000, // Used By Instanced Arenas Only - Unused2 = 0x20000, // Unused In 3.3.5a - ContestedArea = 0x40000, // On Pvp Servers These Areas Are Considered Contested, Even Though The Zone It Is Contained In Is A Horde/Alliance Territory. - Unk6 = 0x80000, // Valgarde And Acherus: The Ebon Hold - Lowlevel = 0x100000, // Used For Some Starting Areas With AreaLevel <= 15 - Town = 0x200000, // Small Towns With Inn - RestZoneHorde = 0x400000, // Warsong Hold, Acherus: The Ebon Hold, New Agamand Inn, Vengeance Landing Inn, Sunreaver Pavilion (Something To Do With Team?) - RestZoneAlliance = 0x800000, // Valgarde, Acherus: The Ebon Hold, Westguard Inn, Silver Covenant Pavilion (Something To Do With Team?) - Combat = 0x1000000, // "combat" area (Script_GetZonePVPInfo), used - Inside = 0x2000000, // Used For Determinating Spell Related Inside/Outside Questions In Map.Isoutdoors - Outside = 0x4000000, // Used For Determinating Spell Related Inside/Outside Questions In Map.Isoutdoors - CanHearthAndResurrect = 0x8000000, // Can Hearth And Resurrect From Area - NoFlyZone = 0x20000000, // Marks Zones Where You Cannot Fly - Unk9 = 0x40000000, + EmitBreathParticles = 0x01, + BreathParticlesOverrideParent = 0x02, + OnMapDungeon = 0x04, + AllowTradeChannel = 0x08, + EnemiesPvPFlagged = 0x10, + AllowResting = 0x20, + AllowDueling = 0x40, + FreeForAllPvP = 0x80, + LinkedChat = 0x100, // Set in cities + LinkedChatSpecialArea = 0x200, + ForceThisAreaWhenOnDynamicTransport = 0x400, + NoPvP = 0x800, + NoGhostOnRelease = 0x1000, + SubZoneAmbientMultiplier = 0x2000, + EnableFlightBoundsOnMap = 0x4000, + PVPPOI = 0x8000, + NoChatChannels = 0x10000, + AreaNotInUse = 0x20000, + Contested = 0x40000, + NoPlayerSummoning = 0x80000, + NoDuelingIfTournamentRealm = 0x100000, + PlayersCallGuards = 0x200000, + HordeResting = 0x400000, + AllianceResting = 0x800000, + CombatZone = 0x1000000, + ForceIndoors = 0x2000000, + ForceOutdoors = 0x4000000, + AllowHearthAndRessurectFromArea = 0x08000000, + NoLocalDefenseChannel = 0x10000000, + OnlyEvaluateGhostBindOnce = 0x20000000, + IsSubzone = 0x40000000, + DontEvaluateGraveyardFromClient = 0x80000000 } [Flags] public enum AreaFlags2 { - DontShowSanctuary = 0x200, // Hides sanctuary status from zone text color (Script_GetZonePVPInfo) - CanEnableWarMode = 0x1000, // Allows enabling war mode + ForceMicroDungeonArtMap = 0x01, // Ask Programmer + UseSubzonePlayerLoot = 0x02, + AllowPetBattleDuelingEvenIfNoDuelingAllowed = 0x04, + UseMapTransferLocsForCemeteries = 0x08, + IsGarrison = 0x10, + UseSubzoneForChatChannel = 0x20, + DontRealmCoalesceChatChannel = 0x40, + NotExplorable = 0x80, // Don't assign area bit + DontUseParentMapForCemeteries = 0x100, + DontShowSanctuaryText = 0x200, + CrossFactionZoneChat = 0x400, + ForceNoResting = 0x800, + AllowWarModeToggle = 0x1000 + } + + [Flags] + public enum AreaMountFlags + { + None = 0x0, + AllowGroundMounts = 0x1, + AllowFlyingMounts = 0x2, + AllowSurfaceSwimmingMounts = 0x4, + AllowUnderwaterSwimmingMounts = 0x8, + ClientEnforcesMount = 0x10 } public enum ArtifactCategory @@ -1702,14 +1726,6 @@ namespace Framework.Constants Weekly = 2 } - public enum AreaMountFlags - { - GroundAllowed = 0x1, - FlyingAllowed = 0x2, - FloatAllowed = 0x4, - UnderwaterAllowed = 0x8 - } - public enum ModifierTreeOperator { SingleTrue = 2, diff --git a/Source/Game/Achievements/CriteriaHandler.cs b/Source/Game/Achievements/CriteriaHandler.cs index bde33929f..373100d7b 100644 --- a/Source/Game/Achievements/CriteriaHandler.cs +++ b/Source/Game/Achievements/CriteriaHandler.cs @@ -1460,9 +1460,8 @@ namespace Game.Achievements { uint zoneId = referencePlayer.GetAreaId(); AreaTableRecord areaEntry = CliDB.AreaTableStorage.LookupByKey(zoneId); - if (areaEntry != null) - if (areaEntry.HasFlag(AreaFlags.Unk9)) - zoneId = areaEntry.ParentAreaID; + if (areaEntry != null && areaEntry.GetFlags().HasFlag(AreaFlags.IsSubzone)) + zoneId = areaEntry.ParentAreaID; if (zoneId != reqValue) return false; break; @@ -1473,9 +1472,8 @@ namespace Game.Achievements return false; uint zoneId = refe.GetAreaId(); AreaTableRecord areaEntry = CliDB.AreaTableStorage.LookupByKey(zoneId); - if (areaEntry != null) - if (areaEntry.HasFlag(AreaFlags.Unk9)) - zoneId = areaEntry.ParentAreaID; + if (areaEntry != null && areaEntry.GetFlags().HasFlag(AreaFlags.IsSubzone)) + zoneId = areaEntry.ParentAreaID; if (zoneId != reqValue) return false; break; diff --git a/Source/Game/DataStorage/Structs/A_Records.cs b/Source/Game/DataStorage/Structs/A_Records.cs index 04bbd50e0..28bb498e7 100644 --- a/Source/Game/DataStorage/Structs/A_Records.cs +++ b/Source/Game/DataStorage/Structs/A_Records.cs @@ -131,25 +131,14 @@ namespace Game.DataStorage public uint[] Flags = new uint[2]; public ushort[] LiquidTypeID = new ushort[4]; + public AreaFlags GetFlags() { return (AreaFlags)Flags[0]; } + public AreaFlags2 GetFlags2() { return (AreaFlags2)Flags[1]; } + public AreaMountFlags GetMountFlags() { return (AreaMountFlags)MountFlags; } + public bool IsSanctuary() { - return HasFlag(AreaFlags.Sanctuary); + return GetFlags().HasFlag(AreaFlags.NoPvP); } - - public bool IsFlyable() - { - if (HasFlag(AreaFlags.Outland)) - { - if (!HasFlag(AreaFlags.NoFlyZone)) - return true; - } - - return false; - } - - public bool HasFlag(AreaFlags flag) { return Flags[0].HasAnyFlag((uint)flag); } - - public bool HasFlag2(AreaFlags2 flag) { return Flags[1].HasAnyFlag((uint)flag); } } public sealed class AreaTriggerRecord diff --git a/Source/Game/Entities/Player/Player.Map.cs b/Source/Game/Entities/Player/Player.Map.cs index c894bd0c1..ab0fe8777 100644 --- a/Source/Game/Entities/Player/Player.Map.cs +++ b/Source/Game/Entities/Player/Player.Map.cs @@ -97,7 +97,7 @@ namespace Game.Entities AreaTableRecord area = CliDB.AreaTableStorage.LookupByKey(newArea); bool oldFFAPvPArea = pvpInfo.IsInFFAPvPArea; - pvpInfo.IsInFFAPvPArea = area != null && area.HasFlag(AreaFlags.Arena); + pvpInfo.IsInFFAPvPArea = area != null && area.GetFlags().HasFlag(AreaFlags.FreeForAllPvP); UpdatePvPState(true); // check if we were in ffa arena and we left @@ -124,8 +124,8 @@ namespace Game.Entities else RemovePvpFlag(UnitPVPStateFlags.Sanctuary); - AreaFlags areaRestFlag = (GetTeam() == Team.Alliance) ? AreaFlags.RestZoneAlliance : AreaFlags.RestZoneHorde; - if (area != null && area.HasFlag(areaRestFlag)) + AreaFlags areaRestFlag = (GetTeam() == Team.Alliance) ? AreaFlags.AllianceResting : AreaFlags.HordeResting; + if (area != null && area.GetFlags().HasFlag(areaRestFlag)) _restMgr.SetRestFlag(RestFlag.FactionArea); else _restMgr.RemoveRestFlag(RestFlag.FactionArea); @@ -181,7 +181,7 @@ namespace Game.Entities UpdateHostileAreaState(zone); - if (zone.HasFlag(AreaFlags.Capital)) // Is in a capital city + if (zone.GetFlags().HasFlag(AreaFlags.LinkedChat)) // Is in a capital city { if (!pvpInfo.IsInHostileArea || zone.IsSanctuary()) _restMgr.SetRestFlag(RestFlag.City); @@ -226,17 +226,17 @@ namespace Game.Entities if (area.IsSanctuary()) // sanctuary and arena cannot be overriden pvpInfo.IsInHostileArea = false; - else if (area.HasFlag(AreaFlags.Arena)) + else if (area.GetFlags().HasFlag(AreaFlags.FreeForAllPvP)) pvpInfo.IsInHostileArea = true; else if (overrideZonePvpType == ZonePVPTypeOverride.None) { if (area != null) { - if (InBattleground() || area.HasFlag(AreaFlags.Combat) || (area.PvpCombatWorldStateID != -1 && Global.WorldStateMgr.GetValue(area.PvpCombatWorldStateID, GetMap()) != 0)) + if (InBattleground() || area.GetFlags().HasFlag(AreaFlags.CombatZone) || (area.PvpCombatWorldStateID != -1 && Global.WorldStateMgr.GetValue(area.PvpCombatWorldStateID, GetMap()) != 0)) pvpInfo.IsInHostileArea = true; - else if (IsWarModeLocalActive() || area.HasFlag(AreaFlags.Unk3)) + else if (IsWarModeLocalActive() || area.GetFlags().HasFlag(AreaFlags.EnemiesPvPFlagged)) { - if (area.HasFlag(AreaFlags.ContestedArea)) + if (area.GetFlags().HasFlag(AreaFlags.Contested)) pvpInfo.IsInHostileArea = IsWarModeLocalActive(); else { diff --git a/Source/Game/Entities/Player/Player.PvP.cs b/Source/Game/Entities/Player/Player.PvP.cs index 58771a3f2..5f11c5ab9 100644 --- a/Source/Game/Entities/Player/Player.PvP.cs +++ b/Source/Game/Entities/Player/Player.PvP.cs @@ -356,7 +356,7 @@ namespace Game.Entities if (area.IsSanctuary()) return false; - if (area.HasFlag(AreaFlags.Arena)) + if (area.GetFlags().HasFlag(AreaFlags.FreeForAllPvP)) return true; if (Global.BattleFieldMgr.IsWorldPvpArea(area.Id)) diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index faf24ef51..180729799 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -2738,10 +2738,10 @@ namespace Game.Entities public bool CanJoinConstantChannelInZone(ChatChannelsRecord channel, AreaTableRecord zone) { - if (channel.Flags.HasAnyFlag(ChannelDBCFlags.ZoneDep) && zone.HasFlag(AreaFlags.ArenaInstance)) + if (channel.Flags.HasAnyFlag(ChannelDBCFlags.ZoneDep) && zone.GetFlags().HasFlag(AreaFlags.NoChatChannels)) return false; - if (channel.Flags.HasAnyFlag(ChannelDBCFlags.CityOnly) && !zone.HasFlag(AreaFlags.Capital)) + if (channel.Flags.HasAnyFlag(ChannelDBCFlags.CityOnly) && !zone.GetFlags().HasFlag(AreaFlags.AllowTradeChannel)) return false; if (channel.Flags.HasAnyFlag(ChannelDBCFlags.GuildReq) && GetGuildId() != 0) @@ -4200,7 +4200,7 @@ namespace Game.Entities bool shouldResurrect = false; // Such zones are considered unreachable as a ghost and the player must be automatically revived - if ((!IsAlive() && zone != null && zone.HasFlag(AreaFlags.NeedFly)) || GetTransport() != null || GetPositionZ() < GetMap().GetMinHeight(GetPhaseShift(), GetPositionX(), GetPositionY())) + if ((!IsAlive() && zone != null && zone.GetFlags().HasFlag(AreaFlags.NoGhostOnRelease)) || GetTransport() != null || GetPositionZ() < GetMap().GetMinHeight(GetPhaseShift(), GetPositionX(), GetPositionY())) { shouldResurrect = true; SpawnCorpseBones(); @@ -4787,7 +4787,7 @@ namespace Game.Entities do { - if ((area.Flags[1] & (uint)AreaFlags2.CanEnableWarMode) != 0) + if (area.GetFlags2().HasFlag(AreaFlags2.AllowWarModeToggle)) return true; area = CliDB.AreaTableStorage.LookupByKey(area.ParentAreaID); diff --git a/Source/Game/Entities/Unit/Unit.Movement.cs b/Source/Game/Entities/Unit/Unit.Movement.cs index 342795652..2c4b6a137 100644 --- a/Source/Game/Entities/Unit/Unit.Movement.cs +++ b/Source/Game/Entities/Unit/Unit.Movement.cs @@ -782,13 +782,13 @@ namespace Game.Entities if (!mountCapability.Flags.HasAnyFlag(MountCapabilityFlags.IgnoreRestrictions)) { - if (mountCapability.Flags.HasAnyFlag(MountCapabilityFlags.Ground) && !mountFlags.HasAnyFlag(AreaMountFlags.GroundAllowed)) + if (mountCapability.Flags.HasAnyFlag(MountCapabilityFlags.Ground) && !mountFlags.HasFlag(AreaMountFlags.AllowGroundMounts)) continue; - if (mountCapability.Flags.HasAnyFlag(MountCapabilityFlags.Flying) && !mountFlags.HasAnyFlag(AreaMountFlags.FlyingAllowed)) + if (mountCapability.Flags.HasAnyFlag(MountCapabilityFlags.Flying) && !mountFlags.HasFlag(AreaMountFlags.AllowFlyingMounts)) continue; - if (mountCapability.Flags.HasAnyFlag(MountCapabilityFlags.Float) && !mountFlags.HasAnyFlag(AreaMountFlags.FloatAllowed)) + if (mountCapability.Flags.HasAnyFlag(MountCapabilityFlags.Float) && !mountFlags.HasFlag(AreaMountFlags.AllowSurfaceSwimmingMounts)) continue; - if (mountCapability.Flags.HasAnyFlag(MountCapabilityFlags.Underwater) && !mountFlags.HasAnyFlag(AreaMountFlags.UnderwaterAllowed)) + if (mountCapability.Flags.HasAnyFlag(MountCapabilityFlags.Underwater) && !mountFlags.HasFlag(AreaMountFlags.AllowUnderwaterSwimmingMounts)) continue; } diff --git a/Source/Game/Handlers/BattleGroundHandler.cs b/Source/Game/Handlers/BattleGroundHandler.cs index 860f11cde..201ac11a1 100644 --- a/Source/Game/Handlers/BattleGroundHandler.cs +++ b/Source/Game/Handlers/BattleGroundHandler.cs @@ -682,7 +682,7 @@ namespace Game } AreaTableRecord atEntry = CliDB.AreaTableStorage.LookupByKey(GetPlayer().GetAreaId()); - if (atEntry == null || !atEntry.HasFlag(AreaFlags.CanHearthAndResurrect)) + if (atEntry == null || !atEntry.GetFlags().HasFlag(AreaFlags.AllowHearthAndRessurectFromArea)) return; GetPlayer().BuildPlayerRepop(); diff --git a/Source/Game/Maps/TerrainManager.cs b/Source/Game/Maps/TerrainManager.cs index 7139ddc7a..f9a986f31 100644 --- a/Source/Game/Maps/TerrainManager.cs +++ b/Source/Game/Maps/TerrainManager.cs @@ -479,7 +479,7 @@ namespace Game.Maps data.AreaId = gridAreaId; var areaEntry1 = CliDB.AreaTableStorage.LookupByKey(data.AreaId); if (areaEntry1 != null) - data.outdoors = ((AreaFlags)areaEntry1.Flags[0] & (AreaFlags.Inside | AreaFlags.Outside)) != AreaFlags.Inside; + data.outdoors = areaEntry1.GetFlags().HasFlag(AreaFlags.ForceOutdoors) || !areaEntry1.GetFlags().HasFlag(AreaFlags.ForceIndoors); } if (data.AreaId == 0) diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index e95eb7f06..af1f4bd6e 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -5717,11 +5717,9 @@ namespace Game.Spells // allow always ghost flight spells if (m_originalCaster != null && m_originalCaster.IsTypeId(TypeId.Player) && m_originalCaster.IsAlive()) { - BattleField Bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(m_originalCaster.GetMap(), m_originalCaster.GetZoneId()); - var area = CliDB.AreaTableStorage.LookupByKey(m_originalCaster.GetAreaId()); - if (area != null) - if (area.HasFlag(AreaFlags.NoFlyZone) || (Bf != null && !Bf.CanFlyIn())) - return SpellCastResult.NotHere; + BattleField battleField = Global.BattleFieldMgr.GetBattlefieldToZoneId(m_originalCaster.GetMap(), m_originalCaster.GetZoneId()); + if (battleField != null && !battleField.CanFlyIn()) + return SpellCastResult.NotHere; } break; } diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index 5b3713aee..d47df1edb 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -2827,14 +2827,14 @@ namespace Game.Spells // Players can only fight a duel in zones with this flag AreaTableRecord casterAreaEntry = CliDB.AreaTableStorage.LookupByKey(caster.GetAreaId()); - if (casterAreaEntry != null && !casterAreaEntry.HasFlag(AreaFlags.AllowDuels)) + if (casterAreaEntry != null && !casterAreaEntry.GetFlags().HasFlag(AreaFlags.AllowDueling)) { SendCastResult(SpellCastResult.NoDueling); // Dueling isn't allowed here return; } AreaTableRecord targetAreaEntry = CliDB.AreaTableStorage.LookupByKey(target.GetAreaId()); - if (targetAreaEntry != null && !targetAreaEntry.HasFlag(AreaFlags.AllowDuels)) + if (targetAreaEntry != null && !targetAreaEntry.GetFlags().HasFlag(AreaFlags.AllowDueling)) { SendCastResult(SpellCastResult.NoDueling); // Dueling isn't allowed here return; diff --git a/Source/Game/Spells/SpellInfo.cs b/Source/Game/Spells/SpellInfo.cs index fde9a0ed9..d1ebb18c8 100644 --- a/Source/Game/Spells/SpellInfo.cs +++ b/Source/Game/Spells/SpellInfo.cs @@ -842,19 +842,19 @@ namespace Game.Spells // continent limitation (virtual continent) if (HasAttribute(SpellAttr4.OnlyFlyingAreas)) { - uint mountFlags = 0; + AreaMountFlags mountFlags = 0; if (player && player.HasAuraType(AuraType.MountRestrictions)) { foreach (AuraEffect auraEffect in player.GetAuraEffectsByType(AuraType.MountRestrictions)) - mountFlags |= (uint)auraEffect.GetMiscValue(); + mountFlags |= (AreaMountFlags)auraEffect.GetMiscValue(); } else { AreaTableRecord areaTable = CliDB.AreaTableStorage.LookupByKey(area_id); if (areaTable != null) - mountFlags = areaTable.MountFlags; + mountFlags = areaTable.GetMountFlags(); } - if (!Convert.ToBoolean(mountFlags & (uint)AreaMountFlags.FlyingAllowed)) + if (!mountFlags.HasFlag(AreaMountFlags.AllowFlyingMounts)) return SpellCastResult.IncorrectArea; if (player) diff --git a/Source/Scripts/Spells/Items.cs b/Source/Scripts/Spells/Items.cs index c7bdaac1e..c6c743be5 100644 --- a/Source/Scripts/Spells/Items.cs +++ b/Source/Scripts/Spells/Items.cs @@ -2944,9 +2944,8 @@ namespace Scripts.Spells.Items void HandleDummy(uint effIndex) { Unit caster = GetCaster(); - AreaTableRecord areaEntry = CliDB.AreaTableStorage.LookupByKey(caster.GetAreaId()); bool success = true; - if (areaEntry != null && areaEntry.IsFlyable() && !caster.GetMap().IsDungeon()) + if (!caster.GetMap().IsDungeon()) success = RandomHelper.randChance(95); caster.CastSpell(caster, success ? SpellIds.NitroBoostsSuccess : SpellIds.NitroBoostsBackfire, new CastSpellExtraArgs(GetCastItem())); }