1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add command line option to load password from file (#7832)

This commit is contained in:
Kevin Abrams 2018-12-18 13:15:14 -06:00 committed by SmallJoker
parent 80eb762af1
commit b7eb81fed9
3 changed files with 19 additions and 0 deletions

View file

@ -392,6 +392,20 @@ bool ClientLauncher::launch_game(std::string &error_message,
if (cmd_args.exists("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 (!game_params.world_path.empty()) {
worldspec.gameid = getWorldGameId(game_params.world_path, true);