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. 18
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Auth/pnNpCli2Auth.h
  12. 6
      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;
char *statusUrl = hsWStringToString(GetServerStatusUrl());
const char *statusUrl = GetServerStatusUrl();
CURL *hCurl = curl_easy_init();
// For reporting errors
@ -1133,7 +1133,6 @@ void StatusCallback(void *param)
}
curl_easy_cleanup(hCurl);
delete [] statusUrl;
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)
{
const wchar_t *signupurl = GetServerSignupUrl();
ShellExecuteW(NULL, L"open", signupurl, NULL, NULL, SW_SHOWNORMAL);
const char* signupurl = GetServerSignupUrl();
ShellExecuteA(NULL, "open", signupurl, NULL, NULL, SW_SHOWNORMAL);
return TRUE;
}
@ -1461,25 +1460,27 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
memset(&si, 0, sizeof(si));
memset(&pi, 0, sizeof(pi));
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
{
StrCopy(cmdLine, s_patcherExeName, arrsize(cmdLine));
cmdLine << _TEMP_CONVERT_FROM_WCHAR_T(s_patcherExeName);
GetAuthSrvHostnames(&addrs);
if(wcslen(addrs[0]))
StrPrintf(cmdLine, arrsize(cmdLine), L"%ws /AuthSrv=%ws", cmdLine, addrs[0]);
if(strlen(addrs[0]))
cmdLine << plString::Format(" /AuthSrv=%s", addrs[0]);
GetFileSrvHostnames(&addrs);
if(wcslen(addrs[0]))
StrPrintf(cmdLine, arrsize(cmdLine), L"%ws /FileSrv=%ws", cmdLine, addrs[0]);
if(strlen(addrs[0]))
cmdLine << plString::Format(" /FileSrv=%s", addrs[0]);
GetGateKeeperSrvHostnames(&addrs);
if(wcslen(addrs[0]))
StrPrintf(cmdLine, arrsize(cmdLine), L"%ws /GateKeeperSrv=%ws", cmdLine, addrs[0]);
if(strlen(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);
}

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

@ -840,7 +840,9 @@ static void FileSrvIpAddressCallback (
plLauncherInfo *info = (plLauncherInfo *) param;
// 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);
@ -902,7 +904,7 @@ void UruPrepProc (void * param) {
s_patchComplete = false;
s_patchError = false;
const wchar_t ** addrs;
const char** addrs;
unsigned count;
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 *)
{
char *serverUrl = hsWStringToString(GetServerStatusUrl());
const char *serverUrl = GetServerStatusUrl();
CURL * hCurl = curl_easy_init();
curl_easy_setopt(hCurl, CURLOPT_ERRORBUFFER, s_curlError);
@ -631,7 +631,6 @@ static void StatusCallback(void *)
}
curl_easy_cleanup(hCurl);
delete [] serverUrl;
s_statusEvent.Signal();
}

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

@ -226,7 +226,9 @@ static void FileSrvIpAddressCallback (
}
// 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));
GetTempFileNameW(s_newPatcherFile, kPatcherExeFilename, 0, s_newPatcherFile);
@ -245,7 +247,7 @@ static bool SelfPatcherProc (bool * abort, plLauncherInfo *info) {
NetClientInitialize();
NetClientSetErrorHandler(NetErrorHandler);
const wchar_t ** addrs;
const char** addrs;
unsigned count;
count = GetGateKeeperSrvHostnames(&addrs);

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

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

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

@ -213,7 +213,7 @@ FAsyncNotifySocketProc AsyncSocketFindNotifyProc (
void AsyncSocketConnect (
AsyncCancelId * cancelId,
const NetAddress & netAddr,
const plNetAddress& netAddr,
FAsyncNotifySocketProc notifyProc,
void * param = 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
// protocols like SNMP on port 25)
unsigned AsyncSocketStartListening (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc = nil
);
void AsyncSocketStopListening (
const NetAddress & listenAddr,
const plNetAddress& listenAddr,
FAsyncNotifySocketProc notifyProc = nil
);
@ -297,15 +297,15 @@ void AsyncSocketEnableNagling (
typedef void (* FAsyncLookupProc) (
void * param,
const wchar_t name[],
const char name[],
unsigned addrCount,
const NetAddress addrs[]
const plNetAddress addrs[]
);
void AsyncAddressLookupName (
AsyncCancelId * cancelId,
FAsyncLookupProc lookupProc,
const wchar_t name[],
const char name[],
unsigned port,
void * param
);
@ -313,7 +313,7 @@ void AsyncAddressLookupName (
void AsyncAddressLookupAddr (
AsyncCancelId * cancelId,
FAsyncLookupProc lookupProc,
const NetAddress & address,
const plNetAddress& address,
void * param
);

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

@ -540,13 +540,13 @@ static SOCKET ListenSocket (NetAddress * listenAddr) {
);
*/
NetAddressNode node = listenAddr->GetHost();
unsigned port = listenAddr->GetPort();
uint32_t node = listenAddr->GetHost();
uint16_t port = listenAddr->GetPort();
// bind socket to port
sockaddr_in addr;
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;
memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
if (bind(s, (sockaddr *) &addr, sizeof(addr))) {

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

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

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 const wchar_t * s_authAddrs[] = {
static char s_authAddrConsole[64] = {0};
static const char* s_authAddrs[] = {
s_authAddrConsole
};
static wchar_t s_fileAddrConsole[64] = {0};
static const wchar_t * s_fileAddrs[] = {
static char s_fileAddrConsole[64] = {0};
static const char* s_fileAddrs[] = {
s_fileAddrConsole
};
static wchar_t s_csrAddrConsole[64] = {0};
static const wchar_t * s_csrAddrs[] = {
static char s_csrAddrConsole[64] = {0};
static const char* s_csrAddrs[] = {
s_csrAddrConsole
};
static wchar_t s_gateKeeperAddrConsole[64] = {0};
static const wchar_t * s_gateKeeperAddrs[] = {
static char s_gateKeeperAddrConsole[64] = {0};
static const char* s_gateKeeperAddrs[] = {
s_gateKeeperAddrConsole
};
@ -86,97 +86,97 @@ static const wchar_t * s_gateKeeperAddrs[] = {
//============================================================================
// Auth
//============================================================================
unsigned GetAuthSrvHostnames (const wchar_t *** addrs) {
unsigned GetAuthSrvHostnames (const char*** addrs) {
*addrs = 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
//============================================================================
unsigned GetFileSrvHostnames (const wchar_t *** addrs) {
unsigned GetFileSrvHostnames (const char*** addrs) {
*addrs = 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
//============================================================================
unsigned GetCsrSrvHostnames (const wchar_t *** addrs) {
unsigned GetCsrSrvHostnames (const char*** addrs) {
*addrs = 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
//============================================================================
unsigned GetGateKeeperSrvHostnames (const wchar_t *** addrs) {
unsigned GetGateKeeperSrvHostnames (const char*** addrs) {
*addrs = s_gateKeeperAddrs;
return arrsize(s_gateKeeperAddrs);
}
//============================================================================
void SetGateKeeperSrvHostname (const wchar_t addr[]) {
wcsncpy(s_gateKeeperAddrConsole, addr, arrsize(s_gateKeeperAddrConsole));
void SetGateKeeperSrvHostname (const char addr[]) {
strncpy(s_gateKeeperAddrConsole, addr, arrsize(s_gateKeeperAddrConsole));
}
//============================================================================
// User-visible Server
//============================================================================
static wchar_t s_serverStatusUrl[256] = {0};
static wchar_t s_serverSignupUrl[256] = {0};
static wchar_t s_serverName[256] = {0};
static char s_serverStatusUrl[256] = {0};
static char s_serverSignupUrl[256] = {0};
static char s_serverName[256] = {0};
//============================================================================
const wchar_t *GetServerStatusUrl () {
const char* GetServerStatusUrl () {
return s_serverStatusUrl;
}
//============================================================================
void SetServerStatusUrl (const wchar_t url[]) {
wcsncpy(s_serverStatusUrl, url, arrsize(s_serverStatusUrl));
void SetServerStatusUrl (const char url[]) {
strncpy(s_serverStatusUrl, url, arrsize(s_serverStatusUrl));
}
//============================================================================
const wchar_t *GetServerSignupUrl () {
const char* GetServerSignupUrl () {
return s_serverSignupUrl;
}
//============================================================================
void SetServerSignupUrl (const wchar_t url[]) {
wcsncpy(s_serverSignupUrl, url, arrsize(s_serverSignupUrl));
void SetServerSignupUrl (const char url[]) {
strncpy(s_serverSignupUrl, url, arrsize(s_serverSignupUrl));
}
//============================================================================
const wchar_t *GetServerDisplayName () {
const char* GetServerDisplayName () {
return s_serverName;
}
//============================================================================
void SetServerDisplayName (const wchar_t name[]) {
wcsncpy(s_serverName, name, arrsize(s_serverName));
void SetServerDisplayName (const char name[]) {
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
void SetAuthSrvHostname (const wchar_t addr[]);
unsigned GetAuthSrvHostnames (const char*** addrs); // returns addrCount
void SetAuthSrvHostname (const char addr[]);
unsigned GetFileSrvHostnames (const wchar_t *** addrs); // returns addrCount
void SetFileSrvHostname (const wchar_t addr[]);
unsigned GetFileSrvHostnames (const char*** addrs); // returns addrCount
void SetFileSrvHostname (const char addr[]);
unsigned GetCsrSrvHostnames (const wchar_t *** addrs); // returns addrCount
void SetCsrSrvHostname (const wchar_t addr[]);
unsigned GetCsrSrvHostnames (const char*** addrs); // returns addrCount
void SetCsrSrvHostname (const char addr[]);
unsigned GetGateKeeperSrvHostnames (const wchar_t *** addrs); // returns addrCount
void SetGateKeeperSrvHostname (const wchar_t addr[]);
unsigned GetGateKeeperSrvHostnames (const char*** addrs); // returns addrCount
void SetGateKeeperSrvHostname (const char addr[]);
const wchar_t *GetServerStatusUrl ();
void SetServerStatusUrl (const wchar_t url[]);
const char *GetServerStatusUrl ();
void SetServerStatusUrl (const char url[]);
const wchar_t *GetServerSignupUrl ();
void SetServerSignupUrl (const wchar_t url[]);
const char *GetServerSignupUrl ();
void SetServerSignupUrl (const char url[]);
const wchar_t *GetServerDisplayName ();
void SetServerDisplayName (const wchar_t name[]);
const char *GetServerDisplayName ();
void SetServerDisplayName (const char name[]);
#endif // pnNbSrvs_inc

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

@ -677,8 +677,8 @@ struct Auth2Cli_AccountExistsReply {
// ServerAddr
extern const NetMsg kNetMsg_Auth2Cli_ServerAddr;
struct Auth2Cli_ServerAddr {
uint32_t messageId;
NetAddressNode srvAddr;
uint32_t messageId;
uint32_t srvAddr;
Uuid token;
};
@ -713,13 +713,13 @@ struct Auth2Cli_AcctLoginReply {
// AgeReply
extern const NetMsg kNetMsg_Auth2Cli_AgeReply;
struct Auth2Cli_AgeReply {
uint32_t messageId;
uint32_t transId;
ENetError result;
uint32_t ageMcpId;
Uuid ageInstId;
uint32_t ageVaultId;
NetAddressNode gameSrvNode;
uint32_t messageId;
uint32_t transId;
ENetError result;
uint32_t ageMcpId;
Uuid ageInstId;
uint32_t ageVaultId;
uint32_t gameSrvNode;
};
// AcctCreateReply

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

@ -191,9 +191,9 @@ struct Srv2Mcp_KickPlayer : SrvMsgHeader {
***/
struct Mcp2Srv_AgeJoinReply : SrvMsgHeader {
uint32_t ageMcpId;
Uuid ageUuid;
NetAddressNode gameSrvNode;
uint32_t ageMcpId;
Uuid ageUuid;
uint32_t gameSrvNode;
};
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 (
void * param,
const wchar_t name[],
const char name[],
unsigned addrCount,
const plNetAddress addrs[]
) {
@ -568,7 +568,7 @@ void SimpleNetDestroyChannel (unsigned channelId) {
//============================================================================
void SimpleNetStartConnecting (
unsigned channelId,
const wchar_t addr[],
const char addr[],
FSimpleNetOnConnect onConnect,
void * param
) {
@ -593,7 +593,7 @@ void SimpleNetStartConnecting (
ASSERT(cp->channel);
// Do we need to lookup the address?
const wchar_t * name = addr;
const char* name = addr;
while (unsigned ch = *name) {
++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
@ -610,8 +610,7 @@ void SimpleNetStartConnecting (
}
}
if (!name[0]) {
plString saddr = _TEMP_CONVERT_FROM_WCHAR_T(addr);
plNetAddress netAddr(saddr.c_str(), kNetDefaultSimpleNetPort);
plNetAddress netAddr(addr, kNetDefaultSimpleNetPort);
Connect(netAddr, cp);
}
}

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

@ -39,7 +39,6 @@ set(pnUtils_SOURCES
if(WIN32)
set(pnUtils_WIN32
Win32/pnUtW32Addr.cpp
Win32/pnUtW32Misc.cpp
Win32/pnUtW32Path.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"
/*****************************************************************************
*
* Types and constants
*
***/
/*struct NetAddress {
uint8_t data[24];
};
typedef unsigned NetAddressNode;*/
#include "pnNetCommon/plNetAddress.h"
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

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

@ -110,11 +110,11 @@ static bool s_loginComplete = false;
static bool s_hasAuthSrvIpAddress = false;
static bool s_hasFileSrvIpAddress = false;
static ENetError s_authResult = kNetErrAuthenticationFailed;
static wchar_t s_authSrvAddr[256];
static wchar_t s_fileSrvAddr[256];
static char s_authSrvAddr[256];
static char s_fileSrvAddr[256];
static wchar_t s_iniServerAddr[256];
static wchar_t s_iniFileServerAddr[256];
static char s_iniServerAddr[256];
static char s_iniFileServerAddr[256];
static wchar_t s_iniAccountUsername[kMaxAccountNameLength];
static ShaDigest s_namePassHash;
static wchar_t s_iniAuthToken[kMaxPublisherAuthKeyLength];
@ -667,7 +667,7 @@ static void AuthSrvIpAddressCallback (
void * param,
const wchar_t addr[]
) {
StrCopy(s_authSrvAddr, addr, arrsize(s_authSrvAddr));
StrToAnsi(s_authSrvAddr, addr, arrsize(s_authSrvAddr));
s_hasAuthSrvIpAddress = true;
}
@ -677,7 +677,7 @@ static void FileSrvIpAddressCallback (
void * param,
const wchar_t addr[]
) {
StrCopy(s_fileSrvAddr, addr, arrsize(s_fileSrvAddr));
StrToAnsi(s_fileSrvAddr, addr, arrsize(s_fileSrvAddr));
s_hasFileSrvIpAddress = true;
}
@ -822,12 +822,12 @@ void NetCommUpdate () {
//============================================================================
void NetCommConnect () {
const wchar_t ** addrs;
const char** addrs;
unsigned count;
hsBool connectedToKeeper = false;
// 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);
}
@ -845,7 +845,7 @@ void NetCommConnect () {
AsyncSleep(10);
}
const wchar_t * authSrv[] = {
const char* authSrv[] = {
s_authSrvAddr
};
NetCliAuthStartConnect(authSrv, 1);
@ -854,7 +854,7 @@ void NetCommConnect () {
if (!gDataServerLocal) {
// 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);
}
@ -874,7 +874,7 @@ void NetCommConnect () {
AsyncSleep(10);
}
const wchar_t * fileSrv[] = {
const char* fileSrv[] = {
s_fileSrvAddr
};
NetCliFileStartConnect(fileSrv, 1);

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

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

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

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

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

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

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

@ -796,7 +796,7 @@ void GamePingEnable (bool enable) {
//============================================================================
void NetCliGameStartConnect (
const NetAddressNode & node
const uint32_t node
) {
plNetAddress addr(node, kNetDefaultClientPort);
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
//============================================================================
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;
AsyncSocket sock;
NetCli * cli;
wchar_t name[MAX_PATH];
char name[MAX_PATH];
NetAddress addr;
Uuid token;
unsigned seq;
@ -463,7 +463,7 @@ static void Connect (
//============================================================================
static void Connect (
const wchar_t name[],
const char name[],
const NetAddress & addr
) {
ASSERT(s_running);
@ -472,7 +472,7 @@ static void Connect (
conn->addr = addr;
conn->seq = ConnNextSequence();
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->AutoReconnect();
@ -481,7 +481,7 @@ static void Connect (
//============================================================================
static void AsyncLookupCallback (
void * param,
const wchar_t name[],
const char name[],
unsigned addrCount,
const NetAddress addrs[]
) {
@ -1053,14 +1053,14 @@ unsigned GateKeeperGetConnId () {
//============================================================================
void NetCliGateKeeperStartConnect (
const wchar_t * gateKeeperAddrList[],
unsigned gateKeeperAddrCount
const char* gateKeeperAddrList[],
uint32_t gateKeeperAddrCount
) {
gateKeeperAddrCount = min(gateKeeperAddrCount, 1);
for (unsigned i = 0; i < gateKeeperAddrCount; ++i) {
// Do we need to lookup the address?
const wchar_t * name = gateKeeperAddrList[i];
const char* name = gateKeeperAddrList[i];
while (unsigned ch = *name) {
++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
@ -1076,8 +1076,7 @@ void NetCliGateKeeperStartConnect (
}
}
if (!name[0]) {
NetAddress addr;
NetAddressFromString(&addr, gateKeeperAddrList[i], kNetDefaultClientPort);
NetAddress addr(gateKeeperAddrList[i], kNetDefaultClientPort);
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
//============================================================================
void NetCliGateKeeperStartConnect (
const wchar_t * gateKeeperAddrList[],
unsigned gateKeeperAddrCount
const char* gateKeeperAddrList[],
uint32_t gateKeeperAddrCount
);
bool NetCliGateKeeperQueryConnected ();

Loading…
Cancel
Save