mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 15:06:43 +00:00
Use LibFFI for Public & Timer APIs Use "PlayerId" type instead "unsigned short" Add GetPluginDir() function
123 lines
2.9 KiB
C++
123 lines
2.9 KiB
C++
#include "Positions.h"
|
|
#include <apps/openmw-mp/Script/Callbacks.hpp>
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
#include <apps/openmw-mp/Player.hpp>
|
|
#include <apps/openmw-mp/Networking.hpp>
|
|
|
|
#include <iostream>
|
|
using namespace std;
|
|
|
|
extern "C" double PositionFunctions::GetPosX(PlayerId pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
return player->position.pos[0];
|
|
}
|
|
|
|
extern "C" double PositionFunctions::GetPosY(PlayerId pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
return player->position.pos[1];
|
|
}
|
|
|
|
extern "C" double PositionFunctions::GetPosZ(PlayerId pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
return player->position.pos[2];
|
|
}
|
|
|
|
extern "C" double PositionFunctions::GetPreviousCellPosX(PlayerId pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
return player->previousCellPosition.pos[0];
|
|
}
|
|
|
|
extern "C" double PositionFunctions::GetPreviousCellPosY(PlayerId pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
return player->previousCellPosition.pos[1];
|
|
}
|
|
|
|
extern "C" double PositionFunctions::GetPreviousCellPosZ(PlayerId pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
return player->previousCellPosition.pos[2];
|
|
}
|
|
|
|
extern "C" double PositionFunctions::GetRotX(PlayerId pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
return player->position.rot[0];
|
|
}
|
|
|
|
extern "C" double PositionFunctions::GetRotZ(PlayerId pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0.0f);
|
|
|
|
return player->position.rot[2];
|
|
}
|
|
|
|
extern "C" void PositionFunctions::SetPos(PlayerId pid, double x, double y, double z) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player,);
|
|
|
|
player->position.pos[0] = x;
|
|
player->position.pos[1] = y;
|
|
player->position.pos[2] = z;
|
|
}
|
|
|
|
extern "C" void PositionFunctions::SetRot(PlayerId pid, double x, double z) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, );
|
|
|
|
player->position.rot[0] = x;
|
|
player->position.rot[2] = z;
|
|
}
|
|
|
|
extern "C" void PositionFunctions::SetMomentum(PlayerId pid, double x, double y, double z) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, );
|
|
|
|
player->momentum.pos[0] = x;
|
|
player->momentum.pos[1] = y;
|
|
player->momentum.pos[2] = z;
|
|
}
|
|
|
|
extern "C" void PositionFunctions::SendPos(PlayerId pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, );
|
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_POSITION);
|
|
packet->setPlayer(player);
|
|
|
|
packet->Send(false);
|
|
}
|
|
|
|
extern "C" void PositionFunctions::SendMomentum(PlayerId pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, );
|
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MOMENTUM);
|
|
packet->setPlayer(player);
|
|
|
|
packet->Send(false);
|
|
}
|