From 64c1ee950fb67ac14e19cf5f197c0751bc381475 Mon Sep 17 00:00:00 2001 From: hilnius Date: Thu, 11 Jul 2013 12:59:53 +0000 Subject: [PATCH] more pointers for less bugs git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13181 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/network/client_network_manager.cpp | 2 +- src/network/protocol_manager.cpp | 3 --- src/network/stk_peer.cpp | 4 ++-- src/network/stk_peer.hpp | 7 ++++--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/network/client_network_manager.cpp b/src/network/client_network_manager.cpp index b0ab35946..ba1dbb39c 100644 --- a/src/network/client_network_manager.cpp +++ b/src/network/client_network_manager.cpp @@ -64,7 +64,7 @@ void* waitInput(void* data) ClientLobbyRoomProtocol* clrp = static_cast(protocol); clrp->requestKartSelection(str2); } - else + else if (NetworkManager::getInstance()->getPeers().size() > 0) { NetworkString msg; msg.ai8(0); diff --git a/src/network/protocol_manager.cpp b/src/network/protocol_manager.cpp index 9b35bf9fa..625b55ac9 100644 --- a/src/network/protocol_manager.cpp +++ b/src/network/protocol_manager.cpp @@ -80,11 +80,8 @@ ProtocolManager::~ProtocolManager() void ProtocolManager::notifyEvent(Event* event) { - Log::debug("ProtocolManager", "Event received."); Event* event2 = new Event(*event); - Log::debug("ProtocolManager", "Trying to copy the event"); pthread_mutex_lock(&m_events_mutex); - Log::debug("ProtocolManager", "Event ADDED."); m_events_to_process.push_back(event2); // add the event to the queue pthread_mutex_unlock(&m_events_mutex); } diff --git a/src/network/stk_peer.cpp b/src/network/stk_peer.cpp index c87394c9a..e0bfa25e5 100644 --- a/src/network/stk_peer.cpp +++ b/src/network/stk_peer.cpp @@ -25,7 +25,8 @@ STKPeer::STKPeer() { m_peer = NULL; - m_player_profile = new NetworkPlayerProfile(); + m_player_profile = new NetworkPlayerProfile*; + *m_player_profile = NULL; m_client_server_token = new uint32_t; *m_client_server_token = 0; m_token_set = new bool; @@ -36,7 +37,6 @@ STKPeer::STKPeer() STKPeer::STKPeer(const STKPeer& peer) { - Log::verbose("STKPeer", "Construction a copy of a STKPeer."); m_peer = peer.m_peer; m_player_profile = peer.m_player_profile; m_client_server_token = peer.m_client_server_token; diff --git a/src/network/stk_peer.hpp b/src/network/stk_peer.hpp index c714cfcf1..d91f291cb 100644 --- a/src/network/stk_peer.hpp +++ b/src/network/stk_peer.hpp @@ -38,12 +38,13 @@ 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; } + void setPlayerProfilePtr(NetworkPlayerProfile** profile) { m_player_profile = profile; } bool isConnected() const; uint32_t getAddress() const; uint16_t getPort() const; - NetworkPlayerProfile* getPlayerProfile() { return m_player_profile; } + NetworkPlayerProfile* getPlayerProfile() { return *m_player_profile; } uint32_t getClientServerToken() const { return *m_client_server_token; } bool isClientServerTokenSet() const { return *m_token_set; } @@ -51,7 +52,7 @@ class STKPeer protected: ENetPeer* m_peer; - NetworkPlayerProfile* m_player_profile; + NetworkPlayerProfile** m_player_profile; uint32_t *m_client_server_token; bool *m_token_set; };