From e0c88150c37bf8a1fba5a15c2d4b9b4c09f81bcf Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sat, 12 Nov 2016 21:01:38 +0200 Subject: [PATCH] Reorder functions for server script translocations --- .../Script/Functions/Translocations.cpp | 115 +++++++++--------- .../Script/Functions/Translocations.hpp | 6 +- 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/apps/openmw-mp/Script/Functions/Translocations.cpp b/apps/openmw-mp/Script/Functions/Translocations.cpp index 2fa2964bc..669fad8f9 100644 --- a/apps/openmw-mp/Script/Functions/Translocations.cpp +++ b/apps/openmw-mp/Script/Functions/Translocations.cpp @@ -49,6 +49,44 @@ double TranslocationFunctions::GetPosZ(unsigned short pid) noexcept return player->Position()->pos[2]; } +void TranslocationFunctions::GetAngle(unsigned short pid, float *x, float *y, float *z) noexcept +{ + *x = 0.00; + *y = 0.00; + *z = 0.00; + + Player *player; + GET_PLAYER(pid, player, ); + + *x = player->Position()->rot[0]; + *y = player->Position()->rot[1]; + *z = player->Position()->rot[2]; +} + +double TranslocationFunctions::GetAngleX(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0.0f); + + return player->Position()->rot[0]; +} + +double TranslocationFunctions::GetAngleY(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0.0f); + + return player->Position()->rot[1]; +} + +double TranslocationFunctions::GetAngleZ(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0.0f); + + return player->Position()->rot[2]; +} + void TranslocationFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept { Player *player; @@ -61,6 +99,26 @@ void TranslocationFunctions::SetPos(unsigned short pid, double x, double y, doub mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_POS)->Send(player, false); } +void TranslocationFunctions::SetAngle(unsigned short pid, double x, double y, double z) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ); + + player->Position()->rot[0] = x; + player->Position()->rot[1] = y; + player->Position()->rot[2] = z; + + mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_POS)->Send(player, false); +} + +const char* TranslocationFunctions::GetCell(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0); + + return player->GetCell()->mName.c_str(); +} + void TranslocationFunctions::SetCell(unsigned short pid, const char *name) noexcept { Player *player; @@ -83,14 +141,6 @@ void TranslocationFunctions::SetCell(unsigned short pid, const char *name) noexc mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_CELL)->Send(player, false); } -const char* TranslocationFunctions::GetCell(unsigned short pid) noexcept -{ - Player *player; - GET_PLAYER(pid, player, 0); - - return player->GetCell()->mName.c_str(); -} - void TranslocationFunctions::SetExterior(unsigned short pid, int x, int y) noexcept { Player *player; @@ -136,52 +186,3 @@ bool TranslocationFunctions::IsInExterior(unsigned short pid) noexcept return player->GetCell()->isExterior(); } -void TranslocationFunctions::GetAngle(unsigned short pid, float *x, float *y, float *z) noexcept -{ - *x = 0.00; - *y = 0.00; - *z = 0.00; - - Player *player; - GET_PLAYER(pid, player,); - - *x = player->Position()->rot[0]; - *y = player->Position()->rot[1]; - *z = player->Position()->rot[2]; -} - -double TranslocationFunctions::GetAngleX(unsigned short pid) noexcept -{ - Player *player; - GET_PLAYER(pid, player, 0.0f); - - return player->Position()->rot[0]; -} - -double TranslocationFunctions::GetAngleY(unsigned short pid) noexcept -{ - Player *player; - GET_PLAYER(pid, player, 0.0f); - - return player->Position()->rot[1]; -} - -double TranslocationFunctions::GetAngleZ(unsigned short pid) noexcept -{ - Player *player; - GET_PLAYER(pid, player, 0.0f); - - return player->Position()->rot[2]; -} - -void TranslocationFunctions::SetAngle(unsigned short pid, double x, double y, double z) noexcept -{ - Player *player; - GET_PLAYER(pid, player,); - - player->Position()->rot[0] = x; - player->Position()->rot[1] = y; - player->Position()->rot[2] = z; - - mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_POS)->Send(player, false); -} diff --git a/apps/openmw-mp/Script/Functions/Translocations.hpp b/apps/openmw-mp/Script/Functions/Translocations.hpp index b82ba1080..0213d8ad7 100644 --- a/apps/openmw-mp/Script/Functions/Translocations.hpp +++ b/apps/openmw-mp/Script/Functions/Translocations.hpp @@ -35,17 +35,17 @@ 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, 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 SetPos(unsigned short pid, double x, double y, double 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; - + static void SetCell(unsigned short pid, const char *name) noexcept; static void SetExterior(unsigned short pid, int x, int y) noexcept; static int GetExteriorX(unsigned short pid) noexcept; static int GetExteriorY(unsigned short pid) noexcept;