2024-12-21 10:04:04 +08:00
# include "StdAfx.h"
# include "DNPvP.h"
# include "Log.h"
# include "DNDivisionManager.h"
# include "DNVillageConnection.h"
# include "DnGameConnection.h"
# include "DNExtManager.h"
extern TMasterConfig g_Config ;
CDNPvP : : CDNPvP ( )
: m_cVillageID ( 0 ) , m_unVillageChannelID ( 0 ) , m_uiVillageMapIndex ( 0 ) , m_uiIndex ( 0 ) , m_uiCaptainAccountDBID ( 0 ) , m_uiRoomState ( PvPCommon : : RoomState : : None )
, m_uiMapIndex ( 0 ) , m_uiMaxUser ( 0 ) , m_iRandomSeed ( 0 ) , m_unGameModeCheck ( PvPCommon : : Check : : AllCheck ) , m_uiGameMode ( PvPCommon : : GameMode : : Max ) , m_uiWinCondition ( 0 ) , m_uiPlayTimeSec ( 0 ) , m_uiGameModeTableID ( 0 )
, m_biSNMain ( 0 ) , m_iSNSub ( 0 )
{
m_cEventRoomIndex = 0 ;
m_bIsCanStartEventRoom = false ;
memset ( & m_EventData , 0 , sizeof ( m_EventData ) ) ;
m_uiMinUser = 0 ;
// PvP<76> <50> <20> <> <EFBFBD> <EFBFBD> GameServer <20> <> <EFBFBD> <EFBFBD>
m_iGameServerID = 0 ;
m_iGameRoomID = 0 ;
m_cMinLevel = 1 ;
m_cMaxLevel = CHARLEVELMAX ;
memset ( m_nVoiceChannelID , 0 , sizeof ( m_nVoiceChannelID ) ) ;
m_unRoomOptionBit = PvPCommon : : RoomOption : : None ;
m_bIsGuildWarSystem = false ;
m_uiStartMsgCount = 0 ;
m_uiStartMsgTick = 0 ;
m_biCreateRoomCharacterDBID = 0 ;
# ifdef PRE_ADD_COLOSSEUM_BEGINNER
m_eRoomType = PvPCommon : : RoomType : : max ;
# endif //#ifdef PRE_ADD_COLOSSEUM_BEGINNER
m_dwPlayingStateCheckTick = 0 ;
# ifdef PRE_MOD_PVPOBSERVER
m_bExtendObserver = false ;
# endif //#ifdef PRE_MOD_PVPOBSERVER
# if defined(PRE_ADD_PVP_TOURNAMENT)
memset ( m_vTournamentAccoutDBID , 0 , sizeof ( m_vTournamentAccoutDBID ) ) ;
# endif //#if defined(PRE_ADD_PVP_TOURNAMENT)
# if defined( PRE_PVP_GAMBLEROOM )
m_cGambleType = 0 ;
m_nGamblePrice = 0 ;
# endif
}
CDNPvP : : ~ CDNPvP ( )
{
if ( m_uiIndex )
{
if ( g_pDivisionManager )
g_pDivisionManager - > PushPvPIndex ( m_uiIndex ) ;
else
_DANGER_POINT ( ) ;
}
}
void CDNPvP : : GetVoiceChannelID ( UINT * pVoiceChannel )
{
if ( pVoiceChannel )
memcpy ( pVoiceChannel , & m_nVoiceChannelID , sizeof ( m_nVoiceChannelID ) ) ;
else
_DANGER_POINT ( ) ;
}
UINT CDNPvP : : GetGuildDBIDbyIdx ( int nIdx ) const
{
if ( nIdx < 0 | | nIdx > = ( int ) m_vGuildDBID . size ( ) )
{
_DANGER_POINT ( ) ;
return 0 ;
}
return m_vGuildDBID [ nIdx ] . nGuildDBID ;
}
void CDNPvP : : Update ( const UINT uiCurTick )
{
if ( m_uiRoomState & PvPCommon : : RoomState : : Starting )
{
if ( uiCurTick - m_uiStartMsgTick > = 1000 )
{
if ( m_uiStartMsgCount = = 0 )
{
_RequestGameRoom ( ) ;
return ;
}
CDNVillageConnection * pVillageCon = g_pDivisionManager - > GetVillageConnectionByVillageID ( m_cVillageID ) ;
if ( pVillageCon )
pVillageCon - > SendPvPStartMsg ( m_unVillageChannelID , m_uiIndex , m_uiStartMsgCount ) ;
m_uiStartMsgTick = uiCurTick ;
- - m_uiStartMsgCount ;
}
}
# if defined( PRE_PVP_GAMBLEROOM )
else if ( ( GetEventRoomIndex ( ) > 0 | | GetGambleRoomType ( ) > 0 ) & & m_uiRoomState = = PvPCommon : : RoomState : : None )
# else
else if ( GetEventRoomIndex ( ) > 0 & & m_uiRoomState = = PvPCommon : : RoomState : : None )
# endif
{
CDNVillageConnection * pVillageCon = g_pDivisionManager - > GetVillageConnectionByVillageID ( m_cVillageID ) ;
if ( pVillageCon = = NULL )
return ;
VIMAPVP_START TxPacket ;
memset ( & TxPacket , 0 , sizeof ( TxPacket ) ) ;
TxPacket . sCSPVP_START . unCheck = PvPCommon : : Check : : AllCheck ;
int iRet = StartPvP ( pVillageCon , & TxPacket ) ;
if ( iRet = = ERROR_NONE )
{
if ( m_bIsCanStartEventRoom = = true )
{
if ( uiCurTick - m_uiStartMsgTick > = 1000 )
{
if ( m_uiStartMsgCount = = 0 )
return ;
CDNVillageConnection * pVillageCon = g_pDivisionManager - > GetVillageConnectionByVillageID ( m_cVillageID ) ;
if ( pVillageCon )
{
if ( m_uiStartMsgCount % 10 = = 0 | | m_uiStartMsgCount < = 5 )
pVillageCon - > SendPvPStartMsg ( m_unVillageChannelID , m_uiIndex , m_uiStartMsgCount ) ;
}
m_uiStartMsgTick = uiCurTick ;
- - m_uiStartMsgCount ;
}
}
}
else
{
m_bIsCanStartEventRoom = false ;
}
}
else if ( GetEventRoomIndex ( ) > 0 & & GetRoomState ( ) & PvPCommon : : RoomState : : Playing )
{
if ( bIsEmpty ( ) )
{
if ( m_dwPlayingStateCheckTick = = 0 )
m_dwPlayingStateCheckTick = timeGetTime ( ) ;
else if ( PvPCommon : : Common : : PvPStateAdjustmentTerm + m_dwPlayingStateCheckTick < uiCurTick )
{
g_pDivisionManager - > SetPvPFinishGameMode ( GetIndex ( ) , GetGameServerRoomIndex ( ) ) ;
g_pDivisionManager - > SetDestroyPvPGameRoom ( GetIndex ( ) , GetGameServerRoomIndex ( ) ) ;
m_dwPlayingStateCheckTick = 0 ;
}
}
}
}
bool CDNPvP : : bCreate ( const BYTE cVillageID , const UINT uiPvPIndex , const VIMAPVP_CREATEROOM * pPacket , const INT64 biCreateRoomCharacterDBID , bool bExtendObserver )
{
m_cEventRoomIndex = pPacket - > nEventID ;
if ( m_cEventRoomIndex > 0 )
memcpy ( & m_EventData , & pPacket - > EventData , sizeof ( m_EventData ) ) ;
m_uiMinUser = pPacket - > sCSPVP_CREATEROOM . cMinUser ;
// PvP<76> <50> <20> <> <EFBFBD> <EFBFBD> Village <20> <> <EFBFBD> <EFBFBD>
m_cVillageID = cVillageID ;
m_unVillageChannelID = pPacket - > unVillageChannelID ;
m_uiVillageMapIndex = pPacket - > uiVillageMapIndex ;
// PvP<76> <50> <20> <> <EFBFBD> <EFBFBD>
m_uiMapIndex = pPacket - > sCSPVP_CREATEROOM . uiMapIndex ;
m_uiGameModeTableID = pPacket - > sCSPVP_CREATEROOM . uiGameModeTableID ;
m_uiGameMode = pPacket - > cGameMode ;
m_uiWinCondition = pPacket - > sCSPVP_CREATEROOM . uiSelectWinCondition ;
m_uiPlayTimeSec = pPacket - > sCSPVP_CREATEROOM . uiSelectPlayTimeSec ;
m_uiMaxUser = pPacket - > sCSPVP_CREATEROOM . cMaxUser ;
m_uiCaptainAccountDBID = pPacket - > uiCreateAccountDBID ;
m_cMinLevel = pPacket - > sCSPVP_CREATEROOM . cMinLevel ;
m_cMaxLevel = pPacket - > sCSPVP_CREATEROOM . cMaxLevel ;
m_unRoomOptionBit = pPacket - > sCSPVP_CREATEROOM . unRoomOptionBit ;
# ifdef PRE_ADD_COLOSSEUM_BEGINNER
m_eRoomType = static_cast < PvPCommon : : RoomType : : eRoomType > ( pPacket - > sCSPVP_CREATEROOM . cRoomType ) ;
# endif //#ifdef PRE_ADD_COLOSSEUM_BEGINNER
# ifdef PRE_MOD_PVPOBSERVER
m_bExtendObserver = bExtendObserver ;
# endif //#ifdef PRE_MOD_PVPOBSERVER
# if defined( PRE_PVP_GAMBLEROOM )
m_cGambleType = pPacket - > cGambleType ;
m_nGamblePrice = pPacket - > nPrice ;
# endif
WCHAR wszBuf [ MAX_PATH ] ;
memset ( & wszBuf , 0 , sizeof ( WCHAR ) * MAX_PATH ) ;
wcsncpy ( wszBuf , pPacket - > sCSPVP_CREATEROOM . wszBuf , pPacket - > sCSPVP_CREATEROOM . cRoomNameLen ) ;
m_wstrRoomName = wszBuf ;
if ( pPacket - > sCSPVP_CREATEROOM . cRoomPWLen > 0 )
{
memset ( & wszBuf , 0 , sizeof ( WCHAR ) * MAX_PATH ) ;
wcsncpy ( wszBuf , pPacket - > sCSPVP_CREATEROOM . wszBuf + pPacket - > sCSPVP_CREATEROOM . cRoomNameLen , pPacket - > sCSPVP_CREATEROOM . cRoomPWLen ) ;
m_wstrRoomPW = wszBuf ;
}
if ( IsMode ( PvPCommon : : GameMode : : PvP_GuildWar ) = = true )
{
if ( _InitGuildWar ( PvPCommon : : Common : : DefaultGuildCount , pPacket ) )
{
m_bIsGuildWarSystem = m_vGuildDBID . empty ( ) ? false : true ;
}
}
m_biCreateRoomCharacterDBID = biCreateRoomCharacterDBID ;
m_uiIndex = uiPvPIndex ;
return true ;
}
void CDNPvP : : ModifyRoom ( CDNVillageConnection * pVillageCon , const VIMAPVP_MODIFYROOM * pPacket )
{
UINT uiPrevGameMode = m_uiGameMode ;
// PvP<76> <50> <20> <> <EFBFBD> <EFBFBD>
m_uiMapIndex = pPacket - > sCSPVP_MODIFYROOM . sCSPVP_CREATEROOM . uiMapIndex ;
m_uiGameModeTableID = pPacket - > sCSPVP_MODIFYROOM . sCSPVP_CREATEROOM . uiGameModeTableID ;
m_uiGameMode = pPacket - > cGameMode ;
m_uiWinCondition = pPacket - > sCSPVP_MODIFYROOM . sCSPVP_CREATEROOM . uiSelectWinCondition ;
m_uiPlayTimeSec = pPacket - > sCSPVP_MODIFYROOM . sCSPVP_CREATEROOM . uiSelectPlayTimeSec ;
m_cMinLevel = pPacket - > sCSPVP_MODIFYROOM . sCSPVP_CREATEROOM . cMinLevel ;
m_cMaxLevel = pPacket - > sCSPVP_MODIFYROOM . sCSPVP_CREATEROOM . cMaxLevel ;
m_unRoomOptionBit = pPacket - > sCSPVP_MODIFYROOM . sCSPVP_CREATEROOM . unRoomOptionBit ;
WCHAR wszBuf [ MAX_PATH ] ;
memset ( & wszBuf , 0 , sizeof ( WCHAR ) * MAX_PATH ) ;
wcsncpy ( wszBuf , pPacket - > sCSPVP_MODIFYROOM . sCSPVP_CREATEROOM . wszBuf , pPacket - > sCSPVP_MODIFYROOM . sCSPVP_CREATEROOM . cRoomNameLen ) ;
m_wstrRoomName = wszBuf ;
if ( pPacket - > sCSPVP_MODIFYROOM . sCSPVP_CREATEROOM . cRoomPWLen > 0 )
{
memset ( & wszBuf , 0 , sizeof ( WCHAR ) * MAX_PATH ) ;
wcsncpy ( wszBuf , pPacket - > sCSPVP_MODIFYROOM . sCSPVP_CREATEROOM . wszBuf + pPacket - > sCSPVP_MODIFYROOM . sCSPVP_CREATEROOM . cRoomNameLen , pPacket - > sCSPVP_MODIFYROOM . sCSPVP_CREATEROOM . cRoomPWLen ) ;
m_wstrRoomPW = wszBuf ;
}
else
m_wstrRoomPW . clear ( ) ;
# ifdef PRE_MOD_PVPOBSERVER
if ( bIsAllowObserver ( ) = = false )
{
LeaveObserver ( pVillageCon ) ;
}
# endif //#ifdef PRE_MOD_PVPOBSERVER
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> ˸ <EFBFBD>
pVillageCon - > SendPvPModifyRoom ( ERROR_NONE , this , pPacket ) ;
// RoomState <20> <> <EFBFBD> <EFBFBD> <20> ˻<EFBFBD>
if ( m_uiRoomState & PvPCommon : : RoomState : : Password )
{
if ( m_wstrRoomPW . empty ( ) )
SetRoomState ( m_uiRoomState & ~ PvPCommon : : RoomState : : Password ) ;
}
else
{
if ( ! m_wstrRoomPW . empty ( ) )
SetRoomState ( m_uiRoomState | PvPCommon : : RoomState : : Password ) ;
}
// UserState <20> <> <EFBFBD> <EFBFBD> (ReadyǮ<79> <C7AE> )
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( * itor ) ;
if ( pUser )
{
UINT uiState = pUser - > GetPvPUserState ( ) ;
if ( uiState & PvPCommon : : UserState : : Ready )
uiState & = ~ PvPCommon : : UserState : : Ready ;
if ( uiPrevGameMode = = PvPCommon : : GameMode : : PvP_AllKill & & IsMode ( PvPCommon : : GameMode : : PvP_AllKill ) = = false )
uiState & = ~ PvPCommon : : UserState : : GroupCaptain ;
if ( uiState ! = pUser - > GetPvPUserState ( ) )
SetPvPUserState ( pUser , uiState ) ;
}
}
if ( uiPrevGameMode ! = PvPCommon : : GameMode : : PvP_AllKill & & IsMode ( PvPCommon : : GameMode : : PvP_AllKill ) = = true )
CheckAndSetGroupCaptain ( ) ;
}
bool CDNPvP : : bIsGuildWarGrade ( UINT nAccountDBID , int nGrade )
{
std : : list < UINT > : : iterator itor = std : : find ( m_listAccountDBID . begin ( ) , m_listAccountDBID . end ( ) , nAccountDBID ) ;
if ( itor ! = m_listAccountDBID . end ( ) )
{
if ( g_pDivisionManager )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser )
{
if ( pUser - > GetPvPUserState ( ) & nGrade )
return true ;
}
}
}
return false ;
}
bool CDNPvP : : bIsCheckUser ( const UINT uiAccountDBID )
{
std : : list < UINT > : : iterator itor = std : : find ( m_listAccountDBID . begin ( ) , m_listAccountDBID . end ( ) , uiAccountDBID ) ;
return ( itor ! = m_listAccountDBID . end ( ) ) ? true : false ;
}
void CDNPvP : : AddBanUser ( UINT uiSessionID )
{
m_mBanUser . insert ( std : : make_pair ( uiSessionID , GetTickCount ( ) ) ) ;
}
void CDNPvP : : ClearBanUser ( )
{
m_mBanUser . clear ( ) ;
}
bool CDNPvP : : bIsBanUser ( const UINT uiSessionID )
{
std : : map < UINT , DWORD > : : iterator itor = m_mBanUser . find ( uiSessionID ) ;
return ( itor = = m_mBanUser . end ( ) ) ? false : true ;
}
bool CDNPvP : : bIsEmpty ( bool bExecptObserver /*=false*/ )
{
if ( bExecptObserver )
{
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( * itor ) ;
if ( pUser )
{
if ( ! pUser - > bIsObserver ( ) )
return false ;
# ifdef PRE_MOD_PVPOBSERVER
if ( bIsExtendObserver ( ) & & pUser - > bIsObserver ( ) & & pUser - > GetPvPUserState ( ) & ( PvPCommon : : UserState : : Captain ) )
return false ;
# endif //#ifdef PRE_MOD_PVPOBSERVER
}
}
return true ;
}
return m_listAccountDBID . empty ( ) ;
}
bool CDNPvP : : bIsReady ( CDNUser * pUser )
{
if ( pUser - > GetPvPUserState ( ) & ( PvPCommon : : UserState : : Ready | PvPCommon : : UserState : : Captain ) )
return true ;
if ( pUser - > bIsObserver ( ) )
return true ;
return false ;
}
bool CDNPvP : : bIsAllowLevel ( const BYTE cUserLevel )
{
if ( cUserLevel > = m_cMinLevel & & cUserLevel < = m_cMaxLevel )
return true ;
g_Log . Log ( LogType : : _ERROR , L " [PvP] LevelLimit!!! PvPRoomIndex:%d Level:%d~%d ReqLv:%d <20> ̻<EFBFBD> \r \n " , m_uiIndex , ( int ) m_cMinLevel , ( int ) m_cMaxLevel , ( int ) cUserLevel ) ;
return false ;
}
bool CDNPvP : : bLeave ( CDNVillageConnection * pVillageCon , CDNUser * pLeaveUser , const bool bDisconnectVillageServer /*=false*/ , PvPCommon : : LeaveType : : eLeaveType Type /*=PvPCommon::LeaveType::Normal*/ )
{
UINT uiLeaveAccountDBID = pLeaveUser - > GetAccountDBID ( ) ;
USHORT nLeaveTeam = pLeaveUser - > GetPvPTeam ( ) ;
UINT uiLeavePvPUserState = pLeaveUser - > GetPvPUserState ( ) ;
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; )
{
if ( ( * itor ) = = uiLeaveAccountDBID )
{
if ( pVillageCon )
pVillageCon - > SendPvPLeaveRoom ( ERROR_NONE , m_unVillageChannelID , m_uiIndex , uiLeaveAccountDBID , Type ) ;
pLeaveUser - > SetPvPIndex ( 0 ) ;
pLeaveUser - > SetPvPTeam ( PvPCommon : : Team : : Max ) ;
pLeaveUser - > SetPvPUserState ( PvPCommon : : UserState : : None ) ;
itor = m_listAccountDBID . erase ( itor ) ;
g_Log . Log ( LogType : : _NORMAL , pLeaveUser , L " [PvP] Leave PvP Room!!! PvPRoomIndex:%d \r \n " , m_uiIndex ) ;
break ;
}
else
{
+ + itor ;
}
}
if ( bDisconnectVillageServer )
return true ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϰ<EFBFBD> <CFB0> <EFBFBD> <20> <> <EFBFBD> 帶<EFBFBD> <E5B8B6> <EFBFBD> Ͱ<EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ѵ <EFBFBD> .
if ( IsMode ( PvPCommon : : GameMode : : PvP_GuildWar ) = = true )
{
SetPvPMemberIndex ( nLeaveTeam , uiLeaveAccountDBID ) ;
if ( GetUserCountByState ( nLeaveTeam , PvPCommon : : UserState : : GuildWarCaptain ) < = 0 & & GetUserCountByTeam ( nLeaveTeam ) > 0 )
{
UINT nNewGuildWarCaptain = SelectNewGuildWarCaptain ( nLeaveTeam ) ;
SetPvPGuildWarMemberGrade ( nLeaveTeam , true , PvPCommon : : UserState : : GuildWarCaptain , nNewGuildWarCaptain ) ;
if ( g_pDivisionManager & & m_iGameServerID > 0 & & ( m_uiRoomState & PvPCommon : : RoomState : : Playing ) )
{
CDNUser * pNewGuildWarCaptain = g_pDivisionManager - > GetUserBySessionID ( nNewGuildWarCaptain ) ;
if ( pNewGuildWarCaptain )
{
CDNGameConnection * pGameCon = g_pDivisionManager - > GetGameConnectionByGameID ( pNewGuildWarCaptain - > GetGameID ( ) ) ;
if ( pGameCon )
{
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> ˸ <EFBFBD> <CBB8> <EFBFBD> .
pGameCon - > SendPvPMemberGrade ( pNewGuildWarCaptain - > GetAccountDBID ( ) , pNewGuildWarCaptain - > GetPvPTeam ( ) , pNewGuildWarCaptain - > GetPvPUserState ( ) , nNewGuildWarCaptain , ERROR_NONE ) ;
}
else
_DANGER_POINT ( ) ;
}
else
_DANGER_POINT ( ) ;
}
}
}
# if defined(PRE_ADD_PVP_TOURNAMENT)
if ( IsMode ( PvPCommon : : GameMode : : PvP_Tournament ) = = true )
{
DelTournamentIndex ( uiLeaveAccountDBID ) ;
}
# endif // #if defined(PRE_ADD_PVP_TOURNAMENT)
if ( ! bIsEmpty ( true ) )
{
// <20> <> <EFBFBD> 庯<EFBFBD> <E5BAAF>
if ( m_uiCaptainAccountDBID = = uiLeaveAccountDBID )
{
# ifdef PRE_MOD_PVPOBSERVER
if ( bIsExtendObserver ( ) )
{
return bLeaveAll ( pVillageCon , PvPCommon : : LeaveType : : DestroyRoom ) ;
}
# endif //#ifdef PRE_MOD_PVPOBSERVER
UINT uiNewCaptain = FindNewCaptain ( ) ;
ChangeCaptain ( pVillageCon , uiNewCaptain ) ;
}
if ( IsMode ( PvPCommon : : GameMode : : PvP_AllKill ) = = true )
{
if ( uiLeavePvPUserState & PvPCommon : : UserState : : GroupCaptain )
{
UINT uiNewGroupCaptaion = FindNewGroupCaptain ( nLeaveTeam ) ;
ChangeGroupCaptain ( uiNewGroupCaptaion , nLeaveTeam ) ;
}
}
// STATE_GAME <20> ̸<EFBFBD> <20> <> <EFBFBD> ӹ濡 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> ˷<EFBFBD> <CBB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ѵ <EFBFBD> .
if ( pLeaveUser - > GetUserState ( ) = = STATE_GAME )
{
CDNGameConnection * pGameCon = g_pDivisionManager - > GetGameConnectionByGameID ( pLeaveUser - > GetGameID ( ) ) ;
if ( pGameCon )
{
CDNUser * pCaptainUser = GetUserByAccountDBID ( m_uiCaptainAccountDBID ) ;
if ( pCaptainUser )
pGameCon - > SendDetachUser ( uiLeaveAccountDBID ) ;
}
}
}
return true ;
}
bool CDNPvP : : bLeaveAll ( CDNVillageConnection * pVillageCon , PvPCommon : : LeaveType : : eLeaveType Type /*=PvPCommon::LeaveType::Normal*/ )
{
std : : list < UINT > tempList = m_listAccountDBID ;
for ( std : : list < UINT > : : iterator itor = tempList . begin ( ) ; itor ! = tempList . end ( ) ; + + itor )
{
if ( g_pDivisionManager )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser )
{
bLeave ( pVillageCon , pUser , true , Type ) ;
}
}
}
return true ;
}
# ifdef PRE_MOD_PVPOBSERVER
bool CDNPvP : : LeaveObserver ( CDNVillageConnection * pVillageCon , PvPCommon : : LeaveType : : eLeaveType Type )
{
std : : list < UINT > tempList = m_listAccountDBID ;
for ( std : : list < UINT > : : iterator itor = tempList . begin ( ) ; itor ! = tempList . end ( ) ; + + itor )
{
if ( g_pDivisionManager )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser & & pUser - > bIsObserver ( ) & & ! ( pUser - > GetPvPUserState ( ) & ( PvPCommon : : UserState : : Captain ) ) )
{
bLeave ( pVillageCon , pUser , true , Type ) ;
}
}
}
return true ;
}
# endif //#ifdef PRE_MOD_PVPOBSERVER
short CDNPvP : : Join ( CDNVillageConnection * pVillageCon , CDNUser * pJoinUser , const UINT UserState , bool bIsObserver /*=false*/ , UINT nGuildDBID /* = 0*/ )
{
USHORT usTeam = PvPCommon : : Team : : Max ;
if ( bIsObserver )
usTeam = PvPCommon : : Team : : Observer ;
else
usTeam = _SelectRandomTeam ( ) ;
char cIndex = - 1 ;
UINT uiUserState = UserState ;
if ( IsMode ( PvPCommon : : GameMode : : PvP_GuildWar ) = = true )
{
if ( bIsObserver = = false )
{
usTeam = _SelectTeamGuild ( nGuildDBID ) ;
if ( usTeam ! = PvPCommon : : Team : : A & & usTeam ! = PvPCommon : : Team : : B )
{
_DANGER_POINT ( ) ;
return ERROR_GENERIC_INVALIDREQUEST ;
}
else
{
if ( GetUserCountByTeam ( usTeam ) > = ( int ) m_uiMaxUser / 2 )
return ERROR_PVP_JOINROOM_MAXPLAYER ;
}
GetAndSetRemainTeamIndex ( usTeam , pJoinUser - > GetAccountDBID ( ) , cIndex ) ;
_GetJoinUserGrade ( usTeam , uiUserState ) ;
}
else if ( GetIsGuildWarSystem ( ) & & pJoinUser - > GetAccountLevel ( ) < = 0 ) //<2F> Ϲ <EFBFBD> <CFB9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> ԺҰ<D4BA>
return ERROR_PVP_JOINROOM_FAILED ;
}
# ifdef PRE_ADD_COLOSSEUM_BEGINNER
if ( m_eRoomType ! = pJoinUser - > GetPvPChannelType ( ) )
return ERROR_PVP_JOINFAIL_MISMATCHCHANNEL ;
# endif //#ifdef PRE_ADD_COLOSSEUM_BEGINNER
if ( IsMode ( PvPCommon : : GameMode : : PvP_AllKill ) = = true )
{
switch ( usTeam )
{
case PvPCommon : : Team : : A :
case PvPCommon : : Team : : B :
{
CDNUser * pUser = GetGroupCaptain ( usTeam ) ;
if ( pUser = = NULL )
uiUserState | = PvPCommon : : UserState : : GroupCaptain ;
break ;
}
}
}
# if defined(PRE_ADD_PVP_TOURNAMENT)
if ( IsMode ( PvPCommon : : GameMode : : PvP_Tournament ) = = true )
{
if ( bIsObserver = = false )
{
cIndex = GetTournamentIndex ( pJoinUser - > GetAccountDBID ( ) ) ;
if ( cIndex = = - 1 )
return ERROR_PVP_JOINROOM_FAILED ;
usTeam = cIndex % 2 = = 0 ? PvPCommon : : Team : : A : PvPCommon : : Team : : B ;
}
}
# endif // #if defined(PRE_ADD_PVP_TOURNAMENT)
m_listAccountDBID . push_back ( pJoinUser - > GetAccountDBID ( ) ) ;
pJoinUser - > SetPvPIndex ( m_uiIndex ) ;
pJoinUser - > SetPvPTeam ( usTeam ) ;
pJoinUser - > SetPvPUserState ( uiUserState ) ;
if ( pVillageCon )
{
# if defined(PRE_ADD_PVP_VILLAGE_ACCESS)
if ( pVillageCon - > GetVillageID ( ) ! = pJoinUser - > GetVillageID ( ) )
pVillageCon = pJoinUser - > GetCurrentVillageConnection ( ) ;
if ( pVillageCon = = NULL )
{
_DANGER_POINT ( ) ;
return ERROR_NONE ;
}
# endif
pVillageCon - > SendPvPJoinRoom ( ERROR_NONE , pJoinUser - > GetAccountDBID ( ) , GetVillageChannelID ( ) , m_uiIndex , usTeam , uiUserState , cIndex ) ;
}
return ERROR_NONE ;
}
bool CDNPvP : : bIsEmptySlot ( bool bIsObserver /*=false*/ )
{
if ( bIsObserver )
{
# ifdef PRE_MOD_PVPOBSERVER
bool bRet = bIsEmptyTeamSlot ( PvPCommon : : Team : : Observer ) ;
if ( bRet = = false )
g_Log . Log ( LogType : : _NORMAL , 0 , 0 , 0 , 0 , L " ObserverUser Overflow pvpid[%d] MaxObserverCount[%d] " , m_uiIndex , bIsExtendObserver ( ) ? PvPCommon : : Common : : ExtendMaxObserverPlayer : PvPCommon : : Common : : MaxObserverPlayer ) ;
return bRet ;
# else //#ifdef PRE_MOD_PVPOBSERVER
return bIsEmptyTeamSlot ( PvPCommon : : Team : : Observer ) ;
# endif //#ifdef PRE_MOD_PVPOBSERVER
}
else
{
return ( bIsEmptyTeamSlot ( PvPCommon : : Team : : A ) | | bIsEmptyTeamSlot ( PvPCommon : : Team : : B ) ) ;
}
}
bool CDNPvP : : bIsEmptyTeamSlot ( const USHORT usTeam )
{
UINT uiCount = 0 ;
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( * itor ) ;
if ( pUser )
{
if ( pUser - > GetPvPTeam ( ) = = usTeam )
+ + uiCount ;
}
else
{
g_Log . Log ( LogType : : _ERROR , L " [PvP] bIsEmptyTeamSlot!!! PvPRoomIndex:%d, AccountDBID:%d \r \n " , m_uiIndex , * itor ) ;
_DANGER_POINT ( ) ;
return false ;
}
}
if ( usTeam = = PvPCommon : : Team : : Observer )
{
# ifdef PRE_MOD_SYNCPACKET
if ( m_bExtendObserver )
return ( uiCount < PvPCommon : : Common : : ExtendMaxObserverPlayer ) ;
# endif //#ifdef PRE_MOD_SYNCPACKET
return ( uiCount < PvPCommon : : Common : : MaxObserverPlayer ) ;
}
if ( m_uiMaxUser / 2 < = uiCount )
return false ;
return true ;
}
bool CDNPvP : : bIsCheckPW ( const WCHAR * pwszPW )
{
return wcscmp ( m_wstrRoomPW . c_str ( ) , pwszPW ) ? false : true ;
}
CDNUser * CDNPvP : : GetUserBySessionID ( const UINT uiSessionID )
{
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( * itor ) ;
if ( pUser & & pUser - > GetSessionID ( ) = = uiSessionID )
return pUser ;
}
return NULL ;
}
CDNUser * CDNPvP : : GetUserByAccountDBID ( const UINT uiAccountDBID )
{
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
if ( uiAccountDBID = = ( * itor ) )
return g_pDivisionManager - > GetUserByAccountDBID ( * itor ) ;
}
return NULL ;
}
void CDNPvP : : ChangeCaptain ( CDNVillageConnection * pVillageCon , const UINT32 uiCaptainAccountDBID )
{
// <20> ̺<EFBFBD> Ʈ<EFBFBD> 濡<EFBFBD> <E6BFA1> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> ʴ´ <CAB4> .
if ( GetEventRoomIndex ( ) > 0 )
return ;
# if defined( PRE_PVP_GAMBLEROOM )
if ( GetGambleRoomType ( ) > 0 )
return ;
# endif
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ý<EFBFBD> <C3BD> ۵ <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> ʴ´ <CAB4>
if ( GetIsGuildWarSystem ( ) )
return ;
// FindNewCaptain <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> ο <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ã<> <C3A3> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> 0 <20> <> <EFBFBD> <EFBFBD> <20> Ѿ<EFBFBD> <D1BE> ´ <EFBFBD> .
if ( uiCaptainAccountDBID = = 0 )
return ;
// <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> UserState <20> <> <EFBFBD> <EFBFBD>
CDNUser * pPrevCaptain = GetUserByAccountDBID ( m_uiCaptainAccountDBID ) ;
if ( pPrevCaptain )
{
UINT uiUserState = pPrevCaptain - > GetPvPUserState ( ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> ڿ<EFBFBD> <20> <> <EFBFBD> <EFBFBD> Ǯ<> <C7AE> <EFBFBD> ش<EFBFBD> .
uiUserState & = ~ ( PvPCommon : : UserState : : Ready | PvPCommon : : UserState : : Captain ) ;
SetPvPUserState ( pPrevCaptain , uiUserState ) ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ̾<EFBFBD>
m_uiCaptainAccountDBID = uiCaptainAccountDBID ;
// <20> <> <EFBFBD> ο <EFBFBD> <20> <> <EFBFBD> <EFBFBD> UserState <20> <> <EFBFBD> <EFBFBD>
CDNUser * pNewCaptain = GetUserByAccountDBID ( m_uiCaptainAccountDBID ) ;
if ( pNewCaptain )
{
UINT uiUserState = pNewCaptain - > GetPvPUserState ( ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> Ǯ<EFBFBD> <C7AE> <20> <> <EFBFBD> <EFBFBD> <20> <EFBFBD> <DEBE> ش<EFBFBD> .
uiUserState & = ~ PvPCommon : : UserState : : Ready ;
uiUserState | = PvPCommon : : UserState : : Captain ;
SetPvPUserState ( pNewCaptain , uiUserState ) ;
# if defined( PRE_ADD_PVP_COMBOEXERCISE )
CDNGameConnection * pGameConnection = g_pDivisionManager - > GetGameConnectionByGameID ( pNewCaptain - > GetGameID ( ) ) ;
if ( pGameConnection & & PvPCommon : : RoomState : : Playing = = m_uiRoomState )
{
pGameConnection - > SendChangeRoomMaster ( m_iGameRoomID , pNewCaptain - > GetCharacterDBID ( ) , pNewCaptain - > GetSessionID ( ) ) ;
}
# endif // #if defined( PRE_ADD_PVP_COMBOEXERCISE )
}
else
_DANGER_POINT ( ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> ٲ<EFBFBD> <D9B2> <EFBFBD> Ban <20> <> <EFBFBD> <EFBFBD> <20> ʱ<EFBFBD> ȭ
ClearBanUser ( ) ;
}
bool CDNPvP : : bIsGroupCaptain ( UINT uiAccountDBID )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( uiAccountDBID ) ;
if ( pUser = = NULL )
return false ;
if ( pUser - > GetPvPUserState ( ) & PvPCommon : : UserState : : GroupCaptain )
return true ;
return false ;
}
CDNUser * CDNPvP : : GetGroupCaptain ( USHORT nTeam )
{
if ( IsMode ( PvPCommon : : GameMode : : PvP_AllKill ) = = false )
return NULL ;
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( * itor ) ;
if ( pUser = = NULL )
continue ;
if ( pUser - > GetPvPTeam ( ) = = nTeam )
{
if ( pUser - > GetPvPUserState ( ) & PvPCommon : : UserState : : GroupCaptain )
return pUser ;
}
}
return NULL ;
}
void CDNPvP : : ChangeGroupCaptain ( UINT uiGroupCaptainAccountDBID , USHORT nTeam )
{
if ( IsMode ( PvPCommon : : GameMode : : PvP_AllKill ) = = false )
return ;
// FindNewGroupCaptain <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> ο <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ã<> <C3A3> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> 0 <20> <> <EFBFBD> <EFBFBD> <20> Ѿ<EFBFBD> <D1BE> ´ <EFBFBD> .
if ( uiGroupCaptainAccountDBID = = 0 )
return ;
CDNUser * pPrevGroupCaptain = GetGroupCaptain ( nTeam ) ;
if ( pPrevGroupCaptain )
{
UINT uiUserState = pPrevGroupCaptain - > GetPvPUserState ( ) ;
uiUserState & = ~ ( PvPCommon : : UserState : : GroupCaptain ) ;
SetPvPUserState ( pPrevGroupCaptain , uiUserState ) ;
}
CDNUser * pNewGroupCaptain = GetUserByAccountDBID ( uiGroupCaptainAccountDBID ) ;
if ( pNewGroupCaptain )
{
UINT uiUserState = pNewGroupCaptain - > GetPvPUserState ( ) ;
uiUserState | = PvPCommon : : UserState : : GroupCaptain ;
SetPvPUserState ( pNewGroupCaptain , uiUserState ) ;
}
}
void CDNPvP : : CheckAndSetGroupCaptain ( )
{
if ( IsMode ( PvPCommon : : GameMode : : PvP_AllKill ) = = false )
return ;
CDNUser * pUser = GetGroupCaptain ( PvPCommon : : Team : : A ) ;
if ( pUser = = NULL )
ChangeGroupCaptain ( FindNewGroupCaptain ( PvPCommon : : Team : : A ) , PvPCommon : : Team : : A ) ;
pUser = GetGroupCaptain ( PvPCommon : : Team : : B ) ;
if ( pUser = = NULL )
ChangeGroupCaptain ( FindNewGroupCaptain ( PvPCommon : : Team : : B ) , PvPCommon : : Team : : B ) ;
}
void CDNPvP : : BanPvPRoom ( CDNVillageConnection * pVillageCon , const VIMAPVP_BAN * pPacket )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ˻<EFBFBD>
if ( ! bIsCaptain ( pPacket - > uiAccountDBID ) )
{
_DANGER_POINT ( ) ;
return ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> RoomState <20> <> <EFBFBD> <EFBFBD> <20> ˻<EFBFBD>
if ( GetRoomState ( ) & PvPCommon : : RoomState : : CantBanMask )
{
_DANGER_POINT ( ) ;
return ;
}
// <20> <> <EFBFBD> <EFBFBD> <20> <> <20> <> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> ˻<EFBFBD>
CDNUser * pBanUser = g_pDivisionManager - > GetUserBySessionID ( pPacket - > sCSPvPBan . uiSessionID ) ;
if ( ! pBanUser )
{
_DANGER_POINT ( ) ;
return ;
}
if ( ! bIsCheckUser ( pBanUser - > GetAccountDBID ( ) ) )
{
_DANGER_POINT ( ) ;
return ;
}
// <20> ڱ<EFBFBD> <DAB1> ڽŰ˻<C5B0>
if ( pBanUser - > GetAccountDBID ( ) = = pPacket - > uiAccountDBID )
{
_DANGER_POINT ( ) ;
return ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> UserState <20> <> <EFBFBD> <EFBFBD> <20> ˻<EFBFBD>
if ( pBanUser - > GetPvPUserState ( ) & PvPCommon : : UserState : : CantBanMask )
{
_DANGER_POINT ( ) ;
return ;
}
PvPCommon : : LeaveType : : eLeaveType Type = ( pPacket - > sCSPvPBan . eType = = PvPCommon : : BanType : : Permanence ) ? PvPCommon : : LeaveType : : PermanenceBan : PvPCommon : : LeaveType : : Ban ;
bLeave ( pVillageCon , pBanUser , false , Type ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ߹<EFBFBD> <DFB9> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
if ( Type = = PvPCommon : : LeaveType : : PermanenceBan )
{
AddBanUser ( pBanUser - > GetSessionID ( ) ) ;
}
}
void CDNPvP : : ReadyUser ( CDNVillageConnection * pVillageCon , const VIMAPVP_READY * pPacket )
{
// <20> ̺<EFBFBD> Ʈ<EFBFBD> <C6AE> <EFBFBD> <EFBFBD> User<65> <72> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ҽ<EFBFBD> <D2BC> <EFBFBD> <EFBFBD> <EFBFBD> .
if ( GetEventRoomIndex ( ) > 0 )
return ;
# if defined( PRE_PVP_GAMBLEROOM )
if ( GetGambleRoomType ( ) > 0 )
return ;
# endif
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ý<EFBFBD> <C3BD> ۵ <EFBFBD> User<65> <72> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> ںҰ<DABA>
if ( GetIsGuildWarSystem ( ) )
return ;
// RoomState <20> ˻<EFBFBD>
UINT uiRoomState = m_uiRoomState & ~ PvPCommon : : RoomState : : Password ;
if ( uiRoomState ! = PvPCommon : : RoomState : : None )
return ;
if ( bIsCaptain ( pPacket - > uiAccountDBID ) )
return ;
CDNUser * pUser = GetUserByAccountDBID ( pPacket - > uiAccountDBID ) ;
if ( pUser )
{
if ( pUser - > bIsObserver ( ) )
return ;
UINT uiUserState = pUser - > GetPvPUserState ( ) ;
if ( pPacket - > sCSPVP_READY . cReady )
uiUserState | = PvPCommon : : UserState : : Ready ;
else
uiUserState & = ~ PvPCommon : : UserState : : Ready ;
SetPvPUserState ( pUser , uiUserState ) ;
}
}
void CDNPvP : : SetVoiceChannelID ( UINT * pChannelID )
{
if ( pChannelID )
{
for ( int i = 0 ; i < PvPCommon : : TeamIndex : : Max ; i + + )
{
if ( pChannelID [ i ] < = 0 ) continue ;
m_nVoiceChannelID [ i ] = pChannelID [ i ] ;
}
}
else
_DANGER_POINT ( ) ;
}
bool CDNPvP : : GetGuildWarInfo ( UINT * pGuildDBID , int * pScore )
{
if ( pGuildDBID = = NULL | | pScore = = NULL )
return false ;
int nCount = 0 ;
std : : vector < PvPCommon : : Team : : TPvPGuildWarInfo > : : iterator ii ;
for ( ii = m_vGuildDBID . begin ( ) ; ii ! = m_vGuildDBID . end ( ) ; ii + + )
{
pGuildDBID [ nCount ] = ( * ii ) . nGuildDBID ;
pScore [ nCount ] = ( * ii ) . nQualifyingScore ;
nCount + + ;
if ( nCount > = PvPCommon : : Common : : DefaultGuildCount )
return true ;
}
return false ;
}
// <20> <> <EFBFBD> <EFBFBD>
short CDNPvP : : _StartBreakInto ( const VIMAPVP_START * pPacket )
{
// <20> <> <EFBFBD> <EFBFBD> <D4B0> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> ˻<EFBFBD>
CDNUser * pUser = NULL ;
if ( g_pDivisionManager )
{
pUser = g_pDivisionManager - > GetUserByAccountDBID ( pPacket - > uiAccountDBID ) ;
if ( bIsBreakIntoRoom ( ) = = false )
{
if ( pUser = = NULL | | pUser - > bIsObserver ( ) = = false )
return ERROR_PVP_STARTPVP_FAILED ;
}
}
else
{
_DANGER_POINT ( ) ;
return ERROR_PVP_STARTPVP_FAILED ;
}
// <20> <> <EFBFBD> <EFBFBD> <D4B0> ɽ<EFBFBD> <C9BD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ų<EFBFBD> <20> <> <EFBFBD> Ӹ<EFBFBD> <D3B8> 尡 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ǿ<EFBFBD> <C7BE> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> ̻<EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> ʴ´ <CAB4> .
if ( m_uiRoomState & ( PvPCommon : : RoomState : : NoMoreBreakInto | PvPCommon : : RoomState : : Finished ) )
return ERROR_PVP_STARTPVP_FAILED ;
if ( g_pDivisionManager )
{
if ( pUser )
{
UINT uiUserState = pUser - > GetPvPUserState ( ) & ~ PvPCommon : : UserState : : Captain ;
if ( IsMode ( PvPCommon : : GameMode : : PvP_GuildWar ) = = true )
{
uiUserState & = ~ PvPCommon : : UserState : : GuildWarCaptain ;
uiUserState & = ~ PvPCommon : : UserState : : GuildWarSedcondCaptain ;
}
if ( uiUserState = = PvPCommon : : UserState : : None )
{
CDNGameConnection * pGameCon = g_pDivisionManager - > GetGameConnectionByGameID ( m_iGameServerID ) ;
if ( pGameCon )
{
// <20> <> <EFBFBD> Խ<EFBFBD> Population <20> ˻<EFBFBD> <CBBB> ؼ<EFBFBD> <20> <> <EFBFBD> ϰ<EFBFBD> <20> Ѵ <EFBFBD> .
if ( pGameCon - > GetZeroPopulation ( ) )
return ERROR_PVP_STARTPVP_FAILED ;
char cTeamSlotIndex = GetPvPTeamIndex ( pUser ) ;
pGameCon - > SendBreakintoRoom ( m_iGameRoomID , pUser , BreakInto : : Type : : None , cTeamSlotIndex ) ;
SetPvPUserState ( pUser , pUser - > GetPvPUserState ( ) | PvPCommon : : UserState : : Syncing ) ;
return ERROR_NONE ;
}
}
}
}
return ERROR_PVP_STARTPVP_FAILED ;
}
short CDNPvP : : StartPvP ( CDNVillageConnection * pVillageCon , const VIMAPVP_START * pPacket )
{
UINT uiRoomState = m_uiRoomState & ~ PvPCommon : : RoomState : : Password ;
// <20> <> <EFBFBD> <EFBFBD>
if ( uiRoomState & PvPCommon : : RoomState : : Playing )
{
return _StartBreakInto ( pPacket ) ;
}
// RoomState <20> ˻<EFBFBD>
else if ( uiRoomState ! = PvPCommon : : RoomState : : None )
{
_DANGER_POINT ( ) ;
return ERROR_PVP_STARTPVP_FAILED ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ˻<EFBFBD>
# if defined( PRE_PVP_GAMBLEROOM )
if ( m_bIsGuildWarSystem = = false & & m_cEventRoomIndex < = 0 & & m_cGambleType < = 0 )
# else
if ( m_bIsGuildWarSystem = = false & & m_cEventRoomIndex < = 0 )
# endif
{
# ifdef _WORK
//todo
# else
if ( IsMode ( PvPCommon : : GameMode : : PvP_GuildWar ) = = true )
{
if ( _CheckReadyGuildWarMaster ( ) = = false )
return ERROR_PVP_STARTPVP_FAIL_READYMASTER ;
}
# endif
if ( ! bIsCaptain ( pPacket - > uiAccountDBID ) )
return ERROR_PVP_STARTPVP_FAILED ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> ̺<EFBFBD> <20> <> <EFBFBD> <EFBFBD>
TPvPGameStartConditionTable * pGameStartConditionTable = g_pExtManager - > GetPvPGameStartConditionTable ( m_uiMaxUser ) ;
if ( ! pGameStartConditionTable )
return ERROR_PVP_STARTPVP_FAILED ;
if ( ! m_bIsGuildWarSystem & & pPacket - > sCSPVP_START . unCheck & PvPCommon : : Check : : CheckStartConditionTable )
{
UINT uiATeamReadyCount , uiBTeamReadyCount ;
# if defined( PRE_PVP_GAMBLEROOM )
if ( m_cEventRoomIndex > 0 | | m_cGambleType > 0 )
# else
if ( m_cEventRoomIndex > 0 )
# endif
_GetTeamUserCount ( uiATeamReadyCount , uiBTeamReadyCount ) ;
else
_GetReadyUserCount ( uiATeamReadyCount , uiBTeamReadyCount ) ;
// <20> ̺<EFBFBD> Ʈ<EFBFBD> <C6AE> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> ּ<EFBFBD> <D6BC> ο <EFBFBD> <CEBF> <EFBFBD> <EFBFBD> <EFBFBD> <20> ˻<EFBFBD> <CBBB> Ѵ <EFBFBD> .
# if defined( PRE_PVP_GAMBLEROOM )
if ( m_cEventRoomIndex > 0 | | m_cGambleType > 0 )
# else
if ( m_cEventRoomIndex > 0 )
# endif
{
if ( m_uiMinUser > ( uiATeamReadyCount + uiBTeamReadyCount ) )
return ERROR_PVP_CANTSTART_LESS_MINTEAMPLAYER ;
}
else if ( GetIsGuildWarSystem ( ) = = false ) //<2F> ý<EFBFBD> <C3BD> ۿ<EFBFBD> <DBBF> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ǿ<EFBFBD> <C7BE> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> ƴѰ<C6B4> <D1B0> <EFBFBD> <20> ˻<EFBFBD> <CBBB> Ѵ <EFBFBD>
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> ó<> <C3B3> <20> ۾<EFBFBD>
if ( IsMode ( PvPCommon : : GameMode : : PvP_IndividualRespawn ) = = true
| | IsMode ( PvPCommon : : GameMode : : PvP_Zombie_Survival ) = = true
# if defined(PRE_ADD_RACING_MODE)
| | IsMode ( PvPCommon : : GameMode : : PvP_Racing ) = = true
# endif // #if defined(PRE_ADD_RACING_MODE)
# if defined(PRE_ADD_PVP_TOURNAMENT)
| | IsMode ( PvPCommon : : GameMode : : PvP_Tournament ) = = true
# endif // #if defined(PRE_ADD_PVP_TOURNAMENT)
)
{
if ( uiATeamReadyCount + uiBTeamReadyCount < pGameStartConditionTable - > uiMinTeamPlayerNum * 2 )
return ERROR_PVP_CANTSTART_LESS_MINTEAMPLAYER ;
}
else
{
# if defined( PRE_ADD_PVP_COMBOEXERCISE )
if ( false = = IsMode ( PvPCommon : : GameMode : : PvP_ComboExercise ) )
# endif // #if defined( PRE_ADD_PVP_COMBOEXERCISE )
{
short nRet = pGameStartConditionTable - > Check ( uiATeamReadyCount , uiBTeamReadyCount , m_unRoomOptionBit & PvPCommon : : RoomOption : : RandomTeam ? true : false ) ;
if ( nRet ! = ERROR_NONE )
return nRet ;
}
}
}
}
# if defined( PRE_PVP_GAMBLEROOM )
if ( m_cEventRoomIndex > 0 | | m_cGambleType > 0 )
# else
if ( m_cEventRoomIndex > 0 )
# endif
{
if ( m_bIsCanStartEventRoom = = false )
{
m_bIsCanStartEventRoom = true ;
m_uiStartMsgCount = 20 ; // <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <EFBFBD> <DEBC> <EFBFBD>
m_uiStartMsgTick = 0 ;
return ERROR_NONE ;
}
else
{
if ( m_uiStartMsgCount > 0 )
return ERROR_NONE ;
}
}
m_unGameModeCheck = pPacket - > sCSPVP_START . unCheck ;
pVillageCon - > SendPvPStart ( ERROR_NONE , GetVillageChannelID ( ) , m_uiIndex , pPacket - > uiAccountDBID ) ;
// RoomState <20> <> <EFBFBD> <EFBFBD>
SetRoomState ( m_uiRoomState | PvPCommon : : RoomState : : Starting ) ;
return ERROR_NONE ;
}
bool CDNPvP : : _InitGuildWar ( BYTE cCount , const VIMAPVP_CREATEROOM * pPacket )
{
if ( IsMode ( PvPCommon : : GameMode : : PvP_GuildWar ) = = true )
{
if ( ! m_vTeamSlotIndex . empty ( ) | | ! m_vGuildDBID . empty ( ) )
return false ;
PvPCommon : : Team : : TPvPTeamIndex TeamIndex ;
PvPCommon : : Team : : TPvPGuildWarInfo GuildInfo ;
int nIndex = 0 ;
for ( int i = PvPCommon : : Team : : StartIndex ; i < = PvPCommon : : Team : : EndIndex ; i + + )
{
memset ( & TeamIndex , 0 , sizeof ( TeamIndex ) ) ;
TeamIndex . nTeam = i ;
m_vTeamSlotIndex . push_back ( TeamIndex ) ;
if ( pPacket - > nGuildDBID [ nIndex ] > 0 )
{
memset ( & GuildInfo , 0 , sizeof ( PvPCommon : : Team : : TPvPGuildWarInfo ) ) ;
GuildInfo . nTeam = TeamIndex . nTeam ;
GuildInfo . nGuildDBID = pPacket - > nGuildDBID [ nIndex ] ;
GuildInfo . nQualifyingScore = pPacket - > nGuildQualifyingScore [ nIndex ] ;
m_vGuildDBID . push_back ( GuildInfo ) ;
}
nIndex + + ;
}
return true ;
}
return false ;
}
USHORT CDNPvP : : _SelectTeamGuild ( UINT nGuildDBID )
{
if ( m_vGuildDBID . empty ( ) ) //<2F> <> <EFBFBD> 尡 <20> <> <EFBFBD> õǾ<C3B5> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> .
return _SelectRandomTeam ( ) ;
std : : vector < PvPCommon : : Team : : TPvPGuildWarInfo > : : iterator ii ;
for ( ii = m_vGuildDBID . begin ( ) ; ii ! = m_vGuildDBID . end ( ) ; ii + + )
{
if ( ( * ii ) . nGuildDBID = = nGuildDBID )
return ( * ii ) . nTeam ;
}
return PvPCommon : : Team : : Observer ;
}
void CDNPvP : : _GetJoinUserGrade ( USHORT nTeam , UINT & uiUserState )
{
int nTeamUserCount = GetUserCountByTeam ( nTeam ) ;
if ( nTeamUserCount = = 0 )
uiUserState | = PvPCommon : : UserState : : GuildWarCaptain ;
}
int CDNPvP : : _GetUserCountByTeamIndex ( PvPCommon : : Team : : TPvPTeamIndex & Team )
{
int nCount = 0 ;
for ( int i = 0 ; i < PARTYMAX ; i + + )
{
if ( Team . nAccountDBID [ i ] < = 0 ) continue ;
nCount + + ;
}
return nCount ;
}
bool CDNPvP : : _CheckReadyGuildWarMaster ( )
{
bool bCheckA , bCheckB ;
bCheckA = bCheckB = false ;
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
if ( g_pDivisionManager )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser & & pUser - > GetPvPUserState ( ) & PvPCommon : : UserState : : GuildWarCaptain )
{
if ( bIsReady ( pUser ) )
{
if ( pUser - > GetPvPTeam ( ) = = PvPCommon : : Team : : A )
bCheckA = true ;
else if ( pUser - > GetPvPTeam ( ) = = PvPCommon : : Team : : B )
bCheckB = true ;
}
}
}
}
return ( bCheckA & & bCheckB ) ? true : false ;
}
int CDNPvP : : SetPvPGuildWarMemberGrade ( USHORT nTeam , bool bAsign , USHORT nType , UINT nSessionID )
{
if ( IsMode ( PvPCommon : : GameMode : : PvP_GuildWar ) = = false )
{
_DANGER_POINT ( ) ;
return ERROR_GENERIC_INVALIDREQUEST ;
}
if ( bAsign = = false & & nType = = PvPCommon : : UserState : : GuildWarCaptain )
{
_DANGER_POINT ( ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> Ұ<EFBFBD> <D2B0> <EFBFBD> <EFBFBD> ϴ<EFBFBD> !
return ERROR_GENERIC_INVALIDREQUEST ;
}
if ( nType ! = PvPCommon : : UserState : : GuildWarSedcondCaptain & & nType ! = PvPCommon : : UserState : : GuildWarCaptain )
{
_DANGER_POINT ( ) ;
return ERROR_GENERIC_INVALIDREQUEST ;
}
CDNUser * pUser = NULL ;
if ( nType = = PvPCommon : : UserState : : GuildWarSedcondCaptain & & bAsign )
{
if ( GetUserCountByState ( nTeam , PvPCommon : : UserState : : GuildWarSedcondCaptain ) > = PvPCommon : : Common : : MaximumGuildWarSecondCaptain )
return ERROR_PVP_GUILDWAR_SECONDARYMASTER_ASIGNFAIL ;
}
int nRet = ERROR_INVALIDPACKET ;
CDNUser * pSecondaryCaptainUser = GetUserBySessionID ( nSessionID ) ;
if ( pSecondaryCaptainUser ) //<2F> ٲ<EFBFBD> <D9B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> PvP<76> 濡 <20> ִ<EFBFBD> <D6B4> <EFBFBD> Ȯ<> <C8AE>
{
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser = = NULL ) continue ;
UINT nUserState = pUser - > GetPvPUserState ( ) ;
if ( pSecondaryCaptainUser - > GetAccountDBID ( ) = = pUser - > GetAccountDBID ( ) )
{
if ( bAsign )
{
if ( nUserState & PvPCommon : : UserState : : GuildWarSedcondCaptain )
nUserState & = ~ PvPCommon : : UserState : : GuildWarSedcondCaptain ;
nUserState | = nType ;
}
else
{
nUserState & = ~ nType ;
}
nRet = ERROR_NONE ;
}
else if ( pSecondaryCaptainUser - > GetPvPTeam ( ) = = pUser - > GetPvPTeam ( ) ) //<2F> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> ¸ <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ѵ <EFBFBD>
{
if ( nType = = PvPCommon : : UserState : : GuildWarCaptain )
nUserState & = ~ nType ;
}
SetPvPUserState ( pUser , nUserState ) ;
}
}
return nRet ;
}
bool CDNPvP : : SetPvPMemberIndex ( int nTeam , UINT nAccountDBID )
{
std : : vector < PvPCommon : : Team : : TPvPTeamIndex > : : iterator ii ;
for ( ii = m_vTeamSlotIndex . begin ( ) ; ii ! = m_vTeamSlotIndex . end ( ) ; ii + + )
{
if ( ( * ii ) . nTeam = = nTeam )
{
for ( int i = 0 ; i < PARTYMAX ; i + + )
{
if ( ( * ii ) . nAccountDBID [ i ] = = nAccountDBID )
{
( * ii ) . nAccountDBID [ i ] = 0 ;
return true ;
}
}
}
}
return false ;
}
bool CDNPvP : : SwapPvPMemberIndex ( USHORT nTeam , BYTE cCount , const TSwapMemberIndex * pIndex )
{
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ε<EFBFBD> <CEB5> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ϴ<EFBFBD> <20> <> <EFBFBD> <EFBFBD>
if ( IsMode ( PvPCommon : : GameMode : : PvP_GuildWar ) = = false )
{
_DANGER_POINT ( ) ;
return false ;
}
if ( pIndex = = NULL )
{
_DANGER_POINT ( ) ;
return false ;
}
//verify index range
int nOffset = m_uiMaxUser / 2 ;
std : : vector < BYTE > vDuplicate ;
std : : vector < BYTE > : : iterator iDuplicater ;
for ( int i = 0 ; i < cCount ; i + + )
{
if ( pIndex [ i ] . cIndex > ( ( nTeam = = PvPCommon : : Team : : A ? nOffset : m_uiMaxUser ) - 1 ) | | pIndex [ i ] . cIndex < ( nTeam = = PvPCommon : : Team : : A ? 0 : nOffset ) )
{
_DANGER_POINT ( ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
return false ;
}
iDuplicater = std : : find ( vDuplicate . begin ( ) , vDuplicate . end ( ) , pIndex [ i ] . cIndex ) ;
if ( vDuplicate . end ( ) ! = iDuplicater )
{
_DANGER_POINT ( ) ; //<2F> ߺ <EFBFBD> <DFBA> ε<EFBFBD> <CEB5> <EFBFBD>
return false ; //<2F> ߺ <EFBFBD> <DFBA> ε<EFBFBD> <CEB5> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> ȵ<EFBFBD> <C8B5> ڳ<EFBFBD>
}
vDuplicate . push_back ( pIndex [ i ] . cIndex ) ;
}
std : : vector < PvPCommon : : Team : : TPvPTeamIndex > : : iterator ii ;
for ( ii = m_vTeamSlotIndex . begin ( ) ; ii ! = m_vTeamSlotIndex . end ( ) ; ii + + )
{
if ( ( * ii ) . nTeam = = nTeam )
break ;
}
if ( ii = = m_vTeamSlotIndex . end ( ) )
{
_DANGER_POINT ( ) ;
return false ;
}
//<2F> ش<EFBFBD> <D8B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> Ǻ<EFBFBD> <C7BA> ǹ濡 <20> ִ<EFBFBD> <20> ο <EFBFBD> <CEBF> <EFBFBD> <EFBFBD> <EFBFBD> Ȯ<> <C8AE>
CDNUser * pUser ;
PvPCommon : : Team : : TPvPTeamIndex TeamIndex = ( * ii ) ;
for ( int i = 0 ; i < cCount ; i + + )
{
if ( pIndex [ i ] . nSessionID < = 0 )
{
TeamIndex . nAccountDBID [ pIndex [ i ] . cIndex ] = 0 ;
}
else
{
pUser = g_pDivisionManager - > GetUserBySessionID ( pIndex [ i ] . nSessionID ) ;
if ( pUser = = NULL )
{
_DANGER_POINT ( ) ;
return false ;
}
TeamIndex . nAccountDBID [ pIndex [ i ] . cIndex ] = pUser - > GetAccountDBID ( ) ;
}
}
//verify
int nPreCount = _GetUserCountByTeamIndex ( ( * ii ) ) ;
int nPostCount = _GetUserCountByTeamIndex ( TeamIndex ) ;
if ( nPreCount ! = nPreCount )
{
_DANGER_POINT ( ) ;
return false ;
}
//Reset!!
( * ii ) = TeamIndex ;
return true ;
}
int CDNPvP : : GetUserCountByTeam ( USHORT nTeam )
{
int outiTeamCount = 0 ;
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
if ( g_pDivisionManager )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser )
{
if ( pUser - > GetPvPTeam ( ) = = nTeam )
+ + outiTeamCount ;
}
}
}
return outiTeamCount ;
}
int CDNPvP : : GetUserCountByState ( USHORT nTeam , USHORT nState )
{
int outnUserCnt = 0 ;
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
if ( g_pDivisionManager )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser & & pUser - > GetPvPTeam ( ) = = nTeam )
{
if ( pUser - > GetPvPUserState ( ) & nState )
+ + outnUserCnt ;
}
}
}
return outnUserCnt ;
}
bool CDNPvP : : GetAndSetRemainTeamIndex ( int nTeam , UINT nAccountDBID , char & cIndex )
{
int nOffset = m_uiMaxUser / 2 ;
std : : vector < PvPCommon : : Team : : TPvPTeamIndex > : : iterator ii ;
for ( ii = m_vTeamSlotIndex . begin ( ) ; ii ! = m_vTeamSlotIndex . end ( ) ; ii + + )
{
if ( ( * ii ) . nTeam = = nTeam )
{
//for (int i = 0; i < PARTYMAX; i++)
for ( int i = ( nTeam = = PvPCommon : : Team : : A ? 0 : nOffset ) ; i < PARTYMAX ; i + + )
{
if ( ( * ii ) . nAccountDBID [ i ] = = 0 )
{
( * ii ) . nAccountDBID [ i ] = nAccountDBID ;
cIndex = ( char ) i ; // + (nTeam == PvPCommon::Team::A ? 0 : nOffset);
if ( nTeam = = PvPCommon : : Team : : A & & ( cIndex > = nOffset | | cIndex < 0 ) )
{
_DANGER_POINT ( ) ;
}
else if ( nTeam = = PvPCommon : : Team : : B & & ( cIndex < nOffset | | cIndex < 0 ) )
{
_DANGER_POINT ( ) ;
}
return true ;
}
}
}
}
return false ;
}
char CDNPvP : : GetPvPTeamIndex ( CDNUser * pUser )
{
if ( pUser = = NULL )
{
_DANGER_POINT ( ) ;
return - 1 ;
}
int nOffset = m_uiMaxUser / 2 ;
std : : vector < PvPCommon : : Team : : TPvPTeamIndex > : : iterator ii ;
for ( ii = m_vTeamSlotIndex . begin ( ) ; ii ! = m_vTeamSlotIndex . end ( ) ; ii + + )
{
if ( ( * ii ) . nTeam = = pUser - > GetPvPTeam ( ) )
{
for ( int i = ( pUser - > GetPvPTeam ( ) = = PvPCommon : : Team : : A ? 0 : nOffset ) ; i < PARTYMAX ; i + + )
{
if ( ( * ii ) . nAccountDBID [ i ] = = pUser - > GetAccountDBID ( ) )
return ( char ) i ; // + (pUser->GetPvPTeam() == PvPCommon::Team::A ? 0 : nOffset);
}
}
}
return - 1 ;
}
UINT CDNPvP : : SelectNewGuildWarCaptain ( USHORT nTeam , UINT nExceptSessionID )
{
CDNUser * pUser ;
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser & & pUser - > GetPvPTeam ( ) = = nTeam )
{
if ( ! ( pUser - > GetPvPUserState ( ) & PvPCommon : : UserState : : GuildWarSedcondCaptain ) & & pUser - > GetSessionID ( ) ! = nExceptSessionID )
return pUser - > GetSessionID ( ) ;
}
}
//<2F> <> <EFBFBD> <EFBFBD> ? <20> <> <EFBFBD> ٸ<EFBFBD> <20> ο <EFBFBD> <CEBF> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> ο <EFBFBD> <CEBF> <EFBFBD> <20> δ<EFBFBD> <CEB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> õǾ<C3B5> <20> ִ<EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ̴<EFBFBD> . <20> Ѹ<EFBFBD> <D1B8> <EFBFBD> <20> °ݽ<C2B0> Ų<EFBFBD> <C5B2> .
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser & & pUser - > GetSessionID ( ) ! = nExceptSessionID )
return pUser - > GetSessionID ( ) ;
}
return 0 ;
}
# if defined(PRE_ADD_PVP_TOURNAMENT)
char CDNPvP : : FindTournamentIndex ( UINT uiAccountDBID )
{
for ( char i = 0 ; i < PvPCommon : : Common : : PvPTournamentUserMax ; + + i )
{
if ( m_vTournamentAccoutDBID [ i ] = = uiAccountDBID )
return i ;
}
return - 1 ;
}
char CDNPvP : : GetTournamentIndex ( UINT uiAccountDBID )
{
for ( char i = 0 ; i < m_uiMaxUser ; + + i )
{
if ( m_vTournamentAccoutDBID [ i ] = = 0 )
{
m_vTournamentAccoutDBID [ i ] = uiAccountDBID ;
return i ;
}
}
return - 1 ;
}
bool CDNPvP : : DelTournamentIndex ( UINT uiAccountDBID )
{
for ( char i = 0 ; i < PvPCommon : : Common : : PvPTournamentUserMax ; + + i )
{
if ( m_vTournamentAccoutDBID [ i ] = = uiAccountDBID )
{
m_vTournamentAccoutDBID [ i ] = 0 ;
return true ;
}
}
return false ;
}
bool CDNPvP : : SwapPvPTournamentIndex ( char cSourceIndex , char cDestIndex )
{
if ( cSourceIndex < 0 | | cSourceIndex > = m_uiMaxUser | | cDestIndex < 0 | | cDestIndex > = m_uiMaxUser )
return false ;
if ( m_vTournamentAccoutDBID [ cSourceIndex ] = = 0 | | m_vTournamentAccoutDBID [ cDestIndex ] = = 0 )
return false ;
UINT nTempAccountDBID = m_vTournamentAccoutDBID [ cDestIndex ] ;
m_vTournamentAccoutDBID [ cDestIndex ] = m_vTournamentAccoutDBID [ cSourceIndex ] ;
m_vTournamentAccoutDBID [ cSourceIndex ] = nTempAccountDBID ;
return true ;
}
UINT CDNPvP : : GetPvPTournamentAccountDBID ( char cIndex )
{
if ( cIndex < 0 | | cIndex > = m_uiMaxUser )
return 0 ;
return m_vTournamentAccoutDBID [ cIndex ] ;
}
void CDNPvP : : SetTournamentShuffleIndex ( )
{
// Max <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Random
std : : vector < UINT > vTournamentIndex ;
vTournamentIndex . reserve ( m_uiMaxUser ) ;
for ( UINT i = 0 ; i < m_uiMaxUser ; + + i )
vTournamentIndex . push_back ( GetPvPTournamentIndex ( i ) ) ;
srand ( unsigned ( time ( NULL ) ) ) ;
random_shuffle ( vTournamentIndex . begin ( ) , vTournamentIndex . end ( ) ) ; // Random<6F> <6D> <20> <> <EFBFBD> ´ <EFBFBD> .
for ( UINT i = 0 ; i < m_uiMaxUser ; + + i )
{
m_vTournamentAccoutDBID [ i ] = vTournamentIndex [ i ] ;
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( m_vTournamentAccoutDBID [ i ] ) ;
if ( pUser )
pUser - > SetPvPTeam ( i % 2 = = 0 ? PvPCommon : : Team : : A : PvPCommon : : Team : : B ) ;
}
CDNVillageConnection * pVillageCon = g_pDivisionManager - > GetVillageConnectionByVillageID ( m_cVillageID ) ;
if ( pVillageCon )
pVillageCon - > SendPvPShuffleTournamentIndex ( this ) ;
}
# endif
void CDNPvP : : SetRoomState ( const UINT uiRoomState )
{
if ( m_cEventRoomIndex > 0 )
g_Log . Log ( LogType : : _PVPROOM , g_Config . nWorldSetID , 0 , 0 , 0 , L " PVP State [Index:%d][Room:%d][Event:%d][State:%d] \r \n " , m_uiIndex , m_iGameRoomID , m_cEventRoomIndex , uiRoomState ) ;
m_uiRoomState = uiRoomState ;
CDNVillageConnection * pVillageCon = g_pDivisionManager - > GetVillageConnectionByVillageID ( m_cVillageID ) ;
if ( pVillageCon )
pVillageCon - > SendPvPRoomState ( GetVillageChannelID ( ) , m_uiIndex , m_uiRoomState ) ;
if ( ( uiRoomState & ~ PvPCommon : : RoomState : : Password ) = = PvPCommon : : RoomState : : None )
{
m_iGameServerID = 0 ;
m_iGameRoomID = 0 ;
m_iRandomSeed = timeGetTime ( ) ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> õ<EFBFBD> <C3B5> <EFBFBD> <EFBFBD> ߱<EFBFBD>
m_bIsCanStartEventRoom = false ;
// S/N <20> <> <EFBFBD> ߱<EFBFBD>
SYSTEMTIME st ;
GetLocalTime ( & st ) ;
char szSN [ MAX_PATH ] ;
sprintf ( szSN , " %.4d%.2d%.2d%.2d%.2d%.2d%.3d% " , st . wYear , st . wMonth , st . wDay , st . wHour , st . wMinute , st . wSecond , st . wMilliseconds ) ;
m_biSNMain = _atoi64 ( szSN ) ;
sprintf ( szSN , " %.2d%.2d%.4d " , g_Config . nWorldSetID , m_cVillageID , m_uiIndex ) ;
m_iSNSub = atoi ( szSN ) ;
// UserState <20> ʱ<EFBFBD> ȭ
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser )
{
UINT uiUserState = pUser - > GetPvPUserState ( ) ;
UINT uiCheckState = PvPCommon : : UserState : : None ;
if ( uiUserState & PvPCommon : : UserState : : Captain )
uiCheckState = PvPCommon : : UserState : : Captain ;
if ( uiUserState & PvPCommon : : UserState : : GuildWarCaptain )
uiCheckState | = PvPCommon : : UserState : : GuildWarCaptain ;
if ( IsMode ( PvPCommon : : GameMode : : PvP_AllKill ) )
{
if ( uiUserState & PvPCommon : : UserState : : GroupCaptain )
uiCheckState | = PvPCommon : : UserState : : GroupCaptain ;
}
if ( uiUserState ! = uiCheckState )
SetPvPUserState ( pUser , uiCheckState ) ;
}
}
if ( IsMode ( PvPCommon : : GameMode : : PvP_AllKill ) )
{
CheckAndSetGroupCaptain ( ) ;
}
}
else if ( uiRoomState & PvPCommon : : RoomState : : Starting )
{
# if defined( PRE_PVP_GAMBLEROOM )
if ( m_cEventRoomIndex > 0 | | m_cGambleType > 0 )
# else
if ( m_cEventRoomIndex > 0 )
# endif
{
m_uiStartMsgCount = 0 ;
m_uiStartMsgTick = 0 ;
}
else
{
m_uiStartMsgCount = 5 ;
m_uiStartMsgTick = 0 ;
}
if ( g_pDivisionManager )
{
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser )
{
if ( bIsReady ( pUser ) )
{
UINT uiUserState = pUser - > GetPvPUserState ( ) ;
uiUserState | = PvPCommon : : UserState : : Starting ;
SetPvPUserState ( pUser , uiUserState ) ;
}
else if ( pUser - > bIsObserver ( ) )
{
UINT uiUserState = pUser - > GetPvPUserState ( ) ;
uiUserState | = PvPCommon : : UserState : : Starting ;
SetPvPUserState ( pUser , uiUserState ) ;
}
// <20> ̺<EFBFBD> Ʈ<EFBFBD> <C6AE> <EFBFBD> <EFBFBD> Starting <20> Ǵ<EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> ۽<EFBFBD> Ų<EFBFBD> <C5B2> .
# if defined( PRE_PVP_GAMBLEROOM )
else if ( m_cEventRoomIndex > 0 | | m_cGambleType > 0 )
# else
else if ( m_cEventRoomIndex > 0 )
# endif
{
UINT uiUserState = pUser - > GetPvPUserState ( ) ;
uiUserState | = ( PvPCommon : : UserState : : Starting | PvPCommon : : UserState : : Ready ) ;
SetPvPUserState ( pUser , uiUserState ) ;
}
}
else
_DANGER_POINT ( ) ;
}
}
else
_DANGER_POINT ( ) ;
}
else if ( uiRoomState & PvPCommon : : RoomState : : Playing )
{
if ( g_pDivisionManager )
{
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser )
AddPvPUserState ( pUser , PvPCommon : : UserState : : Playing ) ;
else
_DANGER_POINT ( ) ;
}
}
else
_DANGER_POINT ( ) ;
}
}
void CDNPvP : : AddPvPUserState ( CDNUser * pUser , const UINT uiAddUserSate )
{
switch ( uiAddUserSate )
{
case PvPCommon : : UserState : : Playing :
{
UINT uiUserState = pUser - > GetPvPUserState ( ) ;
if ( uiUserState & PvPCommon : : UserState : : Syncing )
{
uiUserState & = ~ ( PvPCommon : : UserState : : Syncing | PvPCommon : : UserState : : Ready ) ;
uiUserState | = PvPCommon : : UserState : : Playing ;
SetPvPUserState ( pUser , uiUserState ) ;
}
break ;
}
}
}
void CDNPvP : : SetPvPUserState ( CDNUser * pUser , const UINT uiUserState )
{
pUser - > SetPvPUserState ( uiUserState ) ;
CDNVillageConnection * pVillageCon = g_pDivisionManager - > GetVillageConnectionByVillageID ( m_cVillageID ) ;
if ( pVillageCon )
pVillageCon - > SendPvPChangeUserState ( GetVillageChannelID ( ) , m_uiIndex , pUser - > GetAccountDBID ( ) , uiUserState ) ;
}
void CDNPvP : : SetAllGameID ( USHORT wGameID , int nRandomSeed , int nMapIdx , BYTE cGateNum )
{
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser )
{
if ( pUser - > GetPvPUserState ( ) & PvPCommon : : UserState : : Starting )
{
UINT uiUserState = pUser - > GetPvPUserState ( ) & ~ PvPCommon : : UserState : : Starting ;
uiUserState | = PvPCommon : : UserState : : Syncing ;
if ( pUser - > SetCheckGameInfo ( wGameID , - 1 ) = = false )
continue ;
pUser - > m_nRandomSeed = nRandomSeed ;
pUser - > m_nMapIndex = nMapIdx ;
pUser - > m_cGateNo = cGateNum ;
SetPvPUserState ( pUser , uiUserState ) ;
if ( m_cEventRoomIndex > 0 )
g_Log . Log ( LogType : : _PVPROOM , pUser , L " SetAllGameID Event [Index:%d][Room:%d][Event:%d][CHRID:%d] \r \n " , m_uiIndex , m_iGameRoomID , m_cEventRoomIndex , pUser - > GetCharacterDBID ( ) ) ;
}
}
else
_DANGER_POINT ( ) ;
}
}
// <20> <> <EFBFBD> Ӽ<EFBFBD> <D3BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> PvP<76> <50> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> .
void CDNPvP : : SetAllRoomID ( CDNVillageConnection * pVillageCon , CDNGameConnection * pGameCon , int nRoomID , int nServerIdx )
{
if ( ! g_pDivisionManager )
{
_DANGER_POINT ( ) ;
return ;
}
m_iGameServerID = pGameCon - > GetGameID ( ) ;
m_iGameRoomID = nRoomID ;
pGameCon - > SendPvPGameMode ( this ) ;
# if defined(PRE_ADD_PVP_TOURNAMENT)
if ( IsMode ( PvPCommon : : GameMode : : PvP_Tournament ) = = true )
{
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̸<EFBFBD> <20> ѹ<EFBFBD> <20> <> <EFBFBD> ´ <EFBFBD> .
if ( m_unRoomOptionBit & PvPCommon : : RoomOption : : RandomTeam )
SetTournamentShuffleIndex ( ) ;
pGameCon - > SendPvPTournamentUserInfo ( this ) ; // <20> <> <EFBFBD> <EFBFBD> ǥ <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> Ӽ<EFBFBD> <D3BC> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ֱ<EFBFBD> .
}
# endif
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
// <20> <> <EFBFBD> <EFBFBD> ȭ<EFBFBD> <C8AD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ...
if ( pUser & & pUser - > GetPvPUserState ( ) & PvPCommon : : UserState : : Syncing )
{
if ( g_pDivisionManager - > VillageToGame ( pVillageCon , ( * itor ) , m_iGameServerID , nRoomID , nServerIdx ) = = false )
_DANGER_POINT ( ) ;
}
}
}
void CDNPvP : : GetMembersByAccountDBID ( std : : vector < UINT > & rvAccountDBID )
{
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
rvAccountDBID . push_back ( * itor ) ;
}
// Retrun
// True : PvP<76> <50> <20> ı <EFBFBD>
// Flag : PvP<76> <50> <20> ı <EFBFBD> <20> ȵ<EFBFBD>
bool CDNPvP : : bDisconnectServer ( const int iConnectionKey )
{
switch ( iConnectionKey )
{
case CONNECTIONKEY_VILLAGE :
{
// <20> <> <EFBFBD> <EFBFBD> Ʈ <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
std : : list < UINT > listBackUp = m_listAccountDBID ;
for ( std : : list < UINT > : : iterator itor = listBackUp . begin ( ) ; itor ! = listBackUp . end ( ) ; + + itor )
{
if ( g_pDivisionManager )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( * itor ) ;
if ( pUser )
bLeave ( NULL , pUser , true ) ;
}
}
return true ;
}
case CONNECTIONKEY_GAME :
{
CDNVillageConnection * pVillageCon = NULL ;
if ( g_pDivisionManager )
pVillageCon = g_pDivisionManager - > GetVillageConnectionByVillageID ( m_cVillageID ) ;
if ( ! pVillageCon )
{
_DANGER_POINT ( ) ;
return false ;
}
// <20> <> <EFBFBD> <EFBFBD> Ʈ <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
std : : list < UINT > listBackUp = m_listAccountDBID ;
for ( std : : list < UINT > : : iterator itor = listBackUp . begin ( ) ; itor ! = listBackUp . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( * itor ) ;
if ( pUser )
{
// PvPCommon::UserState::Syncing|PvPCommon::UserStaet::Playing <20> <> <EFBFBD> ¶<EFBFBD> <C2B6> <EFBFBD> <20> <> <EFBFBD> Ӽ<EFBFBD> <D3BC> <EFBFBD> <20> ٿ<EFBFBD> <D9BF> <EFBFBD> PvP<76> 濡<EFBFBD> <E6BFA1> <20> <> <EFBFBD> i<EFBFBD> ´ <EFBFBD> .
if ( pUser - > GetPvPUserState ( ) & ( PvPCommon : : UserState : : Syncing | PvPCommon : : UserState : : Playing ) )
bLeave ( pVillageCon , pUser ) ;
}
}
break ;
}
}
return bIsEmpty ( ) ? true : false ;
}
void CDNPvP : : _RequestGameRoom ( )
{
UINT uiRoomState = m_uiRoomState & ~ PvPCommon : : RoomState : : Starting ;
if ( g_pDivisionManager - > RequestGameRoom ( REQINFO_TYPE_PVP , m_uiIndex , m_iRandomSeed , m_uiMapIndex , 0 , 0 , true , false , 0 ) )
{
SetRoomState ( uiRoomState | PvPCommon : : RoomState : : Syncing ) ;
return ;
}
else
{
SetRoomState ( uiRoomState ) ;
CDNVillageConnection * pVillageCon = g_pDivisionManager - > GetVillageConnectionByVillageID ( m_cVillageID ) ;
if ( pVillageCon )
pVillageCon - > SendPvPStart ( ERROR_GENERIC_GAMECON_NOT_FOUND , GetVillageChannelID ( ) , m_uiIndex , 0 ) ;
}
}
USHORT CDNPvP : : _SelectRandomTeam ( )
{
UINT uiATeam = 0 ;
UINT uiBTeam = 0 ;
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
if ( g_pDivisionManager )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( * itor ) ;
if ( pUser )
{
if ( pUser - > GetPvPTeam ( ) = = PvPCommon : : Team : : A )
+ + uiATeam ;
else if ( pUser - > GetPvPTeam ( ) = = PvPCommon : : Team : : B )
+ + uiBTeam ;
else if ( pUser - > GetPvPTeam ( ) ! = PvPCommon : : Team : : Observer )
_DANGER_POINT ( ) ;
}
}
else
_DANGER_POINT ( ) ;
}
return ( uiATeam < = uiBTeam ) ? PvPCommon : : Team : : A : PvPCommon : : Team : : B ;
}
void CDNPvP : : _GetReadyUserCount ( UINT & ruiATeam , UINT & ruiBTeam )
{
ruiATeam = 0 ;
ruiBTeam = 0 ;
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
if ( g_pDivisionManager )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser )
{
if ( bIsReady ( pUser ) )
{
if ( pUser - > GetPvPTeam ( ) = = PvPCommon : : Team : : A )
+ + ruiATeam ;
else if ( pUser - > GetPvPTeam ( ) = = PvPCommon : : Team : : B )
+ + ruiBTeam ;
}
}
}
}
}
void CDNPvP : : _GetTeamUserCount ( UINT & ruiATeam , UINT & ruiBTeam )
{
ruiATeam = 0 ;
ruiBTeam = 0 ;
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
if ( g_pDivisionManager )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser )
{
if ( pUser - > GetPvPTeam ( ) = = PvPCommon : : Team : : A )
+ + ruiATeam ;
else if ( pUser - > GetPvPTeam ( ) = = PvPCommon : : Team : : B )
+ + ruiBTeam ;
}
}
}
}
UINT CDNPvP : : FindNewCaptain ( )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϶<EFBFBD> <CFB6> <EFBFBD> <20> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ѵ <EFBFBD> .
if ( m_uiRoomState & PvPCommon : : RoomState : : Playing )
{
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser & & ! pUser - > bIsObserver ( ) & & ! bIsCaptain ( * itor ) )
{
if ( pUser - > GetPvPUserState ( ) & PvPCommon : : UserState : : Playing )
return ( * itor ) ;
}
}
}
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser & & ! pUser - > bIsObserver ( ) & & ! bIsCaptain ( * itor ) )
return ( * itor ) ;
}
return 0 ;
}
UINT CDNPvP : : FindNewGroupCaptain ( UINT uiTeam )
{
if ( IsMode ( PvPCommon : : GameMode : : PvP_AllKill ) = = true )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϶<EFBFBD> <CFB6> <EFBFBD> <20> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ѵ <EFBFBD> .
if ( m_uiRoomState & ( PvPCommon : : RoomState : : Playing | PvPCommon : : RoomState : : Syncing ) )
{
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser & & pUser - > GetPvPTeam ( ) = = uiTeam & & ! pUser - > bIsPvPGroupCaptain ( ) )
{
if ( pUser - > GetPvPUserState ( ) & PvPCommon : : UserState : : Playing )
return ( * itor ) ;
}
}
}
for ( std : : list < UINT > : : iterator itor = m_listAccountDBID . begin ( ) ; itor ! = m_listAccountDBID . end ( ) ; + + itor )
{
CDNUser * pUser = g_pDivisionManager - > GetUserByAccountDBID ( ( * itor ) ) ;
if ( pUser & & pUser - > GetPvPTeam ( ) = = uiTeam & & ! pUser - > bIsPvPGroupCaptain ( ) )
return ( * itor ) ;
}
}
return 0 ;
}
# if defined(PRE_ADD_QUICK_PVP)
void CDNPvP : : AddListAccountDBID ( UINT uiAddAccountDBID )
{
m_listAccountDBID . push_back ( uiAddAccountDBID ) ;
}
# endif //#if defined(PRE_ADD_QUICK_PVP)