From 5e3223b5422f419e5507c304c5e787500eb4923d Mon Sep 17 00:00:00 2001 From: diafero Date: Tue, 2 Aug 2011 13:04:12 +0200 Subject: [PATCH] do not attempt to get the server status if no status URL is specified --- Sources/Plasma/Apps/plClient/winmain.cpp | 2 +- Sources/Plasma/Apps/plUruLauncher/Main.cpp | 33 ++++--------------- .../NucleusLib/pnNetBase/Private/pnNbSrvs.cpp | 6 ++-- 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/winmain.cpp b/Sources/Plasma/Apps/plClient/winmain.cpp index 46335029..71f53c55 100644 --- a/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/Sources/Plasma/Apps/plClient/winmain.cpp @@ -1193,7 +1193,7 @@ void StatusCallback(void *param) curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, &CurlCallback); curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, param); - if (curl_easy_perform(hCurl) != 0) + if (statusUrl[0] && 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) diff --git a/Sources/Plasma/Apps/plUruLauncher/Main.cpp b/Sources/Plasma/Apps/plUruLauncher/Main.cpp index 88347521..4fa804a8 100644 --- a/Sources/Plasma/Apps/plUruLauncher/Main.cpp +++ b/Sources/Plasma/Apps/plUruLauncher/Main.cpp @@ -605,39 +605,19 @@ static size_t CurlCallback(void *buffer, size_t size, size_t nmemb, void *) //============================================================================ static void StatusCallback(void *) { - CURL *hCurl; + char *serverUrl = hsWStringToString(GetServerStatusUrl()); - char *serverStatus = hsWStringToString(BuildTypeServerStatusPath()); - char serverUrl[256]; - snprintf(serverUrl, 256, "http://support.cyanworlds.com%s", serverStatus); - delete [] serverStatus; - - hCurl = curl_easy_init(); + CURL * hCurl = curl_easy_init(); curl_easy_setopt(hCurl, CURLOPT_ERRORBUFFER, s_curlError); // update while we are running while(!s_shutdown) { - if(BuildTypeServerStatusPath()) - { - //TODO: Get a server status path from the server.ini, without - // pulling in all the annoying pfConsole dependencies. - // Alternatively, make a better launcher... - - curl_easy_setopt(hCurl, CURLOPT_USERAGENT, "UruClient/1.0"); - curl_easy_setopt(hCurl, CURLOPT_URL, serverUrl); - - if(StrLen(s_postKey)) - { - char *safeData = curl_easy_escape(hCurl, s_postKey, strlen(s_postKey)); - curl_easy_setopt(hCurl, CURLOPT_POST, 1); - curl_easy_setopt(hCurl, CURLOPT_POSTFIELDS, safeData); - curl_free(safeData); - } + curl_easy_setopt(hCurl, CURLOPT_USERAGENT, "UruClient/1.0"); + curl_easy_setopt(hCurl, CURLOPT_URL, serverUrl); - if (curl_easy_perform(hCurl) != 0) - SetStatusText(s_curlError); - } + if (serverUrl[0] && curl_easy_perform(hCurl) != 0) // only perform request if there's actually a URL set + SetStatusText(s_curlError); for(unsigned i = 0; i < UPDATE_STATUSMSG_SECONDS && !s_shutdown; ++i) { @@ -646,6 +626,7 @@ static void StatusCallback(void *) } curl_easy_cleanup(hCurl); + delete [] serverUrl; s_statusEvent.Signal(); } diff --git a/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.cpp b/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.cpp index 62accab6..ed8297a2 100644 --- a/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.cpp +++ b/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.cpp @@ -137,9 +137,9 @@ void SetGateKeeperSrvHostname (const wchar addr[]) { //============================================================================ // User-visible Server //============================================================================ -static wchar s_serverStatusUrl[256]; -static wchar s_serverSignupUrl[256]; -static wchar s_serverName[256]; +static wchar s_serverStatusUrl[256] = {0}; +static wchar s_serverSignupUrl[256] = {0}; +static wchar s_serverName[256] = {0}; //============================================================================ const wchar *GetServerStatusUrl () {