Skip to content

Commit

Permalink
Fix RimFridge warnings (#457)
Browse files Browse the repository at this point in the history
Changed current map usage patches to accept another argument (`logIfMissingMethod`) which, if true, will stop warnings about missing methods.

Changed RimFridge to set this argument to true, stopping warning. The patch is kept for RimFridge forks that haven't fixed this bug (currently the only 1.5 fork has this issue fixed, but there may be a new ones in the future).
  • Loading branch information
SokyranTheDragon authored Aug 8, 2024
1 parent 50a233c commit e800646
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Source/Mods/RimFridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public RimFridgeCompat(ModContentPack mod)
// Current map usage
// Not needed for the fork made by "Not Harry" (at the moment, the only 1.5 fork), but other forks may need this.
{
PatchingUtilities.ReplaceCurrentMapUsage("RimFridge.Patch_ReachabilityUtility_CanReach:Prefix", false);
PatchingUtilities.ReplaceCurrentMapUsage("RimFridge.Patch_ReachabilityUtility_CanReach:Prefix", false, false);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions Source/PatchingUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public static void ReplaceCurrentMapUsage(Type type, string methodName)
}
}

public static void ReplaceCurrentMapUsage(string typeColonName, bool logIfNothingPatched = true)
public static void ReplaceCurrentMapUsage(string typeColonName, bool logIfNothingPatched = true, bool logIfMissingMethod = true)
{
if (typeColonName.NullOrEmpty())
{
Expand All @@ -379,12 +379,12 @@ public static void ReplaceCurrentMapUsage(string typeColonName, bool logIfNothin

var method = AccessTools.DeclaredMethod(typeColonName) ?? AccessTools.Method(typeColonName);
if (method != null)
ReplaceCurrentMapUsage(method, logIfNothingPatched);
else
ReplaceCurrentMapUsage(method, logIfNothingPatched, logIfMissingMethod);
else if (logIfMissingMethod)
Log.Warning($"Trying to patch current map usage for null method ({typeColonName}). Was the method removed or renamed?");
}

public static void ReplaceCurrentMapUsage(MethodBase method, bool logIfNothingPatched = true)
public static void ReplaceCurrentMapUsage(MethodBase method, bool logIfNothingPatched = true, bool logIfMissingMethod = true)
{
if (method != null)
{
Expand All @@ -394,7 +394,7 @@ public static void ReplaceCurrentMapUsage(MethodBase method, bool logIfNothingPa

MpCompat.harmony.Patch(method, transpiler: transpiler);
}
else
else if (logIfMissingMethod)
Log.Warning("Trying to patch current map usage for null method. Was the method removed or renamed?");
}

Expand Down

0 comments on commit e800646

Please sign in to comment.