X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FServerState.cpp;h=13abdc9144d27cb4623e0a55dd5dfd0e9af0b08d;hb=81337cf6dac779222131b5e2843a11ac898bb495;hp=e83984106ed06c100c04c6d6f656fff8c0f9a89e;hpb=13e676a6e49128ebc6c63b8dd08bef51d360e8e9;p=blank.git diff --git a/src/app/ServerState.cpp b/src/app/ServerState.cpp index e839841..13abdc9 100644 --- a/src/app/ServerState.cpp +++ b/src/app/ServerState.cpp @@ -24,12 +24,12 @@ ServerState::ServerState( , skeletons() , spawner(world, skeletons, gc.seed) , server(sc, world) -, push_timer(16) { +, loop_timer(16) { TextureIndex tex_index; env.loader.LoadBlockTypes("default", block_types, tex_index); skeletons.LoadHeadless(); - push_timer.Start(); + loop_timer.Start(); std::cout << "listening on UDP port " << sc.port << std::endl; } @@ -43,14 +43,18 @@ void ServerState::Handle(const SDL_Event &event) { void ServerState::Update(int dt) { - push_timer.Update(dt); + loop_timer.Update(dt); server.Handle(); - spawner.Update(dt); - if (!world.Players().empty()) { - world.Update(dt); + int world_dt = 0; + while (loop_timer.HitOnce()) { + spawner.Update(loop_timer.Interval()); + world.Update(loop_timer.Interval()); + world_dt += loop_timer.Interval(); + loop_timer.PopIteration(); } - if (push_timer.Hit()) { - server.Update(dt); + chunk_loader.Update(dt); + if (world_dt > 0) { + server.Update(world_dt); } }