-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
83 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/Bannerlord.ButterLib.Implementation/SaveSystem/Patches/BehaviourNamePatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|