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
This commit is contained in:
parent
5d0da9a2c0
commit
94132159be
@ -124,7 +124,12 @@ void cPlayer::Initialize( cWorld* a_World )
|
|||||||
|
|
||||||
cPlayer::~cPlayer(void)
|
cPlayer::~cPlayer(void)
|
||||||
{
|
{
|
||||||
|
LOG("Deleting cPlayer \"%s\" @ %p", m_pState->PlayerName.c_str(), this);
|
||||||
|
|
||||||
SaveToDisk();
|
SaveToDisk();
|
||||||
|
|
||||||
|
m_World->RemovePlayer( this );
|
||||||
|
|
||||||
m_ClientHandle = NULL;
|
m_ClientHandle = NULL;
|
||||||
|
|
||||||
CloseWindow(-1);
|
CloseWindow(-1);
|
||||||
@ -134,7 +139,8 @@ cPlayer::~cPlayer(void)
|
|||||||
delete m_CreativeInventory;
|
delete m_CreativeInventory;
|
||||||
|
|
||||||
delete m_pState;
|
delete m_pState;
|
||||||
m_World->RemovePlayer( this );
|
|
||||||
|
LOG("Player %p deleted", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -910,7 +910,8 @@ void cWorld::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude)
|
|||||||
cCSLock Lock(m_CSPlayers);
|
cCSLock Lock(m_CSPlayers);
|
||||||
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1187,7 +1188,8 @@ void cWorld::SendPlayerList(cPlayer * a_DestPlayer)
|
|||||||
cCSLock Lock(m_CSPlayers);
|
cCSLock Lock(m_CSPlayers);
|
||||||
for ( cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
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());
|
cPacket_PlayerListItem PlayerListItem((*itr)->GetColor() + (*itr)->GetName(), true, (*itr)->GetClientHandle()->GetPing());
|
||||||
a_DestPlayer->GetClientHandle()->Send( PlayerListItem );
|
a_DestPlayer->GetClientHandle()->Send( PlayerListItem );
|
||||||
|
Loading…
Reference in New Issue
Block a user