From 94ef64284f6fae595cf5e8f48cc94d4ff3184e14 Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Tue, 21 Mar 2023 02:34:22 -0700 Subject: [PATCH] feat: support addresslib matching for fo4 --- fallout_vr_address_library | 2 +- vr_address_tools.py | 41 ++++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/fallout_vr_address_library b/fallout_vr_address_library index 06fdd91..a8aa3e3 160000 --- a/fallout_vr_address_library +++ b/fallout_vr_address_library @@ -1 +1 @@ -Subproject commit 06fdd91cea3cd2eb1252d52978f1594c5ae34a21 +Subproject commit a8aa3e30d7142cd294cbd31b42d367983d72c21b diff --git a/vr_address_tools.py b/vr_address_tools.py index 0e0d264..fef617e 100755 --- a/vr_address_tools.py +++ b/vr_address_tools.py @@ -200,25 +200,28 @@ async def load_database( except FileNotFoundError: print(f"database.csv not found") - if skyrim: - try: - async with aiofiles.open(os.path.join(path, addresslib), mode="r") as infile: - reader = aiocsv.AsyncDictReader(infile) - async for row in reader: - id = int(row["id"]) - sse = add_hex_strings(row["sse"]) - vr = add_hex_strings(row["vr"]) - if id_vr_status.get(id): - if debug: - print( - f"Database Load Warning: {id} already loaded skipping load from {addresslib}" - ) - else: - id_sse[id] = sse - id_vr[id] = vr - loaded += 1 - except FileNotFoundError: - print(f"{addresslib} not found") + try: + async with aiofiles.open(os.path.join(path, addresslib), mode="r") as infile: + reader = aiocsv.AsyncDictReader(infile) + async for row in reader: + id = int(row["id"]) + sse = add_hex_strings(row.get("sse" if skyrim else "fo4_addr")) + vr = add_hex_strings(row.get("vr" if skyrim else "vr_addr")) + if id_vr_status.get(id): + if debug: + print( + f"Database Load Warning: {id} already loaded skipping load from {addresslib}" + ) + elif vr: + id_sse[id] = sse + id_vr[id] = vr + id_vr_status[id] = { + "sse": sse, + "status": CONFIDENCE["SUGGESTED"], + } + loaded += 1 + except FileNotFoundError: + print(f"{addresslib} not found") try: async with aiofiles.open(os.path.join(path, offsets), mode="r") as infile: