100 FPS server tick LETS GOOOOOOO

This commit is contained in:
Hamcha 2020-10-01 16:47:55 +02:00
parent ff9502cffe
commit f63c184d13
Signed by: hamcha
GPG key ID: 41467804B19A3315

View file

@ -11,8 +11,8 @@ use std::time::Duration;
use tokio::net::{TcpListener, TcpStream}; use tokio::net::{TcpListener, TcpStream};
use tokio_tungstenite::WebSocketStream; use tokio_tungstenite::WebSocketStream;
// Minimum delay between updates, in nanoseconds // Minimum delay between updates, in milliseconds
const MIN_UPDATE_NS: u32 = 1000; // 1ms const MIN_UPDATE_MS: u64 = 10;
struct Game { struct Game {
world: World, world: World,
@ -23,7 +23,7 @@ impl Actor for Game {
fn started(&mut self, ctx: &mut Self::Context) { fn started(&mut self, ctx: &mut Self::Context) {
// Start update loop // Start update loop
ctx.run_interval(Duration::new(0, MIN_UPDATE_NS), |game, _ctx| { ctx.run_interval(Duration::from_millis(MIN_UPDATE_MS), |game, _ctx| {
game.world.run_workload("update"); game.world.run_workload("update");
}); });
} }
@ -48,13 +48,13 @@ impl Actor for NetworkManager {
} }
fn main() { fn main() {
let env = Env::default().filter_or("LOG_LEVEL", "trace"); let env = Env::default().filter_or("LOG_LEVEL", "info");
env_logger::init_from_env(env); env_logger::init_from_env(env);
let settings = Settings::new().unwrap(); let settings = Settings::new().unwrap();
let system = System::new("main"); let system = System::new("main");
Game::create(|ctx| { Game::create(|_ctx| {
// Create world // Create world
let world = World::default(); let world = World::default();