Fixed the bug in rejoining a lobby. Added a lot of mutex stuff, which wasn't actually related to the problem at all.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13323 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
311fb7bf4b
commit
182cd15477
@ -58,7 +58,7 @@ namespace Online{
|
||||
{
|
||||
//Negative numbers are reserved for special requests ment for the HTTP Manager
|
||||
assert(type >= 0);
|
||||
m_url = "";
|
||||
m_url.setAtomic("");
|
||||
m_parameters = new Parameters;
|
||||
m_progress.setAtomic(0);
|
||||
}
|
||||
@ -70,9 +70,12 @@ namespace Online{
|
||||
|
||||
bool HTTPRequest::isAllowedToAdd()
|
||||
{
|
||||
if (m_url.size() > 5 && ( m_url.substr(0, 5) != "http:"))
|
||||
return false;
|
||||
return true;
|
||||
bool ok = true;
|
||||
m_url.lock();
|
||||
if (m_url.getData().size() > 5 && ( m_url.getData().substr(0, 5) != "http:"))
|
||||
ok = false;
|
||||
m_url.unlock();
|
||||
return ok;
|
||||
}
|
||||
|
||||
void HTTPRequest::afterOperation()
|
||||
@ -90,8 +93,7 @@ namespace Online{
|
||||
Log::error("online/http_functions", "Error while initialising libCurl session");
|
||||
return "";
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl_session, CURLOPT_URL, m_url.c_str());
|
||||
curl_easy_setopt(curl_session, CURLOPT_URL, m_url.getAtomic().c_str());
|
||||
Parameters::iterator iter;
|
||||
std::string postString = "";
|
||||
for (iter = m_parameters->begin(); iter != m_parameters->end(); ++iter)
|
||||
@ -195,11 +197,16 @@ namespace Online{
|
||||
XMLRequest::XMLRequest(int type, bool manage_memory, int priority)
|
||||
: HTTPRequest(priority, manage_memory, type)
|
||||
{
|
||||
m_info = "";
|
||||
m_success = false;
|
||||
m_info.setAtomic("");
|
||||
m_success.setAtomic(false);
|
||||
m_result = NULL;
|
||||
}
|
||||
|
||||
XMLRequest::~XMLRequest()
|
||||
{
|
||||
delete m_result;
|
||||
}
|
||||
|
||||
|
||||
void XMLRequest::operation()
|
||||
{
|
||||
@ -220,8 +227,8 @@ namespace Online{
|
||||
}
|
||||
else
|
||||
info = _("Unable to connect to the server. Check your internet connection or try again later.");
|
||||
m_info = info;
|
||||
m_success = success;
|
||||
m_info.setAtomic(info);
|
||||
m_success.setAtomic(success);
|
||||
HTTPRequest::afterOperation();
|
||||
}
|
||||
} // namespace Online
|
||||
|
@ -120,7 +120,7 @@ namespace Online{
|
||||
* packet is downloaded. At the end either -1 (error) or 1
|
||||
* (everything ok) at the end. */
|
||||
Synchronised<float> m_progress;
|
||||
std::string m_url;
|
||||
Synchronised<std::string> m_url;
|
||||
Parameters * m_parameters;
|
||||
|
||||
virtual void afterOperation() OVERRIDE;
|
||||
@ -164,8 +164,14 @@ namespace Online{
|
||||
/** Sets the current progress. */
|
||||
void setProgress(float f) { m_progress.setAtomic(f); }
|
||||
|
||||
const std::string &getURL() const {return m_url;}
|
||||
void setURL(const std::string & url) { m_url = url;}
|
||||
const std::string getURL() {
|
||||
m_url.lock();
|
||||
const std::string url = m_url.getData();
|
||||
m_url.unlock();
|
||||
return url;
|
||||
}
|
||||
|
||||
void setURL(const std::string & url) { m_url.setAtomic(url);}
|
||||
|
||||
virtual bool isAllowedToAdd() OVERRIDE;
|
||||
|
||||
@ -175,20 +181,25 @@ namespace Online{
|
||||
{
|
||||
protected :
|
||||
|
||||
XMLNode * m_result;
|
||||
irr::core::stringw m_info;
|
||||
bool m_success;
|
||||
XMLNode * m_result;
|
||||
Synchronised<irr::core::stringw> m_info;
|
||||
Synchronised<bool> m_success;
|
||||
|
||||
virtual void operation() OVERRIDE;
|
||||
virtual void afterOperation() OVERRIDE;
|
||||
|
||||
public :
|
||||
XMLRequest(int type = 0, bool manage_memory = false, int priority = 1);
|
||||
virtual ~XMLRequest() {delete m_result;}
|
||||
virtual ~XMLRequest();
|
||||
|
||||
virtual XMLNode * getResult() const { return m_result; }
|
||||
const irr::core::stringw & getInfo() const { return m_info; }
|
||||
bool isSuccess() const { return m_success; }
|
||||
const irr::core::stringw getInfo() {
|
||||
m_info.lock();
|
||||
const irr::core::stringw info = m_info.getData();
|
||||
m_info.unlock();
|
||||
return info;
|
||||
}
|
||||
bool isSuccess() const { return m_success.getAtomic(); }
|
||||
|
||||
};
|
||||
} //namespace Online
|
||||
|
@ -87,7 +87,7 @@ namespace Online{
|
||||
return request;
|
||||
}
|
||||
|
||||
void ServersManager::refresh(const RefreshRequest * input)
|
||||
void ServersManager::refresh(RefreshRequest * input)
|
||||
{
|
||||
if (input->isSuccess())
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ namespace Online {
|
||||
Server * m_joined_server;
|
||||
irr::core::stringw m_info_message;
|
||||
float m_last_load_time;
|
||||
void refresh(const RefreshRequest * input);
|
||||
void refresh(RefreshRequest * input);
|
||||
|
||||
public:
|
||||
// Singleton
|
||||
|
@ -46,8 +46,7 @@ DEFINE_SCREEN_SINGLETON( NetworkingLobby );
|
||||
|
||||
NetworkingLobby::NetworkingLobby() : Screen("online/lobby.stkgui")
|
||||
{
|
||||
m_server = ServersManager::acquire()->getJoinedServer();
|
||||
ServersManager::release();
|
||||
m_server = NULL;
|
||||
} // NetworkingLobby
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -85,6 +84,8 @@ void NetworkingLobby::init()
|
||||
Screen::init();
|
||||
setInitialFocus();
|
||||
DemoWorld::resetIdleTime(); //FIXME : what's this?
|
||||
m_server = ServersManager::acquire()->getJoinedServer();
|
||||
ServersManager::release();
|
||||
m_server_name_widget->setText(m_server->getName(),false);
|
||||
|
||||
} // init
|
||||
|
@ -46,9 +46,15 @@ ServerSelection::ServerSelection() : Screen("online/server_selection.stkgui")
|
||||
|
||||
ServerSelection::~ServerSelection()
|
||||
{
|
||||
delete m_refresh_request;
|
||||
} // ServerSelection
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void ServerSelection::tearDown()
|
||||
{
|
||||
delete m_refresh_request;
|
||||
} // tearDown
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
@ -76,6 +76,8 @@ public:
|
||||
|
||||
virtual void init() OVERRIDE;
|
||||
|
||||
virtual void tearDown() OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void onUpdate(float dt, irr::video::IVideoDriver*) OVERRIDE;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user