Skip to content

Commit

Permalink
Parse the rest of BMSAD
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquegemignani committed Aug 4, 2023
1 parent cac2fe6 commit ca9d6f5
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 4 deletions.
55 changes: 52 additions & 3 deletions src/mercury_engine_data_structures/formats/bmsad.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def component_type(this):
ErrorWithMessage(lambda ctx: f"Unknown argument type: {ctx.type}", construct.SwitchError)
)
))
))
), allow_duplicates=True)


DreadComponent = Struct(
Expand Down Expand Up @@ -214,7 +214,7 @@ def component_type(this):

def SRDependencies():
component_dependencies = {
"CAnimationComponent": Hex(Int32ul),
"CAnimationComponent": make_vector(StrId),
"CFXComponent": make_vector(Struct(
"file" / StrId,
"unk1" / Int32ul,
Expand All @@ -225,9 +225,54 @@ def SRDependencies():
"unk" / Int16ul
),
"CGrabComponent": make_vector(Struct(
"unk" / Const(0, Int32ul),
a=StrId,
b=StrId,
c=StrId,
d=Hex(Int32ul)[2],
e=Float[8],
f=Hex(Int32ul)[9],
)),
"CGlowflyAnimationComponent": make_vector(StrId),
"CSceneModelAnimationComponent": make_dict(make_dict(StrId)),

"CBillboardComponent": Struct(
"id1" / StrId,
"unk1" / make_dict(Struct(
"unk1" / Int32ul[3],
"unk2" / Byte,
"unk3" / Int32ul[2],
"unk4" / Float32l
)),
"id2" / StrId,
"unk3" / make_vector(Struct(
"id" / StrId,
"unk1" / Byte,
"unk2" / make_vector(Struct(
"a" / Float,
"b" / Float,
"c" / Float,
)),
)),
),

"CSwarmControllerComponent": Struct(
"unk1" / make_vector(StrId),
"unk2" / make_vector(StrId),
"unk3" / make_vector(StrId)
),
}
for dep in [
"CTsumuriAcidDroolCollision",
"CBillboardCollisionComponent",
"CQueenPlasmaArcCollision",
]:
component_dependencies[dep] = component_dependencies["CCollisionComponent"]

for dep in [
"CFlockingSwarmControllerComponent",
"CBeeSwarmControllerComponent",
]:
component_dependencies[dep] = component_dependencies["CSwarmControllerComponent"]

return Switch(construct.this.type, component_dependencies)

Expand Down Expand Up @@ -259,8 +304,12 @@ def SRDependencies():
sub_actors=make_vector(StrId),
unk_8=Int32ul,

# count=Int32ul,
# component=(StrId >> SR_Component)[4],
components=make_dict(SR_Component),

binaries=make_vector(StrId),

rest=construct.GreedyBytes,
_end=construct.Terminated,
)
Expand Down
9 changes: 8 additions & 1 deletion tests/formats/test_bmsad.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
expected_dread_failures = {
"actors/props/pf_mushr_fr/charclasses/pf_mushr_fr.bmsad",
}
expected_sr_failures = {
"actors/items/adn/charclasses/adn.bmsad",
"actors/props/ridleystorm/charclasses/ridleystorm.bmsad",
}


@pytest.mark.parametrize("bmsad_path", all_dread_bmsad)
Expand All @@ -36,7 +40,10 @@ def test_compare_sr_all(samus_returns_tree, bmsad_path):
if not samus_returns_tree.does_asset_exists(bmsad_path):
return pytest.skip()

expectation = contextlib.nullcontext()
if bmsad_path in expected_sr_failures:
expectation = pytest.raises(construct.core.ConstError)
else:
expectation = contextlib.nullcontext()

with expectation:
parse_build_compare_editor(
Expand Down

0 comments on commit ca9d6f5

Please sign in to comment.