- if (pack_diff > 0 || overdue) {
- player_update_pack = pack.Seq();
- pack.ReadPlayerState(player_update_state);
- // accept velocity and orientation as "user input"
- PlayerEntity().Velocity(player_update_state.velocity);
- PlayerEntity().Orientation(player_update_state.orient);
+ if (pack_diff <= 0 && !overdue) {
+ // drop old packets if we have a fairly recent state
+ 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->SelectInventory(slot);
+
+ if ((new_actions & 0x01) && !(old_actions & 0x01)) {
+ input->StartPrimaryAction();
+ } else if (!(new_actions & 0x01) && (old_actions & 0x01)) {
+ input->StopPrimaryAction();
+ }
+ if ((new_actions & 0x02) && !(old_actions & 0x02)) {
+ input->StartSecondaryAction();
+ } else if (!(new_actions & 0x02) && (old_actions & 0x02)) {
+ input->StopSecondaryAction();
+ }
+ if ((new_actions & 0x04) && !(old_actions & 0x04)) {
+ input->StartTertiaryAction();
+ } else if (!(new_actions & 0x04) && (old_actions & 0x04)) {
+ input->StopTertiaryAction();