From fd721143e226061d72f7b8931b8d4192a5327f47 Mon Sep 17 00:00:00 2001 From: Koncord Date: Sun, 10 Dec 2017 09:56:55 +0800 Subject: [PATCH] [Client] Implement weather packet --- .../player/ProcessorGameWeather.hpp | 26 ++++++++++++++++++- apps/openmw/mwworld/weather.hpp | 6 +++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmp/processors/player/ProcessorGameWeather.hpp b/apps/openmw/mwmp/processors/player/ProcessorGameWeather.hpp index 6865e3ae4..a2d9634f5 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorGameWeather.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorGameWeather.hpp @@ -1,7 +1,11 @@ #ifndef OPENMW_PROCESSORGAMEWEATHER_HPP #define OPENMW_PROCESSORGAMEWEATHER_HPP +#include +#include #include "../PlayerProcessor.hpp" +#include +#include namespace mwmp { @@ -15,7 +19,27 @@ namespace mwmp void Do(PlayerPacket &packet, BasePlayer *player) final { - // Placeholder to be filled in later + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received %s", strPacketID); + MWWorld::WeatherManager *weatherManager = Main::get().getWeatherManager(); + auto &weather = player->weather; + if(isRequest()) + { + LOG_APPEND(Log::LOG_TRACE, "- requested data"); + weather.currentWeather = weatherManager->mCurrentWeather; + weather.nextWeather = weatherManager->mNextWeather; + weather.transitionFactor = weatherManager->mTransitionFactor; + weather.updateTime = weatherManager->mWeatherUpdateTime; + packet.setPlayer(player); + packet.Send(); + } + else + { + LOG_APPEND(Log::LOG_TRACE, "- received data"); + weatherManager->mCurrentWeather = weather.currentWeather; + weatherManager->mNextWeather = weather.nextWeather; + weatherManager->mTransitionFactor = weather.transitionFactor; + weatherManager->mWeatherUpdateTime = weather.updateTime; + } } }; } diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index 84a6c5105..5ca60c4cc 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -34,6 +34,11 @@ namespace Fallback class Map; } +namespace mwmp +{ + class ProcessorGameWeather; +} + namespace MWWorld { class TimeStamp; @@ -204,6 +209,7 @@ namespace MWWorld /// Interface for weather settings class WeatherManager { + friend class mwmp::ProcessorGameWeather; public: // Have to pass fallback and Store, can't use singleton since World isn't fully constructed yet at the time WeatherManager(MWRender::RenderingManager& rendering,