From 0717a9e792b0255902f63f499507ec399e4f7870 Mon Sep 17 00:00:00 2001 From: dpogue Date: Sat, 10 Aug 2024 20:09:07 -0700 Subject: [PATCH] Add server.ini support to Internal builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Michael Hansen Co-Authored-By: Adam Johnson Co-Authored-By: Florian Meißner --- .../NucleusLib/pnNetBase/pnNetBase.vcxproj | 6 +- .../pnNetBase/pnNetBase.vcxproj.filters | 18 +- Sources/Plasma/Apps/plClient/winmain.cpp | 71 +++- .../pfConsole/pfConsoleCommandsNet.cpp | 333 ++++++++++++++++++ .../FeatureLib/pfConsole/pfConsoleEngine.cpp | 174 ++++----- .../FeatureLib/pfConsole/pfConsoleEngine.h | 2 - .../pnNetBase/Private/pnNbAllIncludes.h | 1 + .../NucleusLib/pnNetBase/Private/pnNbKeys.cpp | 141 ++++++++ .../{pnNbAuthKey.hpp => Private/pnNbKeys.h} | 49 ++- .../NucleusLib/pnNetBase/Private/pnNbSrvs.cpp | 77 ++++ .../NucleusLib/pnNetBase/Private/pnNbSrvs.h | 14 + .../Plasma/NucleusLib/pnNetBase/pnNbConst.h | 4 - .../NucleusLib/pnNetBase/pnNbGameKey.hpp | 74 ---- .../NucleusLib/pnSimpleNet/pnSimpleNet.cpp | 8 +- .../NucleusLib/pnUtils/Private/pnUtBase64.cpp | 2 +- .../NucleusLib/pnUtils/Private/pnUtBase64.h | 9 +- .../plNetGameLib/Private/plNglAuth.cpp | 13 +- .../plNetGameLib/Private/plNglCsr.cpp | 13 +- .../plNetGameLib/Private/plNglFile.cpp | 8 +- .../plNetGameLib/Private/plNglGame.cpp | 9 +- .../plNetGameLib/Private/plNglGateKeeper.cpp | 13 +- 21 files changed, 781 insertions(+), 258 deletions(-) create mode 100644 Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbKeys.cpp rename Sources/Plasma/NucleusLib/pnNetBase/{pnNbAuthKey.hpp => Private/pnNbKeys.h} (60%) delete mode 100644 Sources/Plasma/NucleusLib/pnNetBase/pnNbGameKey.hpp diff --git a/Build/VS2010/Plasma/NucleusLib/pnNetBase/pnNetBase.vcxproj b/Build/VS2010/Plasma/NucleusLib/pnNetBase/pnNetBase.vcxproj index fbc1776f..196d83d2 100644 --- a/Build/VS2010/Plasma/NucleusLib/pnNetBase/pnNetBase.vcxproj +++ b/Build/VS2010/Plasma/NucleusLib/pnNetBase/pnNetBase.vcxproj @@ -167,20 +167,18 @@ - - - - + + diff --git a/Build/VS2010/Plasma/NucleusLib/pnNetBase/pnNetBase.vcxproj.filters b/Build/VS2010/Plasma/NucleusLib/pnNetBase/pnNetBase.vcxproj.filters index aacca62d..fc97a1f3 100644 --- a/Build/VS2010/Plasma/NucleusLib/pnNetBase/pnNetBase.vcxproj.filters +++ b/Build/VS2010/Plasma/NucleusLib/pnNetBase/pnNetBase.vcxproj.filters @@ -20,18 +20,6 @@ Header Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - Header Files @@ -53,6 +41,9 @@ Private + + Private + @@ -64,5 +55,8 @@ Private + + Private + \ No newline at end of file diff --git a/Sources/Plasma/Apps/plClient/winmain.cpp b/Sources/Plasma/Apps/plClient/winmain.cpp index 6cf77992..b12533ff 100644 --- a/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/Sources/Plasma/Apps/plClient/winmain.cpp @@ -72,6 +72,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "../plPhysX/plSimulationMgr.h" +#include "pfConsole/pfConsoleEngine.h" + #include "res\resource.h" #include @@ -112,6 +114,7 @@ enum kArgAuthSrv, kArgFileSrv, kArgGateKeeperSrv, + kArgServerIni, kArgLocalData, kArgBackgroundDownloader, }; @@ -122,6 +125,7 @@ static const CmdArgDef s_cmdLineArgs[] = { { kCmdArgFlagged | kCmdTypeString, L"AuthSrv", kArgAuthSrv }, { kCmdArgFlagged | kCmdTypeString, L"FileSrv", kArgFileSrv }, { kCmdArgFlagged | kCmdTypeString, L"GateKeeperSrv", kArgGateKeeperSrv }, + { kCmdArgFlagged | kCmdTypeString, L"ServerIni", kArgServerIni }, { kCmdArgFlagged | kCmdTypeBool, L"LocalData", kArgLocalData }, { kCmdArgFlagged | kCmdTypeBool, L"BGDownload", kArgBackgroundDownloader }, }; @@ -1321,13 +1325,13 @@ void StatusCallback(void *param) while(s_loginDlgRunning) { // get status message from webpage and display in status area. - const wchar *path = BuildTypeServerStatusPath(); + const wchar *path = GetServerStatusUrl(); if(path) { HINTERNET hSession = 0; HINTERNET hConnect = 0; HINTERNET hRequest = 0; - + hSession = WinHttpOpen( L"UruClient/1.0", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, @@ -1336,22 +1340,51 @@ void StatusCallback(void *param) ); if(hSession) { - HINTERNET hConnect = WinHttpConnect( hSession, STATUS_PATH, INTERNET_DEFAULT_HTTP_PORT, 0); + INTERNET_PORT port = INTERNET_DEFAULT_HTTP_PORT; + const wchar* truncpath = path; + + if (wcsncmp(path, L"http:", 5) == 0) { + truncpath += 7; + } else if (wcsncmp(path, L"https:", 6) == 0) { + port = INTERNET_DEFAULT_HTTPS_PORT; + truncpath += 8; + } + + const wchar* pathval = wcschr(truncpath, L'/'); + const wchar* portnum = wcschr(truncpath, L':'); + + wchar host[256]; + if (portnum != nil && portnum < pathval) { + int count = wcslen(truncpath) - wcslen(portnum); + wcsncpy(host, truncpath, count); + host[count] = L'\0'; + + unsigned long parsedport = wcstoul(portnum + 1, nil, 10); + if (parsedport != 0) { + port = (INTERNET_PORT)parsedport; + } + } else { + int count = wcslen(truncpath) - wcslen(pathval); + wcsncpy(host, truncpath, count); + host[count] = L'\0'; + } + + HINTERNET hConnect = WinHttpConnect( hSession, host, port, 0); if(hConnect) { HINTERNET hRequest = WinHttpOpenRequest( hConnect, L"GET", - path, + pathval, NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, - 0 + (port == INTERNET_DEFAULT_HTTPS_PORT ? WINHTTP_FLAG_SECURE : 0) ); if(hRequest) { static char data[256] = {0}; - DWORD bytesRead; + DWORD bytesRead = 0; if( WinHttpSendRequest( hRequest, @@ -1379,7 +1412,7 @@ void StatusCallback(void *param) } else break; // no status message - + for(unsigned i = 0; i < UPDATE_STATUSMSG_SECONDS && s_loginDlgRunning; ++i) { Sleep(1000); @@ -1528,7 +1561,8 @@ BOOL CALLBACK UruLoginDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM } else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_URULOGIN_GAMETAPLINK) { - ShellExecute(NULL, "open", "http://www.mystonline.com/signup.html", NULL, NULL, SW_SHOWNORMAL); + const wchar *signupurl = GetServerSignupUrl(); + ShellExecuteW(NULL, L"open", signupurl, NULL, NULL, SW_SHOWNORMAL); return TRUE; } @@ -1708,6 +1742,13 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC if(cmdParser.IsSpecified(kArgBackgroundDownloader)) gUseBackgroundDownloader = true; #endif + + const wchar *serverIni = nil; + if(cmdParser.IsSpecified(kArgServerIni)) + { + serverIni = cmdParser.GetString(kArgServerIni); + } + if(cmdParser.IsSpecified(kArgAuthSrv)) { SetAuthSrvHostname(cmdParser.GetString(kArgAuthSrv)); @@ -1810,6 +1851,20 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC return PARABLE_NORMAL_EXIT; } +#ifndef PLASMA_EXTERNAL_RELEASE + /////////<<<<<<<< + if (serverIni) { + FILE *serverIniFile = _wfopen(serverIni, L"rb"); + if (serverIniFile) + { + fclose(serverIniFile); + pfConsoleEngine tempConsole; + tempConsole.ExecuteFile(serverIni); + } + } + /////////<<<<<<<< +#endif + NetCliAuthAutoReconnectEnable(false); NetCommSetReadIniAccountInfo(!doIntroDialogs); diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp index 581a4a13..e2ab3a10 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp @@ -1071,3 +1071,336 @@ PF_CONSOLE_CMD( #endif /////////////////////////////////////// + +/***************************************************************************** +* +* Server +* +***/ + +#ifndef LIMIT_CONSOLE_COMMANDS + +//TODO: Fix Plasma to use OpenSSL's byte order (or better yet, to use OpenSSL), +// so this hack isn't needed +static void swap_key_bytes(byte keyData[]) +{ + for (size_t i = 0; i < (kNetDiffieHellmanKeyBits / 16); ++i) + std::swap(keyData[i], keyData[ (kNetDiffieHellmanKeyBits / 8) - i - 1 ]); +} + +//============================================================================ +// Server group +PF_CONSOLE_GROUP(Server) + +//============================================================================ +PF_CONSOLE_CMD( + Server, + Status, + "string url", + "Set the server's status URL" +) { + wchar_t *wurl = hsStringToWString((const char *)params[0]); + SetServerStatusUrl(wurl); + delete [] wurl; +} + +//============================================================================ +PF_CONSOLE_CMD( + Server, + Signup, + "string url", + "Set the server's new user sign-up URL" +) { + wchar_t *wurl = hsStringToWString((const char *)params[0]); + SetServerSignupUrl(wurl); + delete [] wurl; +} + +//============================================================================ +PF_CONSOLE_CMD( + Server, + DispName, + "string name", + "Set the displayable server name" +) { + wchar_t *wname = hsStringToWString((const char *)params[0]); + SetServerDisplayName(wname); + delete [] wname; +} + +//============================================================================ +PF_CONSOLE_CMD( + Server, + Port, + "int port", + "Set the server's port" +) { + SetClientPort((int)params[0]); +} + + +//============================================================================ +// Server.File group +PF_CONSOLE_SUBGROUP(Server, File) + +//============================================================================ +PF_CONSOLE_CMD( + Server_File, + Host, + "string address", + "Set the File Server address" +) { + wchar_t *wHost = hsStringToWString((const char *)params[0]); + SetFileSrvHostname(wHost); + delete [] wHost; +} + + +//============================================================================ +// Server.Auth group +PF_CONSOLE_SUBGROUP(Server, Auth) + +//============================================================================ +PF_CONSOLE_CMD( + Server_Auth, + Host, + "string address", + "Set the Auth Server address" +) { + wchar_t *wHost = hsStringToWString((const char *)params[0]); + SetAuthSrvHostname(wHost); + delete [] wHost; +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Auth, + N, + "string base64Key", + "Set the Auth Server N key" +) { + int baseLength = hsStrlen((const char *)params[0]); + if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { + PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", + kNetDiffieHellmanKeyBits / 8); + return; + } + + Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], + kNetDiffieHellmanKeyBits / 8, kAuthDhNData); + swap_key_bytes(kAuthDhNData); +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Auth, + X, + "string base64Key", + "Set the Auth Server X key" +) { + int baseLength = hsStrlen((const char *)params[0]); + if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { + PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", + kNetDiffieHellmanKeyBits / 8); + return; + } + + Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], + kNetDiffieHellmanKeyBits / 8, kAuthDhXData); + swap_key_bytes(kAuthDhXData); +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Auth, + G, + "int GValue", + "Set the Auth Server G value" +) { + kAuthDhGValue = (int)params[0]; +} + + +//============================================================================ +// Server.Csr group +PF_CONSOLE_SUBGROUP(Server, Csr) + +//============================================================================ +PF_CONSOLE_CMD( + Server_Csr, + Host, + "string address", + "Set the Csr Server address" +) { + wchar_t *wHost = hsStringToWString((const char *)params[0]); + SetCsrSrvHostname(wHost); + delete [] wHost; +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Csr, + N, + "string base64Key", + "Set the Csr Server N key" +) { + int baseLength = hsStrlen((const char *)params[0]); + if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { + PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", + kNetDiffieHellmanKeyBits / 8); + return; + } + + Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], + kNetDiffieHellmanKeyBits / 8, kCsrDhNData); + swap_key_bytes(kCsrDhNData); +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Csr, + X, + "string base64Key", + "Set the Csr Server X key" +) { + int baseLength = hsStrlen((const char *)params[0]); + if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { + PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", + kNetDiffieHellmanKeyBits / 8); + return; + } + + Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], + kNetDiffieHellmanKeyBits / 8, kCsrDhXData); + swap_key_bytes(kCsrDhXData); +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Csr, + G, + "int GValue", + "Set the Csr Server G value" +) { + kCsrDhGValue = (int)params[0]; +} + + +//============================================================================ +// Server.Game group +PF_CONSOLE_SUBGROUP(Server, Game) + +//============================================================================ +PF_CONSOLE_CMD( + Server_Game, + N, + "string base64Key", + "Set the Game Server N key" +) { + int baseLength = hsStrlen((const char *)params[0]); + if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { + PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", + kNetDiffieHellmanKeyBits / 8); + return; + } + + Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], + kNetDiffieHellmanKeyBits / 8, kGameDhNData); + swap_key_bytes(kGameDhNData); +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Game, + X, + "string base64Key", + "Set the Game Server X key" +) { + int baseLength = hsStrlen((const char *)params[0]); + if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { + PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", + kNetDiffieHellmanKeyBits / 8); + return; + } + + Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], + kNetDiffieHellmanKeyBits / 8, kGameDhXData); + swap_key_bytes(kGameDhXData); +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Game, + G, + "int GValue", + "Set the Game Server G value" +) { + kGameDhGValue = (int)params[0]; +} + + +//============================================================================ +// Server.Gate group +PF_CONSOLE_SUBGROUP(Server, Gate) + +//============================================================================ +PF_CONSOLE_CMD( + Server_Gate, + Host, + "string address", + "Set the GateKeeper Server address" +) { + wchar_t *wHost = hsStringToWString((const char *)params[0]); + SetGateKeeperSrvHostname(wHost); + delete [] wHost; +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Gate, + N, + "string base64Key", + "Set the GateKeeper Server N key" +) { + int baseLength = hsStrlen((const char *)params[0]); + if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { + PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", + kNetDiffieHellmanKeyBits / 8); + return; + } + + Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], + kNetDiffieHellmanKeyBits / 8, kGateKeeperDhNData); + swap_key_bytes(kGateKeeperDhNData); +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Gate, + X, + "string base64Key", + "Set the GateKeeper Server X key" +) { + int baseLength = hsStrlen((const char *)params[0]); + if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { + PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", + kNetDiffieHellmanKeyBits / 8); + return; + } + + Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], + kNetDiffieHellmanKeyBits / 8, kGateKeeperDhXData); + swap_key_bytes(kGateKeeperDhXData); +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Gate, + G, + "int GValue", + "Set the GateKeeper Server G value" +) { + kGateKeeperDhGValue = (int)params[0]; +} + +#endif \ No newline at end of file diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.cpp index a02ac118..2408f4b7 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.cpp @@ -53,9 +53,56 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com const Int32 pfConsoleEngine::fMaxNumParams = 16; -const char pfConsoleEngine::fTokenSeparators[] = " =\r\n\t,"; -const char pfConsoleEngine::fTokenGrpSeps[] = " =\r\n._\t,"; +static const char kTokenSeparators[] = " =\r\n\t,"; +static const char kTokenGrpSeps[] = " =\r\n._\t,"; + +static char *console_strtok( char *&line, hsBool haveCommand ) +{ + char *begin = line; + + while (*begin && isspace(*begin)) + ++begin; + + for (line = begin; *line; ++line) { + if (!haveCommand) { + for (const char *sep = kTokenGrpSeps; *sep; ++sep) { + if (*line == *sep) { + *line = 0; + while (*++line && (*line == *sep)) + /* skip duplicate delimiters */; + return begin; + } + } + } else { + if (*begin == '"' || *begin == '\'') { + // Handle strings as a single token + char *endptr = strchr(line + 1, *line); + if (endptr == nil) { + // Bad string token sentry + return "\xFF"; + } + *endptr = 0; + line = endptr + 1; + return begin + 1; + } + for (const char *sep = kTokenSeparators; *sep; ++sep) { + if (*line == *sep) { + *line = 0; + while (*++line && (*line == *sep)) + /* skip duplicate delimiters */; + return begin; + } + } + } + } + + if (begin == line) + return nil; + + line = line + strlen(line); + return begin; +} //// Constructor & Destructor //////////////////////////////////////////////// @@ -82,7 +129,7 @@ hsBool pfConsoleEngine::PrintCmdHelp( char *name, void (*PrintFn)( const char * /// Scan for subgroups. This can be an empty loop group = pfConsoleCmdGroup::GetBaseGroup(); - ptr = strtok( name, fTokenGrpSeps ); + ptr = console_strtok( name, false ); while( ptr != nil ) { // Take this token and check to see if it's a group @@ -91,7 +138,7 @@ hsBool pfConsoleEngine::PrintCmdHelp( char *name, void (*PrintFn)( const char * else break; - ptr = strtok( nil, fTokenGrpSeps ); + ptr = console_strtok( name, false ); } if( ptr == nil ) @@ -159,7 +206,7 @@ const char *pfConsoleEngine::GetCmdSignature( char *name ) /// Scan for subgroups. This can be an empty loop group = pfConsoleCmdGroup::GetBaseGroup(); - ptr = strtok( name, fTokenGrpSeps ); + ptr = console_strtok( name, false ); while( ptr != nil ) { // Take this token and check to see if it's a group @@ -168,7 +215,7 @@ const char *pfConsoleEngine::GetCmdSignature( char *name ) else break; - ptr = strtok( nil, fTokenGrpSeps ); + ptr = console_strtok( name, false ); } if( ptr == nil ) @@ -262,7 +309,7 @@ hsBool pfConsoleEngine::RunCommand( char *line, void (*PrintFn)( const char * ) /// Loop #1: Scan for subgroups. This can be an empty loop group = pfConsoleCmdGroup::GetBaseGroup(); - ptr = strtok( line, fTokenGrpSeps ); + ptr = console_strtok( line, false ); while( ptr != nil ) { // Take this token and check to see if it's a group @@ -271,7 +318,7 @@ hsBool pfConsoleEngine::RunCommand( char *line, void (*PrintFn)( const char * ) else break; - ptr = strtok( nil, fTokenGrpSeps ); + ptr = console_strtok( line, false ); } if( ptr == nil ) @@ -293,84 +340,39 @@ hsBool pfConsoleEngine::RunCommand( char *line, void (*PrintFn)( const char * ) /// params for( numParams = numQuotedParams = 0; numParams < fMaxNumParams - && ( ptr = strtok( nil, fTokenSeparators ) ) != nil + && ( ptr = console_strtok( line, true ) ) != nil && valid; numParams++ ) { - if( ptr[ 0 ] == '\'' || ptr[ 0 ] == '"' ) - { - // String parameter--keep getting tokens until we hit the other end - - // Note: since params take pointers to strings, we have to have unique temp strings - // for each quoted param we parse. So we have a static array here to a) do so, b) - // avoid having to delete them afterwards, and thus c) reduce overhead. - static char tempStrings[ fMaxNumParams ][ 512 ]; - - char *tempStr = tempStrings[ numQuotedParams++ ], toSearch[ 2 ] = "'"; - - toSearch[ 0 ] = ptr[ 0 ]; - - if( strlen( ptr ) >= sizeof( tempStrings[ 0 ] ) ) // They're all the same, after all... - { - ISetErrorMsg( "Invalid syntax: quoted parameter too long" ); - return false; - } - - if( strlen( ptr ) > 1 && ptr[ strlen( ptr ) - 1 ] == toSearch[ 0 ] ) - { - // Single word string - strcpy( tempStr, ptr + 1 ); - tempStr[ strlen( tempStr ) - 1 ] = 0; - } - else - { - // Multiple word string - sprintf( tempStr, "%s ", ptr + 1 ); // Not perfect, but close - ptr = strtok( nil, toSearch ); - if( ptr == nil ) - { - ISetErrorMsg( "Invalid syntax: unterminated quoted parameter" ); - return false; - } - - if( strlen( ptr ) + strlen( tempStr ) >= sizeof( tempStrings[ 0 ] ) ) // They're all the same, after all... - { - ISetErrorMsg( "Invalid syntax: quoted parameter too long" ); - return false; - } - strcat( tempStr, ptr ); - } - - valid = IConvertToParam( cmd->GetSigEntry( (UInt8)numParams ), tempStr, ¶mArray[ numParams ] ); - } - else - { - // Normal parameter - - // Special case for context variables--if we're specifying one, we want to just grab - // the value of it and return that instead - valid = false; - if( ptr[ 0 ] == '$' ) - { - pfConsoleContext &context = pfConsoleContext::GetRootContext(); - - // Potential variable, see if we can find it - Int32 idx = context.FindVar( ptr + 1 ); - if( idx == -1 ) - { - ISetErrorMsg( "Invalid console variable name" ); - } - else - { - // Just copy. Note that this will copy string pointers, but so long as the variable in - // question doesn't change, we'll be OK... - paramArray[ numParams ] = context.GetVarValue( idx ); - valid = true; - } - } - - if( !valid ) - valid = IConvertToParam( cmd->GetSigEntry( (UInt8)numParams ), ptr, ¶mArray[ numParams ] ); - } + if( ptr[ 0 ] == '\xFF' ) + { + ISetErrorMsg( "Invalid syntax: unterminated quoted parameter" ); + return false; + } + + // Special case for context variables--if we're specifying one, we want to just grab + // the value of it and return that instead + valid = false; + if( ptr[ 0 ] == '$' ) + { + pfConsoleContext &context = pfConsoleContext::GetRootContext(); + + // Potential variable, see if we can find it + Int32 idx = context.FindVar( ptr + 1 ); + if( idx == -1 ) + { + ISetErrorMsg( "Invalid console variable name" ); + } + else + { + // Just copy. Note that this will copy string pointers, but so long as the variable in + // question doesn't change, we'll be OK... + paramArray[ numParams ] = context.GetVarValue( idx ); + valid = true; + } + } + + if( !valid ) + valid = IConvertToParam( cmd->GetSigEntry( (UInt8)numParams ), ptr, ¶mArray[ numParams ] ); } for( i = numParams; i < fMaxNumParams + 1; i++ ) paramArray[ i ].SetNone(); @@ -493,7 +495,7 @@ hsBool pfConsoleEngine::FindPartialCmd( char *line, hsBool findAgain, hsBool pre /// Loop #1: Scan for subgroups. This can be an empty loop lastParentGroup = group = pfConsoleCmdGroup::GetBaseGroup(); - ptr = strtok( line, fTokenGrpSeps ); + ptr = console_strtok( line, false ); while( ptr != nil ) { // Take this token and check to see if it's a group @@ -508,7 +510,7 @@ hsBool pfConsoleEngine::FindPartialCmd( char *line, hsBool findAgain, hsBool pre else break; - ptr = strtok( nil, fTokenGrpSeps ); + ptr = console_strtok( line, false ); strcat( newStr, "." ); insertLoc++; } diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.h b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.h index 38fbcdb7..42f9ed03 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.h +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.h @@ -68,8 +68,6 @@ class pfConsoleEngine private: static const Int32 fMaxNumParams; - static const char fTokenSeparators[]; - static const char fTokenGrpSeps[]; hsBool IConvertToParam( UInt8 type, char *string, pfConsoleCmdParam *param ); diff --git a/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbAllIncludes.h b/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbAllIncludes.h index 27795bb9..ab136da0 100644 --- a/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbAllIncludes.h +++ b/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbAllIncludes.h @@ -53,6 +53,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnNbConst.h" #include "pnNbError.h" +#include "pnNbKeys.h" #include "pnNbProtocol.h" #include "pnNbSrvs.h" diff --git a/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbKeys.cpp b/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbKeys.cpp new file mode 100644 index 00000000..3bf1f980 --- /dev/null +++ b/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbKeys.cpp @@ -0,0 +1,141 @@ +/*==LICENSE==* + +CyanWorlds.com Engine - MMOG client, server and tools +Copyright (C) 2011 Cyan Worlds, Inc. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +Additional permissions under GNU GPL version 3 section 7 + +If you modify this Program, or any covered work, by linking or +combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, +NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent +JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK +(or a modified version of those libraries), +containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, +PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG +JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the +licensors of this Program grant you additional +permission to convey the resulting work. Corresponding Source for a +non-source form of such a combination shall include the source code for +the parts of OpenSSL and IJG JPEG Library used as well as that of the covered +work. + +You can contact Cyan Worlds, Inc. by email legal@cyan.com + or by snail mail at: + Cyan Worlds, Inc. + 14617 N Newport Hwy + Mead, WA 99021 + +*==LICENSE==*/ +/***************************************************************************** +* +* $/Plasma20/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbKeys.cpp +* +***/ + +#include "../Pch.h" +#pragma hdrstop + +// Auth Server +unsigned kAuthDhGValue = 41; +byte kAuthDhNData[kNetDiffieHellmanKeyBits / 8] = { + 0x2d, 0x17, 0x19, 0x42, 0xeb, 0x71, 0x8f, 0x91, + 0x29, 0x7c, 0x61, 0x88, 0x43, 0x75, 0xe5, 0xee, + 0x72, 0xfe, 0x45, 0x1b, 0x43, 0xc3, 0x8e, 0xb9, + 0x47, 0x5e, 0x03, 0xc8, 0x0c, 0x78, 0xb7, 0xe4, + 0x4d, 0x31, 0x5b, 0xcb, 0x66, 0xc2, 0x54, 0x1a, + 0x0a, 0x61, 0x11, 0x57, 0x38, 0x66, 0x9b, 0x34, + 0x6b, 0xab, 0x6d, 0x12, 0x12, 0x38, 0x87, 0xc5, + 0x3f, 0x20, 0xbe, 0x97, 0xa3, 0xa6, 0x56, 0x8f +}; +byte kAuthDhXData[kNetDiffieHellmanKeyBits / 8] = { + 0x21, 0xcf, 0x1d, 0xc6, 0x08, 0xc0, 0x23, 0xad, + 0x53, 0x36, 0xce, 0x61, 0x25, 0xdd, 0xb9, 0x55, + 0x05, 0xc1, 0xbb, 0x8f, 0xf4, 0x0d, 0x59, 0xf9, + 0x20, 0x27, 0x9a, 0xee, 0xfb, 0x23, 0x5b, 0xeb, + 0xe5, 0xec, 0x01, 0x55, 0x2e, 0xd5, 0x64, 0xef, + 0xea, 0x43, 0xb1, 0x9e, 0xb9, 0x8c, 0x75, 0x3f, + 0xda, 0xb2, 0xbb, 0xb3, 0x6a, 0x3d, 0xcd, 0xbc, + 0xfa, 0x6f, 0x03, 0xf3, 0x55, 0xd8, 0xe9, 0x1b +}; + +// CSR Server +unsigned kCsrDhGValue = 97; +byte kCsrDhNData[kNetDiffieHellmanKeyBits / 8] = { + 0xbd, 0xf8, 0x03, 0x17, 0xed, 0x27, 0x74, 0x0d, + 0x76, 0x8e, 0x7a, 0x8c, 0x88, 0xeb, 0xec, 0xde, + 0xd7, 0x73, 0x37, 0x8f, 0x4b, 0xbc, 0xae, 0x75, + 0xf8, 0xda, 0x22, 0xee, 0x50, 0xc9, 0xb3, 0x69, + 0x97, 0x0b, 0xe5, 0x28, 0x98, 0x91, 0xf7, 0x44, + 0x97, 0xdf, 0x70, 0xf1, 0x86, 0x6c, 0xfa, 0x03, + 0x7c, 0x47, 0x73, 0xb1, 0x62, 0x00, 0x42, 0x99, + 0xf0, 0xc6, 0xe7, 0x05, 0xd8, 0xcd, 0xd6, 0x6d +}; +byte kCsrDhXData[kNetDiffieHellmanKeyBits / 8] = { + 0x03, 0x1d, 0x83, 0x62, 0x36, 0x92, 0x63, 0xa6, + 0xa8, 0x66, 0x31, 0xbe, 0x28, 0x42, 0xc2, 0xe6, + 0x86, 0x98, 0x3a, 0x81, 0x13, 0x0e, 0xb7, 0x96, + 0x5e, 0x27, 0x87, 0x6a, 0x06, 0x68, 0x51, 0x21, + 0xf3, 0x74, 0xe9, 0x11, 0xe9, 0x73, 0x5f, 0xdb, + 0x37, 0x2a, 0x2d, 0x49, 0xa4, 0x76, 0x12, 0x06, + 0x58, 0x36, 0x59, 0x6d, 0xbb, 0x59, 0x57, 0x2c, + 0x34, 0xe4, 0x5e, 0xd4, 0x2c, 0x78, 0xc3, 0x34 +}; + +// Game Server +unsigned kGameDhGValue = 73; +byte kGameDhNData[kNetDiffieHellmanKeyBits / 8] = { + 0x38, 0xa4, 0xf7, 0x69, 0x43, 0xd7, 0xa6, 0xc7, + 0x27, 0x72, 0x3b, 0x12, 0x6a, 0x76, 0x09, 0x5d, + 0xaa, 0x9a, 0x38, 0x44, 0xde, 0x84, 0x22, 0xc4, + 0xde, 0x3f, 0xfd, 0x50, 0x26, 0xea, 0xbb, 0x20, + 0xd6, 0xad, 0x2e, 0xcd, 0xfe, 0xf2, 0x70, 0x1b, + 0x19, 0xd1, 0x82, 0x15, 0xd7, 0xcb, 0x33, 0x60, + 0x20, 0xbc, 0x43, 0xc9, 0x55, 0x0b, 0xc9, 0x20, + 0xd9, 0x24, 0xd2, 0x49, 0xd0, 0x28, 0x4b, 0x90 +}; +byte kGameDhXData[kNetDiffieHellmanKeyBits / 8] = { + 0xf9, 0xb2, 0x93, 0xbd, 0x02, 0xbd, 0x72, 0x48, + 0xa9, 0x21, 0xbd, 0x09, 0x3e, 0x44, 0x65, 0x3e, + 0xc2, 0xfd, 0x5a, 0xf0, 0x99, 0x3b, 0x3f, 0x5c, + 0x47, 0x76, 0x5c, 0x1f, 0x84, 0xd8, 0x01, 0x68, + 0xdc, 0x5f, 0xb6, 0xba, 0xc8, 0xfd, 0x79, 0x98, + 0x62, 0x93, 0x36, 0x7f, 0x14, 0xcf, 0x33, 0x67, + 0x84, 0x04, 0xcf, 0xa3, 0x7a, 0x65, 0xe9, 0x68, + 0x4f, 0x58, 0x58, 0xb3, 0x8f, 0x3d, 0xdb, 0x3d +}; + +// GateKeeper Server +unsigned kGateKeeperDhGValue = 4; +byte kGateKeeperDhNData[kNetDiffieHellmanKeyBits / 8] = { + 0x8d, 0xfa, 0x35, 0xe6, 0xf8, 0x7a, 0x50, 0x50, + 0xab, 0x25, 0x4b, 0x81, 0xd1, 0xd7, 0x7a, 0x23, + 0xa3, 0x9a, 0x21, 0x0f, 0x34, 0xab, 0x66, 0x2e, + 0x16, 0x98, 0x55, 0xb6, 0xfc, 0x49, 0xd5, 0x50, + 0xdc, 0xb8, 0x4c, 0x4d, 0xc7, 0xdb, 0xf1, 0x1c, + 0x15, 0x4c, 0x55, 0xf5, 0x92, 0x0d, 0x6a, 0xec, + 0x60, 0xbc, 0x55, 0xfa, 0x29, 0x2f, 0x6f, 0xc3, + 0xd7, 0x21, 0x80, 0xa3, 0x6b, 0x44, 0x23, 0xb5, +}; +byte kGateKeeperDhXData[kNetDiffieHellmanKeyBits / 8] = { + 0xb3, 0x88, 0xff, 0x0b, 0x90, 0x70, 0x2b, 0x2e, + 0x07, 0xbc, 0x62, 0x98, 0x83, 0x9d, 0x0f, 0x05, + 0x39, 0xfa, 0x35, 0x39, 0xa9, 0xf3, 0xb3, 0xfc, + 0xcd, 0x5e, 0xa9, 0xa6, 0x61, 0x0f, 0x9b, 0x38, + 0x0f, 0x9c, 0xbe, 0xa0, 0xbe, 0x6f, 0x7f, 0xe4, + 0x7c, 0xcb, 0xc4, 0x09, 0x6c, 0x8d, 0xce, 0x47, + 0x68, 0x82, 0x32, 0xc5, 0x89, 0x94, 0xf9, 0xca, + 0x69, 0x69, 0xd0, 0x60, 0x19, 0xb7, 0xf3, 0x1a, +}; \ No newline at end of file diff --git a/Sources/Plasma/NucleusLib/pnNetBase/pnNbAuthKey.hpp b/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbKeys.h similarity index 60% rename from Sources/Plasma/NucleusLib/pnNetBase/pnNbAuthKey.hpp rename to Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbKeys.h index f0974cfb..6194b38a 100644 --- a/Sources/Plasma/NucleusLib/pnNetBase/pnNbAuthKey.hpp +++ b/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbKeys.h @@ -39,36 +39,33 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com Mead, WA 99021 *==LICENSE==*/ -/************************************************************* -* -* This file was auto-generated by plDhKeyGen.exe +/***************************************************************************** * +* $/Plasma20/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbKeys.h +* ***/ -static const unsigned kDhGValue = 41; +#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNNETBASE_PRIVATE_PNNBKEYS_H +#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbKeys.h included more than once" +#endif +#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNNETBASE_PRIVATE_PNNBKEYS_H -static const byte kDhNData[] = { - 0x2d, 0x17, 0x19, 0x42, 0xeb, 0x71, 0x8f, 0x91, - 0x29, 0x7c, 0x61, 0x88, 0x43, 0x75, 0xe5, 0xee, - 0x72, 0xfe, 0x45, 0x1b, 0x43, 0xc3, 0x8e, 0xb9, - 0x47, 0x5e, 0x03, 0xc8, 0x0c, 0x78, 0xb7, 0xe4, - 0x4d, 0x31, 0x5b, 0xcb, 0x66, 0xc2, 0x54, 0x1a, - 0x0a, 0x61, 0x11, 0x57, 0x38, 0x66, 0x9b, 0x34, - 0x6b, 0xab, 0x6d, 0x12, 0x12, 0x38, 0x87, 0xc5, - 0x3f, 0x20, 0xbe, 0x97, 0xa3, 0xa6, 0x56, 0x8f -}; -COMPILER_ASSERT(sizeof(kDhNData) == kNetDiffieHellmanKeyBits / 8); +// Auth Server +extern unsigned kAuthDhGValue; +extern byte kAuthDhNData[kNetDiffieHellmanKeyBits / 8]; +extern byte kAuthDhXData[kNetDiffieHellmanKeyBits / 8]; -static const byte kDhXData[] = { - 0x21, 0xcf, 0x1d, 0xc6, 0x08, 0xc0, 0x23, 0xad, - 0x53, 0x36, 0xce, 0x61, 0x25, 0xdd, 0xb9, 0x55, - 0x05, 0xc1, 0xbb, 0x8f, 0xf4, 0x0d, 0x59, 0xf9, - 0x20, 0x27, 0x9a, 0xee, 0xfb, 0x23, 0x5b, 0xeb, - 0xe5, 0xec, 0x01, 0x55, 0x2e, 0xd5, 0x64, 0xef, - 0xea, 0x43, 0xb1, 0x9e, 0xb9, 0x8c, 0x75, 0x3f, - 0xda, 0xb2, 0xbb, 0xb3, 0x6a, 0x3d, 0xcd, 0xbc, - 0xfa, 0x6f, 0x03, 0xf3, 0x55, 0xd8, 0xe9, 0x1b -}; -COMPILER_ASSERT(sizeof(kDhXData) == kNetDiffieHellmanKeyBits / 8); +// CSR Server +extern unsigned kCsrDhGValue; +extern byte kCsrDhNData[kNetDiffieHellmanKeyBits / 8]; +extern byte kCsrDhXData[kNetDiffieHellmanKeyBits / 8]; +// Game Server +extern unsigned kGameDhGValue; +extern byte kGameDhNData[kNetDiffieHellmanKeyBits / 8]; +extern byte kGameDhXData[kNetDiffieHellmanKeyBits / 8]; +// GateKeeper Server +extern unsigned kGateKeeperDhGValue; +extern byte kGateKeeperDhNData[kNetDiffieHellmanKeyBits / 8]; +extern byte kGateKeeperDhXData[kNetDiffieHellmanKeyBits / 8]; \ No newline at end of file diff --git a/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.cpp b/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.cpp index de8aac81..bf7013f3 100644 --- a/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.cpp +++ b/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.cpp @@ -162,6 +162,9 @@ static const wchar * s_gateKeeperAddrsOverride[] = { s_gateKeeperAddrCmdLine }; +static unsigned s_clientPort = 14617; +static unsigned s_serverPort = 14618; +static unsigned s_simpleNetPort = 14620; /***************************************************************************** * @@ -276,3 +279,77 @@ bool GateKeeperSrvHostnameOverride () { return s_gateKeeperAddrCmdLine[0]; } +//============================================================================ +// Client Port +//============================================================================ +unsigned GetClientPort() { + return s_clientPort; +} + +//============================================================================ +void SetClientPort(unsigned port) { + s_clientPort = port; +} + +//============================================================================ +unsigned GetServerPort() { + return s_serverPort; +} + +//============================================================================ +unsigned GetSimpleNetPort() { + return s_simpleNetPort; +} + +//============================================================================ +// User-visible Server +//============================================================================ +static const wchar* kDefaultStatusUrl = L"http://account.mystonline.com/serverstatus/moullive.php"; +static const wchar* kDefaultSignupUrl = L"http://www.mystonline.com/signup.html"; +static const wchar* kDefaultServerName = L"MOULagain"; + +static wchar s_serverStatusUrl[256]; +static wchar s_serverSignupUrl[256]; +static wchar s_serverName[256]; + +//============================================================================ +const wchar *GetServerStatusUrl () { + if (s_serverStatusUrl[0]) { + return s_serverStatusUrl; + } + + return kDefaultStatusUrl; +} + +//============================================================================ +void SetServerStatusUrl (const wchar url[]) { + StrCopy(s_serverStatusUrl, url, arrsize(s_serverStatusUrl)); +} + +//============================================================================ +const wchar *GetServerSignupUrl () { + if (s_serverSignupUrl[0]) { + return s_serverSignupUrl; + } + + return kDefaultSignupUrl; +} + +//============================================================================ +void SetServerSignupUrl (const wchar url[]) { + StrCopy(s_serverSignupUrl, url, arrsize(s_serverSignupUrl)); +} + +//============================================================================ +const wchar *GetServerDisplayName () { + if (s_serverName[0]) { + return s_serverName; + } + + return kDefaultServerName; +} + +//============================================================================ +void SetServerDisplayName (const wchar name[]) { + StrCopy(s_serverName, name, arrsize(s_serverName)); +} \ No newline at end of file diff --git a/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.h b/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.h index 615cf1f0..98a5a048 100644 --- a/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.h +++ b/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.h @@ -104,3 +104,17 @@ bool CsrSrvHostnameOverride (); unsigned GetGateKeeperSrvHostnames (const wchar *** addrs); // returns addrCount void SetGateKeeperSrvHostname (const wchar addr[]); bool GateKeeperSrvHostnameOverride (); + +unsigned GetClientPort(); +void SetClientPort(unsigned port); +unsigned GetServerPort(); +unsigned GetSimpleNetPort(); + +const wchar *GetServerStatusUrl (); +void SetServerStatusUrl (const wchar url[]); + +const wchar *GetServerSignupUrl (); +void SetServerSignupUrl (const wchar url[]); + +const wchar *GetServerDisplayName (); +void SetServerDisplayName (const wchar name[]); \ No newline at end of file diff --git a/Sources/Plasma/NucleusLib/pnNetBase/pnNbConst.h b/Sources/Plasma/NucleusLib/pnNetBase/pnNbConst.h index c6e8faac..a51d0e1c 100644 --- a/Sources/Plasma/NucleusLib/pnNetBase/pnNbConst.h +++ b/Sources/Plasma/NucleusLib/pnNetBase/pnNbConst.h @@ -60,10 +60,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com //============================================================================ // Network constants //============================================================================ -const unsigned kNetLegacyClientPort = 80; -const unsigned kNetDefaultClientPort = 14617; -const unsigned kNetDefaultServerPort = 14618; -const unsigned kNetDefaultSimpleNetPort = 14620; const unsigned kMaxTcpPacketSize = 1460; //============================================================================ diff --git a/Sources/Plasma/NucleusLib/pnNetBase/pnNbGameKey.hpp b/Sources/Plasma/NucleusLib/pnNetBase/pnNbGameKey.hpp deleted file mode 100644 index 65431efe..00000000 --- a/Sources/Plasma/NucleusLib/pnNetBase/pnNbGameKey.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/*==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Additional permissions under GNU GPL version 3 section 7 - -If you modify this Program, or any covered work, by linking or -combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, -NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent -JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK -(or a modified version of those libraries), -containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, -PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG -JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the -licensors of this Program grant you additional -permission to convey the resulting work. Corresponding Source for a -non-source form of such a combination shall include the source code for -the parts of OpenSSL and IJG JPEG Library used as well as that of the covered -work. - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - -*==LICENSE==*/ -/************************************************************* -* -* This file was auto-generated by plDhKeyGen.exe -* -***/ - -static const unsigned kDhGValue = 73; - -static const byte kDhNData[] = { - 0x38, 0xa4, 0xf7, 0x69, 0x43, 0xd7, 0xa6, 0xc7, - 0x27, 0x72, 0x3b, 0x12, 0x6a, 0x76, 0x09, 0x5d, - 0xaa, 0x9a, 0x38, 0x44, 0xde, 0x84, 0x22, 0xc4, - 0xde, 0x3f, 0xfd, 0x50, 0x26, 0xea, 0xbb, 0x20, - 0xd6, 0xad, 0x2e, 0xcd, 0xfe, 0xf2, 0x70, 0x1b, - 0x19, 0xd1, 0x82, 0x15, 0xd7, 0xcb, 0x33, 0x60, - 0x20, 0xbc, 0x43, 0xc9, 0x55, 0x0b, 0xc9, 0x20, - 0xd9, 0x24, 0xd2, 0x49, 0xd0, 0x28, 0x4b, 0x90 -}; -COMPILER_ASSERT(sizeof(kDhNData) == kNetDiffieHellmanKeyBits / 8); - -static const byte kDhXData[] = { - 0xf9, 0xb2, 0x93, 0xbd, 0x02, 0xbd, 0x72, 0x48, - 0xa9, 0x21, 0xbd, 0x09, 0x3e, 0x44, 0x65, 0x3e, - 0xc2, 0xfd, 0x5a, 0xf0, 0x99, 0x3b, 0x3f, 0x5c, - 0x47, 0x76, 0x5c, 0x1f, 0x84, 0xd8, 0x01, 0x68, - 0xdc, 0x5f, 0xb6, 0xba, 0xc8, 0xfd, 0x79, 0x98, - 0x62, 0x93, 0x36, 0x7f, 0x14, 0xcf, 0x33, 0x67, - 0x84, 0x04, 0xcf, 0xa3, 0x7a, 0x65, 0xe9, 0x68, - 0x4f, 0x58, 0x58, 0xb3, 0x8f, 0x3d, 0xdb, 0x3d -}; -COMPILER_ASSERT(sizeof(kDhXData) == kNetDiffieHellmanKeyBits / 8); - - diff --git a/Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.cpp b/Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.cpp index eecf1ca4..d883f9b7 100644 --- a/Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.cpp +++ b/Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.cpp @@ -488,7 +488,7 @@ bool SimpleNetStartListening ( s_queryAcceptParam = param; NetAddress addr; - NetAddressFromNode(0, kNetDefaultSimpleNetPort, &addr); + NetAddressFromNode(0, GetSimpleNetPort(), &addr); return (0 != AsyncSocketStartListening(addr, nil)); } @@ -498,7 +498,7 @@ void SimpleNetStopListening () { ASSERT(s_running); NetAddress addr; - NetAddressFromNode(0, kNetDefaultSimpleNetPort, &addr); + NetAddressFromNode(0, GetSimpleNetPort(), &addr); AsyncSocketStopListening(addr, nil); s_queryAccept = nil; @@ -591,7 +591,7 @@ void SimpleNetStartConnecting ( &cancelId, AsyncLookupCallback, addr, - kNetDefaultSimpleNetPort, + GetSimpleNetPort(), cp ); break; @@ -599,7 +599,7 @@ void SimpleNetStartConnecting ( } if (!name[0]) { NetAddress netAddr; - NetAddressFromString(&netAddr, addr, kNetDefaultSimpleNetPort); + NetAddressFromString(&netAddr, addr, GetSimpleNetPort()); Connect(netAddr, cp); } } diff --git a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBase64.cpp b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBase64.cpp index 08a234b0..bb7a0830 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBase64.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBase64.cpp @@ -150,7 +150,7 @@ unsigned Base64Decode ( byte * dstData ) { ASSERT(srcData); - ASSERT(dstChars >= Base64DecodeSize(srcChars)); + ASSERT(dstChars >= Base64DecodeSize(srcChars, srcData)); ASSERT(dstData); REF(dstChars); diff --git a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBase64.h b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBase64.h index c84cdfd0..6810d94c 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBase64.h +++ b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBase64.h @@ -62,7 +62,8 @@ const unsigned kBase64EncodeBlock = 4; const unsigned kBase64EncodeMultiple = 3; inline unsigned Base64EncodeSize (unsigned srcChars) { - return srcChars * kBase64EncodeBlock / kBase64EncodeMultiple + kBase64EncodeBlock; + return (srcChars + kBase64EncodeMultiple - 1) / kBase64EncodeMultiple + * kBase64EncodeBlock; } unsigned Base64Encode ( unsigned srcChars, @@ -71,8 +72,10 @@ unsigned Base64Encode ( char * dstData ); -inline unsigned Base64DecodeSize (unsigned srcChars) { - return srcChars * kBase64EncodeMultiple / kBase64EncodeBlock + kBase64EncodeMultiple; +inline unsigned Base64DecodeSize (unsigned srcChars, const char srcData[]) { + return srcChars * kBase64EncodeMultiple / kBase64EncodeBlock + - ((srcChars >= 1 && srcData[srcChars - 1] == '=') ? 1 : 0) + - ((srcChars >= 2 && srcData[srcChars - 2] == '=') ? 1 : 0); } unsigned Base64Decode ( unsigned srcChars, diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp index 8585cdc6..e2b03507 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp @@ -48,9 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "../Pch.h" #pragma hdrstop -// This file excluded from pre-compiled header because it is auto-generated by the build server. -#include "pnNetBase/pnNbAuthKey.hpp" - namespace Ngl { namespace Auth { /***************************************************************************** * @@ -5089,9 +5086,9 @@ void AuthInitialize () { false, s_send, arrsize(s_send), s_recv, arrsize(s_recv), - kDhGValue, - BigNum(sizeof(kDhXData), kDhXData), - BigNum(sizeof(kDhNData), kDhNData) + kAuthDhGValue, + BigNum(sizeof(kAuthDhXData), kAuthDhXData), + BigNum(sizeof(kAuthDhNData), kAuthDhNData) ); } @@ -5201,7 +5198,7 @@ void NetCliAuthStartConnect ( &cancelId, AsyncLookupCallback, authAddrList[i], - kNetDefaultClientPort, + GetClientPort(), nil ); break; @@ -5209,7 +5206,7 @@ void NetCliAuthStartConnect ( } if (!name[0]) { NetAddress addr; - NetAddressFromString(&addr, authAddrList[i], kNetDefaultClientPort); + NetAddressFromString(&addr, authAddrList[i], GetClientPort()); Connect(authAddrList[i], addr); } } diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.cpp index 7c1e04da..b0bcff95 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.cpp @@ -48,9 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "../Pch.h" #pragma hdrstop -// This file excluded from pre-compiled header because it is auto-generated by the build server. -#include "pnNetBase/pnNbCsrKey.hpp" - namespace Ngl { namespace Csr { /***************************************************************************** @@ -764,9 +761,9 @@ void CsrInitialize () { false, s_send, arrsize(s_send), s_recv, arrsize(s_recv), - kDhGValue, - BigNum(sizeof(kDhXData), kDhXData), - BigNum(sizeof(kDhNData), kDhNData) + kCsrDhGValue, + BigNum(sizeof(kCsrDhXData), kCsrDhXData), + BigNum(sizeof(kCsrDhNData), kCsrDhNData) ); } @@ -860,7 +857,7 @@ void NetCliCsrStartConnect ( &cancelId, AsyncLookupCallback, addrList[i], - kNetDefaultClientPort, + GetClientPort(), cp ); break; @@ -868,7 +865,7 @@ void NetCliCsrStartConnect ( } if (!name[0]) { NetAddress addr; - NetAddressFromString(&addr, addrList[i], kNetDefaultClientPort); + NetAddressFromString(&addr, addrList[i], GetClientPort()); ConnectParam * cp = NEW(ConnectParam); cp->callback = callback; diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp index 0193ada6..ad0a188f 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp @@ -1361,7 +1361,7 @@ void NetCliFileStartConnect ( &cancelId, AsyncLookupCallback, fileAddrList[i], - kNetDefaultClientPort, + GetClientPort(), nil ); break; @@ -1369,7 +1369,7 @@ void NetCliFileStartConnect ( } if (!name[0]) { NetAddress addr; - NetAddressFromString(&addr, fileAddrList[i], kNetDefaultClientPort); + NetAddressFromString(&addr, fileAddrList[i], GetClientPort()); Connect(fileAddrList[i], addr); } } @@ -1399,7 +1399,7 @@ void NetCliFileStartConnectAsServer ( &cancelId, AsyncLookupCallback, fileAddrList[i], - kNetDefaultClientPort, + GetClientPort(), nil ); break; @@ -1407,7 +1407,7 @@ void NetCliFileStartConnectAsServer ( } if (!name[0]) { NetAddress addr; - NetAddressFromString(&addr, fileAddrList[i], kNetDefaultServerPort); + NetAddressFromString(&addr, fileAddrList[i], GetServerPort()); Connect(fileAddrList[i], addr); } } diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp index 83ae03ad..28083b40 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp @@ -48,9 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "../Pch.h" #pragma hdrstop -// This file excluded from pre-compiled header because it is auto-generated by the build server. -#include "pnNetBase/pnNbGameKey.hpp" - namespace Ngl { namespace Game { /***************************************************************************** * @@ -665,9 +662,9 @@ void GameInitialize () { false, s_send, arrsize(s_send), s_recv, arrsize(s_recv), - kDhGValue, - BigNum(sizeof(kDhXData), kDhXData), - BigNum(sizeof(kDhNData), kDhNData) + kGameDhGValue, + BigNum(sizeof(kGameDhXData), kGameDhXData), + BigNum(sizeof(kGameDhNData), kGameDhNData) ); } diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp index a168ec97..dbe96280 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp @@ -48,9 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "../Pch.h" #pragma hdrstop -// This file excluded from pre-compiled header because it is auto-generated by the build server. -#include "pnNetBase/pnNbGateKeeperKey.hpp" - namespace Ngl { namespace GateKeeper { /***************************************************************************** @@ -1005,9 +1002,9 @@ void GateKeeperInitialize () { false, s_send, arrsize(s_send), s_recv, arrsize(s_recv), - kDhGValue, - BigNum(sizeof(kDhXData), kDhXData), - BigNum(sizeof(kDhNData), kDhNData) + kGateKeeperDhGValue, + BigNum(sizeof(kGateKeeperDhXData), kGateKeeperDhXData), + BigNum(sizeof(kGateKeeperDhNData), kGateKeeperDhNData) ); } @@ -1091,7 +1088,7 @@ void NetCliGateKeeperStartConnect ( &cancelId, AsyncLookupCallback, gateKeeperAddrList[i], - kNetDefaultClientPort, + GetClientPort(), nil ); break; @@ -1099,7 +1096,7 @@ void NetCliGateKeeperStartConnect ( } if (!name[0]) { NetAddress addr; - NetAddressFromString(&addr, gateKeeperAddrList[i], kNetDefaultClientPort); + NetAddressFromString(&addr, gateKeeperAddrList[i], GetClientPort()); Connect(gateKeeperAddrList[i], addr); } }