From 7268a70902b04e098b6b530986d9ce6d210fdd07 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 26 Feb 2012 12:55:42 +0000 Subject: Attempt at fixing crashes with disconnecting players git-svn-id: http://mc-server.googlecode.com/svn/trunk@329 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cClientHandle.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/cClientHandle.cpp') diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index 41d2fda6c..4a6a0b508 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -165,6 +165,10 @@ cClientHandle::~cClientHandle() cPacket_Chat Left(m_Username + " left the game!"); World->Broadcast(Left, this); } + if (World != NULL) + { + World->RemovePlayer(m_Player); + } } if (m_Socket.IsValid()) @@ -209,6 +213,10 @@ cClientHandle::~cClientHandle() // Queue the socket to close as soon as it sends all outgoing data: cRoot::Get()->GetServer()->QueueClientClose(&m_Socket); + // We need to remove the socket from SocketThreads because we own it and it gets destroyed after this destructor finishes + // TODO: The socket needs to stay alive, someone else has to own it + cRoot::Get()->GetServer()->RemoveClient(&m_Socket); + LOG("ClientHandle at %p deleted", this); } -- cgit v1.2.3