2024-12-21 10:04:04 +08:00
|
|
|
|
|
|
|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
|
#include "DNBreakIntoUserSession.h"
|
|
|
|
|
|
#include "DNGameRoom.h"
|
|
|
|
|
|
#include "DnGameTask.h"
|
|
|
|
|
|
#include "DnItemTask.h"
|
|
|
|
|
|
#include "DnPartyTask.h"
|
|
|
|
|
|
#include "GameSendPacket.h"
|
|
|
|
|
|
#include "PvPGameMode.h"
|
|
|
|
|
|
#include "MasterRewardSystem.h"
|
|
|
|
|
|
#include "DNMasterConnectionManager.h"
|
|
|
|
|
|
#include "DNWorldUserState.h"
|
|
|
|
|
|
#include "DNPvPGameRoom.h"
|
|
|
|
|
|
|
|
|
|
|
|
CDNBreakIntoUserSession::CDNBreakIntoUserSession( UINT uiUID, CDNRUDPGameServer* pServer, CDNGameRoom* pRoom )
|
|
|
|
|
|
: CDNUserSession( uiUID, pServer, pRoom ), m_bBreakIntoSession(true)
|
|
|
|
|
|
{
|
|
|
|
|
|
_SetGameRoomState( _GAME_STATE_READY2CONNECT );
|
|
|
|
|
|
m_uiNextGameRoomStateTick = pRoom->GetGameTick();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CDNBreakIntoUserSession::~CDNBreakIntoUserSession()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(PRE_ADD_MULTILANGUAGE)
|
|
|
|
|
|
void CDNBreakIntoUserSession::PreInitializeUser(WCHAR * wszAccountName, UINT nAccountDBID, UINT nSessionID, INT64 biCharacterDBID, int iTeam, int nWorldID, int nVillageID, bool bTutorial, bool bAdult, char cPCBangGrade, char cSelectedLanguage, TMemberVoiceInfo * pInfo/* = NULL*/)
|
|
|
|
|
|
#else //#if defined(PRE_ADD_MULTILANGUAGE)
|
|
|
|
|
|
void CDNBreakIntoUserSession::PreInitializeUser(WCHAR * wszAccountName, UINT nAccountDBID, UINT nSessionID, INT64 biCharacterDBID, int iTeam, int nWorldID, int nVillageID, bool bTutorial, bool bAdult, char cPCBangGrade, TMemberVoiceInfo * pInfo/* = NULL*/)
|
|
|
|
|
|
#endif //#if defined(PRE_ADD_MULTILANGUAGE)
|
|
|
|
|
|
{
|
|
|
|
|
|
#if defined(PRE_ADD_MULTILANGUAGE)
|
|
|
|
|
|
CDNUserSession::PreInitializeUser( wszAccountName, nAccountDBID, nSessionID, biCharacterDBID, iTeam, nWorldID, nVillageID, bTutorial, bAdult, cPCBangGrade, cSelectedLanguage, pInfo );
|
|
|
|
|
|
#else //#if defined(PRE_ADD_MULTILANGUAGE)
|
|
|
|
|
|
CDNUserSession::PreInitializeUser( wszAccountName, nAccountDBID, nSessionID, biCharacterDBID, iTeam, nWorldID, nVillageID, bTutorial, bAdult, cPCBangGrade, pInfo );
|
|
|
|
|
|
#endif //#if defined(PRE_ADD_MULTILANGUAGE)
|
|
|
|
|
|
|
|
|
|
|
|
bool bLessTeam = false;
|
|
|
|
|
|
// PvP <20><><EFBFBD>̰<EFBFBD> PvP<76>̺<EFBFBD>Ʈ<EFBFBD><C6AE><EFBFBD>϶<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
|
|
|
|
|
|
|
|
|
|
|
//rlkt 2016
|
|
|
|
|
|
/* if( GetGameRoom() && GetGameRoom()->bIsPvPRoom() )
|
|
|
|
|
|
{
|
|
|
|
|
|
if( static_cast<CDNPvPGameRoom*>(GetGameRoom())->GetEventRoomIndex() > 0 )
|
|
|
|
|
|
bLessTeam = true;
|
|
|
|
|
|
*/ if( static_cast<CDNPvPGameRoom*>(GetGameRoom())->GetRoomOptionBit()&PvPCommon::RoomOption::RandomTeam )
|
|
|
|
|
|
bLessTeam = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
if( bLessTeam == true && iTeam != PvPCommon::Team::Observer )
|
|
|
|
|
|
{
|
|
|
|
|
|
int iATeam = 0;
|
|
|
|
|
|
int iBTeam = 0;
|
|
|
|
|
|
for( UINT i=0 ; i<GetGameRoom()->GetUserCount() ; ++i )
|
|
|
|
|
|
{
|
|
|
|
|
|
CDNUserSession* pSession = GetGameRoom()->GetUserData(i);
|
|
|
|
|
|
if( pSession->GetTeam() == PvPCommon::Team::A )
|
|
|
|
|
|
++iATeam;
|
|
|
|
|
|
else if( pSession->GetTeam() == PvPCommon::Team::B )
|
|
|
|
|
|
++iBTeam;
|
|
|
|
|
|
}
|
|
|
|
|
|
int iBreakIntoATeam = 0;
|
|
|
|
|
|
int iBreakIntoBTeam = 0;
|
|
|
|
|
|
GetGameRoom()->GetBreakIntoUserTeamCount( iBreakIntoATeam, iBreakIntoBTeam );
|
|
|
|
|
|
iATeam += iBreakIntoATeam;
|
|
|
|
|
|
iBTeam += iBreakIntoBTeam;
|
|
|
|
|
|
|
|
|
|
|
|
SetTeam( iATeam > iBTeam ? PvPCommon::Team::B : PvPCommon::Team::A );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CDNBreakIntoUserSession::BreakIntoProcess()
|
|
|
|
|
|
{
|
|
|
|
|
|
ULONG uiCurTick = m_pGameRoom->GetGameTick();
|
|
|
|
|
|
unsigned long iCurTick2 = timeGetTime();
|
|
|
|
|
|
|
|
|
|
|
|
switch( m_uiGameRoomState )
|
|
|
|
|
|
{
|
|
|
|
|
|
case _GAME_STATE_READY2CONNECT:
|
|
|
|
|
|
{
|
|
|
|
|
|
if( IsConnected() || (uiCurTick > m_uiNextGameRoomStateTick+WAIT_FOR_ANOTHER_USER_TIME_LIMIT) )
|
|
|
|
|
|
{
|
|
|
|
|
|
_SetGameRoomState( _GAME_STATE_CONNECT2CHECKAUTH );
|
|
|
|
|
|
m_uiNextGameRoomStateTick = timeGetTime();
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case _GAME_STATE_CONNECT2CHECKAUTH:
|
|
|
|
|
|
{
|
|
|
|
|
|
if (IsCertified())
|
|
|
|
|
|
{
|
|
|
|
|
|
_SetGameRoomState( _GAME_STATE_CONNECT2LOAD );
|
|
|
|
|
|
m_uiNextGameRoomStateTick = 0;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(CHECKAUTHLIMITTERM < GetTickTerm(m_uiNextGameRoomStateTick, iCurTick2))
|
|
|
|
|
|
{
|
|
|
|
|
|
DetachConnection(L"_GAME_STATE_CONNECT2CHECKAUTH TimeOver"); // <20>߰<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʿ<EFBFBD> ??? (<28><><EFBFBD><EFBFBD> <20><><EFBFBD>·<EFBFBD> <20><><EFBFBD><EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD> ǥ<><C7A5><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ƴ<EFBFBD> ???)
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case _GAME_STATE_CONNECT2LOAD:
|
|
|
|
|
|
{
|
|
|
|
|
|
if( m_uiNextGameRoomStateTick == 0 )
|
|
|
|
|
|
{
|
|
|
|
|
|
//if( !IsConnected() )
|
|
|
|
|
|
// DetachConnection();
|
|
|
|
|
|
|
|
|
|
|
|
InitialUser();
|
|
|
|
|
|
m_uiNextGameRoomStateTick = uiCurTick + WAIT_FOR_LOAD_TIME_LIMIT;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( GetState() == SESSION_STATE_LOADED )
|
|
|
|
|
|
{
|
|
|
|
|
|
SendConnectedResult();
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(_HSHIELD)
|
|
|
|
|
|
if (GetAccountLevel() != AccountLevel_Developer){ // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(?)
|
|
|
|
|
|
SendMakeRequest(); // CRC <20><>û
|
|
|
|
|
|
}
|
|
|
|
|
|
#elif defined(_GPK)
|
|
|
|
|
|
SendGPKCode();
|
|
|
|
|
|
SendGPKAuthData();
|
|
|
|
|
|
#endif // _HSHIELD
|
|
|
|
|
|
|
|
|
|
|
|
_SetGameRoomState( _GAME_STATE_LOAD2SYNC );
|
|
|
|
|
|
m_uiNextGameRoomStateTick = uiCurTick + WAIT_FOR_LOAD_TIME_LIMIT;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case _GAME_STATE_LOAD2SYNC:
|
|
|
|
|
|
{
|
|
|
|
|
|
if( GetState() == SESSION_STATE_READY_TO_SYNC )
|
|
|
|
|
|
{
|
|
|
|
|
|
CDnGameTask* pGameTask = m_pGameRoom->GetGameTask();
|
|
|
|
|
|
CDnItemTask* pItemTask = m_pGameRoom->GetItemTask();
|
|
|
|
|
|
if( !pGameTask || !pItemTask )
|
|
|
|
|
|
DN_RETURN(false);
|
|
|
|
|
|
|
|
|
|
|
|
if( !m_pGameRoom->AddPartyStruct( this, false ) )
|
|
|
|
|
|
{
|
|
|
|
|
|
DetachConnection( L"PartyMax" );
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if( m_pGameRoom->GetMasterRewardSystem() )
|
|
|
|
|
|
m_pGameRoom->GetMasterRewardSystem()->RequestRefresh();
|
|
|
|
|
|
|
|
|
|
|
|
pItemTask->InitializePlayerItem( this );
|
|
|
|
|
|
pGameTask->OnInitializeBreakIntoActor( this, 0 );
|
|
|
|
|
|
m_pGameRoom->CheckDiePlayer( this );
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><>Ƽ<EFBFBD>ʴ<EFBFBD><CAB4>ΰ<EFBFBD><CEB0><EFBFBD> <20><>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD>Ÿ<EFBFBD><C5B8> <20><><EFBFBD>⸦ <20><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>.
|
|
|
|
|
|
//SendBreakIntoUser <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!
|
|
|
|
|
|
int nIdx = GetGameRoom()->AdjustBreakintoUser(GetCharacterName(), GetSessionID(), ERROR_NONE, false);
|
|
|
|
|
|
if (nIdx >= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetPartyMemberIndex(nIdx);
|
|
|
|
|
|
GetGameRoom()->SetPartyMemberIndex(nIdx, GetSessionID());
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (GetGameRoom()->bIsOccupationMode())
|
|
|
|
|
|
{
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΰ<EFBFBD><CEB0>쿡<EFBFBD><ECBFA1> <20><><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF><EFBFBD> <20>ε<EFBFBD><CEB5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؿ´<D8BF> <20><> <20><>ġ<EFBFBD><C4A1><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><>
|
|
|
|
|
|
int nPvPTeamSlotIndex = GetPartyMemberIndex();
|
|
|
|
|
|
if (nPvPTeamSlotIndex >= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (GetGameRoom()->SetPartyMemberIndex(nPvPTeamSlotIndex, GetSessionID(), GetTeam()) == false)
|
|
|
|
|
|
_DANGER_POINT(); //<2F><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƾƾƾƾƾƾƾӾƤ<D3BE><C6A4>ƾƾƾƾ<C6BE>
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (GetTeam() != PvPCommon::Team::Observer)
|
|
|
|
|
|
_DANGER_POINT(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴѵ<C6B4> <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>! <20>̷<EFBFBD> <20>ȵ<EFBFBD><C8B5><EFBFBD>!
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
m_pGameRoom->SendBreakIntoUser( this ); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
m_pGameRoom->SetSync2SyncStateTemplateMethod( 0, this ); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
_SetGameRoomState( _GAME_STATE_SYNC2SYNC );
|
|
|
|
|
|
m_uiNextGameRoomStateTick = uiCurTick + GOGO_SING_TO_PLAY_FOR_WAIT_TIME_LIMIT;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case _GAME_STATE_SYNC2SYNC:
|
|
|
|
|
|
{
|
|
|
|
|
|
_SetGameRoomState( _GAME_STATE_SYNC2PLAY );
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case _GAME_STATE_SYNC2PLAY:
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>
|
|
|
|
|
|
if( GetState() == SESSION_STATE_READY_TO_PLAY )
|
|
|
|
|
|
{
|
|
|
|
|
|
#if defined( PRE_ADD_NAMEDITEM_SYSTEM )
|
|
|
|
|
|
m_pGameRoom->SendCompleteBreakIntoUser(this);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
SetMapIndex( m_pGameRoom->GetGameTask()->GetMapTableID() );
|
|
|
|
|
|
m_pGameRoom->SyncMonster( this );
|
|
|
|
|
|
m_pGameRoom->SyncNpc( this );
|
|
|
|
|
|
m_pGameRoom->SyncProp( this );
|
|
|
|
|
|
m_pGameRoom->OnSync2Sync( this );
|
|
|
|
|
|
m_pGameRoom->SyncPlayer( this );
|
|
|
|
|
|
m_pGameRoom->SyncGate( this );
|
|
|
|
|
|
#if defined( PRE_PARTY_DB )
|
|
|
|
|
|
if (m_pGameRoom->GetGameType() == REQINFO_TYPE_PARTY)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pGameRoom->AddPartyMemberDB( this );
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
#if defined( PRE_WORLDCOMBINE_PVP )
|
|
|
|
|
|
if( m_pGameRoom->bIsWorldPvPRoom() )
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pGameRoom->AddDBWorldPvPRoomMember( this );
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
// <20><><EFBFBD>Կ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ <20><><EFBFBD><EFBFBD>ȭ
|
|
|
|
|
|
if( g_pMasterConnectionManager )
|
|
|
|
|
|
{
|
|
|
|
|
|
DNVector(std::wstring) vUserName;
|
|
|
|
|
|
vUserName.push_back( GetCharacterName() );
|
|
|
|
|
|
g_pMasterConnectionManager->SendWorldUserState( GetWorldSetID(), vUserName, GetMapIndex() );
|
|
|
|
|
|
}
|
|
|
|
|
|
if( g_pWorldUserState )
|
|
|
|
|
|
g_pWorldUserState->UpdateUserState( GetCharacterName(), GetCharacterDBID(), _LOCATION_GAME, _COMMUNITY_NONE, -1, GetMapIndex() );
|
|
|
|
|
|
|
|
|
|
|
|
SetSessionState( SESSION_STATE_GAME_PLAY );
|
|
|
|
|
|
SetSecurityUpdateFlag( true );
|
|
|
|
|
|
_SetGameRoomState( _GAME_STATE_PLAY );
|
|
|
|
|
|
FlushPacketQueue();
|
|
|
|
|
|
m_pGameRoom->OnRequestSyncStartMsg( this );
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>˸<EFBFBD>
|
|
|
|
|
|
m_pGameRoom->OnSuccessBreakInto( this );
|
|
|
|
|
|
|
|
|
|
|
|
m_pGameRoom->SendPosition( this );
|
|
|
|
|
|
m_pGameRoom->SendDropItemList( this );
|
|
|
|
|
|
if( m_hActor )
|
|
|
|
|
|
{
|
|
|
|
|
|
m_hActor->InsertOctreeNode();
|
|
|
|
|
|
m_hActor->SetOctreeUpdate( true );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (GetGameRoom()->GetPartyIndex() > 0)
|
|
|
|
|
|
m_pSession->SendJoinParty(ERROR_NONE, GetGameRoom()->GetPartyIndex(), GetGameRoom()->GetPartyName() );
|
|
|
|
|
|
|
|
|
|
|
|
if( CDnPartyTask::IsActive(GetGameRoom()) )
|
|
|
|
|
|
CDnPartyTask::GetInstance(GetGameRoom()).UpdateGateInfo();
|
|
|
|
|
|
GetGameRoom()->SendRefreshParty(GetSessionID(), GetProfile()->bOpenPublic == true ? GetProfile() : NULL);
|
|
|
|
|
|
GetGameRoom()->UpdateAppliedEventValue();
|
|
|
|
|
|
GetGameRoom()->SendChatRoomInfo( this );
|
|
|
|
|
|
CDnWorld *pWorld = GetGameRoom()->GetWorld();
|
|
|
|
|
|
if( pWorld && pWorld->GetDragonNestType() != eDragonNestType::None )
|
|
|
|
|
|
{
|
|
|
|
|
|
CDNGameRoom::PartyStruct* pStruct = GetGameRoom()->GetPartyData( this );
|
|
|
|
|
|
if( pStruct )
|
|
|
|
|
|
{
|
|
|
|
|
|
SendStartDragonNest( pWorld->GetDragonNestType(), pStruct->nUsableRebirthCoin );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
m_bBreakIntoSession = false; //<--<2D><><EFBFBD><EFBFBD> <20>극<EFBFBD>̽<EFBFBD><CCBD><EFBFBD> <20>ϴܿ<CFB4> <20><>ġ<EFBFBD><C4A1><EFBFBD><EFBFBD><EFBFBD>ּ<EFBFBD><D6BC><EFBFBD>~
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|