From eb5369af00532139d2425741fcc5da08e9729458 Mon Sep 17 00:00:00 2001 From: Zhenhuan Li Date: Wed, 31 Aug 2022 23:04:03 +0800 Subject: [PATCH] Fix crash when player in settlement and enter then exit ebt --- .github/resources/config.env | 2 +- .../Modules/EnhancedBattleTest/SubModule.xml | 2 +- .../src/EnhancedBattleTestSubModule.cs | 10 +++------- source/EnhancedBattleTest/src/Patch/Patch_MapScreen.cs | 10 ++++++++++ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/resources/config.env b/.github/resources/config.env index 958441b..be5d0f8 100644 --- a/.github/resources/config.env +++ b/.github/resources/config.env @@ -1,3 +1,3 @@ GAME_VERSION=e1.8.0 GAME_BRANCH=beta -MOD_VERSION=v3.0.0 \ No newline at end of file +MOD_VERSION=v3.0.1 \ No newline at end of file diff --git a/source/EnhancedBattleTest/Modules/EnhancedBattleTest/SubModule.xml b/source/EnhancedBattleTest/Modules/EnhancedBattleTest/SubModule.xml index 4858e6e..c0cdb11 100644 --- a/source/EnhancedBattleTest/Modules/EnhancedBattleTest/SubModule.xml +++ b/source/EnhancedBattleTest/Modules/EnhancedBattleTest/SubModule.xml @@ -2,7 +2,7 @@ - + diff --git a/source/EnhancedBattleTest/src/EnhancedBattleTestSubModule.cs b/source/EnhancedBattleTest/src/EnhancedBattleTestSubModule.cs index c249e35..77c0c41 100644 --- a/source/EnhancedBattleTest/src/EnhancedBattleTestSubModule.cs +++ b/source/EnhancedBattleTest/src/EnhancedBattleTestSubModule.cs @@ -1,20 +1,16 @@ -using System; -using System.IO; -using System.Reflection; using EnhancedBattleTest.Data; -using EnhancedBattleTest.GameMode; using EnhancedBattleTest.Patch; using EnhancedBattleTest.Patch.Fix; using EnhancedBattleTest.SinglePlayer; using EnhancedBattleTest.UI; using HarmonyLib; +using System; +using System.IO; +using System.Reflection; using TaleWorlds.Core; using TaleWorlds.Library; -using TaleWorlds.Localization; -using TaleWorlds.ModuleManager; using TaleWorlds.MountAndBlade; using Campaign = TaleWorlds.CampaignSystem.Campaign; -using Module = TaleWorlds.MountAndBlade.Module; using MultiplayerGame = EnhancedBattleTest.GameMode.MultiplayerGame; namespace EnhancedBattleTest diff --git a/source/EnhancedBattleTest/src/Patch/Patch_MapScreen.cs b/source/EnhancedBattleTest/src/Patch/Patch_MapScreen.cs index 08549a2..9160008 100644 --- a/source/EnhancedBattleTest/src/Patch/Patch_MapScreen.cs +++ b/source/EnhancedBattleTest/src/Patch/Patch_MapScreen.cs @@ -4,6 +4,9 @@ using System; using System.Collections.Generic; using System.Reflection; +using TaleWorlds.CampaignSystem; +using TaleWorlds.CampaignSystem.Encounters; +using TaleWorlds.CampaignSystem.Party; using TaleWorlds.Core; using TaleWorlds.Localization; using TaleWorlds.MountAndBlade.ViewModelCollection.EscapeMenu; @@ -37,6 +40,13 @@ public static void Postfix_GetEscapeMenuItems(MapScreen __instance, List { __instance.CloseEscapeMenu(); + if (PlayerEncounter.Current != null) + { + PlayerEncounter.Finish(); + typeof(MapScreen).GetMethod("ExitMenuContext", BindingFlags.Instance | BindingFlags.NonPublic) + .Invoke(__instance, new object[] { }); + } + Game.Current.GameStateManager.PushState(Game.Current.GameStateManager.CreateState()); }, null, () => new Tuple(false, TextObject.Empty))); }