Browse Source

Convert server name stuff to plString

Adam Johnson 10 years ago
parent
commit
2039d88025
  1. 10
      Sources/Plasma/Apps/plClient/winmain.cpp
  2. 17
      Sources/Plasma/Apps/plUruLauncher/plClientLauncher.cpp
  3. 13
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp
  4. 78
      Sources/Plasma/NucleusLib/pnNetBase/pnNbSrvs.cpp
  5. 26
      Sources/Plasma/NucleusLib/pnNetBase/pnNbSrvs.h
  6. 4
      Sources/Plasma/NucleusLib/pnNetCommon/plNetAddress.cpp
  7. 4
      Sources/Plasma/NucleusLib/pnNetCommon/plNetAddress.h
  8. 8
      Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.cpp
  9. 2
      Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.h
  10. 26
      Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp
  11. 14
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  12. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h
  13. 23
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp
  14. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.h
  15. 24
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp
  16. 16
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.h

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

@ -871,7 +871,7 @@ void StatusCallback(void *param)
HWND hwnd = (HWND)param;
const char *statusUrl = GetServerStatusUrl();
plString statusUrl = GetServerStatusUrl();
CURL *hCurl = curl_easy_init();
// For reporting errors
@ -880,12 +880,12 @@ void StatusCallback(void *param)
while(s_loginDlgRunning)
{
curl_easy_setopt(hCurl, CURLOPT_URL, statusUrl);
curl_easy_setopt(hCurl, CURLOPT_URL, statusUrl.c_str());
curl_easy_setopt(hCurl, CURLOPT_USERAGENT, "UruClient/1.0");
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, &CurlCallback);
curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, param);
if (statusUrl[0] && curl_easy_perform(hCurl) != 0) // only perform request if there's actually a URL set
if (!statusUrl.IsEmpty() && curl_easy_perform(hCurl) != 0) // only perform request if there's actually a URL set
PostMessage(hwnd, WM_USER_SETSTATUSMSG, 0, (LPARAM) curlError);
for(unsigned i = 0; i < UPDATE_STATUSMSG_SECONDS && s_loginDlgRunning; ++i)
@ -1033,8 +1033,8 @@ BOOL CALLBACK UruLoginDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
}
else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_URULOGIN_NEWACCTLINK)
{
const char* signupurl = GetServerSignupUrl();
ShellExecuteA(NULL, "open", signupurl, NULL, NULL, SW_SHOWNORMAL);
plString signupurl = GetServerSignupUrl();
ShellExecuteW(NULL, L"open", signupurl.ToWchar(), NULL, NULL, SW_SHOWNORMAL);
return TRUE;
}

17
Sources/Plasma/Apps/plUruLauncher/plClientLauncher.cpp

@ -103,13 +103,13 @@ static size_t ICurlCallback(void* buffer, size_t size, size_t nmemb, void* threa
hsError plShardStatus::Run()
{
{
const char* url = GetServerStatusUrl();
plString url = GetServerStatusUrl();
// initialize CURL
std::unique_ptr<CURL, std::function<void(CURL*)>> curl(curl_easy_init(), curl_easy_cleanup);
curl_easy_setopt(curl.get(), CURLOPT_ERRORBUFFER, fCurlError);
curl_easy_setopt(curl.get(), CURLOPT_USERAGENT, "UruClient/1.0");
curl_easy_setopt(curl.get(), CURLOPT_URL, url);
curl_easy_setopt(curl.get(), CURLOPT_URL, url.c_str());
curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, this);
curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, ICurlCallback);
@ -123,7 +123,7 @@ hsError plShardStatus::Run()
if (!fRunning)
break;
if (url[0] && curl_easy_perform(curl.get()))
if (!url.IsEmpty() && curl_easy_perform(curl.get()))
fShardFunc(fCurlError);
fLastUpdate = hsTimer::GetSysSeconds();
} while (fRunning);
@ -334,16 +334,15 @@ bool plClientLauncher::CompleteSelfPatch(std::function<void(void)> waitProc) con
// ===================================================
static void IGotFileServIPs(ENetError result, void* param, const wchar_t* addr)
static void IGotFileServIPs(ENetError result, void* param, const plString& addr)
{
plClientLauncher* launcher = static_cast<plClientLauncher*>(param);
NetCliGateKeeperDisconnect();
if (IS_NET_SUCCESS(result)) {
// bah... why do I even bother
plString eapSucks = plString::FromWchar(addr);
const char* eapReallySucks[] = { eapSucks.c_str() };
NetCliFileStartConnect(eapReallySucks, 1, true);
plString eapSucks[] = { addr };
NetCliFileStartConnect(eapSucks, 1, true);
// Who knows if we will actually connect. So let's start updating.
launcher->PatchClient();
@ -373,8 +372,8 @@ void plClientLauncher::InitializeNetCore()
NetClientSetTransTimeoutMs(kNetTransTimeout);
// Gotta grab the filesrvs from the gate
const char** addrs;
uint32_t num = GetGateKeeperSrvHostnames(&addrs);
const plString* addrs;
uint32_t num = GetGateKeeperSrvHostnames(addrs);
NetCliGateKeeperStartConnect(addrs, num);
NetCliGateKeeperFileSrvIpAddressRequest(IGotFileServIPs, this, true);

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

@ -48,6 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pfConsoleCmd.h"
#include "pnNetBase/pnNetBase.h"
#include "pfUtilBase64.h"
#include "plString.h"
#include <algorithm>
@ -89,7 +90,7 @@ PF_CONSOLE_CMD(
"string url",
"Set the server's status URL"
) {
SetServerStatusUrl(params[0]);
SetServerStatusUrl((char*)params[0]);
}
//============================================================================
@ -99,7 +100,7 @@ PF_CONSOLE_CMD(
"string url",
"Set the server's new user sign-up URL"
) {
SetServerSignupUrl(params[0]);
SetServerSignupUrl((char*)params[0]);
}
//============================================================================
@ -109,7 +110,7 @@ PF_CONSOLE_CMD(
"string name",
"Set the displayable server name"
) {
SetServerDisplayName(params[0]);
SetServerDisplayName((char*)params[0]);
}
//============================================================================
@ -134,7 +135,7 @@ PF_CONSOLE_CMD(
"string address",
"Set the File Server address"
) {
SetFileSrvHostname(params[0]);
SetFileSrvHostname((char*)params[0]);
}
@ -149,7 +150,7 @@ PF_CONSOLE_CMD(
"string address",
"Set the Auth Server address"
) {
SetAuthSrvHostname(params[0]);
SetAuthSrvHostname((char*)params[0]);
}
//============================================================================
@ -261,7 +262,7 @@ PF_CONSOLE_CMD(
"string address",
"Set the GateKeeper Server address"
) {
SetGateKeeperSrvHostname(params[0]);
SetGateKeeperSrvHostname((char*)params[0]);
}
//============================================================================

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

@ -41,11 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "pnNbSrvs.h"
#if !HS_BUILD_FOR_WIN32
# include <wchar.h>
#endif
#include "plString.h"
/*****************************************************************************
*
@ -53,22 +49,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/
static char s_authAddrConsole[64] = {0};
static const char* s_authAddrs[] = {
s_authAddrConsole
};
static char s_fileAddrConsole[64] = {0};
static const char* s_fileAddrs[] = {
s_fileAddrConsole
};
static char s_gateKeeperAddrConsole[64] = {0};
static const char* s_gateKeeperAddrs[] = {
s_gateKeeperAddrConsole
};
static plString s_authAddrs[] = { "" };
static plString s_fileAddrs[] = { "" };
static plString s_gateKeeperAddrs[] = { "" };
static unsigned s_clientPort = 14617;
@ -82,45 +65,40 @@ static unsigned s_clientPort = 14617;
//============================================================================
// Auth
//============================================================================
unsigned GetAuthSrvHostnames (const char*** addrs) {
*addrs = s_authAddrs;
unsigned GetAuthSrvHostnames (const plString*& addrs) {
addrs = s_authAddrs;
return arrsize(s_authAddrs);
}
//============================================================================
void SetAuthSrvHostname (const char addr[]) {
strncpy(s_authAddrConsole, addr, arrsize(s_authAddrConsole));
void SetAuthSrvHostname (const plString& addr) {
s_authAddrs[0] = addr;
}
//============================================================================
// File
//============================================================================
unsigned GetFileSrvHostnames (const char*** addrs) {
*addrs = s_fileAddrs;
unsigned GetFileSrvHostnames (const plString*& addrs) {
addrs = s_fileAddrs;
return arrsize(s_fileAddrs);
}
//============================================================================
void SetFileSrvHostname (const char addr[]) {
strncpy(s_fileAddrConsole, addr, arrsize(s_fileAddrConsole));
void SetFileSrvHostname (const plString& addr) {
s_fileAddrs[0] = addr;
}
//============================================================================
// GateKeeper
//============================================================================
unsigned GetGateKeeperSrvHostnames (const char*** addrs) {
*addrs = s_gateKeeperAddrs;
unsigned GetGateKeeperSrvHostnames (const plString*& addrs) {
addrs = s_gateKeeperAddrs;
return arrsize(s_gateKeeperAddrs);
}
//============================================================================
void SetGateKeeperSrvHostname (const char addr[]) {
strncpy(s_gateKeeperAddrConsole, addr, arrsize(s_gateKeeperAddrConsole));
void SetGateKeeperSrvHostname (const plString& addr) {
s_gateKeeperAddrs[0] = addr;
}
//============================================================================
@ -139,36 +117,36 @@ void SetClientPort(unsigned port) {
//============================================================================
// User-visible Server
//============================================================================
static char s_serverStatusUrl[256] = {0};
static char s_serverSignupUrl[256] = {0};
static char s_serverName[256] = {0};
static plString s_serverStatusUrl;
static plString s_serverSignupUrl;
static plString s_serverName;
//============================================================================
const char* GetServerStatusUrl () {
plString GetServerStatusUrl () {
return s_serverStatusUrl;
}
//============================================================================
void SetServerStatusUrl (const char url[]) {
strncpy(s_serverStatusUrl, url, arrsize(s_serverStatusUrl));
void SetServerStatusUrl (const plString& url) {
s_serverStatusUrl = url;
}
//============================================================================
const char* GetServerSignupUrl () {
plString GetServerSignupUrl () {
return s_serverSignupUrl;
}
//============================================================================
void SetServerSignupUrl (const char url[]) {
strncpy(s_serverSignupUrl, url, arrsize(s_serverSignupUrl));
void SetServerSignupUrl (const plString& url) {
s_serverSignupUrl = url;
}
//============================================================================
const char* GetServerDisplayName () {
plString GetServerDisplayName () {
return s_serverName;
}
//============================================================================
void SetServerDisplayName (const char name[]) {
strncpy(s_serverName, name, arrsize(s_serverName));
void SetServerDisplayName (const plString& name) {
s_serverName = name;
}

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

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

4
Sources/Plasma/NucleusLib/pnNetCommon/plNetAddress.cpp

@ -57,7 +57,7 @@ plNetAddress::plNetAddress(uint32_t addr, uint16_t port)
SetPort(port);
}
plNetAddress::plNetAddress(const char* addr, uint16_t port)
plNetAddress::plNetAddress(const plString& addr, uint16_t port)
{
Clear();
SetHost(addr);
@ -114,7 +114,7 @@ plString plNetAddress::GetHostWithPort() const
return ss.GetString();
}
bool plNetAddress::SetHost(const char* hostname)
bool plNetAddress::SetHost(const plString& hostname)
{
fAddr.sin_addr.s_addr = pnNetCommon::GetBinAddr(hostname);
fAddr.sin_family = AF_INET;

4
Sources/Plasma/NucleusLib/pnNetCommon/plNetAddress.h

@ -104,7 +104,7 @@ public:
* @param addr The DNS hostname of the host.
* @param port The port number as a 16-bit host order integer.
*/
plNetAddress(const char* addr, uint16_t port);
plNetAddress(const plString& addr, uint16_t port);
virtual ~plNetAddress(){}
@ -158,7 +158,7 @@ public:
*
* @param hostname The DNS name of the host.
*/
bool SetHost(const char* hostname);
bool SetHost(const plString& hostname);
/**
* Sets the IPv4 address of the host from an unsigned 32-bit integer in

8
Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.cpp

@ -67,13 +67,13 @@ plString GetTextAddr(uint32_t binAddr)
}
// NOTE: On Win32, WSAStartup() must be called before GetBinAddr() will work.
uint32_t GetBinAddr(const char * textAddr)
uint32_t GetBinAddr(const plString& textAddr)
{
uint32_t addr = 0;
if (!textAddr)
if (textAddr.IsEmpty())
return addr;
addr = inet_addr(textAddr);
addr = inet_addr(textAddr.c_str());
if(addr == INADDR_NONE)
{
struct addrinfo* ai = nil;
@ -81,7 +81,7 @@ uint32_t GetBinAddr(const char * textAddr)
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = PF_INET;
hints.ai_flags = AI_CANONNAME;
if (getaddrinfo(textAddr, nil, &hints, &ai) != 0)
if (getaddrinfo(textAddr.c_str(), nil, &hints, &ai) != 0)
{
hsAssert(false, "getaddrinfo failed");
return addr;

2
Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.h

@ -81,7 +81,7 @@ namespace pnNetCommon
{
#ifndef SERVER
uint32_t GetBinAddr(const char* textAddr);
uint32_t GetBinAddr(const plString& textAddr);
plString GetTextAddr(uint32_t binAddr);
#endif // SERVER

26
Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp

@ -111,8 +111,8 @@ static bool s_loginComplete = false;
static bool s_hasAuthSrvIpAddress = false;
static bool s_hasFileSrvIpAddress = false;
static ENetError s_authResult = kNetErrAuthenticationFailed;
static char s_authSrvAddr[256];
static char s_fileSrvAddr[256];
static plString s_authSrvAddr;
static plString s_fileSrvAddr;
static char s_iniServerAddr[256];
static char s_iniFileServerAddr[256];
@ -667,9 +667,9 @@ static void INetCliAuthSendFriendInviteCallback (
static void AuthSrvIpAddressCallback (
ENetError result,
void * param,
const wchar_t addr[]
const plString& addr
) {
StrToAnsi(s_authSrvAddr, addr, arrsize(s_authSrvAddr));
s_authSrvAddr = addr;
s_hasAuthSrvIpAddress = true;
}
@ -677,9 +677,9 @@ static void AuthSrvIpAddressCallback (
static void FileSrvIpAddressCallback (
ENetError result,
void * param,
const wchar_t addr[]
const plString& addr
) {
StrToAnsi(s_fileSrvAddr, addr, arrsize(s_fileSrvAddr));
s_fileSrvAddr = addr;
s_hasFileSrvIpAddress = true;
}
@ -822,18 +822,18 @@ void NetCommUpdate () {
//============================================================================
void NetCommConnect () {
const char** addrs;
const plString* addrs;
unsigned count;
bool 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)) && strlen(addrs[0]))
if((count = GetAuthSrvHostnames(addrs)) && !addrs[0].IsEmpty())
{
NetCliAuthStartConnect(addrs, count);
}
else
{
count = GetGateKeeperSrvHostnames(&addrs);
count = GetGateKeeperSrvHostnames(addrs);
NetCliGateKeeperStartConnect(addrs, count);
connectedToKeeper = true;
@ -845,7 +845,7 @@ void NetCommConnect () {
AsyncSleep(10);
}
const char* authSrv[] = {
const plString authSrv[] = {
s_authSrvAddr
};
NetCliAuthStartConnect(authSrv, 1);
@ -854,14 +854,14 @@ 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)) && strlen(addrs[0]))
if((count = GetFileSrvHostnames(addrs)) && !addrs[0].IsEmpty())
{
NetCliFileStartConnect(addrs, count);
}
else
{
if (!connectedToKeeper) {
count = GetGateKeeperSrvHostnames(&addrs);
count = GetGateKeeperSrvHostnames(addrs);
NetCliGateKeeperStartConnect(addrs, count);
connectedToKeeper = true;
}
@ -874,7 +874,7 @@ void NetCommConnect () {
AsyncSleep(10);
}
const char* fileSrv[] = {
const plString fileSrv[] = {
s_fileSrvAddr
};
NetCliFileStartConnect(fileSrv, 1);

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

@ -91,7 +91,7 @@ struct CliAuConn : hsRefCnt {
LINK(CliAuConn) link;
AsyncSocket sock;
NetCli * cli;
char name[MAX_PATH];
plString name;
plNetAddress addr;
plUUID token;
unsigned seq;
@ -1529,7 +1529,7 @@ static void Connect (
//============================================================================
static void Connect (
const char name[],
const plString& name,
const plNetAddress& addr
) {
ASSERT(s_running);
@ -1538,7 +1538,7 @@ static void Connect (
conn->addr = addr;
conn->seq = ConnNextSequence();
conn->lastHeardTimeMs = GetNonZeroTimeMs(); // used in connect timeout, and ping timeout
strncpy(conn->name, name, arrsize(conn->name));
conn->name = name;
conn->Ref("Lifetime");
conn->AutoReconnect();
@ -1594,8 +1594,6 @@ CliAuConn::CliAuConn ()
, sock(nil), cli(nil), seq(0), serverChallenge(0)
, cancelId(nil), abandoned(false)
{
memset(name, 0, sizeof(name));
++s_perf[kPerfConnCount];
}
@ -5124,7 +5122,7 @@ void AuthPingEnable (bool enable) {
//============================================================================
void NetCliAuthStartConnect (
const char* authAddrList[],
const plString authAddrList[],
uint32_t authAddrCount
) {
// TEMP: Only connect to one auth server until we fill out this module
@ -5133,7 +5131,7 @@ void NetCliAuthStartConnect (
for (unsigned i = 0; i < authAddrCount; ++i) {
// Do we need to lookup the address?
const char* name = authAddrList[i];
const char* name = authAddrList[i].c_str();
while (unsigned ch = *name) {
++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
@ -5141,7 +5139,7 @@ void NetCliAuthStartConnect (
AsyncAddressLookupName(
&cancelId,
AsyncLookupCallback,
authAddrList[i],
authAddrList[i].c_str(),
GetClientPort(),
nil
);

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

@ -62,7 +62,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Connect
//============================================================================
void NetCliAuthStartConnect (
const char* authAddrList[],
const plString authAddrList[],
uint32_t authAddrCount
);
bool NetCliAuthQueryConnected ();

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

@ -64,7 +64,7 @@ struct CliFileConn : hsRefCnt {
LINK(CliFileConn) link;
hsReaderWriterLock sockLock; // to protect the socket pointer so we don't nuke it while using it
AsyncSocket sock;
char name[MAX_PATH];
plString name;
plNetAddress addr;
unsigned seq;
ARRAY(uint8_t) recvBuffer;
@ -536,18 +536,18 @@ static void Connect (CliFileConn * conn) {
//============================================================================
static void Connect (
const char name[],
const plString& name,
const plNetAddress& addr
) {
ASSERT(s_running);
CliFileConn * conn = new CliFileConn;
strncpy(conn->name, name, arrsize(conn->name));
conn->addr = addr;
conn->buildId = s_connectBuildId;
conn->serverType = s_serverType;
conn->seq = ConnNextSequence();
conn->lastHeardTimeMs = GetNonZeroTimeMs(); // used in connect timeout, and ping timeout
conn->name = name;
conn->addr = addr;
conn->buildId = s_connectBuildId;
conn->serverType = s_serverType;
conn->seq = ConnNextSequence();
conn->lastHeardTimeMs = GetNonZeroTimeMs(); // used in connect timeout, and ping timeout
conn->Ref("Lifetime");
conn->AutoReconnect();
@ -584,7 +584,6 @@ CliFileConn::CliFileConn ()
, numImmediateDisconnects(0), numFailedConnects(0)
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
{
memset(name, 0, sizeof(name));
++s_perf[kPerfConnCount];
}
@ -1344,7 +1343,7 @@ unsigned FileGetConnId () {
//============================================================================
void NetCliFileStartConnect (
const char* fileAddrList[],
const plString fileAddrList[],
uint32_t fileAddrCount,
bool isPatcher /* = false */
) {
@ -1356,7 +1355,7 @@ void NetCliFileStartConnect (
for (unsigned i = 0; i < fileAddrCount; ++i) {
// Do we need to lookup the address?
const char* name = fileAddrList[i];
const char* name = fileAddrList[i].c_str();
while (unsigned ch = *name) {
++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
@ -1364,7 +1363,7 @@ void NetCliFileStartConnect (
AsyncAddressLookupName(
&cancelId,
AsyncLookupCallback,
fileAddrList[i],
fileAddrList[i].c_str(),
GetClientPort(),
nil
);

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

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

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

@ -89,7 +89,7 @@ struct CliGkConn : hsRefCnt {
LINK(CliGkConn) link;
AsyncSocket sock;
NetCli * cli;
char name[MAX_PATH];
plString name;
plNetAddress addr;
plUUID token;
unsigned seq;
@ -131,7 +131,7 @@ struct PingRequestTrans : NetGateKeeperTrans {
struct FileSrvIpAddressRequestTrans : NetGateKeeperTrans {
FNetCliGateKeeperFileSrvIpAddressRequestCallback m_callback;
void * m_param;
wchar_t m_addr[64];
plString m_addr;
bool m_isPatcher;
FileSrvIpAddressRequestTrans (
@ -154,7 +154,7 @@ struct FileSrvIpAddressRequestTrans : NetGateKeeperTrans {
struct AuthSrvIpAddressRequestTrans : NetGateKeeperTrans {
FNetCliGateKeeperAuthSrvIpAddressRequestCallback m_callback;
void * m_param;
wchar_t m_addr[64];
plString m_addr;
AuthSrvIpAddressRequestTrans (
FNetCliGateKeeperAuthSrvIpAddressRequestCallback callback,
@ -463,7 +463,7 @@ static void Connect (
//============================================================================
static void Connect (
const char name[],
const plString& name,
const plNetAddress& 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
strncpy(conn->name, name, arrsize(conn->name));
conn->name = name;
conn->Ref("Lifetime");
conn->AutoReconnect();
@ -530,8 +530,6 @@ CliGkConn::CliGkConn ()
, sock(nil), cli(nil), seq(0), serverChallenge(0)
, cancelId(nil), abandoned(false)
{
memset(name, 0, sizeof(name));
++s_perf[kPerfConnCount];
}
@ -876,7 +874,7 @@ bool FileSrvIpAddressRequestTrans::Recv (
m_result = kNetSuccess;
m_state = kTransStateComplete;
StrCopy(m_addr, reply.address, 64);
m_addr = plString::FromWchar(reply.address);
return true;
}
@ -933,7 +931,7 @@ bool AuthSrvIpAddressRequestTrans::Recv (
m_result = kNetSuccess;
m_state = kTransStateComplete;
StrCopy(m_addr, reply.address, 64);
m_addr = plString::FromWchar(reply.address);
return true;
}
@ -1059,14 +1057,14 @@ unsigned GateKeeperGetConnId () {
//============================================================================
void NetCliGateKeeperStartConnect (
const char* gateKeeperAddrList[],
uint32_t gateKeeperAddrCount
const plString gateKeeperAddrList[],
uint32_t gateKeeperAddrCount
) {
gateKeeperAddrCount = std::min(gateKeeperAddrCount, 1u);
for (unsigned i = 0; i < gateKeeperAddrCount; ++i) {
// Do we need to lookup the address?
const char* name = gateKeeperAddrList[i];
const char* name = gateKeeperAddrList[i].c_str();
while (unsigned ch = *name) {
++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
@ -1074,7 +1072,7 @@ void NetCliGateKeeperStartConnect (
AsyncAddressLookupName(
&cancelId,
AsyncLookupCallback,
gateKeeperAddrList[i],
gateKeeperAddrList[i].c_str(),
GetClientPort(),
nil
);

16
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 char* gateKeeperAddrList[],
uint32_t gateKeeperAddrCount
const plString gateKeeperAddrList[],
uint32_t gateKeeperAddrCount
);
bool NetCliGateKeeperQueryConnected ();
@ -107,9 +107,9 @@ void NetCliGateKeeperPingRequest (
// FileSrvIpAddress
//============================================================================
typedef void (*FNetCliGateKeeperFileSrvIpAddressRequestCallback)(
ENetError result,
void * param,
const wchar_t addr[]
ENetError result,
void * param,
const plString& addr
);
void NetCliGateKeeperFileSrvIpAddressRequest (
@ -123,9 +123,9 @@ void NetCliGateKeeperFileSrvIpAddressRequest (
// AuthSrvIpAddress
//============================================================================
typedef void (*FNetCliGateKeeperAuthSrvIpAddressRequestCallback)(
ENetError result,
void * param,
const wchar_t addr[]
ENetError result,
void * param,
const plString& addr
);
void NetCliGateKeeperAuthSrvIpAddressRequest (

Loading…
Cancel
Save