forked from teamnwah/openmw-tes3coop
[Server] Create WorldstateFunctions and move GameTime functions there
parent
9b9dd4abaf
commit
bef36f77ca
@ -0,0 +1,50 @@
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
|
||||
#include <apps/openmw-mp/Networking.hpp>
|
||||
#include <apps/openmw-mp/Player.hpp>
|
||||
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
||||
|
||||
#include "Worldstate.hpp"
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
void WorldstateFunctions::SetHour(unsigned short pid, double hour) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->hour = hour;
|
||||
player->month = -1;
|
||||
player->day = -1;
|
||||
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_TIME)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_TIME)->Send(false);
|
||||
}
|
||||
|
||||
void WorldstateFunctions::SetMonth(unsigned short pid, int month) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->hour = -1;
|
||||
player->month = month;
|
||||
player->day = -1;
|
||||
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_TIME)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_TIME)->Send(false);
|
||||
|
||||
}
|
||||
|
||||
void WorldstateFunctions::SetDay(unsigned short pid, int day) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->hour = -1;
|
||||
player->month = -1;
|
||||
player->day = day;
|
||||
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_TIME)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_TIME)->Send(false);
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
#ifndef OPENMW_WORLDSTATEAPI_HPP
|
||||
#define OPENMW_WORLDSTATEAPI_HPP
|
||||
|
||||
#include "../Types.hpp"
|
||||
|
||||
#define WORLDSTATEAPI \
|
||||
{"SetHour", WorldstateFunctions::SetHour},\
|
||||
{"SetMonth", WorldstateFunctions::SetMonth},\
|
||||
{"SetDay", WorldstateFunctions::SetDay}
|
||||
|
||||
class WorldstateFunctions
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Set the game hour for a player and send a GameTime packet to that player.
|
||||
*
|
||||
* \param pid The player ID.
|
||||
* \param hour The hour.
|
||||
* \return void
|
||||
*/
|
||||
static void SetHour(unsigned short pid, double hour) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Set the game month for a player and send a GameTime packet to that player.
|
||||
*
|
||||
* \param pid The player ID.
|
||||
* \param month The month.
|
||||
* \return void
|
||||
*/
|
||||
static void SetMonth(unsigned short pid, int month) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Set the game day for a player and send a GameTime packet to that player.
|
||||
*
|
||||
* \param pid The player ID.
|
||||
* \param day The day.
|
||||
* \return void
|
||||
*/
|
||||
static void SetDay(unsigned short pid, int day) noexcept;
|
||||
|
||||
};
|
||||
|
||||
#endif //OPENMW_WORLDSTATEAPI_HPP
|
Loading…
Reference in New Issue