Include whole file path for searchability of references to .mbr

This commit is contained in:
deceivedhornet 2026-06-11 02:06:56 -04:00
parent 27bd4fc818
commit d80b9d56c8

View file

@ -3,7 +3,11 @@ import json
import re import re
# Paths configuration # Paths configuration
VANILLA_DB_DIR = r"D:\SteamLibrary\steamapps\common\Grim Dawn\database\records" VANILLA_DB_DIR = r"D:\SteamLibrary\steamapps\common\Grim Dawn\database"
# Target scan directory for Phase 1 ingestion
VANILLA_RECORDS_DIR = os.path.join(VANILLA_DB_DIR, "records")
JSON_OUTPUT_DIR = r".\vanilla_json_mirror" JSON_OUTPUT_DIR = r".\vanilla_json_mirror"
def clean_dbr_value(val): def clean_dbr_value(val):
@ -39,18 +43,18 @@ def parse_dbr_file(file_path):
return file_data return file_data
def main(): def main():
if not os.path.exists(VANILLA_DB_DIR): if not os.path.exists(VANILLA_RECORDS_DIR):
print(f"Error: Vanilla database directory not found at: {VANILLA_DB_DIR}") print(f"Error: Vanilla records directory not found at: {VANILLA_RECORDS_DIR}")
return return
print(f"Starting database ingestion from: {VANILLA_DB_DIR}") print(f"Starting database ingestion from: {VANILLA_RECORDS_DIR}")
print("Grouping files by directory level...") print("Grouping files by directory level...")
processed_directories = 0 processed_directories = 0
total_files_mapped = 0 total_files_mapped = 0
# Walk the directory tree # Walk the directory tree
for root, dirs, files in os.walk(VANILLA_DB_DIR): for root, dirs, files in os.walk(VANILLA_RECORDS_DIR):
# Filter for only .dbr files in the current folder # Filter for only .dbr files in the current folder
dbr_files = [f for f in files if f.lower().endswith('.dbr')] dbr_files = [f for f in files if f.lower().endswith('.dbr')]
@ -66,7 +70,17 @@ def main():
# Keep track of the file even if it's completely empty after cleaning, # Keep track of the file even if it's completely empty after cleaning,
# so the compiler knows the file exists in vanilla. # so the compiler knows the file exists in vanilla.
directory_map[filename] = sparse_content
# Determine the relative path back to the base database directory
rel_path = os.path.relpath(root, VANILLA_DB_DIR)
# Reconstruct the standard internal game engine path format
# e.g., "records/skills/playerclass01/willtolive1.dbr"
normalized_game_key = os.path.join(rel_path, filename).replace(os.sep, "/")
# Save using the full normalized path as the dictionary key
directory_map[normalized_game_key] = sparse_content
total_files_mapped += 1 total_files_mapped += 1
# Determine the relative path to recreate the mirror structure # Determine the relative path to recreate the mirror structure