forked from DodoCooker/ArkSavegameToolkit
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read ArkTribe and ArkProfile data (--UseStore) (#9)
* Re-worked read of cryo/trap references to read all data in forward-only before re-parenting and adding to Objects in a parallel loop. GameObject constructor and LoadProperties methods both still use name tables internally which need to be read in single threaded to prevent mis-reads and possible duplication. Added defensive check to ensure redictors array contains the index we're trying to read. Had one that only had a "Settings" redirector for a Soul Trap and no "Dino" redirector. * Parse .arktribe and .arkprofile data from .ark save when using --UseStore.
- Loading branch information
1 parent
128c688
commit 1b15a5c
Showing
6 changed files
with
408 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using SavegameToolkit.Propertys; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SavegameToolkit | ||
{ | ||
internal class ArkStoreProfile : GameObjectContainerMixin, IConversionSupport, IPropertyContainer | ||
{ | ||
|
||
public int ProfileVersion { get; set; } | ||
|
||
public List<IProperty> Properties => profile.Properties; | ||
|
||
private GameObject profile; | ||
private long propertiesBlockOffset; | ||
|
||
public GameObject Profile | ||
{ | ||
get => profile; | ||
set | ||
{ | ||
if (profile != null) | ||
{ | ||
int oldIndex = Objects.IndexOf(profile); | ||
if (oldIndex > -1) | ||
{ | ||
Objects.RemoveAt(oldIndex); | ||
} | ||
} | ||
|
||
profile = value; | ||
if (value != null && Objects.IndexOf(value) == -1) | ||
{ | ||
Objects.Insert(0, value); | ||
} | ||
} | ||
} | ||
|
||
public void ReadBinary(ArkArchive archive, ReadingOptions options) | ||
{ | ||
|
||
propertiesBlockOffset = archive.Position; | ||
var useNameTable = archive.UseNameTable; | ||
archive.UseNameTable = false; | ||
try | ||
{ | ||
ProfileVersion = archive.ReadInt(); | ||
|
||
if (ProfileVersion != 1) | ||
{ | ||
//throw new NotSupportedException("Unknown Profile Version " + ProfileVersion); | ||
} | ||
|
||
int profilesCount = archive.ReadInt(); | ||
|
||
Objects.Clear(); | ||
ObjectMap.Clear(); | ||
for (int i = 0; i < profilesCount; i++) | ||
{ | ||
addObject(new GameObject(archive), options.BuildComponentTree); | ||
} | ||
|
||
for (int i = 0; i < profilesCount; i++) | ||
{ | ||
GameObject gameObject = Objects[i]; | ||
if (gameObject.ClassString == "PrimalPlayerData" || gameObject.ClassString == "PrimalPlayerDataBP_C") | ||
{ | ||
profile = gameObject; | ||
} | ||
|
||
gameObject.LoadProperties(archive, new GameObject(), propertiesBlockOffset); | ||
} | ||
} | ||
catch | ||
{ | ||
|
||
} | ||
archive.UseNameTable = useNameTable; | ||
//var tekGrams = Objects.Where(o => o.ClassString.ToLower().Contains("canteen")).ToList(); | ||
|
||
} | ||
|
||
|
||
public int CalculateSize() | ||
{ | ||
int size = sizeof(int) * 2; | ||
|
||
NameSizeCalculator nameSizer = ArkArchive.GetNameSizer(false); | ||
|
||
size += Objects.Sum(o => o.Size(nameSizer)); | ||
|
||
propertiesBlockOffset = size; | ||
|
||
size += Objects.Sum(o => o.PropertiesSize(nameSizer)); | ||
return size; | ||
} | ||
|
||
public void WriteBinary(ArkArchive archive, WritingOptions options) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void ReadJson(JToken node, ReadingOptions options) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void WriteJson(JsonTextWriter generator, WritingOptions options) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using SavegameToolkit.Propertys; | ||
|
||
namespace SavegameToolkit | ||
{ | ||
|
||
public class ArkStoreTribe : GameObjectContainerMixin, IConversionSupport, IPropertyContainer | ||
{ | ||
|
||
public int TribeVersion { get; set; } | ||
|
||
public GameObject Tribe { get; set; } | ||
|
||
public List<IProperty> Properties => Tribe.Properties; | ||
|
||
private long propertiesBlockOffset; | ||
|
||
public void ReadBinary(ArkArchive archive, ReadingOptions options) | ||
{ | ||
|
||
propertiesBlockOffset = archive.Position; | ||
var useNameTable = archive.UseNameTable; | ||
archive.UseNameTable = false; | ||
|
||
TribeVersion = archive.ReadInt(); | ||
|
||
if (TribeVersion != 1) | ||
{ | ||
throw new NotSupportedException("Unknown Tribe Version " + TribeVersion); | ||
} | ||
|
||
int tribesCount = archive.ReadInt(); | ||
|
||
Objects.Clear(); | ||
ObjectMap.Clear(); | ||
for (int i = 0; i < tribesCount; i++) | ||
{ | ||
var newObject = new GameObject(archive); | ||
|
||
addObject(newObject, false); | ||
} | ||
|
||
for (int i = 0; i < tribesCount; i++) | ||
{ | ||
GameObject gameObject = Objects[i]; | ||
if (gameObject.ClassString == "PrimalTribeData") | ||
{ | ||
Tribe = gameObject; | ||
} | ||
|
||
gameObject.LoadProperties(archive, new GameObject(), propertiesBlockOffset); | ||
} | ||
|
||
archive.UseNameTable = useNameTable; | ||
} | ||
|
||
public void WriteBinary(ArkArchive archive, WritingOptions options) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public int CalculateSize() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void ReadJson(JToken node, ReadingOptions options) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void WriteJson(JsonTextWriter generator, WritingOptions options) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.