From 329baa54a900b579ff660a8544d559aaecb8fbb3 Mon Sep 17 00:00:00 2001 From: Thanatos Date: Tue, 24 Oct 2023 16:28:57 +0200 Subject: [PATCH 1/3] Add support for BMSMSD --- .../formats/__init__.py | 2 + .../formats/bmsmsd.py | 51 +++++++++++++++++++ tests/formats/test_bmsmsd.py | 13 +++++ 3 files changed, 66 insertions(+) create mode 100644 src/mercury_engine_data_structures/formats/bmsmsd.py create mode 100644 tests/formats/test_bmsmsd.py diff --git a/src/mercury_engine_data_structures/formats/__init__.py b/src/mercury_engine_data_structures/formats/__init__.py index 8bba034f..515a7d3f 100644 --- a/src/mercury_engine_data_structures/formats/__init__.py +++ b/src/mercury_engine_data_structures/formats/__init__.py @@ -14,6 +14,7 @@ from mercury_engine_data_structures.formats.bmsld import Bmsld from mercury_engine_data_structures.formats.bmslgroup import Bmslgroup from mercury_engine_data_structures.formats.bmslink import Bmslink +from mercury_engine_data_structures.formats.bmsmsd import Bmsmsd from mercury_engine_data_structures.formats.bmsnav import Bmsnav from mercury_engine_data_structures.formats.bmssd import Bmssd from mercury_engine_data_structures.formats.bmtre import Bmtre @@ -50,6 +51,7 @@ "BMSCD": Bmscc, "BMSCU": Bmscu, "BMSLD": Bmsld, + "BMSMSD": Bmsmsd, "BMSNAV": Bmsnav, "BMSLGROUP": Bmslgroup, "BMSLINK": Bmslink, diff --git a/src/mercury_engine_data_structures/formats/bmsmsd.py b/src/mercury_engine_data_structures/formats/bmsmsd.py new file mode 100644 index 00000000..c9cb4023 --- /dev/null +++ b/src/mercury_engine_data_structures/formats/bmsmsd.py @@ -0,0 +1,51 @@ +import functools + +import construct +from construct.core import Const, Construct, Float32l, Hex, Int32sl, Int32ul, Struct + +from mercury_engine_data_structures.common_types import CVector2D, CVector3D, StrId, make_vector +from mercury_engine_data_structures.formats import BaseResource +from mercury_engine_data_structures.game_check import Game + +# BMSMSD +BMSMSD = Struct( + "_magic" / Const(b"MMSD"), + "version" / Const(0x00070001, Hex(Int32ul)), + "scenario" / StrId, + "unk1" / Float32l, + "unk2" / Float32l, + "x_tiles" / Int32sl, + "y_tiles" / Int32sl, + "dimension" / Struct( + "bottom_left" / CVector2D, + "top_right" / CVector2D, + ), + "tiles" / make_vector( + Struct( + "tile_coordinates" / construct.Array(2, Int32sl), + "dimension" / Struct( + "bottom_left" / CVector2D, + "top_right" / CVector2D, + ), + "unk3" / Int32sl, + "unk4" / Int32sl, + "icons" / make_vector( + Struct( + "actor_name" / StrId, + "item_id" / StrId, + "icon" / StrId, + "unk5" / Int32sl, + "coordinates" / CVector3D, + ) + ), + ) + ), + construct.Terminated, +) + + +class Bmsmsd(BaseResource): + @classmethod + @functools.lru_cache + def construct_class(cls, target_game: Game) -> Construct: + return BMSMSD diff --git a/tests/formats/test_bmsmsd.py b/tests/formats/test_bmsmsd.py new file mode 100644 index 00000000..6e11cf29 --- /dev/null +++ b/tests/formats/test_bmsmsd.py @@ -0,0 +1,13 @@ +import pytest +from tests.test_lib import parse_build_compare_editor + +from mercury_engine_data_structures import samus_returns_data +from mercury_engine_data_structures.formats.bmsmsd import Bmsmsd + +all_sr_bmsmsd = [name for name in samus_returns_data.all_name_to_asset_id().keys() + if name.endswith(".bmsmsd")] + + +@pytest.mark.parametrize("bmsmsd_path", all_sr_bmsmsd) +def test_bmtun(samus_returns_tree, bmsmsd_path): + parse_build_compare_editor(Bmsmsd, samus_returns_tree, bmsmsd_path) From 2a28d3eb87c68be519ae6e3209803a13c857f837 Mon Sep 17 00:00:00 2001 From: dyceron <38679103+dyceron@users.noreply.github.com> Date: Tue, 24 Oct 2023 21:16:44 -0400 Subject: [PATCH 2/3] Rename remainder of unknowns --- src/mercury_engine_data_structures/formats/bmsmsd.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/mercury_engine_data_structures/formats/bmsmsd.py b/src/mercury_engine_data_structures/formats/bmsmsd.py index c9cb4023..e361549a 100644 --- a/src/mercury_engine_data_structures/formats/bmsmsd.py +++ b/src/mercury_engine_data_structures/formats/bmsmsd.py @@ -12,8 +12,7 @@ "_magic" / Const(b"MMSD"), "version" / Const(0x00070001, Hex(Int32ul)), "scenario" / StrId, - "unk1" / Float32l, - "unk2" / Float32l, + "tile_size" / construct.Array(2, Float32l), "x_tiles" / Int32sl, "y_tiles" / Int32sl, "dimension" / Struct( @@ -27,14 +26,14 @@ "bottom_left" / CVector2D, "top_right" / CVector2D, ), - "unk3" / Int32sl, - "unk4" / Int32sl, + "border_type" / Int32sl, + "tile_type" / Int32sl, "icons" / make_vector( Struct( "actor_name" / StrId, - "item_id" / StrId, + "clear_condition" / StrId, "icon" / StrId, - "unk5" / Int32sl, + "icon_priority" / Int32sl, "coordinates" / CVector3D, ) ), From b91e0ceb0649590d01384e11e4c9ab5ecf70b9e0 Mon Sep 17 00:00:00 2001 From: dyceron <38679103+dyceron@users.noreply.github.com> Date: Tue, 24 Oct 2023 21:20:59 -0400 Subject: [PATCH 3/3] Update bmsmsd.py --- src/mercury_engine_data_structures/formats/bmsmsd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mercury_engine_data_structures/formats/bmsmsd.py b/src/mercury_engine_data_structures/formats/bmsmsd.py index e361549a..1e19bdb5 100644 --- a/src/mercury_engine_data_structures/formats/bmsmsd.py +++ b/src/mercury_engine_data_structures/formats/bmsmsd.py @@ -15,7 +15,7 @@ "tile_size" / construct.Array(2, Float32l), "x_tiles" / Int32sl, "y_tiles" / Int32sl, - "dimension" / Struct( + "map_dimensions" / Struct( "bottom_left" / CVector2D, "top_right" / CVector2D, ),