From 347353c0de871a7b072fc22ceeafb0e32fe2f019 Mon Sep 17 00:00:00 2001 From: ricin Date: Tue, 5 Jul 2022 09:57:28 -0700 Subject: [PATCH] More sanity checks - check that length of entered old name matches length in file - character names must be 2 characters or more --- .gitignore | 7 +++++++ edit-vrising-name/edit-vrising-name.py | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eb03464 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +build/ +lib/ +*.pyd +*.pyc +*.dll +*.zip +*.ctypes diff --git a/edit-vrising-name/edit-vrising-name.py b/edit-vrising-name/edit-vrising-name.py index e77b061..5d88a90 100644 --- a/edit-vrising-name/edit-vrising-name.py +++ b/edit-vrising-name/edit-vrising-name.py @@ -44,6 +44,9 @@ def editCharacterName(bin_file, old, new): if data != old_byte_data: continue + + if old_len != len(old): + continue print(f'\t{Fore.BLUE}---{Style.RESET_ALL}') print(f'\t{Fore.GREEN}Found {Fore.LIGHTCYAN_EX}{data} {Fore.GREEN}at {Fore.YELLOW}{occurrenceOffset} {Fore.WHITE}({Fore.LIGHTCYAN_EX}{int(old_len)}{Style.RESET_ALL})') @@ -76,6 +79,12 @@ def editCharacterName(bin_file, old, new): for old,new in args.rename_pairs: + if (len(new) < 2 or len(old) < 2): + print(f' {Fore.YELLOW}{old}{Fore.GREEN} is {Fore.LIGHTCYAN_EX}{len(old)}{Fore.GREEN} characters{Style.RESET_ALL}') + print(f' {Fore.YELLOW}{new}{Fore.GREEN} is {Fore.LIGHTCYAN_EX}{len(new)}{Fore.GREEN} characters{Style.RESET_ALL}') + print(f'{Fore.RED}Character names must be at least 2 characters. Skipping pair.{Style.RESET_ALL}') + continue + if (len(new) > 20 or len(old) > 20): print(f' {Fore.YELLOW}{old}{Fore.GREEN} is {Fore.LIGHTCYAN_EX}{len(old)}{Fore.GREEN} characters{Style.RESET_ALL}') print(f' {Fore.YELLOW}{new}{Fore.GREEN} is {Fore.LIGHTCYAN_EX}{len(new)}{Fore.GREEN} characters{Style.RESET_ALL}')