refactor: name TeamHeader.turn_action_flags, clean up fire_skip_go
Browse filesIdentify TeamHeader._unknown_7c as turn_action_flags (u32 bitfield).
Skip Go toggles a bit here to mark the team's turn as skipped.
In game_version > 0x1C the bit toggles; in older versions it only sets.
fire_skip_go now accesses the field via TeamArenaRef::team_header()
instead of raw byte slicing into team_blocks_region.
Verified: headless PASS (byte-identical).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
crates/openwa-core/src/engine/ddgame.rs
CHANGED
|
@@ -1698,8 +1698,11 @@ pub struct TeamHeader {
|
|
| 1698 |
pub active_worm: i32,
|
| 1699 |
/// 0x78: Number of worms on this team.
|
| 1700 |
pub worm_count: i32,
|
| 1701 |
-
/// 0x7C:
|
| 1702 |
-
|
|
|
|
|
|
|
|
|
|
| 1703 |
/// 0x80: Alliance ID for ammo/delay table indexing (GetAmmo/AddAmmo/SubtractAmmo).
|
| 1704 |
/// Teams with the same weapon_alliance share ammo pools. Distinct from
|
| 1705 |
/// `alliance` at 0x70 which is used by CountTeamsByAlliance.
|
|
|
|
| 1698 |
pub active_worm: i32,
|
| 1699 |
/// 0x78: Number of worms on this team.
|
| 1700 |
pub worm_count: i32,
|
| 1701 |
+
/// 0x7C: Per-team turn action flags (bitfield).
|
| 1702 |
+
/// Skip Go (weapon 57) toggles a bit here based on the weapon's fire_params.
|
| 1703 |
+
/// Bit is set to mark the team should skip; in game_version > 0x1C, toggling
|
| 1704 |
+
/// again clears it.
|
| 1705 |
+
pub turn_action_flags: u32,
|
| 1706 |
/// 0x80: Alliance ID for ammo/delay table indexing (GetAmmo/AddAmmo/SubtractAmmo).
|
| 1707 |
/// Teams with the same weapon_alliance share ammo pools. Distinct from
|
| 1708 |
/// `alliance` at 0x70 which is used by CountTeamsByAlliance.
|
crates/openwa-wormkit/src/replacements/weapon.rs
CHANGED
|
@@ -395,29 +395,30 @@ unsafe fn fire_weapon_special(
|
|
| 395 |
|
| 396 |
/// Skip Go (subtype 19) — pure Rust replacement for 0x51E8C0.
|
| 397 |
///
|
| 398 |
-
/// Toggles a bit in the team's
|
| 399 |
-
///
|
| 400 |
-
///
|
| 401 |
unsafe fn fire_skip_go(worm: *const CTaskWorm, entry: *const WeaponEntry) {
|
|
|
|
|
|
|
| 402 |
use openwa_core::engine::DDGame;
|
| 403 |
|
| 404 |
-
let ddgame =
|
| 405 |
-
let game_version = (*ddgame.game_info).game_version;
|
| 406 |
let team_index = (*worm).team_index as usize;
|
| 407 |
|
| 408 |
let bit_index = (*entry).fire_params._data[0] & 0x1F;
|
| 409 |
let bit = 1u32 << bit_index;
|
| 410 |
|
| 411 |
-
|
| 412 |
-
let
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
let flags = *flags_ptr;
|
| 416 |
|
| 417 |
if game_version > 0x1C && (flags & bit) != 0 {
|
| 418 |
-
*
|
| 419 |
} else {
|
| 420 |
-
*
|
| 421 |
}
|
| 422 |
}
|
| 423 |
|
|
|
|
| 395 |
|
| 396 |
/// Skip Go (subtype 19) — pure Rust replacement for 0x51E8C0.
|
| 397 |
///
|
| 398 |
+
/// Toggles a bit in the team's `TeamHeader.turn_action_flags` (+0x7C).
|
| 399 |
+
/// Bit position comes from weapon entry's fire_params.
|
| 400 |
+
/// In game_version > 0x1C: toggles (set/clear). Otherwise: always sets.
|
| 401 |
unsafe fn fire_skip_go(worm: *const CTaskWorm, entry: *const WeaponEntry) {
|
| 402 |
+
use openwa_core::engine::ddgame::TeamArenaRef;
|
| 403 |
+
use openwa_core::engine::ddgame::TeamHeader;
|
| 404 |
use openwa_core::engine::DDGame;
|
| 405 |
|
| 406 |
+
let ddgame = (*worm).base.base.ddgame as *mut DDGame;
|
| 407 |
+
let game_version = (*(*ddgame).game_info).game_version;
|
| 408 |
let team_index = (*worm).team_index as usize;
|
| 409 |
|
| 410 |
let bit_index = (*entry).fire_params._data[0] & 0x1F;
|
| 411 |
let bit = 1u32 << bit_index;
|
| 412 |
|
| 413 |
+
let arena_ptr = &raw mut (*ddgame).team_arena as u32;
|
| 414 |
+
let arena = TeamArenaRef::from_raw(arena_ptr);
|
| 415 |
+
let header = arena.team_header(team_index) as *const TeamHeader as *mut TeamHeader;
|
| 416 |
+
let flags = (*header).turn_action_flags;
|
|
|
|
| 417 |
|
| 418 |
if game_version > 0x1C && (flags & bit) != 0 {
|
| 419 |
+
(*header).turn_action_flags = flags & !bit;
|
| 420 |
} else {
|
| 421 |
+
(*header).turn_action_flags = flags | bit;
|
| 422 |
}
|
| 423 |
}
|
| 424 |
|