refactor: rename NapalmStrike subtype to StrikeFire
Browse filesSpecialFireSubtype::NapalmStrike (subtype 13) is actually used by
multiple weapons (Napalm Strike, Surrender, and others) β it's a
generic "send team message 0x2B" handler, not Napalm-specific.
Renamed to StrikeFire to match the WA function name (StrikeFire at
0x51E2C0). Also renamed TeamMessage::NapalmStrike to StrikeFire and
on_napalm_strike to on_strike_fire.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
crates/openwa-core/src/game/weapon.rs
CHANGED
|
@@ -223,7 +223,7 @@ pub enum SpecialFireSubtype {
|
|
| 223 |
AirStrike = 10,
|
| 224 |
ScalesOfJustice = 11,
|
| 225 |
// 12: unknown
|
| 226 |
-
|
| 227 |
MailMineMole = 14,
|
| 228 |
// 15: unknown
|
| 229 |
IndianNuclearTest = 16,
|
|
@@ -251,7 +251,7 @@ impl TryFrom<i32> for SpecialFireSubtype {
|
|
| 251 |
9 => Ok(Self::Prod),
|
| 252 |
10 => Ok(Self::AirStrike),
|
| 253 |
11 => Ok(Self::ScalesOfJustice),
|
| 254 |
-
13 => Ok(Self::
|
| 255 |
14 => Ok(Self::MailMineMole),
|
| 256 |
16 => Ok(Self::IndianNuclearTest),
|
| 257 |
17 => Ok(Self::Freeze),
|
|
|
|
| 223 |
AirStrike = 10,
|
| 224 |
ScalesOfJustice = 11,
|
| 225 |
// 12: unknown
|
| 226 |
+
StrikeFire = 13,
|
| 227 |
MailMineMole = 14,
|
| 228 |
// 15: unknown
|
| 229 |
IndianNuclearTest = 16,
|
|
|
|
| 251 |
9 => Ok(Self::Prod),
|
| 252 |
10 => Ok(Self::AirStrike),
|
| 253 |
11 => Ok(Self::ScalesOfJustice),
|
| 254 |
+
13 => Ok(Self::StrikeFire),
|
| 255 |
14 => Ok(Self::MailMineMole),
|
| 256 |
16 => Ok(Self::IndianNuclearTest),
|
| 257 |
17 => Ok(Self::Freeze),
|
crates/openwa-core/src/task/team.rs
CHANGED
|
@@ -118,26 +118,20 @@ bind_CTaskTeamVTable!(CTaskTeam, base.vtable);
|
|
| 118 |
// ββ Typed message handlers ββββββββββββββββββββββββββββββββββ
|
| 119 |
|
| 120 |
impl CTaskTeam {
|
| 121 |
-
/// Handle
|
|
|
|
| 122 |
///
|
| 123 |
-
///
|
| 124 |
-
///
|
| 125 |
-
/// Logic:
|
| 126 |
-
/// 1. Team ownership check (msg team_index must match this.team_index)
|
| 127 |
-
/// 2. If game_version > 0xF4: broadcast DetonateWeapon (0x2A) to children
|
| 128 |
-
/// 3. Set per-team napalm flag at ddgame + team_index * 0x51C + 0x4618
|
| 129 |
-
/// 4. Broadcast original message (0x2B) to children
|
| 130 |
-
///
|
| 131 |
-
/// # Safety
|
| 132 |
-
/// `this` must be a valid CTaskTeam pointer with valid ddgame.
|
| 133 |
-
/// Handle NapalmStrike message (0x2B) β ported from CTaskTeam::HandleMessage.
|
| 134 |
///
|
| 135 |
/// Uses `CTask::broadcast_message_raw` for child dispatch (no `&mut self`,
|
| 136 |
/// no noalias UB). This is a pure Rust handler β no bridge to WA code.
|
| 137 |
///
|
|
|
|
|
|
|
| 138 |
/// # Safety
|
| 139 |
/// `this` must be a valid CTaskTeam pointer with valid ddgame.
|
| 140 |
-
pub unsafe fn
|
| 141 |
this: *mut Self,
|
| 142 |
sender: *mut CTask,
|
| 143 |
msg_team_index: u32,
|
|
|
|
| 118 |
// ββ Typed message handlers ββββββββββββββββββββββββββββββββββ
|
| 119 |
|
| 120 |
impl CTaskTeam {
|
| 121 |
+
/// Handle StrikeFire / Surrender message (0x2B) β ported from
|
| 122 |
+
/// CTaskTeam::HandleMessage case 0x2B.
|
| 123 |
///
|
| 124 |
+
/// Used by SpecialFireSubtype::StrikeFire (subtype 13), shared by
|
| 125 |
+
/// Napalm Strike, Surrender, and other weapons.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
///
|
| 127 |
/// Uses `CTask::broadcast_message_raw` for child dispatch (no `&mut self`,
|
| 128 |
/// no noalias UB). This is a pure Rust handler β no bridge to WA code.
|
| 129 |
///
|
| 130 |
+
/// **Status:** Has a behavioral difference vs the WA handler β under investigation.
|
| 131 |
+
///
|
| 132 |
/// # Safety
|
| 133 |
/// `this` must be a valid CTaskTeam pointer with valid ddgame.
|
| 134 |
+
pub unsafe fn on_strike_fire(
|
| 135 |
this: *mut Self,
|
| 136 |
sender: *mut CTask,
|
| 137 |
msg_team_index: u32,
|
crates/openwa-core/src/task/team_message.rs
CHANGED
|
@@ -12,9 +12,11 @@ use crate::game::TaskMessage;
|
|
| 12 |
/// its payload as typed fields instead of a raw byte buffer.
|
| 13 |
#[derive(Debug, Clone, Copy)]
|
| 14 |
pub enum TeamMessage {
|
| 15 |
-
/// 0x2B (Surrender):
|
|
|
|
|
|
|
| 16 |
/// Sets a per-team flag and optionally broadcasts DetonateWeapon.
|
| 17 |
-
|
| 18 |
/// Team index (1-based) identifying which team fired.
|
| 19 |
team_index: u32,
|
| 20 |
},
|
|
@@ -32,12 +34,11 @@ impl TeamMessage {
|
|
| 32 |
pub unsafe fn from_raw(msg_type: u32, _size: u32, data: *const u8) -> Option<Self> {
|
| 33 |
match TaskMessage::try_from(msg_type) {
|
| 34 |
Ok(TaskMessage::Surrender) => {
|
| 35 |
-
// data[0..4] = team_index
|
| 36 |
if data.is_null() {
|
| 37 |
return None;
|
| 38 |
}
|
| 39 |
let team_index = *(data as *const u32);
|
| 40 |
-
Some(TeamMessage::
|
| 41 |
}
|
| 42 |
_ => None,
|
| 43 |
}
|
|
@@ -48,7 +49,7 @@ impl TeamMessage {
|
|
| 48 |
/// Writes the payload into `buf` and returns `(msg_type, size)`.
|
| 49 |
pub fn to_raw(&self, buf: &mut [u8]) -> (u32, u32) {
|
| 50 |
match self {
|
| 51 |
-
TeamMessage::
|
| 52 |
buf[0..4].copy_from_slice(&team_index.to_ne_bytes());
|
| 53 |
(TaskMessage::Surrender as u32, 4)
|
| 54 |
}
|
|
|
|
| 12 |
/// its payload as typed fields instead of a raw byte buffer.
|
| 13 |
#[derive(Debug, Clone, Copy)]
|
| 14 |
pub enum TeamMessage {
|
| 15 |
+
/// 0x2B (Surrender): Strike fire / team-targeted action.
|
| 16 |
+
/// Used by SpecialFireSubtype::StrikeFire (subtype 13) β shared by
|
| 17 |
+
/// Napalm Strike, Surrender, and other weapons that send a team message.
|
| 18 |
/// Sets a per-team flag and optionally broadcasts DetonateWeapon.
|
| 19 |
+
StrikeFire {
|
| 20 |
/// Team index (1-based) identifying which team fired.
|
| 21 |
team_index: u32,
|
| 22 |
},
|
|
|
|
| 34 |
pub unsafe fn from_raw(msg_type: u32, _size: u32, data: *const u8) -> Option<Self> {
|
| 35 |
match TaskMessage::try_from(msg_type) {
|
| 36 |
Ok(TaskMessage::Surrender) => {
|
|
|
|
| 37 |
if data.is_null() {
|
| 38 |
return None;
|
| 39 |
}
|
| 40 |
let team_index = *(data as *const u32);
|
| 41 |
+
Some(TeamMessage::StrikeFire { team_index })
|
| 42 |
}
|
| 43 |
_ => None,
|
| 44 |
}
|
|
|
|
| 49 |
/// Writes the payload into `buf` and returns `(msg_type, size)`.
|
| 50 |
pub fn to_raw(&self, buf: &mut [u8]) -> (u32, u32) {
|
| 51 |
match self {
|
| 52 |
+
TeamMessage::StrikeFire { team_index } => {
|
| 53 |
buf[0..4].copy_from_slice(&team_index.to_ne_bytes());
|
| 54 |
(TaskMessage::Surrender as u32, 4)
|
| 55 |
}
|
crates/openwa-wormkit/src/replacements/weapon.rs
CHANGED
|
@@ -323,7 +323,7 @@ unsafe fn fire_weapon_special(
|
|
| 323 |
Ok(S::Prod) => fire_prod(worm, ctx as *const u8),
|
| 324 |
Ok(S::AirStrike) => fire_air_strike(worm),
|
| 325 |
Ok(S::ScalesOfJustice) => CTaskWorm::set_state_raw(worm, WormState::ScalesOfJustice),
|
| 326 |
-
Ok(S::
|
| 327 |
Ok(S::MailMineMole) => fire_mail_mine_mole(worm),
|
| 328 |
Ok(S::IndianNuclearTest) => {
|
| 329 |
if can_fire_subtype16((*worm).state()) {
|
|
@@ -364,14 +364,13 @@ pub(crate) unsafe fn lookup_team_task(worm: *const CTaskWorm) -> *mut openwa_cor
|
|
| 364 |
table.lookup(0, 0x14) as *mut openwa_core::task::CTaskTeam
|
| 365 |
}
|
| 366 |
|
| 367 |
-
///
|
| 368 |
///
|
| 369 |
-
///
|
| 370 |
-
///
|
| 371 |
-
///
|
| 372 |
-
/// Uses on_napalm_strike for the full Rust path.
|
| 373 |
#[inline(never)]
|
| 374 |
-
unsafe fn
|
| 375 |
use openwa_core::task::TeamMessage;
|
| 376 |
|
| 377 |
let team = lookup_team_task(worm);
|
|
@@ -379,7 +378,7 @@ unsafe fn fire_napalm_strike_typed(worm: *mut CTaskWorm) {
|
|
| 379 |
return;
|
| 380 |
}
|
| 381 |
|
| 382 |
-
let msg = TeamMessage::
|
| 383 |
team_index: (*worm).team_index,
|
| 384 |
};
|
| 385 |
let mut buf = [0u8; 0x40C];
|
|
|
|
| 323 |
Ok(S::Prod) => fire_prod(worm, ctx as *const u8),
|
| 324 |
Ok(S::AirStrike) => fire_air_strike(worm),
|
| 325 |
Ok(S::ScalesOfJustice) => CTaskWorm::set_state_raw(worm, WormState::ScalesOfJustice),
|
| 326 |
+
Ok(S::StrikeFire) => fire_strike_typed(worm),
|
| 327 |
Ok(S::MailMineMole) => fire_mail_mine_mole(worm),
|
| 328 |
Ok(S::IndianNuclearTest) => {
|
| 329 |
if can_fire_subtype16((*worm).state()) {
|
|
|
|
| 364 |
table.lookup(0, 0x14) as *mut openwa_core::task::CTaskTeam
|
| 365 |
}
|
| 366 |
|
| 367 |
+
/// StrikeFire (subtype 13) β typed Rust handler.
|
| 368 |
///
|
| 369 |
+
/// Shared by Napalm Strike, Surrender, and other weapons that send
|
| 370 |
+
/// message 0x2B to CTaskTeam. Constructs a typed TeamMessage::StrikeFire,
|
| 371 |
+
/// serializes to raw bytes, and dispatches through CTaskTeam's WA vtable.
|
|
|
|
| 372 |
#[inline(never)]
|
| 373 |
+
unsafe fn fire_strike_typed(worm: *mut CTaskWorm) {
|
| 374 |
use openwa_core::task::TeamMessage;
|
| 375 |
|
| 376 |
let team = lookup_team_task(worm);
|
|
|
|
| 378 |
return;
|
| 379 |
}
|
| 380 |
|
| 381 |
+
let msg = TeamMessage::StrikeFire {
|
| 382 |
team_index: (*worm).team_index,
|
| 383 |
};
|
| 384 |
let mut buf = [0u8; 0x40C];
|