diff options
author | Samuel Barney <samjbarney@gmail.com> | 2013-10-29 17:44:51 +0100 |
---|---|---|
committer | Samuel Barney <samjbarney@gmail.com> | 2013-10-29 17:44:51 +0100 |
commit | e1a06153b2e93473af58e1d801998ff7f388dc6d (patch) | |
tree | 080e0f9744333fe7936bcda1da47757dfa9fb10f /source/World.cpp | |
parent | Merge branch 'master' of https://github.com/SamJBarney/MCServer into MobSpawning (diff) | |
download | cuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.tar cuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.tar.gz cuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.tar.bz2 cuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.tar.lz cuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.tar.xz cuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.tar.zst cuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.zip |
Diffstat (limited to '')
-rw-r--r-- | source/World.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/source/World.cpp b/source/World.cpp index 786d97a4d..dcd51afcf 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,8 @@ void cWorld::Tick(float a_Dt) m_WorldAge = (Int64)(m_WorldAgeSecs * 20.0); m_TimeOfDay = (Int64)(m_TimeOfDaySecs * 20.0); + UpdateSkyDarkness(); + // Broadcast time update every 40 ticks (2 seconds) if (m_LastTimeUpdate < m_WorldAge - 40) { @@ -2676,3 +2679,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; +} + + + + |