From 94132159be14774d56392136c10b908cb89cd33d Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 29 Feb 2012 08:40:15 +0000 Subject: Added validity checks to world broadcasting. Also added logging to cPlayer deletion to catch that stupid BugByBoo. git-svn-id: http://mc-server.googlecode.com/svn/trunk@342 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cWorld.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source/cWorld.cpp') diff --git a/source/cWorld.cpp b/source/cWorld.cpp index cc7f0b88b..85faa72e0 100644 --- a/source/cWorld.cpp +++ b/source/cWorld.cpp @@ -905,12 +905,13 @@ const double & cWorld::GetSpawnY(void) -void cWorld::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude) +void cWorld::Broadcast( const cPacket & a_Packet, cClientHandle * a_Exclude) { cCSLock Lock(m_CSPlayers); for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { - if (((*itr)->GetClientHandle() == a_Exclude) || !(*itr)->GetClientHandle()->IsLoggedIn() ) + cClientHandle * ch = (*itr)->GetClientHandle(); + if ((ch == a_Exclude) || (ch == NULL) || !ch->IsLoggedIn() || ch->IsDestroyed()) { continue; } @@ -1187,7 +1188,8 @@ void cWorld::SendPlayerList(cPlayer * a_DestPlayer) cCSLock Lock(m_CSPlayers); for ( cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { - if (((*itr)->GetClientHandle() != NULL) && !((*itr)->GetClientHandle()->IsDestroyed())) + cClientHandle * ch = (*itr)->GetClientHandle(); + if ((ch != NULL) && !ch->IsDestroyed()) { cPacket_PlayerListItem PlayerListItem((*itr)->GetColor() + (*itr)->GetName(), true, (*itr)->GetClientHandle()->GetPing()); a_DestPlayer->GetClientHandle()->Send( PlayerListItem ); -- cgit v1.2.3