a bit more log

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13223 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hilnius 2013-07-14 22:54:45 +00:00
parent 6fdf7cb55e
commit db376f9745
5 changed files with 15 additions and 5 deletions

View File

@ -104,11 +104,15 @@ void ClientNetworkManager::run()
m_localhost->setupClient(1, 2, 0, 0);
m_localhost->startListening();
Log::info("ClientNetworkManager", "Host initialized.");
// listen keyboard console input
m_thread_keyboard = (pthread_t*)(malloc(sizeof(pthread_t)));
pthread_create(m_thread_keyboard, NULL, waitInput, NULL);
NetworkManager::run();
Log::info("ClientNetworkManager", "Ready !");
}
void ClientNetworkManager::sendPacket(const NetworkString& data, bool reliable)

View File

@ -383,6 +383,7 @@ void ClientLobbyRoomProtocol::startGame(Event* event)
if (token == NetworkManager::getInstance()->getPeers()[0]->getClientServerToken())
{
m_listener->requestStart(new StartGameProtocol(m_setup));
Log::error("ClientLobbyRoomProtocol", "Starting new game");
}
else
Log::error("ClientLobbyRoomProtocol", "Bad token when starting game");

View File

@ -170,6 +170,7 @@ void ServerLobbyRoomProtocol::startGame()
{
NetworkString ns;
ns.ai8(0x04).ai8(4).ai32(peers[i]->getClientServerToken()); // start game
m_listener->sendMessage(this, peers[i], ns, true); // reliably
}
m_listener->requestStart(new StartGameProtocol(m_setup));
}

View File

@ -59,6 +59,11 @@ void StartGameProtocol::notifyEvent(Event* event)
void StartGameProtocol::setup()
{
m_state = LOADING;
// if no synchronization protocol exists, create one
SynchronizationProtocol* protocol = static_cast<SynchronizationProtocol*>(m_listener->getProtocol(PROTOCOL_SYNCHRONIZATION));
if (!protocol)
m_listener->requestStart(new SynchronizationProtocol());
race_manager->setNumKarts(m_game_setup->getPlayerCount());
race_manager->setNumPlayers(m_game_setup->getPlayerCount());
race_manager->setNumLocalPlayers(1);
@ -72,10 +77,6 @@ void StartGameProtocol::setup()
rki.setHostId(profile->race_id);
race_manager->setPlayerKart(i, rki);
}
// if no synchronization protocol exists, create one
SynchronizationProtocol* protocol = static_cast<SynchronizationProtocol*>(m_listener->getProtocol(PROTOCOL_SYNCHRONIZATION));
if (!protocol)
m_listener->requestStart(new SynchronizationProtocol());
}
void StartGameProtocol::update()

View File

@ -85,18 +85,21 @@ void ServerNetworkManager::run()
{
if (enet_initialize() != 0)
{
Log::error("ServerNetworkManager", "Could not initialize enet.\n");
Log::error("ServerNetworkManager", "Could not initialize enet.");
return;
}
m_localhost = new STKHost();
m_localhost->setupServer(STKHost::HOST_ANY, 7321, 16, 2, 0, 0);
m_localhost->startListening();
Log::error("ServerNetworkManager", "Host initialized.");
// listen keyboard console input
m_thread_keyboard = (pthread_t*)(malloc(sizeof(pthread_t)));
pthread_create(m_thread_keyboard, NULL, waitInput2, NULL);
NetworkManager::run();
Log::error("ServerNetworkManager", "Ready.");
}
void ServerNetworkManager::kickAllPlayers()