From b4802e42018b938c5dfb0952de318310a9666365 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 26 Jul 2018 19:01:27 +0300 Subject: [PATCH] [General] Use Time struct for time in BaseWorldstate --- .../openmw-mp/Script/Functions/Worldstate.cpp | 12 +++++----- .../worldstate/ProcessorWorldTime.hpp | 24 +++++++++---------- components/openmw-mp/Base/BaseWorldstate.hpp | 19 ++++++--------- .../Packets/Worldstate/PacketWorldTime.cpp | 12 +++++----- 4 files changed, 31 insertions(+), 36 deletions(-) diff --git a/apps/openmw-mp/Script/Functions/Worldstate.cpp b/apps/openmw-mp/Script/Functions/Worldstate.cpp index 96d446c13..3fb9ffb21 100644 --- a/apps/openmw-mp/Script/Functions/Worldstate.cpp +++ b/apps/openmw-mp/Script/Functions/Worldstate.cpp @@ -106,32 +106,32 @@ void WorldstateFunctions::SetWeatherTransitionFactor(double transitionFactor) no void WorldstateFunctions::SetHour(double hour) noexcept { - writeWorldstate.hour = hour; + writeWorldstate.time.hour = hour; } void WorldstateFunctions::SetDay(int day) noexcept { - writeWorldstate.day = day; + writeWorldstate.time.day = day; } void WorldstateFunctions::SetMonth(int month) noexcept { - writeWorldstate.month = month; + writeWorldstate.time.month = month; } void WorldstateFunctions::SetYear(int year) noexcept { - writeWorldstate.year = year; + writeWorldstate.time.year = year; } void WorldstateFunctions::SetDaysPassed(int daysPassed) noexcept { - writeWorldstate.daysPassed = daysPassed; + writeWorldstate.time.daysPassed = daysPassed; } void WorldstateFunctions::SetTimeScale(double timeScale) noexcept { - writeWorldstate.timeScale = timeScale; + writeWorldstate.time.timeScale = timeScale; } void WorldstateFunctions::SetPlayerCollisionState(bool state) noexcept diff --git a/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp b/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp index d39a2aa81..5b2b056f6 100644 --- a/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp +++ b/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp @@ -20,23 +20,23 @@ namespace mwmp { MWBase::World *world = MWBase::Environment::get().getWorld(); - if (worldstate.hour != -1) - world->setHour(worldstate.hour); + if (worldstate.time.hour != -1) + world->setHour(worldstate.time.hour); - if (worldstate.day != -1) - world->setDay(worldstate.day); + if (worldstate.time.day != -1) + world->setDay(worldstate.time.day); - if (worldstate.month != -1) - world->setMonth(worldstate.month); + if (worldstate.time.month != -1) + world->setMonth(worldstate.time.month); - if (worldstate.year != -1) - world->setYear(worldstate.year); + if (worldstate.time.year != -1) + world->setYear(worldstate.time.year); - if (worldstate.daysPassed != -1) - world->setDaysPassed(worldstate.daysPassed); + if (worldstate.time.daysPassed != -1) + world->setDaysPassed(worldstate.time.daysPassed); - if (worldstate.timeScale != -1) - world->setTimeScale(worldstate.timeScale); + if (worldstate.time.timeScale != -1) + world->setTimeScale(worldstate.time.timeScale); } }; } diff --git a/components/openmw-mp/Base/BaseWorldstate.hpp b/components/openmw-mp/Base/BaseWorldstate.hpp index 53cd16c53..df021a4de 100644 --- a/components/openmw-mp/Base/BaseWorldstate.hpp +++ b/components/openmw-mp/Base/BaseWorldstate.hpp @@ -33,23 +33,18 @@ namespace mwmp BaseWorldstate() { - month = -1; - day = -1; - hour = -1; + time.year = -1; + time.month = -1; + time.day = -1; + time.hour = -1; - daysPassed = -1; - timeScale = -1; + time.daysPassed = -1; + time.timeScale = -1; } RakNet::RakNetGUID guid; - float hour; - int day; - int month; - int year; - - int daysPassed; - float timeScale; + mwmp::Time time; bool hasPlayerCollision; bool hasActorCollision; diff --git a/components/openmw-mp/Packets/Worldstate/PacketWorldTime.cpp b/components/openmw-mp/Packets/Worldstate/PacketWorldTime.cpp index 62f5ff2ee..6bf43da12 100644 --- a/components/openmw-mp/Packets/Worldstate/PacketWorldTime.cpp +++ b/components/openmw-mp/Packets/Worldstate/PacketWorldTime.cpp @@ -13,11 +13,11 @@ void PacketWorldTime::Packet(RakNet::BitStream *bs, bool send) { WorldstatePacket::Packet(bs, send); - RW(worldstate->hour, send); - RW(worldstate->day, send); - RW(worldstate->month, send); - RW(worldstate->year, send); + RW(worldstate->time.hour, send); + RW(worldstate->time.day, send); + RW(worldstate->time.month, send); + RW(worldstate->time.year, send); - RW(worldstate->daysPassed, send); - RW(worldstate->timeScale, send); + RW(worldstate->time.daysPassed, send); + RW(worldstate->time.timeScale, send); }