models: overview
The model system of the client: the M2 model format as the client loads it, the shared model and
its instances, their animation, lighting and drawing, the particle and ribbon emitters they carry,
and the world model objects (.wmo) with their groups and BSP trees.
The system owns seventeen object files, listed below; 0x827000, the C runtime's initializer table,
lists each one's static initializers in one run. The docs split by topic: cache (the model cache
and its helper thread), scene (a scene's frame), render (the draw), model (the instance API),
animation, lights, shared (the file and its fixup), records (its records), emission and
particles, ribbons and wmo. This doc holds the object files, their static initializers and the
code nothing reaches. Other systems enter through the roots each topic doc lists, and through the
static initializers below.
Roots: 0x692ba0, 0x692bc0, 0x692be0, 0x692c10, 0x692c40, 0x692cc0, 0x693bb0, 0x693be0, 0x693c10, 0x693c40, 0x693c70, 0x6a2c70, 0x6a2c90, 0x6a2d70, 0x6a2ef0, 0x6a2f30, 0x6a2f50, 0x6a2f90, 0x6a2fb0, 0x6a3020, 0x6a55d0, 0x6a55f0, 0x6a6270, 0x6a62a0, 0x6a62d0, 0x6a6300, 0x6a6330, 0x6a6360, 0x6a6390, 0x6a63c0, 0x6a63f0, 0x6a6420, 0x6a6450, 0x6a6480, 0x6a64b0, 0x6a64e0, 0x6a6500, 0x6a6530, 0x6a6560, 0x6a6590, 0x6a65c0, 0x6a65f0, 0x6a6620, 0x6a6650, 0x6a6680, 0x6a66b0, 0x6a66e0, 0x6b83a0, 0x6b83c0, 0x6b8420, 0x6b8540, 0x6b85a0, 0x6b86c0, 0x6b8710, 0x6bb120, 0x6bb140, 0x6bcb00, 0x6bcb30, 0x6bcb60, 0x6bcb90, 0x6bcbc0, 0x6bcbf0, 0x6bcc20, 0x6bcc50, 0x6bcc80, 0x6bccb0, 0x6bcce0, 0x6bcd10, 0x6bcd40, 0x6bcd70, 0x6bcd90, 0x6bcdc0, 0x6bcdf0, 0x6bce20, 0x6bcec0, 0x6bcef0, 0x6bcf20, 0x6bcf50, 0x6bcf80, 0x6bcfb0, 0x6bcfe0, 0x6c3870, 0x6c4730, 0x6c4750, 0x6c4780, 0x6c47b0, 0x6c47e0, 0x6c4810, 0x6c4840, 0x6c4870, 0x6c48a0, 0x6c48d0, 0x6c4900, 0x6c4930, 0x6c4960, 0x6c4990, 0x6c49c0, 0x6c49f0, 0x6c4a10, 0x6c4a40, 0x6c4a70, 0x6c4aa0, 0x6c4ad0, 0x6c4b00, 0x6c4b30, 0x6c4b60, 0x6c4b90, 0x6c4bc0, 0x6c4bf0, 0x706d90, 0x706dc0, 0x706e40, 0x706e60, 0x706e80, 0x706eb0, 0x706ee0, 0x706f10, 0x706fe0, 0x70b310, 0x70d9b0, 0x70d9d0, 0x70dc00, 0x70dc30, 0x70dc60, 0x70dd30, 0x711bd0, 0x714210, 0x714230, 0x7187e0, 0x71b030, 0x71b060, 0x71cc40, 0x71cc60, 0x71cc80, 0x71ccb0, 0x71cce0, 0x71e050, 0x71e070, 0x71e090, 0x71f800, 0x71f830, 0x71f9f0, 0x71fa10, 0x71fa30, 0x71fa60, 0x71fa90, 0x7adf90, 0x7af1b0, 0x7af1d0, 0x7b0dd0, 0x7b0df0, 0x7b0e10, 0x7b0e40, 0x7b0e70, 0x7b0ea0, 0x7b0ee0, 0x7b0ef0, 0x7b0f50, 0x7b0f80, 0x7b1050, 0x7b1070, 0x7b10b0, 0x7b6c10, 0x7b8390, 0x7b83b0, 0x7b8750, 0x7b9aa0, 0x7b9ac0, 0x7b9af0, 0x7b9f00, 0x7b9f20, 0x7b9f50, 0x7b9f70, 0x7b9fa0, 0x7ba860, 0x7ba880
Object files
The map object files are AaBsp.cpp (0x692ba0 through 0x693e80), MapObj.cpp (0x6a2c70
through 0x6a6710), the group file (0x6b83a0 through 0x6bcff0) and the reader (0x6c3840
through 0x6c4c20). The model files are M2Cache.cpp (0x706440 through 0x706ef0), M2Scene.cpp
(0x706f10 through 0x70dc40), M2Model.cpp (0x70dc60 through 0x71b070), the lights file
(0x71b090 through 0x71ccf0), the shared model file (0x71cd10 through 0x71e0a0), the header
fixups (0x71e0c0 through 0x71f840) and the model buffers (0x71f860 through 0x71faa0). The
emitter files are the registries (0x7adf90 through 0x7af530), the particle emitters (0x7b0dd0
through 0x7b6990), the ribbons (0x7b6c10 through 0x7b8710), the emitter shapes (0x7b8750
through 0x7b9ad0), the particle gradients (0x7b9af0 through 0x7b9f30) and the legacy
particles (0x7b9f50 through 0x7ba9f0).
Addresses: 0x692ba0, 0x693e80, 0x693ca0, 0xca03e4, 0xca03e8, 0x6a2c70, 0x6a6710, 0x6b83a0, 0x6bcff0, 0x6c3840, 0x6c4c20, 0x6c4ca0, 0x706440, 0x706ef0, 0x706f10, 0x70dc40, 0x70dc60, 0x71b070, 0x71b090, 0x71ccf0, 0x71cd10, 0x71e0a0, 0x71e0c0, 0x71f840, 0x71f860, 0x71faa0, 0x7adf90, 0x7af530, 0x7b0dd0, 0x7b6990, 0x7b6c10, 0x7b8710, 0x7b8750, 0x7b9ad0, 0x7b9af0, 0x7b9f30, 0x7b9f50, 0x7ba9f0, 0x827000, 0x6a2c90, 0x6b83c0, 0x7b9b00, 0x7b9b10, 0x7b9f60, 0x7b9f70
Confidence: verified
Proof: one
Test: models::attach_light_grid_window_difftest, models::grid_scale_product_difftest
The source paths AaBsp.cpp (pushed in 0x692ce0), MapObj.cpp (in 0x6a36d0), M2Cache.cpp
(in 0x706510), M2Scene.cpp (in 0x707350), M2Model.cpp (in 0x70ebd0),
Services/RibbonEmitter.h (in 0x7aeeb0) and ParticleSystem2.h (in 0x7b87b0) name the files
they appear in. Each file's initializer run is contiguous in 0x827000 and opens with its +∞, 2π
and 1/2π; the runs give each file's initializers: AaBsp.cpp 0x82bfb0 to 0x82bfd4, MapObj.cpp
0x82c408 to 0x82c484, the group file 0x82c854 to 0x82c8cc, the reader 0x82cc00 to
0x82cc6c, the model files 0x82d110 to 0x82d190, the registries 0x82d994 to 0x82d99c, and
the particle files 0x82d9b0 to 0x82da04. Code past a file's last initializer is placed by the
data and callers it shares, since a file with no run can follow (systems/README, Object files):
the BSP leaf cache 0x693ca0 to 0x693e80 keeps its counter in AaBsp's .bss (0xca03e8, beside
the leaf cache root 0xca03e4 that AaBsp's 0x693080 frees), before the next file's first global;
0x6c4c20, called only by the reader, precedes the next run at 0x6c4ca0.
attach_light_grid_window_difftest runs 0x70dc40 whole; grid_scale_product_difftest runs
0x71ccf0 whole.
Shared header constants
Every file runs constant initializers from shared headers, each a 5-byte thunk jumping to a body
that rounds one value to a float in a .data global: 2π as π + π, 1/2π, +∞, and in the map
object files the squares 10², 11.111111², 5.5555553², 5², 30², 120², 20², 0.5², 3², 100², 50²,
40², 1.5², the plain value 5.0, −21·(−1/36), that times −255, 18·(1/36), that times 256 and
1/4.1666665; the model files add 10² and 0.5/10. AaBsp.cpp's first statics also zero its BSP
scratch counters and visited bitset.
Addresses: 0x692ba0, 0x692bb0, 0x692bc0, 0x692bd0, 0x692be0, 0x692bf0, 0x692c10, 0x692c20, 0x693bb0, 0x693bc0, 0x693be0, 0x693bf0, 0x693c10, 0x693c20, 0x693c40, 0x693c50, 0x693c70, 0x693c80, 0x6a55d0, 0x6a55e0, 0x6a55f0, 0x6a5600, 0x6a6270, 0x6a6280, 0x6a62a0, 0x6a62b0, 0x6a62d0, 0x6a62e0, 0x6a6300, 0x6a6310, 0x6a6330, 0x6a6340, 0x6a6360, 0x6a6370, 0x6a6390, 0x6a63a0, 0x6a63c0, 0x6a63d0, 0x6a63f0, 0x6a6400, 0x6a6420, 0x6a6430, 0x6a6450, 0x6a6460, 0x6a6480, 0x6a6490, 0x6a64b0, 0x6a64c0, 0x6a64e0, 0x6a64f0, 0x6a6500, 0x6a6510, 0x6a6530, 0x6a6540, 0x6a6560, 0x6a6570, 0x6a6590, 0x6a65a0, 0x6a65c0, 0x6a65d0, 0x6a65f0, 0x6a6600, 0x6a6620, 0x6a6630, 0x6a6650, 0x6a6660, 0x6a6680, 0x6a6690, 0x6a66b0, 0x6a66c0, 0x6a66e0, 0x6a66f0, 0x6bb120, 0x6bb130, 0x6bb140, 0x6bb150, 0x6bcb00, 0x6bcb10, 0x6bcb30, 0x6bcb40, 0x6bcb60, 0x6bcb70, 0x6bcb90, 0x6bcba0, 0x6bcbc0, 0x6bcbd0, 0x6bcbf0, 0x6bcc00, 0x6bcc20, 0x6bcc30, 0x6bcc50, 0x6bcc60, 0x6bcc80, 0x6bcc90, 0x6bccb0, 0x6bccc0, 0x6bcce0, 0x6bccf0, 0x6bcd10, 0x6bcd20, 0x6bcd40, 0x6bcd50, 0x6bcd70, 0x6bcd80, 0x6bcd90, 0x6bcda0, 0x6bcdc0, 0x6bcdd0, 0x6bcdf0, 0x6bce00, 0x6bce20, 0x6bce30, 0x6bcec0, 0x6bced0, 0x6bcef0, 0x6bcf00, 0x6bcf20, 0x6bcf30, 0x6bcf50, 0x6bcf60, 0x6bcf80, 0x6bcf90, 0x6bcfb0, 0x6bcfc0, 0x6bcfe0, 0x6bcff0, 0x6c3870, 0x6c3880, 0x6c4730, 0x6c4740, 0x6c4750, 0x6c4760, 0x6c4780, 0x6c4790, 0x6c47b0, 0x6c47c0, 0x6c47e0, 0x6c47f0, 0x6c4810, 0x6c4820, 0x6c4840, 0x6c4850, 0x6c4870, 0x6c4880, 0x6c48a0, 0x6c48b0, 0x6c48d0, 0x6c48e0, 0x6c4900, 0x6c4910, 0x6c4930, 0x6c4940, 0x6c4960, 0x6c4970, 0x6c4990, 0x6c49a0, 0x6c49c0, 0x6c49d0, 0x6c49f0, 0x6c4a00, 0x6c4a10, 0x6c4a20, 0x6c4a40, 0x6c4a50, 0x6c4a70, 0x6c4a80, 0x6c4aa0, 0x6c4ab0, 0x6c4ad0, 0x6c4ae0, 0x6c4b00, 0x6c4b10, 0x6c4b30, 0x6c4b40, 0x6c4b60, 0x6c4b70, 0x6c4b90, 0x6c4ba0, 0x6c4bc0, 0x6c4bd0, 0x6c4bf0, 0x6c4c00, 0x706e40, 0x706e50, 0x706e60, 0x706e70, 0x706e80, 0x706e90, 0x706eb0, 0x706ec0, 0x706ee0, 0x706ef0, 0x70b310, 0x70b320, 0x70d9b0, 0x70d9c0, 0x70d9d0, 0x70d9e0, 0x70dc00, 0x70dc10, 0x70dc30, 0x70dc40, 0x711bd0, 0x711be0, 0x714210, 0x714220, 0x714230, 0x714240, 0x71b030, 0x71b040, 0x71b060, 0x71b070, 0x71cc40, 0x71cc50, 0x71cc60, 0x71cc70, 0x71cc80, 0x71cc90, 0x71ccb0, 0x71ccc0, 0x71cce0, 0x71ccf0, 0x71e050, 0x71e060, 0x71e070, 0x71e080, 0x71e090, 0x71e0a0, 0x71f800, 0x71f810, 0x71f830, 0x71f840, 0x71f9f0, 0x71fa00, 0x71fa10, 0x71fa20, 0x71fa30, 0x71fa40, 0x71fa60, 0x71fa70, 0x71fa90, 0x71faa0, 0x7af1b0, 0x7af1c0, 0x7af1d0, 0x7af1e0, 0x7b0dd0, 0x7b0de0, 0x7b0df0, 0x7b0e00, 0x7b0e10, 0x7b0e20, 0x7b0e40, 0x7b0e50, 0x7b0e70, 0x7b0e80, 0x7b6c10, 0x7b6c20, 0x7b8390, 0x7b83a0, 0x7b83b0, 0x7b83c0, 0x7b8750, 0x7b8760, 0x7b9aa0, 0x7b9ab0, 0x7b9ac0, 0x7b9ad0, 0x7b9af0, 0x7b9b00, 0x7b9f00, 0x7b9f10, 0x7b9f20, 0x7b9f30, 0x7b9f50, 0x7b9f60, 0x7ba860, 0x7ba870, 0x7ba880, 0x7ba890, 0x6a2c80, 0x6b83b0
Confidence: verified
Proof: one
Test: models::inv_tile_size_difftest
Each body is fld; fadd st(0),st; fstp for 2π, fld 1.0; fdiv; fstp for the quotients, fld; fmul; fstp for the products, mov eax,[c]; mov [g],eax for +∞ and mov dword [g],0x40a00000
for 5.0. The bodies were classified one by one from their instructions and constants. 0x692c20
zeroes three dwords and 0x800 dwords from the BSP scratch.
inv_tile_size_difftest runs 0x6bcf90 whole.
Static objects
The files' own statics: the model cache, the identity matrices of the scene, model and particle
files, the particle up axis and four-vector table, the sortable particle record heap, the legacy
particle seed, the BSP 3×3 identity, and the map object pool, vectors, plane and vertex pools. Each
initializer calls its body and jumps to a registrar that passes its exit hook to _atexit.
Addresses: 0x692c40, 0x692c50, 0x692cb0, 0x692cc0, 0x6a2c90, 0x6a2ca0, 0x6a2d60, 0x6a2d70, 0x6a2ef0, 0x6a2f00, 0x6a2f20, 0x6a2f30, 0x6a2f50, 0x6a2f60, 0x6a2f80, 0x6a2f90, 0x6a2fb0, 0x6a2fc0, 0x6a3010, 0x6a3020, 0x6b83c0, 0x6b83d0, 0x6b8410, 0x6b8420, 0x6b8540, 0x6b8550, 0x6b8590, 0x6b85a0, 0x6b86c0, 0x6b86d0, 0x6b8700, 0x6b8710, 0x706d90, 0x706da0, 0x706db0, 0x706dc0, 0x706f10, 0x706f20, 0x706fd0, 0x706fe0, 0x70dc60, 0x70dc70, 0x70dd20, 0x70dd30, 0x7b0ea0, 0x7b0eb0, 0x7b0ed0, 0x7b0ee0, 0x7b0ef0, 0x7b0f00, 0x7b0f40, 0x7b0f50, 0x7b0f80, 0x7b0f90, 0x7b1040, 0x7b1050, 0x7b1070, 0x7b1080, 0x7b10a0, 0x7b10b0, 0x7b9f70, 0x7b9f80, 0x7b9f90, 0x7b9fa0, 0xca8038
Confidence: verified
Proof: one
Test: none
The pairs are call body; jmp registrar; each registrar is push hook; call 0x409aef; pop ecx; ret. The hooks either destroy their object, set a guard bit of their file, or return. 0x6a2ca0
sets up the map object hash table at 0xca8038: vtable 0x810998, link offset 0x10 at +0x4, an
empty list head at +0x8 and the mask −1 at +0x24; 0x6a3388 passes it to 0x6a5b80 to resize.
Unreached code
182 functions of the system have no live caller: the deleting destructors and accessors the
compiler kept, the legacy particle emitter, most of the emitter registries, BSP building, the
group liquid-area test, and getters no code uses. No call or jmp from live code reaches them,
no byte sequence e8 or e9 encodes a branch to one from live code, and their addresses appear
nowhere in the image as a dword. The liquid-area test 0x6a4ee0 is called only at 0x69b4eb, in
the terrain's unreached 0x69b4a0, and its tile-flag lookup 0x6b9e50 only from it.
Addresses: 0x692ce0, 0x692df0, 0x692f60, 0x692fc0, 0x693020, 0x693120, 0x693140, 0x693160, 0x693170, 0x693190, 0x693310, 0x6934a0, 0x693700, 0x693830, 0x6938a0, 0x693ad0, 0x6a42e0, 0x6a4710, 0x6a48e0, 0x6a4b40, 0x6a4ee0, 0x6b9950, 0x6b9d60, 0x6b9e50, 0x6ba6e0, 0x6bbd10, 0x7072c0, 0x707310, 0x7075e0, 0x70e7a0, 0x70e7f0, 0x70e840, 0x70e890, 0x70e920, 0x70e970, 0x710c30, 0x710c80, 0x710cc0, 0x710d10, 0x710d60, 0x710d70, 0x710d90, 0x710da0, 0x711080, 0x7117e0, 0x711830, 0x7119a0, 0x711d70, 0x711dd0, 0x711e60, 0x711ec0, 0x7120e0, 0x712a90, 0x712bf0, 0x712f40, 0x713130, 0x713260, 0x7133d0, 0x713400, 0x713500, 0x713740, 0x713c80, 0x71b510, 0x71b720, 0x7ae2d0, 0x7ae3f0, 0x7ae520, 0x7ae650, 0x7ae8a0, 0x7aea10, 0x7aea20, 0x7aea30, 0x7aea40, 0x7aeb60, 0x7aec80, 0x7aed90, 0x7aeeb0, 0x7aef80, 0x7af080, 0x7af090, 0x7af0a0, 0x7af200, 0x7af2f0, 0x7af330, 0x7af350, 0x7af3e0, 0x7af420, 0x7af440, 0x7af4d0, 0x7af510, 0x7af530, 0x7b34e0, 0x7b37d0, 0x7b39b0, 0x7b4bd0, 0x7b4cc0, 0x7b4cf0, 0x7b4d50, 0x7b4fd0, 0x7b4fe0, 0x7b4ff0, 0x7b5000, 0x7b5010, 0x7b5020, 0x7b5030, 0x7b5040, 0x7b5050, 0x7b5070, 0x7b5090, 0x7b50d0, 0x7b54e0, 0x7b5c60, 0x7b5d20, 0x7b6500, 0x7b71f0, 0x7b7380, 0x7b7830, 0x7b79e0, 0x7b7a30, 0x7b7e20, 0x7b82e0, 0x7b82f0, 0x7b85c0, 0x7b8630, 0x7b86e0, 0x7b8bd0, 0x7b8be0, 0x7b8bf0, 0x7b8c00, 0x7b9140, 0x7b9150, 0x7b9160, 0x7b9170, 0x7b9930, 0x7b9940, 0x7b9950, 0x7b9960, 0x7b9e40, 0x7b9e60, 0x7b9e70, 0x7b9e80, 0x7b9ea0, 0x7b9ec0, 0x7b9ee0, 0x7b9fb0, 0x7ba010, 0x7ba060, 0x7ba0b0, 0x7ba0c0, 0x7ba200, 0x7ba370, 0x7ba380, 0x7ba430, 0x7ba470, 0x7ba4c0, 0x7ba550, 0x7ba560, 0x7ba570, 0x7ba580, 0x7ba590, 0x7ba5a0, 0x7ba5b0, 0x7ba5c0, 0x7ba5d0, 0x7ba5e0, 0x7ba720, 0x7ba730, 0x7ba740, 0x7ba780, 0x7ba790, 0x7ba7a0, 0x7ba7b0, 0x7ba7c0, 0x7ba7d0, 0x7ba7e0, 0x7ba7f0, 0x7ba800, 0x7ba830, 0x7ba8b0, 0x7ba8f0, 0x7ba910, 0x7ba9f0
Confidence: verified
Proof: one
Test: none
The census takes every listing operand, every aligned dword of .rdata and .data, and every
e8/e9 rel32 in .text, and walks from the live entries: references from other systems' code,
initializer slots, stored addresses, and vtable slots whose vtable a live constructor installs. The
rel32 scan finds no hit for any of the 182 except from other unreached code, and an image-wide
dword search finds none. As a control, the scan finds the call to 0x7b5230 at 0x719164 and the
dword 0x7b8890 in the vtable at 0x81d890.