fix(app): the game placement reads the card again and stage retries start over with each new wish
- the game stage reads the card again: other programs as at the last normal placement made with no game running, and a reserve of at least what grew since (the game and programs opened after that reading); with a game already running at the start (game detection now looks once before the LLM starts) it counts what the card holds now and leaves only the room for other programs, so it no longer pauses for counting the game twice - the retry count starts over whenever another stage is wanted, also when the game ends with the normal stage already running, so the next game tries again - the wait before the next try counts from when the failed switch and its way back are over - the worker client keeps, sends and readies a connection under one lock (llm, then state), so an LLM state set while a worker connects is not lost - a game watch dropped by a start that fails part way stops its thread Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -205,8 +205,14 @@ pub struct GameWatch {
|
||||
}
|
||||
|
||||
impl GameWatch {
|
||||
/// Start watching; the first look happens before this returns, so a game already running is
|
||||
/// known at once (`on`).
|
||||
pub fn start(settings: GameSettings) -> Self {
|
||||
let (state, stop) = (Arc::new(Mutex::new(GameState::default())), Arc::new(AtomicBool::new(false)));
|
||||
if cfg!(windows) && settings.detect {
|
||||
let snap = probe::Probe::new().snapshot();
|
||||
state.lock().unwrap().update(&snap, &settings, probe::alive);
|
||||
}
|
||||
let thread = (cfg!(windows) && settings.detect).then(|| {
|
||||
let (state, stop) = (state.clone(), stop.clone());
|
||||
std::thread::spawn(move || {
|
||||
@@ -254,6 +260,13 @@ impl GameWatch {
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GameWatch {
|
||||
/// A start that fails part way drops the watch: its thread ends too.
|
||||
fn drop(&mut self) {
|
||||
self.stop();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
mod probe {
|
||||
use super::Snapshot;
|
||||
|
||||
Reference in New Issue
Block a user