cleaning the includes to meet stk's standard
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13075 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -115,7 +115,7 @@ void ClientNetworkManager::packetReceived(char* data)
|
||||
printf("ClientNetworkManager::packetReceived()\n");
|
||||
puts(data);
|
||||
}
|
||||
void ClientNetworkManager::sendPacket(char* data)
|
||||
void ClientNetworkManager::sendPacket(const char* data)
|
||||
{
|
||||
if (m_peers.size() > 1)
|
||||
printf("Ambiguous send of data\n");
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef CLIENT_NETWORK_MANAGER_HPP
|
||||
#define CLIENT_NETWORK_MANAGER_HPP
|
||||
|
||||
#include "network_manager.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
|
||||
class ClientNetworkManager : public NetworkManager
|
||||
{
|
||||
@@ -35,7 +35,7 @@ class ClientNetworkManager : public NetworkManager
|
||||
bool connectToHost(std::string serverNickname);
|
||||
|
||||
virtual void packetReceived(char* data);
|
||||
virtual void sendPacket(char* data);
|
||||
virtual void sendPacket(const char* data);
|
||||
|
||||
STKPeer* getPeer();
|
||||
virtual bool isServer() { return false; }
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "event.hpp"
|
||||
#include "network/event.hpp"
|
||||
|
||||
#include "network_manager.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
@@ -71,3 +71,9 @@ Event::~Event()
|
||||
if (m_packet)
|
||||
enet_packet_destroy(m_packet);
|
||||
}
|
||||
|
||||
void Event::removeFront(int size)
|
||||
{
|
||||
data.erase(0, size);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef EVENT_HPP
|
||||
#define EVENT_HPP
|
||||
|
||||
#include "stk_peer.hpp"
|
||||
#include "network/stk_peer.hpp"
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
@@ -47,16 +47,19 @@ enum EVENT_TYPE
|
||||
class Event
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Constructor
|
||||
* \param event : The event that needs to be translated.
|
||||
/*! \brief Constructor
|
||||
* \param event : The event that needs to be translated.
|
||||
*/
|
||||
Event(ENetEvent* event);
|
||||
/*!
|
||||
* \brief Destructor
|
||||
* frees the memory of the ENetPacket.
|
||||
/*! \brief Destructor
|
||||
* frees the memory of the ENetPacket.
|
||||
*/
|
||||
~Event();
|
||||
|
||||
/*! \brief Remove bytes at the beginning of data.
|
||||
* \param size : The number of bytes to remove.
|
||||
*/
|
||||
void removeFront(int size);
|
||||
|
||||
EVENT_TYPE type; //!< Type of the event.
|
||||
std::string data; //!< Copy of the data passed by the event.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "http_functions.hpp"
|
||||
#include "network/http_functions.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "network_interface.hpp"
|
||||
#include "network/network_interface.hpp"
|
||||
|
||||
|
||||
NetworkInterface::NetworkInterface()
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
#ifndef NETWORK_INTERFACE_H
|
||||
#define NETWORK_INTERFACE_H
|
||||
|
||||
#include "singleton.hpp"
|
||||
#include "types.hpp"
|
||||
#include "network_manager.hpp"
|
||||
#include "network/singleton.hpp"
|
||||
#include "network/types.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <pthread.h>
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "network_manager.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
|
||||
#include "protocols/hide_public_address.hpp"
|
||||
#include "protocols/show_public_address.hpp"
|
||||
#include "protocols/get_public_address.hpp"
|
||||
#include "network/protocols/hide_public_address.hpp"
|
||||
#include "network/protocols/show_public_address.hpp"
|
||||
#include "network/protocols/get_public_address.hpp"
|
||||
|
||||
#include "protocol_manager.hpp"
|
||||
#include "client_network_manager.hpp"
|
||||
#include "server_network_manager.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/client_network_manager.hpp"
|
||||
#include "network/server_network_manager.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
@@ -19,14 +19,15 @@
|
||||
#ifndef NETWORKMANAGER_HPP
|
||||
#define NETWORKMANAGER_HPP
|
||||
|
||||
#include "stk_peer.hpp"
|
||||
#include "stk_host.hpp"
|
||||
#include <vector>
|
||||
#include "network/stk_peer.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
|
||||
#include "protocol_manager.hpp"
|
||||
#include "singleton.hpp"
|
||||
#include "types.hpp"
|
||||
#include "event.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/singleton.hpp"
|
||||
#include "network/types.hpp"
|
||||
#include "network/event.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class NetworkManager : public Singleton<NetworkManager>
|
||||
{
|
||||
@@ -39,6 +40,7 @@ class NetworkManager : public Singleton<NetworkManager>
|
||||
virtual void setManualSocketsMode(bool manual);
|
||||
virtual void notifyEvent(Event* event);
|
||||
virtual void packetReceived(char* data) = 0;
|
||||
virtual void sendPacket(const char* data) = 0;
|
||||
|
||||
// raw data management
|
||||
void setLogin(std::string username, std::string password);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "protocol.hpp"
|
||||
#include "network/protocol.hpp"
|
||||
|
||||
Protocol::Protocol(CallbackObject* callback_object, PROTOCOL_TYPE type)
|
||||
{
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#ifndef PROTOCOL_HPP
|
||||
#define PROTOCOL_HPP
|
||||
|
||||
#include "protocol_manager.hpp"
|
||||
#include "types.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/types.hpp"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "protocol_manager.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
|
||||
#include "protocol.hpp"
|
||||
#include "network/protocol.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
@@ -46,10 +47,11 @@ void ProtocolManager::notifyEvent(Event* event)
|
||||
pthread_mutex_unlock(&m_events_mutex);
|
||||
}
|
||||
|
||||
void ProtocolManager::sendMessage(std::string message)
|
||||
void ProtocolManager::sendMessage(Protocol* sender, std::string message)
|
||||
{
|
||||
std::string newMessage = " " + message; // add one byte
|
||||
newMessage[0] = (char)(0);
|
||||
std::string newMessage = " " + message; // add one byte to add protocol type
|
||||
newMessage[0] = (char)(sender->getProtocolType());
|
||||
NetworkManager::getInstance()->sendPacket(newMessage.c_str());
|
||||
}
|
||||
|
||||
int ProtocolManager::requestStart(Protocol* protocol)
|
||||
@@ -184,6 +186,7 @@ void ProtocolManager::update()
|
||||
PROTOCOL_TYPE searchedProtocol = PROTOCOL_NONE;
|
||||
if (event->data.size() > 0)
|
||||
searchedProtocol = (PROTOCOL_TYPE)(event->data[0]);
|
||||
event->removeFront(1); // remove the first byte which indicates the protocol
|
||||
for (unsigned int i = 0; i < m_protocols.size() ; i++)
|
||||
{
|
||||
if (m_protocols[i].protocol->getProtocolType() == searchedProtocol || event->type != EVENT_TYPE_MESSAGE) // pass data to protocols even when paused
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#ifndef PROTOCOL_MANAGER_HPP
|
||||
#define PROTOCOL_MANAGER_HPP
|
||||
|
||||
#include "singleton.hpp"
|
||||
#include "event.hpp"
|
||||
#include "network/singleton.hpp"
|
||||
#include "network/event.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
@@ -104,7 +104,7 @@ class ProtocolManager : public Singleton<ProtocolManager>
|
||||
/*!
|
||||
* \brief WILL BE COMMENTED LATER
|
||||
*/
|
||||
virtual void sendMessage(std::string message);
|
||||
virtual void sendMessage(Protocol* sender, std::string message);
|
||||
|
||||
/*!
|
||||
* \brief Asks the manager to start a protocol.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "lobby_room_protocol.hpp"
|
||||
#include "network/protocols/lobby_room_protocol.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "show_public_address.hpp"
|
||||
#include "network/protocols/show_public_address.hpp"
|
||||
|
||||
#include "../http_functions.hpp"
|
||||
#include "network/http_functions.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
@@ -16,13 +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 "server_network_manager.hpp"
|
||||
#include "network/server_network_manager.hpp"
|
||||
|
||||
#include "protocols/get_public_address.hpp"
|
||||
#include "protocols/hide_public_address.hpp"
|
||||
#include "protocols/show_public_address.hpp"
|
||||
#include "protocols/get_peer_address.hpp"
|
||||
#include "protocols/connect_to_server.hpp"
|
||||
#include "network/protocols/get_public_address.hpp"
|
||||
#include "network/protocols/hide_public_address.hpp"
|
||||
#include "network/protocols/show_public_address.hpp"
|
||||
#include "network/protocols/get_peer_address.hpp"
|
||||
#include "network/protocols/connect_to_server.hpp"
|
||||
|
||||
#include <enet/enet.h>
|
||||
#include <stdio.h>
|
||||
@@ -117,7 +117,7 @@ void ServerNetworkManager::packetReceived(char* data)
|
||||
puts(data);
|
||||
sendPacket(data);
|
||||
}
|
||||
void ServerNetworkManager::sendPacket(char* data)
|
||||
void ServerNetworkManager::sendPacket(const char* data)
|
||||
{
|
||||
m_localhost->broadcastPacket(data);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef SERVER_NETWORK_MANAGER_HPP
|
||||
#define SERVER_NETWORK_MANAGER_HPP
|
||||
|
||||
#include "network_manager.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
|
||||
|
||||
class ServerNetworkManager : public NetworkManager
|
||||
@@ -37,7 +37,7 @@ class ServerNetworkManager : public NetworkManager
|
||||
bool connectToPeer(std::string peer_username);
|
||||
|
||||
virtual void packetReceived(char* data);
|
||||
virtual void sendPacket(char* data);
|
||||
virtual void sendPacket(const char* data);
|
||||
|
||||
virtual bool isServer() { return false; }
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "stk_host.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
|
||||
#include "network_manager.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -179,7 +179,7 @@ uint8_t* STKHost::receiveRawPacket(TransportAddress sender)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void STKHost::broadcastPacket(char* data)
|
||||
void STKHost::broadcastPacket(const char* data)
|
||||
{
|
||||
ENetPacket* packet = enet_packet_create(data, strlen(data)+1,
|
||||
ENET_PACKET_FLAG_RELIABLE);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#define STK_HOST_HPP
|
||||
|
||||
#include <enet/enet.h>
|
||||
#include "types.hpp"
|
||||
#include "network/types.hpp"
|
||||
|
||||
/*! \class STKHost
|
||||
* \brief Represents the local host.
|
||||
@@ -122,7 +122,7 @@ class STKHost
|
||||
/*! \brief Broadcasts a packet to all peers.
|
||||
* \param data : Data to send.
|
||||
*/
|
||||
void broadcastPacket(char* data);
|
||||
void broadcastPacket(const char* data);
|
||||
|
||||
/*! \brief Tells if a peer is known.
|
||||
* \return True if the peer is known, false elseway.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "stk_peer.hpp"
|
||||
#include "network/stk_peer.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -48,7 +48,7 @@ bool STKPeer::connectToHost(STKHost* localhost, TransportAddress host, uint32_t
|
||||
return true;
|
||||
}
|
||||
|
||||
void STKPeer::sendPacket(char* data)
|
||||
void STKPeer::sendPacket(const char* data)
|
||||
{
|
||||
//printf("sending packet to %i.%i.%i.%i:%i", (m_peer->address.host>>24)&0xff,(m_peer->address.host>>16)&0xff,(m_peer->address.host>>8)&0xff,(m_peer->address.host>>0)&0xff,m_peer->address.port);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef STK_PEER_HPP
|
||||
#define STK_PEER_HPP
|
||||
|
||||
#include "stk_host.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include <enet/enet.h>
|
||||
|
||||
class STKPeer
|
||||
@@ -29,7 +29,7 @@ class STKPeer
|
||||
STKPeer();
|
||||
virtual ~STKPeer();
|
||||
|
||||
virtual void sendPacket(char* data);
|
||||
virtual void sendPacket(const char* data);
|
||||
|
||||
static bool connectToHost(STKHost* localhost, TransportAddress host, uint32_t channel_count, uint32_t data);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "time.hpp"
|
||||
#include "network/time.hpp"
|
||||
|
||||
namespace Time
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user