From 8b6cce18cb90014e4e8e4c491b0c06def4982c13 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 11 Mar 2012 12:06:59 +0200 Subject: Improve command-line parameters --- doc/minetest.6 | 31 ++++++--- doc/minetestserver.6 | 18 +++-- src/game.cpp | 14 +++- src/main.cpp | 192 ++++++++++++++++++++++++++------------------------- 4 files changed, 144 insertions(+), 111 deletions(-) diff --git a/doc/minetest.6 b/doc/minetest.6 index ef425a6df..fe260da08 100644 --- a/doc/minetest.6 +++ b/doc/minetest.6 @@ -1,5 +1,5 @@ .\" Minetest man page -.TH minetest 6 "29 January 2012" "" "" +.TH minetest 6 "11 March 2012" "" "" .SH NAME minetest \- Multiplayer infinite-world block sandbox @@ -28,26 +28,41 @@ Disable unit tests \-\-enable\-unittests Enable unit tests .TP +\-\-go +Disable main menu +.TP \-\-help Show allowed options .TP -\-\-info\-on\-stderr -Print debug information to console +\-\-logfile +Set logfile path (debug.txt) .TP \-\-map\-dir -Map directory (where everything in the world is stored) +Same as --world (deprecated) +.TP +\-\-name +Set player name +.TP +\-\-password +Set password .TP \-\-port -Set network port to connect to +Set network port (UDP) to use .TP \-\-random\-input Enable random user input, for testing .TP \-\-server -Run server directly +Run dedicated server .TP \-\-speedtests Run speed tests +.TP +\-\-verbose +Print more information to console +.TP +\-\-world +Set world path .SH BUGS Please report all bugs to Perttu Ahola . @@ -57,11 +72,11 @@ Please report all bugs to Perttu Ahola . Perttu Ahola and contributors. .PP -This man page was written by +This man page was originally written by Juhani Numminen . .SH WWW http://c55.me/minetest/ .SH "SEE ALSO" -.BR minetestserver(6) \ No newline at end of file +.BR minetestserver(6) diff --git a/doc/minetestserver.6 b/doc/minetestserver.6 index 9540e2c42..0db7e3863 100644 --- a/doc/minetestserver.6 +++ b/doc/minetestserver.6 @@ -1,5 +1,5 @@ .\" Minetestserver man page -.TH minetestserver 6 "29 January 2012" "" "" +.TH minetestserver 6 "11 March 2012" "" "" .SH NAME minetestserver \- Minetest server @@ -28,14 +28,20 @@ Enable unit tests \-\-help Show allowed options .TP -\-\-info\-on\-stderr -Print debug information to console +\-\-logfile +Set logfile path (debug.txt) .TP \-\-map\-dir -Map directory (where everything in the world is stored) +Same as --world (deprecated) .TP \-\-port Set network port (UDP) to use +.TP +\-\-verbose +Print more information to console +.TP +\-\-world +Set world path .SH BUGS Please report all bugs to Perttu Ahola . @@ -45,11 +51,11 @@ Please report all bugs to Perttu Ahola . Perttu Ahola and contributors. .PP -This man page was written by +This man page was originally written by Juhani Numminen . .SH WWW http://c55.me/minetest/ .SH "SEE ALSO" -.BR minetest(6) \ No newline at end of file +.BR minetest(6) diff --git a/src/game.cpp b/src/game.cpp index 1c5b065ba..6dbbd43df 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -737,8 +737,8 @@ void the_game( } catch(ResolveError &e) { - errorstream<<"Couldn't resolve address"<wasKeyDown(EscapeKey)){ connect_aborted = true; + infostream<<"Connect aborted [Escape]"<wasKeyDown(EscapeKey)){ content_aborted = true; + infostream<<"Connect aborted [Escape]"<get("address"); if(cmd_args.exists("address")) - { address = cmd_args.get("address"); - } - else - { - address = g_settings->get("address"); - } std::string playername = g_settings->get("name"); + if(cmd_args.exists("name")) + playername = cmd_args.get("name"); + + bool skip_main_menu = cmd_args.getFlag("go"); /* Device initialization @@ -1193,98 +1201,84 @@ int main(int argc, char *argv[]) menudata.opaque_water = g_settings->getBool("opaque_water"); menudata.creative_mode = g_settings->getBool("creative_mode"); menudata.enable_damage = g_settings->getBool("enable_damage"); + if(cmd_args.exists("password")) + menudata.password = narrow_to_wide(cmd_args.get("password")); - GUIMainMenu *menu = - new GUIMainMenu(guienv, guiroot, -1, - &g_menumgr, &menudata, g_gamecallback); - menu->allowFocusRemoval(true); - - if(error_message != L"") + if(skip_main_menu == false) { - errorstream<<"error_message = " - <drop(); - error_message = L""; - } - - video::IVideoDriver* driver = device->getVideoDriver(); - - infostream<<"Created main menu"<run() && kill == false) - { - if(menu->getStatus() == true) - break; - - //driver->beginScene(true, true, video::SColor(255,0,0,0)); - driver->beginScene(true, true, video::SColor(255,128,128,128)); - - drawMenuBackground(driver); - - guienv->drawAll(); + GUIMainMenu *menu = + new GUIMainMenu(guienv, guiroot, -1, + &g_menumgr, &menudata, g_gamecallback); + menu->allowFocusRemoval(true); + + if(error_message != L"") + { + verbosestream<<"error_message = " + <drop(); + error_message = L""; + } + + video::IVideoDriver* driver = device->getVideoDriver(); - driver->endScene(); + infostream<<"Created main menu"<run() && kill == false) + { + if(menu->getStatus() == true) + break; + + //driver->beginScene(true, true, video::SColor(255,0,0,0)); + driver->beginScene(true, true, video::SColor(255,128,128,128)); + + drawMenuBackground(driver); + + guienv->drawAll(); + + driver->endScene(); + + // On some computers framerate doesn't seem to be + // automatically limited + sleep_ms(25); + } - // On some computers framerate doesn't seem to be - // automatically limited - sleep_ms(25); - } - - // Break out of menu-game loop to shut down cleanly - if(device->run() == false || kill == true) - break; - - infostream<<"Dropping main menu"<run() == false || kill == true) + break; + + infostream<<"Dropping main menu"<drop(); - - // Delete map if requested - if(menudata.delete_map) - { - bool r = fs::RecursiveDeleteContent(map_dir); - if(r == false) - error_message = L"Delete failed"; - continue; + menu->drop(); + + // Delete map if requested + if(menudata.delete_map) + { + bool r = fs::RecursiveDeleteContent(map_dir); + if(r == false) + error_message = L"Delete failed"; + continue; + } } playername = wide_to_narrow(menudata.name); - password = translatePassword(playername, menudata.password); - //infostream<<"Main: password hash: '"<set("new_style_leaves", itos(menudata.fancy_trees)); g_settings->set("smooth_lighting", itos(menudata.smooth_lighting)); g_settings->set("enable_3d_clouds", itos(menudata.clouds_3d)); g_settings->set("opaque_water", itos(menudata.opaque_water)); g_settings->set("creative_mode", itos(menudata.creative_mode)); g_settings->set("enable_damage", itos(menudata.enable_damage)); - - // NOTE: These are now checked server side; no need to do it - // here, so let's not do it here. - /*// Check for valid parameters, restart menu if invalid. - if(playername == "") - { - error_message = L"Name required."; - continue; - } - // Check that name has only valid chars - if(string_allowed(playername, PLAYERNAME_ALLOWED_CHARS)==false) - { - error_message = L"Characters allowed: " - +narrow_to_wide(PLAYERNAME_ALLOWED_CHARS); - continue; - }*/ - - // Save settings g_settings->set("name", playername); g_settings->set("address", address); g_settings->set("port", itos(port)); @@ -1346,6 +1340,16 @@ int main(int argc, char *argv[]) } #endif + // If no main menu, show error and exit + if(skip_main_menu) + { + if(error_message != L""){ + verbosestream<<"error_message = " + <