feat: map Dota 2 GSI game-state transitions to match events

This commit is contained in:
Alvin-Zilverstand committed 2026-09-14 12:53:29 +02:00
1 parent 78fc2951a8
commit 6839fdbf47
2 files changed
+126 -3

No files matched your search

+3 -3
View File
@@ -45,7 +45,7 @@
- Per-game capture quality overrides can be set from the Recording screen per detected game title, saved in settings, and applied automatically by the recorder when that game is active.
- The configured storage cap is enforced by a backend worker that prunes the oldest rolling buffer segments once the buffer exceeds `storage_limit_gb`.
- SQLite schema uses versioned migrations tracked via `PRAGMA user_version`; legacy databases (missing tables or the `title` column) are repaired and upgraded in place, with migration tests.
- Valve GSI event mapping enriches CS2 round, bomb, and match-start events with round number, map scores, and plant-region metadata; these events are unit tested against realistic JSON payloads.
- Valve GSI event mapping enriches CS2 round, bomb, and match-start events with round number, map scores, and plant-region metadata; Dota 2 game-state transitions map to match-start bookmarks and match-end events carrying final radiant/dire scores. These events are unit tested against realistic JSON payloads.
- A GitHub Actions release workflow (`.github/workflows/release.yml`) builds MSI and NSIS installers on tag push or manual dispatch and publishes them to a GitHub Release, ready for the auto-updater to pick up.
- Auto-update checks the GitHub repo releases (`Alvin-Zilverstand/clipforge-game-clipper`) for the latest MSI/NSIS installer, compares it against the running version, downloads it to temp, launches the installer, and exits the app to finish; version comparison, asset selection, and parsing are unit tested plus one ignored live test against the GitHub API.
- A GitHub Actions release workflow publishes MSI/NSIS assets on tag push; auto-update will pick up newer releases automatically once the repo ships a tag newer than the running app version.
@@ -58,7 +58,7 @@
- Native Windows Graphics Capture and FFmpeg capture finalization have not yet been manually QA-tested on real NVIDIA/AMD/Intel gaming systems.
- Native WASAPI audio is mixed into a single AAC track for MVP clips; separate audio tracks are now honored by the FFmpeg recording backend (routing around the single-track native WGC encoder), while per-process audio capture remains future work.
- Valve GSI receiver is a lightweight MVP receiver; config templates can be generated from the Auto Clip screen. CS2 event mapping is now enriched with round, bomb, and match-start metadata, but full per-game mapping for Dota 2 and other Source titles is still needed.
- Valve GSI receiver is a lightweight MVP receiver; config templates can be generated from the Auto Clip screen. CS2 round/bomb/match-start and Dota 2 match-start/match-end transitions are mapped, but per-player kill/death/objective event detection for Dota 2 and other Source titles is still needed.
- Auto start/stop is conservative but live: when auto-record is enabled, supported detected games can start recording and stop when the game disappears.
- Recorder service still runs inside the Tauri process instead of a separate background service process.
- Installer onboarding is still not implemented.
@@ -67,7 +67,7 @@
## Next Engineering Steps
1. Add per-process loopback capture so individual application audio can be captured independently of the system mix.
2. Add full per-game Valve GSI event mapping for Dota 2 and other Source titles beyond the current CS2 enrichment.
2. Add per-player kill/death/objective event detection for Dota 2 and other Source titles beyond the current match-level transitions.
3. Add installer/onboarding screens for privacy, capture source, storage, and hotkeys.
4. Exercise the GitHub Actions release workflow with a real tag push and verify the published assets appear in a GitHub Release.
5. Run manual QA on Windows gaming hardware and tune CPU/GPU overhead.
+123
View File
@@ -170,6 +170,8 @@ impl GameIntegration for ValveGsiIntegration {
GameEventType::RoundWin
} else if lower.contains("match_end") {
GameEventType::MatchWin
} else if lower.contains("match_start") {
GameEventType::Bookmark
} else if lower.contains("bomb") {
GameEventType::Objective
} else if lower.contains("mvp") {
@@ -391,6 +393,54 @@ pub fn valve_gsi_raw_events(
}
}
// Dota 2 game-state transitions (GSI posts a periodic snapshot; the auto-clip merge
// window collapses repeated posts into a single event)
if let Some(game_state) = value.pointer("/map/game_state").and_then(Value::as_str) {
let game_time = value
.pointer("/map/game_time")
.and_then(Value::as_u64)
.unwrap_or_default();
match game_state {
"DOTA_GAMERULES_STATE_GAME_IN_PROGRESS" if game_time < 10 => {
events.push(RawGameEvent {
event_id: format!("dota_match_start:{}", millis(now)),
name: "match_start".to_string(),
timestamp: now,
player: None,
metadata: [
("map".to_string(), map_stat_string(&value, "/map/name")),
("game_time".to_string(), game_time.to_string()),
]
.into(),
});
}
"DOTA_GAMERULES_STATE_POST_GAME" => {
events.push(RawGameEvent {
event_id: format!("dota_match_end:{}", millis(now)),
name: "match_end".to_string(),
timestamp: now,
player: None,
metadata: [
(
"radiant_score".to_string(),
map_stat_string(&value, "/map/radiant_score"),
),
(
"dire_score".to_string(),
map_stat_string(&value, "/map/dire_score"),
),
(
"win_team".to_string(),
map_stat_string(&value, "/map/win_team"),
),
]
.into(),
});
}
_ => {}
}
}
// Match end events
if let Some(phase) = value.pointer("/map/phase").and_then(Value::as_str) {
if phase == "gameover" {
@@ -625,4 +675,77 @@ mod tests {
);
assert_eq!(bomb.metadata.get("round").map(String::as_str), Some("2"));
}
#[test]
fn parses_dota2_match_end_with_score_metadata() {
let body = r#"{
"map": {
"game_state": "DOTA_GAMERULES_STATE_POST_GAME",
"game_time": 2543,
"name": "dota",
"radiant_score": 28,
"dire_score": 14,
"win_team": "radiant"
}
}"#;
let events = valve_gsi_raw_events(body, SystemTime::UNIX_EPOCH).expect("events");
let match_end = events
.iter()
.find(|event| event.name == "match_end")
.expect("match_end event");
assert_eq!(
match_end.metadata.get("radiant_score").map(String::as_str),
Some("28")
);
assert_eq!(
match_end.metadata.get("dire_score").map(String::as_str),
Some("14")
);
assert_eq!(
match_end.metadata.get("win_team").map(String::as_str),
Some("radiant")
);
}
#[test]
fn parses_dota2_match_start_on_game_in_progress() {
let body = r#"{
"map": {
"game_state": "DOTA_GAMERULES_STATE_GAME_IN_PROGRESS",
"game_time": 4,
"name": "dota"
}
}"#;
let events = valve_gsi_raw_events(body, SystemTime::UNIX_EPOCH).expect("events");
let start = events
.iter()
.find(|event| event.name == "match_start")
.expect("match_start event");
assert_eq!(
start.metadata.get("map").map(String::as_str),
Some("dota")
);
assert_eq!(
start.metadata.get("game_time").map(String::as_str),
Some("4")
);
}
#[test]
fn dota2_ignores_match_start_after_initial_snapshot() {
let body = r#"{
"map": {
"game_state": "DOTA_GAMERULES_STATE_GAME_IN_PROGRESS",
"game_time": 30
}
}"#;
let events = valve_gsi_raw_events(body, SystemTime::UNIX_EPOCH).expect("events");
assert!(!events.iter().any(|event| event.name == "match_start"));
}
}