Skip to content

Commit

Permalink
use fake profile name for nh
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnCorby committed Apr 25, 2024
1 parent 401f3de commit bd03bae
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
6 changes: 6 additions & 0 deletions QSB-NH/Patches/GameStateMessagePatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
namespace QSBNH.Patches;


/// <summary>
/// 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
/// </summary>
internal class GameStateMessagePatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnModStart;
Expand Down
33 changes: 33 additions & 0 deletions QSB-NH/Patches/NewHorizonsDataPatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using HarmonyLib;
using NewHorizons.External;
using QSB;
using QSB.Patches;
using QSB.SaveSync;
using QSB.Utility;

namespace QSBNH.Patches;

/// <summary>
/// pretends to be a new profile when in multiplayer so nh saves its data to a new place
/// </summary>
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;
}
}
2 changes: 1 addition & 1 deletion QSB-NH/QSB-NH.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<TargetFramework>net48</TargetFramework>
<RootNamespace>QSBNH</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputPath Condition="Exists('$(OwmlDir)')">$(OwmlDir)\Mods\Raicuparta.QuantumSpaceBuddies</OutputPath>
<NoWarn>CS1998;CS0649</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion QSB-NH/WarpManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public override void OnReceiveRemote()
}
}

[HarmonyPatch]
public class NHWarpPatch : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnModStart;
Expand Down

0 comments on commit bd03bae

Please sign in to comment.