Skip to content

Commit

Permalink
Merge pull request #403 from BUTR/dev
Browse files Browse the repository at this point in the history
v2.9.9
  • Loading branch information
Aragas authored Jun 18, 2024
2 parents e6e4cd0 + d5b2df6 commit 0ac12e1
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<BaseGameVersion>1.0.0</BaseGameVersion>
<!--Module Version-->
<Version>2.9.8</Version>
<Version>2.9.9</Version>
<!--Harmony Version-->
<HarmonyVersion>2.2.2</HarmonyVersion>
<HarmonyExtensionsVersion>3.2.0.77</HarmonyExtensionsVersion>
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/articles/DelayedSubModule/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructio
}
else
{
codes.InsertRange(finallyIndex + 1, new CodeInstruction[] { new CodeInstruction(opcode: OpCodes.Ldarg_0),
new CodeInstruction(opcode: OpCodes.Call, operand: miDelayedScreenAsRootEventCaller) });
codes.InsertRange(finallyIndex + 1, new CodeInstruction[] {
new CodeInstruction(opcode: OpCodes.Ldarg_0),
new CodeInstruction(opcode: OpCodes.Call, operand: miDelayedScreenAsRootEventCaller)
});
codes[finallyIndex + 1].MoveLabelsFrom(codes[finallyIndex + 3]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,34 @@ namespace Bannerlord.ButterLib.Implementation.ObjectSystem;

internal class MBObjectFinder : IMBObjectFinder
{
private static readonly AccessTools.FieldRef<CampaignObjectManager, object[]>? CampaignObjectTypeObjects =
private static readonly AccessTools.FieldRef<CampaignObjectManager, object?[]>? CampaignObjectTypeObjects =
AccessTools2.FieldRefAccess<CampaignObjectManager, object[]>("_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<object>())
// 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<object>()) as Type && cot is IEnumerable<MBObjectBase> 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<MBObjectBase> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static bool SyncDataAsJson<T>(this IDataStore dataStore, string key, ref
var jsonDataChunks = Array.Empty<string>();
if (dataStore.SyncData(key, ref jsonDataChunks))
{
var (format, jsonData) = JsonConvert.DeserializeObject<JsonData?>(ChunksToString(jsonDataChunks ?? Array.Empty<string>())) ?? new(-1, string.Empty);
var (format, jsonData) = JsonConvert.DeserializeObject<JsonData?>(ChunksToString(jsonDataChunks ?? [])) ?? new(-1, string.Empty);
data = format switch
{
2 => Deserialize<T>(jsonData, serializer),
Expand Down

0 comments on commit 0ac12e1

Please sign in to comment.