Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated and fixed ReplaceMethod #499

Merged

Conversation

SokyranTheDragon
Copy link
Member

  • The opcode of replaced method is based on the new method, rather than the one it replaces
  • Added extraInstructionsAfter argument to insert instructions after the targeted code instruction
  • The extraInstructions argument was renamed to extraInstructionsBefore
  • Made the method replacement (and the argument for it) optional
    • The method can now be used to insert extra instructions before/after the targeted method without replacing it
  • An exception will be thrown if the IEnumerable<CodeInstruction> is null
    • It feels like the best course of action, as not doing anything will cause an exception later on and returning anything (or nothing) could have an unexpected consequences
  • An error will be displayed if the method was provided a null target method
  • An error will be displayed if the method was not provided a replacement method or a function to insert extra instructions
  • Updated the compat for "A RimWorld of Magic" to support the new method signature

- The opcode of replaced method is based on the new method, rather than the one it replaces
- Added `extraInstructionsAfter` argument to insert instructions after the targeted code instruction
- The `extraInstructions` argument was renamed to `extraInstructionsBefore`
- Made the method replacement (and the argument for it) optional
  - The method can now be used to insert extra instructions before/after the targeted method without replacing it
- An exception will be thrown if the `IEnumerable<CodeInstruction>` is null
  - It feels like the best course of action, as not doing anything will cause an exception later on and returning anything (or nothing) could have an unexpected consequences
- An error will be displayed if the method was provided a null target method
- An error will be displayed if the method was not provided a replacement method or a function to insert extra instructions
- Updated the compat for "A RimWorld of Magic" to support the new method signature
@notfood notfood merged commit 60f95c6 into rwmt:master Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants