From 8ab5d53f2c692c506b8976f696a25ceb249c2524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Wed, 6 Apr 2022 00:12:26 +0200 Subject: [PATCH] sync make systems more stable by: - fix wobbly, by doing CompSync and TimeSync in same ecs system - dont interpolate on voxygen - sync PhysState to the client in order to get rid of the jump snap to ground bug - make the simulate_ahead more constant over time, as "jumps" in this number will be noticed by the client as "lag jumps" There are still some problems - [ ] Snap to the ground on jump isn't fixed completly, as we depend on tick n-1 and we only sync tick n to the client - [ ] Arrows dont work properly yet with this commit, e.g. right click arrow attack - [ ] Verify that clientcommands are actually broadcasted to all clients - [ ] Followup: Agent needs to send clientcommands rather than commands --- client/src/lib.rs | 298 ++--------------------- client/src/revertclock.rs | 249 +++++++++++++++++++ common/net/src/msg/ecs_packet.rs | 11 + common/net/src/msg/server.rs | 7 +- common/net/src/sync/interpolation.rs | 4 +- common/net/src/sync/mod.rs | 2 +- common/src/comp/remote_controller.rs | 102 +++----- common/state/src/state.rs | 31 --- common/systems/src/predict_controller.rs | 4 +- server/src/client.rs | 4 +- server/src/sys/entity_sync.rs | 40 ++- server/src/sys/msg/ping.rs | 3 +- voxygen/src/ecs/sys/interpolation.rs | 8 +- 13 files changed, 372 insertions(+), 391 deletions(-) create mode 100644 client/src/revertclock.rs diff --git a/client/src/lib.rs b/client/src/lib.rs index 7b3b33ab3c..bb0e114e88 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -4,6 +4,7 @@ pub mod addr; pub mod error; +mod revertclock; // Reexports pub use crate::error::Error; @@ -15,7 +16,7 @@ pub use specs::{ Builder, DispatcherBuilder, Entity as EcsEntity, ReadStorage, World, WorldExt, }; -use crate::addr::ConnectionArgs; +use crate::{addr::ConnectionArgs, revertclock::RevertClock}; use byteorder::{ByteOrder, LittleEndian}; use common::{ character::{CharacterId, CharacterItem}, @@ -64,7 +65,7 @@ use common_net::{ sync::WorldSyncExt, }; use common_state::State; -use common_systems::{add_local_systems, add_rewind_systems}; +use common_systems::add_local_systems; use comp::BuffKind; use hashbrown::{HashMap, HashSet}; use image::DynamicImage; @@ -237,9 +238,7 @@ pub struct Client { local_command_gen: CommandGenerator, next_control: Controller, - inter_tick_reverted_time: Option, - inter_tick_time_syncs: usize, - rewind_fluctuation_budget: f64, + revert_clock: RevertClock, network: Option, participant: Option, @@ -724,9 +723,7 @@ impl Client { local_command_gen: CommandGenerator::default(), next_control: Controller::default(), - inter_tick_reverted_time: None, - inter_tick_time_syncs: 0, - rewind_fluctuation_budget: 0.0, + revert_clock: RevertClock::default(), network: Some(network), participant: Some(participant), @@ -1705,8 +1702,7 @@ impl Client { // 1) Build up a list of events for this frame, to be passed to the frontend. let mut frontend_events = Vec::new(); - self.inter_tick_reverted_time = None; - self.inter_tick_time_syncs = 0; + self.revert_clock.reset(); // Prepare for new events { @@ -1736,256 +1732,9 @@ impl Client { // Handle new messages from the server. frontend_events.append(&mut self.handle_new_messages()?); - // Simulate Ahead - - //TODO: also waro budget in non rewind workflow - //Dies hier. außerdem ist immernoch 200 als fixer wert im controler drinn - - let time = self.state.ecs().read_resource::