diff --git a/apps/openmw-mp/Script/Functions/Worldstate.cpp b/apps/openmw-mp/Script/Functions/Worldstate.cpp index b59ac9d32..e395ac91c 100644 --- a/apps/openmw-mp/Script/Functions/Worldstate.cpp +++ b/apps/openmw-mp/Script/Functions/Worldstate.cpp @@ -27,6 +27,11 @@ void WorldstateFunctions::SetMonth(int month) noexcept writeWorldstate.month = month; } +void WorldstateFunctions::SetDaysPassed(int daysPassed) noexcept +{ + writeWorldstate.daysPassed = daysPassed; +} + void WorldstateFunctions::SetTimeScale(double timeScale) noexcept { writeWorldstate.timeScale = timeScale; diff --git a/apps/openmw-mp/Script/Functions/Worldstate.hpp b/apps/openmw-mp/Script/Functions/Worldstate.hpp index c3b2de7bf..56c2baf15 100644 --- a/apps/openmw-mp/Script/Functions/Worldstate.hpp +++ b/apps/openmw-mp/Script/Functions/Worldstate.hpp @@ -7,6 +7,7 @@ {"SetHour", WorldstateFunctions::SetHour},\ {"SetDay", WorldstateFunctions::SetDay},\ {"SetMonth", WorldstateFunctions::SetMonth},\ + {"SetDaysPassed", WorldstateFunctions::SetDaysPassed},\ {"SetTimeScale", WorldstateFunctions::SetTimeScale},\ \ {"SendWorldTime", WorldstateFunctions::SendWorldTime} @@ -18,7 +19,6 @@ public: /** * \brief Set the world's hour in the worldstate stored on the server. * - * \param pid The player ID. * \param hour The hour. * \return void */ @@ -27,7 +27,6 @@ public: /** * \brief Set the world's day in the worldstate stored on the server. * - * \param pid The player ID. * \param day The day. * \return void */ @@ -36,12 +35,19 @@ public: /** * \brief Set the world's month in the worldstate stored on the server. * - * \param pid The player ID. * \param month The month. * \return void */ static void SetMonth(int month) noexcept; + /** + * \brief Set the world's days passed in the worldstate stored on the server. + * + * \param daysPassed The days passed. + * \return void + */ + static void SetDaysPassed(int daysPassed) noexcept; + /** * \brief Set the world's time scale in the worldstate stored on the server. * diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index acd81b0c0..b09f2425b 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -200,13 +200,23 @@ namespace MWBase /* Start of tes3mp addition - Make it possible to set a custom timescale from a server + Make it possible to set a custom timeScale from elsewhere */ virtual void setTimeScale(float timeScale) = 0; /* End of tes3mp addition */ + /* + Start of tes3mp addition + + Make it possible to set the number of days passed from elsewhere + */ + virtual void setDaysPassed(int daysPassed) = 0; + /* + End of tes3mp addition + */ + virtual void setHour (double hour) = 0; ///< Set in-game time hour. diff --git a/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp b/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp index 8061f0edb..acff155c7 100644 --- a/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp +++ b/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp @@ -29,7 +29,10 @@ namespace mwmp if (worldstate.month != -1) world->setMonth(worldstate.month); - + + if (worldstate.daysPassed != -1) + world->setDaysPassed(worldstate.daysPassed); + if (worldstate.timeScale != -1) world->setTimeScale(worldstate.timeScale); } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 96052952a..c2a2a1230 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -868,7 +868,7 @@ namespace MWWorld /* Start of tes3mp addition - Make it possible to set a custom timescale from a server + Make it possible to set a custom timeScale from elsewhere */ void World::setTimeScale(float timeScale) { @@ -878,6 +878,19 @@ namespace MWWorld End of tes3mp addition */ + /* + Start of tes3mp addition + + Make it possible to set the number of days passed from elsewhere + */ + void World::setDaysPassed(int days) + { + mDaysPassed->setInteger(days); + } + /* + End of tes3mp addition + */ + void World::setHour (double hour) { if (hour<0) diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 44016fa05..484d92041 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -309,13 +309,23 @@ namespace MWWorld /* Start of tes3mp addition - Make it possible to set a custom timescale from a server + Make it possible to set a custom timeScale from elsewhere */ void setTimeScale(float timeScale) override; /* End of tes3mp addition */ + /* + Start of tes3mp addition + + Make it possible to set the number of days passed from elsewhere + */ + void setDaysPassed(int daysPassed) override; + /* + End of tes3mp addition + */ + void setHour (double hour) override; ///< Set in-game time hour. diff --git a/components/openmw-mp/Base/BaseWorldstate.hpp b/components/openmw-mp/Base/BaseWorldstate.hpp index 3c6174c76..990435f80 100644 --- a/components/openmw-mp/Base/BaseWorldstate.hpp +++ b/components/openmw-mp/Base/BaseWorldstate.hpp @@ -17,6 +17,8 @@ namespace mwmp month = -1; day = -1; hour = -1; + + daysPassed = -1; timeScale = -1; } @@ -25,6 +27,8 @@ namespace mwmp int month; int day; double hour; + + int daysPassed; float timeScale; bool isValid; diff --git a/components/openmw-mp/Packets/Worldstate/PacketWorldTime.cpp b/components/openmw-mp/Packets/Worldstate/PacketWorldTime.cpp index ea20e6f0e..fd13014ed 100644 --- a/components/openmw-mp/Packets/Worldstate/PacketWorldTime.cpp +++ b/components/openmw-mp/Packets/Worldstate/PacketWorldTime.cpp @@ -16,5 +16,7 @@ void PacketWorldTime::Packet(RakNet::BitStream *bs, bool send) RW(worldstate->month, send); RW(worldstate->day, send); RW(worldstate->hour, send); + + RW(worldstate->daysPassed, send); RW(worldstate->timeScale, send); }