From 926422412304afdf52f4d9bfd01165d7560abd62 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Tue, 7 Jul 2015 18:56:51 -0400 Subject: [PATCH] Allow internal clients to start in any age. Usage: plClient.exe /PlayerId=[kinum] /Age=[agefilename] --- Sources/Plasma/Apps/plClient/winmain.cpp | 12 ++++-- .../plNetClientComm/plNetClientComm.cpp | 42 ++++++++----------- .../plNetClientComm/plNetClientComm.h | 3 +- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/winmain.cpp b/Sources/Plasma/Apps/plClient/winmain.cpp index 458d5b6d..052f7bcf 100644 --- a/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/Sources/Plasma/Apps/plClient/winmain.cpp @@ -94,7 +94,9 @@ enum kArgSkipLoginDialog, kArgServerIni, kArgLocalData, - kArgSkipPreload + kArgSkipPreload, + kArgPlayerId, + kArgStartUpAgeName, }; static const plCmdArgDef s_cmdLineArgs[] = { @@ -102,6 +104,8 @@ static const plCmdArgDef s_cmdLineArgs[] = { { kCmdArgFlagged | kCmdTypeString, "ServerIni", kArgServerIni }, { kCmdArgFlagged | kCmdTypeBool, "LocalData", kArgLocalData }, { kCmdArgFlagged | kCmdTypeBool, "SkipPreload", kArgSkipPreload }, + { kCmdArgFlagged | kCmdTypeInt, "PlayerId", kArgPlayerId }, + { kCmdArgFlagged | kCmdTypeString, "Age", kArgStartUpAgeName }, }; /// Made globals now, so we can set them to zero if we take the border and @@ -1153,6 +1157,10 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC } if (cmdParser.IsSpecified(kArgSkipPreload)) gSkipPreload = true; + if (cmdParser.IsSpecified(kArgPlayerId)) + NetCommSetIniPlayerId(cmdParser.GetInt(kArgPlayerId)); + if (cmdParser.IsSpecified(kArgStartUpAgeName)) + NetCommSetIniStartUpAge(cmdParser.GetString(kArgStartUpAgeName)); #endif plFileName serverIni = "server.ini"; @@ -1263,8 +1271,6 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC } NetCliAuthAutoReconnectEnable(false); - - NetCommSetReadIniAccountInfo(!doIntroDialogs); InitNetClientComm(); curl_global_init(CURL_GLOBAL_ALL); diff --git a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp index cf186275..9ae3b9c4 100644 --- a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp @@ -114,17 +114,14 @@ static ENetError s_authResult = kNetErrAuthenticationFailed; static plString s_authSrvAddr; static plString s_fileSrvAddr; -static char s_iniServerAddr[256]; -static char s_iniFileServerAddr[256]; static plString s_iniAccountUsername; -static ShaDigest s_namePassHash; -static wchar_t s_iniAuthToken[kMaxPublisherAuthKeyLength]; -static wchar_t s_iniOS[kMaxGTOSIdLength]; -static bool s_iniReadAccountInfo = true; -static plString s_iniStartupAgeName; -static plUUID s_iniStartupAgeInstId; -static plString s_iniStartupPlayerName; -static bool s_netError = false; +static ShaDigest s_namePassHash; +static wchar_t s_iniAuthToken[kMaxPublisherAuthKeyLength]; +static wchar_t s_iniOS[kMaxGTOSIdLength]; +static plString s_iniStartupAgeName = "StartUp"; +static plUUID s_iniStartupAgeInstId; +static unsigned s_iniStartupPlayerId = 0; +static bool s_netError = false; struct NetCommMsgHandler : THashKeyVal { @@ -408,7 +405,7 @@ static void INetCliAuthLoginRequestCallback ( s_players[i].explorer = playerInfoArr[i].explorer; s_players[i].playerName = playerInfoArr[i].playerName; s_players[i].avatarDatasetName = playerInfoArr[i].avatarShape; - if (!wantsStartUpAge && s_players[i].playerName.CompareI(s_iniStartupPlayerName) == 0) + if (!wantsStartUpAge && s_players[i].playerInt == s_iniStartupPlayerId) s_player = &s_players[i]; } @@ -700,6 +697,16 @@ bool NetCommIsLoginComplete() { return s_loginComplete; } +//============================================================================ +void NetCommSetIniPlayerId(unsigned playerId) { + s_iniStartupPlayerId = playerId; +} + +//============================================================================ +void NetCommSetIniStartUpAge(const plString& ageName) { + s_iniStartupAgeName = ageName; +} + //============================================================================ const NetCommAge * NetCommGetAge () { return &s_age; @@ -741,8 +748,6 @@ void NetCommStartup () { // Set startup age info memset(&s_startupAge, 0, sizeof(s_startupAge)); - - s_iniStartupAgeName = "StartUp"; s_startupAge.ageDatasetName = s_iniStartupAgeName; s_startupAge.ageInstId = s_iniStartupAgeInstId; @@ -1010,8 +1015,6 @@ void NetCommSetAccountUsernamePassword ( ) { s_iniAccountUsername = username; memcpy(s_namePassHash, namePassHash, sizeof(ShaDigest)); - - s_iniReadAccountInfo = false; } //============================================================================ @@ -1030,11 +1033,6 @@ ENetError NetCommGetAuthResult () { return s_authResult; } -//============================================================================ -void NetCommSetReadIniAccountInfo(bool readFromIni) { - s_iniReadAccountInfo = readFromIni; -} - //============================================================================ void NetCommAuthenticate ( void * param @@ -1105,10 +1103,6 @@ void NetCommSetActivePlayer (//--> plNetCommActivePlayerMsg s_player = &s_players[i]; break; } - else if (s_players[i].playerName.CompareI(s_iniStartupPlayerName) == 0) { - playerInt = s_players[i].playerInt; - s_player = &s_players[i]; - } } ASSERT(s_player); } diff --git a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h index b12821ec..4e2660e5 100644 --- a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h +++ b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h @@ -105,7 +105,8 @@ const NetCommPlayer * NetCommGetPlayer (); const ARRAY(NetCommPlayer) & NetCommGetPlayerList (); unsigned NetCommGetPlayerCount (); bool NetCommIsLoginComplete (); -void NetCommSetReadIniAccountInfo (bool readFromIni); +void NetCommSetIniPlayerId(unsigned playerId); +void NetCommSetIniStartUpAge(const plString& ageName); void NetCommSetAccountUsernamePassword (const plString& username, const ShaDigest & namePassHash); void NetCommSetAuthTokenAndOS (wchar_t authToken[], wchar_t os[]); ENetError NetCommGetAuthResult ();