fixing segfault and comparison operators

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13171 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hilnius 2013-07-10 23:03:45 +00:00
parent 3c3868210f
commit b00bb5c050
3 changed files with 19 additions and 1 deletions

View File

@ -145,12 +145,15 @@ void ServerLobbyRoomProtocol::update()
void ServerLobbyRoomProtocol::kartDisconnected(Event* event)
{
Log::info("ServerLobbyRoomProtocol", "Player disconnected.");
if (event->peer->getPlayerProfile() != NULL) // others knew him
{
NetworkString msg;
msg.ai8(0x02).ai8(1).ai8(event->peer->getPlayerProfile()->race_id);
m_listener->sendMessage(this, msg);
}
else
Log::info("ServerLobbyRoomProtocol", "Peer not registered");
}
//-----------------------------------------------------------------------------

View File

@ -32,7 +32,6 @@ STKPeer::~STKPeer()
{
if (m_peer)
{
free(m_peer);
m_peer = NULL;
}
}
@ -85,7 +84,20 @@ bool STKPeer::isConnected() const
Log::info("STKPeer", "The peer state is %i\n", m_peer->state);
return (m_peer->state == ENET_PEER_STATE_CONNECTED);
}
bool STKPeer::operator==(const STKPeer* peer) const
{
return peer->m_peer==m_peer;
}
bool STKPeer::operator!=(const STKPeer* peer) const
{
return peer->m_peer!=m_peer;
}
bool STKPeer::operator==(const ENetPeer* peer) const
{
return peer==m_peer;
}
bool STKPeer::operator!=(const ENetPeer* peer) const
{
return peer!=m_peer;
}

View File

@ -48,7 +48,10 @@ class STKPeer
bool isClientServerTokenSet() const { return m_token_set; }
NetworkPlayerProfile* getPlayerProfile() { return m_player_profile; }
bool operator==(const STKPeer* peer) const;
bool operator==(const ENetPeer* peer) const;
bool operator!=(const STKPeer* peer) const;
bool operator!=(const ENetPeer* peer) const;
protected:
ENetPeer* m_peer;