]> git.localhorst.tv Git - blank.git/blobdiff - src/client/client.cpp
make gcc nag more
[blank.git] / src / client / client.cpp
index d20a98c32bcdcd514d44fb7ef37c5964416f9fb0..be62988769130a8dbdd27ed4cfeeeceea5b0278c 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "../app/Environment.hpp"
 #include "../app/init.hpp"
+#include "../geometry/distance.hpp"
 #include "../model/Model.hpp"
 #include "../io/WorldSave.hpp"
 #include "../world/ChunkIndex.hpp"
@@ -56,7 +57,7 @@ InteractiveState::InteractiveState(MasterState &master, uint32_t player_id)
 , manip(master.GetEnv().audio, sounds, player.GetEntity())
 , input(world, player, master.GetClient())
 , interface(master.GetConfig(), master.GetEnv().keymap, input, *this)
-, chunk_receiver(world.Chunks(), save)
+, chunk_receiver(master.GetClient(), world.Chunks(), save)
 , chunk_renderer(player.GetChunks())
 , loop_timer(16)
 , stat_timer(1000)
@@ -79,9 +80,6 @@ InteractiveState::InteractiveState(MasterState &master, uint32_t player_id)
        chunk_renderer.FogDensity(master.GetWorldConf().fog_density);
        loop_timer.Start();
        stat_timer.Start();
-       if (save.Exists(player)) {
-               save.Read(player);
-       }
 }
 
 void InteractiveState::OnResume() {
@@ -160,7 +158,7 @@ void InteractiveState::Update(int dt) {
        if (input.BlockFocus()) {
                hud.FocusBlock(input.BlockFocus().GetChunk(), input.BlockFocus().block);
        } else if (input.EntityFocus()) {
-               hud.FocusEntity(*input.EntityFocus().entity);
+               hud.FocusEntity(input.EntityFocus().GetEntity());
        } else {
                hud.FocusNone();
        }
@@ -189,12 +187,13 @@ void InteractiveState::Update(int dt) {
 }
 
 void InteractiveState::Render(Viewport &viewport) {
-       viewport.WorldPosition(
-               player.GetEntity().Transform(player.GetEntity().ChunkCoords())
-               * player.GetEntity().GetModel().EyesTransform());
+       viewport.WorldPosition(player.GetEntity().ViewTransform(player.GetEntity().ChunkCoords()));
        if (master.GetConfig().video.world) {
                chunk_renderer.Render(viewport);
                world.Render(viewport);
+               if (master.GetConfig().video.debug) {
+                       world.RenderDebug(viewport);
+               }
                sky.Render(viewport);
        }
        hud.Render(viewport);
@@ -349,6 +348,14 @@ void InteractiveState::SetDebug(bool b) {
        }
 }
 
+void InteractiveState::NextCamera() {
+       if (iszero(master.GetEnv().viewport.CameraOffset())) {
+               master.GetEnv().viewport.OffsetCamera(glm::vec3(0.0f, 0.0f, -5.0f));
+       } else {
+               master.GetEnv().viewport.OffsetCamera(glm::vec3(0.0f, 0.0f, 0.0f));
+       }
+}
+
 void InteractiveState::Exit() {
        save.Write(player);
        master.Quit();
@@ -389,7 +396,7 @@ void MasterState::OnEnter() {
 }
 
 
-void MasterState::Handle(const SDL_Event &event) {
+void MasterState::Handle(const SDL_Event &) {
 
 }
 
@@ -443,7 +450,7 @@ void MasterState::On(const Packet::Join &pack) {
        env.state.Push(state.get());
 }
 
-void MasterState::On(const Packet::Part &pack) {
+void MasterState::On(const Packet::Part &) {
        Quit();
        if (state) {
                // kicked