mirror of
https://github.com/minetest/minetest.git
synced 2024-10-27 11:09:25 +01:00
Improve command-line parameters
This commit is contained in:
parent
d330430336
commit
8b6cce18cb
@ -1,5 +1,5 @@
|
|||||||
.\" Minetest man page
|
.\" Minetest man page
|
||||||
.TH minetest 6 "29 January 2012" "" ""
|
.TH minetest 6 "11 March 2012" "" ""
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
minetest \- Multiplayer infinite-world block sandbox
|
minetest \- Multiplayer infinite-world block sandbox
|
||||||
@ -28,26 +28,41 @@ Disable unit tests
|
|||||||
\-\-enable\-unittests
|
\-\-enable\-unittests
|
||||||
Enable unit tests
|
Enable unit tests
|
||||||
.TP
|
.TP
|
||||||
|
\-\-go
|
||||||
|
Disable main menu
|
||||||
|
.TP
|
||||||
\-\-help
|
\-\-help
|
||||||
Show allowed options
|
Show allowed options
|
||||||
.TP
|
.TP
|
||||||
\-\-info\-on\-stderr
|
\-\-logfile <value>
|
||||||
Print debug information to console
|
Set logfile path (debug.txt)
|
||||||
.TP
|
.TP
|
||||||
\-\-map\-dir <value>
|
\-\-map\-dir <value>
|
||||||
Map directory (where everything in the world is stored)
|
Same as --world (deprecated)
|
||||||
|
.TP
|
||||||
|
\-\-name <value>
|
||||||
|
Set player name
|
||||||
|
.TP
|
||||||
|
\-\-password <value>
|
||||||
|
Set password
|
||||||
.TP
|
.TP
|
||||||
\-\-port <value>
|
\-\-port <value>
|
||||||
Set network port to connect to
|
Set network port (UDP) to use
|
||||||
.TP
|
.TP
|
||||||
\-\-random\-input
|
\-\-random\-input
|
||||||
Enable random user input, for testing
|
Enable random user input, for testing
|
||||||
.TP
|
.TP
|
||||||
\-\-server
|
\-\-server
|
||||||
Run server directly
|
Run dedicated server
|
||||||
.TP
|
.TP
|
||||||
\-\-speedtests
|
\-\-speedtests
|
||||||
Run speed tests
|
Run speed tests
|
||||||
|
.TP
|
||||||
|
\-\-verbose
|
||||||
|
Print more information to console
|
||||||
|
.TP
|
||||||
|
\-\-world <value>
|
||||||
|
Set world path
|
||||||
|
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Please report all bugs to Perttu Ahola <celeron55@gmail.com>.
|
Please report all bugs to Perttu Ahola <celeron55@gmail.com>.
|
||||||
@ -57,7 +72,7 @@ Please report all bugs to Perttu Ahola <celeron55@gmail.com>.
|
|||||||
Perttu Ahola <celeron55@gmail.com>
|
Perttu Ahola <celeron55@gmail.com>
|
||||||
and contributors.
|
and contributors.
|
||||||
.PP
|
.PP
|
||||||
This man page was written by
|
This man page was originally written by
|
||||||
Juhani Numminen <juhaninumminen0@gmail.com>.
|
Juhani Numminen <juhaninumminen0@gmail.com>.
|
||||||
|
|
||||||
.SH WWW
|
.SH WWW
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
.\" Minetestserver man page
|
.\" Minetestserver man page
|
||||||
.TH minetestserver 6 "29 January 2012" "" ""
|
.TH minetestserver 6 "11 March 2012" "" ""
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
minetestserver \- Minetest server
|
minetestserver \- Minetest server
|
||||||
@ -28,14 +28,20 @@ Enable unit tests
|
|||||||
\-\-help
|
\-\-help
|
||||||
Show allowed options
|
Show allowed options
|
||||||
.TP
|
.TP
|
||||||
\-\-info\-on\-stderr
|
\-\-logfile <value>
|
||||||
Print debug information to console
|
Set logfile path (debug.txt)
|
||||||
.TP
|
.TP
|
||||||
\-\-map\-dir <value>
|
\-\-map\-dir <value>
|
||||||
Map directory (where everything in the world is stored)
|
Same as --world (deprecated)
|
||||||
.TP
|
.TP
|
||||||
\-\-port <value>
|
\-\-port <value>
|
||||||
Set network port (UDP) to use
|
Set network port (UDP) to use
|
||||||
|
.TP
|
||||||
|
\-\-verbose
|
||||||
|
Print more information to console
|
||||||
|
.TP
|
||||||
|
\-\-world <value>
|
||||||
|
Set world path
|
||||||
|
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Please report all bugs to Perttu Ahola <celeron55@gmail.com>.
|
Please report all bugs to Perttu Ahola <celeron55@gmail.com>.
|
||||||
@ -45,7 +51,7 @@ Please report all bugs to Perttu Ahola <celeron55@gmail.com>.
|
|||||||
Perttu Ahola <celeron55@gmail.com>
|
Perttu Ahola <celeron55@gmail.com>
|
||||||
and contributors.
|
and contributors.
|
||||||
.PP
|
.PP
|
||||||
This man page was written by
|
This man page was originally written by
|
||||||
Juhani Numminen <juhaninumminen0@gmail.com>.
|
Juhani Numminen <juhaninumminen0@gmail.com>.
|
||||||
|
|
||||||
.SH WWW
|
.SH WWW
|
||||||
|
14
src/game.cpp
14
src/game.cpp
@ -737,8 +737,8 @@ void the_game(
|
|||||||
}
|
}
|
||||||
catch(ResolveError &e)
|
catch(ResolveError &e)
|
||||||
{
|
{
|
||||||
errorstream<<"Couldn't resolve address"<<std::endl;
|
|
||||||
error_message = L"Couldn't resolve address";
|
error_message = L"Couldn't resolve address";
|
||||||
|
errorstream<<wide_to_narrow(error_message)<<std::endl;
|
||||||
// Break out of client scope
|
// Break out of client scope
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -777,10 +777,12 @@ void the_game(
|
|||||||
if(client.accessDenied()){
|
if(client.accessDenied()){
|
||||||
error_message = L"Access denied. Reason: "
|
error_message = L"Access denied. Reason: "
|
||||||
+client.accessDeniedReason();
|
+client.accessDeniedReason();
|
||||||
|
errorstream<<wide_to_narrow(error_message)<<std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(input->wasKeyDown(EscapeKey)){
|
if(input->wasKeyDown(EscapeKey)){
|
||||||
connect_aborted = true;
|
connect_aborted = true;
|
||||||
|
infostream<<"Connect aborted [Escape]"<<std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -803,8 +805,10 @@ void the_game(
|
|||||||
Handle failure to connect
|
Handle failure to connect
|
||||||
*/
|
*/
|
||||||
if(!could_connect){
|
if(!could_connect){
|
||||||
if(error_message == L"" && !connect_aborted)
|
if(error_message == L"" && !connect_aborted){
|
||||||
error_message = L"Connection failed";
|
error_message = L"Connection failed";
|
||||||
|
errorstream<<wide_to_narrow(error_message)<<std::endl;
|
||||||
|
}
|
||||||
// Break out of client scope
|
// Break out of client scope
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -835,10 +839,12 @@ void the_game(
|
|||||||
// Break conditions
|
// Break conditions
|
||||||
if(!client.connectedAndInitialized()){
|
if(!client.connectedAndInitialized()){
|
||||||
error_message = L"Client disconnected";
|
error_message = L"Client disconnected";
|
||||||
|
errorstream<<wide_to_narrow(error_message)<<std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(input->wasKeyDown(EscapeKey)){
|
if(input->wasKeyDown(EscapeKey)){
|
||||||
content_aborted = true;
|
content_aborted = true;
|
||||||
|
infostream<<"Connect aborted [Escape]"<<std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -863,8 +869,10 @@ void the_game(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!got_content){
|
if(!got_content){
|
||||||
if(error_message == L"" && !content_aborted)
|
if(error_message == L"" && !content_aborted){
|
||||||
error_message = L"Something failed";
|
error_message = L"Something failed";
|
||||||
|
errorstream<<wide_to_narrow(error_message)<<std::endl;
|
||||||
|
}
|
||||||
// Break out of client scope
|
// Break out of client scope
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
90
src/main.cpp
90
src/main.cpp
@ -741,6 +741,8 @@ void SpeedTests()
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
int retval = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Initialization
|
Initialization
|
||||||
*/
|
*/
|
||||||
@ -766,26 +768,34 @@ int main(int argc, char *argv[])
|
|||||||
allowed_options.insert("config", ValueSpec(VALUETYPE_STRING,
|
allowed_options.insert("config", ValueSpec(VALUETYPE_STRING,
|
||||||
"Load configuration from specified file"));
|
"Load configuration from specified file"));
|
||||||
allowed_options.insert("port", ValueSpec(VALUETYPE_STRING,
|
allowed_options.insert("port", ValueSpec(VALUETYPE_STRING,
|
||||||
"Set network port (UDP) to use"));
|
"Set network port (UDP)"));
|
||||||
allowed_options.insert("disable-unittests", ValueSpec(VALUETYPE_FLAG,
|
allowed_options.insert("disable-unittests", ValueSpec(VALUETYPE_FLAG,
|
||||||
"Disable unit tests"));
|
"Disable unit tests"));
|
||||||
allowed_options.insert("enable-unittests", ValueSpec(VALUETYPE_FLAG,
|
allowed_options.insert("enable-unittests", ValueSpec(VALUETYPE_FLAG,
|
||||||
"Enable unit tests"));
|
"Enable unit tests"));
|
||||||
allowed_options.insert("map-dir", ValueSpec(VALUETYPE_STRING,
|
allowed_options.insert("map-dir", ValueSpec(VALUETYPE_STRING,
|
||||||
"Map directory (where everything in the world is stored)"));
|
"Same as --world (deprecated)"));
|
||||||
allowed_options.insert("info-on-stderr", ValueSpec(VALUETYPE_FLAG,
|
allowed_options.insert("world", ValueSpec(VALUETYPE_STRING,
|
||||||
"Print more information to console (deprecated; use --verbose)"));
|
"Set world path"));
|
||||||
allowed_options.insert("verbose", ValueSpec(VALUETYPE_FLAG,
|
allowed_options.insert("verbose", ValueSpec(VALUETYPE_FLAG,
|
||||||
"Print more information to console"));
|
"Print more information to console"));
|
||||||
|
allowed_options.insert("logfile", ValueSpec(VALUETYPE_STRING,
|
||||||
|
"Set logfile path (debug.txt)"));
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
allowed_options.insert("speedtests", ValueSpec(VALUETYPE_FLAG,
|
allowed_options.insert("speedtests", ValueSpec(VALUETYPE_FLAG,
|
||||||
"Run speed tests"));
|
"Run speed tests"));
|
||||||
allowed_options.insert("address", ValueSpec(VALUETYPE_STRING,
|
allowed_options.insert("address", ValueSpec(VALUETYPE_STRING,
|
||||||
"Address to connect to"));
|
"Address to connect to. ('' = local game)"));
|
||||||
allowed_options.insert("random-input", ValueSpec(VALUETYPE_FLAG,
|
allowed_options.insert("random-input", ValueSpec(VALUETYPE_FLAG,
|
||||||
"Enable random user input, for testing"));
|
"Enable random user input, for testing"));
|
||||||
allowed_options.insert("server", ValueSpec(VALUETYPE_FLAG,
|
allowed_options.insert("server", ValueSpec(VALUETYPE_FLAG,
|
||||||
"Run server directly"));
|
"Run dedicated server"));
|
||||||
|
allowed_options.insert("name", ValueSpec(VALUETYPE_STRING,
|
||||||
|
"Set player name"));
|
||||||
|
allowed_options.insert("password", ValueSpec(VALUETYPE_STRING,
|
||||||
|
"Set password"));
|
||||||
|
allowed_options.insert("go", ValueSpec(VALUETYPE_FLAG,
|
||||||
|
"Disable main menu"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Settings cmd_args;
|
Settings cmd_args;
|
||||||
@ -819,9 +829,8 @@ int main(int argc, char *argv[])
|
|||||||
Low-level initialization
|
Low-level initialization
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(cmd_args.getFlag("verbose") ||
|
// In certain cases, output info level on stderr
|
||||||
cmd_args.getFlag("info-on-stderr") ||
|
if(cmd_args.getFlag("verbose") || cmd_args.getFlag("speedtests"))
|
||||||
cmd_args.getFlag("speedtests"))
|
|
||||||
log_add_output(&main_stderr_log_out, LMT_INFO);
|
log_add_output(&main_stderr_log_out, LMT_INFO);
|
||||||
|
|
||||||
porting::signal_handler_init();
|
porting::signal_handler_init();
|
||||||
@ -836,17 +845,20 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Initialize debug streams
|
// Initialize debug streams
|
||||||
#ifdef RUN_IN_PLACE
|
#ifdef RUN_IN_PLACE
|
||||||
std::string debugfile = DEBUGFILE;
|
std::string logfile = DEBUGFILE;
|
||||||
#else
|
#else
|
||||||
std::string debugfile = porting::path_user+DIR_DELIM+DEBUGFILE;
|
std::string logfile = porting::path_user+DIR_DELIM+DEBUGFILE;
|
||||||
#endif
|
#endif
|
||||||
|
if(cmd_args.exists("logfile"))
|
||||||
|
logfile = cmd_args.get("logfile");
|
||||||
bool disable_stderr = false;
|
bool disable_stderr = false;
|
||||||
debugstreams_init(disable_stderr, debugfile.c_str());
|
debugstreams_init(disable_stderr, logfile.c_str());
|
||||||
// Initialize debug stacks
|
// Initialize debug stacks
|
||||||
debug_stacks_init();
|
debug_stacks_init();
|
||||||
|
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
|
dstream<<"logfile = "<<logfile<<std::endl;
|
||||||
dstream<<"path_share = "<<porting::path_share<<std::endl;
|
dstream<<"path_share = "<<porting::path_share<<std::endl;
|
||||||
dstream<<"path_user = "<<porting::path_user<<std::endl;
|
dstream<<"path_user = "<<porting::path_user<<std::endl;
|
||||||
|
|
||||||
@ -994,19 +1006,15 @@ int main(int argc, char *argv[])
|
|||||||
More parameters
|
More parameters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Address to connect to
|
std::string address = g_settings->get("address");
|
||||||
std::string address = "";
|
|
||||||
|
|
||||||
if(cmd_args.exists("address"))
|
if(cmd_args.exists("address"))
|
||||||
{
|
|
||||||
address = cmd_args.get("address");
|
address = cmd_args.get("address");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
address = g_settings->get("address");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string playername = g_settings->get("name");
|
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
|
Device initialization
|
||||||
@ -1193,7 +1201,11 @@ int main(int argc, char *argv[])
|
|||||||
menudata.opaque_water = g_settings->getBool("opaque_water");
|
menudata.opaque_water = g_settings->getBool("opaque_water");
|
||||||
menudata.creative_mode = g_settings->getBool("creative_mode");
|
menudata.creative_mode = g_settings->getBool("creative_mode");
|
||||||
menudata.enable_damage = g_settings->getBool("enable_damage");
|
menudata.enable_damage = g_settings->getBool("enable_damage");
|
||||||
|
if(cmd_args.exists("password"))
|
||||||
|
menudata.password = narrow_to_wide(cmd_args.get("password"));
|
||||||
|
|
||||||
|
if(skip_main_menu == false)
|
||||||
|
{
|
||||||
GUIMainMenu *menu =
|
GUIMainMenu *menu =
|
||||||
new GUIMainMenu(guienv, guiroot, -1,
|
new GUIMainMenu(guienv, guiroot, -1,
|
||||||
&g_menumgr, &menudata, g_gamecallback);
|
&g_menumgr, &menudata, g_gamecallback);
|
||||||
@ -1201,7 +1213,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if(error_message != L"")
|
if(error_message != L"")
|
||||||
{
|
{
|
||||||
errorstream<<"error_message = "
|
verbosestream<<"error_message = "
|
||||||
<<wide_to_narrow(error_message)<<std::endl;
|
<<wide_to_narrow(error_message)<<std::endl;
|
||||||
|
|
||||||
GUIMessageMenu *menu2 =
|
GUIMessageMenu *menu2 =
|
||||||
@ -1250,41 +1262,23 @@ int main(int argc, char *argv[])
|
|||||||
error_message = L"Delete failed";
|
error_message = L"Delete failed";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
playername = wide_to_narrow(menudata.name);
|
playername = wide_to_narrow(menudata.name);
|
||||||
|
|
||||||
password = translatePassword(playername, menudata.password);
|
password = translatePassword(playername, menudata.password);
|
||||||
|
|
||||||
//infostream<<"Main: password hash: '"<<password<<"'"<<std::endl;
|
//infostream<<"Main: password hash: '"<<password<<"'"<<std::endl;
|
||||||
|
|
||||||
address = wide_to_narrow(menudata.address);
|
address = wide_to_narrow(menudata.address);
|
||||||
int newport = stoi(wide_to_narrow(menudata.port));
|
int newport = stoi(wide_to_narrow(menudata.port));
|
||||||
if(newport != 0)
|
if(newport != 0)
|
||||||
port = newport;
|
port = newport;
|
||||||
|
// Save settings
|
||||||
g_settings->set("new_style_leaves", itos(menudata.fancy_trees));
|
g_settings->set("new_style_leaves", itos(menudata.fancy_trees));
|
||||||
g_settings->set("smooth_lighting", itos(menudata.smooth_lighting));
|
g_settings->set("smooth_lighting", itos(menudata.smooth_lighting));
|
||||||
g_settings->set("enable_3d_clouds", itos(menudata.clouds_3d));
|
g_settings->set("enable_3d_clouds", itos(menudata.clouds_3d));
|
||||||
g_settings->set("opaque_water", itos(menudata.opaque_water));
|
g_settings->set("opaque_water", itos(menudata.opaque_water));
|
||||||
g_settings->set("creative_mode", itos(menudata.creative_mode));
|
g_settings->set("creative_mode", itos(menudata.creative_mode));
|
||||||
g_settings->set("enable_damage", itos(menudata.enable_damage));
|
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("name", playername);
|
||||||
g_settings->set("address", address);
|
g_settings->set("address", address);
|
||||||
g_settings->set("port", itos(port));
|
g_settings->set("port", itos(port));
|
||||||
@ -1346,6 +1340,16 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// If no main menu, show error and exit
|
||||||
|
if(skip_main_menu)
|
||||||
|
{
|
||||||
|
if(error_message != L""){
|
||||||
|
verbosestream<<"error_message = "
|
||||||
|
<<wide_to_narrow(error_message)<<std::endl;
|
||||||
|
retval = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
} // Menu-game loop
|
} // Menu-game loop
|
||||||
|
|
||||||
delete input;
|
delete input;
|
||||||
@ -1365,7 +1369,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
debugstreams_deinit();
|
debugstreams_deinit();
|
||||||
|
|
||||||
return 0;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
//END
|
//END
|
||||||
|
Loading…
Reference in New Issue
Block a user