//! (HP, Size_X, Size_Y, Size_Z) for every craft unit and vessel on the disc.
//!
//! A live definition object in guest RAM carries HP at `+0x54` and the sizes at
//! `+0x30/34/38` but no name in its first words, so identity has to come from the
//! values themselves: this is the lookup table for that match.
//! Run: unit_signatures <disc-root>
use sylpheed_formats::game_data::{load_units, load_vessels};
use sylpheed_formats::PakArchive;
fn main() {
    let disc = std::env::args().nth(1).expect("disc root");
    let pak = PakArchive::open(format!("{disc}/dat/GP_MAIN_GAME_E.pak")).expect("pak");
    println!("{:<34} {:>9} {:>8} {:>8} {:>8}  kind", "id", "hp", "size_x", "size_y", "size_z");
    for u in load_units(&pak) {
        println!(
            "{:<34} {:>9} {:>8} {:>8} {:>8}  unit",
            u.id.unwrap_or_default(),
            u.hp.map(|v| v.to_string()).unwrap_or("—".into()),
            u.size_x.map(|v| v.to_string()).unwrap_or("—".into()),
            u.size_y.map(|v| v.to_string()).unwrap_or("—".into()),
            u.size_z.map(|v| v.to_string()).unwrap_or("—".into()),
        );
    }
    for v in load_vessels(&pak) {
        println!(
            "{:<34} {:>9} {:>8} {:>8} {:>8}  vessel",
            v.id.unwrap_or_default(),
            v.hp.map(|x| x.to_string()).unwrap_or("—".into()),
            v.size_x.map(|x| x.to_string()).unwrap_or("—".into()),
            v.size_y.map(|x| x.to_string()).unwrap_or("—".into()),
            v.size_z.map(|x| x.to_string()).unwrap_or("—".into()),
        );
    }
}
