]> git.localhorst.tv Git - blank.git/blobdiff - src/server/net.cpp
centralize entity controllers
[blank.git] / src / server / net.cpp
index e739922b60268062f4c6a708d0de334d03e401cf..38224ec9a57e879e2a84357a77456b30253f3f1c 100644 (file)
@@ -247,7 +247,6 @@ void ClientConnection::Update(int dt) {
                }
                SendUpdates();
 
-               input->Update(dt);
                CheckPlayerFix();
                CheckChunkQueue();
        }
@@ -317,10 +316,12 @@ void ClientConnection::QueueUpdate(SpawnStatus &status) {
 }
 
 void ClientConnection::SendUpdates() {
+       auto base = PlayerChunks().Base();
        auto pack = Prepare<Packet::EntityUpdate>();
+       pack.WriteChunkBase(base);
        int entity_pos = 0;
        for (SpawnStatus *status : entity_updates) {
-               pack.WriteEntity(*status->entity, entity_pos);
+               pack.WriteEntity(*status->entity, base, entity_pos);
                ++entity_pos;
                if (entity_pos == Packet::EntityUpdate::MAX_ENTITIES) {
                        pack.WriteEntityCount(entity_pos);
@@ -548,21 +549,17 @@ void ClientConnection::On(const Packet::PlayerUpdate &pack) {
                return;
        }
        glm::vec3 movement(0.0f);
-       float pitch = 0.0f;
-       float yaw = 0.0f;
        uint8_t new_actions;
        uint8_t slot;
 
        player_update_pack = pack.Seq();
        pack.ReadPredictedState(player_update_state);
        pack.ReadMovement(movement);
-       pack.ReadPitch(pitch);
-       pack.ReadYaw(yaw);
        pack.ReadActions(new_actions);
        pack.ReadSlot(slot);
 
        input->SetMovement(movement);
-       input->TurnHead(pitch - input->GetPitch(), yaw - input->GetYaw());
+       input->TurnHead(player_update_state.pitch - input->GetPitch(), player_update_state.yaw - input->GetYaw());
        input->SelectInventory(slot);
 
        if ((new_actions & 0x01) && !(old_actions & 0x01)) {