RimWorld

RimWorld

Ben Lubar's Android Tiers Patches
SlippyCheeze 12 Apr, 2022 @ 8:47am
[BUG] Exception when SOS2 is not installed
I'm cutting the error only because I tracked down what triggers it – harmony apparently doesn't like the way you handle the "optional" nature of the patch in
ShipInteriorMod2_HasSpaceSuitSlow_Patch.cs
or something.

It looks like the "approved" way of making a patch do nothing if there is no target method is using the `Prepare` feature instead: https://harmony.pardeike.net/articles/patching-auxilary.html#prepare and returning false.

I can throw a patch your way, if you want, but I don't have a compiler environment set up for rimworld or anything. That should let you check for the SOS2 mod and disable patching if it isn't present.


[me.lubar.AndroidTiersPatches][ERR] Failed to apply Harmony patches for me.lubar.AndroidTiersPatches. Exception was: HarmonyLib.HarmonyException: Patching exception in method null ---> System.ArgumentException: Undefined target method for patch method static System.Void BenLubarsAndroidTiersPatches.ShipInteriorMod2_HasSpaceSuitSlow_Patch::Postfix(System.Boolean& __result, Verse.Pawn pawn) at HarmonyLib.PatchClassProcessor.PatchWithAttributes (System.Reflection.MethodBase& lastOriginal) [0x00047] in <afae5a8d84e24373b604e1b6d209d116>:0 at HarmonyLib.PatchClassProcessor.Patch () [0x00068] in <afae5a8d84e24373b604e1b6d209d116>:0 --- End of inner exception stack trace --- at HarmonyLib.PatchClassProcessor.ReportException (System.Exception exception, System.Reflection.MethodBase original) [0x00127] in <afae5a8d84e24373b604e1b6d209d116>:0 at HarmonyLib.PatchClassProcessor.Patch () [0x00093] in <afae5a8d84e24373b604e1b6d209d116>:0 at HarmonyLib.Harmony.<PatchAll>b__10_0 (System.Type type) [0x00007] in <afae5a8d84e24373b604e1b6d209d116>:0 at HarmonyLib.CollectionExtensions.Do[T] (System.Collections.Generic.IEnumerable`1[T] sequence, System.Action`1[T] action) [0x00014] in <afae5a8d84e24373b604e1b6d209d116>:0 at HarmonyLib.Harmony.PatchAll (System.Reflection.Assembly assembly) [0x00006] in <afae5a8d84e24373b604e1b6d209d116>:0 at HugsLib.ModBase.ApplyHarmonyPatches () [0x0009a] in <a56dbe2cf5184fe991f5fb736b3081b0>:0
< >
Showing 1-5 of 5 comments
SlippyCheeze 19 Apr, 2022 @ 12:53am 
FWIW, I added a small patch for myself, and it fixes the problem: no more exception because a null value was received from the target method. Not the absolute minimalist patch, but close enough.

private static Lazy<bool> hasSOS2 => new Lazy<bool>((Func<bool>) (() => System.Type.GetType("SaveOurShip2.ShipInteriorMod2,ShipsHaveInsides", false) != (System.Type) null)); public static bool Prepare() => ShipInteriorMod2_HasSpaceSuitSlow_Patch.hasSOS2.Value;
Scorpio 6 Sep, 2022 @ 12:46pm 
Originally posted by SlippyCheeze:
FWIW, I added a small patch for myself, and it fixes the problem: no more exception because a null value was received from the target method. Not the absolute minimalist patch, but close enough.

private static Lazy<bool> hasSOS2 => new Lazy<bool>((Func<bool>) (() => System.Type.GetType("SaveOurShip2.ShipInteriorMod2,ShipsHaveInsides", false) != (System.Type) null)); public static bool Prepare() => ShipInteriorMod2_HasSpaceSuitSlow_Patch.hasSOS2.Value;


can you share the file?
nchorbajian 12 Sep, 2022 @ 8:36pm 
I have compiled what SlippyCheeze wrote here and it does not show errors on startup without SOS2
Google Drive [drive.google.com] (gameplay idk if anything changed yet).
Scorpio 13 Sep, 2022 @ 2:33am 
Originally posted by nchorbajian:
I have compiled what SlippyCheeze wrote here and it does not show errors on startup without SOS2
Google Drive [drive.google.com] (gameplay idk if anything changed yet).

strangely still errors here wonder if its because of the SOS2 experimental version?
Last edited by Scorpio; 13 Sep, 2022 @ 4:53am
nchorbajian 13 Sep, 2022 @ 3:34pm 
Ah maybe. They did change some stuff on their shipInteriorMod2 source.
< >
Showing 1-5 of 5 comments
Per page: 1530 50