From 704c96a475465b31b047f54dec8faa147d34ca8d Mon Sep 17 00:00:00 2001 From: "H. C. Kruse" Date: Sun, 12 May 2024 20:57:18 +0200 Subject: [PATCH] fix: Nullpoiner in 3.23.1 --- Loader/ItemBuilder.cs | 16 +++++++++------- Loader/ItemInstaller.cs | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Loader/ItemBuilder.cs b/Loader/ItemBuilder.cs index 1f304c5ad..d48780feb 100644 --- a/Loader/ItemBuilder.cs +++ b/Loader/ItemBuilder.cs @@ -25,6 +25,8 @@ public ItemBuilder(LocalisationService localisationSvc, ManufacturerService manu public StandardisedItem BuildItem(EntityClassDefinition entity) { + if (entity == null) return null; + var volume = ConvertToSCU(entity.Components?.SAttachableComponentParams?.AttachDef?.inventoryOccupancyVolume) ?? 0; @@ -32,16 +34,16 @@ public StandardisedItem BuildItem(EntityClassDefinition entity) { UUID = entity.__ref, ClassName = entity.ClassName, - Size = entity.Components.SAttachableComponentParams?.AttachDef.Size ?? 0, - Grade = entity.Components.SAttachableComponentParams?.AttachDef.Grade ?? 0, + Size = entity.Components?.SAttachableComponentParams?.AttachDef?.Size ?? 0, + Grade = entity.Components?.SAttachableComponentParams?.AttachDef?.Grade ?? 0, Width = entity.Components?.SAttachableComponentParams?.AttachDef?.inventoryOccupancyDimensions?.x ?? 0, Length = entity.Components?.SAttachableComponentParams?.AttachDef?.inventoryOccupancyDimensions?.y ?? 0, Height = entity.Components?.SAttachableComponentParams?.AttachDef?.inventoryOccupancyDimensions?.z ?? 0, Volume = volume, - Type = BuildTypeName(entity.Components.SAttachableComponentParams?.AttachDef.Type, entity.Components.SAttachableComponentParams?.AttachDef.SubType), - Name = localisationSvc.GetText(entity.Components.SAttachableComponentParams?.AttachDef.Localization.Name, entity.ClassName), - Description = localisationSvc.GetText(entity.Components.SAttachableComponentParams?.AttachDef.Localization.Description), - Manufacturer = manufacturerSvc.GetManufacturer(entity.Components.SAttachableComponentParams?.AttachDef.Manufacturer, entity.ClassName), + Type = BuildTypeName(entity.Components?.SAttachableComponentParams?.AttachDef?.Type, entity.Components?.SAttachableComponentParams?.AttachDef?.SubType), + Name = localisationSvc.GetText(entity.Components?.SAttachableComponentParams?.AttachDef?.Localization?.Name, entity.ClassName), + Description = localisationSvc.GetText(entity.Components?.SAttachableComponentParams?.AttachDef?.Localization?.Description), + Manufacturer = manufacturerSvc.GetManufacturer(entity.Components?.SAttachableComponentParams?.AttachDef?.Manufacturer, entity.ClassName), Ports = BuildPortList(entity), Tags = BuildTagList(entity) }; @@ -105,7 +107,7 @@ List BuildPortList(EntityClassDefinition entity) { var ports = new List(); - if (entity.Components.SItemPortContainerComponentParams == null) return ports; + if (entity?.Components?.SItemPortContainerComponentParams == null) return ports; foreach (var port in entity.Components.SItemPortContainerComponentParams.Ports) { diff --git a/Loader/ItemInstaller.cs b/Loader/ItemInstaller.cs index 9469c908a..91922c977 100644 --- a/Loader/ItemInstaller.cs +++ b/Loader/ItemInstaller.cs @@ -83,6 +83,7 @@ public void InstallLoadout(StandardisedItemPort port, List