Now each PlayerProfile has a (currently still called) CurrentUser
which manages online connection data. Work-in-progress to use only one object for all player data (instead of two atm: PlayerProfile and CurrentUser).
This commit is contained in:
parent
481b5f22bb
commit
502987d3e0
@ -24,6 +24,7 @@
|
||||
#include "guiengine/dialog_queue.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "states_screens/dialogs/notification_dialog.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@ -207,11 +208,11 @@ void Achievement::check()
|
||||
|
||||
// Sends a confirmation to the server that an achievement has been
|
||||
// completed, if a user is signed in.
|
||||
Online::CurrentUser *cu = Online::CurrentUser::get();
|
||||
Online::CurrentUser *cu = PlayerManager::getCurrentUser();
|
||||
if (cu->isRegisteredUser())
|
||||
{
|
||||
Online::HTTPRequest * request = new Online::HTTPRequest(true);
|
||||
Online::CurrentUser::setUserDetails(request, "achieving");
|
||||
PlayerManager::setUserDetails(request, "achieving");
|
||||
request->addParameter("achievementid", m_id);
|
||||
request->queue();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
@ -45,6 +46,14 @@ void PlayerManager::create()
|
||||
|
||||
} // create
|
||||
|
||||
// ============================================================================
|
||||
void PlayerManager::setUserDetails(Online::HTTPRequest *request,
|
||||
const std::string &action,
|
||||
const std::string &php_name)
|
||||
{
|
||||
get()->getCurrentUser()->setUserDetails(request, action, php_name);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
/** Constructor.
|
||||
*/
|
||||
|
@ -30,6 +30,12 @@
|
||||
#include <cstddef> // NULL
|
||||
|
||||
class AchievementsStatus;
|
||||
|
||||
namespace online
|
||||
{
|
||||
class HTTPRequest;
|
||||
class CurrentUser;
|
||||
}
|
||||
class PlayerProfile;
|
||||
|
||||
/** A special class that manages all local player accounts. It reads all player
|
||||
@ -74,7 +80,11 @@ public:
|
||||
m_player_manager = NULL;
|
||||
} // destroy
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
static void setUserDetails(Online::HTTPRequest *request,
|
||||
const std::string &action,
|
||||
const std::string &php_name="");
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void save();
|
||||
void loadRemainingData();
|
||||
unsigned int getUniqueId() const;
|
||||
@ -91,6 +101,11 @@ public:
|
||||
return get()->m_current_player;
|
||||
} // getCurrentPlayer
|
||||
// ------------------------------------------------------------------------
|
||||
static Online::CurrentUser* getCurrentUser()
|
||||
{
|
||||
return get()->m_current_player->getCurrentUser();
|
||||
} // getCurrentUser
|
||||
// ------------------------------------------------------------------------
|
||||
PlayerProfile *getPlayer(const irr::core::stringw &name);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the number of players in the config file.*/
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "achievements/achievements_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
@ -45,6 +46,7 @@ PlayerProfile::PlayerProfile(const core::stringw& name, bool is_guest)
|
||||
m_unique_id = PlayerManager::get()->getUniqueId();
|
||||
m_story_mode_status = unlock_manager->createStoryModeStatus();
|
||||
m_is_default = false;
|
||||
m_current_user = new Online::CurrentUser();
|
||||
m_achievements_status =
|
||||
AchievementsManager::get()->createAchievementsStatus();
|
||||
} // PlayerProfile
|
||||
@ -70,6 +72,7 @@ PlayerProfile::PlayerProfile(const XMLNode* node)
|
||||
m_saved_user_id = 0;
|
||||
m_story_mode_status = NULL;
|
||||
m_achievements_status = NULL;
|
||||
m_current_user = new Online::CurrentUser();
|
||||
|
||||
node->get("name", &m_name );
|
||||
node->get("guest", &m_is_guest_account);
|
||||
@ -86,7 +89,17 @@ PlayerProfile::PlayerProfile(const XMLNode* node)
|
||||
} // PlayerProfile
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** This function loads the achievement and story mode data. This
|
||||
PlayerProfile::~PlayerProfile()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
m_magic_number = 0xDEADBEEF;
|
||||
#endif
|
||||
delete m_current_user;
|
||||
} // ~PlayerProfile
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** This function loads the achievement and story mode data. This
|
||||
*/
|
||||
void PlayerProfile::loadRemainingData(const XMLNode *node)
|
||||
{
|
||||
|
@ -28,8 +28,9 @@ using namespace irr;
|
||||
|
||||
#include <string>
|
||||
|
||||
class UTFWriter;
|
||||
class AchievementsStatus;
|
||||
namespace Online { class CurrentUser; }
|
||||
class UTFWriter;
|
||||
|
||||
/** Class for managing player profiles (name, usage frequency,
|
||||
* etc.). All PlayerProfiles are managed by the PlayerManager.
|
||||
@ -42,6 +43,8 @@ class PlayerProfile : public NoCopy
|
||||
{
|
||||
private:
|
||||
|
||||
Online::CurrentUser *m_current_user;
|
||||
|
||||
/** The name of the player (wide string, so it can be in native
|
||||
* language). */
|
||||
core::stringw m_name;
|
||||
@ -78,10 +81,9 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
PlayerProfile(const core::stringw &name, bool is_guest = false);
|
||||
|
||||
PlayerProfile(const XMLNode *node);
|
||||
|
||||
PlayerProfile(const core::stringw &name, bool is_guest = false);
|
||||
PlayerProfile(const XMLNode *node);
|
||||
~PlayerProfile();
|
||||
void save(UTFWriter &out);
|
||||
void loadRemainingData(const XMLNode *node);
|
||||
void incrementUseFrequency();
|
||||
@ -92,13 +94,7 @@ public:
|
||||
void clearSession();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
~PlayerProfile()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
m_magic_number = 0xDEADBEEF;
|
||||
#endif
|
||||
} // ~PlayerProfile
|
||||
|
||||
Online::CurrentUser* getCurrentUser() { return m_current_user; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the name of this player. */
|
||||
void setName(const core::stringw& name)
|
||||
@ -113,9 +109,7 @@ public:
|
||||
/** Returns the name of this player. */
|
||||
core::stringw getName() const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(m_magic_number == 0xABCD1234);
|
||||
#endif
|
||||
return m_name.c_str();
|
||||
} // getName
|
||||
|
||||
|
@ -966,7 +966,7 @@ int handleCmdLine()
|
||||
{
|
||||
irr::core::stringw s;
|
||||
Online::XMLRequest* request =
|
||||
Online::CurrentUser::get()->requestSignIn(login, password, false, false);
|
||||
PlayerManager::getCurrentUser()->requestSignIn(login, password, false, false);
|
||||
request->executeNow();
|
||||
|
||||
if (request->isSuccess())
|
||||
@ -1425,7 +1425,6 @@ static void cleanSuperTuxKart()
|
||||
Online::RequestManager::deallocate();
|
||||
Online::ServersManager::deallocate();
|
||||
Online::ProfileManager::destroy();
|
||||
Online::CurrentUser::deallocate();
|
||||
GUIEngine::DialogQueue::deallocate();
|
||||
|
||||
AchievementsManager::destroy();
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "network/protocols/client_lobby_room_protocol.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "modes/world_with_rank.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "network/network_world.hpp"
|
||||
@ -233,7 +234,7 @@ void ClientLobbyRoomProtocol::update()
|
||||
{
|
||||
NetworkString ns;
|
||||
// 1 (connection request), 4 (size of id), global id
|
||||
ns.ai8(1).ai8(4).ai32(Online::CurrentUser::get()->getID());
|
||||
ns.ai8(1).ai8(4).ai32(PlayerManager::getCurrentUser()->getID());
|
||||
m_listener->sendMessage(this, ns);
|
||||
m_state = REQUESTING_CONNECTION;
|
||||
}
|
||||
@ -295,7 +296,7 @@ void ClientLobbyRoomProtocol::newPlayer(Event* event)
|
||||
uint32_t global_id = data.gui32(1);
|
||||
uint8_t race_id = data.gui8(6);
|
||||
|
||||
if (global_id == Online::CurrentUser::get()->getID())
|
||||
if (global_id == PlayerManager::getCurrentUser()->getID())
|
||||
{
|
||||
Log::error("ClientLobbyRoomProtocol", "The server notified me that i'm a new player in the room (not normal).");
|
||||
}
|
||||
@ -368,7 +369,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
|
||||
STKPeer* peer = *(event->peer);
|
||||
|
||||
uint32_t global_id = data.gui32(8);
|
||||
if (global_id == Online::CurrentUser::get()->getID())
|
||||
if (global_id == PlayerManager::getCurrentUser()->getID())
|
||||
{
|
||||
Log::info("ClientLobbyRoomProtocol", "The server accepted the connection.");
|
||||
|
||||
@ -376,7 +377,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
|
||||
NetworkPlayerProfile* profile = new NetworkPlayerProfile();
|
||||
profile->kart_name = "";
|
||||
profile->race_id = data.gui8(1);
|
||||
profile->user_profile = Online::CurrentUser::get()->getProfile();
|
||||
profile->user_profile = PlayerManager::getCurrentUser()->getProfile();
|
||||
m_setup->addPlayer(profile);
|
||||
// connection token
|
||||
uint32_t token = data.gui32(3);
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "network/protocols/get_peer_address.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
@ -45,11 +46,9 @@ void GetPeerAddress::asynchronousUpdate()
|
||||
if (m_state == NONE)
|
||||
{
|
||||
m_request = new Online::XMLRequest();
|
||||
m_request->setServerURL("address-management.php");
|
||||
m_request->addParameter("id",Online::CurrentUser::get()->getID());
|
||||
m_request->addParameter("token",Online::CurrentUser::get()->getToken());
|
||||
PlayerManager::setUserDetails(m_request, "get",
|
||||
"address-management.php");
|
||||
m_request->addParameter("peer_id",m_peer_id);
|
||||
m_request->addParameter("action","get");
|
||||
|
||||
Online::RequestManager::get()->addRequest(m_request);
|
||||
m_state = REQUEST_PENDING;
|
||||
|
@ -18,10 +18,11 @@
|
||||
|
||||
#include "network/protocols/hide_public_address.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
HidePublicAddress::HidePublicAddress() : Protocol(NULL, PROTOCOL_SILENT)
|
||||
@ -42,10 +43,8 @@ void HidePublicAddress::asynchronousUpdate()
|
||||
if (m_state == NONE)
|
||||
{
|
||||
m_request = new Online::XMLRequest();
|
||||
m_request->setServerURL("address-management.php");
|
||||
m_request->addParameter("id",Online::CurrentUser::get()->getID());
|
||||
m_request->addParameter("token",Online::CurrentUser::get()->getToken());
|
||||
m_request->addParameter("action","unset");
|
||||
PlayerManager::setUserDetails(m_request, "unset",
|
||||
"address-management.php");
|
||||
|
||||
Online::RequestManager::get()->addRequest(m_request);
|
||||
m_state = REQUEST_PENDING;
|
||||
|
@ -18,10 +18,11 @@
|
||||
|
||||
#include "quick_join_protocol.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
QuickJoinProtocol::QuickJoinProtocol(CallbackObject* callback_object, uint32_t* server_id) : Protocol(callback_object, PROTOCOL_SILENT)
|
||||
@ -44,10 +45,8 @@ void QuickJoinProtocol::asynchronousUpdate()
|
||||
{
|
||||
TransportAddress addr = NetworkManager::getInstance()->getPublicAddress();
|
||||
m_request = new Online::XMLRequest();
|
||||
PlayerManager::setUserDetails(m_request, "quick-join");
|
||||
m_request->setServerURL("address-management.php");
|
||||
m_request->addParameter("id",Online::CurrentUser::get()->getID());
|
||||
m_request->addParameter("token",Online::CurrentUser::get()->getToken());
|
||||
m_request->addParameter("action","quick-join");
|
||||
|
||||
Online::RequestManager::get()->addRequest(m_request);
|
||||
m_state = REQUEST_PENDING;
|
||||
|
@ -18,10 +18,11 @@
|
||||
|
||||
#include "network/protocols/request_connection.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "online/servers_manager.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
|
||||
using namespace Online;
|
||||
|
||||
@ -72,8 +73,8 @@ void RequestConnection::asynchronousUpdate()
|
||||
case NONE:
|
||||
{
|
||||
m_request = new ServerJoinRequest();
|
||||
CurrentUser::setUserDetails(m_request, "request-connection");
|
||||
m_request->setServerURL("address-management.php");
|
||||
PlayerManager::setUserDetails(m_request, "request-connection",
|
||||
"address-management.php");
|
||||
m_request->addParameter("server_id",m_server_id);
|
||||
m_request->queue();
|
||||
m_state = REQUEST_PENDING;
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "network/protocols/server_lobby_room_protocol.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "network/network_world.hpp"
|
||||
@ -183,12 +184,10 @@ void ServerLobbyRoomProtocol::checkIncomingConnectionRequests()
|
||||
last_poll_time = StkTime::getRealTime();
|
||||
TransportAddress addr = NetworkManager::getInstance()->getPublicAddress();
|
||||
Online::XMLRequest* request = new Online::XMLRequest();
|
||||
request->setServerURL("address-management.php");
|
||||
request->addParameter("id",Online::CurrentUser::get()->getProfile()->getID());
|
||||
request->addParameter("token",Online::CurrentUser::get()->getToken());
|
||||
PlayerManager::setUserDetails(request, "poll-connection-requests",
|
||||
"address-management.php");
|
||||
request->addParameter("address",addr.ip);
|
||||
request->addParameter("port",addr.port);
|
||||
request->addParameter("action","poll-connection-requests");
|
||||
|
||||
request->executeNow();
|
||||
assert(request->isDone());
|
||||
|
@ -18,10 +18,11 @@
|
||||
|
||||
#include "network/protocols/show_public_address.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
ShowPublicAddress::ShowPublicAddress() : Protocol(NULL, PROTOCOL_SILENT)
|
||||
@ -43,13 +44,11 @@ void ShowPublicAddress::asynchronousUpdate()
|
||||
{
|
||||
TransportAddress addr = NetworkManager::getInstance()->getPublicAddress();
|
||||
m_request = new Online::XMLRequest();
|
||||
m_request->setServerURL("address-management.php");
|
||||
m_request->addParameter("id",Online::CurrentUser::get()->getID());
|
||||
m_request->addParameter("token",Online::CurrentUser::get()->getToken());
|
||||
PlayerManager::setUserDetails(m_request, "set",
|
||||
"address-management.php");
|
||||
m_request->addParameter("address",addr.ip);
|
||||
m_request->addParameter("port",addr.port);
|
||||
m_request->addParameter("private_port",NetworkManager::getInstance()->getHost()->getPort());
|
||||
m_request->addParameter("action","set");
|
||||
Log::info("ShowPublicAddress", "Showing addr %u and port %d", addr.ip, addr.port);
|
||||
|
||||
Online::RequestManager::get()->addRequest(m_request);
|
||||
|
@ -106,7 +106,7 @@ void StartGameProtocol::update()
|
||||
// have to add self first
|
||||
for (unsigned int i = 0; i < players.size(); i++)
|
||||
{
|
||||
bool is_me = (players[i]->user_profile == Online::CurrentUser::get()->getProfile());
|
||||
bool is_me = (players[i]->user_profile == PlayerManager::getCurrentUser()->getProfile());
|
||||
if (is_me)
|
||||
{
|
||||
NetworkPlayerProfile* profile = players[i];
|
||||
@ -134,7 +134,7 @@ void StartGameProtocol::update()
|
||||
}
|
||||
for (unsigned int i = 0; i < players.size(); i++)
|
||||
{
|
||||
bool is_me = (players[i]->user_profile == Online::CurrentUser::get()->getProfile());
|
||||
bool is_me = (players[i]->user_profile == PlayerManager::getCurrentUser()->getProfile());
|
||||
NetworkPlayerProfile* profile = players[i];
|
||||
RemoteKartInfo rki(profile->race_id, profile->kart_name,
|
||||
profile->user_profile->getUserName(), profile->race_id, !is_me);
|
||||
|
@ -18,10 +18,11 @@
|
||||
|
||||
#include "network/protocols/start_server.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
|
||||
StartServer::StartServer() : Protocol(NULL, PROTOCOL_SILENT)
|
||||
{
|
||||
@ -42,14 +43,12 @@ void StartServer::asynchronousUpdate()
|
||||
{
|
||||
TransportAddress addr = NetworkManager::getInstance()->getPublicAddress();
|
||||
m_request = new Online::XMLRequest();
|
||||
m_request->setServerURL("address-management.php");
|
||||
m_request->addParameter("id",Online::CurrentUser::get()->getID());
|
||||
m_request->addParameter("token",Online::CurrentUser::get()->getToken());
|
||||
PlayerManager::setUserDetails(m_request, "start-server",
|
||||
"address-management.php");
|
||||
m_request->addParameter("address",addr.ip);
|
||||
m_request->addParameter("port",addr.port);
|
||||
m_request->addParameter("private_port",NetworkManager::getInstance()->getHost()->getPort());
|
||||
m_request->addParameter("max_players",UserConfigParams::m_server_max_players);
|
||||
m_request->addParameter("action","start-server");
|
||||
Log::info("ShowPublicAddress", "Showing addr %u and port %d", addr.ip, addr.port);
|
||||
|
||||
Online::RequestManager::get()->addRequest(m_request);
|
||||
|
@ -18,10 +18,11 @@
|
||||
|
||||
#include "network/protocols/stop_server.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
|
||||
StopServer::StopServer() : Protocol(NULL, PROTOCOL_SILENT)
|
||||
{
|
||||
@ -47,12 +48,10 @@ void StopServer::asynchronousUpdate()
|
||||
{
|
||||
TransportAddress addr = NetworkManager::getInstance()->getPublicAddress();
|
||||
m_request = new Online::XMLRequest();
|
||||
m_request->setServerURL( "address-management.php");
|
||||
m_request->addParameter("id",Online::CurrentUser::get()->getID());
|
||||
m_request->addParameter("token",Online::CurrentUser::get()->getToken());
|
||||
PlayerManager::setUserDetails(m_request, "stop-server",
|
||||
"address-management.php");
|
||||
m_request->addParameter("address",addr.ip);
|
||||
m_request->addParameter("port",addr.port);
|
||||
m_request->addParameter("action","stop-server");
|
||||
Log::info("StopServer", "address %u, port %d", addr.ip, addr.port);
|
||||
|
||||
Online::RequestManager::get()->addRequest(m_request);
|
||||
|
@ -45,39 +45,25 @@ using namespace Online;
|
||||
|
||||
namespace Online
|
||||
{
|
||||
static CurrentUser* current_user_singleton(NULL);
|
||||
|
||||
/** Singleton create function. */
|
||||
CurrentUser* CurrentUser::get()
|
||||
{
|
||||
if (current_user_singleton == NULL)
|
||||
current_user_singleton = new CurrentUser();
|
||||
return current_user_singleton;
|
||||
} // get
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
void CurrentUser::deallocate()
|
||||
{
|
||||
delete current_user_singleton;
|
||||
current_user_singleton = NULL;
|
||||
} // deallocate
|
||||
// ------------------------------------------------------------------------
|
||||
/** Adds the login credential to a http request. A handy static function
|
||||
* to allow for shorter request creation code. It sets the name of
|
||||
/** Adds the login credential to a http request. It sets the name of
|
||||
* the script to invokce, token, and user id.
|
||||
* \param request The http request.
|
||||
* \param action If not empty, the action to be set.
|
||||
*/
|
||||
void CurrentUser::setUserDetails(HTTPRequest *request,
|
||||
const std::string &action)
|
||||
const std::string &action,
|
||||
const std::string &php_script)
|
||||
{
|
||||
CurrentUser *cu = CurrentUser::get();
|
||||
request->setServerURL("client-user.php");
|
||||
if (php_script.size()>0)
|
||||
request->setServerURL(php_script);
|
||||
else
|
||||
request->setServerURL("client-user.php");
|
||||
|
||||
if (cu && cu->m_profile)
|
||||
request->addParameter("userid", cu->m_profile->getID());
|
||||
if(cu->m_state == US_SIGNED_IN)
|
||||
request->addParameter("token", cu->m_token);
|
||||
if (m_profile)
|
||||
request->addParameter("userid", m_profile->getID());
|
||||
if(m_state == US_SIGNED_IN)
|
||||
request->addParameter("token", m_token);
|
||||
if (action.size() > 0)
|
||||
request->addParameter("action", action);
|
||||
} // setUserDetails
|
||||
@ -145,7 +131,7 @@ namespace Online
|
||||
*/
|
||||
void CurrentUser::SignInRequest::callback()
|
||||
{
|
||||
CurrentUser::get()->signIn(isSuccess(), getXMLData());
|
||||
PlayerManager::getCurrentUser()->signIn(isSuccess(), getXMLData());
|
||||
GUIEngine::Screen *screen = GUIEngine::getCurrentScreen();
|
||||
LoginScreen *login = dynamic_cast<LoginScreen*>(screen);
|
||||
if(login)
|
||||
@ -214,7 +200,7 @@ namespace Online
|
||||
// --------------------------------------------------------------------
|
||||
void CurrentUser::SignOutRequest::callback()
|
||||
{
|
||||
CurrentUser::get()->signOut(isSuccess(), getXMLData());
|
||||
PlayerManager::getCurrentUser()->signOut(isSuccess(), getXMLData());
|
||||
} // SignOutRequest::callback
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -256,9 +242,9 @@ namespace Online
|
||||
{
|
||||
if(isSuccess())
|
||||
{
|
||||
if(!CurrentUser::get()->isRegisteredUser())
|
||||
if (!PlayerManager::getCurrentUser()->isRegisteredUser())
|
||||
return;
|
||||
if(CurrentUser::get()->getProfile()->hasFetchedFriends())
|
||||
if (PlayerManager::getCurrentUser()->getProfile()->hasFetchedFriends())
|
||||
{
|
||||
std::string online_friends_string("");
|
||||
if(getXMLData()->get("online", &online_friends_string) == 1)
|
||||
@ -267,7 +253,7 @@ namespace Online
|
||||
StringUtils::splitToUInt(online_friends_string, ' ');
|
||||
bool went_offline = false;
|
||||
std::vector<uint32_t> friends =
|
||||
CurrentUser::get()->getProfile()->getFriends();
|
||||
PlayerManager::getCurrentUser()->getProfile()->getFriends();
|
||||
std::vector<core::stringw> to_notify;
|
||||
for(unsigned int i = 0; i < friends.size(); ++i)
|
||||
{
|
||||
@ -343,7 +329,7 @@ namespace Online
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentUser::get()->getProfile()->fetchFriends();
|
||||
PlayerManager::getCurrentUser()->getProfile()->fetchFriends();
|
||||
}
|
||||
|
||||
int friend_request_count = 0;
|
||||
|
@ -24,8 +24,9 @@
|
||||
#include "online/request_manager.hpp"
|
||||
#include "online/server.hpp"
|
||||
#include "online/xml_request.hpp"
|
||||
#include "utils/types.hpp"
|
||||
#include "utils/leak_check.hpp"
|
||||
#include "utils/synchronised.hpp"
|
||||
#include "utils/types.hpp"
|
||||
|
||||
#include <irrString.h>
|
||||
|
||||
@ -45,6 +46,8 @@ namespace Online
|
||||
*/
|
||||
class CurrentUser
|
||||
{
|
||||
private:
|
||||
LEAK_CHECK()
|
||||
public:
|
||||
enum UserState
|
||||
{
|
||||
@ -87,17 +90,15 @@ namespace Online
|
||||
|
||||
bool saveSession() const { return m_save_session; }
|
||||
|
||||
CurrentUser();
|
||||
|
||||
void signIn (bool success, const XMLNode * input);
|
||||
void signOut (bool success, const XMLNode * input);
|
||||
|
||||
public:
|
||||
/**Singleton */
|
||||
static CurrentUser * get();
|
||||
static void deallocate();
|
||||
static void setUserDetails(HTTPRequest *request,
|
||||
const std::string &action);
|
||||
CurrentUser();
|
||||
void setUserDetails(HTTPRequest *request,
|
||||
const std::string &action,
|
||||
const std::string &php_script="");
|
||||
|
||||
void requestSavedSession();
|
||||
SignInRequest * requestSignIn( const irr::core::stringw &username,
|
||||
|
@ -19,9 +19,10 @@
|
||||
|
||||
#include "online/online_profile.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "online/profile_manager.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@ -113,7 +114,7 @@ OnlineProfile::OnlineProfile(const XMLNode * xml, ConstructorType type)
|
||||
|
||||
xml->get("id", &m_id );
|
||||
xml->get("user_name", &m_username);
|
||||
m_is_current_user = (m_id == CurrentUser::get()->getID());
|
||||
m_is_current_user = (m_id == PlayerManager::getCurrentUser()->getID());
|
||||
m_state = S_READY;
|
||||
} // OnlineProfile(XMLNode)
|
||||
|
||||
@ -130,7 +131,7 @@ OnlineProfile::~OnlineProfile()
|
||||
*/
|
||||
void OnlineProfile::fetchAchievements()
|
||||
{
|
||||
assert(CurrentUser::get()->isRegisteredUser());
|
||||
assert(PlayerManager::getCurrentUser()->isRegisteredUser());
|
||||
if (m_has_fetched_achievements || m_is_current_user)
|
||||
return;
|
||||
m_state = S_FETCHING;
|
||||
@ -154,7 +155,7 @@ void OnlineProfile::fetchAchievements()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
AchievementsRequest * request = new AchievementsRequest();
|
||||
CurrentUser::setUserDetails(request, "get-achievements");
|
||||
PlayerManager::setUserDetails(request, "get-achievements");
|
||||
request->addParameter("visitingid", m_id);
|
||||
RequestManager::get()->addRequest(request);
|
||||
} // fetchAchievements
|
||||
@ -184,7 +185,7 @@ void OnlineProfile::storeAchievements(const XMLNode * input)
|
||||
*/
|
||||
void OnlineProfile::fetchFriends()
|
||||
{
|
||||
assert(CurrentUser::get()->isRegisteredUser());
|
||||
assert(PlayerManager::getCurrentUser()->isRegisteredUser());
|
||||
if (m_has_fetched_friends)
|
||||
return;
|
||||
m_state = S_FETCHING;
|
||||
@ -206,7 +207,7 @@ void OnlineProfile::fetchFriends()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
FriendsListRequest * request = new FriendsListRequest();
|
||||
CurrentUser::setUserDetails(request, "get-friends-list");
|
||||
PlayerManager::setUserDetails(request, "get-friends-list");
|
||||
request->addParameter("visitingid", m_id);
|
||||
RequestManager::get()->addRequest(request);
|
||||
} // fetchFriends
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "online/request_manager.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
|
||||
@ -128,7 +129,7 @@ namespace Online
|
||||
errno);
|
||||
}
|
||||
pthread_attr_destroy(&attr);
|
||||
CurrentUser::get()->requestSavedSession();
|
||||
PlayerManager::getCurrentUser()->requestSavedSession();
|
||||
} // startNetworkThread
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -146,7 +147,7 @@ namespace Online
|
||||
// a download, which mean we can get the mutex and ask the service
|
||||
// thread here to cancel properly.
|
||||
//cancelAllDownloads(); FIXME if used this way it also cancels the client-quit action
|
||||
CurrentUser::get()->onSTKQuit();
|
||||
PlayerManager::getCurrentUser()->onSTKQuit();
|
||||
addRequest(new Request(true, HTTP_MAX_PRIORITY, Request::RT_QUIT));
|
||||
} // stopNetworkThread
|
||||
|
||||
@ -277,7 +278,7 @@ namespace Online
|
||||
handleResultQueue();
|
||||
|
||||
//Database polling starts here, only needed for registered users
|
||||
if(!CurrentUser::get()->isRegisteredUser())
|
||||
if (!PlayerManager::getCurrentUser()->isRegisteredUser())
|
||||
return;
|
||||
|
||||
m_time_since_poll += dt;
|
||||
@ -287,7 +288,7 @@ namespace Online
|
||||
if(m_time_since_poll > interval)
|
||||
{
|
||||
m_time_since_poll = 0;
|
||||
CurrentUser::get()->requestPoll();
|
||||
PlayerManager::getCurrentUser()->requestPoll();
|
||||
}
|
||||
|
||||
} // update
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "modes/demo_world.hpp"
|
||||
#include "online/servers_manager.hpp"
|
||||
#include "online/messages.hpp"
|
||||
@ -57,7 +58,7 @@ void CreateServerScreen::loadedFromFile()
|
||||
|
||||
m_name_widget = getWidget<TextBoxWidget>("name");
|
||||
assert(m_name_widget != NULL);
|
||||
m_name_widget->setText(CurrentUser::get()->getUserName() + _("'s server"));
|
||||
m_name_widget->setText(PlayerManager::getCurrentUser()->getUserName() + _("'s server"));
|
||||
m_max_players_widget = getWidget<SpinnerWidget>("max_players");
|
||||
assert(m_max_players_widget != NULL);
|
||||
m_max_players_widget->setValue(8);
|
||||
@ -138,7 +139,7 @@ void CreateServerScreen::serverCreationRequest()
|
||||
{
|
||||
|
||||
m_server_creation_request = new ServerCreationRequest();
|
||||
CurrentUser::setUserDetails(m_server_creation_request,"create_server");
|
||||
PlayerManager::setUserDetails(m_server_creation_request,"create_server");
|
||||
m_server_creation_request->addParameter("name", name);
|
||||
m_server_creation_request->addParameter("max_players", max_players);
|
||||
m_server_creation_request->queue();
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <pthread.h>
|
||||
|
||||
#include "addons/addons_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
@ -252,7 +253,7 @@ GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& event
|
||||
// ----------------------------------------------------------------------------
|
||||
void AddonsLoading::voteClicked()
|
||||
{
|
||||
if (Online::CurrentUser::get()->isRegisteredUser())
|
||||
if (PlayerManager::getCurrentUser()->isRegisteredUser())
|
||||
{
|
||||
// We need to keep a copy of the addon id, since dismiss() will
|
||||
// delete this object (and the copy of the addon).
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "states_screens/dialogs/change_password_dialog.hpp"
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@ -110,8 +111,7 @@ void ChangePasswordDialog::changePassword(const stringw ¤t_password,
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
ChangePasswordRequest * request = new ChangePasswordRequest();
|
||||
CurrentUser::setUserDetails(request, "change_password");
|
||||
request->addParameter("userid", CurrentUser::get()->getID());
|
||||
PlayerManager::setUserDetails(request, "change_password");
|
||||
request->addParameter("current", current_password);
|
||||
// The server code expects two passwords (and verifies again that they
|
||||
// are identical), so send the passwod twice.
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <IGUIEnvironment.h>
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/online_profile_achievements.hpp"
|
||||
@ -138,12 +139,12 @@ void NotificationDialog::onUpdate(float dt)
|
||||
{
|
||||
if(type == T_Friends)
|
||||
{
|
||||
ProfileManager::get()->setVisiting(CurrentUser::get()->getID());
|
||||
ProfileManager::get()->setVisiting(PlayerManager::getCurrentUser()->getID());
|
||||
StateManager::get()->pushScreen(OnlineProfileFriends::getInstance());
|
||||
}
|
||||
else if (type == T_Achievements)
|
||||
{
|
||||
ProfileManager::get()->setVisiting(CurrentUser::get()->getID());
|
||||
ProfileManager::get()->setVisiting(PlayerManager::getCurrentUser()->getID());
|
||||
StateManager::get()->pushScreen(OnlineProfileAchievements::getInstance());
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "states_screens/dialogs/recovery_dialog.hpp"
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@ -127,7 +128,7 @@ void RecoveryDialog::processInput()
|
||||
m_options_widget->setDeactivated();
|
||||
m_recovery_request = new XMLRequest();
|
||||
// This function also works when the current user is not logged in
|
||||
CurrentUser::setUserDetails(m_recovery_request, "recovery");
|
||||
PlayerManager::setUserDetails(m_recovery_request, "recovery");
|
||||
m_recovery_request->addParameter("username", username);
|
||||
m_recovery_request->addParameter("email", email );
|
||||
m_recovery_request->queue();
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "states_screens/dialogs/user_info_dialog.hpp"
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/dialog_queue.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
@ -62,7 +63,7 @@ void UserInfoDialog::beforeAddingWidgets()
|
||||
// Avoid a crash in case that an invalid m_showing_id is given
|
||||
// (which can only happen if there's a problem on the server).
|
||||
if (!m_profile)
|
||||
m_profile = CurrentUser::get()->getProfile();
|
||||
m_profile = PlayerManager::getCurrentUser()->getProfile();
|
||||
m_self_destroy = false;
|
||||
m_enter_profile = false;
|
||||
m_processing = false;
|
||||
@ -147,7 +148,7 @@ void UserInfoDialog::sendFriendRequest()
|
||||
core::stringw info_text("");
|
||||
if (isSuccess())
|
||||
{
|
||||
CurrentUser::get()->getProfile()->addFriend(id);
|
||||
PlayerManager::getCurrentUser()->getProfile()->addFriend(id);
|
||||
OnlineProfile::RelationInfo *info =
|
||||
new OnlineProfile::RelationInfo(_("Today"), false,
|
||||
true, false);
|
||||
@ -169,7 +170,7 @@ void UserInfoDialog::sendFriendRequest()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
FriendRequest *request = new FriendRequest();
|
||||
CurrentUser::setUserDetails(request, "friend-request");
|
||||
PlayerManager::setUserDetails(request, "friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
|
||||
@ -220,7 +221,7 @@ void UserInfoDialog::acceptFriendRequest()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
AcceptFriendRequest *request = new AcceptFriendRequest();
|
||||
CurrentUser::setUserDetails(request, "accept-friend-request");
|
||||
PlayerManager::setUserDetails(request, "accept-friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
m_processing = true;
|
||||
@ -248,7 +249,7 @@ void UserInfoDialog::declineFriendRequest()
|
||||
core::stringw info_text("");
|
||||
if (isSuccess())
|
||||
{
|
||||
CurrentUser::get()->getProfile()->removeFriend(id);
|
||||
PlayerManager::getCurrentUser()->getProfile()->removeFriend(id);
|
||||
ProfileManager::get()->moveToCache(id);
|
||||
ProfileManager::get()->getProfileByID(id)
|
||||
->deleteRelationalInfo();
|
||||
@ -266,7 +267,7 @@ void UserInfoDialog::declineFriendRequest()
|
||||
}; // DeclineFriendRequest
|
||||
// ----------------------------------------------------------------
|
||||
DeclineFriendRequest *request = new DeclineFriendRequest();
|
||||
CurrentUser::setUserDetails(request, "decline-friend-request");
|
||||
PlayerManager::setUserDetails(request, "decline-friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
|
||||
@ -289,7 +290,7 @@ void UserInfoDialog::removeExistingFriend()
|
||||
core::stringw info_text("");
|
||||
if (isSuccess())
|
||||
{
|
||||
CurrentUser::get()->getProfile()->removeFriend(m_id);
|
||||
PlayerManager::getCurrentUser()->getProfile()->removeFriend(m_id);
|
||||
ProfileManager *pm = ProfileManager::get();
|
||||
pm->moveToCache(m_id);
|
||||
pm->getProfileByID(m_id)->deleteRelationalInfo();
|
||||
@ -313,7 +314,7 @@ void UserInfoDialog::removeExistingFriend()
|
||||
|
||||
int friend_id = m_profile->getID();
|
||||
RemoveFriendRequest * request = new RemoveFriendRequest(friend_id);
|
||||
CurrentUser::setUserDetails(request, "remove-friend");
|
||||
PlayerManager::setUserDetails(request, "remove-friend");
|
||||
request->addParameter("friendid", friend_id);
|
||||
request->queue();
|
||||
} // removeExistingFriend
|
||||
@ -337,7 +338,7 @@ void UserInfoDialog::removePendingFriend()
|
||||
core::stringw info_text("");
|
||||
if (isSuccess())
|
||||
{
|
||||
CurrentUser::get()->getProfile()->removeFriend(id);
|
||||
PlayerManager::getCurrentUser()->getProfile()->removeFriend(id);
|
||||
ProfileManager *pm = ProfileManager::get();
|
||||
pm->moveToCache(id);
|
||||
pm->getProfileByID(id)->deleteRelationalInfo();
|
||||
@ -357,7 +358,7 @@ void UserInfoDialog::removePendingFriend()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
CancelFriendRequest * request = new CancelFriendRequest();
|
||||
CurrentUser::setUserDetails(request, "cancel-friend-request");
|
||||
PlayerManager::setUserDetails(request, "cancel-friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
} // removePendingFriend
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "states_screens/dialogs/vote_dialog.hpp"
|
||||
|
||||
#include "addons/addons_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
@ -60,7 +61,7 @@ VoteDialog::VoteDialog(const std::string & addon_id)
|
||||
|
||||
|
||||
m_fetch_vote_request = new XMLRequest();
|
||||
CurrentUser::setUserDetails(m_fetch_vote_request, "get-addon-vote");
|
||||
PlayerManager::setUserDetails(m_fetch_vote_request, "get-addon-vote");
|
||||
m_fetch_vote_request->addParameter("addonid", addon_id.substr(6));
|
||||
m_fetch_vote_request->queue();
|
||||
|
||||
@ -119,7 +120,7 @@ void VoteDialog::sendVote()
|
||||
|
||||
|
||||
m_perform_vote_request = new SetAddonVoteRequest();
|
||||
CurrentUser::setUserDetails(m_perform_vote_request, "set-addon-vote");
|
||||
PlayerManager::setUserDetails(m_perform_vote_request, "set-addon-vote");
|
||||
m_perform_vote_request->addParameter("addonid", m_addon_id.substr(6));
|
||||
m_perform_vote_request->addParameter("rating", m_rating_widget->getRating());
|
||||
m_perform_vote_request->queue();
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "states_screens/login_screen.hpp"
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/widgets/check_box_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||
@ -98,7 +99,7 @@ void LoginScreen::login()
|
||||
m_options_widget->setDeactivated();
|
||||
info_widget->setDefaultColor();
|
||||
bool remember = getWidget<CheckBoxWidget>("remember")->getState();
|
||||
Online::CurrentUser::get()->requestSignIn(username,password,
|
||||
PlayerManager::getCurrentUser()->requestSignIn(username, password,
|
||||
remember );
|
||||
}
|
||||
} // login
|
||||
|
@ -146,13 +146,13 @@ void MainMenuScreen::init()
|
||||
void MainMenuScreen::onUpdate(float delta)
|
||||
|
||||
{
|
||||
if(CurrentUser::get()->getUserState()==CurrentUser::US_GUEST ||
|
||||
CurrentUser::get()->getUserState()==CurrentUser::US_SIGNED_IN)
|
||||
if(PlayerManager::getCurrentUser()->getUserState() == CurrentUser::US_GUEST ||
|
||||
PlayerManager::getCurrentUser()->getUserState() == CurrentUser::US_SIGNED_IN)
|
||||
{
|
||||
m_online->setActivated();
|
||||
m_online->setLabel( _("Online"));
|
||||
}
|
||||
else if(CurrentUser::get()->getUserState()==CurrentUser::US_SIGNED_OUT)
|
||||
else if (PlayerManager::getCurrentUser()->getUserState() == CurrentUser::US_SIGNED_OUT)
|
||||
{
|
||||
m_online->setActivated();
|
||||
m_online->setLabel( _("Login" ));
|
||||
@ -160,8 +160,8 @@ void MainMenuScreen::onUpdate(float delta)
|
||||
else // now must be either logging in or logging out
|
||||
m_online->setDeactivated();
|
||||
|
||||
m_online->setLabel(CurrentUser::get()->getID() ? _("Online")
|
||||
: _("Login" ) );
|
||||
m_online->setLabel(PlayerManager::getCurrentUser()->getID() ? _("Online")
|
||||
: _("Login" ) );
|
||||
IconButtonWidget* addons_icon = getWidget<IconButtonWidget>("addons");
|
||||
if (addons_icon != NULL)
|
||||
{
|
||||
@ -405,7 +405,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
"\"Allow STK to connect to the Internet\"."));
|
||||
return;
|
||||
}
|
||||
if(CurrentUser::get()->getID())
|
||||
if (PlayerManager::getCurrentUser()->getID())
|
||||
StateManager::get()->pushScreen(OnlineScreen::getInstance());
|
||||
else
|
||||
StateManager::get()->pushScreen(LoginScreen::getInstance());
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "items/item_manager.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
@ -67,7 +68,7 @@ void NetworkKartSelectionScreen::init()
|
||||
|
||||
for (unsigned int i = 0; i < players.size(); i++)
|
||||
{
|
||||
if (players[i]->user_profile == Online::CurrentUser::get()->getProfile())
|
||||
if (players[i]->user_profile == PlayerManager::getCurrentUser()->getProfile())
|
||||
{
|
||||
m_id_mapping.insert(m_id_mapping.begin(),players[i]->race_id); //!< first kart widget always me
|
||||
Log::info("NKSS", "Insert %d at pos 0", players[i]->race_id);
|
||||
|
@ -19,10 +19,8 @@
|
||||
|
||||
#include "states_screens/online_screen.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
@ -45,9 +43,13 @@
|
||||
#include "states_screens/create_server_screen.hpp"
|
||||
#include "states_screens/online_profile_overview.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
using namespace GUIEngine;
|
||||
using namespace Online;
|
||||
|
||||
|
||||
DEFINE_SCREEN_SINGLETON( OnlineScreen );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -97,7 +99,7 @@ void OnlineScreen::loadedFromFile()
|
||||
bool OnlineScreen::hasStateChanged()
|
||||
{
|
||||
CurrentUser::UserState previous_state = m_recorded_state;
|
||||
m_recorded_state = CurrentUser::get()->getUserState();
|
||||
m_recorded_state = PlayerManager::getCurrentUser()->getUserState();
|
||||
if (previous_state != m_recorded_state)
|
||||
return true;
|
||||
return false;
|
||||
@ -135,7 +137,8 @@ void OnlineScreen::init()
|
||||
Screen::init();
|
||||
setInitialFocus();
|
||||
DemoWorld::resetIdleTime();
|
||||
core::stringw m = _("Signed in as: %s.",CurrentUser::get()->getUserName());
|
||||
core::stringw m = _("Signed in as: %s.",
|
||||
PlayerManager::getCurrentUser()->getUserName());
|
||||
m_online_status_widget->setText(m, false);
|
||||
} // init
|
||||
|
||||
@ -186,7 +189,7 @@ void OnlineScreen::doQuickPlay()
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentUser::setUserDetails(request2, "request-connection");
|
||||
PlayerManager::setUserDetails(request2, "request-connection");
|
||||
request2->setServerURL("address-management.php");
|
||||
request2->addParameter("server_id", server->getServerId());
|
||||
|
||||
@ -223,12 +226,12 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
|
||||
if (selection == m_sign_out_widget->m_properties[PROP_ID])
|
||||
{
|
||||
CurrentUser::get()->requestSignOut();
|
||||
PlayerManager::getCurrentUser()->requestSignOut();
|
||||
StateManager::get()->popMenu();
|
||||
}
|
||||
else if (selection == m_profile_widget->m_properties[PROP_ID])
|
||||
{
|
||||
ProfileManager::get()->setVisiting(CurrentUser::get()->getID());
|
||||
ProfileManager::get()->setVisiting(PlayerManager::getCurrentUser()->getID());
|
||||
StateManager::get()->pushScreen(OnlineProfileOverview::getInstance());
|
||||
}
|
||||
else if (selection == m_find_server_widget->m_properties[PROP_ID])
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "states_screens/online_user_search.hpp"
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "online/messages.hpp"
|
||||
@ -192,7 +193,7 @@ void OnlineUserSearch::search()
|
||||
if (m_search_string != "" && m_last_search_string != m_search_string)
|
||||
{
|
||||
m_search_request = new XMLRequest();
|
||||
CurrentUser::setUserDetails(m_search_request, "user-search");
|
||||
PlayerManager::setUserDetails(m_search_request, "user-search");
|
||||
m_search_request->addParameter("search-string", m_search_string);
|
||||
m_search_request->queue();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user