Changed: cli character selection

--HG--
branch : develop
This commit is contained in:
Inky 2019-06-19 00:10:01 +03:00
parent 527d4bf00c
commit f17aeff6f2
3 changed files with 23 additions and 7 deletions

View file

@ -180,6 +180,7 @@ int main(int argc, char **argv)
Args.addAdditionalArg("login", "Login to use", true, false);
Args.addAdditionalArg("password", "Password to use", true, false);
Args.addAdditionalArg("shard_id", "Shard ID to use", true, false);
Args.addAdditionalArg("slot", "Char slot to use", true, false);
#ifdef TEST_CRASH_COUNTER
Args.addArg("", "crash", "", "Crash client before init");
@ -220,6 +221,12 @@ int main(int argc, char **argv)
if (Args.haveAdditionalArg("shard_id"))
sLoginShardId = Args.getAdditionalArg("shard_id").front();
if (Args.haveAdditionalArg("slot"))
{
if (!fromString(Args.getAdditionalArg("slot").front(), LoginCharsel))
LoginCharsel = -1;
}
}
}

View file

@ -144,14 +144,13 @@ ucstring PlayerSelectedHomeShardName;
ucstring PlayerSelectedHomeShardNameWithParenthesis;
extern std::string CurrentCookie;
ucstring NewKeysCharNameWanted; // name of the character for which a new keyset must be created
ucstring NewKeysCharNameValidated;
std::string GameKeySet = "keys.xml";
std::string RingEditorKeySet = "keys_r2ed.xml";
string ScenarioFileName;
sint LoginCharsel = -1;
static const char *KeySetVarName = "BuiltInKeySets";
@ -1095,8 +1094,15 @@ TInterfaceState globalMenu()
noUserChar = userChar = false;
if( FarTP.isReselectingChar() || !FarTP.isServerHopInProgress() ) // if doing a Server Hop, expect serverReceivedReady without action from the user
{
sint charSelect = -1;
if (ClientCfg.SelectCharacter != -1)
charSelect = ClientCfg.SelectCharacter;
if (LoginCharsel != -1)
charSelect = LoginCharsel;
WaitServerAnswer = false;
if (ClientCfg.SelectCharacter == -1)
if (charSelect == -1)
{
CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SERVER_RECEIVED_CHARS", false);
if (pNL != NULL)
@ -1112,7 +1118,7 @@ TInterfaceState globalMenu()
else
{
// check that the pre selected character is available
if (CharacterSummaries[ClientCfg.SelectCharacter].People == EGSPD::CPeople::Unknown)
if (CharacterSummaries[charSelect].People == EGSPD::CPeople::Unknown || charSelect > 4)
{
// BAD ! preselected char does not exist, use the first available or fail
uint i;
@ -1132,12 +1138,14 @@ TInterfaceState globalMenu()
if (ret == UDriver::noId)
exit(-1);
else
ClientCfg.SelectCharacter = i;
charSelect = i;
}
}
// Auto-selection for fast launching (dev only)
CAHManager::getInstance()->runActionHandler("launch_game", NULL, toString("slot=%d|edit_mode=0", ClientCfg.SelectCharacter));
CAHManager::getInstance()->runActionHandler("launch_game", NULL, toString("slot=%d|edit_mode=0", charSelect));
if (LoginCharsel == -1)
ClientCfg.SelectCharacter = charSelect;
}
}

View file

@ -34,6 +34,7 @@ extern ucstring PlayerSelectedHomeShardName; // The home shard name (aniro,
extern ucstring PlayerSelectedHomeShardNameWithParenthesis; // Same with parenthesis
extern std::vector<CCharacterSummary> CharacterSummaries;
extern std::string UserPrivileges;
extern sint LoginCharsel;
extern ucstring NewKeysCharNameWanted;
extern ucstring NewKeysCharNameValidated;