Skip to content

Commit 9abf7bd

Browse files
author
Leo Schurrer
committed
patch: update submodule
1 parent ca6e551 commit 9abf7bd

File tree

2 files changed

+137
-14
lines changed

2 files changed

+137
-14
lines changed

kaitai_lithtech_dat_struct/lithtech_dat.ksy

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,38 @@ types:
106106
- id: poly_index
107107
type: u4
108108
# world object types
109+
wop_string:
110+
seq:
111+
- id: value
112+
type: str_with_len2
113+
wop_vec3:
114+
seq:
115+
- id: value
116+
type: vec3
117+
wop_color:
118+
seq:
119+
- id: value
120+
type: color
121+
wop_f4:
122+
seq:
123+
- id: value
124+
type: f4
125+
wop_flag:
126+
seq:
127+
- id: value
128+
type: u4
129+
wop_bool:
130+
seq:
131+
- id: value
132+
type: u1
133+
wop_int:
134+
seq:
135+
- id: value
136+
type: s4
137+
wop_quaternion:
138+
seq:
139+
- id: value
140+
type: quaternion
109141
world_object_property:
110142
seq:
111143
- id: name
@@ -120,13 +152,14 @@ types:
120152
type:
121153
switch-on: magic
122154
cases:
123-
0x00: str_with_len2
124-
0x01: vec3
125-
0x02: color
126-
0x03: f4
127-
0x05: u1 # boolean
128-
0x06: s4
129-
0x07: quaternion
155+
0x00: wop_string
156+
0x01: wop_vec3
157+
0x02: wop_color
158+
0x03: wop_f4
159+
0x04: wop_flag
160+
0x05: wop_bool
161+
0x06: wop_int
162+
0x07: wop_quaternion
130163
world_object:
131164
seq:
132165
- id: len_object

kaitai_lithtech_dat_struct/lithtech_dat.py

Lines changed: 97 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,21 @@ def _read(self):
3333
self.len_data = self._io.read_u2le()
3434
_on = self.magic
3535
if _on == 0:
36-
self.data = LithtechDat.StrWithLen2(self._io, self, self._root)
36+
self.data = LithtechDat.WopString(self._io, self, self._root)
37+
elif _on == 4:
38+
self.data = LithtechDat.WopFlag(self._io, self, self._root)
3739
elif _on == 6:
38-
self.data = self._io.read_s4le()
40+
self.data = LithtechDat.WopInt(self._io, self, self._root)
3941
elif _on == 7:
40-
self.data = LithtechDat.Quaternion(self._io, self, self._root)
42+
self.data = LithtechDat.WopQuaternion(self._io, self, self._root)
4143
elif _on == 1:
42-
self.data = LithtechDat.Vec3(self._io, self, self._root)
44+
self.data = LithtechDat.WopVec3(self._io, self, self._root)
4345
elif _on == 3:
44-
self.data = self._io.read_f4le()
46+
self.data = LithtechDat.WopF4(self._io, self, self._root)
4547
elif _on == 5:
46-
self.data = self._io.read_u1()
48+
self.data = LithtechDat.WopBool(self._io, self, self._root)
4749
elif _on == 2:
48-
self.data = LithtechDat.Color(self._io, self, self._root)
50+
self.data = LithtechDat.WopColor(self._io, self, self._root)
4951

5052

5153
class WorldObject(KaitaiStruct):
@@ -218,6 +220,17 @@ def _read(self):
218220

219221

220222

223+
class WopF4(KaitaiStruct):
224+
def __init__(self, _io, _parent=None, _root=None):
225+
self._io = _io
226+
self._parent = _parent
227+
self._root = _root if _root else self
228+
self._read()
229+
230+
def _read(self):
231+
self.value = self._io.read_f4le()
232+
233+
221234
class RenderSection(KaitaiStruct):
222235
def __init__(self, _io, _parent=None, _root=None):
223236
self._io = _io
@@ -253,6 +266,28 @@ def _read(self):
253266
self.world_offset = LithtechDat.Vec3(self._io, self, self._root)
254267

255268

269+
class WopInt(KaitaiStruct):
270+
def __init__(self, _io, _parent=None, _root=None):
271+
self._io = _io
272+
self._parent = _parent
273+
self._root = _root if _root else self
274+
self._read()
275+
276+
def _read(self):
277+
self.value = self._io.read_s4le()
278+
279+
280+
class WopColor(KaitaiStruct):
281+
def __init__(self, _io, _parent=None, _root=None):
282+
self._io = _io
283+
self._parent = _parent
284+
self._root = _root if _root else self
285+
self._read()
286+
287+
def _read(self):
288+
self.value = LithtechDat.Color(self._io, self, self._root)
289+
290+
256291
class WorldModel(KaitaiStruct):
257292
def __init__(self, _io, _parent=None, _root=None):
258293
self._io = _io
@@ -311,6 +346,17 @@ def _read(self):
311346
self.sections = self._io.read_u4le()
312347

313348

349+
class WopFlag(KaitaiStruct):
350+
def __init__(self, _io, _parent=None, _root=None):
351+
self._io = _io
352+
self._parent = _parent
353+
self._root = _root if _root else self
354+
self._read()
355+
356+
def _read(self):
357+
self.value = self._io.read_u4le()
358+
359+
314360
class SkyPortal(KaitaiStruct):
315361
def __init__(self, _io, _parent=None, _root=None):
316362
self._io = _io
@@ -425,6 +471,17 @@ def _read(self):
425471
self.name = self._io.read_u4le()
426472

427473

474+
class WopVec3(KaitaiStruct):
475+
def __init__(self, _io, _parent=None, _root=None):
476+
self._io = _io
477+
self._parent = _parent
478+
self._root = _root if _root else self
479+
self._read()
480+
481+
def _read(self):
482+
self.value = LithtechDat.Vec3(self._io, self, self._root)
483+
484+
428485
class WorldModelRenderNode(KaitaiStruct):
429486
def __init__(self, _io, _parent=None, _root=None):
430487
self._io = _io
@@ -499,6 +556,17 @@ def _read(self):
499556

500557

501558

559+
class WopBool(KaitaiStruct):
560+
def __init__(self, _io, _parent=None, _root=None):
561+
self._io = _io
562+
self._parent = _parent
563+
self._root = _root if _root else self
564+
self._read()
565+
566+
def _read(self):
567+
self.value = self._io.read_u1()
568+
569+
502570
class WorldModelPolygon(KaitaiStruct):
503571
def __init__(self, num_vertices_indices, _io, _parent=None, _root=None):
504572
self._io = _io
@@ -553,6 +621,17 @@ def _read(self):
553621

554622

555623

624+
class WopQuaternion(KaitaiStruct):
625+
def __init__(self, _io, _parent=None, _root=None):
626+
self._io = _io
627+
self._parent = _parent
628+
self._root = _root if _root else self
629+
self._read()
630+
631+
def _read(self):
632+
self.value = LithtechDat.Quaternion(self._io, self, self._root)
633+
634+
556635
class Vec3(KaitaiStruct):
557636
def __init__(self, _io, _parent=None, _root=None):
558637
self._io = _io
@@ -566,6 +645,17 @@ def _read(self):
566645
self.z = self._io.read_f4le()
567646

568647

648+
class WopString(KaitaiStruct):
649+
def __init__(self, _io, _parent=None, _root=None):
650+
self._io = _io
651+
self._parent = _parent
652+
self._root = _root if _root else self
653+
self._read()
654+
655+
def _read(self):
656+
self.value = LithtechDat.StrWithLen2(self._io, self, self._root)
657+
658+
569659
class RenderData(KaitaiStruct):
570660
def __init__(self, _io, _parent=None, _root=None):
571661
self._io = _io

0 commit comments

Comments
 (0)