mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-02 22:19:41 +00:00
[General] Make it possible to set year via WorldTime
This commit is contained in:
parent
4acf93b7db
commit
3b5fb9cd6b
8 changed files with 102 additions and 48 deletions
|
@ -27,6 +27,11 @@ void WorldstateFunctions::SetMonth(int month) noexcept
|
||||||
writeWorldstate.month = month;
|
writeWorldstate.month = month;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorldstateFunctions::SetYear(int year) noexcept
|
||||||
|
{
|
||||||
|
writeWorldstate.year = year;
|
||||||
|
}
|
||||||
|
|
||||||
void WorldstateFunctions::SetDaysPassed(int daysPassed) noexcept
|
void WorldstateFunctions::SetDaysPassed(int daysPassed) noexcept
|
||||||
{
|
{
|
||||||
writeWorldstate.daysPassed = daysPassed;
|
writeWorldstate.daysPassed = daysPassed;
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
{"SetHour", WorldstateFunctions::SetHour},\
|
{"SetHour", WorldstateFunctions::SetHour},\
|
||||||
{"SetDay", WorldstateFunctions::SetDay},\
|
{"SetDay", WorldstateFunctions::SetDay},\
|
||||||
{"SetMonth", WorldstateFunctions::SetMonth},\
|
{"SetMonth", WorldstateFunctions::SetMonth},\
|
||||||
|
{"SetYear", WorldstateFunctions::SetYear},\
|
||||||
|
\
|
||||||
{"SetDaysPassed", WorldstateFunctions::SetDaysPassed},\
|
{"SetDaysPassed", WorldstateFunctions::SetDaysPassed},\
|
||||||
{"SetTimeScale", WorldstateFunctions::SetTimeScale},\
|
{"SetTimeScale", WorldstateFunctions::SetTimeScale},\
|
||||||
\
|
\
|
||||||
|
@ -40,6 +42,14 @@ public:
|
||||||
*/
|
*/
|
||||||
static void SetMonth(int month) noexcept;
|
static void SetMonth(int month) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the world's year in the worldstate stored on the server.
|
||||||
|
*
|
||||||
|
* \param year The year.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void SetYear(int year) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the world's days passed in the worldstate stored on the server.
|
* \brief Set the world's days passed in the worldstate stored on the server.
|
||||||
*
|
*
|
||||||
|
|
|
@ -197,12 +197,21 @@ namespace MWBase
|
||||||
virtual void advanceTime (double hours, bool incremental = false) = 0;
|
virtual void advanceTime (double hours, bool incremental = false) = 0;
|
||||||
///< Advance in-game time.
|
///< Advance in-game time.
|
||||||
|
|
||||||
|
virtual void setHour (double hour) = 0;
|
||||||
|
///< Set in-game time hour.
|
||||||
|
|
||||||
|
virtual void setMonth (int month) = 0;
|
||||||
|
///< Set in-game time month.
|
||||||
|
|
||||||
|
virtual void setDay (int day) = 0;
|
||||||
|
///< Set in-game time day.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Start of tes3mp addition
|
Start of tes3mp addition
|
||||||
|
|
||||||
Make it possible to set a custom timeScale from elsewhere
|
Make it possible to set the year from elsewhere
|
||||||
*/
|
*/
|
||||||
virtual void setTimeScale(float timeScale) = 0;
|
virtual void setYear(int year) = 0;
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
@ -217,14 +226,15 @@ namespace MWBase
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual void setHour (double hour) = 0;
|
/*
|
||||||
///< Set in-game time hour.
|
Start of tes3mp addition
|
||||||
|
|
||||||
virtual void setMonth (int month) = 0;
|
Make it possible to set a custom timeScale from elsewhere
|
||||||
///< Set in-game time month.
|
*/
|
||||||
|
virtual void setTimeScale(float timeScale) = 0;
|
||||||
virtual void setDay (int day) = 0;
|
/*
|
||||||
///< Set in-game time day.
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
virtual int getDay() const = 0;
|
virtual int getDay() const = 0;
|
||||||
virtual int getMonth() const = 0;
|
virtual int getMonth() const = 0;
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace mwmp
|
||||||
if (isLocal())
|
if (isLocal())
|
||||||
{
|
{
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
if (worldstate.hour != -1)
|
if (worldstate.hour != -1)
|
||||||
world->setHour(worldstate.hour);
|
world->setHour(worldstate.hour);
|
||||||
|
|
||||||
|
@ -30,6 +31,9 @@ namespace mwmp
|
||||||
if (worldstate.month != -1)
|
if (worldstate.month != -1)
|
||||||
world->setMonth(worldstate.month);
|
world->setMonth(worldstate.month);
|
||||||
|
|
||||||
|
if (worldstate.year != -1)
|
||||||
|
world->setYear(worldstate.year);
|
||||||
|
|
||||||
if (worldstate.daysPassed != -1)
|
if (worldstate.daysPassed != -1)
|
||||||
world->setDaysPassed(worldstate.daysPassed);
|
world->setDaysPassed(worldstate.daysPassed);
|
||||||
|
|
||||||
|
|
|
@ -865,32 +865,6 @@ namespace MWWorld
|
||||||
days + mDaysPassed->getInteger());
|
days + mDaysPassed->getInteger());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Start of tes3mp addition
|
|
||||||
|
|
||||||
Make it possible to set a custom timeScale from elsewhere
|
|
||||||
*/
|
|
||||||
void World::setTimeScale(float timeScale)
|
|
||||||
{
|
|
||||||
mTimeScale->setFloat(timeScale);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
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)
|
void World::setHour (double hour)
|
||||||
{
|
{
|
||||||
if (hour<0)
|
if (hour<0)
|
||||||
|
@ -959,6 +933,45 @@ namespace MWWorld
|
||||||
mRendering->skySetDate (mDay->getInteger(), month);
|
mRendering->skySetDate (mDay->getInteger(), month);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Make it possible to set the year from elsewhere
|
||||||
|
*/
|
||||||
|
void World::setYear(int year)
|
||||||
|
{
|
||||||
|
mYear->setInteger(year);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Make it possible to set a custom timeScale from elsewhere
|
||||||
|
*/
|
||||||
|
void World::setTimeScale(float timeScale)
|
||||||
|
{
|
||||||
|
mTimeScale->setFloat(timeScale);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
int World::getDay() const
|
int World::getDay() const
|
||||||
{
|
{
|
||||||
return mDay->getInteger();
|
return mDay->getInteger();
|
||||||
|
|
|
@ -306,12 +306,21 @@ namespace MWWorld
|
||||||
void advanceTime (double hours, bool incremental = false) override;
|
void advanceTime (double hours, bool incremental = false) override;
|
||||||
///< Advance in-game time.
|
///< Advance in-game time.
|
||||||
|
|
||||||
|
void setHour (double hour) override;
|
||||||
|
///< Set in-game time hour.
|
||||||
|
|
||||||
|
void setMonth (int month) override;
|
||||||
|
///< Set in-game time month.
|
||||||
|
|
||||||
|
void setDay (int day) override;
|
||||||
|
///< Set in-game time day.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Start of tes3mp addition
|
Start of tes3mp addition
|
||||||
|
|
||||||
Make it possible to set a custom timeScale from elsewhere
|
Make it possible to set the year from elsewhere
|
||||||
*/
|
*/
|
||||||
void setTimeScale(float timeScale) override;
|
void setYear(int year) override;
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
@ -326,14 +335,15 @@ namespace MWWorld
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void setHour (double hour) override;
|
/*
|
||||||
///< Set in-game time hour.
|
Start of tes3mp addition
|
||||||
|
|
||||||
void setMonth (int month) override;
|
Make it possible to set a custom timeScale from elsewhere
|
||||||
///< Set in-game time month.
|
*/
|
||||||
|
void setTimeScale(float timeScale) override;
|
||||||
void setDay (int day) override;
|
/*
|
||||||
///< Set in-game time day.
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
int getDay() const override;
|
int getDay() const override;
|
||||||
int getMonth() const override;
|
int getMonth() const override;
|
||||||
|
|
|
@ -24,9 +24,10 @@ namespace mwmp
|
||||||
|
|
||||||
RakNet::RakNetGUID guid;
|
RakNet::RakNetGUID guid;
|
||||||
|
|
||||||
int month;
|
|
||||||
int day;
|
|
||||||
double hour;
|
double hour;
|
||||||
|
int day;
|
||||||
|
int month;
|
||||||
|
int year;
|
||||||
|
|
||||||
int daysPassed;
|
int daysPassed;
|
||||||
float timeScale;
|
float timeScale;
|
||||||
|
|
|
@ -13,9 +13,10 @@ void PacketWorldTime::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
WorldstatePacket::Packet(bs, send);
|
WorldstatePacket::Packet(bs, send);
|
||||||
|
|
||||||
RW(worldstate->month, send);
|
|
||||||
RW(worldstate->day, send);
|
|
||||||
RW(worldstate->hour, send);
|
RW(worldstate->hour, send);
|
||||||
|
RW(worldstate->day, send);
|
||||||
|
RW(worldstate->month, send);
|
||||||
|
RW(worldstate->year, send);
|
||||||
|
|
||||||
RW(worldstate->daysPassed, send);
|
RW(worldstate->daysPassed, send);
|
||||||
RW(worldstate->timeScale, send);
|
RW(worldstate->timeScale, send);
|
||||||
|
|
Loading…
Reference in a new issue