Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added new hashes for Obscure 2 HVP Tools
  • Loading branch information
bartlomiejduda committed Dec 22, 2022
1 parent 3c89e49 commit bc411cd
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 8 deletions.
Expand Up @@ -19,6 +19,8 @@
import lzokay
from reversebox.common.common import convert_int_to_hex_string
from reversebox.io_files.file_handler import FileHandler

from constants import STR_ENCODING
from objects import HashEntryObject, DirectoryEntryObject, RepackInfoObject


Expand Down Expand Up @@ -62,7 +64,7 @@ def export_data(hvp_path: str) -> Optional[tuple]:
for file in f:
if file.endswith(".txt"):
hash_list_path = os.path.join(r, file)
hash_list_file = open(hash_list_path, "rt")
hash_list_file = open(hash_list_path, "rt", encoding=STR_ENCODING)
for line in hash_list_file:
if line.startswith("#"):
continue
Expand Down Expand Up @@ -176,7 +178,7 @@ def get_subentries(dir_entries: List[DirectoryEntryObject], entry_number: int, f

# print("Generating repack info...")
# repack_info_file_path = hvp_path + "_repack_info.txt"
# repack_info_file = open(repack_info_file_path, "wt")
# repack_info_file = open(repack_info_file_path, "wt", encoding=STR_ENCODING)
# for repack_entry in repack_info_list:
# out_line = repack_entry.entry_hash + \
# "|||" + str(repack_entry.entry_type) + \
Expand Down
2 changes: 2 additions & 0 deletions NEW Tools/ObsCure 2/ObsCure 2 HVP Tools/constants.py
@@ -0,0 +1,2 @@

STR_ENCODING = "windows-1250"
Expand Up @@ -14,6 +14,8 @@

from operator import attrgetter
from typing import List

from constants import STR_ENCODING
from custom_filenames import CUSTOM_FILENAMES
from objects import HashEntryObject
from reversebox.common.common import convert_int_to_hex_string
Expand All @@ -28,7 +30,7 @@
print("Starting to create custom hash list...")

# read hook list (to check for duplicates)
hook_list_file = open("hash_lists\\obscure_2_hook_list.txt", "rt")
hook_list_file = open("hash_lists\\obscure_2_hook_list.txt", "rt", encoding=STR_ENCODING)
for line in hook_list_file:
if line.startswith("#"):
continue
Expand All @@ -44,7 +46,7 @@
# (also check for issues, e.g. duplicates, wrong length etc.)
for custom_filename in CUSTOM_FILENAMES:
custom_hash_entry: HashEntryObject = HashEntryObject(
crc=crc32_handler.calculate_crc32(bytes(custom_filename.encode("utf8"))),
crc=crc32_handler.calculate_crc32(bytes(custom_filename.encode(STR_ENCODING))),
path_length=len(custom_filename),
file_path=custom_filename
)
Expand All @@ -60,7 +62,7 @@
f" for path {custom_hash_entry.file_path}! Please remove it!")

calculated_crc = crc32_handler.calculate_crc32(
bytes(custom_hash_entry.file_path.encode("utf8")[0:custom_hash_entry.path_length]))
bytes(custom_hash_entry.file_path.encode(STR_ENCODING)[0:custom_hash_entry.path_length]))
if calculated_crc != custom_hash_entry.crc:
raise Exception("Wrong CRC value! Please correct it!")

Expand All @@ -73,7 +75,7 @@
custom_hash_list: list[HashEntryObject] = sorted(custom_hash_list, key=attrgetter('crc'))

# write results to file if no exception occurred at checking phase
custom_hash_file = open("hash_lists\\obscure_2_custom_hash_list.txt", "wt")
custom_hash_file = open("hash_lists\\obscure_2_custom_hash_list.txt", "wt", encoding=STR_ENCODING)
for custom_entry in custom_hash_list:
out_line: str = convert_int_to_hex_string(custom_entry.crc) + "|||" + str(
custom_entry.path_length) + "|||" + custom_entry.file_path + "\n"
Expand Down
6 changes: 4 additions & 2 deletions NEW Tools/ObsCure 2/ObsCure 2 HVP Tools/create_hook_list.py
Expand Up @@ -15,6 +15,8 @@

import os
from operator import attrgetter

from constants import STR_ENCODING
from objects import HashDumpObject

print("Starting create hook list script...")
Expand All @@ -32,7 +34,7 @@
if file.endswith(".txt"):
print("Opening file ", file)
hash_dump_path = os.path.join(r, file)
hash_dump_file = open(hash_dump_path, "rt")
hash_dump_file = open(hash_dump_path, "rt", encoding=STR_ENCODING)
for line in hash_dump_file:
if line.startswith("#"):
continue
Expand Down Expand Up @@ -64,7 +66,7 @@
hash_list_without_duplicates: list[HashDumpObject] = sorted(hash_list_without_duplicates, key=attrgetter('crc'))


output_file = open("hash_lists/obscure_2_hook_list.txt", "wt")
output_file = open("hash_lists/obscure_2_hook_list.txt", "wt", encoding=STR_ENCODING)

for hash_clean_entry in hash_list_without_duplicates:
out_line = "0x" + hash_clean_entry.crc + "|||" + str(hash_clean_entry.path_length) \
Expand Down
59 changes: 59 additions & 0 deletions NEW Tools/ObsCure 2/ObsCure 2 HVP Tools/custom_filenames.py
Expand Up @@ -3730,6 +3730,65 @@
"adid_004.bmp",
"debug.xmc",

"x000.dat",
"x001.dat",
"x002.dat",
"x003.dat",
"x004.dat",
"x005.dat",
"x006.dat",
"x007.dat",
"x008.dat",
"x009.dat",
"x010.dat",
"x100.dat",
"x000",
"x001",
"x002",
"x003",
"x004",
"x005",
"x006",
"x007",
"x008",
"x009",
"x010",
"x100",
"w000",
"w001",
"w002",
"w003",
"w004",
"w005",
"w006",
"w007",
"w008",
"w009",
"w010",
"w011",
"w012",
"w000.dat",
"w001.dat",
"w002.dat",
"w003.dat",
"w004.dat",
"w005.dat",
"w006.dat",
"w007.dat",
"w008.dat",
"w009.dat",
"w010.dat",
"w011.dat",
"w012.dat",

"pllo.bik",
"hydr.bik",

"ch09_01_avance jardin jed_b.ogg",
"ch03_c004_projo_b.ogg",
"ch12_musée_confrerie_b.ogg",
"ch12_entrée_confrérie_b.ogg",
"ch12_confrérie_l.ogg",


]

0 comments on commit bc411cd

Please sign in to comment.