From 39dfe86e106c1772a655b43de7530ee27775f540 Mon Sep 17 00:00:00 2001 From: Kamron Batman Date: Sun, 3 Mar 2019 14:28:24 -0800 Subject: [PATCH] Merges crash bugs into master (#12) --- Scripts/Gumps/Props/PropsGump.cs | 12 ++++--- Scripts/Items/Food/Beverage.cs | 5 +-- Scripts/Misc/VendorGenerator.cs | 62 ++++++-------------------------- Scripts/Mobiles/PlayerMobile.cs | 8 ++--- Scripts/Regions/HouseRegion.cs | 2 +- Server/Mobile.cs | 13 +------ Server/Region.cs | 8 ++--- Server/packages.config | 8 ++--- 8 files changed, 33 insertions(+), 85 deletions(-) diff --git a/Scripts/Gumps/Props/PropsGump.cs b/Scripts/Gumps/Props/PropsGump.cs index 1d0d3e606..7ed7093c1 100644 --- a/Scripts/Gumps/Props/PropsGump.cs +++ b/Scripts/Gumps/Props/PropsGump.cs @@ -572,12 +572,14 @@ namespace Server.Gumps if (baseType == typeofObject || baseType?.GetProperty(prop.Name, prop.PropertyType) == null) break; - + type = baseType; } - + if (type != null && !groups.ContainsKey(type)) groups[type] = new List{ prop }; + else + groups[type].Add(prop); } } } @@ -657,13 +659,13 @@ namespace Server.Gumps return 0; if (x == null) return -1; - + return y == null ? 1 : x.Name.CompareTo(x.Name); } } private class GroupComparer : IComparer>> - { + { private Type m_Start; public GroupComparer(Type start) @@ -689,4 +691,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Food/Beverage.cs b/Scripts/Items/Food/Beverage.cs index af564855b..2c54548a4 100644 --- a/Scripts/Items/Food/Beverage.cs +++ b/Scripts/Items/Food/Beverage.cs @@ -1104,6 +1104,7 @@ namespace Server.Items public static void CheckHeaveTimer(Mobile from) { + Timer t; if (from.BAC > 0 && from.Map != Map.Internal && !from.Deleted) { if (m_Table.ContainsKey(from)) @@ -1112,12 +1113,12 @@ namespace Server.Items if (from.BAC > 60) from.BAC = 60; - Timer t = new HeaveTimer(from); + t = new HeaveTimer(from); t.Start(); m_Table[from] = t; } - else if (m_Table.TryGetValue(from, out Timer t)) + else if (m_Table.TryGetValue(from, out t)) { t.Stop(); m_Table.Remove(from); diff --git a/Scripts/Misc/VendorGenerator.cs b/Scripts/Misc/VendorGenerator.cs index a8a38f218..0d1a0f181 100644 --- a/Scripts/Misc/VendorGenerator.cs +++ b/Scripts/Misc/VendorGenerator.cs @@ -281,62 +281,22 @@ namespace Server private static bool IsArmor(int itemID) { - if (itemID >= 0x13BB && itemID <= 0x13E2) - return true; - - if (itemID >= 0x13E5 && itemID <= 0x13F2) - return true; - - if (itemID >= 0x1408 && itemID <= 0x141A) - return true; - - if (itemID >= 0x144E && itemID <= 0x1457) - return true; - - return false; + return itemID >= 0x13BB && itemID <= 0x13E2 || itemID >= 0x13E5 && itemID <= 0x13F2 || + itemID >= 0x1408 && itemID <= 0x141A || itemID >= 0x144E && itemID <= 0x1457; } private static bool IsMetalWeapon(int itemID) { - if (itemID >= 0xF43 && itemID <= 0xF4E) - return true; - - if (itemID >= 0xF51 && itemID <= 0xF52) - return true; - - if (itemID >= 0xF5C && itemID <= 0xF63) - return true; - - if (itemID >= 0x13AF && itemID <= 0x13B0) - return true; - - if (itemID >= 0x13B5 && itemID <= 0x13BA) - return true; - - if (itemID >= 0x13FA && itemID <= 0x13FB) - return true; - - if (itemID >= 0x13FE && itemID <= 0x1407) - return true; - - if (itemID >= 0x1438 && itemID <= 0x1443) - return true; - - return false; + return itemID >= 0xF43 && itemID <= 0xF4E || itemID >= 0xF51 && itemID <= 0xF52 || + itemID >= 0xF5C && itemID <= 0xF63 || itemID >= 0x13AF && itemID <= 0x13B0 || + itemID >= 0x13B5 && itemID <= 0x13BA || itemID >= 0x13FA && itemID <= 0x13FB || + itemID >= 0x13FE && itemID <= 0x1407 || itemID >= 0x1438 && itemID <= 0x1443; } private static bool IsArcheryWeapon(int itemID) { - if (itemID >= 0xF4F && itemID <= 0xF50) - return true; - - if (itemID >= 0x13B1 && itemID <= 0x13B2) - return true; - - if (itemID >= 0x13FC && itemID <= 0x13FD) - return true; - - return false; + return itemID >= 0xF4F && itemID <= 0xF50 || itemID >= 0x13B1 && itemID <= 0x13B2 || + itemID >= 0x13FC && itemID <= 0x13FD; } private static ShopFlags ProcessDisplayedItem(int itemID) @@ -481,9 +441,9 @@ namespace Server floor.Add(p); for (int xo = -1; xo <= 1; ++xo) - for (int yo = -1; yo <= 1; ++yo) - if ((xo != 0 || yo != 0) && IsFloor(map, x + xo, y + yo, false)) - RecurseFindFloor(map, x + xo, y + yo, floor); + for (int yo = -1; yo <= 1; ++yo) + if ((xo != 0 || yo != 0) && IsFloor(map, x + xo, y + yo, false)) + RecurseFindFloor(map, x + xo, y + yo, floor); } [Flags] diff --git a/Scripts/Mobiles/PlayerMobile.cs b/Scripts/Mobiles/PlayerMobile.cs index f1ecc1494..8646e6f6e 100644 --- a/Scripts/Mobiles/PlayerMobile.cs +++ b/Scripts/Mobiles/PlayerMobile.cs @@ -4728,16 +4728,12 @@ namespace Server.Mobiles public virtual bool HasRecipe(Recipe r) { - if (r == null) - return false; - - return HasRecipe(r.ID); + return r != null && HasRecipe(r.ID); } public virtual bool HasRecipe(int recipeID) { - m_AcquiredRecipes?.TryGetValue(recipeID, out bool value); - return value; + return m_AcquiredRecipes.TryGetValue(recipeID, out bool value) && value; } public virtual void AcquireRecipe(Recipe r) diff --git a/Scripts/Regions/HouseRegion.cs b/Scripts/Regions/HouseRegion.cs index 1203e1d46..964c8ab5c 100644 --- a/Scripts/Regions/HouseRegion.cs +++ b/Scripts/Regions/HouseRegion.cs @@ -91,7 +91,7 @@ namespace Server.Regions if (bc?.NoHouseRestrictions == true) { } - else if (bc.IsHouseSummonable == true && + else if (bc?.IsHouseSummonable == true && !(BaseCreature.Summoning || House.IsInside(oldLocation, 16))) { } diff --git a/Server/Mobile.cs b/Server/Mobile.cs index 8ffad92a9..ec94cccc1 100644 --- a/Server/Mobile.cs +++ b/Server/Mobile.cs @@ -1789,18 +1789,7 @@ namespace Server [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] public Map LogoutMap{ get; set; } - public Region Region - { - get - { - if (m_Region == null) - if (Map == null) - return Map.Internal.DefaultRegion; - else - return Map.DefaultRegion; - return m_Region; - } - } + public Region Region => m_Region ?? (Map == null ? Map.Internal.DefaultRegion : Map.DefaultRegion); public Packet RemovePacket { diff --git a/Server/Region.cs b/Server/Region.cs index 3b7e9458c..9d16ac806 100644 --- a/Server/Region.cs +++ b/Server/Region.cs @@ -416,7 +416,7 @@ namespace Server return false; } - + // TODO: Memoize this public T GetRegion() where T : Region { @@ -468,7 +468,7 @@ namespace Server return null; } - + public bool IsPartOf() where T : Region { return GetRegion() != null; @@ -840,7 +840,7 @@ namespace Server Console.WriteLine("Could not find root element 'ServerRegions' in Regions.xml"); return; } - + foreach (XmlElement facet in root.SelectNodes("Facet")) { Map map = null; @@ -1172,4 +1172,4 @@ namespace Server return true; } } -} \ No newline at end of file +} diff --git a/Server/packages.config b/Server/packages.config index c697f90c1..8e1dc78d7 100644 --- a/Server/packages.config +++ b/Server/packages.config @@ -7,7 +7,7 @@ - - - - \ No newline at end of file + + + + \ No newline at end of file