mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Fix game event not getting saved to DB until first game switc #36h
This commit is contained in:
@@ -302,6 +302,7 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
|||||||
}).collect(),
|
}).collect(),
|
||||||
index: first,
|
index: first,
|
||||||
started: chrono::Utc::now().timestamp(),
|
started: chrono::Utc::now().timestamp(),
|
||||||
|
needs_to_be_saved: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,17 +160,22 @@ pub struct GameEventSequence {
|
|||||||
pub modes: Vec<GameEvents>,
|
pub modes: Vec<GameEvents>,
|
||||||
pub index: usize,
|
pub index: usize,
|
||||||
pub started: i64,
|
pub started: i64,
|
||||||
|
pub(crate) needs_to_be_saved: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GameEventSequence {
|
impl GameEventSequence {
|
||||||
pub fn now(&mut self, updater: Box<dyn crate::persist::user::GameEventSetter>) -> GameEventTransmissible {
|
pub fn now(&mut self, updater: Box<dyn crate::persist::user::GameEventSetter>) -> GameEventTransmissible {
|
||||||
let time_now = chrono::Utc::now().timestamp();
|
let time_now = chrono::Utc::now().timestamp();
|
||||||
let mut item_now = &self.modes[self.index];
|
let mut item_now = &self.modes[self.index];
|
||||||
if time_now >= (item_now.duration.as_secs() as i64) + self.started {
|
let needs_refresh = time_now >= (item_now.duration.as_secs() as i64) + self.started;
|
||||||
// needs refresh
|
if self.needs_to_be_saved || needs_refresh {
|
||||||
self.index = self.strategy.next(self.index, self.modes.len());
|
if needs_refresh {
|
||||||
|
self.index = self.strategy.next(self.index, self.modes.len());
|
||||||
|
self.started = time_now;
|
||||||
|
} else {
|
||||||
|
self.needs_to_be_saved = false;
|
||||||
|
}
|
||||||
item_now = &self.modes[self.index];
|
item_now = &self.modes[self.index];
|
||||||
self.started = time_now;
|
|
||||||
let mp = crate::persist::user::CurrentGameEvent {
|
let mp = crate::persist::user::CurrentGameEvent {
|
||||||
map: crate::data::game_mode::GameMap::from_persist(item_now.multiplayer.map).as_str().to_owned(),
|
map: crate::data::game_mode::GameMap::from_persist(item_now.multiplayer.map).as_str().to_owned(),
|
||||||
visibility: crate::data::game_mode::MapVisibility::from_persist(item_now.multiplayer.visibility),
|
visibility: crate::data::game_mode::MapVisibility::from_persist(item_now.multiplayer.visibility),
|
||||||
|
|||||||
Reference in New Issue
Block a user