Skip to content

Commit

Permalink
[BUGFIX]: Fixed bad reads on property arrays
Browse files Browse the repository at this point in the history
[MISC]: Implemented ExtraData
[MISC]: Release 0.0.13
  • Loading branch information
R3dByt3 committed Apr 20, 2024
1 parent de6cb29 commit 1b54e61
Show file tree
Hide file tree
Showing 54 changed files with 760 additions and 99 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
with:
PROJECT_FILE_PATH: ./SatisfactorySaveNet.Abstracts/SatisfactorySaveNet.Abstracts.csproj
PACKAGE_NAME: SatisfactorySaveNet
VERSION_STATIC: 0.0.12
VERSION_STATIC: 0.0.13
TAG_COMMIT: false
NUGET_KEY: ${{secrets.NUGET_API_KEY}}
NUGET_SOURCE: https://api.nuget.org
Expand All @@ -45,7 +45,7 @@ jobs:
with:
PROJECT_FILE_PATH: ./SatisfactorySaveNet/SatisfactorySaveNet.csproj
PACKAGE_NAME: SatisfactorySaveNet
VERSION_STATIC: 0.0.12
VERSION_STATIC: 0.0.13
TAG_COMMIT: false
NUGET_KEY: ${{secrets.NUGET_API_KEY}}
NUGET_SOURCE: https://api.nuget.org
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>

<VersionPrefix>0.0.12</VersionPrefix>
<VersionPrefix>0.0.13</VersionPrefix>
<Version Condition=" '$(VersionSuffix)' != '' ">$(VersionPrefix)-$(VersionSuffix)</Version>
<Version Condition=" '$(VersionSuffix)' == '' ">$(VersionPrefix)</Version>

Expand Down
24 changes: 24 additions & 0 deletions SatisfactorySaveNet.Abstracts/Exceptions/BadReadException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Runtime.Serialization;
using System;

namespace SatisfactorySaveNet.Abstracts.Exceptions;

[Serializable]
public class BadReadException : SatisFactoryException
{
public BadReadException()
{
}

public BadReadException(string? message) : base(message)
{
}

public BadReadException(string? message, Exception? innerException) : base(message, innerException)
{
}

protected BadReadException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
11 changes: 11 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/BlueprintData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace SatisfactorySaveNet.Abstracts.Model.Extra;

public class BlueprintData : ExtraData
{
public override ExtraDataConstraint Type => ExtraDataConstraint.BlueprintData;

public int Count { get; set; }
public required ICollection<ObjectReference> Objects { get; set; }
}
7 changes: 7 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/CargoObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SatisfactorySaveNet.Abstracts.Extra;

public class CargoObject
{
public string Name { get; set; } = string.Empty;
public string Unknown { get; set; } = string.Empty;
}
9 changes: 9 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/Circuit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using SatisfactorySaveNet.Abstracts.Model;

namespace SatisfactorySaveNet.Abstracts.Extra;

public class Circuit
{
public int CircuitId { get; set; }
public required ObjectReference ObjectReference { get; set; }
}
12 changes: 12 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/CircuitData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using SatisfactorySaveNet.Abstracts.Model.Extra;
using System.Collections.Generic;

namespace SatisfactorySaveNet.Abstracts.Extra;

public class CircuitData : ExtraData
{
public override ExtraDataConstraint Type => ExtraDataConstraint.CircuitData;

public int Count { get; set; }
public required ICollection<Circuit> Circuits { get; set; }
}
11 changes: 11 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/ConveyorData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace SatisfactorySaveNet.Abstracts.Model.Extra;

public class ConveyorData : ExtraData
{
public override ExtraDataConstraint Type => ExtraDataConstraint.Conveyor;

public int Count { get; set; }
public required ICollection<Item> Items { get; set; }
}
10 changes: 10 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/DroneStationAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using SatisfactorySaveNet.Abstracts.Model.Properties;
using System.Collections.Generic;

namespace SatisfactorySaveNet.Abstracts.Extra;

public class DroneStationAction
{
public string Name { get; set; } = string.Empty;
public required ICollection<Property> Properties { get; set; }
}
21 changes: 21 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/DroneStationData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using SatisfactorySaveNet.Abstracts.Model.Extra;
using System.Collections.Generic;

namespace SatisfactorySaveNet.Abstracts.Extra;

public class DroneStationData : ExtraData
{
public override ExtraDataConstraint Type => ExtraDataConstraint.DroneStationData;

public int Unknown1 { get; set; }
public int Unknown2 { get; set; }
/// <summary>
/// Should only be null if Missing is filled, which indicates that there were unparseable data
/// </summary>
public ICollection<DroneStationAction>? ActiveActions { get; set; }
/// <summary>
/// Should only be null if Missing is filled, which indicates that there were unparseable data
/// </summary>
public ICollection<DroneStationAction>? ActionQueue { get; set; }
public string? Missing { get; set; }
}
6 changes: 6 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/ExtraData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace SatisfactorySaveNet.Abstracts.Model.Extra;

public abstract class ExtraData
{
public abstract ExtraDataConstraint Type { get; }
}
14 changes: 14 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/ExtraDataConstraint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace SatisfactorySaveNet.Abstracts.Model.Extra;

public enum ExtraDataConstraint
{
Conveyor,
BlueprintData,
PlayerData,
PowerLineData,
VehicleData,
LocomotiveData,
DroneStationData,
CircuitData,
UnknownExtraData
}
15 changes: 15 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/LocomotiveData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using SatisfactorySaveNet.Abstracts.Model;
using SatisfactorySaveNet.Abstracts.Model.Extra;
using System.Collections.Generic;

namespace SatisfactorySaveNet.Abstracts.Extra;

public class LocomotiveData : ExtraData
{
public override ExtraDataConstraint Type => ExtraDataConstraint.LocomotiveData;

public int Count { get; set; }
public required ICollection<CargoObject> CargoObjects { get; set; }
public required ObjectReference Previous { get; set; }
public required ObjectReference Next { get; set; }
}
12 changes: 12 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/PlayerData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace SatisfactorySaveNet.Abstracts.Model.Extra;

public class PlayerData : ExtraData
{
public override ExtraDataConstraint Type => ExtraDataConstraint.PlayerData;

public string? Missing { get; set; }
public byte PlayerType { get; set; }
public string? EpicOnlineServicesId { get; set; }
public string? SteamId { get; set; }
public string? PlatformId { get; set; }
}
16 changes: 16 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/PowerLineData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using SatisfactorySaveNet.Abstracts.Maths.Vector;
using SatisfactorySaveNet.Abstracts.Model;
using SatisfactorySaveNet.Abstracts.Model.Extra;

namespace SatisfactorySaveNet.Abstracts.Extra;

public class PowerLineData : ExtraData
{
public override ExtraDataConstraint Type => ExtraDataConstraint.PowerLineData;

public int Count { get; set; }
public required ObjectReference Source { get; set; }
public required ObjectReference Target { get; set; }
public Vector3? SourceTranslation { get; set; }
public Vector3? TargetTranslation { get; set;}
}
10 changes: 10 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/UnknownExtraData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using SatisfactorySaveNet.Abstracts.Model.Extra;

namespace SatisfactorySaveNet.Abstracts.Extra;

public class UnknownExtraData : ExtraData
{
public override ExtraDataConstraint Type => ExtraDataConstraint.UnknownExtraData;

public string Missing { get; set; } = string.Empty;
}
12 changes: 12 additions & 0 deletions SatisfactorySaveNet.Abstracts/Extra/VehicleData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using SatisfactorySaveNet.Abstracts.Model.Extra;
using System.Collections.Generic;

namespace SatisfactorySaveNet.Abstracts.Extra;

public class VehicleData : ExtraData
{
public override ExtraDataConstraint Type => ExtraDataConstraint.VehicleData;

public int Count { get; set; }
public required ICollection<CargoObject> CargoObjects { get; set; }
}
10 changes: 10 additions & 0 deletions SatisfactorySaveNet.Abstracts/IExtraDataSerializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using SatisfactorySaveNet.Abstracts.Model;
using SatisfactorySaveNet.Abstracts.Model.Extra;
using System.IO;

namespace SatisfactorySaveNet.Abstracts;

public interface IExtraDataSerializer
{
public ExtraData? Deserialize(BinaryReader reader, string typePath, Header header, long expectedPosition);
}
2 changes: 1 addition & 1 deletion SatisfactorySaveNet.Abstracts/IPropertySerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace SatisfactorySaveNet.Abstracts;

public interface IPropertySerializer
{
public IEnumerable<Property> DeserializeProperties(BinaryReader reader, Header? header = null, string? type = null);
public IEnumerable<Property> DeserializeProperties(BinaryReader reader, Header? header = null, string? type = null, long? expectedPosition = null);
public Property? DeserializeProperty(BinaryReader reader, Header? header = null, string? type = null);
}
2 changes: 1 addition & 1 deletion SatisfactorySaveNet.Abstracts/ITypedDataSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ namespace SatisfactorySaveNet.Abstracts;

public interface ITypedDataSerializer
{
public TypedData Deserialize(BinaryReader reader, Header header, string type);
public TypedData Deserialize(BinaryReader reader, Header header, string type, bool isArrayProperty);
}
2 changes: 1 addition & 1 deletion SatisfactorySaveNet.Abstracts/Model/ActorObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public class ActorObject : ComponentObject

public string ParentObjectRoot { get; set; } = string.Empty;
public string ParentObjectName { get; set; } = string.Empty;
public IList<ObjectReference> Components { get; set; } = [];
public ICollection<ObjectReference> Components { get; set; } = [];
}
4 changes: 2 additions & 2 deletions SatisfactorySaveNet.Abstracts/Model/Body.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Body
/// <summary>
/// Levels and the persistent level. There is one more level than the level count above, the last entry being the persistent level (See SCIM). For the format of one level
/// </summary>
public IList<Level> Levels { get; set; } = [];
public ICollection<Level> Levels { get; set; } = [];

/// <summary>
/// Unknown grid related data
Expand All @@ -19,5 +19,5 @@ public class Body
/// A list of object references, can also be ignored. for the format of one such ObjectReference
/// </summary>
[Obsolete("These information seem to be obsolete")]
public IList<ObjectReference>? ObjectReferences { get; set; }
public ICollection<ObjectReference>? ObjectReferences { get; set; }
}
4 changes: 3 additions & 1 deletion SatisfactorySaveNet.Abstracts/Model/ComponentObject.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using SatisfactorySaveNet.Abstracts.Model.Extra;
using SatisfactorySaveNet.Abstracts.Model.Properties;
using System.Collections.Generic;

Expand All @@ -14,6 +15,7 @@ public class ComponentObject

public string ParentActorName { get; set; } = string.Empty;

public IList<Property> Properties { get; set; } = [];
public ICollection<Property> Properties { get; set; } = [];
public ExtraData? ExtraData { get; set; }
public int? EntitySaveVersion { get; set; }
}
2 changes: 1 addition & 1 deletion SatisfactorySaveNet.Abstracts/Model/Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public class Grid
public int Unknown3 { get; set; }
public string Unknown4 { get; set; } = string.Empty;
public int Unknown5 { get; set; }
public IList<GridData> Data { get; set; } = [];
public ICollection<GridData> Data { get; set; } = [];
}
2 changes: 1 addition & 1 deletion SatisfactorySaveNet.Abstracts/Model/GridData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ public class GridData
public string Unknown1 { get; set; } = string.Empty;
public int Unknown2 { get; set; }
public int Unknown3 { get; set; }
public IList<GridLevel> Levels { get; set; } = [];
public ICollection<GridLevel> Levels { get; set; } = [];
}
14 changes: 14 additions & 0 deletions SatisfactorySaveNet.Abstracts/Model/Item.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using SatisfactorySaveNet.Abstracts.Maths.Vector;

namespace SatisfactorySaveNet.Abstracts.Model;

public class Item
{
public string Name { get; set; } = string.Empty;
public required ObjectReference ObjectReference { get; set; }
/// <summary>
/// Supposed to be a float, but Vec4 seems to be logical?
/// </summary>
public Vector4I Position { get; set; }
public int Length { get; set; }
}
8 changes: 4 additions & 4 deletions SatisfactorySaveNet.Abstracts/Model/Level.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System;
using System;
using System.Collections.Generic;

namespace SatisfactorySaveNet.Abstracts.Model;

public class Level
{
public string Name { get; set; } = string.Empty;
public IList<ObjectReference> Collectables { get; set; } = [];
public IList<ComponentObject> Objects { get; set; } = [];
public ICollection<ObjectReference> Collectables { get; set; } = [];
public ICollection<ComponentObject> Objects { get; set; } = [];
[Obsolete("These information seem to be obsolete")]
public IList<ObjectReference>? SecondCollectables { get; set; } = [];
public ICollection<ObjectReference>? SecondCollectables { get; set; } = [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ public class ArrayBoolProperty : IArrayProperty
/// <summary>
/// Values[x] != 0 <=> True
/// </summary>
public IList<sbyte> Values { get; set; } = [];
public ICollection<sbyte> Values { get; set; } = [];
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace SatisfactorySaveNet.Abstracts.Model.Properties;

public class ArrayByteProperty : IArrayProperty
{
public IList<sbyte> Values { get; set; } = [];
public ICollection<sbyte> Values { get; set; } = [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ namespace SatisfactorySaveNet.Abstracts.Model.Properties;

public class ArrayDoubleProperty : IArrayProperty
{
public IList<double> Values { get; set; } = [];
public ICollection<double> Values { get; set; } = [];
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace SatisfactorySaveNet.Abstracts.Model.Properties;

public class ArrayEnumProperty : IArrayProperty
{
public IList<string> Values { get; set; } = [];
public ICollection<string> Values { get; set; } = [];
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace SatisfactorySaveNet.Abstracts.Model.Properties;

public class ArrayFloatProperty : IArrayProperty
{
public IList<float> Values { get; set; } = [];
public ICollection<float> Values { get; set; } = [];
}
Loading

0 comments on commit 1b54e61

Please sign in to comment.