]> git.localhorst.tv Git - blank.git/blobdiff - src/client/net.cpp
move common exceptions to app/error
[blank.git] / src / client / net.cpp
index 75865be577dfac866df3ac302ac85f0a491e440e..879dfb10ef8908cc30f3b4a07f62d50318e2b2a5 100644 (file)
@@ -3,7 +3,7 @@
 #include "Client.hpp"
 #include "NetworkedInput.hpp"
 
-#include "../app/init.hpp"
+#include "../app/error.hpp"
 #include "../geometry/distance.hpp"
 #include "../io/WorldSave.hpp"
 #include "../net/Packet.hpp"
@@ -185,6 +185,7 @@ void ChunkReceiver::Commit(ChunkTransmission &trans) {
        } else {
                memcpy(dst, src, min(src_len, dst_len));
        }
+       chunk->ScanActive();
        chunk->Invalidate();
        trans.Clear();
 }
@@ -243,10 +244,15 @@ IPaddress client_resolve(const char *host, Uint16 port) {
 
 }
 
+// relying on {} zero intitialization for UDPpacket, because
+// the type and number of fields is not well defined
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
 Client::Client(const Config::Network &conf)
 : conn(client_resolve(conf.host.c_str(), conf.port))
 , client_sock(client_bind(0))
 , client_pack{ -1, nullptr, 0 } {
+#pragma GCC diagnostic pop
        client_pack.data = new Uint8[sizeof(Packet)];
        client_pack.maxlen = sizeof(Packet);
        // establish connection
@@ -305,8 +311,8 @@ uint16_t Client::SendLogin(const string &name) {
 uint16_t Client::SendPlayerUpdate(
        const EntityState &prediction,
        const glm::vec3 &movement,
-       float pitch,
-       float yaw,
+       float,
+       float,
        uint8_t actions,
        uint8_t slot
 ) {
@@ -358,7 +364,7 @@ bool NetworkedInput::UpdateImportant() const noexcept {
        return old_actions != actions || !iszero(old_movement - GetMovement());
 }
 
-void NetworkedInput::Update(Entity &, float dt) {
+void NetworkedInput::Update(Entity &, float) {
        Invalidate();
        UpdatePlayer();
 }
@@ -425,13 +431,13 @@ void NetworkedInput::MergePlayerCorrection(uint16_t seq, const EntityState &corr
        vector<WorldCollision> col;
        while (entry != end) {
                SetMovement(entry->movement);
-               GetWorld().Update(replay, entry->delta_t);
+               replay.Update(GetWorld(), entry->delta_t);
                entry->state.pos = replay.GetState().pos;
                ++entry;
        }
 
        glm::vec3 displacement(replay.GetState().Diff(player_state));
-       const float disp_squared = dot(displacement, displacement);
+       const float disp_squared = glm::dot(displacement, displacement);
 
        if (disp_squared < 16.0f * numeric_limits<float>::epsilon()) {
                SetMovement(restore_movement);