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.
This commit is contained in:
parent
4239680f53
commit
bab24f2295
2 changed files with 12 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
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;
|
pub const MAX_CATCH_UP_TICKS: i32 = 40;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use logic::battle::{
|
use logic::battle::{
|
||||||
|
|
@ -106,11 +106,20 @@ impl BattleSession {
|
||||||
fn snapshot_message(&mut self) -> Option<WireMessage> {
|
fn snapshot_message(&mut self) -> Option<WireMessage> {
|
||||||
let snapshot = self.mode.snapshot().ok()?;
|
let snapshot = self.mode.snapshot().ok()?;
|
||||||
let report = verify_snapshot(&snapshot);
|
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!(
|
tracing::debug!(
|
||||||
tick = self.tick,
|
tick = self.tick,
|
||||||
bytes = snapshot.len(),
|
bytes = snapshot.len(),
|
||||||
ok = report.is_ok(),
|
ok = report.is_ok(),
|
||||||
"built a battle snapshot"
|
unit = ?unit,
|
||||||
|
"battle snapshot"
|
||||||
);
|
);
|
||||||
if !report.is_ok() {
|
if !report.is_ok() {
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ pub enum RoutingError {
|
||||||
Unauthenticated(u16),
|
Unauthenticated(u16),
|
||||||
}
|
}
|
||||||
type RoutingResult<T> = Result<T, RoutingError>;
|
type RoutingResult<T> = Result<T, RoutingError>;
|
||||||
pub const BATTLE_TICK_INTERVAL: Duration = Duration::from_millis(200);
|
pub const BATTLE_TICK_INTERVAL: Duration = Duration::from_millis(50);
|
||||||
pub struct MessageManager {
|
pub struct MessageManager {
|
||||||
peer: SocketAddr,
|
peer: SocketAddr,
|
||||||
config: Arc<GatewayConfig>,
|
config: Arc<GatewayConfig>,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue