game_data: Squadron loader — mission flight groups
Decode the per-stage Enumerate_Squadrons tables (UnitGroup_S<NN>.tbl) into flight groups: formation shape, AI behaviour, side, and the member craft. Definitions are delimited by the FormationID key; members are the first `count` UN_ craft after the header (anything past them belongs to the next squadron or the stage roster — the naive "all UN_ in span" over-collected). e.g. the player's Rhino flight = a 2-craft TCAF squadron of Delta Sabers flying Formation_2_Rhino. Schema hash varies per stage so we match on the table name. Squadron id is positional and left None when the id list and definitions don't line up (honest, not guessed). +1 test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
11
crates/sylpheed-formats/examples/squadrons.rs
Normal file
11
crates/sylpheed-formats/examples/squadrons.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use sylpheed_formats::{game_data, PakArchive};
|
||||
fn main(){
|
||||
let disc=std::env::var("SYLPHEED_DISC").unwrap();
|
||||
let pak=PakArchive::open(format!("{disc}/dat/GP_MAIN_GAME_E.pak")).unwrap();
|
||||
let sq=game_data::load_squadrons(&pak);
|
||||
println!("{} squadron definitions", sq.len());
|
||||
for s in sq.iter().filter(|s|s.side.as_deref()==Some("TCAF")).take(6){
|
||||
let mem:Vec<String>=s.members.iter().map(|m|m.trim_start_matches("UN_").chars().take(18).collect()).collect();
|
||||
println!(" {:8} {:22} {:24} x{} {:?}", s.id.clone().unwrap_or("?".into()), s.formation_id.clone().unwrap_or_default(), s.ai_id.clone().unwrap_or_default(), s.count.unwrap_or(0), mem);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user