2017-01-26 13:48:47 +00:00
|
|
|
#include "Positions.hpp"
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include <apps/openmw-mp/Player.hpp>
|
|
|
|
#include <apps/openmw-mp/Networking.hpp>
|
2016-09-27 08:28:44 +00:00
|
|
|
#include <components/openmw-mp/Log.hpp>
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
|
2017-01-26 13:48:47 +00:00
|
|
|
void PositionFunctions::GetPos(unsigned short pid, float *x, float *y, float *z) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
*x = 0.00;
|
|
|
|
*y = 0.00;
|
|
|
|
*z = 0.00;
|
|
|
|
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
2017-01-25 15:06:15 +00:00
|
|
|
*x = player->position.pos[0];
|
|
|
|
*y = player->position.pos[1];
|
|
|
|
*z = player->position.pos[2];
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 13:48:47 +00:00
|
|
|
double PositionFunctions::GetPosX(unsigned short pid) noexcept
|
2016-07-16 08:19:35 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
|
2017-01-25 15:06:15 +00:00
|
|
|
return player->position.pos[0];
|
2016-07-16 08:19:35 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 13:48:47 +00:00
|
|
|
double PositionFunctions::GetPosY(unsigned short pid) noexcept
|
2016-07-16 08:19:35 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
|
2017-01-25 15:06:15 +00:00
|
|
|
return player->position.pos[1];
|
2016-07-16 08:19:35 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 13:48:47 +00:00
|
|
|
double PositionFunctions::GetPosZ(unsigned short pid) noexcept
|
2016-07-16 08:19:35 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
|
2017-01-25 15:06:15 +00:00
|
|
|
return player->position.pos[2];
|
2016-07-16 08:19:35 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 13:48:47 +00:00
|
|
|
void PositionFunctions::GetAngle(unsigned short pid, float *x, float *y, float *z) noexcept
|
2016-11-12 19:01:38 +00:00
|
|
|
{
|
|
|
|
*x = 0.00;
|
|
|
|
*y = 0.00;
|
|
|
|
*z = 0.00;
|
|
|
|
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
2017-01-25 15:06:15 +00:00
|
|
|
*x = player->position.rot[0];
|
|
|
|
*y = player->position.rot[1];
|
|
|
|
*z = player->position.rot[2];
|
2016-11-12 19:01:38 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 13:48:47 +00:00
|
|
|
double PositionFunctions::GetAngleX(unsigned short pid) noexcept
|
2016-11-12 19:01:38 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
|
2017-01-25 15:06:15 +00:00
|
|
|
return player->position.rot[0];
|
2016-11-12 19:01:38 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 13:48:47 +00:00
|
|
|
double PositionFunctions::GetAngleY(unsigned short pid) noexcept
|
2016-11-12 19:01:38 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
|
2017-01-25 15:06:15 +00:00
|
|
|
return player->position.rot[1];
|
2016-11-12 19:01:38 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 13:48:47 +00:00
|
|
|
double PositionFunctions::GetAngleZ(unsigned short pid) noexcept
|
2016-11-12 19:01:38 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
|
2017-01-25 15:06:15 +00:00
|
|
|
return player->position.rot[2];
|
2016-11-12 19:01:38 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 13:48:47 +00:00
|
|
|
void PositionFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
2017-01-25 15:06:15 +00:00
|
|
|
player->position.pos[0] = x;
|
|
|
|
player->position.pos[1] = y;
|
|
|
|
player->position.pos[2] = z;
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 13:48:47 +00:00
|
|
|
void PositionFunctions::SetAngle(unsigned short pid, double x, double y, double z) noexcept
|
2016-11-12 19:01:38 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
2017-01-25 15:06:15 +00:00
|
|
|
player->position.rot[0] = x;
|
|
|
|
player->position.rot[1] = y;
|
|
|
|
player->position.rot[2] = z;
|
2016-11-12 19:01:38 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 13:48:47 +00:00
|
|
|
void PositionFunctions::SendPos(unsigned short pid) noexcept
|
2016-11-12 19:16:05 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
2017-03-06 09:44:08 +00:00
|
|
|
mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_POS)->setPlayer(player);
|
|
|
|
mwmp::Networking::get().getPlayerController()->GetPacket(ID_PLAYER_POS)->Send(false);
|
2016-11-12 19:16:05 +00:00
|
|
|
}
|