Fixing issue #138: No longer throw an exception if the server list is invalid, because the server list is always invalid in network games.

This commit is contained in:
lotodore
2012-06-17 13:35:31 +02:00
parent f989f447f3
commit 7bc8c1b9f2
2 changed files with 8 additions and 4 deletions
+3
View File
@@ -174,6 +174,9 @@ void
ClientStateStartServerListDownload::Enter(boost::shared_ptr<ClientThread> client) ClientStateStartServerListDownload::Enter(boost::shared_ptr<ClientThread> client)
{ {
path tmpServerListPath(client->GetCacheServerListFileName()); path tmpServerListPath(client->GetCacheServerListFileName());
if (tmpServerListPath.empty())
throw ClientException(__FILE__, __LINE__, ERR_SOCK_INVALID_SERVERLIST_URL, 0);
if (exists(tmpServerListPath)) { if (exists(tmpServerListPath)) {
// Download the current server list once a day. // Download the current server list once a day.
// If the previous file is older than one day, delete it. // If the previous file is older than one day, delete it.
+5 -4
View File
@@ -936,15 +936,16 @@ ClientThread::GetContext()
string string
ClientThread::GetCacheServerListFileName() ClientThread::GetCacheServerListFileName()
{ {
string fileName;
path tmpServerListPath(GetContext().GetCacheDir()); path tmpServerListPath(GetContext().GetCacheDir());
string serverListUrl(GetContext().GetServerListUrl()); string serverListUrl(GetContext().GetServerListUrl());
// Retrieve the file name from the URL. // Retrieve the file name from the URL.
size_t pos = serverListUrl.find_last_of('/'); size_t pos = serverListUrl.find_last_of('/');
if (GetContext().GetCacheDir().empty() || serverListUrl.empty() || pos == string::npos || ++pos >= serverListUrl.length()) { if (!GetContext().GetCacheDir().empty() && !serverListUrl.empty() && pos != string::npos && ++pos < serverListUrl.length()) {
throw ClientException(__FILE__, __LINE__, ERR_SOCK_INVALID_SERVERLIST_URL, 0); tmpServerListPath /= serverListUrl.substr(pos);
fileName = tmpServerListPath.directory_string();
} }
tmpServerListPath /= serverListUrl.substr(pos); return fileName;
return tmpServerListPath.directory_string();
} }
void void