]> git.lizzy.rs Git - minetest.git/blobdiff - src/environment.cpp
fix screen flickering black when rendering to texture
[minetest.git] / src / environment.cpp
index b8e0373766a12f541d20b4742a55efa363d3f6fc..5bf127a174c658a7c15d4a94705046b08987ae19 100644 (file)
@@ -203,7 +203,8 @@ void Environment::printPlayers(std::ostream &o)
 
 u32 Environment::getDayNightRatio()
 {
-       return time_to_daynight_ratio(m_time_of_day);
+       bool smooth = (g_settings->getS32("enable_shaders") != 0);
+       return time_to_daynight_ratio(m_time_of_day_f*24000, smooth);
 }
 
 void Environment::stepTimeOfDay(float dtime)
@@ -329,7 +330,8 @@ ServerEnvironment::ServerEnvironment(ServerMap *map, lua_State *L,
        m_send_recommended_timer(0),
        m_active_block_interval_overload_skip(0),
        m_game_time(0),
-       m_game_time_fraction_counter(0)
+       m_game_time_fraction_counter(0),
+       m_recommended_send_interval(0.1)
 {
 }
 
@@ -940,6 +942,11 @@ void ServerEnvironment::step(float dtime)
        /* Step time of day */
        stepTimeOfDay(dtime);
 
+       // Update this one
+       // NOTE: This is kind of funny on a singleplayer game, but doesn't
+       // really matter that much.
+       m_recommended_send_interval = g_settings->getFloat("dedicated_server_step");
+
        /*
                Increment game time
        */
@@ -2126,15 +2133,15 @@ void ClientEnvironment::step(float dtime)
                }
                
                // Update lighting on all players on client
-               u8 light = LIGHT_MAX;
+               float light = 1.0;
                try{
                        // Get node at head
                        v3s16 p = player->getLightPosition();
                        MapNode n = m_map->getNode(p);
-                       light = n.getLightBlend(getDayNightRatio(), m_gamedef->ndef());
+                       light = n.getLightBlendF1((float)getDayNightRatio()/1000, m_gamedef->ndef());
                }
                catch(InvalidPositionException &e){
-                       light = blend_light(getDayNightRatio(), LIGHT_SUN, 0);
+                       light = blend_light_f1((float)getDayNightRatio()/1000, LIGHT_SUN, 0);
                }
                player->light = light;
        }