From 665e9b9378ba8d245fdd24b544316cefead2ccd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Fri, 24 Sep 2021 01:02:03 +0200 Subject: [PATCH] sync TIME ressource to client - we evaluated multiple ways to sync the time, either store a delta between localtime and ServerTime or just store the ServerTime --- client/src/lib.rs | 32 ++++++++----- common/net/src/msg/server.rs | 6 ++- common/src/comp/remote_controller.rs | 59 ++++++++++++++++++++---- common/src/resources.rs | 6 +++ common/state/src/state.rs | 5 +- common/systems/src/predict_controller.rs | 2 +- server/src/client.rs | 6 ++- server/src/sys/msg/in_game.rs | 13 ++++-- server/src/sys/msg/ping.rs | 3 ++ voxygen/src/menu/char_selection/mod.rs | 1 - voxygen/src/menu/main/mod.rs | 1 - voxygen/src/session/mod.rs | 7 +-- 12 files changed, 101 insertions(+), 40 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index c0c90dd2de..bbaa7b75e5 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -39,7 +39,7 @@ use common::{ mounting::Rider, outcome::Outcome, recipe::{ComponentRecipeBook, RecipeBook}, - resources::{GameMode, PlayerEntity, TimeOfDay}, + resources::{GameMode, PlayerEntity, ServerTime, Time, TimeOfDay}, spiral::Spiral2d, terrain::{ block::Block, map::MapConfig, neighbors, site::DungeonKindMeta, BiomeKind, @@ -1683,7 +1683,6 @@ impl Client { &mut self, inputs: ControllerInputs, dt: Duration, - total_tick_time: Duration, add_foreign_systems: impl Fn(&mut DispatcherBuilder), ) -> Result, Error> { span!(_guard, "tick", "Client::tick"); @@ -1712,7 +1711,8 @@ impl Client { prof_span!("handle and send inputs"); self.next_control.inputs = inputs; let con = std::mem::take(&mut self.next_control); - let rcon = self.local_command_gen.gen(total_tick_time, con); + let time = Duration::from_secs_f64(self.state.ecs().read_resource::