paavohtl Claude Opus 4.6 commited on
Commit
5f922ec
·
1 Parent(s): 6d9733e

feat: add auto-capture mode to validator DLL via OPENWA_REPLAY_TEST env var

Browse files
crates/openwa-validator/Cargo.toml CHANGED
@@ -15,5 +15,6 @@ minhook = "0.9"
15
  windows-sys = { version = "0.59", features = [
16
  "Win32_System_Memory",
17
  "Win32_System_LibraryLoader",
 
18
  "Win32_UI_Input_KeyboardAndMouse",
19
  ] }
 
15
  windows-sys = { version = "0.59", features = [
16
  "Win32_System_Memory",
17
  "Win32_System_LibraryLoader",
18
+ "Win32_System_Threading",
19
  "Win32_UI_Input_KeyboardAndMouse",
20
  ] }
crates/openwa-validator/src/lib.rs CHANGED
@@ -813,47 +813,71 @@ fn run_validation() -> Result<(), Box<dyn std::error::Error>> {
813
  Err(e) => { let _ = log_line(&format!("[ERROR] Hook installation failed: {}", e)); }
814
  }
815
 
816
- // 7. Deferred validation via polling (for DDGameWrapper — hooks don't cover this yet)
817
- let _ = log_line("");
818
- let _ = log_line("--- Deferred Validation (polling) ---");
819
- std::thread::spawn(move || {
820
- // Wait for game to finish init
821
- std::thread::sleep(std::time::Duration::from_secs(10));
822
- deferred_global_validation();
823
- });
824
- let _ = log_line(" Polling thread started (10s delay).");
825
-
826
- // 8. Team block dump — wait 30s for user to start a game
827
- std::thread::spawn(move || {
828
- std::thread::sleep(std::time::Duration::from_secs(30));
829
- dump_team_blocks();
830
- });
831
- let _ = log_line(" Team block dump thread started (30s delay).");
832
-
833
- // 8b. Landscape dump — wait 15s (landscape exists at menu too)
834
- std::thread::spawn(move || {
835
- std::thread::sleep(std::time::Duration::from_secs(15));
836
- dump_landscape();
837
- });
838
- let _ = log_line(" Landscape dump thread started (15s delay).");
839
-
840
- // 9. Hotkey listener — F9 = team blocks, F10 = landscape
841
- std::thread::spawn(|| {
842
- const VK_F9: i32 = 0x78;
843
- const VK_F10: i32 = 0x79;
844
- let _ = log_line(" Hotkey listener started (F9=team blocks, F10=landscape).");
845
- loop {
846
- std::thread::sleep(std::time::Duration::from_millis(100));
847
  unsafe {
848
- if GetAsyncKeyState(VK_F9) & 1 != 0 {
849
- dump_team_blocks();
850
- }
851
- if GetAsyncKeyState(VK_F10) & 1 != 0 {
852
- dump_landscape();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
853
  }
854
  }
855
- }
856
- });
857
 
858
  Ok(())
859
  }
 
813
  Err(e) => { let _ = log_line(&format!("[ERROR] Hook installation failed: {}", e)); }
814
  }
815
 
816
+ // 7. Mode-dependent: auto-capture vs interactive
817
+ let auto_mode = std::env::var("OPENWA_REPLAY_TEST").is_ok();
818
+
819
+ if auto_mode {
820
+ let _ = log_line("");
821
+ let _ = log_line("--- Auto-Capture Mode (OPENWA_REPLAY_TEST) ---");
822
+ std::thread::spawn(move || {
823
+ let _ = log_line(" Waiting 30s for replay to reach gameplay...");
824
+ std::thread::sleep(std::time::Duration::from_secs(30));
825
+
826
+ let _ = log_line(" Running deferred global validation...");
827
+ deferred_global_validation();
828
+
829
+ let _ = log_line(" Running team block dump...");
830
+ dump_team_blocks();
831
+
832
+ let _ = log_line(" Running landscape dump...");
833
+ dump_landscape();
834
+
835
+ let _ = log_line("");
836
+ let _ = log_line("--- Auto-capture complete, exiting ---");
837
+
 
 
 
 
 
 
 
 
 
838
  unsafe {
839
+ windows_sys::Win32::System::Threading::ExitProcess(0);
840
+ }
841
+ });
842
+ } else {
843
+ // Existing interactive mode: deferred timers + hotkey listener
844
+ let _ = log_line("");
845
+ let _ = log_line("--- Interactive Mode (deferred polling + hotkeys) ---");
846
+ std::thread::spawn(move || {
847
+ std::thread::sleep(std::time::Duration::from_secs(10));
848
+ deferred_global_validation();
849
+ });
850
+ let _ = log_line(" Polling thread started (10s delay).");
851
+
852
+ std::thread::spawn(move || {
853
+ std::thread::sleep(std::time::Duration::from_secs(30));
854
+ dump_team_blocks();
855
+ });
856
+ let _ = log_line(" Team block dump thread started (30s delay).");
857
+
858
+ std::thread::spawn(move || {
859
+ std::thread::sleep(std::time::Duration::from_secs(15));
860
+ dump_landscape();
861
+ });
862
+ let _ = log_line(" Landscape dump thread started (15s delay).");
863
+
864
+ std::thread::spawn(|| {
865
+ const VK_F9: i32 = 0x78;
866
+ const VK_F10: i32 = 0x79;
867
+ let _ = log_line(" Hotkey listener started (F9=team blocks, F10=landscape).");
868
+ loop {
869
+ std::thread::sleep(std::time::Duration::from_millis(100));
870
+ unsafe {
871
+ if GetAsyncKeyState(VK_F9) & 1 != 0 {
872
+ dump_team_blocks();
873
+ }
874
+ if GetAsyncKeyState(VK_F10) & 1 != 0 {
875
+ dump_landscape();
876
+ }
877
  }
878
  }
879
+ });
880
+ }
881
 
882
  Ok(())
883
  }