From: Daniel Karbach Date: Thu, 5 Nov 2015 07:55:23 +0000 (+0100) Subject: fix serverside player orientation X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=ec40d74319e24480c00f63cb6cfdbd6e1c454f3d;p=blank.git fix serverside player orientation this seems jerkier than before :/ --- diff --git a/src/server/net.cpp b/src/server/net.cpp index 9eac33e..38266d7 100644 --- a/src/server/net.cpp +++ b/src/server/net.cpp @@ -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)) { diff --git a/src/world/Entity.hpp b/src/world/Entity.hpp index 2a4ef89..3bcc21f 100644 --- a/src/world/Entity.hpp +++ b/src/world/Entity.hpp @@ -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