Skip to content

Commit

Permalink
Release
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Jan 14, 2022
1 parent 4bd7152 commit 7e05351
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!--Development Variables-->
<PropertyGroup>
<!--Module Version-->
<Version>1.0.31</Version>
<Version>1.0.32</Version>
<!--Harmony Version-->
<HarmonyVersion>2.1.1</HarmonyVersion>
<!--Microsoft Extension Libraries Version-->
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: 1.0.32
Game Versions: e1.4.3,e1.5.0,e1.5.1,e1.5.2,e1.5.3,e1.5.4,e1.5.5,e1.5.6,e1.5.7,e1.5.8,e1.5.9,e1.5.10,e1.6.0,e1.6.1,e1.6.2,e1.6.3,e1.6.4,e1.6.5,e1.7.0,e1.7.1
* Fixed TW save changes for the modding community.
---------------------------------------------------------------------------------------------------
Version: 1.0.31
Game Versions: e1.4.3,e1.5.0,e1.5.1,e1.5.2,e1.5.3,e1.5.4,e1.5.5,e1.5.6,e1.5.7,e1.5.8,e1.5.9,e1.5.10,e1.6.0,e1.6.1,e1.6.2,e1.6.3,e1.6.4,e1.6.5,e1.7.0
* Compatibility with e1.7.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void Enable()
#if e143 || e150 || e151 || e152 || e153
Patches.CharacterCreationContentApplyCulturePatch.Enable(_harmony);
Patches.ClanInitializeClanPatch.Enable(_harmony);
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170 || e171
#else
#error ConstGameVersionWithPrefix is not handled!
#endif
Expand All @@ -41,7 +41,7 @@ public void Disable()
#if e143 || e150 || e151 || e152 || e153
//CharacterCreationContentApplyCulturePatch.Disable(_harmony);
//ClanInitializeClanPatch.Disable(_harmony);
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170 || e171
#else
#error ConstGameVersionWithPrefix is not handled!
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal sealed partial class CampaignExtensionsImplementation : ICampaignExtens
return campaign.GameStarted && campaign.GetCampaignBehavior<CampaignIdentifierBehavior>() is { } identifierBehavior
? identifierBehavior.CampaignId
: null;
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170 || e171
return Campaign.Current.UniqueGameId;
#else
#error ConstGameVersionWithPrefix is not handled!
Expand All @@ -30,7 +30,7 @@ internal sealed partial class CampaignExtensionsImplementation : ICampaignExtens
return campaign.GameStarted && campaign.GetCampaignBehavior<CampaignIdentifierBehavior>() is { } identifierBehavior
? identifierBehavior.CampaignDescriptor
: null;
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170 || e171
return new BlankCampaignDescriptor(Campaign.Current);
#else
#error ConstGameVersionWithPrefix is not handled!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private Dictionary<ulong, float> CalculateDistanceMatrix()
{
#if e143 || e150 || e151 || e152 || e153 || e154 || e155 || e156 || e157 || e158 || e159 || e1510
var activeHeroes = Hero.All
#elif e160 || e161 || e162 || e163 || e164 || e165 || e170
#elif e160 || e161 || e162 || e163 || e164 || e165 || e170 || e171
var activeHeroes = Hero.AllAliveHeroes
#else
#error ConstGameVersionWithPrefix is not handled!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override IReadOnlyList<HotKeyBase> Build()
var hotKeyCategoryContainer = new HotKeyCategoryContainer(_subModName, _hotKeys);
#if e143 || e150 || e151 || e152 || e153 || e154 || e155 || e156 || e157 || e158 || e159
TWHotKeyManager.Initialize("Bannerlord", Utilities.GetConfigsPath() + "BannerlordGameKeys.xml", new List<GameKeyContext> { hotKeyCategoryContainer }, true);
#elif e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
#elif e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170 || e171
TWHotKeyManager.Initialize(new PlatformFilePath(EngineFilePaths.ConfigsPath, "BannerlordGameKeys.xml"), new List<GameKeyContext> { hotKeyCategoryContainer }, true);
#else
#error ConstGameVersionWithPrefix is not handled!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static void OnApplicationTick(float dt)
hotKey.OnPressedInternal();
if (hotKey.GameKey.PrimaryKey.InputKey.IsReleased())
hotKey.OnReleasedInternal();
#elif e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
#elif e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170 || e171
if (hotKey.GameKey.KeyboardKey?.InputKey.IsDown() == true || hotKey.GameKey.ControllerKey?.InputKey.IsDown() == true)
hotKey.IsDownInternal();
if (hotKey.GameKey.KeyboardKey?.InputKey.IsPressed() == true || hotKey.GameKey.ControllerKey?.InputKey.IsPressed() == true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ public void RenderDebugText(float screenX, float screenY, string text, uint colo

public Vec3 GetDebugVector() => OriginalDebugManager.GetDebugVector();

#if e164 || e165 || e170
#if e164 || e165 || e170 || e171
public void ShowError(string message)
{
_debugManagerLogger.LogError("{message}", message);
OriginalDebugManager.ShowError(message);
}
#endif
#if e165 || e170
#if e165 || e170 || e171
public void BeginTelemetryScopeBaseLevel(TelemetryLevelMask levelMask, string scopeName) => OriginalDebugManager.BeginTelemetryScopeBaseLevel(levelMask, scopeName);
public void EndTelemetryScopeBaseLevel() => OriginalDebugManager.EndTelemetryScopeBaseLevel();
#endif
#if e170
#if e170 || e171
public void RenderDebugText3D(Vec3 position, string text, uint color = uint.MaxValue, int screenPosOffsetX = 0, int screenPosOffsetY = 0, float time = 0)
{
throw new NotImplementedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class MBObjectFinder : IMBObjectFinder
return null;
}
}
#elif e160 || e161 || e162 || e163 || e164 || e165 || e170
#elif e160 || e161 || e162 || e163 || e164 || e165 || e170 || e171

private static readonly AccessTools.FieldRef<CampaignObjectManager, object[]>? CampaignObjectTypeObjects =
AccessTools2.FieldRefAccess<CampaignObjectManager, object[]>("_objects");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Bannerlord.BUTR.Shared.Helpers;
using Bannerlord.ButterLib.Common.Extensions;

using HarmonyLib;
using HarmonyLib.BUTR.Extensions;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;

using TaleWorlds.CampaignSystem;

namespace Bannerlord.ButterLib.Implementation.SaveSystem.Patches
{
/// <summary>
/// Fixes TW's new implementation. They plan to switch namespaces, to Type.FullName will break saves.
/// Instead, only TW will use Type.Name, the modding community will use Type.FullName
/// </summary>
internal sealed class BehaviourNamePatch
{
internal static bool Enable(Harmony harmony)
{
return harmony.TryPatch(
AccessTools2.Constructor(typeof(CampaignBehaviorBase)),
postfix: AccessTools2.Method(typeof(BehaviourNamePatch), nameof(CampaignBehaviorBaseCtorPostfix)));
}

internal static bool Disable(Harmony harmony)
{
harmony.Unpatch(
AccessTools2.Constructor(typeof(CampaignBehaviorBase)),
AccessTools2.Method(typeof(BehaviourNamePatch), nameof(CampaignBehaviorBaseCtorPostfix)));

return true;
}

private static void CampaignBehaviorBaseCtorPostfix(CampaignBehaviorBase instance, ref string ___StringId)
{
var module = ModuleInfoHelper.GetModuleByType(instance.GetType());
if (module is null) // A non-module dll
{
return;
}

if (module.IsOfficial) // A TW module
{
return;
}

___StringId = instance.GetType().FullName;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bannerlord.ButterLib.Implementation.SaveSystem.Patches;
using Bannerlord.BUTR.Shared.Helpers;
using Bannerlord.ButterLib.Implementation.SaveSystem.Patches;
using Bannerlord.ButterLib.SubSystems;

using HarmonyLib;
Expand Down Expand Up @@ -26,6 +27,11 @@ public void Enable()
{
IsEnabled = true;

if (ApplicationVersionHelper.GameVersion() is { } gameVersion && gameVersion.Major >= 1 && gameVersion.Minor >= 7)
{
BehaviourNamePatch.Enable(_harmony);
}

TypeExtensionsPatch.Enable(_harmony); // Adds support for saving many more container types
//DefinitionContextPatch.Enable(_harmony); // Fixes save corruption & crashes when duplicate types are defined
}
Expand All @@ -34,6 +40,11 @@ public void Disable()
{
IsEnabled = false;

if (ApplicationVersionHelper.GameVersion() is { } gameVersion && gameVersion.Major >= 1 && gameVersion.Minor >= 7)
{
BehaviourNamePatch.Disable(_harmony);
}

TypeExtensionsPatch.Disable(_harmony);
//DefinitionContextPatch.Disable(_harmony);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Bannerlord.ButterLib.Implementation/SubModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void OnServiceRegistration()
services.AddSingleton<ICampaignExtensions, CampaignExtensionsImplementation>();
#if e143 || e150 || e151 || e152 || e153
services.AddTransient<ICampaignDescriptorProvider, JsonCampaignDescriptorProvider>();
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170 || e171
services.AddTransient<ICampaignDescriptorProvider, BlankCampaignDescriptorProvider>();
#else
#error ConstGameVersionWithPrefix is not handled!
Expand Down
1 change: 1 addition & 0 deletions supported-game-versions.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
e1.7.1
e1.7.0
e1.6.5
e1.6.4
Expand Down

0 comments on commit 7e05351

Please sign in to comment.