diff --git a/acd/export_l5x.py b/acd/export_l5x.py index 0f6cd7e..3c7ee84 100644 --- a/acd/export_l5x.py +++ b/acd/export_l5x.py @@ -69,7 +69,7 @@ def __post_init__(self): log.info("Getting records from ACD Comments file and storing in sqllite database") comments_db = DbExtract(os.path.join(self._temp_dir, "Comments.Dat")).read() - for record in comments_db.records: + for record in comments_db.records.record: CommentsRecord(self._cur, record) self._db.commit() diff --git a/acd/generated/sbregion/__init__.py b/acd/generated/sbregion/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/acd/sbregion.py b/acd/sbregion.py index 838592b..72738ff 100644 --- a/acd/sbregion.py +++ b/acd/sbregion.py @@ -4,6 +4,7 @@ from sqlite3 import Cursor from acd.dbextract import DatRecord +from acd.generated.sbregion.fafa_sbregions import FafaSbregions @dataclass @@ -12,7 +13,22 @@ class SbRegionRecord: dat_record: DatRecord def __post_init__(self): - if self.dat_record.identifier == b'\xfa\xfa': + + if self.dat_record.identifier == 64250: + r = FafaSbregions.from_bytes(self.dat_record.record.record_buffer) + else: + return + + if self.language_type == "Rung NT": + + query: str = "INSERT INTO comps VALUES (?, ?, ?, ?, ?, ?)" + entry: tuple = ( + r.header.object_id, r.header.parent_id, r.header.record_name, r.header.seq_number, r.header.record_type, + r.record_buffer) + self._cur.execute(query, entry) + + def __post_init__(self): + if self.dat_record.identifier == 64250: record_length_offset = 0 self.record_length = struct.unpack( "I", self.dat_record.record[0: record_length_offset + 4] diff --git a/resources/templates/SbRegion/FAFA_SbRegion.ksy b/resources/templates/SbRegion/FAFA_SbRegion.ksy index e75a0e5..bbd11f6 100644 --- a/resources/templates/SbRegion/FAFA_SbRegion.ksy +++ b/resources/templates/SbRegion/FAFA_SbRegion.ksy @@ -1,5 +1,5 @@ meta: - id: fafa_comps + id: fafa_sbregions endian: le tags: - version: 33 @@ -12,21 +12,7 @@ seq: size: record_length - 144 - 4 types: header: - instances: - oridinal: - pos: 0x04 + seq: + - id: sb_regions type: u2 - record_type: - pos: 0x06 - type: u2 - object_id: - pos: 0x10 - type: u4 - parent_id: - pos: 0x14 - type: u4 - record_name: - pos: 0x18 - type: str - size: 124 - encoding: UTF-16 + diff --git a/setup.py b/setup.py index c0ec3fe..07c8c05 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,9 @@ def run(self): subprocess.run( ["ksc", "-t", "python", "--outdir", "acd/generated/comps/", "--python-package", "acd.generated.comps", "resources/templates/Comps/FAFA_Comps.ksy"]) - _install.run(self) + subprocess.run( + ["ksc", "-t", "python", "--outdir", "acd/generated/sbregion/", "--python-package", "acd.generated.sbregion", + "resources/templates/SbRegion/FAFA_SbRegion.ksy"]) subprocess.run( ["ksc", "-t", "python", "--outdir", "acd/generated/comps/", "--python-package", "acd.generated.comps", "resources/templates/Comps/FDFD_Comps.ksy"])