refactor: extract WeaponFireParams sub-struct from WeaponEntry
Browse filesThe region at WeaponEntry+0x3C onward is passed as a pointer to all
fire sub-functions. Extract it as WeaponFireParams (0x194 bytes),
embedded in WeaponEntry. Internal layout still unknown but the struct
boundary is now explicit.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
crates/openwa-core/src/game/weapon.rs
CHANGED
|
@@ -135,14 +135,23 @@ pub struct WeaponEntry {
|
|
| 135 |
pub fire_subtype_34: i32,
|
| 136 |
/// +0x38: Fire subtype for weapon types 1 (projectile) and 2 (rope).
|
| 137 |
pub fire_subtype_38: i32,
|
| 138 |
-
/// +0x3C:
|
| 139 |
-
/// to fire sub-functions
|
| 140 |
-
pub
|
| 141 |
-
/// +0x40-0x1CF: Unknown fields.
|
| 142 |
-
pub _unknown_40: [u8; 0x1D0 - 0x40],
|
| 143 |
}
|
| 144 |
const _: () = assert!(core::mem::size_of::<WeaponEntry>() == 0x1D0);
|
| 145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
/// Weapon table — flat array of 71 entries, no header.
|
| 147 |
///
|
| 148 |
/// Allocated by `InitWeaponTable` (0x53CAB0), stored at DDGame+0x510.
|
|
|
|
| 135 |
pub fire_subtype_34: i32,
|
| 136 |
/// +0x38: Fire subtype for weapon types 1 (projectile) and 2 (rope).
|
| 137 |
pub fire_subtype_38: i32,
|
| 138 |
+
/// +0x3C: Fire parameters sub-structure. Pointer to this field is passed
|
| 139 |
+
/// to fire sub-functions (PlacedExplosive, Projectile, CreateWeaponProjectile, etc.).
|
| 140 |
+
pub fire_params: WeaponFireParams,
|
|
|
|
|
|
|
| 141 |
}
|
| 142 |
const _: () = assert!(core::mem::size_of::<WeaponEntry>() == 0x1D0);
|
| 143 |
|
| 144 |
+
/// Weapon fire parameters — embedded at WeaponEntry+0x3C.
|
| 145 |
+
///
|
| 146 |
+
/// Pointer to this struct is passed to all fire dispatch sub-functions.
|
| 147 |
+
/// Internal layout is mostly unknown (0x194 bytes).
|
| 148 |
+
#[repr(C)]
|
| 149 |
+
pub struct WeaponFireParams {
|
| 150 |
+
/// +0x00 (WeaponEntry+0x3C): First param DWORD.
|
| 151 |
+
pub _data: [u8; 0x1D0 - 0x3C],
|
| 152 |
+
}
|
| 153 |
+
const _: () = assert!(core::mem::size_of::<WeaponFireParams>() == 0x1D0 - 0x3C);
|
| 154 |
+
|
| 155 |
/// Weapon table — flat array of 71 entries, no header.
|
| 156 |
///
|
| 157 |
/// Allocated by `InitWeaponTable` (0x53CAB0), stored at DDGame+0x510.
|
crates/openwa-wormkit/src/replacements/weapon.rs
CHANGED
|
@@ -196,7 +196,7 @@ unsafe extern "cdecl" fn fire_weapon_impl(
|
|
| 196 |
let weapon_type = (*entry).fire_type;
|
| 197 |
let subtype_34 = (*entry).fire_subtype_34;
|
| 198 |
let subtype_38 = (*entry).fire_subtype_38;
|
| 199 |
-
let fire_params = &raw const (*entry).
|
| 200 |
let w = worm as u32;
|
| 201 |
|
| 202 |
// Log weapon fire
|
|
|
|
| 196 |
let weapon_type = (*entry).fire_type;
|
| 197 |
let subtype_34 = (*entry).fire_subtype_34;
|
| 198 |
let subtype_38 = (*entry).fire_subtype_38;
|
| 199 |
+
let fire_params = &raw const (*entry).fire_params as u32;
|
| 200 |
let w = worm as u32;
|
| 201 |
|
| 202 |
// Log weapon fire
|