]> git.lizzy.rs Git - minetest.git/blobdiff - src/game.cpp
Fix object duplication bug
[minetest.git] / src / game.cpp
index 78962c18c545d19dafcb24680208fe21cb838c96..92d4a2ae490601d1b101e729763a75e21a311786 100644 (file)
@@ -872,7 +872,6 @@ void the_game(
                        L"",
                        core::rect<s32>(5, 5+(text_height+5)*1, 795, (5+text_height)*2),
                        false, false);
-       
        // At the middle of the screen
        // Object infos are shown in this
        gui::IGUIStaticText *guitext_info = guienv->addStaticText(
@@ -889,6 +888,15 @@ void the_game(
        //guitext_chat->setBackgroundColor(video::SColor(96,0,0,0));
        core::list<ChatLine> chat_lines;
        
+       // Profiler text
+       gui::IGUIStaticText *guitext_profiler = guienv->addStaticText(
+                       L"<Profiler>",
+                       core::rect<s32>(6, 4+(text_height+5)*3, 400,
+                       (text_height+5)*3 + text_height*35),
+                       false, false);
+       guitext_profiler->setBackgroundColor(video::SColor(80,0,0,0));
+       guitext_profiler->setVisible(false);
+       
        /*GUIQuickInventory *quick_inventory = new GUIQuickInventory
                        (guienv, NULL, v2s32(10, 70), 5, &local_inventory);*/
        /*GUIQuickInventory *quick_inventory = new GUIQuickInventory
@@ -942,6 +950,8 @@ void the_game(
 
        bool respawn_menu_active = false;
 
+       bool show_profiler = false;
+
        /*
                Main loop
        */
@@ -1162,14 +1172,23 @@ void the_game(
                */
                float profiler_print_interval =
                                g_settings->getFloat("profiler_print_interval");
-               if(profiler_print_interval != 0)
+               bool print_to_log = true;
+               if(profiler_print_interval == 0){
+                       print_to_log = false;
+                       profiler_print_interval = 5;
+               }
+               if(m_profiler_interval.step(0.030, profiler_print_interval))
                {
-                       if(m_profiler_interval.step(0.030, profiler_print_interval))
-                       {
+                       if(print_to_log){
                                infostream<<"Profiler:"<<std::endl;
                                g_profiler->print(infostream);
-                               g_profiler->clear();
                        }
+
+                       std::ostringstream os(std::ios_base::binary);
+                       g_profiler->print(os);
+                       guitext_profiler->setText(narrow_to_wide(os.str()).c_str());
+
+                       g_profiler->clear();
                }
 
                /*
@@ -1299,6 +1318,11 @@ void the_game(
                                image->drop(); 
                        }                        
                }
+               else if(input->wasKeyDown(getKeySetting("keymap_toggle_profiler")))
+               {
+                       show_profiler = !show_profiler;
+                       guitext_profiler->setVisible(show_profiler);
+               }
 
                // Item selection with mouse wheel
                {
@@ -2025,14 +2049,15 @@ void the_game(
                                        "(% .1f, % .1f, % .1f)"
                                        " (% .3f < btime_jitter < % .3f"
                                        ", dtime_jitter = % .1f %%"
-                                       ", v_range = %.1f)",
+                                       ", v_range = %.1f, RTT = %.3f)",
                                        player_position.X/BS,
                                        player_position.Y/BS,
                                        player_position.Z/BS,
                                        busytime_jitter1_min_sample,
                                        busytime_jitter1_max_sample,
                                        dtime_jitter1_max_fraction * 100.0,
-                                       draw_control.wanted_range
+                                       draw_control.wanted_range,
+                                       client.getRTT()
                                        );
 
                        guitext2->setText(narrow_to_wide(temptext).c_str());
@@ -2113,7 +2138,8 @@ void the_game(
 
                        guitext_chat->setRelativePosition(rect);
 
-                       if(chat_lines.size() == 0)
+                       // Don't show chat if empty or profiler is enabled
+                       if(chat_lines.size() == 0 || show_profiler)
                                guitext_chat->setVisible(false);
                        else
                                guitext_chat->setVisible(true);