-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No more submodule, re-bypassing map saves
- Loading branch information
1 parent
e6c380f
commit f6d18f4
Showing
6 changed files
with
119 additions
and
5 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Submodule ModdedClientChecking
deleted from
5a0a8f
29 changes: 29 additions & 0 deletions
29
BloonsTD6 Mod Helper/Patches/ModdedClientChecking/IsModdedClientPatches.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,29 @@ | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using Assets.Scripts.Unity; | ||
using BTD_Mod_Helper.Api; | ||
using HarmonyLib; | ||
|
||
namespace BTD_Mod_Helper.Patches.ModdedClientChecking | ||
{ | ||
[HarmonyPatch] | ||
internal static class IsModdedClientPatches | ||
{ | ||
private static IEnumerable<MethodBase> TargetMethods() | ||
{ | ||
yield return AccessTools.PropertyGetter(typeof(Game), nameof(Game.IsModdedClient)); | ||
yield return AccessTools.Method(typeof(Modding), nameof(Modding.CheckForMods)); | ||
} | ||
|
||
[HarmonyPrefix] | ||
private static bool Prefix(ref bool __result) | ||
{ | ||
if (ModdedClientBypassing.CurrentlyBypassingCheck && MelonMain.BypassSavingRestrictions) | ||
{ | ||
__result = false; | ||
return false; | ||
} | ||
return true; | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
BloonsTD6 Mod Helper/Patches/ModdedClientChecking/ModdedClientBypassing.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,38 @@ | ||
using Assets.Scripts.Unity; | ||
|
||
namespace BTD_Mod_Helper.Patches.ModdedClientChecking | ||
{ | ||
/// <summary> | ||
/// You forced our hand :( | ||
/// </summary> | ||
public class ModdedClientBypassing | ||
{ | ||
/// <summary> | ||
/// The nuclear option would be just setting this to true, which would entirely bypass all of NK's clientside checks | ||
/// </summary> | ||
private const bool DefaultBypassCheck = false; | ||
|
||
/// <summary> | ||
/// Whether the ModdedClient check is currently being bypassed | ||
/// </summary> | ||
public static bool CurrentlyBypassingCheck { get; private set; } | ||
|
||
/// <summary> | ||
/// Called in prefix patches on methods where we think modded clients should be accepted | ||
/// </summary> | ||
internal static void StartBypassingCheck() | ||
{ | ||
CurrentlyBypassingCheck = true; | ||
Modding.isModdedClient = false; | ||
} | ||
|
||
/// <summary> | ||
/// Called in postfix patches on methods where we think modded clients should be accepted | ||
/// </summary> | ||
internal static void StopBypassingCheck() | ||
{ | ||
CurrentlyBypassingCheck = DefaultBypassCheck; | ||
Modding.isModdedClient = !DefaultBypassCheck; | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
BloonsTD6 Mod Helper/Patches/ModdedClientChecking/ModdedClientUsagePatches.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,51 @@ | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using Assets.Scripts.Unity.Player; | ||
using Assets.Scripts.Unity.UI_New.DailyChallenge; | ||
using Assets.Scripts.Unity.UI_New.GameOver; | ||
using Assets.Scripts.Unity.UI_New.InGame; | ||
using Assets.Scripts.Utils; | ||
using HarmonyLib; | ||
|
||
namespace BTD_Mod_Helper.Patches.ModdedClientChecking | ||
{ | ||
[HarmonyPatch] | ||
internal static class ModdedClientUsagePatches | ||
{ | ||
private static IEnumerable<MethodBase> TargetMethods() | ||
{ | ||
yield return AccessTools.Method(typeof(Btd6Player), nameof(Btd6Player.Save)); | ||
yield return AccessTools.Method(typeof(Btd6Player), nameof(Btd6Player.SaveNow)); | ||
yield return AccessTools.Method(typeof(Btd6Player), nameof(Btd6Player.SyncNow)); | ||
yield return AccessTools.Method(typeof(InGame), nameof(InGame.Continue)); | ||
yield return AccessTools.Method(typeof(InGame), nameof(InGame.ContinueFromCheckpoint)); | ||
yield return AccessTools.Method(typeof(InGame), nameof(InGame.CreateMapSave)); | ||
yield return AccessTools.Method(typeof(InGame), nameof(InGame.RoundEnd)); | ||
yield return AccessTools.Method(typeof(InGame), nameof(InGame.OnVictory)); | ||
yield return AccessTools.Method(typeof(OnlineProfileUpdater), nameof(OnlineProfileUpdater.LateUpdate)); | ||
|
||
yield return AccessTools.Method(typeof(OnlineProfileManager._Upload_d__13), | ||
nameof(OnlineProfileManager._Upload_d__13.MoveNext)); | ||
yield return AccessTools.Method(typeof(Btd6Player._LoadOnlineData_d__38), | ||
nameof(Btd6Player._LoadOnlineData_d__38.MoveNext)); | ||
yield return AccessTools.Method(typeof(BossVictoryScreen._Open_d__24), | ||
nameof(BossVictoryScreen._Open_d__24.MoveNext)); | ||
yield return AccessTools.Method(typeof(BossEventScreenPlayPanel._Open_d__24), | ||
nameof(BossEventScreenPlayPanel._Open_d__24.MoveNext)); | ||
yield return AccessTools.Method(typeof(BossEventScreen._Open_d__43), | ||
nameof(BossEventScreen._Open_d__43.MoveNext)); | ||
} | ||
|
||
[HarmonyPrefix] | ||
private static void Prefix() | ||
{ | ||
ModdedClientBypassing.StartBypassingCheck(); | ||
} | ||
|
||
[HarmonyPostfix] | ||
private static void Postfix() | ||
{ | ||
ModdedClientBypassing.StopBypassingCheck(); | ||
} | ||
} | ||
} |