Added ILFailure Util Extension
This commit is contained in:
1 parent
ed22b65bed
commit
ceb5b4b1d1
5 files changed
+29
-16
No files matched your search
@@ -1,10 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CalamityMod.Systems;
|
||||
using CalamityMod.Waters;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MonoMod.Cil;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
@@ -125,6 +122,6 @@ namespace CalamityMod.ILEditing
|
||||
}
|
||||
|
||||
public static void DumpToLog(ILContext il) => CalamityMod.Log.Debug(il.ToString());
|
||||
public static void LogFailure(string name, string reason) => CalamityMod.Log.Warn($"IL edit \"{name}\" failed! {reason}");
|
||||
public static void LogFailure(string name, string reason) => CalamityMod.Log.ILFailure(name, reason);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CalamityMod.ILEditing;
|
||||
using MonoMod.Cil;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
@@ -32,25 +31,25 @@ namespace CalamityMod.Prefixes.VanillaPrefixChanges
|
||||
var cursor = new ILCursor(il);
|
||||
if (!cursor.TryGotoNext(x => x.MatchCallOrCallvirt<ModPrefix>(nameof(ModPrefix.ModifyValue))))
|
||||
{
|
||||
ILChanges.LogFailure("Vanilla Prefix Override", "Unable to locate callvirt (ModPrefix.ModifyValue)");
|
||||
CalamityMod.Log.ILFailure("Vanilla Prefix Override", "Unable to locate callvirt (ModPrefix.ModifyValue)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cursor.Prev.MatchLdloca(out var multLocaIdx))
|
||||
{
|
||||
ILChanges.LogFailure("Vanilla Prefix Override", "Unable to locate Ldloca (mult)");
|
||||
CalamityMod.Log.ILFailure("Vanilla Prefix Override", "Unable to locate Ldloca (mult)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cursor.TryGotoPrev(x => x.MatchLdsfld<PrefixID>(nameof(PrefixID.Count))))
|
||||
{
|
||||
ILChanges.LogFailure("Vanilla Prefix Override", "Unable to locate Ldsfld (PrefixID.Count)");
|
||||
CalamityMod.Log.ILFailure("Vanilla Prefix Override", "Unable to locate Ldsfld (PrefixID.Count)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cursor.Prev.MatchLdloc(out var prefixLocaIdx))
|
||||
{
|
||||
ILChanges.LogFailure("Vanilla Prefix Override", "Unable to locate Ldloc (prefix)");
|
||||
CalamityMod.Log.ILFailure("Vanilla Prefix Override", "Unable to locate Ldloc (prefix)");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using CalamityMod.ILEditing;
|
||||
using CalamityMod.Walls;
|
||||
using CalamityMod.Walls;
|
||||
using Microsoft.Xna.Framework;
|
||||
using MonoMod.Cil;
|
||||
using Terraria;
|
||||
@@ -66,7 +65,7 @@ namespace CalamityMod.Systems
|
||||
|
||||
private static void LogILFailure(string reason)
|
||||
{
|
||||
ILChanges.LogFailure("Support for Wall FrameOffset", reason);
|
||||
CalamityMod.Log.ILFailure("Support for Wall FrameOffset", reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using CalamityMod.ILEditing;
|
||||
using MonoMod.Cil;
|
||||
using Terraria;
|
||||
using Terraria.GameContent.Drawing;
|
||||
@@ -41,7 +40,7 @@ namespace CalamityMod.Systems
|
||||
|
||||
if (!cursor.TryGotoNext(MoveType.After, x => x.MatchCallOrCallvirt<TileDrawing>(getScreenDrawAreaMethod)))
|
||||
{
|
||||
ILChanges.LogFailure("QualityRequirementHook", $"{getScreenDrawAreaMethod} call is missing!");
|
||||
CalamityMod.Log.ILFailure("QualityRequirementHook", $"{getScreenDrawAreaMethod} call is missing!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,13 +50,13 @@ namespace CalamityMod.Systems
|
||||
|
||||
if (mediumReqField == null)
|
||||
{
|
||||
ILChanges.LogFailure("QualityRequirementHook", $"{midQualityRequirementField} field is missing!");
|
||||
CalamityMod.Log.ILFailure("QualityRequirementHook", $"{midQualityRequirementField} field is missing!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (highReqField == null)
|
||||
{
|
||||
ILChanges.LogFailure("QualityRequirementHook", $"{highQualityRequirementField} field is missing!");
|
||||
CalamityMod.Log.ILFailure("QualityRequirementHook", $"{highQualityRequirementField} field is missing!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using log4net;
|
||||
|
||||
namespace CalamityMod
|
||||
{
|
||||
public static partial class CalamityUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Log out formatted message for IL edit Failure
|
||||
/// <para>Format: IL edit "<u>name</u>" failed! <u>reason</u></para>
|
||||
/// </summary>
|
||||
/// <param name="logger">Logger to use</param>
|
||||
/// <param name="name">Name of the IL Edit</param>
|
||||
/// <param name="reason">Reason why this IL Edit has failed</param>
|
||||
public static void ILFailure(this ILog logger, string name, string reason)
|
||||
{
|
||||
logger.Warn($"IL edit \"{name}\" failed! {reason}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user