Skip to content

Commit

Permalink
wrpl_unpacker: should fix parsing replays
Browse files Browse the repository at this point in the history
  • Loading branch information
klensy committed Aug 5, 2020
1 parent d42e0c0 commit 0beba79
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/wt_tools/formats/wrpl_parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import struct

from construct import Enum, Int16ul, Const, Struct, Int32ub, Int32ul, Bytes, this, Int24ul, Seek
from construct import Enum, Int16ul, Const, Struct, Int32ub, Int32ul, Bytes, this, Int24ul, Seek, Switch, If,\
IfThenElse, Pass, Probe

from .common import zlib_stream

Expand All @@ -9,14 +10,15 @@
def simple_blk_build(obj):
return b"".join([obj.magic, struct.pack('>I', obj.unknown_0), struct.pack('<I', obj.blk_body_size), obj.blk_body])

# i think not byte, but word\dword
wrpl_version = "wrpl_version" / Enum(Int16ul,
version_1_45=0x889a,
version_1_47=0x88c8,
version_1_49=0x88ca,
version_1_51=0x88e7,
version_1_63=0x8964
)
wrpl_versions_list = {
"version_1_45": 0x889a,
"version_1_47": 0x88c8,
"version_1_49": 0x88ca,
"version_1_51": 0x88e7,
"version_1_63": 0x8964,
"version_1_63-99": 0x8a4b,
"version_1_99": 0x8aa9,
}

simple_blk = "blk" / Struct(
"magic" / Const(b"\x00BBF"),
Expand All @@ -28,12 +30,20 @@ def simple_blk_build(obj):

wrpl_file = "wrpl" / Struct(
"magic" / Const(b"\xe5\xac\x00\x10"),
wrpl_version,
"version" / Int16ul,
# here we ignore some bytes, better version detect i think
"unknown_0" / Int24ul,
# there skip some data, not used now anyway
# ...
Seek(0x450 if wrpl_version == "version_1_45" else 0x440),
IfThenElse(
this.version >= wrpl_versions_list['version_1_63-99'],
Seek(0x444),
IfThenElse(
this.version >= wrpl_versions_list['version_1_63'],
Seek(0x440),
Seek(0x450)
)
),
"m_set" / simple_blk,
"wrplu" / zlib_stream,
"rez" / simple_blk,
Expand Down

0 comments on commit 0beba79

Please sign in to comment.