Skip to content

Commit

Permalink
first batch of Playstation tests alongside other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cengelha committed Aug 22, 2023
1 parent 4be7d13 commit be199fc
Show file tree
Hide file tree
Showing 32 changed files with 1,988 additions and 278 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ All notable changes to this project will be documented in this file. It uses the
* A setting to choose between writing always or only if a container is unsynced
### Changed
* Renamed the settings _LastWriteTime_ and _Mapping_
* Names of the IsVersion flags now include the version number as well
* DifficultyPresetTypeEnum has been added and therefore PresetGameModeEnum is now
only used internal
### Deprecated
### Removed
### Fixed
* The _Mapping_ settings is now only used to determine input/output and not for modifying things internally
* A number of different issues reported on [Discord](https://discord.gg/nomnom-762409407488720918) and the [NomNom repository](https://github.com/zencq/NomNom/issues)
* A number of different issues reported on [Discord](https://discord.gg/nomnom-762409407488720918) and the [NomNom repository](https://github.com/zencq/NomNom/milestone/10)
### Security

## 0.5.3 (2023-06-24)
Expand Down
4 changes: 3 additions & 1 deletion GAMEUPDATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

### Enums
* Check whether game enums have been updated:
* `DifficultyPresetTypeEnum`
* `ParticipantTypeEnum`
* `PersistentBaseTypesEnum`
* `PresetGameModeEnum`
* Extend `VersionEnum` and if there is a new Expedition, update the `SeasonEnum`
as well.
* In rare occasions there might be a new game mode as well (`PresetGameModeEnum`).
* If necessary add a `Description` attribute to it.

### Container
Expand All @@ -19,6 +20,7 @@

### Global
* For new game modes the `GetGameModeEnum` needs to be updated.
* For new difficulty preset the `DifficultyPresetTypeEnum` needs to be updated.
* Will probably never be the case but if the formula for the version numbers changes,
the `CalculateBaseVersion` and `CalculateVersion` need an updated as well.

Expand Down
97 changes: 61 additions & 36 deletions libNOM.io/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public partial class Container : IComparable<Container>, IEquatable<Container>
public DateTimeOffset? LastWriteTime // { get; set; }
{
get => Extra.LastWriteTime ?? (Exists ? DataFile?.LastWriteTime : null);
set => Extra.LastWriteTime = value;
set => Extra = Extra with { LastWriteTime = value };
}

public FileInfo? MetaFile { get; internal set; }
Expand Down Expand Up @@ -136,7 +136,13 @@ public partial class Container : IComparable<Container>, IEquatable<Container>
public int BaseVersion
{
get => Extra.BaseVersion;
internal set => Extra.BaseVersion = value;
internal set => Extra = Extra with { BaseVersion = value };
}

public DifficultyPresetTypeEnum GameDifficultyPresetEnum // { get; internal set; }
{
get => (DifficultyPresetTypeEnum)(Extra.DifficultyPreset);
internal set => Extra = Extra with { DifficultyPreset = (byte)(value) };
}

public PresetGameModeEnum GameModeEnum // { get; internal set; }
Expand All @@ -148,67 +154,86 @@ internal set
{
SaveVersion = Calculate.CalculateVersion(BaseVersion, value, SeasonEnum);
}
Extra.GameMode = (short)(value);
Extra = Extra with { GameMode = (short)(value) };
}
}

public GameVersionEnum GameVersionEnum { get; internal set; } = GameVersionEnum.Unknown;

public bool IsBeyondWithVehicleCam => IsVersion(GameVersionEnum.BeyondWithVehicleCam); // { get; }
public bool Is211BeyondWithVehicleCam => IsVersion(GameVersionEnum.BeyondWithVehicleCam); // { get; }

public bool Is220Synthesis => IsVersion(GameVersionEnum.Synthesis); // { get; }

public bool Is226SynthesisWithJetpack => IsVersion(GameVersionEnum.SynthesisWithJetpack); // { get; }

public bool Is230LivingShip => IsVersion(GameVersionEnum.LivingShip); // { get; }

public bool IsSynthesis => IsVersion(GameVersionEnum.Synthesis); // { get; }
public bool Is240ExoMech => IsVersion(GameVersionEnum.ExoMech); // { get; }

public bool IsSynthesisWithJetpack => IsVersion(GameVersionEnum.SynthesisWithJetpack); // { get; }
public bool Is250Crossplay => IsVersion(GameVersionEnum.Crossplay); // { get; }

public bool IsLivingShip => IsVersion(GameVersionEnum.LivingShip); // { get; }
public bool Is260Desolation => IsVersion(GameVersionEnum.Desolation); // { get; }

public bool IsExoMech => IsVersion(GameVersionEnum.ExoMech); // { get; }
public bool Is300Origins => IsVersion(GameVersionEnum.Origins); // { get; }

public bool IsCrossplay => IsVersion(GameVersionEnum.Crossplay); // { get; }
public bool Is310NextGeneration => IsVersion(GameVersionEnum.NextGeneration); // { get; }

public bool IsDesolation => IsVersion(GameVersionEnum.Desolation); // { get; }
public bool Is320Companions => IsVersion(GameVersionEnum.Companions); // { get; }

public bool IsOrigins => IsVersion(GameVersionEnum.Origins); // { get; }
public bool Is330Expeditions => IsVersion(GameVersionEnum.Expeditions); // { get; }

public bool IsNextGeneration => IsVersion(GameVersionEnum.NextGeneration); // { get; }
public bool Is340Beachhead => IsVersion(GameVersionEnum.Beachhead); // { get; }

public bool IsCompanions => IsVersion(GameVersionEnum.Companions); // { get; }
public bool Is350Prisms => IsVersion(GameVersionEnum.Prisms); // { get; }

public bool IsExpeditions => IsVersion(GameVersionEnum.Expeditions); // { get; }
public bool Is351PrismsWithBytebeatAuthor => IsVersion(GameVersionEnum.PrismsWithBytebeatAuthor); // { get; }

public bool IsBeachhead => IsVersion(GameVersionEnum.Beachhead); // { get; }
public bool Is360Frontiers => IsVersion(GameVersionEnum.Frontiers); // { get; }

public bool IsPrisms => IsVersion(GameVersionEnum.Prisms); // { get; }
public bool Is370Emergence => IsVersion(GameVersionEnum.Emergence); // { get; }

public bool IsPrismsWithBytebeatAuthor => IsVersion(GameVersionEnum.PrismsWithBytebeatAuthor); // { get; }
public bool Is380Sentinel => IsVersion(GameVersionEnum.Sentinel); // { get; }

public bool IsFrontiers => IsVersion(GameVersionEnum.Frontiers); // { get; }
public bool Is381SentinelWithWeaponResource => IsVersion(GameVersionEnum.SentinelWithWeaponResource); // { get; }

public bool IsEmergence => IsVersion(GameVersionEnum.Emergence); // { get; }
public bool Is384SentinelWithVehicleAI => IsVersion(GameVersionEnum.SentinelWithVehicleAI); // { get; }

public bool IsSentinel => IsVersion(GameVersionEnum.Sentinel); // { get; }
public bool Is385Outlaws => IsVersion(GameVersionEnum.Outlaws); // { get; }

public bool IsSentinelWithWeaponResource => IsVersion(GameVersionEnum.SentinelWithWeaponResource); // { get; }
public bool Is390Leviathan => IsVersion(GameVersionEnum.Leviathan); // { get; }

public bool IsSentinelWithVehicleAI => IsVersion(GameVersionEnum.SentinelWithVehicleAI); // { get; }
public bool Is394Endurance => IsVersion(GameVersionEnum.Endurance); // { get; }

public bool IsOutlaws => IsVersion(GameVersionEnum.Outlaws); // { get; }
public bool Is400Waypoint => IsVersion(GameVersionEnum.Waypoint); // { get; }

public bool IsLeviathan => IsVersion(GameVersionEnum.Leviathan); // { get; }
public bool Is404WaypointWithAgileStat => IsVersion(GameVersionEnum.WaypointWithAgileStat); // { get; }

public bool IsEndurance => IsVersion(GameVersionEnum.Endurance); // { get; }
public bool Is405WaypointWithSuperchargedSlots => IsVersion(GameVersionEnum.WaypointWithSuperchargedSlots); // { get; }

public bool IsWaypoint => IsVersion(GameVersionEnum.Waypoint); // { get; }
public bool Is410Fractal => IsVersion(GameVersionEnum.Fractal); // { get; }

public bool IsWaypointWithAgileStat => IsVersion(GameVersionEnum.WaypointWithAgileStat); // { get; }
public bool Is420Interceptor => IsVersion(GameVersionEnum.Interceptor); // { get; }

public bool IsWaypointWithSuperchargedSlots => IsVersion(GameVersionEnum.WaypointWithSuperchargedSlots); // { get; }
public bool Is430Singularity => IsVersion(GameVersionEnum.Singularity); // { get; }

public bool IsFractal => IsVersion(GameVersionEnum.Fractal); // { get; }
public bool Is440Echoes => IsVersion(GameVersionEnum.Echoes); // { get; }

public bool IsInterceptor => IsVersion(GameVersionEnum.Interceptor); // { get; }
internal SaveFormatEnum SaveFormatEnum
{
get
{
if (Is400Waypoint)
return SaveFormatEnum.Waypoint;

if (Is360Frontiers)
return SaveFormatEnum.Frontiers;

public bool IsSingularity => IsVersion(GameVersionEnum.Singularity); // { get; }
if (BaseVersion > Constants.THRESHOLD_VANILLA)
return SaveFormatEnum.Foundation;

return SaveFormatEnum.Vanilla;
}
}

public string SaveName // { get; set; }
{
Expand All @@ -218,7 +243,7 @@ internal set
if (_jsonObject is not null)
SetJsonValue(value, "6f=.Pk4", "PlayerStateData.SaveName");

Extra.SaveName = value;
Extra = Extra with { SaveName = value };
}
}

Expand All @@ -230,7 +255,7 @@ internal set
if (_jsonObject is not null)
SetJsonValue(value, "6f=.n:R", "PlayerStateData.SaveSummary");

Extra.SaveSummary = value;
Extra = Extra with { SaveSummary = value };
}
}

Expand All @@ -245,7 +270,7 @@ internal set
{
SaveVersion = Calculate.CalculateVersion(BaseVersion, GameModeEnum, value);
}
Extra.Season = (short)(value);
Extra = Extra with { Season = (short)(value) };
}
}

Expand All @@ -257,7 +282,7 @@ internal set
if (_jsonObject is not null)
SetJsonValue(value, "6f=.Lg8", "PlayerStateData.TotalPlayTime");

Extra.TotalPlayTime = value;
Extra = Extra with { TotalPlayTime = value };
}
}

Expand Down Expand Up @@ -539,7 +564,7 @@ public override int GetHashCode()

public override string ToString()
{
return $"{nameof(Container)} {MetaIndex} {Identifier}";
return $"{nameof(Container)} {MetaIndex:00} {Identifier}{(Exists ? " (exists)" : string.Empty)}";
}

#endregion
Expand Down
16 changes: 16 additions & 0 deletions libNOM.io/Enums/DifficultyPresetTypeEnum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace libNOM.io.Enums;

/// <summary>
/// Specifies available game modes.
/// </summary>
/// <seealso cref="libMBIN\Source\NMS\GameComponents\GcDifficultyPresetType.cs"/>
public enum DifficultyPresetTypeEnum : byte
{
Invalid,
Custom,
Normal,
Creative,
Relaxed,
Survival,
Permadeath,
}
3 changes: 2 additions & 1 deletion libNOM.io/Enums/GameVersionEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace libNOM.io.Enums;
/// <summary>
/// Specifies all versions of big game updates and smaller ones if necessary for specific features.
/// </summary>
public enum GameVersionEnum
public enum GameVersionEnum : uint
{
Unknown = 0,
Vanilla = 100,
Expand Down Expand Up @@ -53,4 +53,5 @@ public enum GameVersionEnum
Interceptor = 420,
Mac = 425,
Singularity = 430,
Echoes = 440,
}
2 changes: 1 addition & 1 deletion libNOM.io/Enums/LoadingStrategyEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// <summary>
/// Specifies strategies how to load and keep containers in a <see cref="Platform"/>.
/// </summary>
public enum LoadingStrategyEnum
public enum LoadingStrategyEnum : uint
{
/// <summary>
/// No save information and data loaded.
Expand Down
2 changes: 1 addition & 1 deletion libNOM.io/Enums/MicrosoftBlobSyncStateEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// <summary>
/// Specifies states used in the containers.index of the <see cref="PlatformMicrosoft"/>.
/// </summary>
internal enum MicrosoftBlobSyncStateEnum
internal enum MicrosoftBlobSyncStateEnum : uint
{
Unknown_Zero = 0,
Synced = 1,
Expand Down
2 changes: 1 addition & 1 deletion libNOM.io/Enums/MicrosoftIndexSyncStateEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// <summary>
/// Specifies states used in the containers.index of the <see cref="PlatformMicrosoft"/>.
/// </summary>
internal enum MicrosoftIndexSyncStateEnum
internal enum MicrosoftIndexSyncStateEnum : uint
{
Unknown_Zero = 0,
Unknown_One = 1,
Expand Down
2 changes: 1 addition & 1 deletion libNOM.io/Enums/ParticipantTypeEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
///
/// </summary>
/// <seealso cref="libMBIN\Source\NMS\GameComponents\GcPlayerMissionParticipantType.cs"/>
public enum ParticipantTypeEnum
public enum ParticipantTypeEnum : uint
{
None,
MissionGiver,
Expand Down
2 changes: 1 addition & 1 deletion libNOM.io/Enums/PersistentBaseTypesEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Specifies types a persistent base can have.
/// </summary>
/// <seealso cref="libMBIN\Source\NMS\GameComponents\GcPersistentBaseTypes.cs"/>
internal enum PersistentBaseTypesEnum
internal enum PersistentBaseTypesEnum : uint
{
HomePlanetBase,
FreighterBase,
Expand Down
2 changes: 1 addition & 1 deletion libNOM.io/Enums/PlatformEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace libNOM.io.Enums;
/// Specifies platforms the game is available on.
/// PlayStation is last as it has the least specific identification characteristics (only Steam like save file in worst case).
/// </summary>
public enum PlatformEnum
public enum PlatformEnum : uint
{
Unknown,
[Description("Apple App Store")]
Expand Down
2 changes: 1 addition & 1 deletion libNOM.io/Enums/PresetGameModeEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// Specifies available game modes.
/// </summary>
/// <seealso cref="libMBIN\Source\NMS\GameComponents\GcGameMode.cs"/>
public enum PresetGameModeEnum
public enum PresetGameModeEnum : uint
{
Unspecified,
Normal,
Expand Down
13 changes: 13 additions & 0 deletions libNOM.io/Enums/SaveFormatEnum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace libNOM.io.Enums;


/// <summary>
/// ...
/// </summary>
internal enum SaveFormatEnum : uint
{
Vanilla,
Foundation,
Frontiers,
Waypoint,
}
2 changes: 1 addition & 1 deletion libNOM.io/Enums/SaveTypeEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// <summary>
/// Specifies types per slot a save can have.
/// </summary>
public enum SaveTypeEnum
public enum SaveTypeEnum : uint
{
Auto,
Manual,
Expand Down
2 changes: 1 addition & 1 deletion libNOM.io/Enums/SeasonEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// <summary>
/// Specifies all known Expeditions incl. a placeholder for the next one.
/// </summary>
public enum SeasonEnum
public enum SeasonEnum : uint
{
None = 0,
Pioneers = None, // 1st
Expand Down
5 changes: 5 additions & 0 deletions libNOM.io/Globals/Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,9 @@ internal static GameVersionEnum GetGameVersionEnum(Container container, JObject
GameVersion = CreativeVersion/BaseVersion (Obfuscated = Deobfuscated)
??? = ????/???? (??? = ?)
Echoes
440 = ????/???? (??? = ?)
Singularity
438 = 4657/4145
437 = 4657/4145
Expand Down Expand Up @@ -846,6 +849,8 @@ internal static GameVersionEnum GetGameVersionEnum(Container container, JObject

var usesMapping = jsonObject.UsesMapping();

//return GameVersionEnum.Echoes;

if (container.BaseVersion >= 4144) // 4.20, 4.25, 4.30
{
// Only used in actual Expedition saves.
Expand Down
1 change: 1 addition & 0 deletions libNOM.io/Globals/LZ4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ internal static int Decode(this byte[] self, out byte[] target, int targetLength
if (targetLength > 0)
{
target = new byte[targetLength];
// TODO ReadOnlySpan
bytesWritten = LZ4Codec.Decode(self, 0, self.Length, target, 0, target.Length);
}

Expand Down
Loading

0 comments on commit be199fc

Please sign in to comment.