diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2022-03-12 22:50:42 -0500 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2022-03-12 22:50:42 -0500 |
commit | 732acf1d4f85b82ed20a69e66224b89db9a06f3f (patch) | |
tree | 50d60af5012d553feefb0b94aa59ec2baf906a8b /tools/make_patch.c | |
parent | f33a04193092e3df8c9b1ac4f560018b95925f61 (diff) |
Allow `{patch offset length}` (necessary for pokegold)
Diffstat (limited to 'tools/make_patch.c')
-rw-r--r-- | tools/make_patch.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/make_patch.c b/tools/make_patch.c index a67a4a399..d83ffc76c 100644 --- a/tools/make_patch.c +++ b/tools/make_patch.c @@ -214,6 +214,9 @@ void interpret_command(char *command, const struct Symbol *current_hook, const s // Use the arguments if (!strcmp(command, "patch") || !strcmp(command, "PATCH") || !strcmp(command, "patch_") || !strcmp(command, "PATCH_")) { + if (argc > 2) { + error_exit("Error: Invalid arguments for command: \"%s\"", command); + } if (!current_hook) { error_exit("Error: No current patch for command: \"%s\"", command); } @@ -224,8 +227,13 @@ void interpret_command(char *command, const struct Symbol *current_hook, const s if (fseek(new_rom, current_offset, SEEK_SET)) { error_exit("Error: Cannot seek to \"vc_patch %s\" in the new ROM\n", current_hook->name); } - const struct Symbol *current_hook_end = symbol_find_cat(symbols, current_hook->name, "_End"); - int length = current_hook_end->offset - current_offset; + int length; + if (argc == 2) { + length = parse_number(argv[1], 0); + } else { + const struct Symbol *current_hook_end = symbol_find_cat(symbols, current_hook->name, "_End"); + length = current_hook_end->offset - current_offset; + } buffer_append(patches, &(struct Patch){current_offset, length}); bool modified = false; if (length == 1) { |