bored of writing commit messages >.<
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13161 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
6199524440
commit
8ca4b62038
@ -55,6 +55,12 @@ void* waitInput(void* data)
|
|||||||
{
|
{
|
||||||
ProtocolManager::getInstance()->requestStart(new ConnectToServer(n));
|
ProtocolManager::getInstance()->requestStart(new ConnectToServer(n));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NetworkString msg("\0\0");
|
||||||
|
msg += str;
|
||||||
|
NetworkManager::getInstance()->getPeers()[0]->sendPacket(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -244,8 +244,7 @@ void ProtocolManager::update()
|
|||||||
if (event->type == EVENT_TYPE_MESSAGE)
|
if (event->type == EVENT_TYPE_MESSAGE)
|
||||||
{
|
{
|
||||||
if (event->data.size() > 0)
|
if (event->data.size() > 0)
|
||||||
searchedProtocol = (PROTOCOL_TYPE)(event->data.getUInt8(0));
|
searchedProtocol = (PROTOCOL_TYPE)(event->data.getAndRemoveUInt8());
|
||||||
event->removeFront(1); // remove the first byte which indicates the protocol
|
|
||||||
}
|
}
|
||||||
if (event->type == EVENT_TYPE_CONNECTED)
|
if (event->type == EVENT_TYPE_CONNECTED)
|
||||||
{
|
{
|
||||||
@ -256,6 +255,10 @@ void ProtocolManager::update()
|
|||||||
if (m_protocols[i].protocol->getProtocolType() == searchedProtocol || event->type == EVENT_TYPE_DISCONNECTED) // pass data to protocols even when paused
|
if (m_protocols[i].protocol->getProtocolType() == searchedProtocol || event->type == EVENT_TYPE_DISCONNECTED) // pass data to protocols even when paused
|
||||||
m_protocols[i].protocol->notifyEvent(event);
|
m_protocols[i].protocol->notifyEvent(event);
|
||||||
}
|
}
|
||||||
|
if (searchedProtocol == PROTOCOL_NONE) // no protocol was aimed, show the msg to debug
|
||||||
|
{
|
||||||
|
Log::debug("ProtocolManager", "Message is \"%s\"", event->data.c_str());
|
||||||
|
}
|
||||||
delete event;
|
delete event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,10 @@ void* waitInput2(void* data)
|
|||||||
{
|
{
|
||||||
stop = true;
|
stop = true;
|
||||||
}
|
}
|
||||||
|
else if (str == "kickall")
|
||||||
|
{
|
||||||
|
ServerNetworkManager::getInstance()->kickAllPlayers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t id = ProtocolManager::getInstance()->requestStart(new StopServer());
|
uint32_t id = ProtocolManager::getInstance()->requestStart(new StopServer());
|
||||||
@ -89,9 +93,12 @@ void ServerNetworkManager::run()
|
|||||||
NetworkManager::run();
|
NetworkManager::run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerNetworkManager::start()
|
void ServerNetworkManager::kickAllPlayers()
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < m_peers.size(); i++)
|
||||||
|
{
|
||||||
|
m_peers[i]->disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerNetworkManager::sendPacket(const NetworkString& data)
|
void ServerNetworkManager::sendPacket(const NetworkString& data)
|
||||||
|
@ -33,7 +33,7 @@ class ServerNetworkManager : public NetworkManager
|
|||||||
|
|
||||||
virtual void run();
|
virtual void run();
|
||||||
|
|
||||||
void start();
|
void kickAllPlayers();
|
||||||
|
|
||||||
virtual void sendPacket(const NetworkString& data);
|
virtual void sendPacket(const NetworkString& data);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user