Added Server and ServersManager to the online namespace and edited everything that uses those.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13279 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
8ec5adeec0
commit
ae6bc57b95
@ -24,10 +24,11 @@
|
|||||||
#include "utils/constants.hpp"
|
#include "utils/constants.hpp"
|
||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
|
|
||||||
Server::SortOrder Server::m_sort_order=Server::SO_NAME; //FIXME change to some other default
|
namespace online{
|
||||||
|
Server::SortOrder Server::m_sort_order=Server::SO_NAME; //FIXME change to some other default
|
||||||
|
|
||||||
Server::Server(const XMLNode & xml)
|
Server::Server(const XMLNode & xml)
|
||||||
{
|
{
|
||||||
assert(xml.getName() == "server");
|
assert(xml.getName() == "server");
|
||||||
m_name = "";
|
m_name = "";
|
||||||
m_satisfaction_score = 0;
|
m_satisfaction_score = 0;
|
||||||
@ -43,16 +44,16 @@ Server::Server(const XMLNode & xml)
|
|||||||
xml.get("max_players", &m_max_players);
|
xml.get("max_players", &m_max_players);
|
||||||
xml.get("current_players", &m_current_players);
|
xml.get("current_players", &m_current_players);
|
||||||
|
|
||||||
}; // Server(const XML&)
|
}; // Server(const XML&)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* \brief Filter the add-on with a list of words.
|
* \brief Filter the add-on with a list of words.
|
||||||
* \param words A list of words separated by ' '.
|
* \param words A list of words separated by ' '.
|
||||||
* \return true if the add-on contains one of the words, otherwise false.
|
* \return true if the add-on contains one of the words, otherwise false.
|
||||||
*/
|
*/
|
||||||
bool Server::filterByWords(const core::stringw words) const
|
bool Server::filterByWords(const core::stringw words) const
|
||||||
{
|
{
|
||||||
if (words == NULL || words.empty())
|
if (words == NULL || words.empty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -69,4 +70,5 @@ bool Server::filterByWords(const core::stringw words) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} // filterByWords
|
} // filterByWords
|
||||||
|
} // namespace online
|
||||||
|
@ -31,12 +31,13 @@
|
|||||||
|
|
||||||
class XMLNode;
|
class XMLNode;
|
||||||
|
|
||||||
/**
|
namespace online{
|
||||||
|
/**
|
||||||
* \ingroup online
|
* \ingroup online
|
||||||
*/
|
*/
|
||||||
class Server
|
class Server
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Set the sort order used in the comparison function. */
|
/** Set the sort order used in the comparison function. */
|
||||||
enum SortOrder { SO_SCORE = 1, // Sorted on satisfaction score
|
enum SortOrder { SO_SCORE = 1, // Sorted on satisfaction score
|
||||||
@ -44,7 +45,7 @@ public:
|
|||||||
SO_PLAYERS = 4
|
SO_PLAYERS = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** The name to be displayed. */
|
/** The name to be displayed. */
|
||||||
irr::core::stringw m_name;
|
irr::core::stringw m_name;
|
||||||
std::string m_lower_case_name; //Used for comparison
|
std::string m_lower_case_name; //Used for comparison
|
||||||
@ -62,7 +63,7 @@ protected:
|
|||||||
|
|
||||||
Server() {};
|
Server() {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Initialises the object from an XML node. */
|
/** Initialises the object from an XML node. */
|
||||||
Server(const XMLNode & xml);
|
Server(const XMLNode & xml);
|
||||||
@ -128,7 +129,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
} // operator>
|
} // operator>
|
||||||
|
|
||||||
}; // Server
|
}; // Server
|
||||||
|
} // namespace online
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,30 +26,32 @@
|
|||||||
#include "config/user_config.hpp"
|
#include "config/user_config.hpp"
|
||||||
#include "utils/translation.hpp"
|
#include "utils/translation.hpp"
|
||||||
|
|
||||||
static ServersManager* user_singleton = NULL;
|
namespace online{
|
||||||
|
|
||||||
ServersManager* ServersManager::get()
|
static ServersManager* user_singleton = NULL;
|
||||||
{
|
|
||||||
|
ServersManager* ServersManager::get()
|
||||||
|
{
|
||||||
if (user_singleton == NULL)
|
if (user_singleton == NULL)
|
||||||
user_singleton = new ServersManager();
|
user_singleton = new ServersManager();
|
||||||
return user_singleton;
|
return user_singleton;
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
void ServersManager::deallocate()
|
void ServersManager::deallocate()
|
||||||
{
|
{
|
||||||
delete user_singleton;
|
delete user_singleton;
|
||||||
user_singleton = NULL;
|
user_singleton = NULL;
|
||||||
} // deallocate
|
} // deallocate
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
ServersManager::ServersManager(){
|
ServersManager::ServersManager(){
|
||||||
m_servers = new PtrVector<Server>;
|
m_servers = new PtrVector<Server>;
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
void ServersManager::refresh()
|
void ServersManager::refresh()
|
||||||
{
|
{
|
||||||
HTTPConnector * connector = new HTTPConnector((std::string)UserConfigParams::m_server_multiplayer + "client-user.php");
|
HTTPConnector * connector = new HTTPConnector((std::string)UserConfigParams::m_server_multiplayer + "client-user.php");
|
||||||
connector->setParameter("action",std::string("get_server_list"));
|
connector->setParameter("action",std::string("get_server_list"));
|
||||||
|
|
||||||
@ -68,12 +70,13 @@ void ServersManager::refresh()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//FIXME error message
|
//FIXME error message
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
Server * ServersManager::getQuickPlay()
|
Server * ServersManager::getQuickPlay()
|
||||||
{
|
{
|
||||||
if(m_servers->size() > 0)
|
if(m_servers->size() > 0)
|
||||||
return m_servers->get(0);
|
return m_servers->get(0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
} // namespace online
|
||||||
|
@ -23,14 +23,14 @@
|
|||||||
#include "online/server.hpp"
|
#include "online/server.hpp"
|
||||||
|
|
||||||
|
|
||||||
// ============================================================================
|
namespace online {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief
|
* \brief
|
||||||
* \ingroup online
|
* \ingroup online
|
||||||
*/
|
*/
|
||||||
class ServersManager
|
class ServersManager
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ServersManager();
|
ServersManager();
|
||||||
PtrVector<Server> * m_servers;
|
PtrVector<Server> * m_servers;
|
||||||
@ -51,7 +51,11 @@ class ServersManager
|
|||||||
Server * getJoinedServer(){ return m_joined_server;};
|
Server * getJoinedServer(){ return m_joined_server;};
|
||||||
//Returns the best server to join
|
//Returns the best server to join
|
||||||
Server * getQuickPlay();
|
Server * getQuickPlay();
|
||||||
}; // class ServersManager
|
}; // class ServersManager
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace online
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
using namespace GUIEngine;
|
using namespace GUIEngine;
|
||||||
using namespace irr;
|
using namespace irr;
|
||||||
using namespace irr::gui;
|
using namespace irr::gui;
|
||||||
|
using namespace online;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include "guiengine/widgets/ribbon_widget.hpp"
|
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||||
#include "guiengine/widgets/label_widget.hpp"
|
#include "guiengine/widgets/label_widget.hpp"
|
||||||
#include "online/server.hpp"
|
#include "online/server.hpp"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Dialog that allows a user to sign in
|
* \brief Dialog that allows a user to sign in
|
||||||
* \ingroup states_screens
|
* \ingroup states_screens
|
||||||
@ -38,7 +40,7 @@ private:
|
|||||||
bool m_self_destroy;
|
bool m_self_destroy;
|
||||||
bool m_enter_lobby;
|
bool m_enter_lobby;
|
||||||
|
|
||||||
Server * m_server;
|
online::Server * m_server;
|
||||||
|
|
||||||
GUIEngine::LabelWidget * m_name_widget;
|
GUIEngine::LabelWidget * m_name_widget;
|
||||||
GUIEngine::LabelWidget * m_info_widget;
|
GUIEngine::LabelWidget * m_info_widget;
|
||||||
@ -50,7 +52,7 @@ private:
|
|||||||
void requestJoin();
|
void requestJoin();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ServerInfoDialog(Server * server);
|
ServerInfoDialog(online::Server * server);
|
||||||
~ServerInfoDialog();
|
~ServerInfoDialog();
|
||||||
|
|
||||||
void onEnterPressedInternal();
|
void onEnterPressedInternal();
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "utils/translation.hpp"
|
#include "utils/translation.hpp"
|
||||||
#include "online/servers_manager.hpp"
|
#include "online/servers_manager.hpp"
|
||||||
|
|
||||||
|
using namespace online;
|
||||||
using namespace GUIEngine;
|
using namespace GUIEngine;
|
||||||
|
|
||||||
DEFINE_SCREEN_SINGLETON( NetworkingLobby );
|
DEFINE_SCREEN_SINGLETON( NetworkingLobby );
|
||||||
|
@ -36,7 +36,7 @@ class NetworkingLobby : public GUIEngine::Screen,
|
|||||||
private:
|
private:
|
||||||
friend class GUIEngine::ScreenSingleton<NetworkingLobby>;
|
friend class GUIEngine::ScreenSingleton<NetworkingLobby>;
|
||||||
|
|
||||||
Server * m_server;
|
online::Server * m_server;
|
||||||
|
|
||||||
NetworkingLobby();
|
NetworkingLobby();
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
|
|
||||||
using namespace GUIEngine;
|
using namespace GUIEngine;
|
||||||
|
using namespace online;
|
||||||
|
|
||||||
DEFINE_SCREEN_SINGLETON( OnlineScreen );
|
DEFINE_SCREEN_SINGLETON( OnlineScreen );
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
#include "online/servers_manager.hpp"
|
#include "online/servers_manager.hpp"
|
||||||
|
|
||||||
|
using namespace online;
|
||||||
|
|
||||||
DEFINE_SCREEN_SINGLETON( ServerSelection );
|
DEFINE_SCREEN_SINGLETON( ServerSelection );
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user