diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 56a145522..f0fbbadf6 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1871,6 +1871,10 @@ void CharacterController::update(float duration) MWMechanics::Movement &movementSettings = cls.getMovementSettings(mPtr); localPlayer->direction.pos[0] = movementSettings.mPosition[0]; localPlayer->direction.pos[1] = movementSettings.mPosition[1]; + localPlayer->direction.pos[2] = movementSettings.mPosition[2]; + localPlayer->direction.rot[0] = movementSettings.mRotation[0]; + localPlayer->direction.rot[1] = movementSettings.mRotation[1]; + localPlayer->direction.rot[2] = movementSettings.mRotation[2]; } else if (mwmp::Main::get().getCellController()->isLocalActor(mPtr)) { diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index 2e26c586b..89c34bcb2 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -133,14 +133,20 @@ void DedicatedPlayer::move(float dt) else world->moveObject(ptr, position.pos[0], position.pos[1], position.pos[2]); - float oldZ = ptr.getRefData().getPosition().rot[2]; - world->rotateObject(ptr, position.rot[0], 0, oldZ); + world->rotateObject(ptr, position.rot[0], 0, position.rot[2]); MWMechanics::Movement *move = &ptr.getClass().getMovementSettings(ptr); move->mPosition[0] = direction.pos[0]; move->mPosition[1] = direction.pos[1]; + move->mPosition[2] = direction.pos[2]; - MWMechanics::zTurn(ptr, position.rot[2], osg::DegreesToRadians(1.0)); + // Make sure the values are valid, or we'll get an infinite error loop + if (!isnan(direction.rot[0]) && !isnan(direction.rot[1]) && !isnan(direction.rot[2])) + { + move->mRotation[0] = direction.rot[0]; + move->mRotation[1] = direction.rot[1]; + move->mRotation[2] = direction.rot[2]; + } } void DedicatedPlayer::setBaseInfo() diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 5a4714019..2925b2ad2 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -383,7 +383,7 @@ void LocalPlayer::updatePosition(bool forceUpdate) position = ptrPlayer.getRefData().getPosition(); bool posIsChanging = (direction.pos[0] != 0 || direction.pos[1] != 0 || - position.rot[0] != oldRot[0] || position.rot[2] != oldRot[1]); + direction.rot[0] != 0 || direction.rot[1] != 0 || direction.rot[2] != 0); // Animations can change a player's position without actually creating directional movement, // so update positions accordingly diff --git a/components/openmw-mp/Packets/Player/PacketPlayerPosition.cpp b/components/openmw-mp/Packets/Player/PacketPlayerPosition.cpp index 9dc55b41a..cc2e63496 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerPosition.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerPosition.cpp @@ -19,27 +19,6 @@ void PacketPlayerPosition::Packet(RakNet::BitStream *bs, bool send) { PlayerPacket::Packet(bs, send); - float rot[2]; - unsigned char dir; - if (send) - { - rot[0] = player->position.rot[0] * 0.1f; - rot[1] = player->position.rot[2] * 0.1f; - - dir = (player->direction.pos[0] >= 0 ? (unsigned char)(player->direction.pos[0]) : (unsigned char) 0x3) << 2; // pack direction - dir += (player->direction.pos[1] >= 0 ? (unsigned char)(player->direction.pos[1]) : (unsigned char) 0x3); - } - RW(rot[0], send, true); - RW(rot[1], send, true); - - RW(player->position.pos, send, true); - RW(dir, send); - - if (!send) - { - player->position.rot[0] = rot[0] / 0.1f; - player->position.rot[2] = rot[1] / 0.1f; - player->direction.pos[0] = (dir >> 2) == 0x3 ? -1 : dir >> 2; // unpack direction - player->direction.pos[1] = (dir & 0x3) == 0x3 ? -1 : dir & 0x3; - } + RW(player->position, send, 1); + RW(player->direction, send, 1); }