-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from steven11sjf/buct
BUCT
- Loading branch information
Showing
4 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import construct | ||
from construct.core import ( | ||
Array, | ||
Const, | ||
Construct, | ||
If, | ||
Int16ul, | ||
Int32ul, | ||
Int64ul, | ||
Rebuild, | ||
Struct, | ||
Terminated, | ||
) | ||
|
||
from mercury_engine_data_structures import game_check | ||
from mercury_engine_data_structures.common_types import VersionAdapter | ||
from mercury_engine_data_structures.formats.base_resource import BaseResource | ||
|
||
BUCT = Struct( | ||
_magic = Const(b"MUCT"), | ||
version = game_check.is_sr_or_else( | ||
VersionAdapter("1.3.0"), | ||
VersionAdapter("1.4.0") | ||
), | ||
size = Rebuild(Int32ul, construct.len_(construct.this.data)), | ||
_padding = If(game_check.current_game_at_least(game_check.Game.DREAD), Const(0xFFFFFFFF, Int32ul)), | ||
_data_start = game_check.is_sr_or_else( | ||
Const(0x10, Int32ul), | ||
Const(0x18, Int64ul) | ||
), | ||
data=Array(construct.this.size, Struct( | ||
char_maybe = Int16ul, # I think this could be utf8 chars? | ||
_padding = game_check.is_sr_or_else( | ||
Const(0x0000, Int16ul), | ||
Const(0xFFFF, Int16ul), | ||
), | ||
index = Int32ul | ||
)), | ||
_eof=Terminated | ||
) | ||
|
||
class Buct(BaseResource): | ||
@classmethod | ||
def construct_class(cls, target_game: game_check.Game) -> Construct: | ||
return BUCT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pytest | ||
from tests.test_lib import parse_build_compare_editor | ||
|
||
from mercury_engine_data_structures import dread_data, samus_returns_data | ||
from mercury_engine_data_structures.formats.buct import Buct | ||
|
||
|
||
@pytest.mark.parametrize("buct_path", dread_data.all_files_ending_with(".buct")) | ||
def test_buct_dread(dread_file_tree, buct_path): | ||
parse_build_compare_editor(Buct, dread_file_tree, buct_path) | ||
|
||
@pytest.mark.parametrize("buct_path", samus_returns_data.all_files_ending_with(".buct")) | ||
def test_buct_sr(samus_returns_tree, buct_path): | ||
parse_build_compare_editor(Buct, samus_returns_tree, buct_path) |