Skip to content

Commit

Permalink
More sanity checks
Browse files Browse the repository at this point in the history
- check that length of entered old name matches length in file
- character names must be 2 characters or more
  • Loading branch information
ricin committed Jul 5, 2022
1 parent 7331cef commit 347353c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build/
lib/
*.pyd
*.pyc
*.dll
*.zip
*.ctypes
9 changes: 9 additions & 0 deletions edit-vrising-name/edit-vrising-name.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})')
Expand Down Expand Up @@ -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}')
Expand Down

0 comments on commit 347353c

Please sign in to comment.