feat(m3a): playable flame client with camera, hud and device perf gate

This commit is contained in:
2026-10-24 22:54:29 +02:00
parent e77595eaf0
commit a30784479b
15 changed files with 1238 additions and 144 deletions
+26 -8
View File
@@ -1,7 +1,12 @@
//! Flutter <-> Rust bridge.
//!
//! Until the flutter_rust_bridge integration (M3) this crate exposes plain
//! C ABI functions so the Android pipeline can be verified end to end.
//! Two layers live here:
//! - stateless probe functions (ABI marker, self test) used to verify the
//! build pipeline and cross-target determinism,
//! - [`match_api`], the stateful API the Flame client drives.
#![allow(clippy::not_unsafe_ptr_arg_deref)]
pub mod match_api;
/// Magic marker to verify that the CDylib was loaded and symbols resolve.
pub const ABI_MARKER: u32 = 0x1A2B_3C4D;
@@ -13,9 +18,6 @@ pub extern "C" fn iron_arc_abi_marker() -> u32 {
}
/// Runs a fixed scripted match and returns its state hash.
///
/// The same seed must produce the same hash on every target (android arm64,
/// x86_64, wasm). This is the cross-target determinism probe from ADR 0002.
#[no_mangle]
pub extern "C" fn iron_arc_selftest(seed: u64) -> u64 {
let mut sim = sim::state::Sim::default_match(seed);
@@ -33,9 +35,7 @@ pub extern "C" fn iron_arc_selftest(seed: u64) -> u64 {
/// Returns the simulation version as a packed `major*10000 + minor*100 + patch`.
#[no_mangle]
pub extern "C" fn iron_arc_sim_version_code() -> u32 {
let mut parts = sim::SIM_VERSION
.split('.')
.filter_map(|p| p.parse::<u32>().ok());
let mut parts = sim::SIM_VERSION.split('.').filter_map(|p| p.parse::<u32>().ok());
let major = parts.next().unwrap_or(0);
let minor = parts.next().unwrap_or(0);
let patch = parts.next().unwrap_or(0);
@@ -61,4 +61,22 @@ mod tests {
fn version_code_is_packed() {
assert_eq!(iron_arc_sim_version_code(), 100);
}
#[test]
fn match_handle_roundtrip() {
unsafe {
let handle = match_api::iron_arc_new_match(7);
assert!(!handle.is_null());
assert_eq!(match_api::iron_arc_phase(handle), 0);
assert_eq!(match_api::iron_arc_current(handle), 0);
assert_eq!(match_api::iron_arc_fire(handle, 45_000, 65_536, 1), 0);
assert_eq!(match_api::iron_arc_phase(handle), 1);
let mut xy = [0i32; 2];
assert_eq!(match_api::iron_arc_projectile(handle, xy.as_mut_ptr()), 1);
let impacts = match_api::iron_arc_tick(handle, 400);
assert!(impacts >= 1, "expected an impact, got {impacts}");
assert!(match_api::iron_arc_terrain_ptr(handle).is_null() == false);
match_api::iron_arc_free_match(handle);
}
}
}