From e1a06153b2e93473af58e1d801998ff7f388dc6d Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Tue, 29 Oct 2013 10:44:51 -0600 Subject: Update to allow the light map to remain the same, but allow alteration of sky light values based on time. --- source/World.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'source/World.cpp') 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; +} + + + + -- cgit v1.2.3