From bab24f2295b2682f3975d8cf5bcfa832e92fe4a9 Mon Sep 17 00:00:00 2001 From: WiseDev <83840010+wisedevik@users.noreply.github.com> Date: Sun, 23 Aug 2026 14:10:55 +0300 Subject: [PATCH] send the battle state five times a second the server was simulating correctly all along - the log shows a goblin covering 120 units a tick and a knight 60, exactly their Speed columns, in a straight line with no jitter. the teleporting was the correction rate: one snapshot a second, while the client runs its own prediction in between and diverges from ours. a unit gets more than a tile out of step before our state arrives and drags it back. the snapshot now goes every four ticks and the gateway ticks every fifty milliseconds rather than two hundred, so a correction moves a unit a fifth as far. this makes the symptom smaller, not absent. it goes away when the two simulations agree, which is what the checksum comparison is for and what collisions and projectiles are still missing for. --- crates/game-service/src/battle_session.rs | 13 +++++++++++-- crates/gateway/src/message_manager.rs | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/game-service/src/battle_session.rs b/crates/game-service/src/battle_session.rs index e565d52..39d2790 100644 --- a/crates/game-service/src/battle_session.rs +++ b/crates/game-service/src/battle_session.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; use std::sync::Arc; -pub const SNAPSHOT_INTERVAL_TICKS: i32 = 20; +pub const SNAPSHOT_INTERVAL_TICKS: i32 = 4; pub const MAX_CATCH_UP_TICKS: i32 = 40; use std::time::Instant; use logic::battle::{ @@ -106,11 +106,20 @@ impl BattleSession { fn snapshot_message(&mut self) -> Option { let snapshot = self.mode.snapshot().ok()?; let report = verify_snapshot(&snapshot); + let unit = self + .mode + .battle + .objects + .objects + .iter() + .find(|entry| entry.stats().speed > 0) + .map(|entry| (entry.position(), entry.owner_index())); tracing::debug!( tick = self.tick, bytes = snapshot.len(), ok = report.is_ok(), - "built a battle snapshot" + unit = ?unit, + "battle snapshot" ); if !report.is_ok() { tracing::error!( diff --git a/crates/gateway/src/message_manager.rs b/crates/gateway/src/message_manager.rs index 2e1409e..ebac6d0 100644 --- a/crates/gateway/src/message_manager.rs +++ b/crates/gateway/src/message_manager.rs @@ -22,7 +22,7 @@ pub enum RoutingError { Unauthenticated(u16), } type RoutingResult = Result; -pub const BATTLE_TICK_INTERVAL: Duration = Duration::from_millis(200); +pub const BATTLE_TICK_INTERVAL: Duration = Duration::from_millis(50); pub struct MessageManager { peer: SocketAddr, config: Arc,