diff options
author | Mattes D <github@xoft.cz> | 2013-10-30 23:25:51 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2013-10-30 23:25:51 +0100 |
commit | 8b9d3c77228b139d5b5a146e0f1aa242e3066903 (patch) | |
tree | 6733363192eb368c335e9aa18fd0df2ab4a266b7 /source/World.cpp | |
parent | Added 1.7 to protocol recognizer. (diff) | |
parent | Last of the nitpicker note fixes. Added some inline commenting. (diff) | |
download | cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.tar cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.tar.gz cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.tar.bz2 cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.tar.lz cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.tar.xz cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.tar.zst cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.zip |
Diffstat (limited to '')
-rw-r--r-- | source/World.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/source/World.cpp b/source/World.cpp index 786d97a4d..ad34dc6a5 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -229,7 +229,8 @@ cWorld::cWorld(const AString & a_WorldName) : m_RSList(0), m_Weather(eWeather_Sunny), m_WeatherInterval(24000), // Guaranteed 1 day of sunshine at server start :) - m_TickThread(*this) + m_TickThread(*this), + m_SkyDarkness(0) { LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str()); @@ -608,6 +609,9 @@ void cWorld::Tick(float a_Dt) m_WorldAge = (Int64)(m_WorldAgeSecs * 20.0); m_TimeOfDay = (Int64)(m_TimeOfDaySecs * 20.0); + // Updates the sky darkness based on current time of day + UpdateSkyDarkness(); + // Broadcast time update every 40 ticks (2 seconds) if (m_LastTimeUpdate < m_WorldAge - 40) { @@ -2676,3 +2680,30 @@ void cWorld::cTaskSaveAllChunks::Run(cWorld & a_World) + +#define TIME_SUNSET 12000 +#define TIME_NIGHT_START 13187 +#define TIME_NIGHT_END 22812 +#define TIME_SUNRISE 23999 +#define TIME_SPAWN_DIVIZOR 148 + + + + + +void cWorld::UpdateSkyDarkness() +{ + int TempTime = m_TimeOfDay; + if (TempTime <= TIME_SUNSET) + m_SkyDarkness = 0; + else if (TempTime <= TIME_NIGHT_START) + m_SkyDarkness = (TIME_NIGHT_START - TempTime)/TIME_SPAWN_DIVIZOR; + else if (TempTime <= TIME_NIGHT_END) + m_SkyDarkness = 8; + else + m_SkyDarkness = (TIME_SUNRISE - TempTime)/TIME_SPAWN_DIVIZOR; +} + + + + |