From b0d8dd42c048a2e7a59a5d7e7ee949e2ef67aa10 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sun, 15 Nov 2020 13:52:05 -0800 Subject: [PATCH] Fixes NPE (#312) - [X] Fixes issue with world load where items modify mobiles before mobiles are initialized Bumps release version --- Projects/Server/World/World.cs | 6 +++--- Projects/UOContent/Items/Armor/BaseArmor.cs | 15 +++++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Projects/Server/World/World.cs b/Projects/Server/World/World.cs index ab7364d4b..b2aa02afb 100644 --- a/Projects/Server/World/World.cs +++ b/Projects/Server/World/World.cs @@ -367,12 +367,12 @@ namespace Server IIndexInfo mobileIndexInfo = new EntityTypeIndex("Mobiles"); IIndexInfo guildIndexInfo = new EntityTypeIndex("Guilds"); - Items = LoadIndex(itemIndexInfo, out items); Mobiles = LoadIndex(mobileIndexInfo, out mobiles); + Items = LoadIndex(itemIndexInfo, out items); Guilds = LoadIndex(guildIndexInfo, out guilds); - LoadData(itemIndexInfo, items); LoadData(mobileIndexInfo, mobiles); + LoadData(itemIndexInfo, items); LoadData(guildIndexInfo, guilds); EventSink.InvokeWorldLoad(); @@ -464,8 +464,8 @@ namespace Server IIndexInfo mobileIndexInfo = new EntityTypeIndex("Mobiles"); IIndexInfo guildIndexInfo = new EntityTypeIndex("Guilds"); - WriteEntities(itemIndexInfo, Items, ItemTypes); WriteEntities(mobileIndexInfo, Mobiles, MobileTypes); + WriteEntities(itemIndexInfo, Items, ItemTypes); WriteEntities(guildIndexInfo, Guilds, GuildTypes); watch.Stop(); diff --git a/Projects/UOContent/Items/Armor/BaseArmor.cs b/Projects/UOContent/Items/Armor/BaseArmor.cs index 1c5fe2f34..0dffbc5f3 100644 --- a/Projects/UOContent/Items/Armor/BaseArmor.cs +++ b/Projects/UOContent/Items/Armor/BaseArmor.cs @@ -1655,17 +1655,12 @@ namespace Server.Items return true; } - if (Layer == Layer.Pants) + return Layer switch { - return m.FindItemOnLayer(Layer.InnerLegs) != null; - } - - if (Layer == Layer.Shirt) - { - return m.FindItemOnLayer(Layer.InnerTorso) != null; - } - - return false; + Layer.Pants => m.FindItemOnLayer(Layer.InnerLegs) != null, + Layer.Shirt => m.FindItemOnLayer(Layer.InnerTorso) != null, + _ => false + }; } public override bool OnEquip(Mobile from)