Moved Server and ServersManager into network directory.

This commit is contained in:
hiker 2015-11-12 17:52:04 +11:00
parent 6716dfce97
commit af9018ea64
17 changed files with 48 additions and 60 deletions

View File

@ -1,5 +1,5 @@
# Modify this file to change the last-modified date when you add/remove a file. # Modify this file to change the last-modified date when you add/remove a file.
# This will then trigger a new cmake run automatically. # This will then trigger a new cmake run automatically.
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp") file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*") file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")

View File

@ -175,10 +175,10 @@
#include "modes/demo_world.hpp" #include "modes/demo_world.hpp"
#include "modes/profile_world.hpp" #include "modes/profile_world.hpp"
#include "network/network_config.hpp" #include "network/network_config.hpp"
#include "network/servers_manager.hpp"
#include "network/stk_host.hpp" #include "network/stk_host.hpp"
#include "online/profile_manager.hpp" #include "online/profile_manager.hpp"
#include "online/request_manager.hpp" #include "online/request_manager.hpp"
#include "online/servers_manager.hpp"
#include "race/grand_prix_manager.hpp" #include "race/grand_prix_manager.hpp"
#include "race/highscore_manager.hpp" #include "race/highscore_manager.hpp"
#include "race/history.hpp" #include "race/history.hpp"
@ -1616,7 +1616,7 @@ static void cleanSuperTuxKart()
// FIXME: do we need to wait for threads there, can they be // FIXME: do we need to wait for threads there, can they be
// moved further up? // moved further up?
Online::ServersManager::deallocate(); ServersManager::deallocate();
if(NetworkConfig::get()->isNetworking()) if(NetworkConfig::get()->isNetworking())
STKHost::destroy(); STKHost::destroy();

View File

@ -28,9 +28,9 @@
#include "network/protocols/ping_protocol.hpp" #include "network/protocols/ping_protocol.hpp"
#include "network/protocols/client_lobby_room_protocol.hpp" #include "network/protocols/client_lobby_room_protocol.hpp"
#include "network/protocol_manager.hpp" #include "network/protocol_manager.hpp"
#include "network/servers_manager.hpp"
#include "network/stk_host.hpp" #include "network/stk_host.hpp"
#include "network/stk_peer.hpp" #include "network/stk_peer.hpp"
#include "online/servers_manager.hpp"
#include "utils/time.hpp" #include "utils/time.hpp"
#include "utils/log.hpp" #include "utils/log.hpp"
@ -63,8 +63,7 @@ ConnectToServer::ConnectToServer(uint32_t server_id, uint32_t host_id)
m_server_id = server_id; m_server_id = server_id;
m_host_id = host_id; m_host_id = host_id;
m_quick_join = false; m_quick_join = false;
const Online::Server *server = const Server *server = ServersManager::get()->getServerByID(server_id);
Online::ServersManager::get()->getServerByID(server_id);
m_server_address.copy(server->getAddress()); m_server_address.copy(server->getAddress());
} // ConnectToServer(server, host) } // ConnectToServer(server, host)

View File

@ -23,7 +23,7 @@
#include "network/network.hpp" #include "network/network.hpp"
#include "network/network_config.hpp" #include "network/network_config.hpp"
#include "network/protocol_manager.hpp" #include "network/protocol_manager.hpp"
#include "online/servers_manager.hpp" #include "network/servers_manager.hpp"
using namespace Online; using namespace Online;
@ -78,7 +78,7 @@ void RequestConnection::asynchronousUpdate()
Network *broadcast = new Network(1, 1, 0, 0); Network *broadcast = new Network(1, 1, 0, 0);
NetworkString s(std::string("connection-request")); NetworkString s(std::string("connection-request"));
const Online::Server *server = const Server *server =
ServersManager::get()->getServerByID(m_server_id); ServersManager::get()->getServerByID(m_server_id);
broadcast->sendRawPacket(s.getBytes(), s.size(), broadcast->sendRawPacket(s.getBytes(), s.size(),
server->getAddress()); server->getAddress());

View File

@ -14,18 +14,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/**
\page online Online
*/
#include "online/server.hpp" #include "network/server.hpp"
#include "io/xml_node.hpp" #include "io/xml_node.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"
namespace Online
{
Server::SortOrder Server::m_sort_order = Server::SO_NAME; Server::SortOrder Server::m_sort_order = Server::SO_NAME;
/** Constructor based on XML data received from the stk server. /** Constructor based on XML data received from the stk server.
@ -102,4 +97,3 @@ bool Server::filterByWords(const core::stringw words) const
return false; return false;
} // filterByWords } // filterByWords
} // namespace Online

View File

@ -33,8 +33,6 @@
class XMLNode; class XMLNode;
namespace Online
{
/** /**
* \ingroup online * \ingroup online
*/ */
@ -137,5 +135,4 @@ public:
} // operator< } // operator<
}; // Server }; // Server
} // namespace Online
#endif // HEADER_SERVER_HPP #endif // HEADER_SERVER_HPP

View File

@ -16,11 +16,13 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "online/servers_manager.hpp" #include "network/servers_manager.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "network/network.hpp" #include "network/network.hpp"
#include "network/network_config.hpp" #include "network/network_config.hpp"
#include "network/network_string.hpp" #include "network/network_string.hpp"
#include "online/xml_request.hpp"
#include "utils/translation.hpp" #include "utils/translation.hpp"
#include "utils/time.hpp" #include "utils/time.hpp"
@ -30,8 +32,6 @@
#define SERVER_REFRESH_INTERVAL 5.0f #define SERVER_REFRESH_INTERVAL 5.0f
namespace Online
{
static ServersManager* manager_singleton(NULL); static ServersManager* manager_singleton(NULL);
ServersManager* ServersManager::get() ServersManager* ServersManager::get()
@ -91,16 +91,16 @@ void ServersManager::cleanUpServers()
/** Returns a WAN update-list-of-servers request. It queries the /** Returns a WAN update-list-of-servers request. It queries the
* STK server for an up-to-date list of servers. * STK server for an up-to-date list of servers.
*/ */
XMLRequest* ServersManager::getWANRefreshRequest() const Online::XMLRequest* ServersManager::getWANRefreshRequest() const
{ {
// ======================================================================== // ========================================================================
/** A small local class that triggers an update of the ServersManager /** A small local class that triggers an update of the ServersManager
* when the request is finished. */ * when the request is finished. */
class WANRefreshRequest : public XMLRequest class WANRefreshRequest : public Online::XMLRequest
{ {
public: public:
WANRefreshRequest() : XMLRequest(/*manage_memory*/false, WANRefreshRequest() : Online::XMLRequest(/*manage_memory*/false,
/*priority*/100) {} /*priority*/100) {}
// -------------------------------------------------------------------- // --------------------------------------------------------------------
virtual void callback() virtual void callback()
{ {
@ -110,8 +110,8 @@ XMLRequest* ServersManager::getWANRefreshRequest() const
}; // RefreshRequest }; // RefreshRequest
// ======================================================================== // ========================================================================
XMLRequest* request = new WANRefreshRequest(); Online::XMLRequest *request = new WANRefreshRequest();
request->setApiURL(API::SERVER_PATH, "get-all"); request->setApiURL(Online::API::SERVER_PATH, "get-all");
return request; return request;
} // getWANRefreshRequest } // getWANRefreshRequest
@ -121,14 +121,14 @@ XMLRequest* ServersManager::getWANRefreshRequest() const
* to find LAN servers, and waits for a certain amount of time fr * to find LAN servers, and waits for a certain amount of time fr
* answers. * answers.
*/ */
XMLRequest* ServersManager::getLANRefreshRequest() const Online::XMLRequest* ServersManager::getLANRefreshRequest() const
{ {
/** A simple class that uses LAN broadcasts to find local servers. /** A simple class that uses LAN broadcasts to find local servers.
* It is based on XML request, but actually does not use any of the * It is based on XML request, but actually does not use any of the
* XML/HTTP based infrastructure, but implements the same interface. * XML/HTTP based infrastructure, but implements the same interface.
* This way the already existing request thread can be used. * This way the already existing request thread can be used.
*/ */
class LANRefreshRequest : public XMLRequest class LANRefreshRequest : public Online::XMLRequest
{ {
public: public:
@ -207,7 +207,7 @@ XMLRequest* ServersManager::getLANRefreshRequest() const
/** Factory function to create either a LAN or a WAN update-of-server /** Factory function to create either a LAN or a WAN update-of-server
* requests. The current list of servers is also cleared/ * requests. The current list of servers is also cleared/
*/ */
XMLRequest* ServersManager::getRefreshRequest(bool request_now) Online::XMLRequest* ServersManager::getRefreshRequest(bool request_now)
{ {
if (StkTime::getRealTime() - m_last_load_time.getAtomic() if (StkTime::getRealTime() - m_last_load_time.getAtomic()
< SERVER_REFRESH_INTERVAL) < SERVER_REFRESH_INTERVAL)
@ -226,11 +226,12 @@ XMLRequest* ServersManager::getRefreshRequest(bool request_now)
} }
cleanUpServers(); cleanUpServers();
XMLRequest *request = NetworkConfig::get()->isWAN() ? getWANRefreshRequest() Online::XMLRequest *request =
: getLANRefreshRequest(); NetworkConfig::get()->isWAN() ? getWANRefreshRequest()
: getLANRefreshRequest();
if (request_now) if (request_now)
RequestManager::get()->addRequest(request); Online::RequestManager::get()->addRequest(request);
return request; return request;
} // getRefreshRequest } // getRefreshRequest
@ -342,4 +343,3 @@ void ServersManager::sort(bool sort_desc)
m_sorted_servers.getData().insertionSort(0, sort_desc); m_sorted_servers.getData().insertionSort(0, sort_desc);
} // sort } // sort
} // namespace Online

View File

@ -20,14 +20,13 @@
#define HEADER_SERVERS_MANAGER_HPP #define HEADER_SERVERS_MANAGER_HPP
#include "online/request_manager.hpp" #include "online/request_manager.hpp"
#include "online/server.hpp" #include "network/server.hpp"
#include "online/xml_request.hpp"
#include "utils/ptr_vector.hpp" #include "utils/ptr_vector.hpp"
#include "utils/synchronised.hpp" #include "utils/synchronised.hpp"
#include "utils/types.hpp" #include "utils/types.hpp"
namespace Online namespace Online { class XMLRequest; }
{
/** /**
* \brief * \brief
* \ingroup online * \ingroup online
@ -50,15 +49,15 @@ private:
Synchronised<float> m_last_load_time; Synchronised<float> m_last_load_time;
void refresh(bool success, const XMLNode * input); void refresh(bool success, const XMLNode * input);
void cleanUpServers(); void cleanUpServers();
XMLRequest * getWANRefreshRequest() const; Online::XMLRequest * getWANRefreshRequest() const;
XMLRequest * getLANRefreshRequest() const; Online::XMLRequest * getLANRefreshRequest() const;
public: public:
// Singleton // Singleton
static ServersManager* get(); static ServersManager* get();
static void deallocate(); static void deallocate();
XMLRequest * getRefreshRequest(bool request_now = true); Online::XMLRequest * getRefreshRequest(bool request_now = true);
void setJoinedServer(uint32_t server_id); void setJoinedServer(uint32_t server_id);
void unsetJoinedServer(); void unsetJoinedServer();
void addServer(Server * server); void addServer(Server * server);
@ -72,5 +71,4 @@ public:
const Server * getQuickPlay() const; const Server * getQuickPlay() const;
}; // class ServersManager }; // class ServersManager
} // namespace Online
#endif // HEADER_SERVERS_MANAGER_HPP #endif // HEADER_SERVERS_MANAGER_HPP

View File

@ -28,8 +28,8 @@
#include "network/protocols/connect_to_server.hpp" #include "network/protocols/connect_to_server.hpp"
#include "network/protocols/server_lobby_room_protocol.hpp" #include "network/protocols/server_lobby_room_protocol.hpp"
#include "network/protocol_manager.hpp" #include "network/protocol_manager.hpp"
#include "network/servers_manager.hpp"
#include "network/stk_peer.hpp" #include "network/stk_peer.hpp"
#include "online/servers_manager.hpp"
#include "utils/log.hpp" #include "utils/log.hpp"
#include "utils/time.hpp" #include "utils/time.hpp"
@ -54,8 +54,7 @@ void STKHost::create()
m_stk_host = new STKHost(NetworkConfig::get()->getServerName()); m_stk_host = new STKHost(NetworkConfig::get()->getServerName());
else else
{ {
Online::Server *server = Server *server = ServersManager::get()->getJoinedServer();
Online::ServersManager::get()->getJoinedServer();
m_stk_host = new STKHost(server->getServerId(), 0); m_stk_host = new STKHost(server->getServerId(), 0);
} }
if(!m_stk_host->m_network) if(!m_stk_host->m_network)

View File

@ -23,7 +23,6 @@
#include "online/http_request.hpp" #include "online/http_request.hpp"
#include "online/online_profile.hpp" #include "online/online_profile.hpp"
#include "online/request_manager.hpp" #include "online/request_manager.hpp"
#include "online/server.hpp"
#include "online/xml_request.hpp" #include "online/xml_request.hpp"
#include "utils/synchronised.hpp" #include "utils/synchronised.hpp"
#include "utils/types.hpp" #include "utils/types.hpp"

View File

@ -24,8 +24,8 @@
#include "config/player_manager.hpp" #include "config/player_manager.hpp"
#include "modes/demo_world.hpp" #include "modes/demo_world.hpp"
#include "network/network_config.hpp" #include "network/network_config.hpp"
#include "network/servers_manager.hpp"
#include "network/stk_host.hpp" #include "network/stk_host.hpp"
#include "online/servers_manager.hpp"
#include "states_screens/online_screen.hpp" #include "states_screens/online_screen.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "states_screens/dialogs/message_dialog.hpp" #include "states_screens/dialogs/message_dialog.hpp"
@ -40,7 +40,6 @@
using namespace GUIEngine; using namespace GUIEngine;
using namespace Online;
DEFINE_SCREEN_SINGLETON( CreateServerScreen ); DEFINE_SCREEN_SINGLETON( CreateServerScreen );

View File

@ -21,8 +21,8 @@
#include "guiengine/engine.hpp" #include "guiengine/engine.hpp"
#include "network/protocol_manager.hpp" #include "network/protocol_manager.hpp"
#include "network/protocols/request_connection.hpp" #include "network/protocols/request_connection.hpp"
#include "network/servers_manager.hpp"
#include "network/stk_host.hpp" #include "network/stk_host.hpp"
#include "online/servers_manager.hpp"
#include "states_screens/dialogs/registration_dialog.hpp" #include "states_screens/dialogs/registration_dialog.hpp"
#include "states_screens/networking_lobby.hpp" #include "states_screens/networking_lobby.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
@ -89,7 +89,7 @@ void ServerInfoDialog::requestJoin()
{ {
// FIXME - without this next line, it appears that m_server_join is completely unused. // FIXME - without this next line, it appears that m_server_join is completely unused.
//m_server_join_request = Online::CurrentUser::get()->requestServerJoin(m_server_id); //m_server_join_request = Online::CurrentUser::get()->requestServerJoin(m_server_id);
Online::ServersManager::get()->setJoinedServer(m_server_id); ServersManager::get()->setJoinedServer(m_server_id);
STKHost::create(); STKHost::create();
ModalDialog::dismiss(); ModalDialog::dismiss();

View File

@ -23,12 +23,13 @@
#include "guiengine/widgets/icon_button_widget.hpp" #include "guiengine/widgets/icon_button_widget.hpp"
#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 "network/server.hpp"
#include "online/xml_request.hpp"
#include "utils/types.hpp" #include "utils/types.hpp"
#include <irrString.h> #include <irrString.h>
namespace Online { class XMLRequest; }
/** /**
* \brief Dialog that allows a user to sign in * \brief Dialog that allows a user to sign in
* \ingroup states_screens * \ingroup states_screens

View File

@ -29,14 +29,14 @@
#include "input/input_manager.hpp" #include "input/input_manager.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "main_loop.hpp" #include "main_loop.hpp"
#include "modes/demo_world.hpp"
#include "network/protocol_manager.hpp"
#include "network/protocols/client_lobby_room_protocol.hpp"
#include "network/servers_manager.hpp"
#include "states_screens/online_screen.hpp" #include "states_screens/online_screen.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "states_screens/dialogs/message_dialog.hpp" #include "states_screens/dialogs/message_dialog.hpp"
#include "network/protocol_manager.hpp"
#include "network/protocols/client_lobby_room_protocol.hpp"
#include "modes/demo_world.hpp"
#include "utils/translation.hpp" #include "utils/translation.hpp"
#include "online/servers_manager.hpp"
using namespace Online; using namespace Online;
using namespace GUIEngine; using namespace GUIEngine;

View File

@ -22,7 +22,8 @@
#include "guiengine/widgets/label_widget.hpp" #include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp" #include "guiengine/widgets/ribbon_widget.hpp"
#include "guiengine/widgets/icon_button_widget.hpp" #include "guiengine/widgets/icon_button_widget.hpp"
#include "online/server.hpp"
class Server;
namespace GUIEngine { class Widget; class ListWidget; } namespace GUIEngine { class Widget; class ListWidget; }
@ -36,7 +37,7 @@ class NetworkingLobby : public GUIEngine::Screen,
private: private:
friend class GUIEngine::ScreenSingleton<NetworkingLobby>; friend class GUIEngine::ScreenSingleton<NetworkingLobby>;
Online::Server * m_server; Server * m_server;
NetworkingLobby(); NetworkingLobby();

View File

@ -31,9 +31,9 @@
#include "network/protocol_manager.hpp" #include "network/protocol_manager.hpp"
#include "network/protocols/connect_to_server.hpp" #include "network/protocols/connect_to_server.hpp"
#include "network/protocols/request_connection.hpp" #include "network/protocols/request_connection.hpp"
#include "network/servers_manager.hpp"
#include "online/profile_manager.hpp" #include "online/profile_manager.hpp"
#include "online/request.hpp" #include "online/request.hpp"
#include "online/servers_manager.hpp"
#include "states_screens/create_server_screen.hpp" #include "states_screens/create_server_screen.hpp"
#include "states_screens/dialogs/message_dialog.hpp" #include "states_screens/dialogs/message_dialog.hpp"
#include "states_screens/networking_lobby.hpp" #include "states_screens/networking_lobby.hpp"

View File

@ -19,7 +19,8 @@
#include "audio/sfx_manager.hpp" #include "audio/sfx_manager.hpp"
#include "guiengine/modaldialog.hpp" #include "guiengine/modaldialog.hpp"
#include "online/servers_manager.hpp" #include "network/servers_manager.hpp"
#include "online/xml_request.hpp"
#include "states_screens/dialogs/message_dialog.hpp" #include "states_screens/dialogs/message_dialog.hpp"
#include "states_screens/dialogs/server_info_dialog.hpp" #include "states_screens/dialogs/server_info_dialog.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"