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 ); }
void CGuildWarMng::Result( CGuildWar* pWar, CGuild* pDecl, CGuild* pAcpt, int nType, int nWptDecl, int nWptAcpt ) { CGuild* pWin, *pLose; switch( nType ) { case WR_DECL_GN: case WR_DECL_SR: case WR_DECL_AB: case WR_DECL_DD: case WR_TRUCE: case WR_DRAW: { pWin = pDecl; pLose = pAcpt; break; } case WR_ACPT_GN: case WR_ACPT_SR: case WR_ACPT_AB: case WR_ACPT_DD: { pWin = pAcpt; pLose = pDecl; break; } } int nWinPointDecl = 0; int nWinPoint = 0; if( nType < WR_TRUCE ) { #ifdef __CORESERVER // nWinPoint nWinPoint = (int)( pWin->m_nWinPoint + ( (float)( 10 + pWin->m_nWinPoint ) / (float)( ( (float)( pWin->m_nWinPoint + 4 ) / (float)( pLose->m_nWinPoint + 1 ) ) * 0.05 ) ) + 1 ); int nMaxWinPoint = (int)( ( 10 + pWin->m_nWinPoint * 0.05 ) * 5 ); if( nWinPoint > nMaxWinPoint ) { pWin->m_nWinPoint += nMaxWinPoint; nWinPointDecl = nMaxWinPoint; } else { pWin->m_nWinPoint += nWinPoint; nWinPointDecl = nWinPoint; } pWin->m_nWin++; nWinPoint = (int)( ( 10 + pLose->m_nWinPoint * 0.02 ) ); pLose->m_nWinPoint -= nWinPoint; if( pLose->m_nWinPoint < 0 ) pLose->m_nWinPoint = 0; pLose->m_nLose++; #else // __CORESERVER pDecl->m_nWinPoint = nWptDecl; pAcpt->m_nWinPoint = nWptAcpt; pWin->m_nWin++; pLose->m_nLose++; #endif // __CORESERVER } // Clean up pWin->m_idWar = 0; pWin->m_idEnemyGuild = 0; pLose->m_idWar = 0; pLose->m_idEnemyGuild = 0; for( map<u_long, CGuildMember*>::iterator i = pWin->m_mapPMember.begin(); i != pWin->m_mapPMember.end(); ++i ) { #ifdef __CORESERVER CPlayer* pPlayer = g_PlayerMng.GetPlayer( i->second->m_idPlayer ); if( pPlayer ) pPlayer->m_idWar = 0; #endif // __CORESERVER #ifdef __WORLDSERVER CUser* pUser = g_UserMng.GetUserByPlayerID( i->second->m_idPlayer ); if( IsValidObj( pUser ) ) { pUser->m_idWar = 0; g_UserMng.AddSetWar( pUser, 0 ); pUser->SetPKTargetLimit( 10 ); } #endif // __WORLDSERVER } for( i = pLose->m_mapPMember.begin(); i != pLose->m_mapPMember.end(); ++i ) { #ifdef __CORESERVER CPlayer* pPlayer = g_PlayerMng.GetPlayer( i->second->m_idPlayer ); if( pPlayer ) pPlayer->m_idWar = 0; #endif // __CORESERVER #ifdef __WORLDSERVER CUser* pUser = g_UserMng.GetUserByPlayerID( i->second->m_idPlayer ); if( IsValidObj( pUser ) ) { pUser->m_idWar = 0; g_UserMng.AddSetWar( pUser, 0 ); pUser->SetPKTargetLimit( 10 ); } #endif // __WORLDSERVER } #ifdef __CORESERVER g_dpCoreSrvr.SendWarEnd( pWar->m_idWar, pDecl->m_nWinPoint, pAcpt->m_nWinPoint, nType ); g_DPCacheSrvr.SendWarEnd( pWar->m_idWar, pDecl->m_nWinPoint, pAcpt->m_nWinPoint, nType ); int nDBType = nType; switch( nType ) { case WR_DECL_AB: case WR_DECL_DD: nDBType = WR_DECL_GN; break; case WR_ACPT_AB: case WR_ACPT_DD: nDBType = WR_ACPT_GN; break; } g_dpDatabaseClient.SendWarEnd( pWar->m_idWar, pDecl->m_idGuild, pAcpt->m_idGuild, pDecl->m_nWinPoint, pAcpt->m_nWinPoint, nDBType, pWar->m_time, pDecl->m_nWinPoint, pAcpt->m_nWinPoint, nWinPointDecl, nWinPoint ); #endif // __CORESERVER #ifdef __CLIENT char lpString[1024] = { 0, }; switch ( nType ) { case WR_DECL_GN: case WR_ACPT_GN: { sprintf( lpString, prj.GetText( TID_GAME_GUILDWARWIN ), pDecl->m_szGuild, pAcpt->m_szGuild, pWin->m_szGuild, prj.GetText( TID_GAME_GUILDWARWIN_MASTER ) ); g_WndMng.PutString( lpString , NULL, prj.GetTextColor( TID_GAME_GUILDWARWIN ) ); break; } case WR_DECL_SR: case WR_ACPT_SR: { sprintf( lpString, prj.GetText( TID_GAME_GUILDWARWIN ), pDecl->m_szGuild, pAcpt->m_szGuild, pWin->m_szGuild, prj.GetText( TID_GAME_GUILDWARWIN_GIVEUP ) ); g_WndMng.PutString( lpString , NULL, prj.GetTextColor( TID_GAME_GUILDWARWIN ) ); break; } case WR_DECL_AB: case WR_ACPT_AB: { sprintf( lpString, prj.GetText( TID_GAME_GUILDWARWIN ), pDecl->m_szGuild, pAcpt->m_szGuild, pWin->m_szGuild, prj.GetText( TID_GAME_GUILDWARWIN_TIMEUP ) ); g_WndMng.PutString( lpString , NULL, prj.GetTextColor( TID_GAME_GUILDWARWIN ) ); break; } case WR_ACPT_DD: case WR_DECL_DD: { sprintf( lpString, prj.GetText( TID_GAME_GUILDWARWIN ), pDecl->m_szGuild, pAcpt->m_szGuild, pWin->m_szGuild, prj.GetText( TID_GAME_GUILDWARWIN_KILLNUM ) ); g_WndMng.PutString( lpString , NULL, prj.GetTextColor( TID_GAME_GUILDWARWIN ) ); break; } case WR_TRUCE: { char lpString[1024] = { 0, }; sprintf( lpString, prj.GetText( TID_GAME_GUILDWARPEACE ), pDecl->m_szGuild, pAcpt->m_szGuild ); g_WndMng.PutString( lpString , NULL, prj.GetTextColor( TID_GAME_GUILDWARPEACE ) ); break; } case WR_DRAW: { char lpString[1024] = { 0, }; sprintf( lpString, prj.GetText( TID_GAME_GUILDWARDRAW ), pDecl->m_szGuild, pAcpt->m_szGuild ); g_WndMng.PutString( lpString , NULL, prj.GetTextColor( TID_GAME_GUILDWARDRAW ) ); break; } } #endif // __CLIENT RemoveWar( pWar->m_idWar ); }
void CPartyMng::RemoveConnection( CPlayer* pPlayer ) { if( pPlayer->m_uPartyId == 0 ) return; CParty* pParty; CMclAutoLock Lock( m_AddRemoveLock ); pParty = GetParty( pPlayer->m_uPartyId ); if( pParty ) { int i = pParty->FindMember( pPlayer->uKey ); if( i < 0 ) return; pParty->m_aMember[i].m_tTime = CTime::GetCurrentTime(); pParty->m_aMember[i].m_bRemove = TRUE; pParty->m_nReferens++; BEFORESENDDUAL( ar, PACKETTYPE_REMOVEPLAYERPARTY, DPID_UNKNOWN, DPID_UNKNOWN ); ar << pPlayer->m_uPartyId << pPlayer->uKey; SEND( ar, &g_dpCoreSrvr, DPID_ALLPLAYERS ); #if __VER >= 12 // __PARSKILL1001 090917 mirchang - 파스킬 아이템 수정 if( pParty->m_nModeTime[PARTY_PARSKILL_MODE] ) g_dpCoreSrvr.SendSetPartyMode( pParty->m_uPartyId, PARTY_PARSKILL_MODE, FALSE ); #endif // __PARSKILL1001 090917 mirchang - 파스킬 아이템 수정 if( i == 0 ) { bool fRemoveParty = true; for( int j = 1; j < pParty->m_nSizeofMember; j++ ) { if( pParty->m_aMember[j].m_bRemove == FALSE ) { fRemoveParty = false; pParty->SwapPartyMember( 0, j ); break; } } #if __VER >= 12 // __PARSKILL1001 //12차 파스킬 아이템 수정 world,core,neuz for( int k = 0 ; k < MAX_PARTYMODE ; k++ ) { if( pParty->m_nModeTime[k] ) { if( k == PARTY_PARSKILL_MODE) continue; pParty->m_nModeTime[k] = 0; } } #endif //__PARSKILL1001 //12차 파스킬 아이템 수정 world,core,neuz if( fRemoveParty ) { CPlayer* pPlayer; for( j = 0; j < pParty->m_nSizeofMember; j++ ) { pPlayer = g_PlayerMng.GetPlayer( pParty->GetPlayerId( j ) ); if( pPlayer ) pPlayer->m_uPartyId = 0; } DeleteParty( pParty->m_uPartyId ); } } } }
void CPartyMng::Worker( void ) { CPlayer* pMember; HANDLE hHandle = m_hCloseWorker; while( WaitForSingleObject( hHandle, 1000 ) == WAIT_TIMEOUT ) { CTime timeCurr = CTime::GetCurrentTime(); CMclAutoLock Lock( g_PlayerMng.m_AddRemoveLock ); CMclAutoLock Lock2( m_AddRemoveLock ); for( C2PartyPtr::iterator i = m_2PartyPtr.begin(); i != m_2PartyPtr.end(); ) { CParty* pParty = (CParty*)i->second; ++i; if( pParty->m_nReferens > 0 ) { for( int j = 1; j < pParty->m_nSizeofMember; j++ ) { if( pParty->m_aMember[j].m_uPlayerId != 0 && pParty->m_aMember[j].m_bRemove ) { if( timeCurr.GetTime() - pParty->m_aMember[j].m_tTime.GetTime() > 60 * 10 ) // 10분 : 60 * 10 // 지금은 1분 { u_long idMember = pParty->GetPlayerId( j ); if( pParty->DeleteMember( idMember ) ) { pParty->m_nReferens--; g_dpCoreSrvr.SendRemoveParty( pParty->m_uPartyId, pParty->m_aMember[0].m_uPlayerId, idMember ); if( pParty->GetSizeofMember() < 2 ) { pMember = g_PlayerMng.GetPlayer( pParty->GetPlayerId( 0 ) ); if( pMember ) pMember->m_uPartyId = 0; DeleteParty( pParty->m_uPartyId ); break; } if( pParty->m_nReferens == 0 ) break; } } } } // for } // if // 파티모드를 체크 for( int j = 0 ; j < MAX_PARTYMODE ; j++ ) { if( pParty->m_nModeTime[j] ) { #if __VER >= 12 // __PARSKILL1001 //12차 파스킬 아이템 수정 world,core,neuz if( j == PARTY_PARSKILL_MODE) continue; #endif //__PARSKILL1001 //12차 파스킬 아이템 수정 world,core,neuz pParty->m_nModeTime[j] -= 1000; if( pParty->m_nModeTime[j] <= 0 ) { pParty->m_nModeTime[j] = 0; g_dpCoreSrvr.SendSetPartyMode( pParty->m_uPartyId, j, FALSE ); } } } } // for // TRACE( "Worker Party\n" ); } }