- Migrate from set_global/get_global to ctx_set/ctx_get - Replace if-else chains with match() expressions - Update inline pointer handling patterns - Improve GfxWorld and asset parsing structures - Clean up redundant code across 60+ definition files Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
222 lines
6.0 KiB
Plaintext
222 lines
6.0 KiB
Plaintext
type gfxworld [display="GFX World"]
|
|
{
|
|
const PTR_INLINE = -1;
|
|
|
|
// ========================================
|
|
// GfxWorld Header - PC VERSION (732 bytes)
|
|
// ========================================
|
|
|
|
// Name pointers (8 bytes)
|
|
i32 name_ptr;
|
|
ui("name_ptr", "Name Ptr");
|
|
|
|
i32 basename_ptr;
|
|
ui("basename_ptr", "Base Name Ptr");
|
|
|
|
// Counts and indices (16 bytes)
|
|
i32 plane_count;
|
|
ui("plane_count", "Plane Count");
|
|
|
|
i32 node_count;
|
|
ui("node_count", "Node Count");
|
|
|
|
i32 index_count;
|
|
ui("index_count", "Index Count");
|
|
|
|
i32 indices_ptr;
|
|
ui("indices_ptr", "Indices Ptr");
|
|
|
|
// PC has no D3DIndexBuffer - just surfaceCount + unk (8 bytes)
|
|
i32 surface_count;
|
|
ui("surface_count", "Surface Count");
|
|
|
|
i32 unk;
|
|
ui("unk", "Unknown");
|
|
|
|
// Sky data (16 bytes)
|
|
i32 sky_surf_count;
|
|
ui("sky_surf_count", "Sky Surf Count");
|
|
|
|
i32 sky_start_surfs_ptr;
|
|
ui("sky_start_surfs_ptr", "Sky Start Surfs Ptr");
|
|
|
|
i32 sky_image_ptr;
|
|
ui("sky_image_ptr", "Sky Image Ptr");
|
|
|
|
u8 sky_sampler_state;
|
|
ui("sky_sampler_state", "Sky Sampler State");
|
|
|
|
skip 3; // padding
|
|
|
|
// Vertex data (4 + 8 = 12 bytes)
|
|
u32 vertex_count;
|
|
ui("vertex_count", "Vertex Count");
|
|
|
|
vertex_data = parse_here("gfxworldvertexdata");
|
|
|
|
// Vertex layer data (4 + 8 = 12 bytes)
|
|
u32 vertex_layer_data_size;
|
|
ui("vertex_layer_data_size", "Vertex Layer Data Size");
|
|
|
|
vertex_layer_data = parse_here("gfxworldvertexlayerdata");
|
|
|
|
// Sun light parse params - EMBEDDED (128 bytes on PC - name is char[64])
|
|
sun_parse = parse_here("sunlightparseparams");
|
|
|
|
// Sun light pointer (4 bytes)
|
|
i32 sun_light_ptr;
|
|
ui("sun_light_ptr", "Sun Light Ptr");
|
|
|
|
// Sun color from BSP (12 bytes)
|
|
sun_color = read(12);
|
|
ui("sun_color", "Sun Color");
|
|
|
|
// Light counts and reflection probes (24 bytes)
|
|
u32 sun_primary_light_index;
|
|
ui("sun_primary_light_index", "Sun Primary Light Index");
|
|
|
|
u32 primary_light_count;
|
|
ui("primary_light_count", "Primary Light Count");
|
|
|
|
i32 cull_group_count;
|
|
ui("cull_group_count", "Cull Group Count");
|
|
|
|
u32 reflection_probe_count;
|
|
ui("reflection_probe_count", "Reflection Probe Count");
|
|
|
|
i32 reflection_probes_ptr;
|
|
ui("reflection_probes_ptr", "Reflection Probes Ptr");
|
|
|
|
i32 reflection_probe_textures_ptr;
|
|
ui("reflection_probe_textures_ptr", "Reflection Probe Textures Ptr");
|
|
|
|
// DPVS planes - EMBEDDED (16 bytes)
|
|
dpvs_planes = parse_here("gfxworlddpvsplanes");
|
|
|
|
// Cells and lightmaps (16 bytes)
|
|
i32 cell_bits_count;
|
|
ui("cell_bits_count", "Cell Bits Count");
|
|
|
|
i32 cells_ptr;
|
|
ui("cells_ptr", "Cells Ptr");
|
|
|
|
i32 lightmap_count;
|
|
ui("lightmap_count", "Lightmap Count");
|
|
|
|
i32 lightmaps_ptr;
|
|
ui("lightmaps_ptr", "Lightmaps Ptr");
|
|
|
|
// Light grid - EMBEDDED (56 bytes on PC - mins/maxs are uint16)
|
|
light_grid = parse_here("gfxlightgrid");
|
|
|
|
// Texture pointers (16 bytes)
|
|
i32 lightmaps_primary_ptr;
|
|
ui("lightmaps_primary_ptr", "Lightmaps Primary Ptr");
|
|
|
|
i32 lightmaps_secondary_ptr;
|
|
ui("lightmaps_secondary_ptr", "Lightmaps Secondary Ptr");
|
|
|
|
i32 model_count;
|
|
ui("model_count", "Model Count");
|
|
|
|
i32 models_ptr;
|
|
ui("models_ptr", "Models Ptr");
|
|
|
|
// Bounds (24 bytes)
|
|
mins = read(12);
|
|
ui("mins", "Mins");
|
|
|
|
maxs = read(12);
|
|
ui("maxs", "Maxs");
|
|
|
|
// Checksum and material memory (12 bytes)
|
|
u32 checksum;
|
|
ui("checksum", "Checksum");
|
|
|
|
i32 material_memory_count;
|
|
ui("material_memory_count", "Material Memory Count");
|
|
|
|
i32 material_memory_ptr;
|
|
ui("material_memory_ptr", "Material Memory Ptr");
|
|
|
|
// Sun flare - EMBEDDED (96 bytes)
|
|
sun_flare = parse_here("sunflare");
|
|
|
|
// Outdoor lookup matrix (64 bytes)
|
|
outdoor_lookup_matrix = read(64);
|
|
ui("outdoor_lookup_matrix", "Outdoor Lookup Matrix");
|
|
|
|
// Final pointers (40 bytes)
|
|
i32 outdoor_image_ptr;
|
|
ui("outdoor_image_ptr", "Outdoor Image Ptr");
|
|
|
|
i32 cell_caster_bits_ptr;
|
|
ui("cell_caster_bits_ptr", "Cell Caster Bits Ptr");
|
|
|
|
i32 scene_dyn_model_ptr;
|
|
ui("scene_dyn_model_ptr", "Scene Dyn Model Ptr");
|
|
|
|
i32 scene_dyn_brush_ptr;
|
|
ui("scene_dyn_brush_ptr", "Scene Dyn Brush Ptr");
|
|
|
|
i32 primary_light_ent_shadow_vis_ptr;
|
|
ui("primary_light_ent_shadow_vis_ptr", "Primary Light Ent Shadow Vis Ptr");
|
|
|
|
i32 primary_light_dyn_ent_shadow_vis_ptr_0;
|
|
ui("primary_light_dyn_ent_shadow_vis_ptr_0", "Primary Light Dyn Ent Shadow Vis Ptr 0");
|
|
|
|
i32 primary_light_dyn_ent_shadow_vis_ptr_1;
|
|
ui("primary_light_dyn_ent_shadow_vis_ptr_1", "Primary Light Dyn Ent Shadow Vis Ptr 1");
|
|
|
|
i32 primary_light_for_model_dyn_ent_ptr;
|
|
ui("primary_light_for_model_dyn_ent_ptr", "Primary Light For Model Dyn Ent Ptr");
|
|
|
|
i32 shadow_geom_ptr;
|
|
ui("shadow_geom_ptr", "Shadow Geom Ptr");
|
|
|
|
i32 light_region_ptr;
|
|
ui("light_region_ptr", "Light Region Ptr");
|
|
|
|
// DPVS static - EMBEDDED (104 bytes on PC - has 3 extra fields)
|
|
dpvs = parse_here("gfxworlddpvsstatic");
|
|
|
|
// DPVS dynamic - EMBEDDED (48 bytes)
|
|
dpvs_dyn = parse_here("gfxworlddpvsdynamic");
|
|
|
|
// ========================================
|
|
// Inline data (after header, ptr == -1)
|
|
// ========================================
|
|
|
|
// Parse names if inline
|
|
inline cstring name when name_ptr [ui="Name", set_name];
|
|
inline cstring basename when basename_ptr [ui="Base Name"];
|
|
|
|
// Indices array - only if inline (ptr == -1)
|
|
if (indices_ptr == PTR_INLINE && index_count > 0) {
|
|
indices = read(index_count * 2);
|
|
ui("indices", "Indices");
|
|
}
|
|
|
|
// Sky start surfs - only if inline
|
|
if (sky_start_surfs_ptr == PTR_INLINE && sky_surf_count > 0) {
|
|
sky_start_surfs = read(sky_surf_count * 4);
|
|
ui("sky_start_surfs", "Sky Start Surfs");
|
|
}
|
|
|
|
// Sky image - only if inline
|
|
inline image sky_image when sky_image_ptr;
|
|
|
|
// Sun light - only if inline
|
|
inline gfxlight sun_light when sun_light_ptr;
|
|
|
|
// Reflection probes - only if inline
|
|
if (reflection_probes_ptr == PTR_INLINE && reflection_probe_count > 0) {
|
|
array[reflection_probe_count] reflection_probes: gfxreflectionprobe;
|
|
}
|
|
|
|
// Reflection probe textures - only if inline
|
|
if (reflection_probe_textures_ptr == PTR_INLINE && reflection_probe_count > 0) {
|
|
array[reflection_probe_count] reflection_probe_textures: gfxtexture;
|
|
}
|
|
}
|