3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #pragma message ("Disabling unit tests")
24 #warning "Disabling unit tests"
27 #define ENABLE_TESTS 0
30 #define ENABLE_TESTS 1
34 #ifndef SERVER // Dedicated server isn't linked with Irrlicht
35 #pragma comment(lib, "Irrlicht.lib")
36 // This would get rid of the console window
37 //#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
39 #pragma comment(lib, "zlibwapi.lib")
40 #pragma comment(lib, "Shell32.lib")
43 #include "irrlicht.h" // createDevice
46 #include "mainmenumanager.h"
50 #include "irrlichttypes_extrabloated.h"
55 #include "constants.h"
58 #include "guiMessageMenu.h"
61 #include "guiMainMenu.h"
66 #include "defaultsettings.h"
73 #include "xCGUITTFont.h"
75 #include "util/string.h"
77 #include "quicktune.h"
78 #include "serverlist.h"
82 These are loaded from the config file.
84 Settings main_settings;
85 Settings *g_settings = &main_settings;
88 Profiler main_profiler;
89 Profiler *g_profiler = &main_profiler;
96 std::ostream *dout_con_ptr = &dummyout;
97 std::ostream *derr_con_ptr = &verbosestream;
100 std::ostream *dout_server_ptr = &infostream;
101 std::ostream *derr_server_ptr = &errorstream;
104 std::ostream *dout_client_ptr = &infostream;
105 std::ostream *derr_client_ptr = &errorstream;
112 /* mainmenumanager.h */
114 gui::IGUIEnvironment* guienv = NULL;
115 gui::IGUIStaticText *guiroot = NULL;
116 MainMenuManager g_menumgr;
120 return (g_menumgr.menuCount() == 0);
123 // Passed to menus to allow disconnecting and exiting
124 MainGameCallback *g_gamecallback = NULL;
128 gettime.h implementation
135 /* Use imprecise system calls directly (from porting.h) */
136 return porting::getTimeMs();
141 // A small helper class
145 virtual u32 getTime() = 0;
148 // A precise irrlicht one
149 class IrrlichtTimeGetter: public TimeGetter
152 IrrlichtTimeGetter(IrrlichtDevice *device):
159 return m_device->getTimer()->getRealTime();
162 IrrlichtDevice *m_device;
164 // Not so precise one which works without irrlicht
165 class SimpleTimeGetter: public TimeGetter
170 return porting::getTimeMs();
174 // A pointer to a global instance of the time getter
176 TimeGetter *g_timegetter = NULL;
180 if(g_timegetter == NULL)
182 return g_timegetter->getTime();
187 class StderrLogOutput: public ILogOutput
190 /* line: Full line with timestamp, level and thread */
191 void printLog(const std::string &line)
193 std::cerr<<line<<std::endl;
195 } main_stderr_log_out;
197 class DstreamNoStderrLogOutput: public ILogOutput
200 /* line: Full line with timestamp, level and thread */
201 void printLog(const std::string &line)
203 dstream_no_stderr<<line<<std::endl;
205 } main_dstream_no_stderr_log_out;
210 Event handler for Irrlicht
212 NOTE: Everything possible should be moved out from here,
213 probably to InputHandler and the_game
216 class MyEventReceiver : public IEventReceiver
219 // This is the one method that we have to implement
220 virtual bool OnEvent(const SEvent& event)
223 React to nothing here if a menu is active
225 if(noMenuActive() == false)
230 // Remember whether each key is down or up
231 if(event.EventType == irr::EET_KEY_INPUT_EVENT)
233 if(event.KeyInput.PressedDown) {
234 keyIsDown.set(event.KeyInput);
235 keyWasDown.set(event.KeyInput);
237 keyIsDown.unset(event.KeyInput);
241 if(event.EventType == irr::EET_MOUSE_INPUT_EVENT)
243 if(noMenuActive() == false)
246 middle_active = false;
247 right_active = false;
251 left_active = event.MouseInput.isLeftPressed();
252 middle_active = event.MouseInput.isMiddlePressed();
253 right_active = event.MouseInput.isRightPressed();
255 if(event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
259 if(event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN)
263 if(event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
267 if(event.MouseInput.Event == EMIE_RMOUSE_LEFT_UP)
269 rightreleased = true;
271 if(event.MouseInput.Event == EMIE_MOUSE_WHEEL)
273 mouse_wheel += event.MouseInput.Wheel;
281 bool IsKeyDown(const KeyPress &keyCode) const
283 return keyIsDown[keyCode];
286 // Checks whether a key was down and resets the state
287 bool WasKeyDown(const KeyPress &keyCode)
289 bool b = keyWasDown[keyCode];
291 keyWasDown.unset(keyCode);
308 rightclicked = false;
309 leftreleased = false;
310 rightreleased = false;
313 middle_active = false;
314 right_active = false;
336 IrrlichtDevice *m_device;
338 // The current state of keys
340 // Whether a key has been pressed or not
345 Separated input handler
348 class RealInputHandler : public InputHandler
351 RealInputHandler(IrrlichtDevice *device, MyEventReceiver *receiver):
356 virtual bool isKeyDown(const KeyPress &keyCode)
358 return m_receiver->IsKeyDown(keyCode);
360 virtual bool wasKeyDown(const KeyPress &keyCode)
362 return m_receiver->WasKeyDown(keyCode);
364 virtual v2s32 getMousePos()
366 return m_device->getCursorControl()->getPosition();
368 virtual void setMousePos(s32 x, s32 y)
370 m_device->getCursorControl()->setPosition(x, y);
373 virtual bool getLeftState()
375 return m_receiver->left_active;
377 virtual bool getRightState()
379 return m_receiver->right_active;
382 virtual bool getLeftClicked()
384 return m_receiver->leftclicked;
386 virtual bool getRightClicked()
388 return m_receiver->rightclicked;
390 virtual void resetLeftClicked()
392 m_receiver->leftclicked = false;
394 virtual void resetRightClicked()
396 m_receiver->rightclicked = false;
399 virtual bool getLeftReleased()
401 return m_receiver->leftreleased;
403 virtual bool getRightReleased()
405 return m_receiver->rightreleased;
407 virtual void resetLeftReleased()
409 m_receiver->leftreleased = false;
411 virtual void resetRightReleased()
413 m_receiver->rightreleased = false;
416 virtual s32 getMouseWheel()
418 return m_receiver->getMouseWheel();
423 m_receiver->clearInput();
426 IrrlichtDevice *m_device;
427 MyEventReceiver *m_receiver;
430 class RandomInputHandler : public InputHandler
438 rightclicked = false;
439 leftreleased = false;
440 rightreleased = false;
443 virtual bool isKeyDown(const KeyPress &keyCode)
445 return keydown[keyCode];
447 virtual bool wasKeyDown(const KeyPress &keyCode)
451 virtual v2s32 getMousePos()
455 virtual void setMousePos(s32 x, s32 y)
457 mousepos = v2s32(x,y);
460 virtual bool getLeftState()
464 virtual bool getRightState()
469 virtual bool getLeftClicked()
473 virtual bool getRightClicked()
477 virtual void resetLeftClicked()
481 virtual void resetRightClicked()
483 rightclicked = false;
486 virtual bool getLeftReleased()
490 virtual bool getRightReleased()
492 return rightreleased;
494 virtual void resetLeftReleased()
496 leftreleased = false;
498 virtual void resetRightReleased()
500 rightreleased = false;
503 virtual s32 getMouseWheel()
508 virtual void step(float dtime)
511 static float counter1 = 0;
515 counter1 = 0.1*Rand(1, 40);
516 keydown.toggle(getKeySetting("keymap_jump"));
520 static float counter1 = 0;
524 counter1 = 0.1*Rand(1, 40);
525 keydown.toggle(getKeySetting("keymap_special1"));
529 static float counter1 = 0;
533 counter1 = 0.1*Rand(1, 40);
534 keydown.toggle(getKeySetting("keymap_forward"));
538 static float counter1 = 0;
542 counter1 = 0.1*Rand(1, 40);
543 keydown.toggle(getKeySetting("keymap_left"));
547 static float counter1 = 0;
551 counter1 = 0.1*Rand(1, 20);
552 mousespeed = v2s32(Rand(-20,20), Rand(-15,20));
556 static float counter1 = 0;
560 counter1 = 0.1*Rand(1, 30);
561 leftdown = !leftdown;
569 static float counter1 = 0;
573 counter1 = 0.1*Rand(1, 15);
574 rightdown = !rightdown;
578 rightreleased = true;
581 mousepos += mousespeed;
584 s32 Rand(s32 min, s32 max)
586 return (myrand()%(max-min+1))+min;
600 //Draw the tiled menu background
601 void drawMenuBackground(video::IVideoDriver* driver) {
602 core::dimension2d<u32> screensize = driver->getScreenSize();
604 std::string path = getTexturePath("menubg.png");
606 video::ITexture *bgtexture =
607 driver->getTexture(path.c_str());
610 s32 scaledsize = 128;
612 // The important difference between destsize and screensize is
613 // that destsize is rounded to whole scaled pixels.
614 // These formulas use component-wise multiplication and division of v2u32.
615 v2u32 texturesize = bgtexture->getSize();
616 v2u32 sourcesize = texturesize * screensize / scaledsize + v2u32(1,1);
617 v2u32 destsize = scaledsize * sourcesize / texturesize;
619 // Default texture wrapping mode in Irrlicht is ETC_REPEAT.
620 driver->draw2DImage(bgtexture,
621 core::rect<s32>(0, 0, destsize.X, destsize.Y),
622 core::rect<s32>(0, 0, sourcesize.X, sourcesize.Y),
628 //Draw the footer at the bottom of the window
629 void drawMenuFooter(video::IVideoDriver* driver, bool clouds) {
630 core::dimension2d<u32> screensize = driver->getScreenSize();
631 std::string path = getTexturePath(clouds ?
632 "menufooter_clouds.png" : "menufooter.png");
634 video::ITexture *footertexture =
635 driver->getTexture(path.c_str());
638 f32 mult = (((f32)screensize.Width)) /
639 ((f32)footertexture->getOriginalSize().Width);
641 v2s32 footersize(((f32)footertexture->getOriginalSize().Width) * mult,
642 ((f32)footertexture->getOriginalSize().Height) * mult);
644 // Don't draw the footer if there isn't enough room
645 s32 free_space = (((s32)screensize.Height)-320)/2;
646 if (free_space > footersize.Y) {
647 core::rect<s32> rect(0,0,footersize.X,footersize.Y);
648 rect += v2s32(screensize.Width/2,screensize.Height-footersize.Y);
649 rect -= v2s32(footersize.X/2, 0);
651 driver->draw2DImage(footertexture, rect,
652 core::rect<s32>(core::position2d<s32>(0,0),
653 core::dimension2di(footertexture->getSize())),
660 // Draw the Header over the main menu
661 void drawMenuHeader(video::IVideoDriver* driver) {
662 core::dimension2d<u32> screensize = driver->getScreenSize();
664 std::string path = getTexturePath("menuheader.png");
666 video::ITexture *splashtexture =
667 driver->getTexture(path.c_str());
670 //v2s32 splashsize((splashtexture->getOriginalSize().Width*100)/
671 // splashtexture->getOriginalSize().Height, 80);
673 f32 mult = (((f32)screensize.Width / 2)) /
674 ((f32)splashtexture->getOriginalSize().Width);
676 v2s32 splashsize(((f32)splashtexture->getOriginalSize().Width) * mult,
677 ((f32)splashtexture->getOriginalSize().Height) * mult);
679 // Don't draw the header is there isn't enough room
680 s32 free_space = (((s32)screensize.Height)-320)/2;
681 if (free_space > splashsize.Y) {
682 core::rect<s32> splashrect(0, 0, splashsize.X, splashsize.Y);
683 splashrect += v2s32((screensize.Width/2)-(splashsize.X/2),
684 ((free_space/2)-splashsize.Y/2)+10);
686 video::SColor bgcolor(255,50,50,50);
688 driver->draw2DImage(splashtexture, splashrect,
689 core::rect<s32>(core::position2d<s32>(0,0),
690 core::dimension2di(splashtexture->getSize())),
697 // Draw the Splash over the clouds and under the main menu
698 void drawMenuSplash(video::IVideoDriver* driver) {
699 core::dimension2d<u32> screensize = driver->getScreenSize();
700 if (getTexturePath("menusplash.png") != "") {
701 video::ITexture *splashtexture =
702 driver->getTexture(getTexturePath("menusplash.png").c_str());
705 core::rect<s32> splashrect(0, 0, screensize.Width, screensize.Height);
707 video::SColor bgcolor(255,50,50,50);
709 driver->draw2DImage(splashtexture, splashrect,
710 core::rect<s32>(core::position2d<s32>(0,0),
711 core::dimension2di(splashtexture->getSize())),
719 // These are defined global so that they're not optimized too much.
720 // Can't change them to volatile.
725 std::string tempstring;
726 std::string tempstring2;
731 infostream<<"The following test should take around 20ms."<<std::endl;
732 TimeTaker timer("Testing std::string speed");
733 const u32 jj = 10000;
734 for(u32 j=0; j<jj; j++)
739 for(u32 i=0; i<ii; i++){
740 tempstring2 += "asd";
742 for(u32 i=0; i<ii+1; i++){
744 if(tempstring == tempstring2)
750 infostream<<"All of the following tests should take around 100ms each."
754 TimeTaker timer("Testing floating-point conversion speed");
756 for(u32 i=0; i<4000000; i++){
763 TimeTaker timer("Testing floating-point vector speed");
765 tempv3f1 = v3f(1,2,3);
766 tempv3f2 = v3f(4,5,6);
767 for(u32 i=0; i<10000000; i++){
768 tempf += tempv3f1.dotProduct(tempv3f2);
769 tempv3f2 += v3f(7,8,9);
774 TimeTaker timer("Testing std::map speed");
776 std::map<v2s16, f32> map1;
779 for(s16 y=0; y<ii; y++){
780 for(s16 x=0; x<ii; x++){
781 map1[v2s16(x,y)] = tempf;
785 for(s16 y=ii-1; y>=0; y--){
786 for(s16 x=0; x<ii; x++){
787 tempf = map1[v2s16(x,y)];
793 infostream<<"Around 5000/ms should do well here."<<std::endl;
794 TimeTaker timer("Testing mutex speed");
808 while(timer.getTime() < 10);
810 u32 dtime = timer.stop();
811 u32 per_ms = n / dtime;
812 infostream<<"Done. "<<dtime<<"ms, "
813 <<per_ms<<"/ms"<<std::endl;
817 static void print_worldspecs(const std::vector<WorldSpec> &worldspecs,
820 for(u32 i=0; i<worldspecs.size(); i++){
821 std::string name = worldspecs[i].name;
822 std::string path = worldspecs[i].path;
823 if(name.find(" ") != std::string::npos)
824 name = std::string("'") + name + "'";
825 path = std::string("'") + path + "'";
826 name = padStringRight(name, 14);
827 os<<" "<<name<<" "<<path<<std::endl;
831 int main(int argc, char *argv[])
839 log_add_output_maxlev(&main_stderr_log_out, LMT_ACTION);
840 log_add_output_all_levs(&main_dstream_no_stderr_log_out);
842 log_register_thread("main");
844 // This enables internatonal characters input
845 if( setlocale(LC_ALL, "") == NULL )
847 fprintf( stderr, "%s: warning: could not set default locale\n", argv[0] );
850 // Set locale. This is for forcing '.' as the decimal point.
852 std::locale::global(std::locale(std::locale(""), "C", std::locale::numeric));
853 setlocale(LC_NUMERIC, "C");
854 } catch (const std::exception& ex) {
855 errorstream<<"Could not set numeric locale to C"<<std::endl;
861 // List all allowed options
862 std::map<std::string, ValueSpec> allowed_options;
863 allowed_options.insert(std::make_pair("help", ValueSpec(VALUETYPE_FLAG,
864 _("Show allowed options"))));
865 allowed_options.insert(std::make_pair("config", ValueSpec(VALUETYPE_STRING,
866 _("Load configuration from specified file"))));
867 allowed_options.insert(std::make_pair("port", ValueSpec(VALUETYPE_STRING,
868 _("Set network port (UDP)"))));
869 allowed_options.insert(std::make_pair("disable-unittests", ValueSpec(VALUETYPE_FLAG,
870 _("Disable unit tests"))));
871 allowed_options.insert(std::make_pair("enable-unittests", ValueSpec(VALUETYPE_FLAG,
872 _("Enable unit tests"))));
873 allowed_options.insert(std::make_pair("map-dir", ValueSpec(VALUETYPE_STRING,
874 _("Same as --world (deprecated)"))));
875 allowed_options.insert(std::make_pair("world", ValueSpec(VALUETYPE_STRING,
876 _("Set world path (implies local game) ('list' lists all)"))));
877 allowed_options.insert(std::make_pair("worldname", ValueSpec(VALUETYPE_STRING,
878 _("Set world by name (implies local game)"))));
879 allowed_options.insert(std::make_pair("info", ValueSpec(VALUETYPE_FLAG,
880 _("Print more information to console"))));
881 allowed_options.insert(std::make_pair("verbose", ValueSpec(VALUETYPE_FLAG,
882 _("Print even more information to console"))));
883 allowed_options.insert(std::make_pair("trace", ValueSpec(VALUETYPE_FLAG,
884 _("Print enormous amounts of information to log and console"))));
885 allowed_options.insert(std::make_pair("logfile", ValueSpec(VALUETYPE_STRING,
886 _("Set logfile path ('' = no logging)"))));
887 allowed_options.insert(std::make_pair("gameid", ValueSpec(VALUETYPE_STRING,
888 _("Set gameid (\"--gameid list\" prints available ones)"))));
890 allowed_options.insert(std::make_pair("speedtests", ValueSpec(VALUETYPE_FLAG,
891 _("Run speed tests"))));
892 allowed_options.insert(std::make_pair("address", ValueSpec(VALUETYPE_STRING,
893 _("Address to connect to. ('' = local game)"))));
894 allowed_options.insert(std::make_pair("random-input", ValueSpec(VALUETYPE_FLAG,
895 _("Enable random user input, for testing"))));
896 allowed_options.insert(std::make_pair("server", ValueSpec(VALUETYPE_FLAG,
897 _("Run dedicated server"))));
898 allowed_options.insert(std::make_pair("name", ValueSpec(VALUETYPE_STRING,
899 _("Set player name"))));
900 allowed_options.insert(std::make_pair("password", ValueSpec(VALUETYPE_STRING,
901 _("Set password"))));
902 allowed_options.insert(std::make_pair("go", ValueSpec(VALUETYPE_FLAG,
903 _("Disable main menu"))));
908 bool ret = cmd_args.parseCommandLine(argc, argv, allowed_options);
910 if(ret == false || cmd_args.getFlag("help") || cmd_args.exists("nonopt1"))
912 dstream<<_("Allowed options:")<<std::endl;
913 for(std::map<std::string, ValueSpec>::iterator
914 i = allowed_options.begin();
915 i != allowed_options.end(); ++i)
917 std::ostringstream os1(std::ios::binary);
918 os1<<" --"<<i->first;
919 if(i->second.type == VALUETYPE_FLAG)
923 dstream<<padStringRight(os1.str(), 24);
925 if(i->second.help != NULL)
926 dstream<<i->second.help;
930 return cmd_args.getFlag("help") ? 0 : 1;
934 Low-level initialization
937 // If trace is enabled, enable logging of certain things
938 if(cmd_args.getFlag("trace")){
939 dstream<<_("Enabling trace level debug output")<<std::endl;
940 log_trace_level_enabled = true;
941 dout_con_ptr = &verbosestream; // this is somewhat old crap
942 socket_enable_debug_output = true; // socket doesn't use log.h
944 // In certain cases, output info level on stderr
945 if(cmd_args.getFlag("info") || cmd_args.getFlag("verbose") ||
946 cmd_args.getFlag("trace") || cmd_args.getFlag("speedtests"))
947 log_add_output(&main_stderr_log_out, LMT_INFO);
948 // In certain cases, output verbose level on stderr
949 if(cmd_args.getFlag("verbose") || cmd_args.getFlag("trace"))
950 log_add_output(&main_stderr_log_out, LMT_VERBOSE);
952 porting::signal_handler_init();
953 bool &kill = *porting::signal_handler_killstatus();
955 porting::initializePaths();
957 // Create user data directory
958 fs::CreateDir(porting::path_user);
960 init_gettext((porting::path_share + DIR_DELIM + "locale").c_str());
962 infostream<<"path_share = "<<porting::path_share<<std::endl;
963 infostream<<"path_user = "<<porting::path_user<<std::endl;
965 // Initialize debug stacks
967 DSTACK(__FUNCTION_NAME);
970 BEGIN_DEBUG_EXCEPTION_HANDLER
972 // List gameids if requested
973 if(cmd_args.exists("gameid") && cmd_args.get("gameid") == "list")
975 std::set<std::string> gameids = getAvailableGameIds();
976 for(std::set<std::string>::const_iterator i = gameids.begin();
977 i != gameids.end(); i++)
978 dstream<<(*i)<<std::endl;
982 // List worlds if requested
983 if(cmd_args.exists("world") && cmd_args.get("world") == "list"){
984 dstream<<_("Available worlds:")<<std::endl;
985 std::vector<WorldSpec> worldspecs = getAvailableWorlds();
986 print_worldspecs(worldspecs, dstream);
990 // Print startup message
991 infostream<<PROJECT_NAME<<
992 " "<<_("with")<<" SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST
1000 // Initialize default settings
1001 set_default_settings(g_settings);
1003 // Initialize sockets
1005 atexit(sockets_cleanup);
1011 // Path of configuration file in use
1012 std::string configpath = "";
1014 if(cmd_args.exists("config"))
1016 bool r = g_settings->readConfigFile(cmd_args.get("config").c_str());
1019 errorstream<<"Could not read configuration from \""
1020 <<cmd_args.get("config")<<"\""<<std::endl;
1023 configpath = cmd_args.get("config");
1027 std::vector<std::string> filenames;
1028 filenames.push_back(porting::path_user +
1029 DIR_DELIM + "minetest.conf");
1030 // Legacy configuration file location
1031 filenames.push_back(porting::path_user +
1032 DIR_DELIM + ".." + DIR_DELIM + "minetest.conf");
1034 // Try also from a lower level (to aid having the same configuration
1035 // for many RUN_IN_PLACE installs)
1036 filenames.push_back(porting::path_user +
1037 DIR_DELIM + ".." + DIR_DELIM + ".." + DIR_DELIM + "minetest.conf");
1040 for(u32 i=0; i<filenames.size(); i++)
1042 bool r = g_settings->readConfigFile(filenames[i].c_str());
1045 configpath = filenames[i];
1050 // If no path found, use the first one (menu creates the file)
1051 if(configpath == "")
1052 configpath = filenames[0];
1055 // Initialize debug streams
1056 #define DEBUGFILE "debug.txt"
1058 std::string logfile = DEBUGFILE;
1060 std::string logfile = porting::path_user+DIR_DELIM+DEBUGFILE;
1062 if(cmd_args.exists("logfile"))
1063 logfile = cmd_args.get("logfile");
1065 log_remove_output(&main_dstream_no_stderr_log_out);
1066 int loglevel = g_settings->getS32("debug_log_level");
1068 if (loglevel == 0) //no logging
1070 else if (loglevel > 0 && loglevel <= LMT_NUM_VALUES)
1071 log_add_output_maxlev(&main_dstream_no_stderr_log_out, (LogMessageLevel)(loglevel - 1));
1074 debugstreams_init(false, logfile.c_str());
1076 debugstreams_init(false, NULL);
1078 infostream<<"logfile = "<<logfile<<std::endl;
1080 // Initialize random seed
1088 if((ENABLE_TESTS && cmd_args.getFlag("disable-unittests") == false)
1089 || cmd_args.getFlag("enable-unittests") == true)
1100 if(cmd_args.exists("port"))
1101 port = cmd_args.getU16("port");
1102 else if(g_settings->exists("port"))
1103 port = g_settings->getU16("port");
1108 std::string commanded_world = "";
1109 if(cmd_args.exists("world"))
1110 commanded_world = cmd_args.get("world");
1111 else if(cmd_args.exists("map-dir"))
1112 commanded_world = cmd_args.get("map-dir");
1113 else if(cmd_args.exists("nonopt0")) // First nameless argument
1114 commanded_world = cmd_args.get("nonopt0");
1115 else if(g_settings->exists("map-dir"))
1116 commanded_world = g_settings->get("map-dir");
1119 std::string commanded_worldname = "";
1120 if(cmd_args.exists("worldname"))
1121 commanded_worldname = cmd_args.get("worldname");
1123 // Strip world.mt from commanded_world
1125 std::string worldmt = "world.mt";
1126 if(commanded_world.size() > worldmt.size() &&
1127 commanded_world.substr(commanded_world.size()-worldmt.size())
1129 dstream<<_("Supplied world.mt file - stripping it off.")<<std::endl;
1130 commanded_world = commanded_world.substr(
1131 0, commanded_world.size()-worldmt.size());
1135 // If a world name was specified, convert it to a path
1136 if(commanded_worldname != ""){
1137 // Get information about available worlds
1138 std::vector<WorldSpec> worldspecs = getAvailableWorlds();
1140 for(u32 i=0; i<worldspecs.size(); i++){
1141 std::string name = worldspecs[i].name;
1142 if(name == commanded_worldname){
1143 if(commanded_world != ""){
1144 dstream<<_("--worldname takes precedence over previously "
1145 "selected world.")<<std::endl;
1147 commanded_world = worldspecs[i].path;
1153 dstream<<_("World")<<" '"<<commanded_worldname<<_("' not "
1154 "available. Available worlds:")<<std::endl;
1155 print_worldspecs(worldspecs, dstream);
1161 SubgameSpec commanded_gamespec;
1162 if(cmd_args.exists("gameid")){
1163 std::string gameid = cmd_args.get("gameid");
1164 commanded_gamespec = findSubgame(gameid);
1165 if(!commanded_gamespec.isValid()){
1166 errorstream<<"Game \""<<gameid<<"\" not found"<<std::endl;
1172 Run dedicated server if asked to or no other option
1175 bool run_dedicated_server = true;
1177 bool run_dedicated_server = cmd_args.getFlag("server");
1179 g_settings->set("server_dedicated", run_dedicated_server ? "true" : "false");
1180 if(run_dedicated_server)
1182 DSTACK("Dedicated server branch");
1183 // Create time getter if built with Irrlicht
1185 g_timegetter = new SimpleTimeGetter();
1189 std::string world_path;
1190 verbosestream<<_("Determining world path")<<std::endl;
1191 bool is_legacy_world = false;
1192 // If a world was commanded, use it
1193 if(commanded_world != ""){
1194 world_path = commanded_world;
1195 infostream<<"Using commanded world path ["<<world_path<<"]"
1198 // No world was specified; try to select it automatically
1201 // Get information about available worlds
1202 std::vector<WorldSpec> worldspecs = getAvailableWorlds();
1203 // If a world name was specified, select it
1204 if(commanded_worldname != ""){
1206 for(u32 i=0; i<worldspecs.size(); i++){
1207 std::string name = worldspecs[i].name;
1208 if(name == commanded_worldname){
1209 world_path = worldspecs[i].path;
1213 if(world_path == ""){
1214 dstream<<_("World")<<" '"<<commanded_worldname<<"' "<<_("not "
1215 "available. Available worlds:")<<std::endl;
1216 print_worldspecs(worldspecs, dstream);
1220 // If there is only a single world, use it
1221 if(worldspecs.size() == 1){
1222 world_path = worldspecs[0].path;
1223 dstream<<_("Automatically selecting world at")<<" ["
1224 <<world_path<<"]"<<std::endl;
1225 // If there are multiple worlds, list them
1226 } else if(worldspecs.size() > 1){
1227 dstream<<_("Multiple worlds are available.")<<std::endl;
1228 dstream<<_("Please select one using --worldname <name>"
1229 " or --world <path>")<<std::endl;
1230 print_worldspecs(worldspecs, dstream);
1232 // If there are no worlds, automatically create a new one
1234 // This is the ultimate default world path
1235 world_path = porting::path_user + DIR_DELIM + "worlds" +
1236 DIR_DELIM + "world";
1237 infostream<<"Creating default world at ["
1238 <<world_path<<"]"<<std::endl;
1242 if(world_path == ""){
1243 errorstream<<"No world path specified or found."<<std::endl;
1246 verbosestream<<_("Using world path")<<" ["<<world_path<<"]"<<std::endl;
1248 // We need a gamespec.
1249 SubgameSpec gamespec;
1250 verbosestream<<_("Determining gameid/gamespec")<<std::endl;
1251 // If world doesn't exist
1252 if(!getWorldExists(world_path))
1254 // Try to take gamespec from command line
1255 if(commanded_gamespec.isValid()){
1256 gamespec = commanded_gamespec;
1257 infostream<<"Using commanded gameid ["<<gamespec.id<<"]"<<std::endl;
1259 // Otherwise we will be using "minetest"
1261 gamespec = findSubgame(g_settings->get("default_game"));
1262 infostream<<"Using default gameid ["<<gamespec.id<<"]"<<std::endl;
1268 std::string world_gameid = getWorldGameId(world_path, is_legacy_world);
1269 // If commanded to use a gameid, do so
1270 if(commanded_gamespec.isValid()){
1271 gamespec = commanded_gamespec;
1272 if(commanded_gamespec.id != world_gameid){
1273 errorstream<<"WARNING: Using commanded gameid ["
1274 <<gamespec.id<<"]"<<" instead of world gameid ["
1275 <<world_gameid<<"]"<<std::endl;
1278 // If world contains an embedded game, use it;
1279 // Otherwise find world from local system.
1280 gamespec = findWorldSubgame(world_path);
1281 infostream<<"Using world gameid ["<<gamespec.id<<"]"<<std::endl;
1284 if(!gamespec.isValid()){
1285 errorstream<<"Subgame ["<<gamespec.id<<"] could not be found."
1289 verbosestream<<_("Using gameid")<<" ["<<gamespec.id<<"]"<<std::endl;
1292 Server server(world_path, configpath, gamespec, false);
1296 dedicated_server_loop(server, kill);
1301 #ifndef SERVER // Exclude from dedicated server build
1307 std::string address = g_settings->get("address");
1308 if(commanded_world != "")
1310 else if(cmd_args.exists("address"))
1311 address = cmd_args.get("address");
1313 std::string playername = g_settings->get("name");
1314 if(cmd_args.exists("name"))
1315 playername = cmd_args.get("name");
1317 bool skip_main_menu = cmd_args.getFlag("go");
1320 Device initialization
1323 // Resolution selection
1325 bool fullscreen = g_settings->getBool("fullscreen");
1326 u16 screenW = g_settings->getU16("screenW");
1327 u16 screenH = g_settings->getU16("screenH");
1331 bool vsync = g_settings->getBool("vsync");
1332 u16 bits = g_settings->getU16("fullscreen_bpp");
1333 u16 fsaa = g_settings->getU16("fsaa");
1337 video::E_DRIVER_TYPE driverType;
1339 std::string driverstring = g_settings->get("video_driver");
1341 if(driverstring == "null")
1342 driverType = video::EDT_NULL;
1343 else if(driverstring == "software")
1344 driverType = video::EDT_SOFTWARE;
1345 else if(driverstring == "burningsvideo")
1346 driverType = video::EDT_BURNINGSVIDEO;
1347 else if(driverstring == "direct3d8")
1348 driverType = video::EDT_DIRECT3D8;
1349 else if(driverstring == "direct3d9")
1350 driverType = video::EDT_DIRECT3D9;
1351 else if(driverstring == "opengl")
1352 driverType = video::EDT_OPENGL;
1355 errorstream<<"WARNING: Invalid video_driver specified; defaulting "
1356 "to opengl"<<std::endl;
1357 driverType = video::EDT_OPENGL;
1361 Create device and exit if creation failed
1364 MyEventReceiver receiver;
1366 IrrlichtDevice *device;
1368 SIrrlichtCreationParameters params = SIrrlichtCreationParameters();
1369 params.DriverType = driverType;
1370 params.WindowSize = core::dimension2d<u32>(screenW, screenH);
1372 params.AntiAlias = fsaa;
1373 params.Fullscreen = fullscreen;
1374 params.Stencilbuffer = false;
1375 params.Vsync = vsync;
1376 params.EventReceiver = &receiver;
1378 device = createDeviceEx(params);
1381 return 1; // could not create selected driver.
1384 Continue initialization
1387 video::IVideoDriver* driver = device->getVideoDriver();
1390 This changes the minimum allowed number of vertices in a VBO.
1393 //driver->setMinHardwareBufferVertexCount(50);
1395 // Create time getter
1396 g_timegetter = new IrrlichtTimeGetter(device);
1398 // Create game callback for menus
1399 g_gamecallback = new MainGameCallback(device);
1402 Speed tests (done after irrlicht is loaded to get timer)
1404 if(cmd_args.getFlag("speedtests"))
1406 dstream<<"Running speed tests"<<std::endl;
1411 device->setResizable(true);
1413 bool random_input = g_settings->getBool("random_input")
1414 || cmd_args.getFlag("random-input");
1415 InputHandler *input = NULL;
1417 input = new RandomInputHandler();
1419 input = new RealInputHandler(device, &receiver);
1421 scene::ISceneManager* smgr = device->getSceneManager();
1423 guienv = device->getGUIEnvironment();
1424 gui::IGUISkin* skin = guienv->getSkin();
1426 std::string font_path = g_settings->get("font_path");
1427 u16 font_size = g_settings->getU16("font_size");
1428 gui::IGUIFont *font = gui::CGUITTFont::createTTFont(guienv, font_path.c_str(), font_size);
1430 gui::IGUIFont* font = guienv->getFont(getTexturePath("fontlucida.png").c_str());
1433 skin->setFont(font);
1435 errorstream<<"WARNING: Font file was not found."
1436 " Using default font."<<std::endl;
1437 // If font was not found, this will get us one
1438 font = skin->getFont();
1441 u32 text_height = font->getDimension(L"Hello, world!").Height;
1442 infostream<<"text_height="<<text_height<<std::endl;
1444 //skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255,0,0,0));
1445 skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255,255,255,255));
1446 //skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(0,0,0,0));
1447 //skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(0,0,0,0));
1448 skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255,0,0,0));
1449 skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255,0,0,0));
1450 skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255,70,100,50));
1451 skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255,255,255,255));
1453 #if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2
1454 // Irrlicht 1.8 input colours
1455 skin->setColor(gui::EGDC_EDITABLE, video::SColor(255,128,128,128));
1456 skin->setColor(gui::EGDC_FOCUSED_EDITABLE, video::SColor(255,96,134,49));
1463 ChatBackend chat_backend;
1466 If an error occurs, this is set to something and the
1467 menu-game loop is restarted. It is then displayed before
1470 std::wstring error_message = L"";
1472 // The password entered during the menu screen,
1473 std::string password;
1475 bool first_loop = true;
1480 while(device->run() && kill == false)
1482 // Set the window caption
1483 device->setWindowCaption((std::wstring(L"Minetest [")+wgettext("Main Menu")+L"]").c_str());
1485 // This is used for catching disconnects
1490 Clear everything from the GUIEnvironment
1495 We need some kind of a root node to be able to add
1496 custom gui elements directly on the screen.
1497 Otherwise they won't be automatically drawn.
1499 guiroot = guienv->addStaticText(L"",
1500 core::rect<s32>(0, 0, 10000, 10000));
1502 SubgameSpec gamespec;
1503 WorldSpec worldspec;
1504 bool simple_singleplayer_mode = false;
1506 // These are set up based on the menu and other things
1507 std::string current_playername = "inv£lid";
1508 std::string current_password = "";
1509 std::string current_address = "does-not-exist";
1510 int current_port = 0;
1513 Out-of-game menu loop.
1515 Loop quits when menu returns proper parameters.
1517 while(kill == false)
1519 // If skip_main_menu, only go through here once
1520 if(skip_main_menu && !first_loop){
1526 // Cursor can be non-visible when coming from the game
1527 device->getCursorControl()->setVisible(true);
1528 // Some stuff are left to scene manager when coming from the game
1532 // Initialize menu data
1533 MainMenuData menudata;
1534 if(g_settings->exists("selected_mainmenu_tab"))
1535 menudata.selected_tab = g_settings->getS32("selected_mainmenu_tab");
1536 menudata.address = narrow_to_wide(address);
1537 menudata.name = narrow_to_wide(playername);
1538 menudata.port = narrow_to_wide(itos(port));
1539 if(cmd_args.exists("password"))
1540 menudata.password = narrow_to_wide(cmd_args.get("password"));
1541 menudata.fancy_trees = g_settings->getBool("new_style_leaves");
1542 menudata.smooth_lighting = g_settings->getBool("smooth_lighting");
1543 menudata.clouds_3d = g_settings->getBool("enable_3d_clouds");
1544 menudata.opaque_water = g_settings->getBool("opaque_water");
1545 menudata.mip_map = g_settings->getBool("mip_map");
1546 menudata.anisotropic_filter = g_settings->getBool("anisotropic_filter");
1547 menudata.bilinear_filter = g_settings->getBool("bilinear_filter");
1548 menudata.trilinear_filter = g_settings->getBool("trilinear_filter");
1549 menudata.enable_shaders = g_settings->getS32("enable_shaders");
1550 menudata.preload_item_visuals = g_settings->getBool("preload_item_visuals");
1551 menudata.enable_particles = g_settings->getBool("enable_particles");
1552 driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, menudata.mip_map);
1553 menudata.creative_mode = g_settings->getBool("creative_mode");
1554 menudata.enable_damage = g_settings->getBool("enable_damage");
1555 menudata.enable_public = g_settings->getBool("server_announce");
1556 // Default to selecting nothing
1557 menudata.selected_world = -1;
1558 // Get world listing for the menu
1559 std::vector<WorldSpec> worldspecs = getAvailableWorlds();
1560 // If there is only one world, select it
1561 if(worldspecs.size() == 1){
1562 menudata.selected_world = 0;
1564 // Otherwise try to select according to selected_world_path
1565 else if(g_settings->exists("selected_world_path")){
1566 std::string trypath = g_settings->get("selected_world_path");
1567 for(u32 i=0; i<worldspecs.size(); i++){
1568 if(worldspecs[i].path == trypath){
1569 menudata.selected_world = i;
1574 // If a world was commanded, append and select it
1575 if(commanded_world != ""){
1576 std::string gameid = getWorldGameId(commanded_world, true);
1577 std::string name = _("[--world parameter]");
1579 gameid = g_settings->get("default_game");
1582 WorldSpec spec(commanded_world, name, gameid);
1583 worldspecs.push_back(spec);
1584 menudata.selected_world = worldspecs.size()-1;
1586 // Copy worldspecs to menu
1587 menudata.worlds = worldspecs;
1589 if(skip_main_menu == false)
1591 video::IVideoDriver* driver = device->getVideoDriver();
1593 infostream<<"Waiting for other menus"<<std::endl;
1594 while(device->run() && kill == false)
1598 driver->beginScene(true, true,
1599 video::SColor(255,128,128,128));
1600 drawMenuBackground(driver);
1603 // On some computers framerate doesn't seem to be
1604 // automatically limited
1607 infostream<<"Waited for other menus"<<std::endl;
1610 new GUIMainMenu(guienv, guiroot, -1,
1611 &g_menumgr, &menudata, g_gamecallback);
1612 menu->allowFocusRemoval(true);
1614 // Clouds for the main menu
1615 bool cloud_menu_background = false;
1616 Clouds *clouds = NULL;
1617 if (g_settings->getBool("menu_clouds")) {
1618 cloud_menu_background = true;
1619 clouds = new Clouds(smgr->getRootSceneNode(),
1620 smgr, -1, rand(), 100);
1621 clouds->update(v2f(0, 0), video::SColor(255,200,200,255));
1623 // A camera to see the clouds
1624 scene::ICameraSceneNode* camera;
1625 camera = smgr->addCameraSceneNode(0,
1626 v3f(0,0,0), v3f(0, 60, 100));
1627 camera->setFarValue(10000);
1630 if(error_message != L"")
1632 verbosestream<<"error_message = "
1633 <<wide_to_narrow(error_message)<<std::endl;
1635 GUIMessageMenu *menu2 =
1636 new GUIMessageMenu(guienv, guiroot, -1,
1637 &g_menumgr, error_message.c_str());
1639 error_message = L"";
1642 // Time is in milliseconds, for clouds
1643 u32 lasttime = device->getTimer()->getTime();
1645 infostream<<"Created main menu"<<std::endl;
1647 while(device->run() && kill == false)
1649 if(menu->getStatus() == true)
1652 // Time calc for the clouds
1653 f32 dtime; // in seconds
1654 if (cloud_menu_background) {
1655 u32 time = device->getTimer()->getTime();
1657 dtime = (time - lasttime) / 1000.0;
1663 //driver->beginScene(true, true, video::SColor(255,0,0,0));
1664 driver->beginScene(true, true, video::SColor(255,140,186,250));
1666 if (cloud_menu_background) {
1667 // *3 otherwise the clouds would move very slowly
1668 clouds->step(dtime*3);
1671 drawMenuSplash(driver);
1672 drawMenuFooter(driver, true);
1673 drawMenuHeader(driver);
1675 drawMenuBackground(driver);
1676 drawMenuFooter(driver, false);
1683 // On some computers framerate doesn't seem to be
1684 // automatically limited
1685 if (!cloud_menu_background)
1689 infostream<<"Dropping main menu"<<std::endl;
1692 if (cloud_menu_background) {
1698 playername = wide_to_narrow(menudata.name);
1699 password = translatePassword(playername, menudata.password);
1700 //infostream<<"Main: password hash: '"<<password<<"'"<<std::endl;
1702 address = wide_to_narrow(menudata.address);
1703 int newport = stoi(wide_to_narrow(menudata.port));
1706 simple_singleplayer_mode = menudata.simple_singleplayer_mode;
1708 g_settings->setS32("selected_mainmenu_tab", menudata.selected_tab);
1709 g_settings->set("new_style_leaves", itos(menudata.fancy_trees));
1710 g_settings->set("smooth_lighting", itos(menudata.smooth_lighting));
1711 g_settings->set("enable_3d_clouds", itos(menudata.clouds_3d));
1712 g_settings->set("opaque_water", itos(menudata.opaque_water));
1714 g_settings->set("mip_map", itos(menudata.mip_map));
1715 g_settings->set("anisotropic_filter", itos(menudata.anisotropic_filter));
1716 g_settings->set("bilinear_filter", itos(menudata.bilinear_filter));
1717 g_settings->set("trilinear_filter", itos(menudata.trilinear_filter));
1719 g_settings->setS32("enable_shaders", menudata.enable_shaders);
1720 g_settings->set("preload_item_visuals", itos(menudata.preload_item_visuals));
1721 g_settings->set("enable_particles", itos(menudata.enable_particles));
1723 g_settings->set("creative_mode", itos(menudata.creative_mode));
1724 g_settings->set("enable_damage", itos(menudata.enable_damage));
1725 g_settings->set("server_announce", itos(menudata.enable_public));
1726 g_settings->set("name", playername);
1727 g_settings->set("address", address);
1728 g_settings->set("port", itos(port));
1729 if(menudata.selected_world != -1)
1730 g_settings->set("selected_world_path",
1731 worldspecs[menudata.selected_world].path);
1733 // Break out of menu-game loop to shut down cleanly
1734 if(device->run() == false || kill == true)
1737 current_playername = playername;
1738 current_password = password;
1739 current_address = address;
1740 current_port = port;
1742 // If using simple singleplayer mode, override
1743 if(simple_singleplayer_mode){
1744 current_playername = "singleplayer";
1745 current_password = "";
1746 current_address = "";
1747 current_port = 30011;
1749 else if (address != "")
1751 ServerListSpec server;
1752 server["name"] = menudata.servername;
1753 server["address"] = wide_to_narrow(menudata.address);
1754 server["port"] = wide_to_narrow(menudata.port);
1755 server["description"] = menudata.serverdescription;
1756 ServerList::insert(server);
1759 // Set world path to selected one
1760 if(menudata.selected_world != -1){
1761 worldspec = worldspecs[menudata.selected_world];
1762 infostream<<"Selected world: "<<worldspec.name
1763 <<" ["<<worldspec.path<<"]"<<std::endl;
1766 // Only refresh if so requested
1767 if(menudata.only_refresh){
1768 infostream<<"Refreshing menu"<<std::endl;
1772 // Create new world if requested
1773 if(menudata.create_world_name != L"")
1775 std::string path = porting::path_user + DIR_DELIM
1776 "worlds" + DIR_DELIM
1777 + wide_to_narrow(menudata.create_world_name);
1778 // Create world if it doesn't exist
1779 if(!initializeWorld(path, menudata.create_world_gameid)){
1780 error_message = wgettext("Failed to initialize world");
1781 errorstream<<wide_to_narrow(error_message)<<std::endl;
1784 g_settings->set("selected_world_path", path);
1789 if(current_address == "")
1791 if(menudata.selected_world == -1){
1792 error_message = wgettext("No world selected and no address "
1793 "provided. Nothing to do.");
1794 errorstream<<wide_to_narrow(error_message)<<std::endl;
1797 // Load gamespec for required game
1798 gamespec = findWorldSubgame(worldspec.path);
1799 if(!gamespec.isValid() && !commanded_gamespec.isValid()){
1800 error_message = wgettext("Could not find or load game \"")
1801 + narrow_to_wide(worldspec.gameid) + L"\"";
1802 errorstream<<wide_to_narrow(error_message)<<std::endl;
1805 if(commanded_gamespec.isValid() &&
1806 commanded_gamespec.id != worldspec.gameid){
1807 errorstream<<"WARNING: Overriding gamespec from \""
1808 <<worldspec.gameid<<"\" to \""
1809 <<commanded_gamespec.id<<"\""<<std::endl;
1810 gamespec = commanded_gamespec;
1813 if(!gamespec.isValid()){
1814 error_message = wgettext("Invalid gamespec.");
1815 error_message += L" (world_gameid="
1816 +narrow_to_wide(worldspec.gameid)+L")";
1817 errorstream<<wide_to_narrow(error_message)<<std::endl;
1826 // Break out of menu-game loop to shut down cleanly
1827 if(device->run() == false || kill == true)
1848 simple_singleplayer_mode
1852 catch(con::PeerNotFoundException &e)
1854 error_message = wgettext("Connection error (timed out?)");
1855 errorstream<<wide_to_narrow(error_message)<<std::endl;
1857 catch(ServerError &e)
1859 error_message = narrow_to_wide(e.what());
1860 errorstream<<wide_to_narrow(error_message)<<std::endl;
1864 errorstream<<e.what()<<std::endl;
1865 error_message = narrow_to_wide(e.what()) + wgettext("\nCheck debug.txt for details.");
1868 catch(std::exception &e)
1870 std::string narrow_message = "Some exception: \"";
1871 narrow_message += e.what();
1872 narrow_message += "\"";
1873 errorstream<<narrow_message<<std::endl;
1874 error_message = narrow_to_wide(narrow_message);
1878 // If no main menu, show error and exit
1881 if(error_message != L""){
1882 verbosestream<<"error_message = "
1883 <<wide_to_narrow(error_message)<<std::endl;
1893 In the end, delete the Irrlicht device.
1899 // Update configuration file
1900 if(configpath != "")
1901 g_settings->updateConfigFile(configpath.c_str());
1903 // Print modified quicktune values
1905 bool header_printed = false;
1906 std::vector<std::string> names = getQuicktuneNames();
1907 for(u32 i=0; i<names.size(); i++){
1908 QuicktuneValue val = getQuicktuneValue(names[i]);
1911 if(!header_printed){
1912 dstream<<"Modified quicktune values:"<<std::endl;
1913 header_printed = true;
1915 dstream<<names[i]<<" = "<<val.getString()<<std::endl;
1919 END_DEBUG_EXCEPTION_HANDLER(errorstream)
1921 debugstreams_deinit();