summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-02-24 12:58:43 +0100
committertroido <troido@protonmail.com>2020-02-24 12:58:43 +0100
commitf6a037faa2b675cd7318d6dd8ccee5133c89845d (patch)
tree6d94c7e84f100d0343ba8e87c03f67082405328b /src
parent715c9106dbff4524f3fdf5d23f762e5e6518e0cb (diff)
run an update before loading an outdated room
Diffstat (limited to 'src')
-rw-r--r--src/main.rs1
-rw-r--r--src/room.rs4
-rw-r--r--src/world.rs4
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"))