mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Add command line option to load password from file (#7832)
This commit is contained in:
parent
80eb762af1
commit
b7eb81fed9
@ -75,6 +75,9 @@ Set player name
|
|||||||
.B \-\-password <value>
|
.B \-\-password <value>
|
||||||
Set password
|
Set password
|
||||||
.TP
|
.TP
|
||||||
|
.B \-\-password\-file <value>
|
||||||
|
Set password from contents of file
|
||||||
|
.TP
|
||||||
.B \-\-random\-input
|
.B \-\-random\-input
|
||||||
Enable random user input, for testing (client only)
|
Enable random user input, for testing (client only)
|
||||||
.TP
|
.TP
|
||||||
|
@ -392,6 +392,20 @@ bool ClientLauncher::launch_game(std::string &error_message,
|
|||||||
if (cmd_args.exists("password"))
|
if (cmd_args.exists("password"))
|
||||||
menudata.password = cmd_args.get("password");
|
menudata.password = cmd_args.get("password");
|
||||||
|
|
||||||
|
|
||||||
|
if (cmd_args.exists("password-file")) {
|
||||||
|
std::ifstream passfile(cmd_args.get("password-file"));
|
||||||
|
if (passfile.good()) {
|
||||||
|
getline(passfile, menudata.password);
|
||||||
|
} else {
|
||||||
|
error_message = gettext("Provided password file "
|
||||||
|
"failed to open: ")
|
||||||
|
+ cmd_args.get("password-file");
|
||||||
|
errorstream << error_message << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If a world was commanded, append and select it
|
// If a world was commanded, append and select it
|
||||||
if (!game_params.world_path.empty()) {
|
if (!game_params.world_path.empty()) {
|
||||||
worldspec.gameid = getWorldGameId(game_params.world_path, true);
|
worldspec.gameid = getWorldGameId(game_params.world_path, true);
|
||||||
|
@ -308,6 +308,8 @@ static void set_allowed_options(OptionList *allowed_options)
|
|||||||
_("Set player name"))));
|
_("Set player name"))));
|
||||||
allowed_options->insert(std::make_pair("password", ValueSpec(VALUETYPE_STRING,
|
allowed_options->insert(std::make_pair("password", ValueSpec(VALUETYPE_STRING,
|
||||||
_("Set password"))));
|
_("Set password"))));
|
||||||
|
allowed_options->insert(std::make_pair("password-file", ValueSpec(VALUETYPE_STRING,
|
||||||
|
_("Set password from contents of file"))));
|
||||||
allowed_options->insert(std::make_pair("go", ValueSpec(VALUETYPE_FLAG,
|
allowed_options->insert(std::make_pair("go", ValueSpec(VALUETYPE_FLAG,
|
||||||
_("Disable main menu"))));
|
_("Disable main menu"))));
|
||||||
allowed_options->insert(std::make_pair("console", ValueSpec(VALUETYPE_FLAG,
|
allowed_options->insert(std::make_pair("console", ValueSpec(VALUETYPE_FLAG,
|
||||||
|
Loading…
Reference in New Issue
Block a user