diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0e246371..1f5983ed 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -122,7 +122,7 @@ jobs: artifact_name: bannerlord secrets: NEXUSMODS_APIKEY: ${{ secrets.ARAGAS_NEXUSMODS_API_KEY }} - NEXUSMODS_COOKIES: ${{ secrets.ARAGAS_NEXUSMODS_COOKIE_SID_DEVELOP }} + NEXUSMODS_SESSION_COOKIE: ${{ secrets.ARAGAS_NEXUSMODS_SESSION_COOKIE }} ########################### # STEAM # diff --git a/.github/workflows/test-full.yml b/.github/workflows/test-full.yml index 544e66f6..a60eb858 100644 --- a/.github/workflows/test-full.yml +++ b/.github/workflows/test-full.yml @@ -71,7 +71,7 @@ jobs: shell: pwsh - name: ReportGenerator - uses: danielpalme/ReportGenerator-GitHub-Action@5.2.4 + uses: danielpalme/ReportGenerator-GitHub-Action@5.3.6 with: reports: '*.xml' targetdir: 'coveragereport' @@ -86,7 +86,7 @@ jobs: path: coveragereport - name: Upload ReportGenerator to CodeCov - uses: codecov/codecov-action@v4.3.0 + uses: codecov/codecov-action@v4.5.0 with: token: ${{secrets.CODECOV_TOKEN}} file: coveragereport/Cobertura.xml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a1debf37..89c11895 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,7 +77,7 @@ jobs: shell: pwsh - name: ReportGenerator - uses: danielpalme/ReportGenerator-GitHub-Action@5.2.4 + uses: danielpalme/ReportGenerator-GitHub-Action@5.3.6 with: reports: 'coverage_butterlib_stable_debug.xml;coverage_butterlib_stable_release.xml;coverage_butterlib_impl_stable_debug.xml;coverage_butterlib_impl_stable_release.xml;coverage_butterlib_impl_beta_debug.xml;coverage_butterlib_impl_beta_release.xml;' targetdir: 'coveragereport' @@ -92,7 +92,7 @@ jobs: path: coveragereport - name: Upload ReportGenerator to CodeCov - uses: codecov/codecov-action@v4.3.0 + uses: codecov/codecov-action@v4.5.0 with: token: ${{secrets.CODECOV_TOKEN}} file: coveragereport/Cobertura.xml diff --git a/README.md b/README.md index 08ca3511..ebb22771 100644 --- a/README.md +++ b/README.md @@ -78,12 +78,12 @@ Extension library for Mount & Blade II: Bannerlord. * [SaveSystem](https://butr.github.io/Bannerlord.ButterLib/articles/SaveSystem/Overview.html) - Provides helper methods for the game's save system. * [SubModuleWrappers](https://butr.github.io/Bannerlord.ButterLib/articles/SubModuleWrappers/Overview.html) - Wraps MBSubModulebase for easier calling of protected internal metods. * [DependencyInjection](https://butterlib.butr.link/articles/Optional/DependencyInjection/Overview.html) - Tools to work with ButterLib subsystems and services. -* [Logging]([https://butterlib.butr.link/articles/Optional/DependencyInjection/Overview.html](https://butterlib.butr.link/articles/Optional/Logging/Overview.html)) - Access to Serilog logging through ILogger Interface. +* [Logging](https://butterlib.butr.link/articles/Optional/Logging/Overview.html) - Access to Serilog logging through ILogger Interface. Check the [/Articles](https://butr.github.io/Bannerlord.ButterLib/articles/index.html) section in the documentation to see all available features! ### Outdated features: -* [AssemblyVerifier]([https://butr.github.io/Bannerlord.ButterLib/articles/CampaignIdentifier/Overview.html](https://butterlib.butr.link/articles/AssemblyVerifier/Overview.html)) - Basic assembly compatibility checks. +* [AssemblyVerifier](https://butterlib.butr.link/articles/AssemblyVerifier/Overview.html) - Basic assembly compatibility checks. * [CampaignIdentifier](https://butr.github.io/Bannerlord.ButterLib/articles/CampaignIdentifier/Overview.html) - Associates unique string ID with every campaign based on the initial character. ## Installation diff --git a/build/common.props b/build/common.props index 2951849e..8880471c 100644 --- a/build/common.props +++ b/build/common.props @@ -5,7 +5,7 @@ 1.0.0 - 2.9.8 + 2.9.9 2.2.2 3.2.0.77 diff --git a/changelog.txt b/changelog.txt index 3a6d9f51..8d0caf23 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,8 @@ --------------------------------------------------------------------------------------------------- +Version: 2.9.9 +Game Versions: v1.0.x,v1.1.x,v1.2.x +* Fixed SyncAsJson not serializing game types +--------------------------------------------------------------------------------------------------- Version: 2.9.8 Game Versions: v1.0.x,v1.1.x,v1.2.x * Improvements to DistanceMatrix diff --git a/docs/articles/DelayedSubModule/Overview.md b/docs/articles/DelayedSubModule/Overview.md index 140e260c..5713a83a 100644 --- a/docs/articles/DelayedSubModule/Overview.md +++ b/docs/articles/DelayedSubModule/Overview.md @@ -45,5 +45,5 @@ protected override void OnBeforeInitialModuleScreenSetAsRoot() ## Note: * If for some reason your Module will load after the Module that you subscribed to, the delegate you passed in ``Subscribe`` will be executed immediately. -* If a derived [``MBSubModuleBase``](https://apidoc.bannerlord.com/v/1.2.7/class_tale_worlds_1_1_mount_and_blade_1_1_m_b_sub_module_base.html) class overrides the method you subcsribe to and calls the base.Method(), you will get two calls, one from the override and one from calling the empty virtual method. Don't forget to filter by [``SubscriptionEventArgs.IsBase``](xref:Bannerlord.ButterLib.DelayedSubModule.SubscriptionEventArgs#collapsible-Bannerlord_ButterLib_DelayedSubModule_SubscriptionEventArgs_IsBase). +* If a derived [``MBSubModuleBase``](xref:TaleWorlds.MountAndBlade.MBSubModuleBase) class overrides the method you subcsribe to and calls the base.Method(), you will get two calls, one from the override and one from calling the empty virtual method. Don't forget to filter by [``SubscriptionEventArgs.IsBase``](xref:Bannerlord.ButterLib.DelayedSubModule.SubscriptionEventArgs#collapsible-Bannerlord_ButterLib_DelayedSubModule_SubscriptionEventArgs_IsBase). * The current implementation does not allow to subscribe to methods e.g. ``OnBeforeInitialModuleScreenSetAsRoot()`` outside the ``OnBeforeInitialModuleScreenSetAsRoot()`` override. You will not be able to subscribe to ``OnBeforeInitialModuleScreenSetAsRoot()`` in ``OnSubModuleLoad()`` override and vise-versa. diff --git a/src/Bannerlord.ButterLib.Implementation/MBSubModuleBaseExtended/Patches/ModulePatch.cs b/src/Bannerlord.ButterLib.Implementation/MBSubModuleBaseExtended/Patches/ModulePatch.cs index 7b3eeed6..f82420e0 100644 --- a/src/Bannerlord.ButterLib.Implementation/MBSubModuleBaseExtended/Patches/ModulePatch.cs +++ b/src/Bannerlord.ButterLib.Implementation/MBSubModuleBaseExtended/Patches/ModulePatch.cs @@ -81,8 +81,10 @@ public static IEnumerable Transpiler(IEnumerable? CampaignObjectTypeObjects = + private static readonly AccessTools.FieldRef? CampaignObjectTypeObjects = AccessTools2.FieldRefAccess("_objects"); private static readonly Type? ICampaignObjectTypeType = - AccessTools2.TypeByName("TaleWorlds.CampaignSystem.CampaignObjectManager.ICampaignObjectType"); + AccessTools2.TypeByName("TaleWorlds.CampaignSystem.CampaignObjectManager+ICampaignObjectType"); private static readonly MethodInfo? ObjectClassGetter = AccessTools2.PropertyGetter(ICampaignObjectTypeType!, "ObjectClass"); private static MBObjectBase? FindCampaignObjectManager(MBGUID id, Type type) { - foreach (var cot in CampaignObjectTypeObjects?.Invoke(Campaign.Current.CampaignObjectManager) ?? Array.Empty()) + // Not sure this piece if code ever worked, but keeping it just in case of edgecases + foreach (var cot in CampaignObjectTypeObjects?.Invoke(Campaign.Current.CampaignObjectManager) ?? []) { - if (type == ObjectClassGetter?.Invoke(cot, Array.Empty()) as Type && cot is IEnumerable en && en.FirstOrDefault(o => o.Id == id) is { } result) + if (cot is null) continue; + + if (ObjectClassGetter?.Invoke(cot, []) is Type objType && objType == type && cot is IEnumerable en && en.FirstOrDefault(o => o.Id == id) is { } result) { return result; } } - return null; + + try + { + return MBObjectManager.Instance.GetObject(id); + } + catch (Exception) + { + return null; + } } public MBObjectBase? Find(MBGUID id, Type? type = null) diff --git a/src/Bannerlord.ButterLib/SaveSystem/Extensions/IDataStoreExtensions.cs b/src/Bannerlord.ButterLib/SaveSystem/Extensions/IDataStoreExtensions.cs index 46b3789c..1ce47fa4 100644 --- a/src/Bannerlord.ButterLib/SaveSystem/Extensions/IDataStoreExtensions.cs +++ b/src/Bannerlord.ButterLib/SaveSystem/Extensions/IDataStoreExtensions.cs @@ -86,7 +86,7 @@ public static bool SyncDataAsJson(this IDataStore dataStore, string key, ref var jsonDataChunks = Array.Empty(); if (dataStore.SyncData(key, ref jsonDataChunks)) { - var (format, jsonData) = JsonConvert.DeserializeObject(ChunksToString(jsonDataChunks ?? Array.Empty())) ?? new(-1, string.Empty); + var (format, jsonData) = JsonConvert.DeserializeObject(ChunksToString(jsonDataChunks ?? [])) ?? new(-1, string.Empty); data = format switch { 2 => Deserialize(jsonData, serializer),