adding debug logging to see why when two players are connected, only one gets all the kart update messages
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13183 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
4334472a3a
commit
f03e366809
@ -76,14 +76,20 @@ bool GameSetup::removePlayer(uint8_t id)
|
||||
|
||||
void GameSetup::setPlayerKart(uint8_t id, std::string kart_name)
|
||||
{
|
||||
bool found = false;
|
||||
for (unsigned int i = 0; i < m_players.size(); i++)
|
||||
{
|
||||
if (m_players[i]->race_id == id)
|
||||
{
|
||||
m_players[i]->kart_name = kart_name;
|
||||
Log::info("GameSetup", "Player %d took kart %s", id, kart_name.c_str());
|
||||
Log::info("GameSetup::setPlayerKart", "Player %d took kart %s", id, kart_name.c_str());
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
Log::info("GameSetup::setPlayerKart", "The player %d was unknown.", id);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -62,9 +62,9 @@ void ClientLobbyRoomProtocol::notifyEvent(Event* event)
|
||||
if (event->type == EVENT_TYPE_MESSAGE)
|
||||
{
|
||||
assert(event->data.size()); // assert that data isn't empty
|
||||
Log::verbose("ClientLobbyRoomProtocol", "Message from %u : \"%s\"", peer->getAddress(), event->data.c_str());
|
||||
uint8_t message_type = event->data.getAndRemoveUInt8();
|
||||
|
||||
Log::debug("ClientLobbyRoomProtocol", "Message of type %d", message_type);
|
||||
if (message_type == 0x01) // new player connected
|
||||
newPlayer(event);
|
||||
else if (message_type == 0x02) // player disconnected
|
||||
@ -220,6 +220,8 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
|
||||
m_server = *(event->peer);
|
||||
m_state = CONNECTED;
|
||||
}
|
||||
else
|
||||
Log::info("ClientLobbyRoomProtocol", "Failure during the connection acceptation process.");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -58,7 +58,6 @@ void ServerLobbyRoomProtocol::setup()
|
||||
void ServerLobbyRoomProtocol::notifyEvent(Event* event)
|
||||
{
|
||||
assert(m_setup); // assert that the setup exists
|
||||
Log::debug("ServerLobbyRoomProtocol", "Event received");
|
||||
if (event->type == EVENT_TYPE_MESSAGE)
|
||||
{
|
||||
assert(event->data.size()); // message not empty
|
||||
@ -165,15 +164,15 @@ void ServerLobbyRoomProtocol::update()
|
||||
void ServerLobbyRoomProtocol::kartDisconnected(Event* event)
|
||||
{
|
||||
STKPeer* peer = *(event->peer);
|
||||
Log::info("ServerLobbyRoomProtocol", "Player disconnected.");
|
||||
if (peer->getPlayerProfile() != NULL) // others knew him
|
||||
{
|
||||
NetworkString msg;
|
||||
msg.ai8(0x02).ai8(1).ai8(peer->getPlayerProfile()->race_id);
|
||||
m_listener->sendMessage(this, msg);
|
||||
Log::info("ServerLobbyRoomProtocol", "Player disconnected.");
|
||||
}
|
||||
else
|
||||
Log::info("ServerLobbyRoomProtocol", "Peer not registered");
|
||||
Log::info("ServerLobbyRoomProtocol", "The DC peer wasn't registered.");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -196,7 +195,6 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event)
|
||||
Log::warn("ServerLobbyRoomProtocol", "The server is sending a badly formated message. Size is %d and first byte %d", event->data.size(), event->data[0]);
|
||||
return;
|
||||
}
|
||||
Log::verbose("ServerLobbyRoomProtocol", "New player.");
|
||||
int player_id = 0;
|
||||
player_id = event->data.getUInt32(1);
|
||||
// can we add the player ?
|
||||
@ -231,6 +229,7 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event)
|
||||
profile->user_profile = new OnlineUser("Unnamed Player");
|
||||
m_setup->addPlayer(profile);
|
||||
peer->setPlayerProfile(profile);
|
||||
Log::verbose("ServerLobbyRoomProtocol", "New player.");
|
||||
} // accept player
|
||||
else // refuse the connection with code 0 (too much players)
|
||||
{
|
||||
@ -240,6 +239,7 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event)
|
||||
message.ai8(0); // 0 = too much players
|
||||
// send only to the peer that made the request
|
||||
m_listener->sendMessage(this, peer, message);
|
||||
Log::verbose("ServerLobbyRoomProtocol", "Player refused");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user