-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from Arkhist/develop
5.3.0
- Loading branch information
Showing
20 changed files
with
443 additions
and
193 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using Hacknet; | ||
using Hacknet.Extensions; | ||
using Hacknet.Misc; | ||
using HarmonyLib; | ||
using MonoMod.Cil; | ||
using Mono.Cecil.Cil; | ||
|
||
namespace Pathfinder.BaseGameFixes; | ||
|
||
[HarmonyPatch] | ||
public static class FixExtensionTests | ||
{ | ||
[HarmonyILManipulator] | ||
[HarmonyPatch(typeof(ExtensionTests), nameof(ExtensionTests.TestExtensionForRuntime))] | ||
[HarmonyPatch(typeof(ExtensionTests), nameof(ExtensionTests.TestExtensionMission))] | ||
internal static void TestMissionStartingMissionNONEFix(ILContext il) | ||
{ | ||
ILCursor c = new ILCursor(il); | ||
|
||
// string _text = TestSuite.TestMission(ExtensionLoader.ActiveExtensionInfo.FolderPath + "/" + ExtensionLoader.ActiveExtensionInfo.StartingMissionPath, _os); | ||
c.GotoNext(MoveType.After, | ||
x => x.MatchLdsfld(AccessTools.Field(typeof(ExtensionLoader), nameof(ExtensionLoader.ActiveExtensionInfo))), | ||
x => x.MatchLdfld(AccessTools.Field(typeof(ExtensionInfo), nameof(ExtensionInfo.FolderPath))), | ||
x => x.MatchLdstr("/"), | ||
x => x.MatchLdsfld(AccessTools.Field(typeof(ExtensionLoader), nameof(ExtensionLoader.ActiveExtensionInfo))), | ||
x => x.MatchLdfld(AccessTools.Field(typeof(ExtensionInfo), nameof(ExtensionInfo.StartingMissionPath))), | ||
x => x.MatchCall(AccessTools.Method(typeof(string), nameof(string.Concat), new Type[] { typeof(string), typeof(string), typeof(string) })), | ||
_ => true, | ||
x => x.MatchCall(AccessTools.Method(typeof(TestSuite), nameof(TestSuite.TestMission))), | ||
x => x.MatchStloc(out int _) | ||
); | ||
c.Index--; | ||
ILLabel labelDontTestStartingMission = c.MarkLabel(); | ||
c.Index -= 7; | ||
ILLabel labelTestStartingMission = c.MarkLabel(); | ||
c.MoveBeforeLabels(); | ||
|
||
c.Emit(OpCodes.Dup); | ||
c.EmitDelegate<Func<ExtensionInfo, bool>>(info => | ||
info.StartingMissionPath == null | ||
); | ||
c.Emit(OpCodes.Brfalse, labelTestStartingMission); | ||
c.Emit(OpCodes.Pop); | ||
c.Emit(OpCodes.Ldstr, ""); | ||
c.Emit(OpCodes.Br, labelDontTestStartingMission); | ||
} | ||
[HarmonyILManipulator] | ||
[HarmonyPatch(typeof(ExtensionInfo), nameof(ExtensionInfo.VerifyExtensionInfo))] | ||
internal static void ExtensionInfoStartingMissionNONEFix(ILContext il) | ||
{ | ||
ILCursor c = new ILCursor(il); | ||
// if (!File.Exists(info.FolderPath + "/" + info.StartingMissionPath)) | ||
c.GotoNext(MoveType.After, | ||
x => x.MatchLdarg(0), | ||
x => x.MatchLdfld(AccessTools.Field(typeof(ExtensionInfo), nameof(ExtensionInfo.FolderPath))), | ||
x => x.MatchLdstr("/"), | ||
x => x.MatchLdarg(0), | ||
x => x.MatchLdfld(AccessTools.Field(typeof(ExtensionInfo), nameof(ExtensionInfo.StartingMissionPath))), | ||
x => x.MatchCall(AccessTools.Method(typeof(string), nameof(string.Concat), new Type[] { typeof(string), typeof(string), typeof(string) })), | ||
x => x.MatchCall(AccessTools.Method(typeof(File), nameof(File.Exists))), | ||
x => x.MatchStloc(3), | ||
x => x.MatchLdloc(3), | ||
x => x.MatchBrtrue(out ILLabel _) | ||
); | ||
c.Index--; | ||
c.Emit(OpCodes.Ldarg_0); | ||
c.EmitDelegate<Func<bool, ExtensionInfo, bool>>((b, info) => | ||
b || info.StartingMissionPath == null | ||
); | ||
} | ||
} |
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,18 +1,58 @@ | ||
using Hacknet; | ||
using Hacknet.Extensions; | ||
using HarmonyLib; | ||
using MonoMod.Cil; | ||
using Mono.Cecil.Cil; | ||
|
||
namespace Pathfinder.BaseGameFixes; | ||
|
||
[HarmonyPatch] | ||
public static class FixTutorialStartup | ||
{ | ||
[HarmonyPrefix] | ||
[HarmonyILManipulator] | ||
[HarmonyPatch(typeof(Programs), nameof(Programs.firstTimeInit))] | ||
internal static void FirstTimeInitSetStartingMissionForTutorial(ILContext il) | ||
{ | ||
ILCursor c = new ILCursor(il); | ||
|
||
c.GotoNext(MoveType.After, | ||
x => x.MatchLdstr("Launching Tutorial...") | ||
); | ||
|
||
c.Emit(OpCodes.Ldarg_1); | ||
c.EmitDelegate<Action<OS>>(os => | ||
{ | ||
if (Settings.IsInExtensionMode && ExtensionLoader.ActiveExtensionInfo?.StartingMissionPath != null) | ||
os.currentMission = (ActiveMission)ComputerLoader.readMission(ExtensionLoader.ActiveExtensionInfo.FolderPath + "/" + ExtensionLoader.ActiveExtensionInfo.StartingMissionPath); | ||
}); | ||
} | ||
[HarmonyILManipulator] | ||
[HarmonyPatch(typeof(AdvancedTutorial), nameof(AdvancedTutorial.Killed))] | ||
internal static bool AdvancedTutorialLoadStartingMission(AdvancedTutorial __instance) | ||
internal static void AdvancedTutorialKilledNullMissionFix(ILContext il) | ||
{ | ||
if (!__instance.os.multiplayer && __instance.os.initShowsTutorial && Settings.IsInExtensionMode && __instance.os.currentMission is null) | ||
__instance.os.currentMission = (ActiveMission)ComputerLoader.readMission(ExtensionLoader.ActiveExtensionInfo.FolderPath + "/" + ExtensionLoader.ActiveExtensionInfo.StartingMissionPath); | ||
return true; | ||
ILCursor c = new ILCursor(il); | ||
|
||
// os.currentMission.sendEmail(os); | ||
c.GotoNext(MoveType.After, | ||
x => x.MatchNop(), | ||
x => x.MatchLdarg(0), | ||
x => x.MatchLdfld(AccessTools.Field(typeof(Module), nameof(Module.os))), | ||
x => x.MatchLdfld(AccessTools.Field(typeof(OS), nameof(OS.currentMission))), | ||
x => x.MatchLdarg(0), | ||
x => x.MatchLdfld(AccessTools.Field(typeof(Module), nameof(Module.os))), | ||
x => x.MatchCallvirt(AccessTools.Method(typeof(ActiveMission), nameof(ActiveMission.sendEmail))) | ||
); | ||
// os.Flags.AddFlag("TutorialComplete"); | ||
ILLabel nextLine = c.MarkLabel(); | ||
c.Index -= 3; | ||
ILLabel continueThisLine = c.MarkLabel(); | ||
c.MoveBeforeLabels(); | ||
|
||
c.Emit(OpCodes.Dup); | ||
c.Emit(OpCodes.Ldnull); | ||
c.Emit(OpCodes.Ceq); | ||
c.Emit(OpCodes.Brfalse, continueThisLine); | ||
c.Emit(OpCodes.Pop); | ||
c.Emit(OpCodes.Br, nextLine); | ||
} | ||
} |
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
Oops, something went wrong.