Add --init-user for server owner to save player profile without gui

This commit is contained in:
Benau 2018-07-07 12:32:06 +08:00
parent 21842f78d8
commit 21ccf587c3
2 changed files with 22 additions and 4 deletions

View File

@ -326,8 +326,9 @@ void PlayerManager::enforceCurrentPlayer()
{
if (!player->isGuestAccount())
{
Log::info("PlayerManager", "Enforcing current player '%ls'.",
player->getName(true/*ignoreRTL*/).c_str());
Log::info("PlayerManager", "Enforcing current player '%s'.",
StringUtils::wideToUtf8(player->getName(true/*ignoreRTL*/))
.c_str());
m_current_player = player;
return;
}
@ -341,7 +342,8 @@ void PlayerManager::enforceCurrentPlayer()
if (!player->isGuestAccount())
{
Log::info("PlayerManager", "Enforcing current player '%s'.",
player->getName(true/*ignoreRTL*/).c_str());
StringUtils::wideToUtf8(player->getName(true/*ignoreRTL*/))
.c_str());
m_current_player = player;
return;
}

View File

@ -597,6 +597,7 @@ void cmdLineHelp()
" public port.\n"
" --login=s Automatically log in (set the login).\n"
" --password=s Automatically log in (set the password).\n"
" --init-user Save the above login and password (if set) in config.\n"
" --port=n Port number to use.\n"
" --disable-lan Disable LAN detection (connect using WAN).\n"
" --auto-connect Automatically connect to fist server and start race\n"
@ -1031,6 +1032,13 @@ int handleCmdLine()
}
} // --type
bool init_user = CommandLine::has("--init-user");
if (init_user)
{
PlayerManager::get()->enforceCurrentPlayer();
PlayerManager::getCurrentPlayer()->setRememberPassword(true);
UserConfigParams::m_internet_status = Online::RequestManager::IPERM_ALLOWED;
}
if (CommandLine::has("--login", &s))
login = s.c_str();
if (CommandLine::has("--password", &s))
@ -1047,8 +1055,16 @@ int handleCmdLine()
StkTime::sleep(1);
}
Log::info("Main", "Logged in from command-line.");
if (init_user)
PlayerManager::getCurrentPlayer()->setWasOnlineLastTime(true);
can_wan = true;
}
if (init_user)
{
Log::info("Main", "Done saving user, leaving");
cleanSuperTuxKart();
return false;
}
if (!can_wan && CommandLine::has("--login-id", &n) &&
CommandLine::has("--token", &s))
@ -1664,12 +1680,12 @@ void askForInternetPermission()
// than sorry). If internet should be allowed, the news
// manager needs to be started (which in turn activates
// the add-ons manager).
#ifndef SERVER_ONLY
bool need_to_start_news_manager =
UserConfigParams::m_internet_status !=
Online::RequestManager::IPERM_ALLOWED;
UserConfigParams::m_internet_status =
Online::RequestManager::IPERM_ALLOWED;
#ifndef SERVER_ONLY
if (need_to_start_news_manager)
NewsManager::get()->init(false);
#endif