Compare commits

...

3 Commits

Author SHA1 Message Date
06ca80a529 Read replay faster as well 2026-07-26 23:42:36 +03:00
212a10e16c Store replay whole buffer at a time 2026-07-26 23:40:20 +03:00
9747681d75 Only clone replay every second during gameplay 2026-07-26 23:34:28 +03:00
2 changed files with 8 additions and 5 deletions

View File

@ -248,6 +248,7 @@ pub struct Game {
pub replay_recorder: Option<Gd<ReplayRecorder>>,
pub current_replay_playback: Option<Gd<ReplayPlayback>>,
pub last_replay_clone: f64,
base: Base<Node>,
}
@ -336,7 +337,11 @@ impl INode for Game {
if let Some(playback) = &mut self.current_replay_playback
&& let Some(recorder) = &self.replay_recorder
{
self.last_replay_clone += delta;
if self.last_replay_clone >= 1. {
playback.bind_mut().replay = recorder.bind().replay.clone();
self.last_replay_clone = 0.
}
}
}
}

View File

@ -43,7 +43,7 @@ impl StandaloneReplayManager {
if let Some(mut file) = FileAccess::open(path, ModeFlags::READ) {
let mut bytes = Vec::new();
while !file.eof_reached() {
bytes.push(file.get_8());
bytes.extend(file.get_buffer(1_000_000).to_vec());
}
let bytes = Cursor::new(&mut bytes);
@ -351,9 +351,7 @@ impl ReplayRecorder {
let mut buf = Vec::new();
let cursor = Cursor::new(&mut buf);
ciborium::into_writer(&self.replay, cursor).ok();
for byte in buf {
file.store_8(byte);
}
file.store_buffer(&PackedArray::from_iter(buf));
}
}