paavohtl Claude Opus 4.6 (1M context) commited on
Commit
9d278f7
·
1 Parent(s): 89c4a78

refactor: name CTaskWorm weapon_self_ptr field, make game_task pub

Browse files

Add weapon_self_ptr (*mut CTaskWorm) at CTaskWorm+0x36C — the
self-pointer read by WeaponRelease (MOV EAX, [EDI+0x36C]) before
calling FireWeapon. Make game_task module public for typed access.

Note: weapon fire state fields at CGameTask+0x30..+0x3C are NOT added
to CGameTask because the _unknown_30 region is polymorphic — each
subclass (worm, missile, filter, team) uses it differently.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

crates/openwa-core/src/task/mod.rs CHANGED
@@ -3,7 +3,7 @@ pub mod bit_grid;
3
  mod cloud;
4
  mod filter;
5
  mod fire;
6
- mod game_task;
7
  mod mine_oil_drum;
8
  mod missile;
9
  mod overlays;
 
3
  mod cloud;
4
  mod filter;
5
  mod fire;
6
+ pub mod game_task;
7
  mod mine_oil_drum;
8
  mod missile;
9
  mod overlays;
crates/openwa-core/src/task/worm.rs CHANGED
@@ -151,8 +151,11 @@ pub struct CTaskWorm {
151
  pub _unknown_338: [u8; 0x368 - 0x338],
152
  /// 0x368: Animator / controller object (dispatched via vtable for state animations)
153
  pub animator: *mut u8,
154
- /// 0x36C–0x3DB: Unknown (rope anchor, weapon-specific data, etc.)
155
- pub _unknown_36c: [u8; 0x3DC - 0x36C],
 
 
 
156
  /// 0x3DC: Facing direction. -1 = facing left, +1 = facing right.
157
  pub facing_direction: i32,
158
  /// 0x3E0–0x3E3: Unknown
@@ -173,13 +176,12 @@ const _: () = assert!(core::mem::size_of::<CTaskWorm>() == 0x3FC);
173
 
174
  impl CTaskWorm {
175
  /// Returns the worm's current state code (lives at offset +0x44, inside the
176
- /// CGameTask base's `_unknown_30` padding region).
177
  ///
178
  /// Known states: `0x65`=idle, `0x67`=active turn, `0x7F`=drowning,
179
  /// `0x80`=hurt, `0x81`/`0x86`=dead, `0x87`=dead variant, `0x8B`=unknown.
180
  pub fn state(&self) -> u32 {
181
- // SAFETY: offset 0x44 is within CGameTask._unknown_30 (0x30..0x84).
182
- // Aligned to 4 bytes; repr(C) guarantees no reordering.
183
  unsafe { *((self as *const CTaskWorm as *const u8).add(0x44) as *const u32) }
184
  }
185
 
 
151
  pub _unknown_338: [u8; 0x368 - 0x338],
152
  /// 0x368: Animator / controller object (dispatched via vtable for state animations)
153
  pub animator: *mut u8,
154
+ /// 0x36C: Self-pointer (points to this CTaskWorm). Used by WeaponRelease
155
+ /// to load EAX before calling FireWeapon: `MOV EAX, [EDI+0x36C]`.
156
+ pub weapon_self_ptr: *mut CTaskWorm,
157
+ /// 0x370–0x3DB: Unknown (rope anchor, weapon-specific data, etc.)
158
+ pub _unknown_370: [u8; 0x3DC - 0x370],
159
  /// 0x3DC: Facing direction. -1 = facing left, +1 = facing right.
160
  pub facing_direction: i32,
161
  /// 0x3E0–0x3E3: Unknown
 
176
 
177
  impl CTaskWorm {
178
  /// Returns the worm's current state code (lives at offset +0x44, inside the
179
+ /// CGameTask base's `_unknown_40` padding region).
180
  ///
181
  /// Known states: `0x65`=idle, `0x67`=active turn, `0x7F`=drowning,
182
  /// `0x80`=hurt, `0x81`/`0x86`=dead, `0x87`=dead variant, `0x8B`=unknown.
183
  pub fn state(&self) -> u32 {
184
+ // SAFETY: offset 0x44 is within CGameTask._unknown_40 (0x40..0x84).
 
185
  unsafe { *((self as *const CTaskWorm as *const u8).add(0x44) as *const u32) }
186
  }
187