aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/script_coverage.rs
blob: e54e1faae3472cc53fec470bd8270c1f44516738 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use fparkan_runtime::{
    loaded_mission_script_bundles, Engine, MissionScriptInitExecution, SimulationReport,
};

pub(super) fn log_script_init(engine: &Engine, mission: &str) {
    for bundle in loaded_mission_script_bundles(engine).unwrap_or_default() {
        let clan = bundle.clan_index;
        let script = &bundle.script_path;
        for &(instruction, handler) in &bundle.init_stubs {
            eprintln!("sim_coverage script_init_handler_stub=1 mission={mission} clan={clan} script={script} instruction={instruction} handler={handler}");
        }
        if let MissionScriptInitExecution::Unsupported {
            event_index,
            instruction_index,
            error,
        } = &bundle.init_execution
        {
            eprintln!("sim_coverage script_init_unsupported=1 mission={mission} clan={clan} script={script} event={event_index} instruction={instruction_index} reason={error}");
        }
    }
}

pub(super) fn log_clan_ai_stops(report: &SimulationReport) {
    for (&(clan, kind), count) in &report.clan_problem_dispatch_stubs {
        eprintln!("sim_coverage script_problem_dispatch_stubs={count} clan={clan} problem={kind}");
    }
    for &(clan, handler, count) in &report.clan_research_status_stubs {
        eprintln!(
            "sim_coverage script_research_status_stubs={count} clan={clan} handler={handler}"
        );
    }
    for (stop, count) in &report.clan_ai_event_stops {
        eprintln!(
            "sim_coverage script_clan_ai_stops={count} clan={} script={} event={} instruction={} reason={}",
            stop.clan_index, stop.script_path, stop.event_index, stop.instruction_index, stop.reason,
        );
    }
}