1 #include "ServerState.hpp"
3 #include "Environment.hpp"
4 #include "TextureIndex.hpp"
5 #include "../net/io.hpp"
12 ServerState::ServerState(
13 HeadlessEnvironment &env,
14 const Generator::Config &gc,
15 const World::Config &wc,
17 const Server::Config &sc
21 , world(block_types, wc)
23 , chunk_loader(world.Chunks(), generator, ws)
25 , spawner(world, skeletons, gc.seed)
28 TextureIndex tex_index;
29 env.loader.LoadBlockTypes("default", block_types, tex_index);
30 skeletons.LoadHeadless();
34 std::cout << "listening on UDP port " << sc.port << std::endl;
38 void ServerState::Handle(const SDL_Event &event) {
39 if (event.type == SDL_QUIT) {
45 void ServerState::Update(int dt) {
46 loop_timer.Update(dt);
49 while (loop_timer.HitOnce()) {
50 spawner.Update(loop_timer.Interval());
51 world.Update(loop_timer.Interval());
52 world_dt += loop_timer.Interval();
53 loop_timer.PopIteration();
55 chunk_loader.Update(dt);
57 server.Update(world_dt);
62 void ServerState::Render(Viewport &viewport) {