A bit longer day and a bit shorter night. Client-side.
authorPerttu Ahola <celeron55@gmail.com>
Wed, 29 Dec 2010 13:26:47 +0000 (15:26 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Wed, 29 Dec 2010 13:26:47 +0000 (15:26 +0200)
src/client.cpp
src/main.cpp
src/map.cpp
src/server.cpp

index 4792490f9fd67816782735396d1e27dba3951fcb..b7a076c5054b9061d4ebd39b08947fc6d24e88ba 100644 (file)
@@ -139,37 +139,6 @@ void Client::step(float dtime)
        if(dtime > 2.0)
                dtime = 2.0;
        
-       /*
-               Day/night
-       */
-       {
-               s32 d = 8;
-               s32 t = (((m_time_of_day.get() + 24000/d/2)%24000)/(24000/d));
-               s32 dn = 0;
-               if(t == d/4 || t == (d-d/4))
-                       dn = 1;
-               else if(t < d/4 || t > (d-d/4))
-                       dn = 2;
-               else
-                       dn = 0;
-
-               u32 dr = 1000;
-               if(dn == 0)
-                       dr = 1000;
-               if(dn == 1)
-                       dr = 600;
-               if(dn == 2)
-                       dr = 300;
-               
-               if(dr != m_env.getDayNightRatio())
-               {
-                       //dstream<<"dr="<<dr<<std::endl;
-                       dout_client<<DTIME<<"Client: changing day-night ratio"<<std::endl;
-                       m_env.setDayNightRatio(dr);
-                       m_env.expireMeshes(true);
-               }
-       }
-
        
        //dstream<<"Client steps "<<dtime<<std::endl;
 
@@ -1003,6 +972,42 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                time = time % 24000;
                m_time_of_day.set(time);
                //dstream<<"Client: time="<<time<<std::endl;
+               
+               /*
+                       Day/night
+
+                       time_of_day:
+                       0 = midnight
+                       12000 = midday
+               */
+               {
+                       const s32 daylength = 8;
+                       const s32 nightlength = 2;
+                       const s32 daytimelength = 4;
+                       s32 d = daylength;
+                       s32 t = (((m_time_of_day.get()/* + 24000/d/2*/)%24000)/(24000/d));
+                       u32 dr;
+                       if(t < nightlength/2 || t >= d - nightlength/2)
+                               dr = 350;
+                       else if(t >= d/2 - daytimelength/2 && t < d/2 + daytimelength/2)
+                               dr = 1000;
+                       else
+                               dr = 750;
+
+                       dstream<<"time_of_day="<<m_time_of_day.get()
+                                       <<", t="<<t
+                                       <<", dr="<<dr
+                                       <<std::endl;
+                       
+                       if(dr != m_env.getDayNightRatio())
+                       {
+                               //dstream<<"dr="<<dr<<std::endl;
+                               dout_client<<DTIME<<"Client: changing day-night ratio"<<std::endl;
+                               m_env.setDayNightRatio(dr);
+                               m_env.expireMeshes(true);
+                       }
+               }
+
        }
        else if(command == TOCLIENT_CHAT_MESSAGE)
        {
index f9022de648f5b608d952e6ec79a30adf8a22915e..a5b9ba0d55ffb06c74e936e8352de1945b998199 100644 (file)
@@ -181,7 +181,9 @@ TODO: There has to be some better way to handle static objects than to
 TODO: When server sees that client is removing an inexistent block or\r
       adding a block to an existent position, resend the MapBlock.\r
 \r
-TODO: Map generator: add other materials underground (mud)\r
+TODO: When player dies, throw items on map\r
+\r
+TODO: Map generator version 2\r
 \r
 Doing now:\r
 ======================================================================\r
@@ -2275,11 +2277,18 @@ int main(int argc, char *argv[])
                camera->setAspectRatio((f32)screensize.X / (f32)screensize.Y);\r
                \r
                u32 daynight_ratio = client.getDayNightRatio();\r
-               video::SColor bgcolor = video::SColor(\r
+               /*video::SColor bgcolor = video::SColor(\r
                                255,\r
                                skycolor.getRed() * daynight_ratio / 1000,\r
                                skycolor.getGreen() * daynight_ratio / 1000,\r
-                               skycolor.getBlue() * daynight_ratio / 1000);\r
+                               skycolor.getBlue() * daynight_ratio / 1000);*/\r
+\r
+               u8 l = decode_light((daynight_ratio * LIGHT_SUN) / 1000);\r
+               video::SColor bgcolor = video::SColor(\r
+                               255,\r
+                               skycolor.getRed() * l / 255,\r
+                               skycolor.getGreen() * l / 255,\r
+                               skycolor.getBlue() * l / 255);\r
 \r
                /*\r
                        Fog\r
index 93c4d50529dca1059cbd9dd5566d9415aa5c9302..a3fe9922ef7600bc4c525e682827bc8e75ee7fbb 100644 (file)
@@ -3178,9 +3178,12 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
                        /*
                                This has to be done with the mesh_mutex unlocked
                        */
-                       if(mesh_expired && mesh_update_count < 6
-                                       && (d < faraway || mesh_update_count < 3))
-                       //if(mesh_expired && mesh_update_count < 4)
+                       // Pretty random but this should work somewhat nicely
+                       if(mesh_expired && mesh_update_count < 3
+                                       && (d < faraway || mesh_update_count < 2
+                                       || m_control.range_all))
+                       /*if(mesh_expired && mesh_update_count < 6
+                                       && (d < faraway || mesh_update_count < 3))*/
                        {
                                mesh_update_count++;
 
index 05ef13d93172cdd6dac99d824e427085fbbdac5b..daf00b8ee9bb5128b651a1c183b57de9781851a0 100644 (file)
@@ -876,7 +876,7 @@ Server::Server(
        m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this),
        m_thread(this),
        m_emergethread(this),
-       m_time_of_day(8000),
+       m_time_of_day(9000),
        m_time_counter(0),
        m_time_of_day_send_timer(0),
        m_uptime(0)