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