Skip to content

Commit

Permalink
Bugfix: Cluster fields on player could throw null-exception (no cluster)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsebring committed Oct 14, 2017
1 parent 6df4310 commit 1e0f882
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions ArkSavegameToolkitNet.Domain/ArkPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ public ArkPlayer()
_creatures = new Lazy<ArkTamedCreature[]>(() =>
{
ArkTamedCreature[] creatures = null;
return _gameData._playerTamedCreatures.TryGetValue(Id, out creatures) ? creatures : new ArkTamedCreature[] { };
return _gameData?._playerTamedCreatures.TryGetValue(Id, out creatures) == true ? creatures : new ArkTamedCreature[] { };
});
_structures = new Lazy<ArkStructure[]>(() =>
{
ArkStructure[] structures = null;
return _gameData._playerStructures.TryGetValue(Id, out structures) ? structures : new ArkStructure[] { };
return _gameData?._playerStructures.TryGetValue(Id, out structures) == true ? structures : new ArkStructure[] { };
});
_items = new Lazy<ArkItem[]>(() => Structures.SelectMany(x => x.Inventory)
.Concat(Creatures.SelectMany(x => x.Inventory))
Expand All @@ -122,28 +122,28 @@ public ArkPlayer()
_tribe = new Lazy<ArkTribe>(() =>
{
ArkTribe tribe = null;
return _gameData._playerTribes.TryGetValue(Id, out tribe) ? tribe : null;
return _gameData?._playerTribes.TryGetValue(Id, out tribe) == true ? tribe : null;
});
_inventory = new Lazy<ArkItem[]>(() => {
if (!InventoryId.HasValue) return new ArkItem[] { };

ArkItem[] items = null;
return _gameData._inventoryItems.TryGetValue(InventoryId.Value, out items) ? items.Where(ArkItem.Filter_RealItems).ToArray() : new ArkItem[] { };
return _gameData?._inventoryItems.TryGetValue(InventoryId.Value, out items) == true ? items.Where(ArkItem.Filter_RealItems).ToArray() : new ArkItem[] { };
});
_cloudCreatures = new Lazy<ArkCloudInventoryDino[]>(() =>
{
ArkCloudInventoryDino[] creatures = null;
return _clusterData._playerCloudCreatures.TryGetValue(SteamId, out creatures) ? creatures : new ArkCloudInventoryDino[] { };
return _clusterData?._playerCloudCreatures.TryGetValue(SteamId, out creatures) == true ? creatures : new ArkCloudInventoryDino[] { };
});
_cloudItems = new Lazy<ArkCloudInventoryItem[]>(() =>
{
ArkCloudInventoryItem[] items = null;
return _clusterData._playerCloudItems.TryGetValue(SteamId, out items) ? items : new ArkCloudInventoryItem[] { };
return _clusterData?._playerCloudItems.TryGetValue(SteamId, out items) == true ? items : new ArkCloudInventoryItem[] { };
});
_lastActiveTime = new Lazy<DateTime>(() =>
{
ArkCloudInventory inv = null;
return _clusterData._playerCloudInventories.TryGetValue(SteamId, out inv) && inv.SavedAt > SavedAt ? inv.SavedAt : SavedAt;
return _clusterData?._playerCloudInventories.TryGetValue(SteamId, out inv) == true && inv.SavedAt > SavedAt ? inv.SavedAt : SavedAt;
});
}

Expand Down
2 changes: 1 addition & 1 deletion ArkSavegameToolkitNet.Domain/ArkStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ArkStructure()
if (!InventoryId.HasValue) return new ArkItem[] { };

ArkItem[] items = null;
return _gameData._inventoryItems.TryGetValue(InventoryId.Value, out items) ? items.Where(ArkItem.Filter_RealItems).ToArray() : new ArkItem[] { };
return _gameData?._inventoryItems.TryGetValue(InventoryId.Value, out items) == true ? items.Where(ArkItem.Filter_RealItems).ToArray() : new ArkItem[] { };
});
}

Expand Down
2 changes: 1 addition & 1 deletion ArkSavegameToolkitNet.Domain/ArkTamedCreature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private void Construct()
if (!InventoryId.HasValue) return new ArkItem[] { };

ArkItem[] items = null;
return _gameData._inventoryItems.TryGetValue(InventoryId.Value, out items) ? items.Where(ArkItem.Filter_RealItems).ToArray() : new ArkItem[] { };
return _gameData?._inventoryItems.TryGetValue(InventoryId.Value, out items) == true ? items.Where(ArkItem.Filter_RealItems).ToArray() : new ArkItem[] { };
});
}

Expand Down
6 changes: 3 additions & 3 deletions ArkSavegameToolkitNet.Domain/ArkTribe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public ArkTribe()
_creatures = new Lazy<ArkTamedCreature[]>(() =>
{
ArkTamedCreature[] creatures = null;
return _gameData._tribeTamedCreatures.TryGetValue(Id, out creatures) ? creatures : new ArkTamedCreature[] { };
return _gameData?._tribeTamedCreatures.TryGetValue(Id, out creatures) == true ? creatures : new ArkTamedCreature[] { };
});
_structures = new Lazy<ArkStructure[]>(() =>
{
ArkStructure[] structures = null;
return _gameData._tribeStructures.TryGetValue(Id, out structures) ? structures : new ArkStructure[] { };
return _gameData?._tribeStructures.TryGetValue(Id, out structures) == true ? structures : new ArkStructure[] { };
});
_items = new Lazy<ArkItem[]>(() => Structures.SelectMany(x => x.Inventory)
.Concat(Creatures.SelectMany(x => x.Inventory)).Where(ArkItem.Filter_RealItems).ToArray());
Expand All @@ -67,7 +67,7 @@ public ArkTribe()
_members = new Lazy<ArkPlayer[]>(() =>
{
ArkPlayer[] members = null;
return _gameData._tribePlayers.TryGetValue(Id, out members) ? members : new ArkPlayer[] { };
return _gameData?._tribePlayers.TryGetValue(Id, out members) == true ? members : new ArkPlayer[] { };
});
_lastActiveTime = new Lazy<DateTime>(() => Members.Length > 0 ? Members.Max(y => y.LastActiveTime) : SavedAt);
}
Expand Down
4 changes: 2 additions & 2 deletions ArkSavegameToolkitNet.Domain/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]

//todo: temp for dev purposes
[assembly: InternalsVisibleTo("ArkSavegameToolkitNet.TestConsoleApp")]
4 changes: 2 additions & 2 deletions ArkSavegameToolkitNet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]

[assembly: InternalsVisibleTo("ArkSavegameToolkitNet.Domain")]

0 comments on commit 1e0f882

Please sign in to comment.