From bd03bae63ed6c0bbe172aab67dc7273f72ef82bf Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Wed, 24 Apr 2024 23:52:20 -0700 Subject: [PATCH] use fake profile name for nh --- QSB-NH/Patches/GameStateMessagePatches.cs | 6 +++++ QSB-NH/Patches/NewHorizonsDataPatches.cs | 33 +++++++++++++++++++++++ QSB-NH/QSB-NH.csproj | 2 +- QSB-NH/WarpManager.cs | 1 - 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 QSB-NH/Patches/NewHorizonsDataPatches.cs diff --git a/QSB-NH/Patches/GameStateMessagePatches.cs b/QSB-NH/Patches/GameStateMessagePatches.cs index 277f5f724..06c58bb3d 100644 --- a/QSB-NH/Patches/GameStateMessagePatches.cs +++ b/QSB-NH/Patches/GameStateMessagePatches.cs @@ -15,6 +15,12 @@ namespace QSBNH.Patches; +/// +/// extremely jank way to inject system and nh addons when joining. +/// this should probably be split into its own separate message, but it doesnt really matter :P +/// +/// BUG: completely explodes if one person has nh and the other does not +/// internal class GameStateMessagePatches : QSBPatch { public override QSBPatchTypes Type => QSBPatchTypes.OnModStart; diff --git a/QSB-NH/Patches/NewHorizonsDataPatches.cs b/QSB-NH/Patches/NewHorizonsDataPatches.cs new file mode 100644 index 000000000..66f382a58 --- /dev/null +++ b/QSB-NH/Patches/NewHorizonsDataPatches.cs @@ -0,0 +1,33 @@ +using HarmonyLib; +using NewHorizons.External; +using QSB; +using QSB.Patches; +using QSB.SaveSync; +using QSB.Utility; + +namespace QSBNH.Patches; + +/// +/// pretends to be a new profile when in multiplayer so nh saves its data to a new place +/// +public class NewHorizonsDataPatches : QSBPatch +{ + public override QSBPatchTypes Type => QSBPatchTypes.OnModStart; + + [HarmonyPrefix] + [HarmonyPatch(typeof(NewHorizonsData), nameof(NewHorizonsData.GetProfileName))] + public static bool NewHorizonsData_GetProfileName(out string __result) + { + if (QSBCore.IsInMultiplayer) + { + DebugLog.DebugWrite($"using fake multiplayer profile for nh"); + __result = QSBStandaloneProfileManager.SharedInstance?.currentProfile?.profileName + "_mult"; + } + else + { + __result = QSBStandaloneProfileManager.SharedInstance?.currentProfile?.profileName; + } + + return false; + } +} diff --git a/QSB-NH/QSB-NH.csproj b/QSB-NH/QSB-NH.csproj index a4427787d..3bd1280b8 100644 --- a/QSB-NH/QSB-NH.csproj +++ b/QSB-NH/QSB-NH.csproj @@ -4,8 +4,8 @@ net48 QSBNH enable - enable $(OwmlDir)\Mods\Raicuparta.QuantumSpaceBuddies + CS1998;CS0649 diff --git a/QSB-NH/WarpManager.cs b/QSB-NH/WarpManager.cs index 62eee1c32..6204856bb 100644 --- a/QSB-NH/WarpManager.cs +++ b/QSB-NH/WarpManager.cs @@ -118,7 +118,6 @@ public override void OnReceiveRemote() } } - [HarmonyPatch] public class NHWarpPatch : QSBPatch { public override QSBPatchTypes Type => QSBPatchTypes.OnModStart;