forked from mirror/openmw-tes3mp
[Server] Create WorldstateFunctions and move GameTime functions there
This commit is contained in:
parent
9b9dd4abaf
commit
bef36f77ca
6 changed files with 100 additions and 73 deletions
|
@ -83,6 +83,7 @@ set(SERVER
|
|||
Script/ScriptFunctions.cpp
|
||||
|
||||
Script/Functions/Actors.cpp Script/Functions/Objects.cpp Script/Functions/Miscellaneous.cpp
|
||||
Script/Functions/Worldstate.cpp
|
||||
|
||||
Script/Functions/Books.cpp Script/Functions/Cells.cpp Script/Functions/CharClass.cpp
|
||||
Script/Functions/Chat.cpp Script/Functions/Dialogue.cpp Script/Functions/Factions.cpp
|
||||
|
|
|
@ -449,43 +449,3 @@ void ObjectFunctions::SendConsoleCommand(bool broadcast) noexcept
|
|||
if (broadcast)
|
||||
packet->Send(true);
|
||||
}
|
||||
|
||||
void ObjectFunctions::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 ObjectFunctions::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 ObjectFunctions::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);
|
||||
}
|
||||
|
|
|
@ -81,11 +81,7 @@
|
|||
{"SendDoorState", ObjectFunctions::SendDoorState},\
|
||||
{"SendDoorDestination", ObjectFunctions::SendDoorDestination},\
|
||||
{"SendContainer", ObjectFunctions::SendContainer},\
|
||||
{"SendConsoleCommand", ObjectFunctions::SendConsoleCommand},\
|
||||
\
|
||||
{"SetHour", ObjectFunctions::SetHour},\
|
||||
{"SetMonth", ObjectFunctions::SetMonth},\
|
||||
{"SetDay", ObjectFunctions::SetDay}
|
||||
{"SendConsoleCommand", ObjectFunctions::SendConsoleCommand}
|
||||
|
||||
class ObjectFunctions
|
||||
{
|
||||
|
@ -751,32 +747,6 @@ public:
|
|||
*/
|
||||
static void SendConsoleCommand(bool broadcast = false) noexcept;
|
||||
|
||||
/**
|
||||
* \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;
|
||||
};
|
||||
|
||||
|
||||
|
|
50
apps/openmw-mp/Script/Functions/Worldstate.cpp
Normal file
50
apps/openmw-mp/Script/Functions/Worldstate.cpp
Normal file
|
@ -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);
|
||||
}
|
44
apps/openmw-mp/Script/Functions/Worldstate.hpp
Normal file
44
apps/openmw-mp/Script/Functions/Worldstate.hpp
Normal file
|
@ -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
|
|
@ -15,13 +15,14 @@
|
|||
#include <Script/Functions/Items.hpp>
|
||||
#include <Script/Functions/Mechanics.hpp>
|
||||
#include <Script/Functions/Miscellaneous.hpp>
|
||||
#include <Script/Functions/Objects.hpp>
|
||||
#include <Script/Functions/Positions.hpp>
|
||||
#include <Script/Functions/Quests.hpp>
|
||||
#include <Script/Functions/Shapeshift.hpp>
|
||||
#include <Script/Functions/Settings.hpp>
|
||||
#include <Script/Functions/Spells.hpp>
|
||||
#include <Script/Functions/Stats.hpp>
|
||||
#include <Script/Functions/Objects.hpp>
|
||||
#include <Script/Functions/Worldstate.hpp>
|
||||
#include <RakNetTypes.h>
|
||||
//#include <amx/amx.h>
|
||||
#include <tuple>
|
||||
|
@ -291,7 +292,8 @@ public:
|
|||
SETTINGSAPI,
|
||||
SPELLAPI,
|
||||
STATAPI,
|
||||
OBJECTAPI
|
||||
OBJECTAPI,
|
||||
WORLDSTATEAPI
|
||||
};
|
||||
|
||||
static constexpr ScriptCallbackData callbacks[]{
|
||||
|
|
Loading…
Reference in a new issue