From 0011db7f47f0c09876d178b078726a96450e0bb6 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Thu, 23 May 2024 16:07:33 -0700 Subject: [PATCH] fix: Fixes house update range bug (#1790) --- Projects/Server/Utilities/Utility.cs | 4 ++-- Projects/UOContent/Engines/Harvest/Mining.cs | 2 +- .../UOContent/Engines/ML Quests/Items/QuestGiverItem.cs | 6 ++---- Projects/UOContent/Multis/Houses/BaseHouse.cs | 5 +++-- Projects/UOContent/Multis/Houses/HouseFoundation.cs | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Projects/Server/Utilities/Utility.cs b/Projects/Server/Utilities/Utility.cs index d82b6a88d..0c2fee286 100644 --- a/Projects/Server/Utilities/Utility.cs +++ b/Projects/Server/Utilities/Utility.cs @@ -674,14 +674,14 @@ public static class Utility InRange(p1.m_X, p1.m_Y, p2.m_X, p2.m_Y, range); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool InUpdateRange(Point2D p1, Point2D p2) => InRange(p1, p2, 18); + public static bool InUpdateRange(Point2D p1, Point2D p2) => InRange(p1, p2, Core.GlobalUpdateRange); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool InRange(Point3D p1, Point3D p2, int range) => InRange(p1.m_X, p1.m_Y, p2.m_X, p2.m_Y, range); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool InUpdateRange(Point3D p1, Point3D p2) => InRange(p1, p2, 18); + public static bool InUpdateRange(Point3D p1, Point3D p2) => InRange(p1, p2, Core.GlobalUpdateRange); // Optimized method for handling 50% random chances in succession up to a maximum public static int CoinFlips(int amount, int maximum) diff --git a/Projects/UOContent/Engines/Harvest/Mining.cs b/Projects/UOContent/Engines/Harvest/Mining.cs index b7f6e3085..e79de9fed 100644 --- a/Projects/UOContent/Engines/Harvest/Mining.cs +++ b/Projects/UOContent/Engines/Harvest/Mining.cs @@ -265,7 +265,7 @@ namespace Server.Engines.Harvest Definitions = new[] { OreAndStone, Sand }; } - public static Mining System => _system ?? (_system = new Mining()); + public static Mining System => _system ??= new Mining(); public HarvestDefinition OreAndStone { get; } diff --git a/Projects/UOContent/Engines/ML Quests/Items/QuestGiverItem.cs b/Projects/UOContent/Engines/ML Quests/Items/QuestGiverItem.cs index 3a0d14ea4..9de4b9ad6 100644 --- a/Projects/UOContent/Engines/ML Quests/Items/QuestGiverItem.cs +++ b/Projects/UOContent/Engines/ML Quests/Items/QuestGiverItem.cs @@ -19,8 +19,7 @@ public abstract partial class QuestGiverItem : Item, IQuestGiver public override bool Nontransferable => true; - public List MLQuests => m_MLQuests ?? - (m_MLQuests = MLQuestSystem.FindQuestList(GetType()) ?? MLQuestSystem.EmptyList); + public List MLQuests => m_MLQuests ??= MLQuestSystem.FindQuestList(GetType()) ?? MLQuestSystem.EmptyList; public override void AddNameProperties(IPropertyList list) { @@ -75,8 +74,7 @@ public abstract partial class TransientQuestGiverItem : TransientItem, IQuestGiv public override bool Nontransferable => true; - public List MLQuests => m_MLQuests ?? - (m_MLQuests = MLQuestSystem.FindQuestList(GetType()) ?? MLQuestSystem.EmptyList); + public List MLQuests => m_MLQuests ??= MLQuestSystem.FindQuestList(GetType()) ?? MLQuestSystem.EmptyList; public override void HandleInvalidTransfer(Mobile from) { diff --git a/Projects/UOContent/Multis/Houses/BaseHouse.cs b/Projects/UOContent/Multis/Houses/BaseHouse.cs index b7637e9b7..b7e911f42 100644 --- a/Projects/UOContent/Multis/Houses/BaseHouse.cs +++ b/Projects/UOContent/Multis/Houses/BaseHouse.cs @@ -716,7 +716,9 @@ namespace Server.Multis return fromSecures + fromVendors + fromLockdowns + fromMovingCrate; } - public bool InRange(Point2D from, int range) + public override bool InRange(Point3D from, int range) => InRange(new Point2D(from), range); + + public override bool InRange(Point2D from, int range) { if (Region == null) { @@ -725,7 +727,6 @@ namespace Server.Multis foreach (var rect in Region.Area) { - // TODO: Convert this to 3D - https://github.com/modernuo/ModernUO/issues/29 if (from.X >= rect.Start.X - range && from.Y >= rect.Start.Y - range && from.X < rect.End.X + range && from.Y < rect.End.Y + range) { return true; diff --git a/Projects/UOContent/Multis/Houses/HouseFoundation.cs b/Projects/UOContent/Multis/Houses/HouseFoundation.cs index 52b617163..74ad5e4e7 100644 --- a/Projects/UOContent/Multis/Houses/HouseFoundation.cs +++ b/Projects/UOContent/Multis/Houses/HouseFoundation.cs @@ -201,7 +201,7 @@ namespace Server.Multis } } - public static ComponentVerification Verification => m_Verification ?? (m_Verification = new ComponentVerification()); + public static ComponentVerification Verification => m_Verification ??= new ComponentVerification(); public bool IsFixture(Item item) => Fixtures.Contains(item);