Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
964 B · 20 lines
Python
at main
123456789101112131415161718192021"""Keep the game's original text parser callable under a new class name."""import sys
from classfile import ClassFilefrom patch_manifest import ORIGINAL_PARSER, ORIGINAL_PARSER_KEPT_AS
def renamed_original_parser(classes): """Bytes of the game's Preprocessor class, renamed to PreprocessorRules.
Reads the .orig backup when the patch is already installed, so rebuilding or reinstalling over an installed patch works.""" backup = classes / (ORIGINAL_PARSER + ".class.orig") source = backup if backup.is_file() else classes / (ORIGINAL_PARSER + ".class") parsed = ClassFile(source.read_bytes()) if "TemplateCompiler/JevBridge" in parsed.utf8_strings(): sys.exit("%s is this patch's class and its .orig backup is gone; reinstall Facade" % source) if parsed.replace_in_utf8({ORIGINAL_PARSER: ORIGINAL_PARSER_KEPT_AS}) == 0: sys.exit("could not find the class name inside %s" % source) return parsed.to_bytes()