diff --git a/replacements/96432fa895dbccc686e83cd3b1b6eacf b/replacements/96432fa895dbccc686e83cd3b1b6eacf index 674f5ca..d2a43ed 100644 --- a/replacements/96432fa895dbccc686e83cd3b1b6eacf +++ b/replacements/96432fa895dbccc686e83cd3b1b6eacf @@ -42,3 +42,14 @@ 22938:;」\ 23078:「カレーはこの世で一番尊くて神聖な素晴らしい料理です。@それとおにぎりを同一扱いするなんて断固許せません。@いいですか?@!s0カ!w100レ!w100ー!w100は!w100四!w100大!w100河!w100川!w100文!w100明!w100に!w100匹!w100敵!w100す!w100る!w100第!w100五!w100の!w100文!w100明!w100と!w100し!w100て!w100古!w100代!w100イ!w100ン!w100ド!w100に!w100生!w100ま!w100れ!w100、!w100ア!w100シ!w100ョ!w100カ!w100王!w100の!w100時!w100代!w100に!w100カ!w100ピ!w100ラ!w100城!w100で!w100シ!w100ャ!w100カ!w100の!w100生!w100誕!w100に!w100万!w100国!w100食!w100文!w100化!w100博!w100覧!w100会!w100が!w100絶!w100賛!w100し!w100て!w100ミ!w100シ!w100ュ!w100ラ!w100ン!w100ぐ!w100る!w100ぐ!w100る!w100エ!w100ッ!w100フ!w100ェ!w100ル!w100塔!w100す!w100ら!w100も!w100カ!w100レ!w100ー!w100漬!w100け!w100を!w100ぐ!w100つ!w100ぐ!w100つ!w100煮!w100込!w100ん!w100で!w100タ!w100ー!w100メ!w100リ!w100ッ!w100ク!w100が!w100寝!w100て!w100も!w100覚!w100め!w100て!w100も!w100カ!w100レ!w100ー!w100カ!w100レ!w100ー!w100カ!w100レ!w100ー!w100カ!w100レ!w100ー!w100……」!sd「…ちょっと圭一さん!¥ 23087: 何をふらふらしてますのー!!@ 後片付けもお料理の一部ですのよー!!」@ +25487: 腕を風車のように大きくゆっくりと回し…@ +# This line sucks beacuse it uses single width characters like its nothing +25803: 「園崎さ〜ん、7番テーブルにDXパフェを5つお願いします〜!」@ +-25803 +39425: 自分の名前が突然出て…、びっくりたのは俺だけのようだった…。¥ +40913:!s100「げげげげげげげげげげげげげげげげげげげげげげげげげげげげげ!!!sd 出来た、全部出来た!@ 私が殺したいヤツは…これで全員…!!!@げげげげげげげげげげげげげげげげげげげげげげげげげげげげげげげげげげげ!!」@ …あの日、魅音が俺に残した最後の言葉が…蘇る!s100「……今日を境に魅音が戻ってくることはもうない。」!sd 今日以降、もし私の姿があったとしても、¥ +-40913 +40918:; +40923:; +40925:それは姿だけ。!w800 …私の姿をした鬼だから。@ +40926:; diff --git a/src/fix.py b/src/fix.py index 71b2a3d..08b7007 100644 --- a/src/fix.py +++ b/src/fix.py @@ -4,6 +4,9 @@ import scripter import config import hashlib +import replacements + +excludes = ['zamyo gorrino'] def open_onikakushi() -> str: @@ -18,51 +21,22 @@ def open_onikakushi() -> str: print(f"Could not open original script path {config.get('original_path')}") exit(1) - replacementsfile = None - try: - replacementsfile = open('replacements/' + md5hash) - except: - print(f"The original script file with hash {md5hash} does not have a matching replacement file, no replacements will be executed") - outpath = 'tmp/onikakushi.txt' outfile = open(outpath, 'w', encoding='shift_jisx0213') - replacements = {} - exclude = [] - - # Parse replacements file - # Syntax: - # - '-' -> exclude this line - # - Begins with '#' -> comment - # - ':' -> replace the line in original script with this string - if replacementsfile != None: - try: - for line in replacementsfile: - if line.startswith('#'): - continue - if line.startswith('-'): - exclude.append(int(line[1:])) - continue - split_line = line.split(':', 1) - offset_number = int(split_line[0]) - replace_string = split_line[1] - replacements[offset_number] = replace_string - except: - print(f"Malformed replacement file on {md5hash}, line: {line}") - exit(1) + repls = replacements.get_replacements(md5hash) + global excludes + excludes = replacements.get_excludes(md5hash) for i, line in enumerate(origfile): - if i+1 not in exclude and i+1 not in replacements: + if i+1 not in repls: outfile.write(fix_common_displaced_commands(line)+'\n') else: - outfile.write(replacements[i+1]) + outfile.write(repls[i+1]) outfile.close() origfile.close() - if replacementsfile != None: - replacementsfile.close() - return outpath diff --git a/src/flow.py b/src/flow.py index 71f2aa4..519dd70 100644 --- a/src/flow.py +++ b/src/flow.py @@ -51,6 +51,24 @@ script_flow = [ CsvEntry("Watanagasi.csv", '2/wata_001.txt', 0, 963), CsvEntry("Watanagasi_day2.csv", '2/wata_002.txt', 0, 919), CsvEntry("Watanagasi_day3.csv", '2/wata_003.txt', 0, 1064), + CsvEntry("Watanagasi_day4.csv", '2/wata_004.txt', 0, 1035), + CsvEntry("Watanagasi_day5.csv", '2/wata_005.txt', 0, 1344), + CsvEntry("Watanagasi_day6.csv", '2/wata_006.txt', 0, 96), + CsvEntry("Watanagasi_day7.csv", '2/wata_007.txt', 0, 764), + CsvEntry("Watanagasi_day8.csv", '2/wata_008.txt', 0, 1529), + CsvEntry("Watanagasi_day9.csv", '2/wata_009.txt', 0, 719), + CsvEntry("Watanagasi_day9_2.csv", '2/wata_009_02.txt', 0, 376), + CsvEntry("Watanagasi_day10.csv", '2/wata_010.txt', 0, 604), + CsvEntry("Watanagasi_day10_2.csv", '2/wata_010_02.txt', 0, 463), + CsvEntry("Watanagasi_day10_3.csv", '2/wata_010_03.txt', 0, 638), + CsvEntry("Watanagasi_day10_4.csv", '2/wata_010_04.txt', 0, 490), + CsvEntry("Watanagasi_day11.csv", '2/wata_011.txt', 0, 395), + CsvEntry("Watanagasi_day11_2.csv", '2/wata_011_02.txt', 0, 972), + CsvEntry("Watanagasi_day12.csv", '2/wata_012.txt', 0, 363), + CsvEntry("Watanagasi_day12_2.csv", '2/wata_012_02.txt', 0, 949), + CsvEntry("Watanagasi_day12_3.csv", '2/wata_012_03.txt', 0, 701), + CsvEntry("Watanagasi_Ep1.csv", '2/wata_ep_01.txt', 0, 329), + CsvEntry("Watanagasi_Ep2.csv", '2/wata_ep_02.txt', 0, 453), ] # "gamestart" : [ # 'onik_000.txt', diff --git a/src/orig.py b/src/orig.py index 5041fcf..abee3ab 100755 --- a/src/orig.py +++ b/src/orig.py @@ -93,6 +93,7 @@ def write_translated(outfile, origfile, translation_file_paths): print(f'- reading "{transfilepath}"') structure = parser.parse_to_structure(transfilepath) + for line in origfile: # --- Debug --- global debug_current_line @@ -121,7 +122,7 @@ def write_translated(outfile, origfile, translation_file_paths): # ------------- # TODO: Bad code - if line_jp+'\n' != line and not transfilepath.endswith("Opening.csv") and not transfilepath.endswith("Sub_Tips_099.csv"): + if line_jp+'\n' != line and not transfilepath.endswith("Opening.csv") and not transfilepath.endswith("Sub_Tips_099.csv") and debug_current_line not in fix.excludes: print() print(" ------------------------------------------------------") print(" ! NO THAT'S WRONG! !") diff --git a/src/replacements.py b/src/replacements.py new file mode 100644 index 0000000..94594b7 --- /dev/null +++ b/src/replacements.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 + +def get_replacements(md5hash: str) -> dict: + replacementsfile = None + try: + replacementsfile = open('replacements/' + md5hash) + except: + print(f"The original script file with hash {md5hash} does not have a matching replacement file, no replacements will be executed") + + replacements = {} + + # Parse replacements file + # Syntax: + # - '-' -> exclude this line + # - Begins with '#' -> comment + # - ':' -> replace the line in original script with this string + if replacementsfile != None: + try: + for line in replacementsfile: + if line.startswith('#'): + continue + if line.startswith('-'): + continue + split_line = line.split(':', 1) + offset_number = int(split_line[0]) + replace_string = split_line[1] + replacements[offset_number] = replace_string + except: + print(f"Malformed replacement file on {md5hash}, line: {line}") + exit(1) + + replacementsfile.close() + + return replacements + +def get_excludes(md5hash: str) -> list: + replacementsfile = None + try: + replacementsfile = open('replacements/' + md5hash) + except: + print(f"The original script file with hash {md5hash} does not have a matching replacement file, no replacements will be executed") + + exclude = [] + + # Parse replacements file + # Syntax: + # - '-' -> exclude this line + # - Begins with '#' -> comment + # - ':' -> replace the line in original script with this string + if replacementsfile != None: + for line in replacementsfile: + if not line.startswith('-'): + continue + exclude.append(int(line[1:])) + + + replacementsfile.close() + + return exclude diff --git a/src/scripter.py b/src/scripter.py index f279ee3..fdf6ed7 100644 --- a/src/scripter.py +++ b/src/scripter.py @@ -89,12 +89,11 @@ def is_double_width(char: str) -> bool: (0x201c, 0x201d), # The characters “ ” (0x2026, 0x2026), # The character … (9734, 9734), # ☆ (Nscripter treats it like a dw character) - + (215, 215), # × (treated as a command when it shouldnt) ] for start, end in japanese_ranges: - #if start <= ord(char[0]) <= end: - if 0xFF < ord(char[0]): + if 0xFF < ord(char[0]) or start <= ord(char[0]) <= end: return True return False