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.
[UNTESTED] Fix integer overflow when reading late object properties i…
…n big files. Better V11 CustomItemDatas redirection support. (#6) * Fix an int overflow when loading object properties beyond 2GB mark * Provide SaveVersion through ArkArchive to rest of the code * Read CustomItemDatas as native structs when version is higher than 11 Object and classes references are suspiciously missing from ArkCryoStore, which was crucial to figuring this out - thanks @miragedmuk.
- Loading branch information
Showing
5 changed files
with
92 additions
and
25 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
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
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,59 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using SavegameToolkit.Arrays; | ||
using SavegameToolkit.Types; | ||
|
||
namespace SavegameToolkit.Structs { | ||
|
||
[JsonObject(MemberSerialization.OptIn)] | ||
public class StructCustomItemDataRef : StructBase { | ||
|
||
[JsonProperty(Order = 0)] | ||
public short Unknown0 { get; private set; } | ||
[JsonProperty(Order = 1)] | ||
public long Position { get; private set; } | ||
[JsonProperty(Order = 2)] | ||
public ObjectReference[] ObjectRefs { get; private set; } | ||
[JsonProperty(Order = 3)] | ||
public ObjectReference[] ClassRefs { get; private set; } | ||
|
||
public override void Init(ArkArchive archive) | ||
{ | ||
// The first unknown field may be two fields - perhaps format version and archive index | ||
Unknown0 = archive.ReadShort(); | ||
Position = archive.ReadLong(); | ||
ObjectRefs = new ObjectReference[archive.ReadInt()]; | ||
for (int index = 0; index < ObjectRefs.Length; index++) | ||
{ | ||
ObjectRefs[index] = new ObjectReference(archive, 8); | ||
} | ||
ClassRefs = new ObjectReference[archive.ReadInt()]; | ||
for (int index = 0; index < ClassRefs.Length; index++) | ||
{ | ||
ClassRefs[index] = new ObjectReference(archive, 8); | ||
} | ||
} | ||
|
||
public override void Init(JObject node) | ||
{ | ||
throw new NotImplementedException("JSON import of StructCustomItemDataRef has not been implemented"); | ||
} | ||
|
||
public override void WriteJson(JsonTextWriter generator, WritingOptions writingOptions) | ||
{ | ||
throw new NotImplementedException("JSON export of StructCustomItemDataRef has not been implemented"); | ||
} | ||
|
||
public override void WriteBinary(ArkArchive archive) | ||
{ | ||
throw new NotImplementedException("Binary export of StructCustomItemDataRef has not been implemented"); | ||
} | ||
|
||
public override int Size(NameSizeCalculator nameSizer) | ||
{ | ||
return sizeof(short) + sizeof(long) + sizeof(int) * 2 + ObjectRefs.Length * 8 + ClassRefs.Length * 8; | ||
} | ||
} | ||
|
||
} |