forked from teamnwah/openmw-tes3coop
Merge pull request #434 from TES3MP/0.6.3 while resolving conflicts
Conflicts: apps/openmw-mp/Networking.cpp apps/openmw/mwmp/processors/worldstate/ProcessorGameTime.hpp components/CMakeLists.txt components/openmw-mp/Base/BasePlayer.hpp components/openmw-mp/Packets/Worldstate/PacketGameTime.hppsol2-server-rewrite
commit
ad4214d3e2
@ -1,84 +0,0 @@
|
|||||||
#include "Shapeshift.hpp"
|
|
||||||
|
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
||||||
#include <components/openmw-mp/Log.hpp>
|
|
||||||
|
|
||||||
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
|
||||||
#include <apps/openmw-mp/Networking.hpp>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
double ShapeshiftFunctions::GetScale(unsigned short pid) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, 0.0f);
|
|
||||||
|
|
||||||
return player->scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ShapeshiftFunctions::IsWerewolf(unsigned short pid) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, 0);
|
|
||||||
|
|
||||||
return player->isWerewolf;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *ShapeshiftFunctions::GetCreatureRefId(unsigned short pid) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, 0);
|
|
||||||
|
|
||||||
return player->creatureRefId.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ShapeshiftFunctions::GetCreatureNameDisplayState(unsigned short pid) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, 0);
|
|
||||||
|
|
||||||
return player->displayCreatureName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShapeshiftFunctions::SetScale(unsigned short pid, double scale) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, );
|
|
||||||
|
|
||||||
player->scale = scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShapeshiftFunctions::SetWerewolfState(unsigned short pid, bool isWerewolf) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, );
|
|
||||||
|
|
||||||
player->isWerewolf = isWerewolf;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShapeshiftFunctions::SetCreatureRefId(unsigned short pid, const char *refId) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, );
|
|
||||||
|
|
||||||
player->creatureRefId = refId;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShapeshiftFunctions::SetCreatureNameDisplayState(unsigned short pid, bool displayState) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, );
|
|
||||||
|
|
||||||
player->displayCreatureName = displayState;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShapeshiftFunctions::SendShapeshift(unsigned short pid)
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, );
|
|
||||||
|
|
||||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SHAPESHIFT)->setPlayer(player);
|
|
||||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SHAPESHIFT)->Send(false);
|
|
||||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SHAPESHIFT)->Send(true);
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
#ifndef OPENMW_SHAPESHIFTAPI_HPP
|
|
||||||
#define OPENMW_SHAPESHIFTAPI_HPP
|
|
||||||
|
|
||||||
#include "../Types.hpp"
|
|
||||||
|
|
||||||
#define SHAPESHIFTAPI \
|
|
||||||
{"GetScale", ShapeshiftFunctions::GetScale},\
|
|
||||||
{"IsWerewolf", ShapeshiftFunctions::IsWerewolf},\
|
|
||||||
{"GetCreatureRefId", ShapeshiftFunctions::GetCreatureRefId},\
|
|
||||||
{"GetCreatureNameDisplayState", ShapeshiftFunctions::GetCreatureNameDisplayState},\
|
|
||||||
\
|
|
||||||
{"SetScale", ShapeshiftFunctions::SetScale},\
|
|
||||||
{"SetWerewolfState", ShapeshiftFunctions::SetWerewolfState},\
|
|
||||||
{"SetCreatureRefId", ShapeshiftFunctions::SetCreatureRefId},\
|
|
||||||
{"SetCreatureNameDisplayState", ShapeshiftFunctions::SetCreatureNameDisplayState},\
|
|
||||||
\
|
|
||||||
{"SendShapeshift", ShapeshiftFunctions::SendShapeshift}
|
|
||||||
|
|
||||||
class ShapeshiftFunctions
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get the scale of a player.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \return The scale.
|
|
||||||
*/
|
|
||||||
static double GetScale(unsigned short pid) noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Check whether a player is a werewolf.
|
|
||||||
*
|
|
||||||
* This is based on the last PlayerShapeshift packet received or sent for that player.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \return The werewolf state.
|
|
||||||
*/
|
|
||||||
static bool IsWerewolf(unsigned short pid) noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get the refId of the creature the player is disguised as.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \return The creature refId.
|
|
||||||
*/
|
|
||||||
static const char *GetCreatureRefId(unsigned short pid) noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Check whether a player's name is replaced by that of the creature they are
|
|
||||||
* disguised as when other players hover over them.
|
|
||||||
*
|
|
||||||
* This is based on the last PlayerShapeshift packet received or sent for that player.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \return The creature name display state.
|
|
||||||
*/
|
|
||||||
static bool GetCreatureNameDisplayState(unsigned short pid) noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set the scale of a player.
|
|
||||||
*
|
|
||||||
* This changes the scale recorded for that player in the server memory, but
|
|
||||||
* does not by itself send a packet.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \param scale The new scale.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void SetScale(unsigned short pid, double scale) noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set the werewolf state of a player.
|
|
||||||
*
|
|
||||||
* This changes the werewolf state recorded for that player in the server memory, but
|
|
||||||
* does not by itself send a packet.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \param isWerewolf The new werewolf state.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void SetWerewolfState(unsigned short pid, bool isWerewolf) noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set the refId of the creature a player is disguised as.
|
|
||||||
*
|
|
||||||
* This changes the creature refId recorded for that player in the server memory, but
|
|
||||||
* does not by itself send a packet.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \param refId The creature refId.
|
|
||||||
* \param displaysCreatureName Whether the player's name appears as that of the creature
|
|
||||||
* when hovered over by others.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void SetCreatureRefId(unsigned short pid, const char *refId) noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set whether a player's name is replaced by that of the creature they are
|
|
||||||
* disguised as when other players hover over them.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \param displayState The creature name display state.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void SetCreatureNameDisplayState(unsigned short pid, bool displayState) noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Send a PlayerShapeshift packet about a player.
|
|
||||||
*
|
|
||||||
* This sends the packet to all players connected to the server. It is currently used
|
|
||||||
* only to communicate werewolf states.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void SendShapeshift(unsigned short pid);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //OPENMW_SHAPESHIFTAPI_HPP
|
|
@ -1,50 +0,0 @@
|
|||||||
#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);
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
#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
|
|
@ -1,6 +1,8 @@
|
|||||||
|
#include "../Packets/Worldstate/PacketGameTime.hpp"
|
||||||
|
|
||||||
#include "WorldstatePacketController.hpp"
|
#include "WorldstatePacketController.hpp"
|
||||||
|
|
||||||
mwmp::WorldstatePacketController::WorldstatePacketController(RakNet::RakPeerInterface *peer)
|
mwmp::WorldstatePacketController::WorldstatePacketController(RakNet::RakPeerInterface *peer)
|
||||||
{
|
{
|
||||||
|
AddPacket<PacketGameTime>(&packets, peer);
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
//
|
|
||||||
// Created by koncord on 30.08.16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef OPENMW_PACKETGAMETIME_HPP
|
#ifndef OPENMW_PACKETGAMETIME_HPP
|
||||||
#define OPENMW_PACKETGAMETIME_HPP
|
#define OPENMW_PACKETGAMETIME_HPP
|
||||||
|
|
||||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
#include <components/openmw-mp/Packets/Worldstate/WorldstatePacket.hpp>
|
||||||
|
|
||||||
namespace mwmp
|
namespace mwmp
|
||||||
{
|
{
|
||||||
class PacketGameTime final: public PlayerPacket
|
class PacketGameTime final : public WorldstatePacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PacketGameTime(RakNet::RakPeerInterface *peer);
|
PacketGameTime(RakNet::RakPeerInterface *peer);
|
Loading…
Reference in New Issue