From d80b9d56c8e60224262a10cf47585b88be6c9c3c Mon Sep 17 00:00:00 2001 From: deceivedhornet Date: Thu, 11 Jun 2026 02:06:56 -0400 Subject: [PATCH] Include whole file path for searchability of references to .mbr --- ingest_database.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/ingest_database.py b/ingest_database.py index e4e88da..ee31a26 100644 --- a/ingest_database.py +++ b/ingest_database.py @@ -3,7 +3,11 @@ import json import re # 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" def clean_dbr_value(val): @@ -39,18 +43,18 @@ def parse_dbr_file(file_path): return file_data def main(): - if not os.path.exists(VANILLA_DB_DIR): - print(f"Error: Vanilla database directory not found at: {VANILLA_DB_DIR}") + if not os.path.exists(VANILLA_RECORDS_DIR): + print(f"Error: Vanilla records directory not found at: {VANILLA_RECORDS_DIR}") 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...") processed_directories = 0 total_files_mapped = 0 # 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 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, # 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 # Determine the relative path to recreate the mirror structure