Skip to content

Commit 75f28a2

Browse files
aronwk-aaronclaude
andcommitted
fix: update raw.ksy with verified field names, v<32 support, missing color_a
Changes verified against Ghidra RE of ReadNewTerrainFormat, RAWReadHeightmap, RAWReadColorandLightMaps, RAWReadFlairData, RAWReadSceneMap, RAWReadMeshData, and FUN_0103aaf0 (blend map reader) in legouniverse.exe 1.10.64. Validated against all 309 .raw files across multiple client versions (v31 and v32). - Rename density → scale (matches client field name) - Rename diffuse_res → color_map_resolution, diffuse_res_pixels → color_map_pixels - Rename bits → blend_channel_mask - Add color_a (u1) to flair_attributes (was missing, 35 vs 36 byte mismatch) - Remove size: 36 override on flairs (struct is now correctly 36 bytes) - Add version >= 32 and vert_size != 0 guards on mesh data (matches client) - Replace unknown1/unknown2 catch-alls with proper v<32 field definitions: - color_map_pixels_legacy: width*width*4 bytes (BGRA per-pixel swizzle) - scene_map_v31: width*width bytes (v==31 per-cell read with border skip) - scene_map_skip: 1 byte (v<31 zero-fill) - No diffuse DDS, blend_channel_mask, or blend DDS for v<32 - No mesh data for v<32 - Add doc annotations throughout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent eb15852 commit 75f28a2

1 file changed

Lines changed: 39 additions & 17 deletions

File tree

files/raw.ksy

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ seq:
99
type: u2
1010
- id: dev
1111
type: u1
12+
doc: Must be 0 for valid terrain data; non-zero aborts loading
1213
- id: num_chunks
1314
type: u4
1415
if: dev == 0
@@ -43,73 +44,92 @@ types:
4344
type: u4
4445
repeat: expr
4546
repeat-expr: 4
46-
- id: density
47+
- id: scale
4748
type: f4
49+
doc: Heightmap scale factor, used to transform grid coords to world coords
4850
- id: height_map
4951
type: f4
5052
repeat: expr
5153
repeat-expr: width * height
52-
- id: diffuse_res
54+
- id: color_map_resolution
5355
type: u4
5456
if: _root.version >= 32
55-
- id: diffuse_res_pixels
56-
size: diffuse_res * diffuse_res * 4
57+
doc: Resolution of the color/diffuse map
58+
- id: color_map_pixels
59+
size: color_map_resolution * color_map_resolution * 4
5760
if: _root.version >= 32
58-
doc: RGBA
59-
- id: unknown1
60-
type: u1
61-
repeat: eos
61+
doc: RGBA color map pixels (raw block)
62+
- id: color_map_pixels_legacy
63+
size: width * width * 4
6264
if: _root.version < 32
63-
doc: todo
65+
doc: >
66+
v<32 color map. Client reads width*width pixels (4 bytes each)
67+
with per-pixel BGRA byte swizzle. colorMapResolution = width - 1;
68+
only the inner (width-1)^2 pixels are used.
6469
- id: diffuse_map_dds_size
6570
type: u4
6671
if: _root.version >= 32
6772
- id: diffuse_map_dds
6873
size: diffuse_map_dds_size
6974
if: _root.version >= 32
75+
doc: DDS texture data for diffuse/light map
7076
- id: blend_res
7177
type: u4
7278
- id: blend_pixels
7379
size: blend_res * blend_res * 4
74-
- id: bits
80+
doc: >
81+
Blend/texture map pixels. v>=32 reads as raw RGBA block;
82+
v<32 reads per-pixel as B,G,R,A (byte-swizzled).
83+
- id: blend_channel_mask
7584
type: u1
7685
if: _root.version >= 32
86+
doc: Bitmask of active detail textures (bits 0-3)
7787
- id: blend_map_dds_size
7888
type: u4
7989
if: _root.version >= 32
8090
- id: blend_map_dds
8191
size: blend_map_dds_size
8292
if: _root.version >= 32
93+
doc: DDS texture data for blend map (DXT5)
8394
- id: num_flairs
8495
type: u4
8596
- id: flairs
8697
type: flair_attributes
87-
size: 36
8898
repeat: expr
8999
repeat-expr: num_flairs
90100
- id: scene_map
91-
size: diffuse_res * diffuse_res
101+
size: color_map_resolution * color_map_resolution
92102
if: _root.version >= 32
93-
- id: unknown2
94-
type: u1
95-
repeat: eos
96-
if: _root.version < 32
97-
doc: todo
103+
doc: Per-pixel scene ID assignment, indexes into LUZ scene list
104+
- id: scene_map_v31
105+
size: width * width
106+
if: _root.version == 31
107+
doc: >
108+
v31 scene map. Allocates (colorMapRes+1)^2 where colorMapRes=width-1.
109+
Client reads (colorMapRes+1)^2 cells; inner colorMapRes^2 cells
110+
contain scene IDs, border cells are skipped/discarded.
111+
- id: scene_map_skip
112+
size: 1
113+
if: _root.version < 31
114+
doc: v<31 skips 1 byte; scene map is zero-filled by client
98115
- id: vert_size
99116
type: u4
100117
if: _root.version >= 32
101118
- id: mesh_vert_usage
102119
type: u2
103120
repeat: expr
104121
repeat-expr: vert_size
122+
if: _root.version >= 32 and vert_size != 0
105123
- id: mesh_vert_size
106124
type: u2
107125
repeat: expr
108126
repeat-expr: 16
127+
if: _root.version >= 32 and vert_size != 0
109128
- id: mesh_tri
110129
type: mesh_tri
111130
repeat: expr
112131
repeat-expr: 16
132+
if: _root.version >= 32 and vert_size != 0
113133

114134
flair_attributes:
115135
seq:
@@ -127,6 +147,8 @@ types:
127147
type: u1
128148
- id: color_b
129149
type: u1
150+
- id: color_a
151+
type: u1
130152
mesh_tri:
131153
seq:
132154
- id: mesh_tri_list_size

0 commit comments

Comments
 (0)