From 850c0c9129ab9f126bf9cada2173df2e30a63c3d Mon Sep 17 00:00:00 2001 From: Christian Engelhardt Date: Fri, 26 Jul 2024 21:51:28 +0200 Subject: [PATCH] fix: possible wrong metadata size when transfering --- CHANGELOG.md | 5 ++++- libNOM.io/Platform_Write.cs | 14 ++++++-------- libNOM.io/libNOM.io.csproj | 2 +- libNOM.test/Steam.cs | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0968cc8..719d383 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,14 +4,17 @@ All notable changes to this project will be documented in this file. It uses the [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) principles and [Semantic Versioning](https://semver.org/) since 1.0.0. -## Unreleased +## Unreleased (0.10.1) ### Known Issues ### Added +* Support for changed save format on Microsoft platform in Worlds 5.01.1 ### Changed +* Make `Common.DeepCopy()` public ### Deprecated ### Removed ### Fixed +* Wrong metadata size when transferring save to container with other size ### Security ## 0.10.0 (2024-07-22) diff --git a/libNOM.io/Platform_Write.cs b/libNOM.io/Platform_Write.cs index e9f05fa..17f419c 100644 --- a/libNOM.io/Platform_Write.cs +++ b/libNOM.io/Platform_Write.cs @@ -163,14 +163,12 @@ protected ReadOnlySpan PrepareMeta(Container container, ReadOnlySpan protected byte[] CreateMetaBuffer(Container container) { - var capacity = (int)(container.Extra.MetaLength); - if (capacity == 0) - capacity = container.GameVersion switch { - >= GameVersionEnum.Worlds => META_LENGTH_TOTAL_WORLDS, - >= GameVersionEnum.Waypoint => META_LENGTH_TOTAL_WAYPOINT, - _ => META_LENGTH_TOTAL_VANILLA, - }; - + var capacity = container.GameVersion switch + { + >= GameVersionEnum.Worlds => META_LENGTH_TOTAL_WORLDS, + >= GameVersionEnum.Waypoint => META_LENGTH_TOTAL_WAYPOINT, + _ => META_LENGTH_TOTAL_VANILLA, + }; return new byte[capacity]; } diff --git a/libNOM.io/libNOM.io.csproj b/libNOM.io/libNOM.io.csproj index 21fe110..df5c912 100644 --- a/libNOM.io/libNOM.io.csproj +++ b/libNOM.io/libNOM.io.csproj @@ -58,7 +58,7 @@ - 0.10.1-beta.3 + 0.10.1-beta.4 cengelha Provides reading and writing save files from the game No Man's Sky for all possible platforms as well as related actions. Copyright (c) Christian Engelhardt 2021 diff --git a/libNOM.test/Steam.cs b/libNOM.test/Steam.cs index e7a00b2..724fad9 100644 --- a/libNOM.test/Steam.cs +++ b/libNOM.test/Steam.cs @@ -237,7 +237,7 @@ public void T102_Read_76561198042453834_0x7D3_Worlds() { // Arrange var expectAccountData = true; - var path = GetCombinedPath("Steam", "st_76561198042453834_Worlds"); + var path = GetCombinedPath("Steam", "st_76561198042453834_0x7D3_Worlds"); var results = new ReadResults[] { new(0, "Slot1Auto", true, true, false, true, true, true, false, false, SaveContextQueryEnum.Main, nameof(PresetGameModeEnum.Normal), DifficultyPresetTypeEnum.Custom, SeasonEnum.None, 4153, 4665, GameVersionEnum.Worlds, "Iteration 1", "An Bord von Die „Batannam“-Sphäre", 1287227),