]> git.localhorst.tv Git - blank.git/commitdiff
fix serverside player orientation
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 5 Nov 2015 07:55:23 +0000 (08:55 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 5 Nov 2015 07:55:23 +0000 (08:55 +0100)
this seems jerkier than before :/

src/server/net.cpp
src/world/Entity.hpp

index 9eac33ece573ed35edb24b78893b855f75c0feb3..38266d79f0f2887f82222b2dc4896e6bc29188b8 100644 (file)
@@ -575,10 +575,16 @@ void ClientConnection::On(const Packet::PlayerUpdate &pack) {
        pack.ReadActions(new_actions);
        pack.ReadSlot(slot);
 
+       // accept client's orientation as is
+       input->GetPlayer().GetEntity().Orientation(player_update_state.orient);
+       // simulate movement
        input->SetMovement(movement);
+       // rotate head to match client's "prediction"
        input->TurnHead(player_update_state.pitch - input->GetPitch(), player_update_state.yaw - input->GetYaw());
+       // select the given inventory slot
        input->SelectInventory(slot);
 
+       // check if any actions have been started or stopped
        if ((new_actions & 0x01) && !(old_actions & 0x01)) {
                input->StartPrimaryAction();
        } else if (!(new_actions & 0x01) && (old_actions & 0x01)) {
index 2a4ef89093ff848556841669839c95965f7614e3..3bcc21f65f2573a456d094bb3a0656c1b1001e99 100644 (file)
@@ -77,6 +77,7 @@ public:
        }
 
        /// orientation of local coordinate system
+       void Orientation(const glm::quat &o) noexcept { state.orient = o; }
        const glm::quat &Orientation() const noexcept { return state.orient; }
 
        /// orientation of head within local coordinate system, in radians