]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/game.cpp
Optimized smooth lighting calculation code
[dragonfireclient.git] / src / game.cpp
index 9a0fd312b2727487df109f068807e7b2b124e6d7..9054f00cc044f1c24471065fd48bb6b51f72bcb9 100644 (file)
@@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "guiTextInputMenu.h"
 #include "guiFurnaceMenu.h"
 #include "materials.h"
+#include "config.h"
 
 /*
        Setting this to 1 enables a special camera mode that forces
@@ -652,15 +653,33 @@ void the_game(
                gui_loadingtext->remove();
                return;
        }
+
+       /*
+               Attempt to connect to the server
+       */
        
        dstream<<DTIME<<"Connecting to server at ";
        connect_address.print(&dstream);
        dstream<<std::endl;
        client.connect(connect_address);
+
+       bool could_connect = false;
        
        try{
-               while(client.connectedAndInitialized() == false)
+               float time_counter = 0.0;
+               for(;;)
                {
+                       if(client.connectedAndInitialized())
+                       {
+                               could_connect = true;
+                               break;
+                       }
+                       // Wait for 10 seconds
+                       if(time_counter >= 10.0)
+                       {
+                               break;
+                       }
+
                        // Update screen
                        driver->beginScene(true, true, video::SColor(255,0,0,0));
                        guienv->drawAll();
@@ -675,12 +694,15 @@ void the_game(
                        
                        // Delay a bit
                        sleep_ms(100);
+                       time_counter += 0.1;
                }
        }
        catch(con::PeerNotFoundException &e)
+       {}
+
+       if(could_connect == false)
        {
                std::cout<<DTIME<<"Timed out."<<std::endl;
-               //return 0;
                error_message = L"Connection timed out.";
                gui_loadingtext->remove();
                return;
@@ -1207,6 +1229,17 @@ void the_game(
                                s32 dx = input->getMousePos().X - displaycenter.X;
                                s32 dy = input->getMousePos().Y - displaycenter.Y;
                                //std::cout<<"window active, pos difference "<<dx<<","<<dy<<std::endl;
+                               
+                               const float keyspeed = 500;
+                               if(input->isKeyDown(irr::KEY_UP))
+                                       dy -= dtime * keyspeed;
+                               if(input->isKeyDown(irr::KEY_DOWN))
+                                       dy += dtime * keyspeed;
+                               if(input->isKeyDown(irr::KEY_LEFT))
+                                       dx -= dtime * keyspeed;
+                               if(input->isKeyDown(irr::KEY_RIGHT))
+                                       dx += dtime * keyspeed;
+
                                camera_yaw -= dx*0.2;
                                camera_pitch += dy*0.2;
                                if(camera_pitch < -89.5) camera_pitch = -89.5;
@@ -1687,13 +1720,12 @@ void the_game(
                        endscenetime_avg = endscenetime_avg * 0.95 + (float)endscenetime*0.05;
                        
                        char temptext[300];
-                       snprintf(temptext, 300, "Minetest-c55 ("
-                                       "F: item=%i"
-                                       ", R: range_all=%i"
+                       snprintf(temptext, 300, "Minetest-c55 %s ("
+                                       "R: range_all=%i"
                                        ")"
                                        " drawtime=%.0f, beginscenetime=%.0f"
                                        ", scenetime=%.0f, endscenetime=%.0f",
-                                       g_selected_item,
+                                       VERSION_STRING,
                                        draw_control.range_all,
                                        drawtime_avg,
                                        beginscenetime_avg,