paavohtl Claude Opus 4.6 (1M context) commited on
Commit
c02910c
·
1 Parent(s): 2eaf41f

refactor: use TaskStateMachine struct for sprite width/height reads

Browse files

Replace *(sprite.add(0x14)) and *(sprite.add(0x18)) with typed
TaskStateMachine field access (.width, .height) in the arrow
collision region computation.

Remaining pointer arithmetic candidates in ddgame.rs:
- GfxHandler +0x198 (file handle) — needs GfxHandler struct (0x19C bytes)
- DDDisplay +0x3120/+0x3534/+0x312C (palette range) — DDDisplay fields
- PCLandscape +0xB34/+0xB38 (land/water layer ptrs) — PCLandscape fields
- DDGame raw fields (0x468, 0x7308, 0x777C, 0x7780) — unnamed struct fields

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

crates/openwa-core/src/engine/ddgame.rs CHANGED
@@ -1028,8 +1028,9 @@ unsafe fn init_graphics_and_resources(
1028
 
1029
  // Calculate collision region dimensions from sprite
1030
  if !sprite.is_null() {
1031
- let sprite_w = *(sprite.add(0x14) as *const i32);
1032
- let sprite_h = *(sprite.add(0x18) as *const i32);
 
1033
  let half_w = (sprite_w / 2 - 10).max(0);
1034
  let half_h = (sprite_h / 2 - 10).max(0);
1035
 
 
1028
 
1029
  // Calculate collision region dimensions from sprite
1030
  if !sprite.is_null() {
1031
+ let tsm = &*(sprite as *const TaskStateMachine);
1032
+ let sprite_w = tsm.width as i32;
1033
+ let sprite_h = tsm.height as i32;
1034
  let half_w = (sprite_w / 2 - 10).max(0);
1035
  let half_h = (sprite_h / 2 - 10).max(0);
1036