Skip to content

Commit

Permalink
Fix object state codec for latest game version
Browse files Browse the repository at this point in the history
  • Loading branch information
ammaraskar committed Oct 20, 2024
1 parent cabc1f1 commit 265662f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Assets/Scripts/OpenTS2/Files/Formats/DBPF/SimsObjectCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ private static SimsObjectAsset DeserializeWithVersion(IoBuffer reader, int versi
var elevation = reader.ReadFloat();
var objectGroupId = reader.ReadInt32();
reader.ReadInt16(); // unknown
if (version > 0xD6)
{
reader.ReadFloat(); // unknown
}

var numAttrs = reader.ReadInt16();
var attrs = new short[numAttrs];
Expand All @@ -78,6 +82,7 @@ private static SimsObjectAsset DeserializeWithVersion(IoBuffer reader, int versi
uint numShorts = version switch
{
0xAD => 0x58,
0xD8 => 0x72,
_ => throw new NotImplementedException($"SimObjectCodec not implemented for version {version:X}"),
};

Expand All @@ -101,7 +106,14 @@ private static SimsObjectAsset DeserializeWithVersion(IoBuffer reader, int versi
// Inventory token.
var tokenGUID = reader.ReadUInt32();
var tokenFlags = reader.ReadUInt16();
if (version > 0xCA)
{
var stackId = reader.ReadInt16();
var personalInventoryInstanceId = reader.ReadInt32();
var tokenCategory = reader.ReadUInt16();
}
var numTokenProperties = reader.ReadUInt32();

for (var i = 0; i < numTokenProperties; i++)
{
reader.ReadUInt16();
Expand Down

0 comments on commit 265662f

Please sign in to comment.