void CDPLoginSrvr::OnLeave( CAr & ar ) { u_long idPlayer; ar >> idPlayer; CMclAutoLock Lock( g_PlayerMng.m_AddRemoveLock ); CPlayer* pPlayer = g_PlayerMng.GetPlayer( idPlayer ); if( pPlayer ) { g_PlayerMng.RemovePlayer( pPlayer ); } else WriteLog( "OnLeave(): player not found, %d", idPlayer ); }
void CDPLoginSrvr::OnPreJoin( CAr & ar ) { static \ TCHAR lpszAccount[MAX_ACCOUNT], lpszPlayer[MAX_PLAYER]; u_long idPlayer; DWORD dwAuthKey; ar >> dwAuthKey; ar.ReadString( lpszAccount, MAX_ACCOUNT ); ar >> idPlayer; ar.ReadString( lpszPlayer, MAX_PLAYER ); CMclAutoLock Lock( g_PlayerMng.m_AddRemoveLock ); BOOL f = g_PlayerMng.AddPlayer( idPlayer, lpszPlayer, lpszAccount ); // lock if( f == FALSE ) { WriteLog( "OnPreJoin(): AddPlayer() return false, %d, %s", idPlayer, lpszPlayer ); CPlayer* pPlayer = g_PlayerMng.GetPlayer( idPlayer ); // if( !pPlayer ) // { // WriteLog( "OnPreJoin(): ID not found" ); // pPlayer = g_PlayerMng.GetPlayer( lpszPlayer ); // } if( pPlayer ) { if( *pPlayer->lpszAccount != '\0' ) SendQueryRemovePlayer( pPlayer->lpszAccount ); else WriteLog( "OnPreJoin(): lpszAccount == '\0'" ); g_PlayerMng.RemovePlayer( pPlayer ); } else WriteLog( "OnPreJoin(): Player not found" ); } BEFORESEND( ar1, PACKETTYPE_PRE_JOIN ); // result ar1 << dwAuthKey; ar1.WriteString( lpszAccount ); ar1 << idPlayer; ar1.WriteString( lpszPlayer ); ar1 << (BYTE)f; // o SEND( ar1, this, DPID_ALLPLAYERS ); }