mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
[General] Make it possible to change world's time scale via WorldTime
This commit is contained in:
parent
f01c761cb1
commit
8d36d0d945
8 changed files with 76 additions and 11 deletions
|
@ -20,8 +20,25 @@ void WorldstateFunctions::SetHour(unsigned short pid, double hour) noexcept
|
|||
writeWorldstate.guid = player->guid;
|
||||
|
||||
writeWorldstate.hour = hour;
|
||||
writeWorldstate.month = -1;
|
||||
writeWorldstate.day = -1;
|
||||
writeWorldstate.month = -1;
|
||||
writeWorldstate.timeScale = -1;
|
||||
|
||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->setWorldstate(&writeWorldstate);
|
||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->Send(false);
|
||||
}
|
||||
|
||||
void WorldstateFunctions::SetDay(unsigned short pid, int day) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
writeWorldstate.guid = player->guid;
|
||||
|
||||
writeWorldstate.hour = -1;
|
||||
writeWorldstate.day = day;
|
||||
writeWorldstate.month = -1;
|
||||
writeWorldstate.timeScale = -1;
|
||||
|
||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->setWorldstate(&writeWorldstate);
|
||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->Send(false);
|
||||
|
@ -35,15 +52,15 @@ void WorldstateFunctions::SetMonth(unsigned short pid, int month) noexcept
|
|||
writeWorldstate.guid = player->guid;
|
||||
|
||||
writeWorldstate.hour = -1;
|
||||
writeWorldstate.month = month;
|
||||
writeWorldstate.day = -1;
|
||||
writeWorldstate.month = month;
|
||||
writeWorldstate.timeScale = -1;
|
||||
|
||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->setWorldstate(&writeWorldstate);
|
||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->Send(false);
|
||||
|
||||
}
|
||||
|
||||
void WorldstateFunctions::SetDay(unsigned short pid, int day) noexcept
|
||||
void WorldstateFunctions::SetTimeScale(unsigned short pid, double timeScale) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
@ -51,8 +68,9 @@ void WorldstateFunctions::SetDay(unsigned short pid, int day) noexcept
|
|||
writeWorldstate.guid = player->guid;
|
||||
|
||||
writeWorldstate.hour = -1;
|
||||
writeWorldstate.day = -1;
|
||||
writeWorldstate.month = -1;
|
||||
writeWorldstate.day = day;
|
||||
writeWorldstate.timeScale = timeScale;
|
||||
|
||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->setWorldstate(&writeWorldstate);
|
||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->Send(false);
|
||||
|
|
|
@ -5,15 +5,16 @@
|
|||
|
||||
#define WORLDSTATEAPI \
|
||||
{"SetHour", WorldstateFunctions::SetHour},\
|
||||
{"SetDay", WorldstateFunctions::SetDay},\
|
||||
{"SetMonth", WorldstateFunctions::SetMonth},\
|
||||
{"SetDay", WorldstateFunctions::SetDay}
|
||||
{"SetTimeScale", WorldstateFunctions::SetTimeScale}
|
||||
|
||||
class WorldstateFunctions
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Set the game hour for a player and send a WorldTime packet to that player.
|
||||
* \brief Set the world's hour for a player and send a WorldTime packet to that player.
|
||||
*
|
||||
* \param pid The player ID.
|
||||
* \param hour The hour.
|
||||
|
@ -22,7 +23,16 @@ public:
|
|||
static void SetHour(unsigned short pid, double hour) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Set the game month for a player and send a WorldTime packet to that player.
|
||||
* \brief Set the world's day of the month for a player and send a WorldTime packet to that player.
|
||||
*
|
||||
* \param pid The player ID.
|
||||
* \param day The day.
|
||||
* \return void
|
||||
*/
|
||||
static void SetDay(unsigned short pid, int day) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Set the world's month for a player and send a WorldTime packet to that player.
|
||||
*
|
||||
* \param pid The player ID.
|
||||
* \param month The month.
|
||||
|
@ -31,13 +41,13 @@ public:
|
|||
static void SetMonth(unsigned short pid, int month) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Set the game day for a player and send a WorldTime packet to that player.
|
||||
* \brief Set the world's time scale for a player and send a WorldTime packet to that player.
|
||||
*
|
||||
* \param pid The player ID.
|
||||
* \param day The day.
|
||||
* \param timeScale The time scale.
|
||||
* \return void
|
||||
*/
|
||||
static void SetDay(unsigned short pid, int day) noexcept;
|
||||
static void SetTimeScale(unsigned short pid, double timeScale) noexcept;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -194,6 +194,16 @@ namespace MWBase
|
|||
virtual void advanceTime (double hours, bool incremental = false) = 0;
|
||||
///< Advance in-game time.
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to set a custom timescale from a server
|
||||
*/
|
||||
virtual void setTimeScale(float timeScale) = 0;
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
virtual void setHour (double hour) = 0;
|
||||
///< Set in-game time hour.
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ namespace mwmp
|
|||
world->setDay(worldstate.day);
|
||||
else if (worldstate.month != -1)
|
||||
world->setMonth(worldstate.month);
|
||||
else if (worldstate.timeScale != -1)
|
||||
world->setTimeScale(worldstate.timeScale);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -865,6 +865,19 @@ namespace MWWorld
|
|||
days + mDaysPassed->getInteger());
|
||||
}
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to set a custom timescale from a server
|
||||
*/
|
||||
void World::setTimeScale(float timeScale)
|
||||
{
|
||||
mTimeScale->setFloat(timeScale);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
void World::setHour (double hour)
|
||||
{
|
||||
if (hour<0)
|
||||
|
|
|
@ -306,6 +306,16 @@ namespace MWWorld
|
|||
void advanceTime (double hours, bool incremental = false) override;
|
||||
///< Advance in-game time.
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to set a custom timescale from a server
|
||||
*/
|
||||
void setTimeScale(float timeScale) override;
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
void setHour (double hour) override;
|
||||
///< Set in-game time hour.
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace mwmp
|
|||
int month;
|
||||
int day;
|
||||
double hour;
|
||||
float timeScale;
|
||||
|
||||
bool isValid;
|
||||
};
|
||||
|
|
|
@ -16,4 +16,5 @@ void PacketWorldTime::Packet(RakNet::BitStream *bs, bool send)
|
|||
RW(worldstate->month, send);
|
||||
RW(worldstate->day, send);
|
||||
RW(worldstate->hour, send);
|
||||
RW(worldstate->timeScale, send);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue