Skip to content

Commit

Permalink
fix: Nullpoiner in 3.23.1
Browse files Browse the repository at this point in the history
  • Loading branch information
octfx committed May 12, 2024
1 parent 4cfc577 commit 704c96a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Loader/ItemBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,25 @@ 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;

var stdItem = new StandardisedItem
{
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)
};
Expand Down Expand Up @@ -105,7 +107,7 @@ List<StandardisedItemPort> BuildPortList(EntityClassDefinition entity)
{
var ports = new List<StandardisedItemPort>();

if (entity.Components.SItemPortContainerComponentParams == null) return ports;
if (entity?.Components?.SItemPortContainerComponentParams == null) return ports;

foreach (var port in entity.Components.SItemPortContainerComponentParams.Ports)
{
Expand Down
1 change: 1 addition & 0 deletions Loader/ItemInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void InstallLoadout(StandardisedItemPort port, List<StandardisedLoadoutEn
if (item == null) return;

var standardisedItem = itemBuilder.BuildItem(item);

port.InstalledItem = standardisedItem;

// Update the loadout with anything this item brings with it
Expand Down

0 comments on commit 704c96a

Please sign in to comment.