From 3f600402f848fa3921e2d5c864c19b2a3bb432e5 Mon Sep 17 00:00:00 2001 From: cadon Date: Fri, 21 Apr 2023 18:52:38 +0200 Subject: [PATCH] handle unclaimed creatures in cryopods if the cryopod has no owner neither --- SavegameToolkit/ArkSavegame.cs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/SavegameToolkit/ArkSavegame.cs b/SavegameToolkit/ArkSavegame.cs index c55294d..16f0c07 100644 --- a/SavegameToolkit/ArkSavegame.cs +++ b/SavegameToolkit/ArkSavegame.cs @@ -451,16 +451,20 @@ private void extractBinaryObjectCryopods(ReadingOptions options) { // if a creature is cryoed and unclaimed, determine the owner of the container the cryopod is in and set that as the owner var ownerInventoryProperty = cryo.GetPropertyValue("OwnerInventory"); - if (!soulTrapContainer.TryGetValue(ownerInventoryProperty.ObjectId, out var ownerString)) + if (ownerInventoryProperty != null) { - var inventoryObject = Objects.FirstOrDefault(o => o.Id == ownerInventoryProperty.ObjectId); - ownerString = inventoryObject?.Parent?.GetPropertyValue("OwnerName"); - soulTrapContainer[ownerInventoryProperty.ObjectId] = ownerString; - } - - if (!string.IsNullOrEmpty(ownerString)) - { - storedGameObjects[0].Properties.Add(new PropertyString("TribeName", ownerString)); + if (!soulTrapContainer.TryGetValue(ownerInventoryProperty.ObjectId, out var ownerString)) + { + var inventoryObject = + Objects.FirstOrDefault(o => o.Id == ownerInventoryProperty.ObjectId); + ownerString = inventoryObject?.Parent?.GetPropertyValue("OwnerName"); + soulTrapContainer[ownerInventoryProperty.ObjectId] = ownerString; + } + + if (!string.IsNullOrEmpty(ownerString)) + { + storedGameObjects[0].Properties.Add(new PropertyString("TribeName", ownerString)); + } } } }