diff --git a/src/network/event.cpp b/src/network/event.cpp index b3ac860f9..5c801782b 100644 --- a/src/network/event.cpp +++ b/src/network/event.cpp @@ -76,7 +76,6 @@ Event::Event(ENetEvent* event) Event::Event(const Event& event) { - Log::verbose("Event", "Constructing a copy of the event."); m_packet = NULL; data = event.data; // copy the peer diff --git a/src/network/network_manager.cpp b/src/network/network_manager.cpp index 187895274..05169f746 100644 --- a/src/network/network_manager.cpp +++ b/src/network/network_manager.cpp @@ -109,7 +109,6 @@ void NetworkManager::notifyEvent(Event* event) } // notify for the event now. - Log::info("NetworkManager", "Notifying the protocol manager."); ProtocolManager::getInstance()->notifyEvent(event); if (event->type == EVENT_TYPE_DISCONNECTED) diff --git a/src/network/protocol_manager.cpp b/src/network/protocol_manager.cpp index 6bf36b7a9..9b35bf9fa 100644 --- a/src/network/protocol_manager.cpp +++ b/src/network/protocol_manager.cpp @@ -241,7 +241,6 @@ void ProtocolManager::update() { pthread_mutex_lock(&m_events_mutex); // secure threads Event* event = m_events_to_process.back(); - Log::debug("ProtocolManager", "Now processing event of type %d", event->type); m_events_to_process.pop_back(); pthread_mutex_unlock(&m_events_mutex); // release the mutex @@ -250,7 +249,6 @@ void ProtocolManager::update() { if (event->data.size() > 0) searchedProtocol = (PROTOCOL_TYPE)(event->data.getAndRemoveUInt8()); - Log::debug("ProtocolManager", "Message of type %d.", searchedProtocol); } if (event->type == EVENT_TYPE_CONNECTED) { diff --git a/src/network/protocols/server_lobby_room_protocol.cpp b/src/network/protocols/server_lobby_room_protocol.cpp index 34bc10361..03bc5e03e 100644 --- a/src/network/protocols/server_lobby_room_protocol.cpp +++ b/src/network/protocols/server_lobby_room_protocol.cpp @@ -203,12 +203,6 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event) // add the player to the game setup while(m_setup->getProfile(m_next_id)!=NULL) m_next_id++; - NetworkPlayerProfile* profile = new NetworkPlayerProfile(); - profile->race_id = m_next_id; - profile->kart_name = ""; - profile->user_profile = new OnlineUser("Unnamed Player"); - m_setup->addPlayer(profile); - event->peer->setPlayerProfile(profile); // notify everybody that there is a new player NetworkString message; // new player (1) -- size of id -- id -- size of local id -- local id; @@ -226,7 +220,15 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event) // connection success (129) -- size of token -- token message_ack.ai8(0x81).ai8(1).ai8(m_next_id).ai8(4).ai32(token).ai8(4).ai32(player_id); m_listener->sendMessage(this, event->peer, message_ack); + event->peer->setClientServerToken(token); + + NetworkPlayerProfile* profile = new NetworkPlayerProfile(); + profile->race_id = m_next_id; + profile->kart_name = ""; + profile->user_profile = new OnlineUser("Unnamed Player"); + m_setup->addPlayer(profile); + event->peer->setPlayerProfile(profile); } // accept player else // refuse the connection with code 0 (too much players) { diff --git a/src/network/stk_host.cpp b/src/network/stk_host.cpp index ebb41c06b..d9693305e 100644 --- a/src/network/stk_host.cpp +++ b/src/network/stk_host.cpp @@ -62,7 +62,7 @@ STKHost::~STKHost() { if (m_listening_thread) { - pthread_cancel(*m_listening_thread);//, SIGKILL); + pthread_cancel(*m_listening_thread);//, SIGKILL); with kill delete m_listening_thread; m_listening_thread = NULL; } @@ -86,8 +86,8 @@ void STKHost::setupServer(uint32_t address, uint16_t port, int peer_count, max_incoming_bandwidth, max_outgoing_bandwidth); if (m_host == NULL) { - Log::error("STKHost", "An error occurred while trying to create an ENet \ - server host."); + Log::error("STKHost", "An error occurred while trying to create an ENet" + " server host."); exit (EXIT_FAILURE); } } @@ -102,8 +102,8 @@ void STKHost::setupClient(int peer_count, int channel_limit, max_incoming_bandwidth, max_outgoing_bandwidth); if (m_host == NULL) { - Log::error("STKHost", "An error occurred while trying to create an ENet \ - client host."); + Log::error("STKHost", "An error occurred while trying to create an ENet" + " client host."); exit (EXIT_FAILURE); } } @@ -140,7 +140,7 @@ void STKHost::sendRawPacket(uint8_t* data, int length, TransportAddress dst) to.sin_addr.s_addr = htonl(dst.ip); sendto(m_host->socket, (char*)data, length, 0,(sockaddr*)&to, to_len); - Log::verbose("STKHost", "Raw packet sent to %i.%i.%i.%i:%u\n", ((dst.ip>>24)&0xff) + Log::verbose("STKHost", "Raw packet sent to %i.%i.%i.%i:%u", ((dst.ip>>24)&0xff) , ((dst.ip>>16)&0xff), ((dst.ip>>8)&0xff), ((dst.ip>>0)&0xff), dst.port); } diff --git a/src/network/stk_peer.cpp b/src/network/stk_peer.cpp index 143c8dbd8..c87394c9a 100644 --- a/src/network/stk_peer.cpp +++ b/src/network/stk_peer.cpp @@ -25,7 +25,7 @@ STKPeer::STKPeer() { m_peer = NULL; - m_player_profile = NULL; + m_player_profile = new NetworkPlayerProfile(); m_client_server_token = new uint32_t; *m_client_server_token = 0; m_token_set = new bool; diff --git a/src/network/stk_peer.hpp b/src/network/stk_peer.hpp index 27485ac2f..c714cfcf1 100644 --- a/src/network/stk_peer.hpp +++ b/src/network/stk_peer.hpp @@ -38,7 +38,7 @@ class STKPeer void setClientServerToken(const uint32_t& token) { *m_client_server_token = token; *m_token_set = true; } void unsetClientServerToken() { *m_token_set = false; } - void setPlayerProfile(NetworkPlayerProfile* profile) { m_player_profile = profile; } + void setPlayerProfile(NetworkPlayerProfile* profile) { *m_player_profile = *profile; } bool isConnected() const; uint32_t getAddress() const;