From 8a68daf8d3f14bb86e4bc93c1a70676418451d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Tue, 28 Sep 2021 23:40:23 +0200 Subject: [PATCH] enforce server physics --- client/src/lib.rs | 30 ++------ common/net/src/msg/client.rs | 11 --- common/src/cmd.rs | 10 --- common/src/comp/remote_controller.rs | 14 ++++ common/src/resources.rs | 25 ------- common/state/src/state.rs | 4 +- server/src/cmd.rs | 35 +-------- server/src/sys/entity_sync.rs | 17 +---- server/src/sys/msg/in_game.rs | 98 +++++--------------------- server/src/sys/msg/ping.rs | 4 +- voxygen/src/session/mod.rs | 1 - voxygen/src/session/settings_change.rs | 10 +-- 12 files changed, 43 insertions(+), 216 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index bbaa7b75e5..a4e408526a 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, ServerTime, Time, TimeOfDay}, + resources::{DeltaTime, GameMode, PlayerEntity, ServerTime, Time, TimeOfDay}, spiral::Spiral2d, terrain::{ block::Block, map::MapConfig, neighbors, site::DungeonKindMeta, BiomeKind, @@ -852,10 +852,8 @@ impl Client { | ClientGeneral::BreakBlock(_) | ClientGeneral::PlaceBlock(_, _) | ClientGeneral::ExitInGame - | ClientGeneral::PlayerPhysics { .. } | ClientGeneral::UnlockSkill(_) | ClientGeneral::RequestSiteInfo(_) - | ClientGeneral::RequestPlayerPhysics { .. } | ClientGeneral::RequestLossyTerrainCompression { .. } | ClientGeneral::UpdateMapMarker(_) | ClientGeneral::SpectatePosition(_) => { @@ -890,12 +888,6 @@ impl Client { } } - pub fn request_player_physics(&mut self, server_authoritative: bool) { - self.send_msg(ClientGeneral::RequestPlayerPhysics { - server_authoritative, - }) - } - pub fn request_lossy_terrain_compression(&mut self, lossy_terrain_compression: bool) { self.send_msg(ClientGeneral::RequestLossyTerrainCompression { lossy_terrain_compression, @@ -1806,22 +1798,6 @@ impl Client { self.last_server_ping = self.state.get_time(); } - // 6) Update the server about the player's physics attributes. - if self.presence.is_some() { - if let (Some(pos), Some(vel), Some(ori)) = ( - self.state.read_storage().get(self.entity()).cloned(), - self.state.read_storage().get(self.entity()).cloned(), - self.state.read_storage().get(self.entity()).cloned(), - ) { - self.in_game_stream.send(ClientGeneral::PlayerPhysics { - pos, - vel, - ori, - force_counter: self.force_update_counter, - })?; - } - } - /* // Output debug metrics if log_enabled!(Level::Info) && self.tick % 600 == 0 { @@ -2180,6 +2156,7 @@ impl Client { match msg { ServerGeneral::TimeSync(time) => { self.state.ecs().write_resource::().0 = time.0; + let dt = self.state.ecs().read_resource::().0 as f64; let latency = self .state .ecs() @@ -2187,7 +2164,8 @@ impl Client { .get(self.entity()) .map(|rc| rc.avg_latency()) .unwrap_or_default(); - self.state.ecs().write_resource::