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)
29 TextureIndex tex_index;
30 env.loader.LoadBlockTypes("default", block_types, tex_index);
31 skeletons.LoadHeadless();
36 std::cout << "listening on UDP port " << sc.port << std::endl;
40 void ServerState::Handle(const SDL_Event &event) {
41 if (event.type == SDL_QUIT) {
47 void ServerState::Update(int dt) {
48 loop_timer.Update(dt);
49 push_timer.Update(dt);
51 while (loop_timer.HitOnce()) {
52 spawner.Update(loop_timer.Interval());
53 world.Update(loop_timer.Interval());
54 loop_timer.PopIteration();
56 chunk_loader.Update(dt);
57 if (push_timer.Hit()) {
63 void ServerState::Render(Viewport &viewport) {