diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index 12bab0186..7def88ce9 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -74,7 +74,7 @@ set(SERVER Script/Functions/CharClass.cpp Script/Functions/Chat.cpp Script/Functions/GUI.cpp Script/Functions/Items.cpp Script/Functions/Quests.cpp Script/Functions/Stats.cpp - Script/Functions/Spells.cpp Script/Functions/Timer.cpp Script/Functions/Translocations.cpp + Script/Functions/Spells.cpp Script/Functions/Timer.cpp Script/Functions/Positions.cpp Script/Functions/World.cpp Script/API/TimerAPI.cpp Script/API/PublicFnAPI.cpp diff --git a/apps/openmw-mp/Script/Functions/Translocations.cpp b/apps/openmw-mp/Script/Functions/Positions.cpp similarity index 69% rename from apps/openmw-mp/Script/Functions/Translocations.cpp rename to apps/openmw-mp/Script/Functions/Positions.cpp index f6378de79..55c83a0a0 100644 --- a/apps/openmw-mp/Script/Functions/Translocations.cpp +++ b/apps/openmw-mp/Script/Functions/Positions.cpp @@ -1,7 +1,4 @@ -// -// Created by koncord on 29.02.16. -// -#include "Translocations.hpp" +#include "Positions.hpp" #include #include #include @@ -11,7 +8,7 @@ #include using namespace std; -void TranslocationFunctions::GetPos(unsigned short pid, float *x, float *y, float *z) noexcept +void PositionFunctions::GetPos(unsigned short pid, float *x, float *y, float *z) noexcept { *x = 0.00; *y = 0.00; @@ -25,7 +22,7 @@ void TranslocationFunctions::GetPos(unsigned short pid, float *x, float *y, floa *z = player->position.pos[2]; } -double TranslocationFunctions::GetPosX(unsigned short pid) noexcept +double PositionFunctions::GetPosX(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -33,7 +30,7 @@ double TranslocationFunctions::GetPosX(unsigned short pid) noexcept return player->position.pos[0]; } -double TranslocationFunctions::GetPosY(unsigned short pid) noexcept +double PositionFunctions::GetPosY(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -41,7 +38,7 @@ double TranslocationFunctions::GetPosY(unsigned short pid) noexcept return player->position.pos[1]; } -double TranslocationFunctions::GetPosZ(unsigned short pid) noexcept +double PositionFunctions::GetPosZ(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -49,7 +46,7 @@ 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 +void PositionFunctions::GetAngle(unsigned short pid, float *x, float *y, float *z) noexcept { *x = 0.00; *y = 0.00; @@ -63,7 +60,7 @@ void TranslocationFunctions::GetAngle(unsigned short pid, float *x, float *y, fl *z = player->position.rot[2]; } -double TranslocationFunctions::GetAngleX(unsigned short pid) noexcept +double PositionFunctions::GetAngleX(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -71,7 +68,7 @@ double TranslocationFunctions::GetAngleX(unsigned short pid) noexcept return player->position.rot[0]; } -double TranslocationFunctions::GetAngleY(unsigned short pid) noexcept +double PositionFunctions::GetAngleY(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -79,7 +76,7 @@ double TranslocationFunctions::GetAngleY(unsigned short pid) noexcept return player->position.rot[1]; } -double TranslocationFunctions::GetAngleZ(unsigned short pid) noexcept +double PositionFunctions::GetAngleZ(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -87,7 +84,7 @@ double TranslocationFunctions::GetAngleZ(unsigned short pid) noexcept return player->position.rot[2]; } -void TranslocationFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept +void PositionFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -97,7 +94,7 @@ void TranslocationFunctions::SetPos(unsigned short pid, double x, double y, doub player->position.pos[2] = z; } -void TranslocationFunctions::SetAngle(unsigned short pid, double x, double y, double z) noexcept +void PositionFunctions::SetAngle(unsigned short pid, double x, double y, double z) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -107,7 +104,7 @@ void TranslocationFunctions::SetAngle(unsigned short pid, double x, double y, do player->position.rot[2] = z; } -const char* TranslocationFunctions::GetCell(unsigned short pid) noexcept +const char* PositionFunctions::GetCell(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -115,7 +112,7 @@ const char* TranslocationFunctions::GetCell(unsigned short pid) noexcept return player->cell.mName.c_str(); } -void TranslocationFunctions::SetCell(unsigned short pid, const char *name) noexcept +void PositionFunctions::SetCell(unsigned short pid, const char *name) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -135,7 +132,7 @@ void TranslocationFunctions::SetCell(unsigned short pid, const char *name) noexc player->cell.mName = name; } -void TranslocationFunctions::SetExterior(unsigned short pid, int x, int y) noexcept +void PositionFunctions::SetExterior(unsigned short pid, int x, int y) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -156,21 +153,21 @@ void TranslocationFunctions::SetExterior(unsigned short pid, int x, int y) noexc player->cell.mData.mY = y; } -int TranslocationFunctions::GetExteriorX(unsigned short pid) noexcept +int PositionFunctions::GetExteriorX(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,0); return player->cell.mData.mX; } -int TranslocationFunctions::GetExteriorY(unsigned short pid) noexcept +int PositionFunctions::GetExteriorY(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,0); return player->cell.mData.mY; } -bool TranslocationFunctions::IsInExterior(unsigned short pid) noexcept +bool PositionFunctions::IsInExterior(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, false); @@ -178,7 +175,7 @@ bool TranslocationFunctions::IsInExterior(unsigned short pid) noexcept return player->cell.isExterior(); } -void TranslocationFunctions::SendPos(unsigned short pid) noexcept +void PositionFunctions::SendPos(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -186,7 +183,7 @@ void TranslocationFunctions::SendPos(unsigned short pid) noexcept mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_POS)->Send(player, false); } -void TranslocationFunctions::SendCell(unsigned short pid) noexcept +void PositionFunctions::SendCell(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); diff --git a/apps/openmw-mp/Script/Functions/Positions.hpp b/apps/openmw-mp/Script/Functions/Positions.hpp new file mode 100644 index 000000000..68bf7358f --- /dev/null +++ b/apps/openmw-mp/Script/Functions/Positions.hpp @@ -0,0 +1,58 @@ +#ifndef OPENMW_POSITIONAPI_HPP +#define OPENMW_POSITIONAPI_HPP + +#include "../Types.hpp" + +#define POSITIONAPI \ + {"GetPos", PositionFunctions::GetPos},\ + {"GetPosX", PositionFunctions::GetPosX},\ + {"GetPosY", PositionFunctions::GetPosY},\ + {"GetPosZ", PositionFunctions::GetPosZ},\ +\ + {"GetAngle", PositionFunctions::GetAngle},\ + {"GetAngleX", PositionFunctions::GetAngleX},\ + {"GetAngleY", PositionFunctions::GetAngleY},\ + {"GetAngleZ", PositionFunctions::GetAngleZ},\ +\ + {"SetPos", PositionFunctions::SetPos},\ + {"SetAngle", PositionFunctions::SetAngle},\ +\ + {"GetCell", PositionFunctions::GetCell},\ + {"SetCell", PositionFunctions::SetCell},\ + {"SetExterior", PositionFunctions::SetExterior},\ + {"GetExteriorX", PositionFunctions::GetExteriorX},\ + {"GetExteriorY", PositionFunctions::GetExteriorY},\ + {"IsInExterior", PositionFunctions::IsInExterior},\ +\ + {"SendPos", PositionFunctions::SendPos},\ + {"SendCell", PositionFunctions::SendCell} + + +class PositionFunctions +{ +public: + static void GetPos(unsigned short pid, float *x, float *y, float *z) noexcept; + static double GetPosX(unsigned short pid) noexcept; + static double GetPosY(unsigned short pid) noexcept; + static double GetPosZ(unsigned short pid) 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 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; + static bool IsInExterior(unsigned short pid) noexcept; + + static void SendPos(unsigned short pid) noexcept; + static void SendCell(unsigned short pid) noexcept; +}; + +#endif //OPENMW_POSITIONAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/Translocations.hpp b/apps/openmw-mp/Script/Functions/Translocations.hpp deleted file mode 100644 index 72a8b493a..000000000 --- a/apps/openmw-mp/Script/Functions/Translocations.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// -// Created by koncord on 30.08.16. -// - -#ifndef OPENMW_TRANSLOCATIONS_HPP -#define OPENMW_TRANSLOCATIONS_HPP - -#include "../Types.hpp" - -#define TRANSLOCATIONFUNCTIONS \ - {"GetPos", TranslocationFunctions::GetPos},\ - {"GetPosX", TranslocationFunctions::GetPosX},\ - {"GetPosY", TranslocationFunctions::GetPosY},\ - {"GetPosZ", TranslocationFunctions::GetPosZ},\ -\ - {"GetAngle", TranslocationFunctions::GetAngle},\ - {"GetAngleX", TranslocationFunctions::GetAngleX},\ - {"GetAngleY", TranslocationFunctions::GetAngleY},\ - {"GetAngleZ", TranslocationFunctions::GetAngleZ},\ -\ - {"SetPos", TranslocationFunctions::SetPos},\ - {"SetAngle", TranslocationFunctions::SetAngle},\ -\ - {"GetCell", TranslocationFunctions::GetCell},\ - {"SetCell", TranslocationFunctions::SetCell},\ - {"SetExterior", TranslocationFunctions::SetExterior},\ - {"GetExteriorX", TranslocationFunctions::GetExteriorX},\ - {"GetExteriorY", TranslocationFunctions::GetExteriorY},\ - {"IsInExterior", TranslocationFunctions::IsInExterior},\ -\ - {"SendPos", TranslocationFunctions::SendPos},\ - {"SendCell", TranslocationFunctions::SendCell} - - -class TranslocationFunctions -{ -public: - static void GetPos(unsigned short pid, float *x, float *y, float *z) noexcept; - static double GetPosX(unsigned short pid) noexcept; - static double GetPosY(unsigned short pid) noexcept; - static double GetPosZ(unsigned short pid) 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 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; - static bool IsInExterior(unsigned short pid) noexcept; - - static void SendPos(unsigned short pid) noexcept; - static void SendCell(unsigned short pid) noexcept; -}; - -#endif //OPENMW_TRANSLOCATIONS_HPP diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index 45732877e..4352f640d 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -6,7 +6,7 @@ #define SCRIPTFUNCTIONS_HPP #include