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.
# 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_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
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/profile_world.hpp"
#include "network/network_config.hpp"
#include "network/servers_manager.hpp"
#include "network/stk_host.hpp"
#include "online/profile_manager.hpp"
#include "online/request_manager.hpp"
#include "online/servers_manager.hpp"
#include "race/grand_prix_manager.hpp"
#include "race/highscore_manager.hpp"
#include "race/history.hpp"
@ -1616,7 +1616,7 @@ static void cleanSuperTuxKart()
// FIXME: do we need to wait for threads there, can they be
// moved further up?
Online::ServersManager::deallocate();
ServersManager::deallocate();
if(NetworkConfig::get()->isNetworking())
STKHost::destroy();

View File

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

View File

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

View File

@ -14,18 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// 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 "utils/constants.hpp"
#include "utils/string_utils.hpp"
namespace Online
{
Server::SortOrder Server::m_sort_order = Server::SO_NAME;
/** Constructor based on XML data received from the stk server.
@ -102,4 +97,3 @@ bool Server::filterByWords(const core::stringw words) const
return false;
} // filterByWords
} // namespace Online

View File

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

View File

@ -16,11 +16,13 @@
// along with this program; if not, write to the Free Software
// 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 "network/network.hpp"
#include "network/network_config.hpp"
#include "network/network_string.hpp"
#include "online/xml_request.hpp"
#include "utils/translation.hpp"
#include "utils/time.hpp"
@ -30,8 +32,6 @@
#define SERVER_REFRESH_INTERVAL 5.0f
namespace Online
{
static ServersManager* manager_singleton(NULL);
ServersManager* ServersManager::get()
@ -91,16 +91,16 @@ void ServersManager::cleanUpServers()
/** Returns a WAN update-list-of-servers request. It queries the
* 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
* when the request is finished. */
class WANRefreshRequest : public XMLRequest
class WANRefreshRequest : public Online::XMLRequest
{
public:
WANRefreshRequest() : XMLRequest(/*manage_memory*/false,
/*priority*/100) {}
WANRefreshRequest() : Online::XMLRequest(/*manage_memory*/false,
/*priority*/100) {}
// --------------------------------------------------------------------
virtual void callback()
{
@ -110,8 +110,8 @@ XMLRequest* ServersManager::getWANRefreshRequest() const
}; // RefreshRequest
// ========================================================================
XMLRequest* request = new WANRefreshRequest();
request->setApiURL(API::SERVER_PATH, "get-all");
Online::XMLRequest *request = new WANRefreshRequest();
request->setApiURL(Online::API::SERVER_PATH, "get-all");
return request;
} // getWANRefreshRequest
@ -121,14 +121,14 @@ XMLRequest* ServersManager::getWANRefreshRequest() const
* to find LAN servers, and waits for a certain amount of time fr
* answers.
*/
XMLRequest* ServersManager::getLANRefreshRequest() const
Online::XMLRequest* ServersManager::getLANRefreshRequest() const
{
/** 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
* XML/HTTP based infrastructure, but implements the same interface.
* This way the already existing request thread can be used.
*/
class LANRefreshRequest : public XMLRequest
class LANRefreshRequest : public Online::XMLRequest
{
public:
@ -207,7 +207,7 @@ XMLRequest* ServersManager::getLANRefreshRequest() const
/** Factory function to create either a LAN or a WAN update-of-server
* 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()
< SERVER_REFRESH_INTERVAL)
@ -226,11 +226,12 @@ XMLRequest* ServersManager::getRefreshRequest(bool request_now)
}
cleanUpServers();
XMLRequest *request = NetworkConfig::get()->isWAN() ? getWANRefreshRequest()
: getLANRefreshRequest();
Online::XMLRequest *request =
NetworkConfig::get()->isWAN() ? getWANRefreshRequest()
: getLANRefreshRequest();
if (request_now)
RequestManager::get()->addRequest(request);
Online::RequestManager::get()->addRequest(request);
return request;
} // getRefreshRequest
@ -342,4 +343,3 @@ void ServersManager::sort(bool sort_desc)
m_sorted_servers.getData().insertionSort(0, sort_desc);
} // sort
} // namespace Online

View File

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

View File

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

View File

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

View File

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

View File

@ -21,8 +21,8 @@
#include "guiengine/engine.hpp"
#include "network/protocol_manager.hpp"
#include "network/protocols/request_connection.hpp"
#include "network/servers_manager.hpp"
#include "network/stk_host.hpp"
#include "online/servers_manager.hpp"
#include "states_screens/dialogs/registration_dialog.hpp"
#include "states_screens/networking_lobby.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.
//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();
ModalDialog::dismiss();

View File

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

View File

@ -29,14 +29,14 @@
#include "input/input_manager.hpp"
#include "io/file_manager.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/state_manager.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 "online/servers_manager.hpp"
using namespace Online;
using namespace GUIEngine;

View File

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

View File

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

View File

@ -19,7 +19,8 @@
#include "audio/sfx_manager.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/server_info_dialog.hpp"
#include "states_screens/state_manager.hpp"