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; HWND hwnd = (HWND)param;
const char *statusUrl = GetServerStatusUrl(); plString statusUrl = GetServerStatusUrl();
CURL *hCurl = curl_easy_init(); CURL *hCurl = curl_easy_init();
// For reporting errors // For reporting errors
@ -880,12 +880,12 @@ void StatusCallback(void *param)
while(s_loginDlgRunning) 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_USERAGENT, "UruClient/1.0");
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, &CurlCallback); curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, &CurlCallback);
curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, param); 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); PostMessage(hwnd, WM_USER_SETSTATUSMSG, 0, (LPARAM) curlError);
for(unsigned i = 0; i < UPDATE_STATUSMSG_SECONDS && s_loginDlgRunning; ++i) 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) else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_URULOGIN_NEWACCTLINK)
{ {
const char* signupurl = GetServerSignupUrl(); plString signupurl = GetServerSignupUrl();
ShellExecuteA(NULL, "open", signupurl, NULL, NULL, SW_SHOWNORMAL); ShellExecuteW(NULL, L"open", signupurl.ToWchar(), NULL, NULL, SW_SHOWNORMAL);
return TRUE; 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() hsError plShardStatus::Run()
{ {
{ {
const char* url = GetServerStatusUrl(); plString url = GetServerStatusUrl();
// initialize CURL // initialize CURL
std::unique_ptr<CURL, std::function<void(CURL*)>> curl(curl_easy_init(), curl_easy_cleanup); 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_ERRORBUFFER, fCurlError);
curl_easy_setopt(curl.get(), CURLOPT_USERAGENT, "UruClient/1.0"); 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_WRITEDATA, this);
curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, ICurlCallback); curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, ICurlCallback);
@ -123,7 +123,7 @@ hsError plShardStatus::Run()
if (!fRunning) if (!fRunning)
break; break;
if (url[0] && curl_easy_perform(curl.get())) if (!url.IsEmpty() && curl_easy_perform(curl.get()))
fShardFunc(fCurlError); fShardFunc(fCurlError);
fLastUpdate = hsTimer::GetSysSeconds(); fLastUpdate = hsTimer::GetSysSeconds();
} while (fRunning); } 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); plClientLauncher* launcher = static_cast<plClientLauncher*>(param);
NetCliGateKeeperDisconnect(); NetCliGateKeeperDisconnect();
if (IS_NET_SUCCESS(result)) { if (IS_NET_SUCCESS(result)) {
// bah... why do I even bother // bah... why do I even bother
plString eapSucks = plString::FromWchar(addr); plString eapSucks[] = { addr };
const char* eapReallySucks[] = { eapSucks.c_str() }; NetCliFileStartConnect(eapSucks, 1, true);
NetCliFileStartConnect(eapReallySucks, 1, true);
// Who knows if we will actually connect. So let's start updating. // Who knows if we will actually connect. So let's start updating.
launcher->PatchClient(); launcher->PatchClient();
@ -373,8 +372,8 @@ void plClientLauncher::InitializeNetCore()
NetClientSetTransTimeoutMs(kNetTransTimeout); NetClientSetTransTimeoutMs(kNetTransTimeout);
// Gotta grab the filesrvs from the gate // Gotta grab the filesrvs from the gate
const char** addrs; const plString* addrs;
uint32_t num = GetGateKeeperSrvHostnames(&addrs); uint32_t num = GetGateKeeperSrvHostnames(addrs);
NetCliGateKeeperStartConnect(addrs, num); NetCliGateKeeperStartConnect(addrs, num);
NetCliGateKeeperFileSrvIpAddressRequest(IGotFileServIPs, this, true); 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 "pfConsoleCmd.h"
#include "pnNetBase/pnNetBase.h" #include "pnNetBase/pnNetBase.h"
#include "pfUtilBase64.h" #include "pfUtilBase64.h"
#include "plString.h"
#include <algorithm> #include <algorithm>
@ -89,7 +90,7 @@ PF_CONSOLE_CMD(
"string url", "string url",
"Set the server's status URL" "Set the server's status URL"
) { ) {
SetServerStatusUrl(params[0]); SetServerStatusUrl((char*)params[0]);
} }
//============================================================================ //============================================================================
@ -99,7 +100,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"
) { ) {
SetServerSignupUrl(params[0]); SetServerSignupUrl((char*)params[0]);
} }
//============================================================================ //============================================================================
@ -109,7 +110,7 @@ PF_CONSOLE_CMD(
"string name", "string name",
"Set the displayable server name" "Set the displayable server name"
) { ) {
SetServerDisplayName(params[0]); SetServerDisplayName((char*)params[0]);
} }
//============================================================================ //============================================================================
@ -134,7 +135,7 @@ PF_CONSOLE_CMD(
"string address", "string address",
"Set the File Server address" "Set the File Server address"
) { ) {
SetFileSrvHostname(params[0]); SetFileSrvHostname((char*)params[0]);
} }
@ -149,7 +150,7 @@ PF_CONSOLE_CMD(
"string address", "string address",
"Set the Auth Server address" "Set the Auth Server address"
) { ) {
SetAuthSrvHostname(params[0]); SetAuthSrvHostname((char*)params[0]);
} }
//============================================================================ //============================================================================
@ -261,7 +262,7 @@ PF_CONSOLE_CMD(
"string address", "string address",
"Set the GateKeeper Server 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==*/ *==LICENSE==*/
#include "pnNbSrvs.h" #include "pnNbSrvs.h"
#include "plString.h"
#if !HS_BUILD_FOR_WIN32
# include <wchar.h>
#endif
/***************************************************************************** /*****************************************************************************
* *
@ -53,22 +49,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
* *
***/ ***/
static char s_authAddrConsole[64] = {0}; static plString s_authAddrs[] = { "" };
static const char* s_authAddrs[] = { static plString s_fileAddrs[] = { "" };
s_authAddrConsole static plString s_gateKeeperAddrs[] = { "" };
};
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 unsigned s_clientPort = 14617; static unsigned s_clientPort = 14617;
@ -82,45 +65,40 @@ static unsigned s_clientPort = 14617;
//============================================================================ //============================================================================
// Auth // Auth
//============================================================================ //============================================================================
unsigned GetAuthSrvHostnames (const char*** addrs) { unsigned GetAuthSrvHostnames (const plString*& addrs) {
addrs = s_authAddrs;
*addrs = s_authAddrs;
return arrsize(s_authAddrs); return arrsize(s_authAddrs);
} }
//============================================================================ //============================================================================
void SetAuthSrvHostname (const char addr[]) { void SetAuthSrvHostname (const plString& addr) {
s_authAddrs[0] = addr;
strncpy(s_authAddrConsole, addr, arrsize(s_authAddrConsole));
} }
//============================================================================ //============================================================================
// File // File
//============================================================================ //============================================================================
unsigned GetFileSrvHostnames (const char*** addrs) { unsigned GetFileSrvHostnames (const plString*& addrs) {
addrs = s_fileAddrs;
*addrs = s_fileAddrs;
return arrsize(s_fileAddrs); return arrsize(s_fileAddrs);
} }
//============================================================================ //============================================================================
void SetFileSrvHostname (const char addr[]) { void SetFileSrvHostname (const plString& addr) {
s_fileAddrs[0] = addr;
strncpy(s_fileAddrConsole, addr, arrsize(s_fileAddrConsole));
} }
//============================================================================ //============================================================================
// GateKeeper // GateKeeper
//============================================================================ //============================================================================
unsigned GetGateKeeperSrvHostnames (const char*** addrs) { unsigned GetGateKeeperSrvHostnames (const plString*& addrs) {
addrs = s_gateKeeperAddrs;
*addrs = s_gateKeeperAddrs;
return arrsize(s_gateKeeperAddrs); return arrsize(s_gateKeeperAddrs);
} }
//============================================================================ //============================================================================
void SetGateKeeperSrvHostname (const char addr[]) { void SetGateKeeperSrvHostname (const plString& addr) {
strncpy(s_gateKeeperAddrConsole, addr, arrsize(s_gateKeeperAddrConsole)); s_gateKeeperAddrs[0] = addr;
} }
//============================================================================ //============================================================================
@ -139,36 +117,36 @@ void SetClientPort(unsigned port) {
//============================================================================ //============================================================================
// User-visible Server // User-visible Server
//============================================================================ //============================================================================
static char s_serverStatusUrl[256] = {0}; static plString s_serverStatusUrl;
static char s_serverSignupUrl[256] = {0}; static plString s_serverSignupUrl;
static char s_serverName[256] = {0}; static plString s_serverName;
//============================================================================ //============================================================================
const char* GetServerStatusUrl () { plString GetServerStatusUrl () {
return s_serverStatusUrl; return s_serverStatusUrl;
} }
//============================================================================ //============================================================================
void SetServerStatusUrl (const char url[]) { void SetServerStatusUrl (const plString& url) {
strncpy(s_serverStatusUrl, url, arrsize(s_serverStatusUrl)); s_serverStatusUrl = url;
} }
//============================================================================ //============================================================================
const char* GetServerSignupUrl () { plString GetServerSignupUrl () {
return s_serverSignupUrl; return s_serverSignupUrl;
} }
//============================================================================ //============================================================================
void SetServerSignupUrl (const char url[]) { void SetServerSignupUrl (const plString& url) {
strncpy(s_serverSignupUrl, url, arrsize(s_serverSignupUrl)); s_serverSignupUrl = url;
} }
//============================================================================ //============================================================================
const char* GetServerDisplayName () { plString GetServerDisplayName () {
return s_serverName; return s_serverName;
} }
//============================================================================ //============================================================================
void SetServerDisplayName (const char name[]) { void SetServerDisplayName (const plString& name) {
strncpy(s_serverName, name, arrsize(s_serverName)); s_serverName = name;
} }

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

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

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

@ -57,7 +57,7 @@ plNetAddress::plNetAddress(uint32_t addr, uint16_t port)
SetPort(port); SetPort(port);
} }
plNetAddress::plNetAddress(const char* addr, uint16_t port) plNetAddress::plNetAddress(const plString& addr, uint16_t port)
{ {
Clear(); Clear();
SetHost(addr); SetHost(addr);
@ -114,7 +114,7 @@ plString plNetAddress::GetHostWithPort() const
return ss.GetString(); 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_addr.s_addr = pnNetCommon::GetBinAddr(hostname);
fAddr.sin_family = AF_INET; 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 addr The DNS hostname of the host.
* @param port The port number as a 16-bit host order integer. * @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(){} virtual ~plNetAddress(){}
@ -158,7 +158,7 @@ public:
* *
* @param hostname The DNS name of the host. * @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 * 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. // 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; uint32_t addr = 0;
if (!textAddr) if (textAddr.IsEmpty())
return addr; return addr;
addr = inet_addr(textAddr); addr = inet_addr(textAddr.c_str());
if(addr == INADDR_NONE) if(addr == INADDR_NONE)
{ {
struct addrinfo* ai = nil; struct addrinfo* ai = nil;
@ -81,7 +81,7 @@ uint32_t GetBinAddr(const char * textAddr)
memset(&hints, 0, sizeof(struct addrinfo)); memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = PF_INET; hints.ai_family = PF_INET;
hints.ai_flags = AI_CANONNAME; 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"); hsAssert(false, "getaddrinfo failed");
return addr; return addr;

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

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

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

@ -91,7 +91,7 @@ struct CliAuConn : hsRefCnt {
LINK(CliAuConn) link; LINK(CliAuConn) link;
AsyncSocket sock; AsyncSocket sock;
NetCli * cli; NetCli * cli;
char name[MAX_PATH]; plString name;
plNetAddress addr; plNetAddress addr;
plUUID token; plUUID token;
unsigned seq; unsigned seq;
@ -1529,7 +1529,7 @@ static void Connect (
//============================================================================ //============================================================================
static void Connect ( static void Connect (
const char name[], const plString& name,
const plNetAddress& addr const plNetAddress& addr
) { ) {
ASSERT(s_running); ASSERT(s_running);
@ -1538,7 +1538,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
strncpy(conn->name, name, arrsize(conn->name)); conn->name = name;
conn->Ref("Lifetime"); conn->Ref("Lifetime");
conn->AutoReconnect(); conn->AutoReconnect();
@ -1594,8 +1594,6 @@ CliAuConn::CliAuConn ()
, sock(nil), cli(nil), seq(0), serverChallenge(0) , sock(nil), cli(nil), seq(0), serverChallenge(0)
, cancelId(nil), abandoned(false) , cancelId(nil), abandoned(false)
{ {
memset(name, 0, sizeof(name));
++s_perf[kPerfConnCount]; ++s_perf[kPerfConnCount];
} }
@ -5124,7 +5122,7 @@ void AuthPingEnable (bool enable) {
//============================================================================ //============================================================================
void NetCliAuthStartConnect ( void NetCliAuthStartConnect (
const char* authAddrList[], const plString authAddrList[],
uint32_t 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
@ -5133,7 +5131,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 char* name = authAddrList[i]; const char* name = authAddrList[i].c_str();
while (unsigned ch = *name) { while (unsigned ch = *name) {
++name; ++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) { if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
@ -5141,7 +5139,7 @@ void NetCliAuthStartConnect (
AsyncAddressLookupName( AsyncAddressLookupName(
&cancelId, &cancelId,
AsyncLookupCallback, AsyncLookupCallback,
authAddrList[i], authAddrList[i].c_str(),
GetClientPort(), GetClientPort(),
nil 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 // Connect
//============================================================================ //============================================================================
void NetCliAuthStartConnect ( void NetCliAuthStartConnect (
const char* authAddrList[], const plString authAddrList[],
uint32_t authAddrCount uint32_t authAddrCount
); );
bool NetCliAuthQueryConnected (); bool NetCliAuthQueryConnected ();

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

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

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

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

Loading…
Cancel
Save