diff --git a/apps/openmw-mp/Script/Functions/Translocations.cpp b/apps/openmw-mp/Script/Functions/Translocations.cpp index 20808b648..7fa33686d 100644 --- a/apps/openmw-mp/Script/Functions/Translocations.cpp +++ b/apps/openmw-mp/Script/Functions/Translocations.cpp @@ -48,7 +48,7 @@ double ScriptFunctions::GetPosZ(unsigned short pid) noexcept return player->Position()->pos[2]; } -void ScriptFunctions::SetPos(unsigned short pid, float x, float y, float z) noexcept +void ScriptFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -140,7 +140,7 @@ double ScriptFunctions::GetAngleZ(unsigned short pid) noexcept return player->Position()->rot[2]; } -void ScriptFunctions::SetAngle(unsigned short pid, float x, float y, float z) noexcept +void ScriptFunctions::SetAngle(unsigned short pid, double x, double y, double z) noexcept { Player *player; GET_PLAYER(pid, player,); diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index 002cd15c9..725b11c36 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -36,14 +36,14 @@ public: static double GetPosX(unsigned short pid) noexcept; static double GetPosY(unsigned short pid) noexcept; static double GetPosZ(unsigned short pid) noexcept; - static void SetPos(unsigned short pid, float x, float y, float z) noexcept; + static void SetPos(unsigned short pid, double x, double y, double z) noexcept; static void GetAngle(unsigned short pid, float *x, float *y, float *z) noexcept; static double GetAngleX(unsigned short pid) noexcept; static double GetAngleY(unsigned short pid) noexcept; static double GetAngleZ(unsigned short pid) noexcept; - static void SetAngle(unsigned short pid, float x, float y, float z) noexcept; + static void SetAngle(unsigned short pid, double x, double y, double z) noexcept; static void SetCell(unsigned short pid, const char *name) noexcept; static const char *GetCell(unsigned short pid) noexcept; diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 026eab2f7..808b1b49e 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -117,6 +117,18 @@ void LocalPlayer::updatePosition(bool forceUpdate) } } + +void LocalPlayer::setPosition() +{ + MWBase::World *world = MWBase::Environment::get().getWorld(); + MWWorld::Ptr player = world->getPlayerPtr(); + + world->getPlayer().setTeleported(true); + world->moveObject(player, Position()->pos[0], Position()->pos[1], Position()->pos[2]); + world->rotateObject(player, Position()->rot[0], Position()->rot[1], Position()->rot[2]); +} + + void LocalPlayer::updateInventory(bool forceUpdate) { MWWorld::Ptr player = GetPlayerPtr(); diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index 09e66b262..0ff0c37a6 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -29,6 +29,8 @@ namespace mwmp void updateCell(bool forceUpdate = false); void updateDrawStateAndFlags(bool forceUpdate = false); + void setPosition(); + void CharGen(int stageFirst, int stageEnd); bool CharGenThread(); // return true if CGStage::current == CGStage::end diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index 7504ce390..31f1b8c68 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -204,7 +204,16 @@ void Networking::ReciveMessage(RakNet::Packet *packet) case ID_GAME_UPDATE_POS: { if(id == myid) - getLocalPlayer()->updatePosition(true); + { + if (packet->length != myPacket->headerSize()) + { + cout << "ID_GAME_UPDATE_POS changed by server" << endl; + myPacket->Packet(&bsIn, getLocalPlayer(), false); + getLocalPlayer()->setPosition(); + } + else + getLocalPlayer()->updatePosition(true); + } else if(pl != 0) myPacket->Packet(&bsIn, pl, false); break;