Skip to content

Commit

Permalink
AQM remove logging (1.0.1) and SpaceCore harmony_invalidate (for tran…
Browse files Browse the repository at this point in the history
…spilers).
  • Loading branch information
spacechase0 committed Nov 11, 2022
1 parent 60037e3 commit 1e85e96
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
2 changes: 0 additions & 2 deletions AQualityMod/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ public static class CaskObjectDropInPatch
{
public static IEnumerable<CodeInstruction> Transpiler(ILGenerator gen, MethodBase original, IEnumerable<CodeInstruction> insns)
{
Log.Debug("meth:" + original);
List<CodeInstruction> ret = new();
foreach (var insn in insns)
{
Log.Debug("insn:" + insn);
if (insn.opcode == OpCodes.Ldc_I4_4)
{
insn.opcode = OpCodes.Ldc_I4_6;
Expand Down
2 changes: 1 addition & 1 deletion AQualityMod/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "A Quality Mod",
"Author": "spacechase0",
"Version": "1.0.0",
"Version": "1.0.1",
"Description": "...",
"UniqueID": "spacechase0.AQualityMod",
"EntryDll": "AQualityMod.dll",
Expand Down
24 changes: 24 additions & 0 deletions SpaceCore/Framework/Commands.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;
using System.Linq;
using System.Text;
using HarmonyLib;
using Microsoft.Xna.Framework.Graphics;
using SpaceShared;
using StardewModdingAPI;
Expand All @@ -16,6 +17,7 @@ internal static void Register()
Command.Register("asset_invalidate", Commands.InvalidateCommand);
Command.Register("exttilesheets_dump", Commands.DumpTilesheetsCommand);
Command.Register("dump_spacecore_skills", Commands.DumpSkills);
Command.Register("harmony_invalidate", Commands.HarmonyInvalidate);
//Command.register( "test", ( args ) => Game1.player.addItemByMenuIfNecessary( new TestObject() ) );
//SpaceCore.modTypes.Add( typeof( TestObject ) );
}
Expand Down Expand Up @@ -150,5 +152,27 @@ private static void DumpTilesheetsCommand(string[] args)
}
}
}

private static void HarmonyInvalidate(string[] args)
{
if (args.Length == 0)
{
Log.Info("You must specify a method, like: harmony_invalidate StardewValley.CraftingRecipe:consumeIngredients");
return;
}

var meth = AccessTools.Method(args[0]);
if (meth == null)
{
Log.Debug("Method not found; note this doesn't work with ambiguous matches");
return;
}

// TODO: Unpatch/repatch the same methods instead of constantly adding new patches
var dummyPrefix = AccessTools.Method(typeof(Commands), nameof(DummyPrefixForHarmonyInvalidate));
SpaceCore.Instance.Harmony.Patch(meth, new HarmonyMethod(dummyPrefix));
}

private static void DummyPrefixForHarmonyInvalidate() { }
}
}
2 changes: 1 addition & 1 deletion SpaceCore/SpaceCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ internal class SpaceCore : Mod
/*********
** Fields
*********/
private Harmony Harmony;
internal Harmony Harmony;

/// <summary>Handles migrating legacy data for a save file.</summary>
private LegacyDataMigrator LegacyDataMigrator;
Expand Down
1 change: 0 additions & 1 deletion Spacechase0.Stardew.sln
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ Global
{AACF284D-8352-4727-9F9E-9916BA2266AF} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA}
{1D6C6511-624C-4332-9E70-486F81A28888} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA}
{CB5BB6E2-D963-4A27-A3B9-1E4BB068983B} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA}
{B5127FFB-A748-44FF-882E-5279B0F7B279} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA}
{19EB9934-6F62-401B-9447-3661BAE212A0} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA}
{7AA1C02E-9099-4C1A-B8AF-AC1966B337E5} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA}
{104FCF4D-7776-4C16-94CE-EDE8209D6D9F} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA}
Expand Down

0 comments on commit 1e85e96

Please sign in to comment.