record-daemon: refactor/remove pregame metadata in daemon
record-daemon / Build, check and test (push) Successful in 2m0s

This commit is contained in:
2026-03-27 16:09:04 +01:00
parent 52f8be7caa
commit 785e5073ec
4 changed files with 5 additions and 405 deletions
+1 -66
View File
@@ -56,8 +56,6 @@ struct Daemon {
event_mapper: Arc<RwLock<EventMapper>>,
/// Current recording ID (if recording).
current_recording_id: Arc<RwLock<Option<uuid::Uuid>>>,
/// Pre-game data (collected before game starts).
pregame_data: Arc<RwLock<Option<record_daemon::lqp::PreGameData>>>,
/// IPC server.
ipc_server: Option<IpcServer>,
/// Shutdown signal.
@@ -77,7 +75,6 @@ impl Daemon {
timeline_store: Arc::new(RwLock::new(TimelineStore::new())),
event_mapper: Arc::new(RwLock::new(EventMapper::new())),
current_recording_id: Arc::new(RwLock::new(None)),
pregame_data: Arc::new(RwLock::new(None)),
ipc_server: None,
shutdown_tx,
}
@@ -232,78 +229,19 @@ impl Daemon {
// Handle pre-game data collection
match &event {
GameEvent::PhaseChange(info) if info.phase == "ChampSelect" => {
info!("[EVENT_HANDLER] Champion select started, fetching pre-game data");
match self.lqp_client.fetch_pregame_data().await {
Ok(data) => {
info!("[EVENT_HANDLER] Pre-game data fetched: {:?}", data);
*self.pregame_data.write() = Some(data);
}
Err(e) => {
warn!("[EVENT_HANDLER] Failed to fetch pre-game data: {}", e);
}
}
info!("[EVENT_HANDLER] Champion select started");
}
GameEvent::ChampionPick(pick) if pick.is_local_player => {
info!(
"[EVENT_HANDLER] Local player picked champion: {}",
pick.champion_name
);
// Champion pick info is now stored in champion_select response
// No need to manually update - refetch if needed
}
GameEvent::GameStart(info) => {
info!(
"[EVENT_HANDLER] Game started with metadata: queue={:?}, mode={:?}, map={:?}",
info.queue_type, info.game_mode, info.map_name
);
// Update pre-game data with game start info if needed
let mut pregame = self.pregame_data.write();
// Extract player-specific data from session using puuid
let (_champion_id, _team, summoner_name) = if let Some(ref session) = info.session {
// Get puuid from pregame data (fetched earlier)
let puuid = pregame.as_ref().and_then(|d| d.puuid());
if let Some(puuid) = puuid {
// Use the puuid to find the correct player's data
let champ_id = session.get_champion_id(puuid);
let team_id = session.get_team(puuid);
let summoner = session.get_summoner_name(puuid).map(|s| s.to_string());
info!("[EVENT_HANDLER] Found player data via puuid: champion_id={:?}, team={:?}, summoner={:?}",
champ_id, team_id, summoner);
(champ_id, team_id, summoner)
} else {
// No puuid available, can't determine player
warn!("[EVENT_HANDLER] No puuid available, cannot determine player-specific data");
(None, None, None)
}
} else {
(None, None, None)
};
// If we don't have pre-game data, create minimal from game start info
if pregame.is_none() {
use record_daemon::lqp::{GameflowSessionResponse, PreGameData};
*pregame = Some(PreGameData {
session: Some(GameflowSessionResponse {
map: info.map_name.clone(),
game_mode: info.game_mode.clone(),
queue_id: info.queue_id.map(|id| id as u64),
..Default::default()
}),
summoner: summoner_name.map(|name| {
use record_daemon::lqp::SummonerResponse;
SummonerResponse {
display_name: Some(name),
..Default::default()
}
}),
..Default::default()
});
}
}
_ => {}
}
@@ -434,9 +372,6 @@ impl Daemon {
// Don't propagate error - keep daemon running
}
// Clear pre-game data
*self.pregame_data.write() = None;
}
_ => {}
}