Skip to content

Commit

Permalink
CodeMatcher - allow inserting at the end (adding)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Sep 26, 2023
1 parent 896c119 commit 2d88dc8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Harmony/Tools/CodeMatcher/CodeMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,10 @@ public CodeMatcher SetJumpTo(OpCode opcode, int destination, out Label label)
///
public CodeMatcher Insert(params CodeInstruction[] instructions)
{
codes.InsertRange(Pos, instructions);
if (Pos == Length)
codes.AddRange(instructions);
else
codes.InsertRange(PosOrThrow(), instructions);
return this;
}

Expand All @@ -436,7 +439,10 @@ public CodeMatcher Insert(params CodeInstruction[] instructions)
///
public CodeMatcher Insert(IEnumerable<CodeInstruction> instructions)
{
codes.InsertRange(Pos, instructions);
if (Pos == Length)
codes.AddRange(instructions);
else
codes.InsertRange(PosOrThrow(), instructions);
return this;
}

Expand Down

0 comments on commit 2d88dc8

Please sign in to comment.