From 7bc8c1b9f288c1591570f466dce318828acbf486 Mon Sep 17 00:00:00 2001 From: lotodore Date: Sun, 17 Jun 2012 13:35:31 +0200 Subject: [PATCH] Fixing issue #138: No longer throw an exception if the server list is invalid, because the server list is always invalid in network games. --- src/net/common/clientstate.cpp | 3 +++ src/net/common/clientthread.cpp | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index 58c35a4d..a98938fe 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -174,6 +174,9 @@ void ClientStateStartServerListDownload::Enter(boost::shared_ptr client) { path tmpServerListPath(client->GetCacheServerListFileName()); + if (tmpServerListPath.empty()) + throw ClientException(__FILE__, __LINE__, ERR_SOCK_INVALID_SERVERLIST_URL, 0); + if (exists(tmpServerListPath)) { // Download the current server list once a day. // If the previous file is older than one day, delete it. diff --git a/src/net/common/clientthread.cpp b/src/net/common/clientthread.cpp index 9055918c..145c3371 100644 --- a/src/net/common/clientthread.cpp +++ b/src/net/common/clientthread.cpp @@ -936,15 +936,16 @@ ClientThread::GetContext() string ClientThread::GetCacheServerListFileName() { + string fileName; path tmpServerListPath(GetContext().GetCacheDir()); string serverListUrl(GetContext().GetServerListUrl()); // Retrieve the file name from the URL. size_t pos = serverListUrl.find_last_of('/'); - if (GetContext().GetCacheDir().empty() || serverListUrl.empty() || pos == string::npos || ++pos >= serverListUrl.length()) { - throw ClientException(__FILE__, __LINE__, ERR_SOCK_INVALID_SERVERLIST_URL, 0); + if (!GetContext().GetCacheDir().empty() && !serverListUrl.empty() && pos != string::npos && ++pos < serverListUrl.length()) { + tmpServerListPath /= serverListUrl.substr(pos); + fileName = tmpServerListPath.directory_string(); } - tmpServerListPath /= serverListUrl.substr(pos); - return tmpServerListPath.directory_string(); + return fileName; } void