Skip to content

Commit

Permalink
.NET 7 (#30)
Browse files Browse the repository at this point in the history
* reworked structure and platforms
* updated meta information
* incompatibility tags as constant and some fixes
* add first tests
* container refactoring
* improvements, refactoring and first Microsoft tests
* more Microsoft tests
* more tests for container and Microsoft
* add Steam tests
* add Gog tests
* new setting to control external sources in user identification process
* add Switch tests and some other stuff
* additional Container tests
* add meta data and account tests for Steam
* meta data and account tests for Microsoft
* unify PlatformExtra for Steam and Microsoft
* meta data and account tests for Switch
* first batch of Playstation tests alongside other changes
* cleanup and refactoring to use span for Steam and Microsoft
* cleanup and refactoring to use span for Switch
* cleanup and refactoring to use span for Playstation plus all tests
* extension cleanup, typos, and some renaming
* add transfer tests
* refactor collection and add tests
* refactor the converter class and add tests
* fixed some last issues
* update secret placeholder
* ci: add matrix tests and separate the build job
* make CRUD properties public and fix Switch meta creation
* add GetValues and some flags to the Container
* update testsuite archive
* fix case sensitive backup collection generation
* minor span extension refactoring
  • Loading branch information
cengelha authored Sep 11, 2023
1 parent 62f9768 commit 7a5046f
Show file tree
Hide file tree
Showing 76 changed files with 17,569 additions and 5,183 deletions.
4 changes: 0 additions & 4 deletions .github/changelogs/0.5.3.md

This file was deleted.

34 changes: 34 additions & 0 deletions .github/changelogs/0.6.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Major refactoring across the board with some breaking changes. Now also targeting
.NET 7 and publishing to the NuGet Gallery.

### Added
* Now targeting .NET 7 as per the [.NET release lifecycle](https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core)
* Now publishing to [NuGet Gallery](https://www.nuget.org/packages/libNOM.io)
* A setting to choose between writing always or only if a container is unsynced
* A privacy setting to decide whether external sources should be used to to improve
user identification (e.g. launcher configs or API calls)
* An IPlatform interface you can use instead of the abstract base class
* Lots of UnitTests
* Support for game version **Echoes 4.40**
* Voyagers Expedition
* Support for macOS when Steam is used
* Probably more...

### Changed
* Bump K4os.Compression.LZ4 from 1.3.5 to 1.3.6
* Bump libNOM.map from 0.9.1 to 0.9.2
* Renamed the settings _LastWriteTime_ and _Mapping_
* Default value for some settings
* Names of the IsVersion flags now include the version number as well
* DifficultyPresetTypeEnum has been added and therefore PresetGameModeEnum is now
only used internal
* More getter and setter for JSON tokens and values
* Probably more...

### Removed
* Maybe some things...

### 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/milestone/10)
67 changes: 42 additions & 25 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,73 @@ on:
create:

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
test:
name: Test
strategy:
matrix:
framwork: [net6.0, net7.0]
os: [windows-latest, macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-quality: ga
- name: Checkout
uses: actions/checkout@v3
- name: Replace
uses: jacobtomlinson/gha-find-replace@v2
- name: Cache
uses: actions/cache@v3
with:
find: "#{STEAM_API_KEY}#"
replace: ${{ secrets.STEAM_API_KEY }}
include: "libNOM.io/Properties/**"
regex: false
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Secret Injector
run: Get-ChildItem "./libNOM.test/Properties/" -File | ForEach-Object { (Get-Content $_.FullName) -Replace "{{ secrets.TESTSUITE_PASSWORD }}","${{ secrets.TESTSUITE_PASSWORD }}" | Set-Content $_.FullName }
shell: pwsh
- name: Unit Test
run: dotnet test libNOM.test --configuration Debug --framework ${{ matrix.framwork }}
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
dotnet-quality: ga
- name: Checkout
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Dependencies
run: dotnet restore
- name: Unit Test
run: dotnet test libNOM.test --no-restore --configuration Debug --framework net6.0
- name: Secret Injector
run: Get-ChildItem "./libNOM.io/Properties/" -File | ForEach-Object { (Get-Content $_.FullName) -Replace "{{ secrets.STEAM_API_KEY }}","${{ secrets.STEAM_API_KEY }}" | Set-Content $_.FullName }
shell: pwsh
- name: Pack
run: dotnet pack libNOM.io --no-restore --configuration Release
run: dotnet pack libNOM.io --configuration Release
- name: Upload
uses: actions/upload-artifact@v3
with:
name: libNOM.io NuGet
path: libNOM.io/bin/Release/libNOM.io.*nupkg
name: NuGet
path: |
./.github/changelogs/
./libNOM.io/bin/Release/libNOM.io.*nupkg
if-no-files-found: error
release:
name: Release
runs-on: ubuntu-latest
# Only if commit was tagged.
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs: build
needs: [test, build]
steps:
# Checkout again to access the changelog.
- name: Checkout
uses: actions/checkout@v3
- name: Download
uses: actions/download-artifact@v3
with:
name: libNOM.io NuGet
name: NuGet
- name: Version
run: echo "nupkg_version=$((((Get-Item -Path .\libNOM.io.*.nupkg).Name -split '\.',3)[2] -split '\.',-2)[0])" >> $env:GITHUB_ENV
shell: pwsh
Expand All @@ -70,7 +87,7 @@ jobs:
- name: Create
uses: softprops/action-gh-release@v1
with:
body_path: ${{ github.workspace }}/.github/changelogs/${{ github.ref_name }}.md
files: libNOM.io.*nupkg
body_path: ./.github/changelogs/${{ github.ref_name }}.md
files: ./libNOM.io.*nupkg
- name: Publish
run: dotnet nuget push ./libNOM.io.*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ./libNOM.io/bin/Release/libNOM.io.*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,50 @@ All notable changes to this project will be documented in this file. It uses the
### Fixed
### Security

## 0.6.0 (2023-09-??)

### Added
* Now targeting .NET 7 as per the [.NET release lifecycle](https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core)
* Now publishing to [NuGet Gallery](https://www.nuget.org/packages/libNOM.io)
* A setting to choose between writing always or only if a container is unsynced
* A privacy setting to decide whether external sources should be used to to improve
user identification (e.g. launcher configs or API calls)
* An IPlatform interface you can use instead of the abstract base class
* Lots of UnitTests
* Support for game version **Echoes 4.40**
* Voyagers Expedition
* Support for macOS when Steam is used

### Changed
* Bump K4os.Compression.LZ4 from 1.3.5 to 1.3.6
* Bump libNOM.map from 0.9.1 to 0.9.2
* Renamed the settings _LastWriteTime_ and _Mapping_
* Default value for some settings
* Names of the IsVersion flags now include the version number as well
* DifficultyPresetTypeEnum has been added and therefore PresetGameModeEnum is now
only used internal
* More getter and setter for JSON tokens and values
* Probably more...

### Removed
* Maybe some things...

### 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/milestone/10)

## 0.5.3 (2023-06-24)

### Added
* Support for game versions up to **Singularity 4.30**
* Singularity Expedition

## 0.5.2 (2023-03-19)

### Added
* Support for game version **Fractal 4.10**
* Utopia Expedition

### Fixed
* OutOfMemoryException while reading Microsoft account files (4.10 only)
Expand All @@ -37,9 +72,11 @@ All notable changes to this project will be documented in this file. It uses the
* OS dependent default paths for Steam
* Support for game version **Waypoint 4.00**
* Support for the Switch platform

### Changed
* PlatformCollection itself is now iterable and therefore `Get()` was removed
* Threshold is now the lowest ever used base version

### Fixed
* Explicitly do not use compression for account data
* SaveWizard usage detection if savedata00.hg file (account data) is present
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
60 changes: 40 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
# libNOM.io

![Maintained](https://img.shields.io/maintenance/yes/2023)
[![.NET Standard 2.0 - 2.1 | 6.0](https://img.shields.io/badge/.NET-Standard%202.0%20--%202.1%20%7C%206.0-lightgrey)](https://dotnet.microsoft.com/en-us/)
[![C# 10](https://img.shields.io/badge/C%23-10-lightgrey)](https://docs.microsoft.com/en-us/dotnet/csharp/)
[![.NET | Standard 2.0 - 2.1 | 6 - 7](https://img.shields.io/badge/.NET-Standard%202.0%20--%202.1%20%7C%206%20--%207-lightgrey)](https://dotnet.microsoft.com/en-us/)
[![C# 11](https://img.shields.io/badge/C%23-11-lightgrey)](https://docs.microsoft.com/en-us/dotnet/csharp/)
[![Release](https://img.shields.io/github/v/release/zencq/libNOM.io?display_name=tag)](https://github.com/zencq/libNOM.io/releases/latest)
[![Nuget](https://img.shields.io/nuget/v/libNOM.io)](https://www.nuget.org/packages/libNOM.io/)

[![libNOM.io](https://github.com/zencq/libNOM.io/actions/workflows/pipeline.yml/badge.svg)](https://github.com/zencq/libNOM.io/actions/workflows/pipeline.yml)

## Introduction

The `libNOM` label is a collection of .NET class libraries originally developed
and used in [NomNom](https://github.com/zencq/NomNom), a savegame editor for [No Man's Sky](https://www.nomanssky.com/).
and used in [NomNom](https://github.com/zencq/NomNom), the most complete savegame
editor for [No Man's Sky](https://www.nomanssky.com/).

`libNOM.io` can be used to read and write save files for all possible platforms
`libNOM.io` can be used to read and write save files for all supported platforms
as well as performing related actions.

## Getting Started

Currently save format `2001` (**Foundation 1.10** to **Prisms 3.53**) and `2002`
(**Frontiers 3.60** and up) are supported. The original format `2000` used in the
vanilla game is not supported. If you are interested in it, have a look at the [nms-savetool by MetaIdea](https://github.com/MetaIdea/nms-savetool).
(**Frontiers 3.60** and up) are supported. The original format `2000` that was used
in the vanilla game is not supported. If you are interested in it, have a look at the [nms-savetool by MetaIdea](https://github.com/MetaIdea/nms-savetool).

The lowest officially supported game version is **Beyond 2.11** to enable support
for homebrew users on PlayStation 4 which could not update further at some point.
Expand All @@ -30,9 +32,8 @@ Each platform has anchor file patterns to check whether it is worth to look furt
into the selected directory. This must be in or one level below the selected one.

* Apple
* Notes: No Man's Sky is coming to both Mac and iPad and can hopefully be supported
short after its release.
* [GOG.com](https://www.gog.com/game/no_mans_sky) (PC)
* Notes: Currently only available via Steam (see below).
* [GOG.com](https://www.gog.com/game/no_mans_sky) (Windows PC)
* Location: **%AppData%\HelloGames\NMS\DefaultUser**
* File Patterns: **save\*.hg**
* [PlayStation 4](https://store.playstation.com/?resolve=EP2034-CUSA03952_00-NOMANSSKYHG00001)
Expand All @@ -47,10 +48,13 @@ into the selected directory. This must be in or one level below the selected one
console itself. By playing the PlayStation 4 version on it, you can still
save edit with [a few additional steps](https://docs.google.com/document/d/1QoD2-PNlX-HeR5K1zuPGLMLBcX4_wknkhzc43-9bEq4/edit?usp=sharing).
* [Steam](https://store.steampowered.com/app/275850/No_Mans_Sky/) (PC)
* Location: **%AppData%\HelloGames\NMS\st\_\<SteamID\>**
* Location
* Windows: **%AppData%\HelloGames\NMS\st\_\<SteamID\>**
* SteamDeck: **~/.local/share/Steam/steamapps/compatdata/275850/pfx/drive_c/users/steamuser/Application Data/HelloGames/NMS/st\_\<SteamID\>**
* macOS: **~/Library/Application Support/HelloGames/NMS/st\_\<SteamID\>**
* File Patterns: **save\*.hg**
* [Microsoft Store](https://www.microsoft.com/p/no-mans-sky/bqvqtl3pch05) (PC)
* Location: **%LocalAppData%\Packages\HelloGames.NoMansSky_bs190hzg1sesy\SystemAppData\wgs\\<XboxID\>_<GUID\>**
* [Microsoft Store](https://www.microsoft.com/p/no-mans-sky/bqvqtl3pch05) (Windows PC)
* Location: **%LocalAppData%\Packages\HelloGames.NoMansSky_bs190hzg1sesy\SystemAppData\wgs\\<XboxID\>_29070100B936489ABCE8B9AF3980429C**
* File Patterns: **containers.index**
* Notes: Reloading of modified saves while the game is running does not work.
* [Nintendo Switch](https://www.nintendo.com/store/products/no-mans-sky-switch)
Expand All @@ -70,14 +74,29 @@ Here you'll find an example usage.
var path = "...";
var settings = new PlatformSettings { LoadingStrategy = LoadingStrategyEnum.Current };

var collection = new PlatformCollection(); // detects all available PC platforms on this machine
var platform = collection.AnalyzePath(path, settings); // get platform in this path
var container = platform.GetContainer(2); // Slot1Auto
var collection = new PlatformCollection(); // detects all available PC platforms on a machine
var platform = collection.AnalyzePath(path, settings); // get platform in path and add to collection
container.Load(); // if using LoadingStrategyEnum.Full this is not necessary
var jsonObject = container.GetJsonObject();
// ... modify jsonObject and set container.IsSynced = false
platform.Write(container); // jsonObject is modified by reference
var collection = new PlatformCollection(path); // additionally analyzes path
var platform = collection.Get(path); // get a previously detected platform with this path
var account = platform.GetAccountContainer(); // always loaded if exists
var save = platform.GetContainer(0); // Slot1Auto // loaded by default if LoadingStrategyEnum.Full
platform.Load(save); // needs to be loaded before you can modify its JSON
// Get the entire object or parts of it to modify on your own or get and set values directly.
// The getter and setter except multiple expressions but only the first valid one will be returned.
JsonObject jsonObject = save.GetJsonObject();
JToken? jsonToken = save.GetJsonToken("JSONPath1");
IEnumerable<JToken> jsonTokens = save.GetJsonTokens("JSONPath1");
int? jsonObject = save.GetJsonValue<int>("PlayerStateData.UniverseAddress.GalacticAddress.VoxelZ");
int? jsonObject = save.GetJsonValue<int>(new[] { 2, 0, 1, 2 }); // as above but with indices
save.SetJsonValue(1, "PlayerStateData.UniverseAddress.GalacticAddress.PlanetIndex");
save.SetJsonValue(1, new[] { 2, 0, 1, 4 }); // save as above
platform.Write(container);
```

## Projects using libNOM.io
Expand All @@ -104,8 +123,9 @@ Thanks to the following people for their help in one way or another.

## Dependencies

* [.NET Community Toolkit](https://github.com/CommunityToolkit/dotnet) - diagnostics and high performace helper
* [K4os.Compression.LZ4](https://www.nuget.org/packages/K4os.Compression.LZ4/) - Compression and decompression
* [LazyCache](https://www.nuget.org/packages/LazyCache) - Caching when a file is updated in the background
* [libNOM.map](https://github.com/zencq/libNOM.map) - Obfuscation and deobfuscation
* [libNOM.map](https://www.nuget.org/packages/libNOM.map) - Obfuscation and deobfuscation
* [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json/) - Handle JSON objects
* [SpookilySharp](https://www.nuget.org/packages/SpookilySharp/) - Creating SpookyHash
Loading

0 comments on commit 7a5046f

Please sign in to comment.