chore: prefer use over qualified path for structs
Browse files
crates/openwa-core/src/engine/team_arena.rs
CHANGED
|
@@ -5,6 +5,8 @@
|
|
| 5 |
// Extracted from ddgame.rs: team/worm data structures, TeamArenaRef,
|
| 6 |
// and related helper structs used as DDGame fields.
|
| 7 |
|
|
|
|
|
|
|
| 8 |
use super::ddgame::offsets;
|
| 9 |
|
| 10 |
/// Coordinate entry used in DDGame screen coordinate tables (stride 0x10).
|
|
@@ -541,8 +543,7 @@ impl crate::snapshot::Snapshot for WormEntry {
|
|
| 541 |
) -> core::fmt::Result {
|
| 542 |
use crate::snapshot::write_indent;
|
| 543 |
let i = indent;
|
| 544 |
-
let name =
|
| 545 |
-
.to_string_lossy();
|
| 546 |
write_indent(w, i)?;
|
| 547 |
writeln!(
|
| 548 |
w,
|
|
|
|
| 5 |
// Extracted from ddgame.rs: team/worm data structures, TeamArenaRef,
|
| 6 |
// and related helper structs used as DDGame fields.
|
| 7 |
|
| 8 |
+
use core::ffi::CStr;
|
| 9 |
+
|
| 10 |
use super::ddgame::offsets;
|
| 11 |
|
| 12 |
/// Coordinate entry used in DDGame screen coordinate tables (stride 0x10).
|
|
|
|
| 543 |
) -> core::fmt::Result {
|
| 544 |
use crate::snapshot::write_indent;
|
| 545 |
let i = indent;
|
| 546 |
+
let name = CStr::from_ptr(self.name.as_ptr() as *const core::ffi::c_char).to_string_lossy();
|
|
|
|
| 547 |
write_indent(w, i)?;
|
| 548 |
writeln!(
|
| 549 |
w,
|
crates/openwa-core/src/task/fire.rs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
use super::base::CTask;
|
| 2 |
-
use crate::FieldRegistry;
|
| 3 |
|
| 4 |
crate::define_addresses! {
|
| 5 |
class "CTaskFire" {
|
|
@@ -51,9 +51,9 @@ pub struct CTaskFire {
|
|
| 51 |
pub burn_rate: u32,
|
| 52 |
pub _unknown_40: u32,
|
| 53 |
/// 0x44: spawn X position (Fixed 16.16)
|
| 54 |
-
pub spawn_x:
|
| 55 |
/// 0x48: spawn Y position (Fixed 16.16)
|
| 56 |
-
pub spawn_y:
|
| 57 |
pub _unknown_4c: [u8; 0x24],
|
| 58 |
/// 0x70: absolute tick (frame counter) when this flame was spawned
|
| 59 |
pub spawn_time: u32,
|
|
|
|
| 1 |
use super::base::CTask;
|
| 2 |
+
use crate::{fixed::Fixed, FieldRegistry};
|
| 3 |
|
| 4 |
crate::define_addresses! {
|
| 5 |
class "CTaskFire" {
|
|
|
|
| 51 |
pub burn_rate: u32,
|
| 52 |
pub _unknown_40: u32,
|
| 53 |
/// 0x44: spawn X position (Fixed 16.16)
|
| 54 |
+
pub spawn_x: Fixed,
|
| 55 |
/// 0x48: spawn Y position (Fixed 16.16)
|
| 56 |
+
pub spawn_y: Fixed,
|
| 57 |
pub _unknown_4c: [u8; 0x24],
|
| 58 |
/// 0x70: absolute tick (frame counter) when this flame was spawned
|
| 59 |
pub spawn_time: u32,
|
crates/openwa-dll/src/replacements/display.rs
CHANGED
|
@@ -5,10 +5,14 @@
|
|
| 5 |
//! - Headless vtable (0x66A0F8): replaces destructor with Rust version that
|
| 6 |
//! correctly frees our Rust-allocated sprite cache sub-objects
|
| 7 |
|
|
|
|
|
|
|
| 8 |
use crate::log_line;
|
| 9 |
use openwa_core::address::va;
|
| 10 |
-
use openwa_core::
|
|
|
|
| 11 |
use openwa_core::display::{DisplayBase, SpriteBufferCtrl, SpriteCacheWrapper};
|
|
|
|
| 12 |
use openwa_core::rebase::rb;
|
| 13 |
use openwa_core::vtable::patch_vtable;
|
| 14 |
use openwa_core::vtable_replace;
|
|
@@ -75,9 +79,9 @@ mod originals {
|
|
| 75 |
/// bit 27 (0x8000000): stippled mode 0
|
| 76 |
/// bit 28 (0x10000000): stippled mode 1
|
| 77 |
unsafe extern "thiscall" fn blit_sprite(
|
| 78 |
-
this: *mut
|
| 79 |
-
x:
|
| 80 |
-
y:
|
| 81 |
sprite_flags: u32,
|
| 82 |
palette: u32,
|
| 83 |
) {
|
|
@@ -179,7 +183,7 @@ unsafe extern "thiscall" fn blit_sprite(
|
|
| 179 |
let mut out_unknown: u32 = 0;
|
| 180 |
|
| 181 |
let fn33: unsafe extern "thiscall" fn(
|
| 182 |
-
*mut
|
| 183 |
u32,
|
| 184 |
u32,
|
| 185 |
*mut i32,
|
|
@@ -249,7 +253,7 @@ unsafe extern "thiscall" fn blit_sprite(
|
|
| 249 |
|
| 250 |
// Call BitGrid__ClearColumn_Maybe (0x4F6590) — clears shadow channel
|
| 251 |
let clear_fn: unsafe extern "cdecl" fn(*mut u8) =
|
| 252 |
-
core::mem::transmute(
|
| 253 |
clear_fn(table_byte as *mut u8);
|
| 254 |
|
| 255 |
*table_byte = saved;
|
|
@@ -388,21 +392,16 @@ unsafe extern "thiscall" fn blit_sprite(
|
|
| 388 |
|
| 389 |
/// Call the original DDDisplay::BlitSprite via saved vtable pointer.
|
| 390 |
unsafe fn call_original_blit_sprite(
|
| 391 |
-
this: *mut
|
| 392 |
-
x:
|
| 393 |
-
y:
|
| 394 |
sprite_flags: u32,
|
| 395 |
palette: u32,
|
| 396 |
) {
|
| 397 |
-
let orig = originals::BLIT_SPRITE.load(
|
| 398 |
if orig != 0 {
|
| 399 |
-
let f: unsafe extern "thiscall" fn(
|
| 400 |
-
|
| 401 |
-
openwa_core::fixed::Fixed,
|
| 402 |
-
openwa_core::fixed::Fixed,
|
| 403 |
-
u32,
|
| 404 |
-
u32,
|
| 405 |
-
) = core::mem::transmute(orig as usize);
|
| 406 |
f(this, x, y, sprite_flags, palette);
|
| 407 |
}
|
| 408 |
}
|
|
@@ -412,10 +411,10 @@ unsafe fn call_original_blit_sprite(
|
|
| 412 |
/// Computes coordinates in core, then dispatches the blit via blit_impl.
|
| 413 |
/// Falls through to the original WA function for unhandled modes (stippled).
|
| 414 |
unsafe extern "thiscall" fn draw_scaled_sprite(
|
| 415 |
-
this: *mut
|
| 416 |
-
x:
|
| 417 |
-
y:
|
| 418 |
-
sprite: *mut
|
| 419 |
src_x: i32,
|
| 420 |
src_y: i32,
|
| 421 |
src_w: i32,
|
|
@@ -453,13 +452,13 @@ unsafe extern "thiscall" fn draw_scaled_sprite(
|
|
| 453 |
DrawScaledSpriteResult::Handled => {}
|
| 454 |
DrawScaledSpriteResult::Unhandled => {
|
| 455 |
// Fall through to original WA function for stippled modes
|
| 456 |
-
let orig = originals::DRAW_SCALED_SPRITE.load(
|
| 457 |
if orig != 0 {
|
| 458 |
let f: unsafe extern "thiscall" fn(
|
| 459 |
-
*mut
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
*mut
|
| 463 |
i32,
|
| 464 |
i32,
|
| 465 |
i32,
|
|
|
|
| 5 |
//! - Headless vtable (0x66A0F8): replaces destructor with Rust version that
|
| 6 |
//! correctly frees our Rust-allocated sprite cache sub-objects
|
| 7 |
|
| 8 |
+
use core::sync::atomic::Ordering;
|
| 9 |
+
|
| 10 |
use crate::log_line;
|
| 11 |
use openwa_core::address::va;
|
| 12 |
+
use openwa_core::bitgrid::DisplayBitGrid;
|
| 13 |
+
use openwa_core::display::dd_display::{self, DDDisplay, DDDisplayVtable};
|
| 14 |
use openwa_core::display::{DisplayBase, SpriteBufferCtrl, SpriteCacheWrapper};
|
| 15 |
+
use openwa_core::fixed::Fixed;
|
| 16 |
use openwa_core::rebase::rb;
|
| 17 |
use openwa_core::vtable::patch_vtable;
|
| 18 |
use openwa_core::vtable_replace;
|
|
|
|
| 79 |
/// bit 27 (0x8000000): stippled mode 0
|
| 80 |
/// bit 28 (0x10000000): stippled mode 1
|
| 81 |
unsafe extern "thiscall" fn blit_sprite(
|
| 82 |
+
this: *mut DDDisplay,
|
| 83 |
+
x: Fixed,
|
| 84 |
+
y: Fixed,
|
| 85 |
sprite_flags: u32,
|
| 86 |
palette: u32,
|
| 87 |
) {
|
|
|
|
| 183 |
let mut out_unknown: u32 = 0;
|
| 184 |
|
| 185 |
let fn33: unsafe extern "thiscall" fn(
|
| 186 |
+
*mut DDDisplay,
|
| 187 |
u32,
|
| 188 |
u32,
|
| 189 |
*mut i32,
|
|
|
|
| 253 |
|
| 254 |
// Call BitGrid__ClearColumn_Maybe (0x4F6590) — clears shadow channel
|
| 255 |
let clear_fn: unsafe extern "cdecl" fn(*mut u8) =
|
| 256 |
+
core::mem::transmute(rb(0x004F6590) as usize);
|
| 257 |
clear_fn(table_byte as *mut u8);
|
| 258 |
|
| 259 |
*table_byte = saved;
|
|
|
|
| 392 |
|
| 393 |
/// Call the original DDDisplay::BlitSprite via saved vtable pointer.
|
| 394 |
unsafe fn call_original_blit_sprite(
|
| 395 |
+
this: *mut DDDisplay,
|
| 396 |
+
x: Fixed,
|
| 397 |
+
y: Fixed,
|
| 398 |
sprite_flags: u32,
|
| 399 |
palette: u32,
|
| 400 |
) {
|
| 401 |
+
let orig = originals::BLIT_SPRITE.load(Ordering::Relaxed);
|
| 402 |
if orig != 0 {
|
| 403 |
+
let f: unsafe extern "thiscall" fn(*mut DDDisplay, Fixed, Fixed, u32, u32) =
|
| 404 |
+
core::mem::transmute(orig as usize);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 405 |
f(this, x, y, sprite_flags, palette);
|
| 406 |
}
|
| 407 |
}
|
|
|
|
| 411 |
/// Computes coordinates in core, then dispatches the blit via blit_impl.
|
| 412 |
/// Falls through to the original WA function for unhandled modes (stippled).
|
| 413 |
unsafe extern "thiscall" fn draw_scaled_sprite(
|
| 414 |
+
this: *mut DDDisplay,
|
| 415 |
+
x: Fixed,
|
| 416 |
+
y: Fixed,
|
| 417 |
+
sprite: *mut DisplayBitGrid,
|
| 418 |
src_x: i32,
|
| 419 |
src_y: i32,
|
| 420 |
src_w: i32,
|
|
|
|
| 452 |
DrawScaledSpriteResult::Handled => {}
|
| 453 |
DrawScaledSpriteResult::Unhandled => {
|
| 454 |
// Fall through to original WA function for stippled modes
|
| 455 |
+
let orig = originals::DRAW_SCALED_SPRITE.load(Ordering::Relaxed);
|
| 456 |
if orig != 0 {
|
| 457 |
let f: unsafe extern "thiscall" fn(
|
| 458 |
+
*mut DDDisplay,
|
| 459 |
+
Fixed,
|
| 460 |
+
Fixed,
|
| 461 |
+
*mut DisplayBitGrid,
|
| 462 |
i32,
|
| 463 |
i32,
|
| 464 |
i32,
|