diff options
| -rw-r--r-- | src/main.rs | 1 | ||||
| -rw-r--r-- | src/room.rs | 4 | ||||
| -rw-r--r-- | src/world.rs | 4 |
3 files changed, 9 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 2e6ca10..6ee205f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,6 +109,7 @@ fn main() -> Result<()>{ if message.is_empty(){ continue; } + //println!("c {}", message.to_json()); let _ = gameserver.send(&player, message.to_json()); } diff --git a/src/room.rs b/src/room.rs index 3856cbd..9b0f33a 100644 --- a/src/room.rs +++ b/src/room.rs @@ -236,6 +236,10 @@ impl <'a, 'b>Room<'a, 'b> { self.world.insert(Emigration::default()); emigrants } + + pub fn get_time(&self) -> i64 { + self.world.fetch::<TimeStamp>().time + } } diff --git a/src/world.rs b/src/world.rs index 9f86cb8..40d600a 100644 --- a/src/world.rs +++ b/src/world.rs @@ -47,6 +47,10 @@ impl <'a, 'b>World<'a, 'b> { if let Ok(state) = self.persistence.load_room(id.clone()){ room.load_saved(&state); } + let last_time = self.timestamp - 1; + if room.get_time() < last_time { + room.update(last_time); + } self.rooms.insert(id.clone(), room); } self.rooms.get_mut(id).ok_or(aerr!("can't get room after loading it")) |
