1 #include "ServerState.hpp"
3 #include "../app/Environment.hpp"
4 #include "../app/TextureIndex.hpp"
5 #include "../net/io.hpp"
13 ServerState::ServerState(
14 HeadlessEnvironment &env,
15 const Generator::Config &gc,
16 const World::Config &wc,
18 const Server::Config &sc
22 , world(block_types, wc)
24 , chunk_loader(world.Chunks(), generator, ws)
26 , spawner(world, skeletons, gc.seed)
29 TextureIndex tex_index;
30 env.loader.LoadBlockTypes("default", block_types, tex_index);
31 skeletons.LoadHeadless();
32 spawner.LimitSkeletons(1, skeletons.Size());
33 server.SetPlayerModel(skeletons[0]);
37 std::cout << "listening on UDP port " << sc.port << std::endl;
41 void ServerState::Handle(const SDL_Event &event) {
42 if (event.type == SDL_QUIT) {
48 void ServerState::Update(int dt) {
49 loop_timer.Update(dt);
52 while (loop_timer.HitOnce()) {
53 spawner.Update(loop_timer.Interval());
54 world.Update(loop_timer.Interval());
55 world_dt += loop_timer.Interval();
56 loop_timer.PopIteration();
58 chunk_loader.Update(dt);
60 server.Update(world_dt);
65 void ServerState::Render(Viewport &viewport) {