From f40db53cb9ee052ed699688729c521de83e3aadf Mon Sep 17 00:00:00 2001 From: Colin Basnett Date: Sat, 18 Feb 2023 00:28:31 -0800 Subject: [PATCH] Fixed a bug where it was possible to export a PSK with no bones --- io_scene_psk_psa/psk/exporter.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/io_scene_psk_psa/psk/exporter.py b/io_scene_psk_psa/psk/exporter.py index eac69c6..7739e25 100644 --- a/io_scene_psk_psa/psk/exporter.py +++ b/io_scene_psk_psa/psk/exporter.py @@ -30,12 +30,14 @@ def _write_section(fp, name: bytes, data_type: Type[Structure] = None, data: lis def export_psk(psk: Psk, path: str): if len(psk.wedges) > MAX_WEDGE_COUNT: raise RuntimeError(f'Number of wedges ({len(psk.wedges)}) exceeds limit of {MAX_WEDGE_COUNT}') - if len(psk.bones) > MAX_BONE_COUNT: - raise RuntimeError(f'Number of bones ({len(psk.bones)}) exceeds limit of {MAX_BONE_COUNT}') if len(psk.points) > MAX_POINT_COUNT: raise RuntimeError(f'Numbers of vertices ({len(psk.points)}) exceeds limit of {MAX_POINT_COUNT}') if len(psk.materials) > MAX_MATERIAL_COUNT: raise RuntimeError(f'Number of materials ({len(psk.materials)}) exceeds limit of {MAX_MATERIAL_COUNT}') + if len(psk.bones) > MAX_BONE_COUNT: + raise RuntimeError(f'Number of bones ({len(psk.bones)}) exceeds limit of {MAX_BONE_COUNT}') + elif len(psk.bones) == 0: + raise RuntimeError(f'At least one bone must be marked for export') with open(path, 'wb') as fp: _write_section(fp, b'ACTRHEAD')