forked from mirror/openmw-tes3mp
[General] Turn GameTime into a Worldstate packet
This commit is contained in:
parent
e87e1dbb30
commit
5af1150ab2
13 changed files with 68 additions and 62 deletions
|
@ -1,4 +1,5 @@
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
#include <components/openmw-mp/Base/BaseWorldstate.hpp>
|
||||||
|
|
||||||
#include <apps/openmw-mp/Networking.hpp>
|
#include <apps/openmw-mp/Networking.hpp>
|
||||||
#include <apps/openmw-mp/Player.hpp>
|
#include <apps/openmw-mp/Player.hpp>
|
||||||
|
@ -6,20 +7,24 @@
|
||||||
|
|
||||||
#include "Worldstate.hpp"
|
#include "Worldstate.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace mwmp;
|
||||||
|
|
||||||
|
BaseWorldstate writeWorldstate;
|
||||||
|
|
||||||
void WorldstateFunctions::SetHour(unsigned short pid, double hour) noexcept
|
void WorldstateFunctions::SetHour(unsigned short pid, double hour) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, );
|
GET_PLAYER(pid, player, );
|
||||||
|
|
||||||
player->hour = hour;
|
writeWorldstate.guid = player->guid;
|
||||||
player->month = -1;
|
|
||||||
player->day = -1;
|
|
||||||
|
|
||||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_TIME)->setPlayer(player);
|
writeWorldstate.hour = hour;
|
||||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_TIME)->Send(false);
|
writeWorldstate.month = -1;
|
||||||
|
writeWorldstate.day = -1;
|
||||||
|
|
||||||
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_GAME_TIME)->setWorldstate(&writeWorldstate);
|
||||||
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_GAME_TIME)->Send(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldstateFunctions::SetMonth(unsigned short pid, int month) noexcept
|
void WorldstateFunctions::SetMonth(unsigned short pid, int month) noexcept
|
||||||
|
@ -27,12 +32,14 @@ void WorldstateFunctions::SetMonth(unsigned short pid, int month) noexcept
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, );
|
GET_PLAYER(pid, player, );
|
||||||
|
|
||||||
player->hour = -1;
|
writeWorldstate.guid = player->guid;
|
||||||
player->month = month;
|
|
||||||
player->day = -1;
|
|
||||||
|
|
||||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_TIME)->setPlayer(player);
|
writeWorldstate.hour = -1;
|
||||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_TIME)->Send(false);
|
writeWorldstate.month = month;
|
||||||
|
writeWorldstate.day = -1;
|
||||||
|
|
||||||
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_GAME_TIME)->setWorldstate(&writeWorldstate);
|
||||||
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_GAME_TIME)->Send(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,10 +48,12 @@ void WorldstateFunctions::SetDay(unsigned short pid, int day) noexcept
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, );
|
GET_PLAYER(pid, player, );
|
||||||
|
|
||||||
player->hour = -1;
|
writeWorldstate.guid = player->guid;
|
||||||
player->month = -1;
|
|
||||||
player->day = day;
|
|
||||||
|
|
||||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_TIME)->setPlayer(player);
|
writeWorldstate.hour = -1;
|
||||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_TIME)->Send(false);
|
writeWorldstate.month = -1;
|
||||||
|
writeWorldstate.day = day;
|
||||||
|
|
||||||
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_GAME_TIME)->setWorldstate(&writeWorldstate);
|
||||||
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_GAME_TIME)->Send(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,14 +115,14 @@ add_openmw_dir (mwmp/processors/actor ProcessorActorAI ProcessorActorAnimFlags P
|
||||||
|
|
||||||
add_openmw_dir (mwmp/processors/player ProcessorChatMessage ProcessorGUIMessageBox ProcessorHandshake
|
add_openmw_dir (mwmp/processors/player ProcessorChatMessage ProcessorGUIMessageBox ProcessorHandshake
|
||||||
ProcessorUserDisconnected ProcessorUserMyID ProcessorCellCreate ProcessorRecordDynamic ProcessorGameSettings
|
ProcessorUserDisconnected ProcessorUserMyID ProcessorCellCreate ProcessorRecordDynamic ProcessorGameSettings
|
||||||
ProcessorGameTime ProcessorGameWeather ProcessorPlayerAnimFlags ProcessorPlayerAnimPlay ProcessorPlayerAttack
|
ProcessorGameWeather ProcessorPlayerAnimFlags ProcessorPlayerAnimPlay ProcessorPlayerAttack ProcessorPlayerAttribute
|
||||||
ProcessorPlayerAttribute ProcessorPlayerBaseInfo ProcessorPlayerBehavior ProcessorPlayerBook ProcessorPlayerBounty
|
ProcessorPlayerBaseInfo ProcessorPlayerBehavior ProcessorPlayerBook ProcessorPlayerBounty ProcessorPlayerCellChange
|
||||||
ProcessorPlayerCellChange ProcessorPlayerCellState ProcessorPlayerCharClass ProcessorPlayerCharGen ProcessorPlayerDeath
|
ProcessorPlayerCellState ProcessorPlayerCharClass ProcessorPlayerCharGen ProcessorPlayerDeath ProcessorPlayerDisposition
|
||||||
ProcessorPlayerDisposition ProcessorPlayerEquipment ProcessorPlayerFaction ProcessorPlayerInteraction
|
ProcessorPlayerEquipment ProcessorPlayerFaction ProcessorPlayerInteraction ProcessorPlayerInventory ProcessorPlayerJail
|
||||||
ProcessorPlayerInventory ProcessorPlayerJail ProcessorPlayerJournal ProcessorPlayerKillCount ProcessorPlayerLevel
|
ProcessorPlayerJournal ProcessorPlayerKillCount ProcessorPlayerLevel ProcessorPlayerMap ProcessorPlayerMiscellaneous
|
||||||
ProcessorPlayerMap ProcessorPlayerMiscellaneous ProcessorPlayerMomentum ProcessorPlayerPosition ProcessorPlayerQuickKeys
|
ProcessorPlayerMomentum ProcessorPlayerPosition ProcessorPlayerQuickKeys ProcessorPlayerReputation ProcessorPlayerResurrect
|
||||||
ProcessorPlayerReputation ProcessorPlayerResurrect ProcessorPlayerShapeshift ProcessorPlayerSkill ProcessorPlayerSpeech
|
ProcessorPlayerShapeshift ProcessorPlayerSkill ProcessorPlayerSpeech ProcessorPlayerSpellbook ProcessorPlayerStatsDynamic
|
||||||
ProcessorPlayerSpellbook ProcessorPlayerStatsDynamic ProcessorPlayerTopic
|
ProcessorPlayerTopic
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwmp/processors/object BaseObjectProcessor ProcessorConsoleCommand ProcessorContainer ProcessorDoorDestination
|
add_openmw_dir (mwmp/processors/object BaseObjectProcessor ProcessorConsoleCommand ProcessorContainer ProcessorDoorDestination
|
||||||
|
@ -133,6 +133,9 @@ add_openmw_dir (mwmp/processors/object BaseObjectProcessor ProcessorConsoleComma
|
||||||
ProcessorScriptMemberFloat ProcessorScriptGlobalShort ProcessorScriptGlobalFloat
|
ProcessorScriptMemberFloat ProcessorScriptGlobalShort ProcessorScriptGlobalFloat
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_openmw_dir (mwmp/processors/worldstate ProcessorGameTime
|
||||||
|
)
|
||||||
|
|
||||||
# Main executable
|
# Main executable
|
||||||
|
|
||||||
if (NOT ANDROID)
|
if (NOT ANDROID)
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#include "ObjectProcessor.hpp"
|
|
||||||
#include "../Main.hpp"
|
#include "../Main.hpp"
|
||||||
#include "../Networking.hpp"
|
#include "../Networking.hpp"
|
||||||
|
|
||||||
|
#include "ObjectProcessor.hpp"
|
||||||
|
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "player/ProcessorCellCreate.hpp"
|
#include "player/ProcessorCellCreate.hpp"
|
||||||
#include "player/ProcessorRecordDynamic.hpp"
|
#include "player/ProcessorRecordDynamic.hpp"
|
||||||
#include "player/ProcessorGameSettings.hpp"
|
#include "player/ProcessorGameSettings.hpp"
|
||||||
#include "player/ProcessorGameTime.hpp"
|
|
||||||
#include "player/ProcessorGameWeather.hpp"
|
#include "player/ProcessorGameWeather.hpp"
|
||||||
#include "player/ProcessorPlayerAnimFlags.hpp"
|
#include "player/ProcessorPlayerAnimFlags.hpp"
|
||||||
#include "player/ProcessorPlayerAnimPlay.hpp"
|
#include "player/ProcessorPlayerAnimPlay.hpp"
|
||||||
|
@ -92,6 +91,7 @@
|
||||||
#include "actor/ProcessorActorTest.hpp"
|
#include "actor/ProcessorActorTest.hpp"
|
||||||
|
|
||||||
#include "WorldstateProcessor.hpp"
|
#include "WorldstateProcessor.hpp"
|
||||||
|
#include "worldstate/ProcessorGameTime.hpp"
|
||||||
|
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
|
@ -104,7 +104,6 @@ void ProcessorInitializer()
|
||||||
PlayerProcessor::AddProcessor(new ProcessorCellCreate());
|
PlayerProcessor::AddProcessor(new ProcessorCellCreate());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorRecordDynamic());
|
PlayerProcessor::AddProcessor(new ProcessorRecordDynamic());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorGameSettings());
|
PlayerProcessor::AddProcessor(new ProcessorGameSettings());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorGameTime());
|
|
||||||
PlayerProcessor::AddProcessor(new ProcessorGameWeather());
|
PlayerProcessor::AddProcessor(new ProcessorGameWeather());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerAnimFlags());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerAnimFlags());
|
||||||
PlayerProcessor::AddProcessor(new ProcessorPlayerAnimPlay());
|
PlayerProcessor::AddProcessor(new ProcessorPlayerAnimPlay());
|
||||||
|
@ -184,4 +183,6 @@ void ProcessorInitializer()
|
||||||
ActorProcessor::AddProcessor(new ProcessorActorSpeech());
|
ActorProcessor::AddProcessor(new ProcessorActorSpeech());
|
||||||
ActorProcessor::AddProcessor(new ProcessorActorStatsDynamic());
|
ActorProcessor::AddProcessor(new ProcessorActorStatsDynamic());
|
||||||
ActorProcessor::AddProcessor(new ProcessorActorTest());
|
ActorProcessor::AddProcessor(new ProcessorActorTest());
|
||||||
|
|
||||||
|
WorldstateProcessor::AddProcessor(new ProcessorGameTime());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
//
|
|
||||||
// Created by koncord on 16.04.17.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef OPENMW_PROCESSORGAMETIME_HPP
|
#ifndef OPENMW_PROCESSORGAMETIME_HPP
|
||||||
#define OPENMW_PROCESSORGAMETIME_HPP
|
#define OPENMW_PROCESSORGAMETIME_HPP
|
||||||
|
|
||||||
|
|
||||||
#include <apps/openmw/mwbase/world.hpp>
|
#include <apps/openmw/mwbase/world.hpp>
|
||||||
#include <apps/openmw/mwbase/environment.hpp>
|
#include <apps/openmw/mwbase/environment.hpp>
|
||||||
#include "../PlayerProcessor.hpp"
|
#include "../WorldstateProcessor.hpp"
|
||||||
|
|
||||||
namespace mwmp
|
namespace mwmp
|
||||||
{
|
{
|
||||||
class ProcessorGameTime : public PlayerProcessor
|
class ProcessorGameTime : public WorldstateProcessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProcessorGameTime()
|
ProcessorGameTime()
|
||||||
|
@ -20,17 +16,17 @@ namespace mwmp
|
||||||
BPP_INIT(ID_GAME_TIME)
|
BPP_INIT(ID_GAME_TIME)
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
virtual void Do(WorldstatePacket &packet, BaseWorldstate &worldstate)
|
||||||
{
|
{
|
||||||
if (isLocal())
|
if (isLocal())
|
||||||
{
|
{
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
if (player->hour != -1)
|
if (worldstate.hour != -1)
|
||||||
world->setHour(player->hour);
|
world->setHour(worldstate.hour);
|
||||||
else if (player->day != -1)
|
else if (worldstate.day != -1)
|
||||||
world->setDay(player->day);
|
world->setDay(worldstate.day);
|
||||||
else if (player->month != -1)
|
else if (worldstate.month != -1)
|
||||||
world->setMonth(player->month);
|
world->setMonth(worldstate.month);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -174,7 +174,7 @@ add_component_dir (openmw-mp/Packets/Actor
|
||||||
|
|
||||||
add_component_dir (openmw-mp/Packets/Player
|
add_component_dir (openmw-mp/Packets/Player
|
||||||
PlayerPacket
|
PlayerPacket
|
||||||
PacketHandshake PacketChatMessage PacketGUIBoxes PacketGameSettings PacketGameTime PacketGameWeather
|
PacketHandshake PacketChatMessage PacketGUIBoxes PacketGameSettings PacketGameWeather
|
||||||
|
|
||||||
PacketCellCreate PacketRecordDynamic
|
PacketCellCreate PacketRecordDynamic
|
||||||
|
|
||||||
|
@ -198,6 +198,7 @@ add_component_dir (openmw-mp/Packets/Object
|
||||||
|
|
||||||
add_component_dir (openmw-mp/Packets/Worldstate
|
add_component_dir (openmw-mp/Packets/Worldstate
|
||||||
WorldstatePacket
|
WorldstatePacket
|
||||||
|
PacketGameTime
|
||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (fallback
|
add_component_dir (fallback
|
||||||
|
|
|
@ -246,9 +246,6 @@ namespace mwmp
|
||||||
|
|
||||||
RakNet::RakNetGUID guid;
|
RakNet::RakNetGUID guid;
|
||||||
GUIMessageBox guiMessageBox;
|
GUIMessageBox guiMessageBox;
|
||||||
int month;
|
|
||||||
int day;
|
|
||||||
double hour;
|
|
||||||
|
|
||||||
// Track only the indexes of the attributes that have been changed,
|
// Track only the indexes of the attributes that have been changed,
|
||||||
// with the attribute values themselves being stored in creatureStats.mAttributes
|
// with the attribute values themselves being stored in creatureStats.mAttributes
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef OPENMW_BASESTRUCTS_HPP
|
#ifndef OPENMW_BASESTRUCTS_HPP
|
||||||
#define OPENMW_BASESTRUCTS_HPP
|
#define OPENMW_BASESTRUCTS_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <components/esm/statstate.hpp>
|
#include <components/esm/statstate.hpp>
|
||||||
|
|
||||||
#include <RakNetTypes.h>
|
#include <RakNetTypes.h>
|
||||||
|
|
|
@ -19,6 +19,10 @@ namespace mwmp
|
||||||
|
|
||||||
RakNet::RakNetGUID guid;
|
RakNet::RakNetGUID guid;
|
||||||
|
|
||||||
|
int month;
|
||||||
|
int day;
|
||||||
|
double hour;
|
||||||
|
|
||||||
bool isValid;
|
bool isValid;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include "../Packets/Player/PacketCellCreate.hpp"
|
#include "../Packets/Player/PacketCellCreate.hpp"
|
||||||
#include "../Packets/Player/PacketRecordDynamic.hpp"
|
#include "../Packets/Player/PacketRecordDynamic.hpp"
|
||||||
#include "../Packets/Player/PacketGameSettings.hpp"
|
#include "../Packets/Player/PacketGameSettings.hpp"
|
||||||
#include "../Packets/Player/PacketGameTime.hpp"
|
|
||||||
#include "../Packets/Player/PacketGameWeather.hpp"
|
#include "../Packets/Player/PacketGameWeather.hpp"
|
||||||
#include "../Packets/Player/PacketPlayerActiveSkills.hpp"
|
#include "../Packets/Player/PacketPlayerActiveSkills.hpp"
|
||||||
#include "../Packets/Player/PacketPlayerAnimFlags.hpp"
|
#include "../Packets/Player/PacketPlayerAnimFlags.hpp"
|
||||||
|
@ -66,7 +65,6 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p
|
||||||
AddPacket<PacketCellCreate>(&packets, peer);
|
AddPacket<PacketCellCreate>(&packets, peer);
|
||||||
AddPacket<PacketRecordDynamic>(&packets, peer);
|
AddPacket<PacketRecordDynamic>(&packets, peer);
|
||||||
AddPacket<PacketGameSettings>(&packets, peer);
|
AddPacket<PacketGameSettings>(&packets, peer);
|
||||||
AddPacket<PacketGameTime>(&packets, peer);
|
|
||||||
AddPacket<PacketGameWeather>(&packets, peer);
|
AddPacket<PacketGameWeather>(&packets, peer);
|
||||||
AddPacket<PacketPlayerActiveSkills>(&packets, peer);
|
AddPacket<PacketPlayerActiveSkills>(&packets, peer);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include "../Packets/Worldstate/PacketGameTime.hpp"
|
||||||
|
|
||||||
#include "WorldstatePacketController.hpp"
|
#include "WorldstatePacketController.hpp"
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -10,7 +12,7 @@ inline void AddPacket(mwmp::WorldstatePacketController::packets_t *packets, RakN
|
||||||
|
|
||||||
mwmp::WorldstatePacketController::WorldstatePacketController(RakNet::RakPeerInterface *peer)
|
mwmp::WorldstatePacketController::WorldstatePacketController(RakNet::RakPeerInterface *peer)
|
||||||
{
|
{
|
||||||
|
AddPacket<PacketGameTime>(&packets, peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
//
|
|
||||||
// Created by koncord on 30.08.16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "PacketGameTime.hpp"
|
#include "PacketGameTime.hpp"
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
PacketGameTime::PacketGameTime(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
PacketGameTime::PacketGameTime(RakNet::RakPeerInterface *peer) : WorldstatePacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_GAME_TIME;
|
packetID = ID_GAME_TIME;
|
||||||
orderChannel = CHANNEL_SYSTEM;
|
orderChannel = CHANNEL_SYSTEM;
|
||||||
|
@ -15,9 +11,9 @@ PacketGameTime::PacketGameTime(RakNet::RakPeerInterface *peer) : PlayerPacket(pe
|
||||||
|
|
||||||
void PacketGameTime::Packet(RakNet::BitStream *bs, bool send)
|
void PacketGameTime::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
WorldstatePacket::Packet(bs, send);
|
||||||
|
|
||||||
RW(player->month, send);
|
RW(worldstate->month, send);
|
||||||
RW(player->day, send);
|
RW(worldstate->day, send);
|
||||||
RW(player->hour, send);
|
RW(worldstate->hour, send);
|
||||||
}
|
}
|
|
@ -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 : public PlayerPacket
|
class PacketGameTime : public WorldstatePacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PacketGameTime(RakNet::RakPeerInterface *peer);
|
PacketGameTime(RakNet::RakPeerInterface *peer);
|
Loading…
Reference in a new issue