]> git.localhorst.tv Git - blank.git/blob - src/app/ServerState.cpp
first draft for client/server architecture
[blank.git] / src / app / ServerState.cpp
1 #include "ServerState.hpp"
2
3 #include "Environment.hpp"
4 #include "TextureIndex.hpp"
5 #include "../net/io.hpp"
6
7 #include <iostream>
8
9
10 namespace blank {
11
12 ServerState::ServerState(
13         HeadlessEnvironment &env,
14         const World::Config &wc,
15         const WorldSave &ws,
16         const Server::Config &sc
17 )
18 : env(env)
19 , block_types()
20 , world(block_types, wc, ws)
21 , server(sc, world) {
22         TextureIndex tex_index;
23         env.loader.LoadBlockTypes("default", block_types, tex_index);
24
25         std::cout << "listening on UDP port " << sc.port << std::endl;
26 }
27
28
29 void ServerState::Handle(const SDL_Event &event) {
30         if (event.type == SDL_QUIT) {
31                 env.state.PopAll();
32         }
33 }
34
35
36 void ServerState::Update(int dt) {
37         server.Handle();
38         server.Update(dt);
39 }
40
41
42 void ServerState::Render(Viewport &viewport) {
43
44 }
45
46 }