]> git.localhorst.tv Git - blank.git/blobdiff - src/app/WorldState.cpp
try to get every chunk change saved to disk
[blank.git] / src / app / WorldState.cpp
index 6ca9959c7de78c634316e1c46e78d7d0e53d1180..86e3eac93bdaa619fd344d7709f92b6ff4a65421 100644 (file)
@@ -1,6 +1,7 @@
 #include "WorldState.hpp"
 
 #include "Environment.hpp"
+#include "UnloadState.hpp"
 
 #include <SDL.h>
 
@@ -10,10 +11,11 @@ namespace blank {
 WorldState::WorldState(
        Environment &env,
        const Interface::Config &ic,
-       const World::Config &wc
+       const World::Config &wc,
+       const WorldSave &save
 )
 : env(env)
-, world(wc)
+, world(env.assets, wc, save)
 , spawner(world)
 , interface(ic, env, world) {
 
@@ -40,6 +42,10 @@ void WorldState::Handle(const SDL_Event &event) {
                case SDL_MOUSEWHEEL:
                        interface.Handle(event.wheel);
                        break;
+               case SDL_QUIT:
+                       // don't care about this leak just now
+                       env.state.Switch(new UnloadState(env, world.Loader()));
+                       break;
                default:
                        break;
        }