Compare commits
3 Commits
5b1f840e40
...
06ca80a529
| Author | SHA1 | Date | |
|---|---|---|---|
| 06ca80a529 | |||
| 212a10e16c | |||
| 9747681d75 |
@ -248,6 +248,7 @@ pub struct Game {
|
|||||||
|
|
||||||
pub replay_recorder: Option<Gd<ReplayRecorder>>,
|
pub replay_recorder: Option<Gd<ReplayRecorder>>,
|
||||||
pub current_replay_playback: Option<Gd<ReplayPlayback>>,
|
pub current_replay_playback: Option<Gd<ReplayPlayback>>,
|
||||||
|
pub last_replay_clone: f64,
|
||||||
|
|
||||||
base: Base<Node>,
|
base: Base<Node>,
|
||||||
}
|
}
|
||||||
@ -336,7 +337,11 @@ impl INode for Game {
|
|||||||
if let Some(playback) = &mut self.current_replay_playback
|
if let Some(playback) = &mut self.current_replay_playback
|
||||||
&& let Some(recorder) = &self.replay_recorder
|
&& let Some(recorder) = &self.replay_recorder
|
||||||
{
|
{
|
||||||
playback.bind_mut().replay = recorder.bind().replay.clone();
|
self.last_replay_clone += delta;
|
||||||
|
if self.last_replay_clone >= 1. {
|
||||||
|
playback.bind_mut().replay = recorder.bind().replay.clone();
|
||||||
|
self.last_replay_clone = 0.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,7 @@ impl StandaloneReplayManager {
|
|||||||
if let Some(mut file) = FileAccess::open(path, ModeFlags::READ) {
|
if let Some(mut file) = FileAccess::open(path, ModeFlags::READ) {
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
while !file.eof_reached() {
|
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);
|
let bytes = Cursor::new(&mut bytes);
|
||||||
@ -351,9 +351,7 @@ impl ReplayRecorder {
|
|||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
let cursor = Cursor::new(&mut buf);
|
let cursor = Cursor::new(&mut buf);
|
||||||
ciborium::into_writer(&self.replay, cursor).ok();
|
ciborium::into_writer(&self.replay, cursor).ok();
|
||||||
for byte in buf {
|
file.store_buffer(&PackedArray::from_iter(buf));
|
||||||
file.store_8(byte);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user