Decent clean-up when closing STK. Send a message to the server if still signed in. (Server-code will not be pushed immediately, so testers might experience errors.)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13590 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
unitraxx
2013-08-28 22:45:11 +00:00
parent e0e8dff768
commit 7e8d167a89
5 changed files with 27 additions and 4 deletions

View File

@@ -155,6 +155,7 @@
#include "graphics/referee.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/event_handler.hpp"
#include "guiengine/dialog_queue.hpp"
#include "input/input_manager.hpp"
#include "input/device_manager.hpp"
#include "input/wiimote_manager.hpp"
@@ -168,13 +169,14 @@
#include "modes/demo_world.hpp"
#include "modes/profile_world.hpp"
#include "network/network_manager.hpp"
#include "online/http_manager.hpp"
#include "network/client_network_manager.hpp"
#include "network/server_network_manager.hpp"
#include "network/protocol_manager.hpp"
#include "network/protocols/server_lobby_room_protocol.hpp"
#include "online/current_user.hpp"
#include "online/http_manager.hpp"
#include "online/profile_manager.hpp"
#include "online/servers_manager.hpp"
#include "race/grand_prix_manager.hpp"
#include "race/highscore_manager.hpp"
#include "race/history.hpp"
@@ -1242,8 +1244,13 @@ void cleanSuperTuxKart()
if(Online::HTTPManager::isRunning())
Online::HTTPManager::get()->stopNetworkThread();
//delete in reverse order of what they were created in.
//delete in reverse order of what they were created in.
//see InitTuxkart()
Online::ServersManager::deallocate();
Online::ProfileManager::deallocate();
Online::CurrentUser::deallocate();
GUIEngine::DialogQueue::deallocate();
Referee::cleanup();
if(ReplayPlay::get()) ReplayPlay::destroy();
if(race_manager) delete race_manager;

View File

@@ -612,6 +612,20 @@ namespace Online{
// after 2 misses I'll show something
}
// ============================================================================
void CurrentUser::onSTKQuit() const
{
if(m_state != US_SIGNED_OUT)
{
HTTPRequest * request = new HTTPRequest(true, HTTPManager::MAX_PRIORITY);
request->setURL((std::string)UserConfigParams::m_server_multiplayer + "client-user.php");
request->setParameter("action", std::string("client-quit"));
request->setParameter("token", getToken());
request->setParameter("userid", getID());
HTTPManager::get()->addRequest(request);
}
}
// ============================================================================
irr::core::stringw CurrentUser::getUserName() const

View File

@@ -169,7 +169,7 @@ namespace Online{
const XMLRequest * requestUserSearch(const irr::core::stringw & search_string) const;
void onSTKQuit() const;
/** Returns the username if signed in. */
irr::core::stringw getUserName() const;

View File

@@ -135,7 +135,8 @@ namespace Online{
// a download, which mean we can get the mutex and ask the service
// thread here to cancel properly.
cancelAllDownloads();
addRequest(new Request(true, 9999, Request::RT_QUIT));
CurrentUser::get()->onSTKQuit();
addRequest(new Request(true, MAX_PRIORITY, Request::RT_QUIT));
} // stopNetworkThread

View File

@@ -82,6 +82,7 @@ namespace Online{
~HTTPManager();
public:
static const int MAX_PRIORITY = 9999;
// singleton
static HTTPManager* get();