Browse Source

Get rid of pnUtW32Addr and make IP strings char*s.

IP addresses don't need to be unicode.
pnUtAddr is still around until we replace all NetAddress uses with
plNetAddress (they are typedef'ed to each other right now).
Darryl Pogue 13 years ago
parent
commit
3ea3473d13
  1. 29
      Sources/Plasma/Apps/plClient/winmain.cpp
  2. 6
      Sources/Plasma/Apps/plClientPatcher/UruPlayer.cpp
  3. 3
      Sources/Plasma/Apps/plUruLauncher/Main.cpp
  4. 6
      Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp
  5. 28
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp
  6. 14
      Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcIo.h
  7. 6
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp
  8. 17
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Dns.cpp
  9. 64
      Sources/Plasma/NucleusLib/pnNetBase/pnNbSrvs.cpp
  10. 28
      Sources/Plasma/NucleusLib/pnNetBase/pnNbSrvs.h
  11. 4
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Auth/pnNpCli2Auth.h
  12. 2
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Srv2Mcp/pnNpSrv2Mcp.h
  13. 9
      Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.cpp
  14. 1
      Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt
  15. 117
      Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Addr.cpp
  16. 28
      Sources/Plasma/NucleusLib/pnUtils/pnUtAddr.h
  17. 22
      Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp
  18. 19
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  19. 4
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h
  20. 11
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.cpp
  21. 4
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.h
  22. 26
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp
  23. 4
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.h
  24. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp
  25. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.h
  26. 17
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp
  27. 4
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.h

29
Sources/Plasma/Apps/plClient/winmain.cpp

@ -1109,7 +1109,7 @@ void StatusCallback(void *param)
{ {
HWND hwnd = (HWND)param; HWND hwnd = (HWND)param;
char *statusUrl = hsWStringToString(GetServerStatusUrl()); const char *statusUrl = GetServerStatusUrl();
CURL *hCurl = curl_easy_init(); CURL *hCurl = curl_easy_init();
// For reporting errors // For reporting errors
@ -1133,7 +1133,6 @@ void StatusCallback(void *param)
} }
curl_easy_cleanup(hCurl); curl_easy_cleanup(hCurl);
delete [] statusUrl;
s_statusEvent.Signal(); // Signal the semaphore s_statusEvent.Signal(); // Signal the semaphore
} }
@ -1254,8 +1253,8 @@ BOOL CALLBACK UruLoginDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
} }
else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_URULOGIN_GAMETAPLINK) else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_URULOGIN_GAMETAPLINK)
{ {
const wchar_t *signupurl = GetServerSignupUrl(); const char* signupurl = GetServerSignupUrl();
ShellExecuteW(NULL, L"open", signupurl, NULL, NULL, SW_SHOWNORMAL); ShellExecuteA(NULL, "open", signupurl, NULL, NULL, SW_SHOWNORMAL);
return TRUE; return TRUE;
} }
@ -1461,25 +1460,27 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
memset(&si, 0, sizeof(si)); memset(&si, 0, sizeof(si));
memset(&pi, 0, sizeof(pi)); memset(&pi, 0, sizeof(pi));
si.cb = sizeof(si); si.cb = sizeof(si);
wchar_t cmdLine[MAX_PATH];
const wchar_t ** addrs; plStringStream cmdLine;
const char** addrs;
if (!eventExists) // if it is missing, assume patcher wasn't launched if (!eventExists) // if it is missing, assume patcher wasn't launched
{ {
StrCopy(cmdLine, s_patcherExeName, arrsize(cmdLine)); cmdLine << _TEMP_CONVERT_FROM_WCHAR_T(s_patcherExeName);
GetAuthSrvHostnames(&addrs); GetAuthSrvHostnames(&addrs);
if(wcslen(addrs[0])) if(strlen(addrs[0]))
StrPrintf(cmdLine, arrsize(cmdLine), L"%ws /AuthSrv=%ws", cmdLine, addrs[0]); cmdLine << plString::Format(" /AuthSrv=%s", addrs[0]);
GetFileSrvHostnames(&addrs); GetFileSrvHostnames(&addrs);
if(wcslen(addrs[0])) if(strlen(addrs[0]))
StrPrintf(cmdLine, arrsize(cmdLine), L"%ws /FileSrv=%ws", cmdLine, addrs[0]); cmdLine << plString::Format(" /FileSrv=%s", addrs[0]);
GetGateKeeperSrvHostnames(&addrs); GetGateKeeperSrvHostnames(&addrs);
if(wcslen(addrs[0])) if(strlen(addrs[0]))
StrPrintf(cmdLine, arrsize(cmdLine), L"%ws /GateKeeperSrv=%ws", cmdLine, addrs[0]); cmdLine << plString::Format(" /GateKeeperSrv=%s", addrs[0]);
if(!CreateProcessW(NULL, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) if(!CreateProcessW(NULL, (LPWSTR)cmdLine.GetString().ToUtf16().GetData(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{ {
hsMessageBox("Failed to launch patcher", "Error", hsMessageBoxNormal); hsMessageBox("Failed to launch patcher", "Error", hsMessageBoxNormal);
} }

6
Sources/Plasma/Apps/plClientPatcher/UruPlayer.cpp

@ -840,7 +840,9 @@ static void FileSrvIpAddressCallback (
plLauncherInfo *info = (plLauncherInfo *) param; plLauncherInfo *info = (plLauncherInfo *) param;
// Start connecting to the server // Start connecting to the server
NetCliFileStartConnect(&addr, 1, true); const char* caddr = hsWStringToString(addr);
NetCliFileStartConnect(&caddr, 1, true);
delete[] caddr;
NetCliFileManifestRequest(ThinManifestCallback, info, s_thinmanifest, info->buildId); NetCliFileManifestRequest(ThinManifestCallback, info, s_thinmanifest, info->buildId);
@ -902,7 +904,7 @@ void UruPrepProc (void * param) {
s_patchComplete = false; s_patchComplete = false;
s_patchError = false; s_patchError = false;
const wchar_t ** addrs; const char** addrs;
unsigned count; unsigned count;
count = GetGateKeeperSrvHostnames(&addrs); count = GetGateKeeperSrvHostnames(&addrs);

3
Sources/Plasma/Apps/plUruLauncher/Main.cpp

@ -609,7 +609,7 @@ static size_t CurlCallback(void *buffer, size_t size, size_t nmemb, void *)
//============================================================================ //============================================================================
static void StatusCallback(void *) static void StatusCallback(void *)
{ {
char *serverUrl = hsWStringToString(GetServerStatusUrl()); const char *serverUrl = GetServerStatusUrl();
CURL * hCurl = curl_easy_init(); CURL * hCurl = curl_easy_init();
curl_easy_setopt(hCurl, CURLOPT_ERRORBUFFER, s_curlError); curl_easy_setopt(hCurl, CURLOPT_ERRORBUFFER, s_curlError);
@ -631,7 +631,6 @@ static void StatusCallback(void *)
} }
curl_easy_cleanup(hCurl); curl_easy_cleanup(hCurl);
delete [] serverUrl;
s_statusEvent.Signal(); s_statusEvent.Signal();
} }

6
Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp

@ -226,7 +226,9 @@ static void FileSrvIpAddressCallback (
} }
// Start connecting to the server // Start connecting to the server
NetCliFileStartConnect(&addr, 1, true); const char* caddr = hsWStringToString(addr);
NetCliFileStartConnect(&caddr, 1, true);
delete[] caddr;
PathGetProgramDirectory(s_newPatcherFile, arrsize(s_newPatcherFile)); PathGetProgramDirectory(s_newPatcherFile, arrsize(s_newPatcherFile));
GetTempFileNameW(s_newPatcherFile, kPatcherExeFilename, 0, s_newPatcherFile); GetTempFileNameW(s_newPatcherFile, kPatcherExeFilename, 0, s_newPatcherFile);
@ -245,7 +247,7 @@ static bool SelfPatcherProc (bool * abort, plLauncherInfo *info) {
NetClientInitialize(); NetClientInitialize();
NetClientSetErrorHandler(NetErrorHandler); NetClientSetErrorHandler(NetErrorHandler);
const wchar_t ** addrs; const char** addrs;
unsigned count; unsigned count;
count = GetGateKeeperSrvHostnames(&addrs); count = GetGateKeeperSrvHostnames(&addrs);

28
Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp

@ -89,9 +89,7 @@ PF_CONSOLE_CMD(
"string url", "string url",
"Set the server's status URL" "Set the server's status URL"
) { ) {
wchar_t *wurl = hsStringToWString((const char *)params[0]); SetServerStatusUrl(params[0]);
SetServerStatusUrl(wurl);
delete [] wurl;
} }
//============================================================================ //============================================================================
@ -101,9 +99,7 @@ PF_CONSOLE_CMD(
"string url", "string url",
"Set the server's new user sign-up URL" "Set the server's new user sign-up URL"
) { ) {
wchar_t *wurl = hsStringToWString((const char *)params[0]); SetServerSignupUrl(params[0]);
SetServerSignupUrl(wurl);
delete [] wurl;
} }
//============================================================================ //============================================================================
@ -113,9 +109,7 @@ PF_CONSOLE_CMD(
"string name", "string name",
"Set the displayable server name" "Set the displayable server name"
) { ) {
wchar_t *wname = hsStringToWString((const char *)params[0]); SetServerDisplayName(params[0]);
SetServerDisplayName(wname);
delete [] wname;
} }
@ -130,9 +124,7 @@ PF_CONSOLE_CMD(
"string address", "string address",
"Set the File Server address" "Set the File Server address"
) { ) {
wchar_t *wHost = hsStringToWString((const char *)params[0]); SetFileSrvHostname(params[0]);
SetFileSrvHostname(wHost);
delete [] wHost;
} }
@ -147,9 +139,7 @@ PF_CONSOLE_CMD(
"string address", "string address",
"Set the Auth Server address" "Set the Auth Server address"
) { ) {
wchar_t *wHost = hsStringToWString((const char *)params[0]); SetAuthSrvHostname(params[0]);
SetAuthSrvHostname(wHost);
delete [] wHost;
} }
//============================================================================ //============================================================================
@ -200,9 +190,7 @@ PF_CONSOLE_CMD(
"string address", "string address",
"Set the Csr Server address" "Set the Csr Server address"
) { ) {
wchar_t *wHost = hsStringToWString((const char *)params[0]); SetCsrSrvHostname(params[0]);
SetCsrSrvHostname(wHost);
delete [] wHost;
} }
//============================================================================ //============================================================================
@ -294,9 +282,7 @@ PF_CONSOLE_CMD(
"string address", "string address",
"Set the GateKeeper Server address" "Set the GateKeeper Server address"
) { ) {
wchar_t *wHost = hsStringToWString((const char *)params[0]); SetGateKeeperSrvHostname(params[0]);
SetGateKeeperSrvHostname(wHost);
delete [] wHost;
} }
//============================================================================ //============================================================================

14
Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcIo.h

@ -213,7 +213,7 @@ FAsyncNotifySocketProc AsyncSocketFindNotifyProc (
void AsyncSocketConnect ( void AsyncSocketConnect (
AsyncCancelId * cancelId, AsyncCancelId * cancelId,
const NetAddress & netAddr, const plNetAddress& netAddr,
FAsyncNotifySocketProc notifyProc, FAsyncNotifySocketProc notifyProc,
void * param = nil, void * param = nil,
const void * sendData = nil, const void * sendData = nil,
@ -275,11 +275,11 @@ void AsyncSocketSetBacklogAlloc (
// for connections with hard-coded behavior, set the notifyProc here (e.g. for use // for connections with hard-coded behavior, set the notifyProc here (e.g. for use
// protocols like SNMP on port 25) // protocols like SNMP on port 25)
unsigned AsyncSocketStartListening ( unsigned AsyncSocketStartListening (
const NetAddress & listenAddr, const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc = nil FAsyncNotifySocketProc notifyProc = nil
); );
void AsyncSocketStopListening ( void AsyncSocketStopListening (
const NetAddress & listenAddr, const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc = nil FAsyncNotifySocketProc notifyProc = nil
); );
@ -297,15 +297,15 @@ void AsyncSocketEnableNagling (
typedef void (* FAsyncLookupProc) ( typedef void (* FAsyncLookupProc) (
void * param, void * param,
const wchar_t name[], const char name[],
unsigned addrCount, unsigned addrCount,
const NetAddress addrs[] const plNetAddress addrs[]
); );
void AsyncAddressLookupName ( void AsyncAddressLookupName (
AsyncCancelId * cancelId, AsyncCancelId * cancelId,
FAsyncLookupProc lookupProc, FAsyncLookupProc lookupProc,
const wchar_t name[], const char name[],
unsigned port, unsigned port,
void * param void * param
); );
@ -313,7 +313,7 @@ void AsyncAddressLookupName (
void AsyncAddressLookupAddr ( void AsyncAddressLookupAddr (
AsyncCancelId * cancelId, AsyncCancelId * cancelId,
FAsyncLookupProc lookupProc, FAsyncLookupProc lookupProc,
const NetAddress & address, const plNetAddress& address,
void * param void * param
); );

6
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp

@ -540,13 +540,13 @@ static SOCKET ListenSocket (NetAddress * listenAddr) {
); );
*/ */
NetAddressNode node = listenAddr->GetHost(); uint32_t node = listenAddr->GetHost();
unsigned port = listenAddr->GetPort(); uint16_t port = listenAddr->GetPort();
// bind socket to port // bind socket to port
sockaddr_in addr; sockaddr_in addr;
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons((uint16_t)port); addr.sin_port = htons(port);
addr.sin_addr.S_un.S_addr = node; addr.sin_addr.S_un.S_addr = node;
memset(addr.sin_zero, 0, sizeof(addr.sin_zero)); memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
if (bind(s, (sockaddr *) &addr, sizeof(addr))) { if (bind(s, (sockaddr *) &addr, sizeof(addr))) {

17
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Dns.cpp

@ -69,7 +69,7 @@ struct Lookup {
FAsyncLookupProc lookupProc; FAsyncLookupProc lookupProc;
unsigned port; unsigned port;
void * param; void * param;
wchar_t name[kMaxLookupName]; char name[kMaxLookupName];
char buffer[MAXGETHOSTSTRUCT]; char buffer[MAXGETHOSTSTRUCT];
}; };
@ -122,7 +122,7 @@ static void LookupProcess (Lookup * lookup, unsigned error) {
} }
if (host.h_name && host.h_name[0]) if (host.h_name && host.h_name[0])
StrToUnicode(lookup->name, host.h_name, arrsize(lookup->name)); strncpy(lookup->name, host.h_name, arrsize(lookup->name));
if (lookup->lookupProc) if (lookup->lookupProc)
lookup->lookupProc(lookup->param, lookup->name, count, addrs); lookup->lookupProc(lookup->param, lookup->name, count, addrs);
@ -271,7 +271,7 @@ void DnsDestroy (unsigned exitThreadWaitMs) {
void AsyncAddressLookupName ( void AsyncAddressLookupName (
AsyncCancelId * cancelId, // out AsyncCancelId * cancelId, // out
FAsyncLookupProc lookupProc, FAsyncLookupProc lookupProc,
const wchar_t name[], const char* name,
unsigned port, unsigned port,
void * param void * param
) { ) {
@ -282,9 +282,8 @@ void AsyncAddressLookupName (
PerfAddCounter(kAsyncPerfNameLookupAttemptsTotal, 1); PerfAddCounter(kAsyncPerfNameLookupAttemptsTotal, 1);
// Get name/port // Get name/port
char ansiName[kMaxLookupName]; char* ansiName = strdup(name);
StrToAnsi(ansiName, name, arrsize(ansiName)); if (char* portStr = StrChr(ansiName, ':')) {
if (char * portStr = StrChr(ansiName, ':')) {
if (unsigned newPort = StrToUnsigned(portStr + 1, nil, 10)) if (unsigned newPort = StrToUnsigned(portStr + 1, nil, 10))
port = newPort; port = newPort;
*portStr = 0; *portStr = 0;
@ -295,7 +294,7 @@ void AsyncAddressLookupName (
lookup->lookupProc = lookupProc; lookup->lookupProc = lookupProc;
lookup->port = port; lookup->port = port;
lookup->param = param; lookup->param = param;
StrCopy(lookup->name, name, arrsize(lookup->name)); strncpy(lookup->name, name, arrsize(lookup->name));
s_critsect.Enter(); s_critsect.Enter();
{ {
@ -312,7 +311,7 @@ void AsyncAddressLookupName (
lookup->cancelHandle = WSAAsyncGetHostByName( lookup->cancelHandle = WSAAsyncGetHostByName(
s_lookupWindow, s_lookupWindow,
WM_LOOKUP_FOUND_HOST, WM_LOOKUP_FOUND_HOST,
ansiName, name,
&lookup->buffer[0], &lookup->buffer[0],
sizeof(lookup->buffer) sizeof(lookup->buffer)
); );
@ -342,7 +341,7 @@ void AsyncAddressLookupAddr (
lookup->param = param; lookup->param = param;
plString str = address.GetHostString(); plString str = address.GetHostString();
wcsncpy(lookup->name, (const wchar_t*)str.ToUtf16().GetData(), 127); strncpy(lookup->name, str.c_str(), arrsize(lookup->name));
s_critsect.Enter(); s_critsect.Enter();
{ {

64
Sources/Plasma/NucleusLib/pnNetBase/pnNbSrvs.cpp

@ -53,26 +53,26 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
* *
***/ ***/
static wchar_t s_authAddrConsole[64] = {0}; static char s_authAddrConsole[64] = {0};
static const wchar_t * s_authAddrs[] = { static const char* s_authAddrs[] = {
s_authAddrConsole s_authAddrConsole
}; };
static wchar_t s_fileAddrConsole[64] = {0}; static char s_fileAddrConsole[64] = {0};
static const wchar_t * s_fileAddrs[] = { static const char* s_fileAddrs[] = {
s_fileAddrConsole s_fileAddrConsole
}; };
static wchar_t s_csrAddrConsole[64] = {0}; static char s_csrAddrConsole[64] = {0};
static const wchar_t * s_csrAddrs[] = { static const char* s_csrAddrs[] = {
s_csrAddrConsole s_csrAddrConsole
}; };
static wchar_t s_gateKeeperAddrConsole[64] = {0}; static char s_gateKeeperAddrConsole[64] = {0};
static const wchar_t * s_gateKeeperAddrs[] = { static const char* s_gateKeeperAddrs[] = {
s_gateKeeperAddrConsole s_gateKeeperAddrConsole
}; };
@ -86,97 +86,97 @@ static const wchar_t * s_gateKeeperAddrs[] = {
//============================================================================ //============================================================================
// Auth // Auth
//============================================================================ //============================================================================
unsigned GetAuthSrvHostnames (const wchar_t *** addrs) { unsigned GetAuthSrvHostnames (const char*** addrs) {
*addrs = s_authAddrs; *addrs = s_authAddrs;
return arrsize(s_authAddrs); return arrsize(s_authAddrs);
} }
//============================================================================ //============================================================================
void SetAuthSrvHostname (const wchar_t addr[]) { void SetAuthSrvHostname (const char addr[]) {
wcsncpy(s_authAddrConsole, addr, arrsize(s_authAddrConsole)); strncpy(s_authAddrConsole, addr, arrsize(s_authAddrConsole));
} }
//============================================================================ //============================================================================
// File // File
//============================================================================ //============================================================================
unsigned GetFileSrvHostnames (const wchar_t *** addrs) { unsigned GetFileSrvHostnames (const char*** addrs) {
*addrs = s_fileAddrs; *addrs = s_fileAddrs;
return arrsize(s_fileAddrs); return arrsize(s_fileAddrs);
} }
//============================================================================ //============================================================================
void SetFileSrvHostname (const wchar_t addr[]) { void SetFileSrvHostname (const char addr[]) {
wcsncpy(s_fileAddrConsole, addr, arrsize(s_fileAddrConsole)); strncpy(s_fileAddrConsole, addr, arrsize(s_fileAddrConsole));
} }
//============================================================================ //============================================================================
// Csr // Csr
//============================================================================ //============================================================================
unsigned GetCsrSrvHostnames (const wchar_t *** addrs) { unsigned GetCsrSrvHostnames (const char*** addrs) {
*addrs = s_csrAddrs; *addrs = s_csrAddrs;
return arrsize(s_csrAddrs); return arrsize(s_csrAddrs);
} }
//============================================================================ //============================================================================
void SetCsrSrvHostname (const wchar_t addr[]) { void SetCsrSrvHostname (const char addr[]) {
wcsncpy(s_csrAddrConsole, addr, arrsize(s_csrAddrConsole)); strncpy(s_csrAddrConsole, addr, arrsize(s_csrAddrConsole));
} }
//============================================================================ //============================================================================
// GateKeeper // GateKeeper
//============================================================================ //============================================================================
unsigned GetGateKeeperSrvHostnames (const wchar_t *** addrs) { unsigned GetGateKeeperSrvHostnames (const char*** addrs) {
*addrs = s_gateKeeperAddrs; *addrs = s_gateKeeperAddrs;
return arrsize(s_gateKeeperAddrs); return arrsize(s_gateKeeperAddrs);
} }
//============================================================================ //============================================================================
void SetGateKeeperSrvHostname (const wchar_t addr[]) { void SetGateKeeperSrvHostname (const char addr[]) {
wcsncpy(s_gateKeeperAddrConsole, addr, arrsize(s_gateKeeperAddrConsole)); strncpy(s_gateKeeperAddrConsole, addr, arrsize(s_gateKeeperAddrConsole));
} }
//============================================================================ //============================================================================
// User-visible Server // User-visible Server
//============================================================================ //============================================================================
static wchar_t s_serverStatusUrl[256] = {0}; static char s_serverStatusUrl[256] = {0};
static wchar_t s_serverSignupUrl[256] = {0}; static char s_serverSignupUrl[256] = {0};
static wchar_t s_serverName[256] = {0}; static char s_serverName[256] = {0};
//============================================================================ //============================================================================
const wchar_t *GetServerStatusUrl () { const char* GetServerStatusUrl () {
return s_serverStatusUrl; return s_serverStatusUrl;
} }
//============================================================================ //============================================================================
void SetServerStatusUrl (const wchar_t url[]) { void SetServerStatusUrl (const char url[]) {
wcsncpy(s_serverStatusUrl, url, arrsize(s_serverStatusUrl)); strncpy(s_serverStatusUrl, url, arrsize(s_serverStatusUrl));
} }
//============================================================================ //============================================================================
const wchar_t *GetServerSignupUrl () { const char* GetServerSignupUrl () {
return s_serverSignupUrl; return s_serverSignupUrl;
} }
//============================================================================ //============================================================================
void SetServerSignupUrl (const wchar_t url[]) { void SetServerSignupUrl (const char url[]) {
wcsncpy(s_serverSignupUrl, url, arrsize(s_serverSignupUrl)); strncpy(s_serverSignupUrl, url, arrsize(s_serverSignupUrl));
} }
//============================================================================ //============================================================================
const wchar_t *GetServerDisplayName () { const char* GetServerDisplayName () {
return s_serverName; return s_serverName;
} }
//============================================================================ //============================================================================
void SetServerDisplayName (const wchar_t name[]) { void SetServerDisplayName (const char name[]) {
wcsncpy(s_serverName, name, arrsize(s_serverName)); strncpy(s_serverName, name, arrsize(s_serverName));
} }

28
Sources/Plasma/NucleusLib/pnNetBase/pnNbSrvs.h

@ -84,25 +84,25 @@ enum ESrvType {
* *
***/ ***/
unsigned GetAuthSrvHostnames (const wchar_t *** addrs); // returns addrCount unsigned GetAuthSrvHostnames (const char*** addrs); // returns addrCount
void SetAuthSrvHostname (const wchar_t addr[]); void SetAuthSrvHostname (const char addr[]);
unsigned GetFileSrvHostnames (const wchar_t *** addrs); // returns addrCount unsigned GetFileSrvHostnames (const char*** addrs); // returns addrCount
void SetFileSrvHostname (const wchar_t addr[]); void SetFileSrvHostname (const char addr[]);
unsigned GetCsrSrvHostnames (const wchar_t *** addrs); // returns addrCount unsigned GetCsrSrvHostnames (const char*** addrs); // returns addrCount
void SetCsrSrvHostname (const wchar_t addr[]); void SetCsrSrvHostname (const char addr[]);
unsigned GetGateKeeperSrvHostnames (const wchar_t *** addrs); // returns addrCount unsigned GetGateKeeperSrvHostnames (const char*** addrs); // returns addrCount
void SetGateKeeperSrvHostname (const wchar_t addr[]); void SetGateKeeperSrvHostname (const char addr[]);
const wchar_t *GetServerStatusUrl (); const char *GetServerStatusUrl ();
void SetServerStatusUrl (const wchar_t url[]); void SetServerStatusUrl (const char url[]);
const wchar_t *GetServerSignupUrl (); const char *GetServerSignupUrl ();
void SetServerSignupUrl (const wchar_t url[]); void SetServerSignupUrl (const char url[]);
const wchar_t *GetServerDisplayName (); const char *GetServerDisplayName ();
void SetServerDisplayName (const wchar_t name[]); void SetServerDisplayName (const char name[]);
#endif // pnNbSrvs_inc #endif // pnNbSrvs_inc

4
Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Auth/pnNpCli2Auth.h

@ -678,7 +678,7 @@ struct Auth2Cli_AccountExistsReply {
extern const NetMsg kNetMsg_Auth2Cli_ServerAddr; extern const NetMsg kNetMsg_Auth2Cli_ServerAddr;
struct Auth2Cli_ServerAddr { struct Auth2Cli_ServerAddr {
uint32_t messageId; uint32_t messageId;
NetAddressNode srvAddr; uint32_t srvAddr;
Uuid token; Uuid token;
}; };
@ -719,7 +719,7 @@ struct Auth2Cli_AgeReply {
uint32_t ageMcpId; uint32_t ageMcpId;
Uuid ageInstId; Uuid ageInstId;
uint32_t ageVaultId; uint32_t ageVaultId;
NetAddressNode gameSrvNode; uint32_t gameSrvNode;
}; };
// AcctCreateReply // AcctCreateReply

2
Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Srv2Mcp/pnNpSrv2Mcp.h

@ -193,7 +193,7 @@ struct Srv2Mcp_KickPlayer : SrvMsgHeader {
struct Mcp2Srv_AgeJoinReply : SrvMsgHeader { struct Mcp2Srv_AgeJoinReply : SrvMsgHeader {
uint32_t ageMcpId; uint32_t ageMcpId;
Uuid ageUuid; Uuid ageUuid;
NetAddressNode gameSrvNode; uint32_t gameSrvNode;
}; };
struct Mcp2Srv_AgeSpawnRequest : SrvMsgHeader { struct Mcp2Srv_AgeSpawnRequest : SrvMsgHeader {

9
Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.cpp

@ -410,7 +410,7 @@ static void Connect(const plNetAddress& addr, ConnectParam * cp) {
//============================================================================ //============================================================================
static void AsyncLookupCallback ( static void AsyncLookupCallback (
void * param, void * param,
const wchar_t name[], const char name[],
unsigned addrCount, unsigned addrCount,
const plNetAddress addrs[] const plNetAddress addrs[]
) { ) {
@ -568,7 +568,7 @@ void SimpleNetDestroyChannel (unsigned channelId) {
//============================================================================ //============================================================================
void SimpleNetStartConnecting ( void SimpleNetStartConnecting (
unsigned channelId, unsigned channelId,
const wchar_t addr[], const char addr[],
FSimpleNetOnConnect onConnect, FSimpleNetOnConnect onConnect,
void * param void * param
) { ) {
@ -593,7 +593,7 @@ void SimpleNetStartConnecting (
ASSERT(cp->channel); ASSERT(cp->channel);
// Do we need to lookup the address? // Do we need to lookup the address?
const wchar_t * name = addr; const char* name = addr;
while (unsigned ch = *name) { while (unsigned ch = *name) {
++name; ++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) { if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
@ -610,8 +610,7 @@ void SimpleNetStartConnecting (
} }
} }
if (!name[0]) { if (!name[0]) {
plString saddr = _TEMP_CONVERT_FROM_WCHAR_T(addr); plNetAddress netAddr(addr, kNetDefaultSimpleNetPort);
plNetAddress netAddr(saddr.c_str(), kNetDefaultSimpleNetPort);
Connect(netAddr, cp); Connect(netAddr, cp);
} }
} }

1
Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt

@ -39,7 +39,6 @@ set(pnUtils_SOURCES
if(WIN32) if(WIN32)
set(pnUtils_WIN32 set(pnUtils_WIN32
Win32/pnUtW32Addr.cpp
Win32/pnUtW32Misc.cpp Win32/pnUtW32Misc.cpp
Win32/pnUtW32Path.cpp Win32/pnUtW32Path.cpp
Win32/pnUtW32Str.cpp Win32/pnUtW32Str.cpp

117
Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Addr.cpp

@ -1,117 +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 <http://www.gnu.org/licenses/>.
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/pnUtils/Private/Win32/pnUtW32Addr.cpp
*
***/
#include "../pnUtils.h"
/*****************************************************************************
*
* Internal functions
*
***/
//===========================================================================
static NetAddressNode NodeFromString (const wchar_t * string[]) {
// skip leading whitespace
const wchar_t * str = *string;
while (iswspace(*str))
++str;
// This function handles partial ip addresses (61.33)
// as well as full dotted quads. The address can be
// terminated by whitespace or ':' as well as '\0'
uint8_t data[4];
* (uint32_t *) data = 0;
for (unsigned i = sizeof(data); i--; ) {
if (!iswdigit(*str))
return (unsigned)-1;
unsigned value = StrToUnsigned(str, &str, 10);
if (value >= 256)
return (unsigned)-1;
data[i] = (uint8_t) value;
if (!*str || (*str == ':') || iswspace(*str))
break;
static const wchar_t s_separator[] = L"\0...";
if (*str++ != s_separator[i])
return (unsigned)-1;
}
*string = str;
return * (NetAddressNode *) &data[0];
}
/*****************************************************************************
*
* Exports
*
***/
//===========================================================================
bool NetAddressFromString (NetAddress * addr, const wchar_t str[], uint16_t defaultPort) {
ASSERT(addr);
ASSERT(str);
for (;;) {
NetAddressNode node = NodeFromString(&str);
if (node == (unsigned)-1)
break;
if (*str == L':')
defaultPort = StrToUnsigned(str + 1, nil, 10);
addr->SetPort((uint16_t)defaultPort);
addr->SetHostLE(node);
return true;
}
// address already zeroed
return false;
}

28
Sources/Plasma/NucleusLib/pnUtils/pnUtAddr.h

@ -50,36 +50,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "Pch.h" #include "Pch.h"
/*****************************************************************************
*
* Types and constants
*
***/
/*struct NetAddress {
uint8_t data[24];
};
typedef unsigned NetAddressNode;*/
#include "pnNetCommon/plNetAddress.h" #include "pnNetCommon/plNetAddress.h"
typedef plNetAddress NetAddress; typedef plNetAddress NetAddress;
typedef uint32_t NetAddressNode;
/*****************************************************************************
*
* Functions
*
***/
// 'str' must be in the form of a dotted IP address (IPv4 or IPv6)
// - names which require DNS lookup will cause the function to return false
bool NetAddressFromString (
NetAddress * addr,
const wchar_t str[],
uint16_t defaultPort
);
#endif #endif

22
Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp

@ -110,11 +110,11 @@ static bool s_loginComplete = false;
static bool s_hasAuthSrvIpAddress = false; static bool s_hasAuthSrvIpAddress = false;
static bool s_hasFileSrvIpAddress = false; static bool s_hasFileSrvIpAddress = false;
static ENetError s_authResult = kNetErrAuthenticationFailed; static ENetError s_authResult = kNetErrAuthenticationFailed;
static wchar_t s_authSrvAddr[256]; static char s_authSrvAddr[256];
static wchar_t s_fileSrvAddr[256]; static char s_fileSrvAddr[256];
static wchar_t s_iniServerAddr[256]; static char s_iniServerAddr[256];
static wchar_t s_iniFileServerAddr[256]; static char s_iniFileServerAddr[256];
static wchar_t s_iniAccountUsername[kMaxAccountNameLength]; static wchar_t s_iniAccountUsername[kMaxAccountNameLength];
static ShaDigest s_namePassHash; static ShaDigest s_namePassHash;
static wchar_t s_iniAuthToken[kMaxPublisherAuthKeyLength]; static wchar_t s_iniAuthToken[kMaxPublisherAuthKeyLength];
@ -667,7 +667,7 @@ static void AuthSrvIpAddressCallback (
void * param, void * param,
const wchar_t addr[] const wchar_t addr[]
) { ) {
StrCopy(s_authSrvAddr, addr, arrsize(s_authSrvAddr)); StrToAnsi(s_authSrvAddr, addr, arrsize(s_authSrvAddr));
s_hasAuthSrvIpAddress = true; s_hasAuthSrvIpAddress = true;
} }
@ -677,7 +677,7 @@ static void FileSrvIpAddressCallback (
void * param, void * param,
const wchar_t addr[] const wchar_t addr[]
) { ) {
StrCopy(s_fileSrvAddr, addr, arrsize(s_fileSrvAddr)); StrToAnsi(s_fileSrvAddr, addr, arrsize(s_fileSrvAddr));
s_hasFileSrvIpAddress = true; s_hasFileSrvIpAddress = true;
} }
@ -822,12 +822,12 @@ void NetCommUpdate () {
//============================================================================ //============================================================================
void NetCommConnect () { void NetCommConnect () {
const wchar_t ** addrs; const char** addrs;
unsigned count; unsigned count;
hsBool connectedToKeeper = false; hsBool connectedToKeeper = false;
// if a console override was specified for a authserv, connect directly to the authserver rather than going through the gatekeeper // if a console override was specified for a authserv, connect directly to the authserver rather than going through the gatekeeper
if((count = GetAuthSrvHostnames(&addrs)) && wcslen(addrs[0])) if((count = GetAuthSrvHostnames(&addrs)) && strlen(addrs[0]))
{ {
NetCliAuthStartConnect(addrs, count); NetCliAuthStartConnect(addrs, count);
} }
@ -845,7 +845,7 @@ void NetCommConnect () {
AsyncSleep(10); AsyncSleep(10);
} }
const wchar_t * authSrv[] = { const char* authSrv[] = {
s_authSrvAddr s_authSrvAddr
}; };
NetCliAuthStartConnect(authSrv, 1); NetCliAuthStartConnect(authSrv, 1);
@ -854,7 +854,7 @@ void NetCommConnect () {
if (!gDataServerLocal) { if (!gDataServerLocal) {
// if a console override was specified for a filesrv, connect directly to the fileserver rather than going through the gatekeeper // if a console override was specified for a filesrv, connect directly to the fileserver rather than going through the gatekeeper
if((count = GetFileSrvHostnames(&addrs)) && wcslen(addrs[0])) if((count = GetFileSrvHostnames(&addrs)) && strlen(addrs[0]))
{ {
NetCliFileStartConnect(addrs, count); NetCliFileStartConnect(addrs, count);
} }
@ -874,7 +874,7 @@ void NetCommConnect () {
AsyncSleep(10); AsyncSleep(10);
} }
const wchar_t * fileSrv[] = { const char* fileSrv[] = {
s_fileSrvAddr s_fileSrvAddr
}; };
NetCliFileStartConnect(fileSrv, 1); NetCliFileStartConnect(fileSrv, 1);

19
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp

@ -90,7 +90,7 @@ struct CliAuConn : AtomicRef {
LINK(CliAuConn) link; LINK(CliAuConn) link;
AsyncSocket sock; AsyncSocket sock;
NetCli * cli; NetCli * cli;
wchar_t name[MAX_PATH]; char name[MAX_PATH];
plNetAddress addr; plNetAddress addr;
Uuid token; Uuid token;
unsigned seq; unsigned seq;
@ -197,7 +197,7 @@ struct AgeRequestTrans : NetAuthTrans {
unsigned m_ageMcpId; unsigned m_ageMcpId;
Uuid m_ageInstId; Uuid m_ageInstId;
unsigned m_ageVaultId; unsigned m_ageVaultId;
NetAddressNode m_gameSrvNode; uint32_t m_gameSrvNode;
AgeRequestTrans ( AgeRequestTrans (
const wchar_t ageName[], const wchar_t ageName[],
@ -1527,7 +1527,7 @@ static void Connect (
//============================================================================ //============================================================================
static void Connect ( static void Connect (
const wchar_t name[], const char name[],
const NetAddress & addr const NetAddress & addr
) { ) {
ASSERT(s_running); ASSERT(s_running);
@ -1536,7 +1536,7 @@ static void Connect (
conn->addr = addr; conn->addr = addr;
conn->seq = ConnNextSequence(); conn->seq = ConnNextSequence();
conn->lastHeardTimeMs = GetNonZeroTimeMs(); // used in connect timeout, and ping timeout conn->lastHeardTimeMs = GetNonZeroTimeMs(); // used in connect timeout, and ping timeout
StrCopy(conn->name, name, arrsize(conn->name)); strncpy(conn->name, name, arrsize(conn->name));
conn->IncRef("Lifetime"); conn->IncRef("Lifetime");
conn->AutoReconnect(); conn->AutoReconnect();
@ -1545,7 +1545,7 @@ static void Connect (
//============================================================================ //============================================================================
static void AsyncLookupCallback ( static void AsyncLookupCallback (
void * param, void * param,
const wchar_t name[], const char name[],
unsigned addrCount, unsigned addrCount,
const plNetAddress addrs[] const plNetAddress addrs[]
) { ) {
@ -5121,8 +5121,8 @@ void AuthPingEnable (bool enable) {
//============================================================================ //============================================================================
void NetCliAuthStartConnect ( void NetCliAuthStartConnect (
const wchar_t * authAddrList[], const char* authAddrList[],
unsigned authAddrCount uint32_t authAddrCount
) { ) {
// TEMP: Only connect to one auth server until we fill out this module // TEMP: Only connect to one auth server until we fill out this module
// to choose the "best" auth connection. // to choose the "best" auth connection.
@ -5130,7 +5130,7 @@ void NetCliAuthStartConnect (
for (unsigned i = 0; i < authAddrCount; ++i) { for (unsigned i = 0; i < authAddrCount; ++i) {
// Do we need to lookup the address? // Do we need to lookup the address?
const wchar_t * name = authAddrList[i]; const char* name = authAddrList[i];
while (unsigned ch = *name) { while (unsigned ch = *name) {
++name; ++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) { if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
@ -5146,8 +5146,7 @@ void NetCliAuthStartConnect (
} }
} }
if (!name[0]) { if (!name[0]) {
NetAddress addr; NetAddress addr(authAddrList[i], kNetDefaultClientPort);
NetAddressFromString(&addr, authAddrList[i], kNetDefaultClientPort);
Connect(authAddrList[i], addr); Connect(authAddrList[i], addr);
} }
} }

4
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h

@ -62,8 +62,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Connect // Connect
//============================================================================ //============================================================================
void NetCliAuthStartConnect ( void NetCliAuthStartConnect (
const wchar_t * authAddrList[], const char* authAddrList[],
unsigned authAddrCount uint32_t authAddrCount
); );
bool NetCliAuthQueryConnected (); bool NetCliAuthQueryConnected ();
void NetCliAuthAutoReconnectEnable (bool enable); // is enabled by default void NetCliAuthAutoReconnectEnable (bool enable); // is enabled by default

11
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.cpp

@ -413,7 +413,7 @@ static void Connect (
//============================================================================ //============================================================================
static void AsyncLookupCallback ( static void AsyncLookupCallback (
void * param, void * param,
const wchar_t name[], const char name[],
unsigned addrCount, unsigned addrCount,
const NetAddress addrs[] const NetAddress addrs[]
) { ) {
@ -830,8 +830,8 @@ unsigned CsrGetConnId () {
//============================================================================ //============================================================================
void NetCliCsrStartConnect ( void NetCliCsrStartConnect (
const wchar_t * addrList[], const char* addrList[],
unsigned addrCount, uint32_t addrCount,
FNetCliCsrConnectedCallback callback, FNetCliCsrConnectedCallback callback,
void * param void * param
) { ) {
@ -840,7 +840,7 @@ void NetCliCsrStartConnect (
for (unsigned i = 0; i < addrCount; ++i) { for (unsigned i = 0; i < addrCount; ++i) {
// Do we need to lookup the address? // Do we need to lookup the address?
const wchar_t * name = addrList[i]; const char* name = addrList[i];
while (unsigned ch = *name) { while (unsigned ch = *name) {
++name; ++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) { if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
@ -860,8 +860,7 @@ void NetCliCsrStartConnect (
} }
} }
if (!name[0]) { if (!name[0]) {
NetAddress addr; NetAddress addr(addrList[i], kNetDefaultClientPort);
NetAddressFromString(&addr, addrList[i], kNetDefaultClientPort);
ConnectParam * cp = new ConnectParam; ConnectParam * cp = new ConnectParam;
cp->callback = callback; cp->callback = callback;

4
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.h

@ -62,8 +62,8 @@ typedef void (*FNetCliCsrConnectedCallback) (
unsigned latestBuildId unsigned latestBuildId
); );
void NetCliCsrStartConnect ( void NetCliCsrStartConnect (
const wchar_t * addrList[], const char* addrList[],
unsigned addrCount, uint32_t addrCount,
FNetCliCsrConnectedCallback callback = nil, FNetCliCsrConnectedCallback callback = nil,
void * param = nil void * param = nil
); );

26
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp

@ -64,7 +64,7 @@ struct CliFileConn : AtomicRef {
LINK(CliFileConn) link; LINK(CliFileConn) link;
CLock sockLock; // to protect the socket pointer so we don't nuke it while using it CLock sockLock; // to protect the socket pointer so we don't nuke it while using it
AsyncSocket sock; AsyncSocket sock;
wchar_t name[MAX_PATH]; char name[MAX_PATH];
NetAddress addr; NetAddress addr;
unsigned seq; unsigned seq;
ARRAY(uint8_t) recvBuffer; ARRAY(uint8_t) recvBuffer;
@ -539,13 +539,13 @@ static void Connect (CliFileConn * conn) {
//============================================================================ //============================================================================
static void Connect ( static void Connect (
const wchar_t name[], const char name[],
const NetAddress & addr const NetAddress & addr
) { ) {
ASSERT(s_running); ASSERT(s_running);
CliFileConn * conn = NEWZERO(CliFileConn); CliFileConn * conn = NEWZERO(CliFileConn);
StrCopy(conn->name, name, arrsize(conn->name)); strncpy(conn->name, name, arrsize(conn->name));
conn->addr = addr; conn->addr = addr;
conn->buildId = s_connectBuildId; conn->buildId = s_connectBuildId;
conn->serverType = s_serverType; conn->serverType = s_serverType;
@ -559,7 +559,7 @@ static void Connect (
//============================================================================ //============================================================================
static void AsyncLookupCallback ( static void AsyncLookupCallback (
void * param, void * param,
const wchar_t name[], const char name[],
unsigned addrCount, unsigned addrCount,
const NetAddress addrs[] const NetAddress addrs[]
) { ) {
@ -1334,8 +1334,8 @@ unsigned FileGetConnId () {
//============================================================================ //============================================================================
void NetCliFileStartConnect ( void NetCliFileStartConnect (
const wchar_t * fileAddrList[], const char* fileAddrList[],
unsigned fileAddrCount, uint32_t fileAddrCount,
bool isPatcher /* = false */ bool isPatcher /* = false */
) { ) {
// TEMP: Only connect to one file server until we fill out this module // TEMP: Only connect to one file server until we fill out this module
@ -1346,7 +1346,7 @@ void NetCliFileStartConnect (
for (unsigned i = 0; i < fileAddrCount; ++i) { for (unsigned i = 0; i < fileAddrCount; ++i) {
// Do we need to lookup the address? // Do we need to lookup the address?
const wchar_t * name = fileAddrList[i]; const char* name = fileAddrList[i];
while (unsigned ch = *name) { while (unsigned ch = *name) {
++name; ++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) { if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
@ -1362,8 +1362,7 @@ void NetCliFileStartConnect (
} }
} }
if (!name[0]) { if (!name[0]) {
NetAddress addr; NetAddress addr(fileAddrList[i], kNetDefaultClientPort);
NetAddressFromString(&addr, fileAddrList[i], kNetDefaultClientPort);
Connect(fileAddrList[i], addr); Connect(fileAddrList[i], addr);
} }
} }
@ -1371,8 +1370,8 @@ void NetCliFileStartConnect (
//============================================================================ //============================================================================
void NetCliFileStartConnectAsServer ( void NetCliFileStartConnectAsServer (
const wchar_t * fileAddrList[], const char* fileAddrList[],
unsigned fileAddrCount, uint32_t fileAddrCount,
unsigned serverType, unsigned serverType,
unsigned serverBuildId unsigned serverBuildId
) { ) {
@ -1384,7 +1383,7 @@ void NetCliFileStartConnectAsServer (
for (unsigned i = 0; i < fileAddrCount; ++i) { for (unsigned i = 0; i < fileAddrCount; ++i) {
// Do we need to lookup the address? // Do we need to lookup the address?
const wchar_t * name = fileAddrList[i]; const char* name = fileAddrList[i];
while (unsigned ch = *name) { while (unsigned ch = *name) {
++name; ++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) { if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
@ -1400,8 +1399,7 @@ void NetCliFileStartConnectAsServer (
} }
} }
if (!name[0]) { if (!name[0]) {
NetAddress addr; NetAddress addr(fileAddrList[i], kNetDefaultServerPort);
NetAddressFromString(&addr, fileAddrList[i], kNetDefaultServerPort);
Connect(fileAddrList[i], addr); Connect(fileAddrList[i], addr);
} }
} }

4
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.h

@ -62,12 +62,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Connect // Connect
//============================================================================ //============================================================================
void NetCliFileStartConnect ( void NetCliFileStartConnect (
const wchar_t * fileAddrList[], const char* fileAddrList[],
unsigned fileAddrCount, unsigned fileAddrCount,
bool isPatcher = false bool isPatcher = false
); );
void NetCliFileStartConnectAsServer ( void NetCliFileStartConnectAsServer (
const wchar_t * fileAddrList[], const char* fileAddrList[],
unsigned fileAddrCount, unsigned fileAddrCount,
unsigned serverType, unsigned serverType,
unsigned serverBuildId unsigned serverBuildId

2
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp

@ -796,7 +796,7 @@ void GamePingEnable (bool enable) {
//============================================================================ //============================================================================
void NetCliGameStartConnect ( void NetCliGameStartConnect (
const NetAddressNode & node const uint32_t node
) { ) {
plNetAddress addr(node, kNetDefaultClientPort); plNetAddress addr(node, kNetDefaultClientPort);
Connect(addr); Connect(addr);

2
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.h

@ -61,7 +61,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Connect // Connect
//============================================================================ //============================================================================
void NetCliGameStartConnect ( void NetCliGameStartConnect (
const NetAddressNode & node const uint32_t node
); );
//============================================================================ //============================================================================

17
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp

@ -89,7 +89,7 @@ struct CliGkConn : AtomicRef {
LINK(CliGkConn) link; LINK(CliGkConn) link;
AsyncSocket sock; AsyncSocket sock;
NetCli * cli; NetCli * cli;
wchar_t name[MAX_PATH]; char name[MAX_PATH];
NetAddress addr; NetAddress addr;
Uuid token; Uuid token;
unsigned seq; unsigned seq;
@ -463,7 +463,7 @@ static void Connect (
//============================================================================ //============================================================================
static void Connect ( static void Connect (
const wchar_t name[], const char name[],
const NetAddress & addr const NetAddress & addr
) { ) {
ASSERT(s_running); ASSERT(s_running);
@ -472,7 +472,7 @@ static void Connect (
conn->addr = addr; conn->addr = addr;
conn->seq = ConnNextSequence(); conn->seq = ConnNextSequence();
conn->lastHeardTimeMs = GetNonZeroTimeMs(); // used in connect timeout, and ping timeout conn->lastHeardTimeMs = GetNonZeroTimeMs(); // used in connect timeout, and ping timeout
StrCopy(conn->name, name, arrsize(conn->name)); strncpy(conn->name, name, arrsize(conn->name));
conn->IncRef("Lifetime"); conn->IncRef("Lifetime");
conn->AutoReconnect(); conn->AutoReconnect();
@ -481,7 +481,7 @@ static void Connect (
//============================================================================ //============================================================================
static void AsyncLookupCallback ( static void AsyncLookupCallback (
void * param, void * param,
const wchar_t name[], const char name[],
unsigned addrCount, unsigned addrCount,
const NetAddress addrs[] const NetAddress addrs[]
) { ) {
@ -1053,14 +1053,14 @@ unsigned GateKeeperGetConnId () {
//============================================================================ //============================================================================
void NetCliGateKeeperStartConnect ( void NetCliGateKeeperStartConnect (
const wchar_t * gateKeeperAddrList[], const char* gateKeeperAddrList[],
unsigned gateKeeperAddrCount uint32_t gateKeeperAddrCount
) { ) {
gateKeeperAddrCount = min(gateKeeperAddrCount, 1); gateKeeperAddrCount = min(gateKeeperAddrCount, 1);
for (unsigned i = 0; i < gateKeeperAddrCount; ++i) { for (unsigned i = 0; i < gateKeeperAddrCount; ++i) {
// Do we need to lookup the address? // Do we need to lookup the address?
const wchar_t * name = gateKeeperAddrList[i]; const char* name = gateKeeperAddrList[i];
while (unsigned ch = *name) { while (unsigned ch = *name) {
++name; ++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) { if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
@ -1076,8 +1076,7 @@ void NetCliGateKeeperStartConnect (
} }
} }
if (!name[0]) { if (!name[0]) {
NetAddress addr; NetAddress addr(gateKeeperAddrList[i], kNetDefaultClientPort);
NetAddressFromString(&addr, gateKeeperAddrList[i], kNetDefaultClientPort);
Connect(gateKeeperAddrList[i], addr); Connect(gateKeeperAddrList[i], addr);
} }
} }

4
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.h

@ -62,8 +62,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Connect // Connect
//============================================================================ //============================================================================
void NetCliGateKeeperStartConnect ( void NetCliGateKeeperStartConnect (
const wchar_t * gateKeeperAddrList[], const char* gateKeeperAddrList[],
unsigned gateKeeperAddrCount uint32_t gateKeeperAddrCount
); );
bool NetCliGateKeeperQueryConnected (); bool NetCliGateKeeperQueryConnected ();

Loading…
Cancel
Save