From 5632df406b141f09805fe7d49d99efd475dfe70d Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Tue, 15 Dec 2020 23:27:35 +0000 Subject: [PATCH] Fix colliderinit.py to run from project root (#531) * Now works from root but not from overlayhelpers * Fix to run from anywhere --- tools/csdis.py | 6 +++--- tools/overlayhelpers/colliderinit.py | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/csdis.py b/tools/csdis.py index cfc266719..6088cfede 100755 --- a/tools/csdis.py +++ b/tools/csdis.py @@ -2,8 +2,7 @@ from overlayhelpers import filemap -import argparse -import struct +import argparse, os, struct """ Enumerations @@ -472,8 +471,9 @@ def main(): print(file_result) print() + script_dir = os.path.dirname(os.path.realpath(__file__)) cs_data = None - with open("baserom/" + file_result.name, "rb") as ovl_file: + with open(script_dir + "/../baserom/" + file_result.name, "rb") as ovl_file: ovl_file.seek(file_result.offset) cs_data = [i[0] for i in struct.iter_unpack(">I", bytearray(ovl_file.read()))] if cs_data is not None: diff --git a/tools/overlayhelpers/colliderinit.py b/tools/overlayhelpers/colliderinit.py index b35a4b34e..9d958405f 100755 --- a/tools/overlayhelpers/colliderinit.py +++ b/tools/overlayhelpers/colliderinit.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import os import struct import argparse from filemap import FileResult, GetFromVRam, GetFromRom @@ -223,7 +224,9 @@ else: print("ItemInit type must specify number of elements") exit() -ovlFile = open("../../baserom/" + fileResult.name, "rb") +script_dir = os.path.dirname(os.path.realpath(__file__)) + +ovlFile = open(script_dir + "/../../baserom/" + fileResult.name, "rb") ovlData = bytearray(ovlFile.read()) ovlFile.close()