#include "StdAfx.h" #include "DnPartyTask.h" #include "GameSendPacket.h" #include "DnWorld.h" #include "DnWorldGrid.h" #include "DnWorldSector.h" #include "EtWorldEventControl.h" #include "EtWorldEventArea.h" #include "TaskManager.h" #include "DnGameTask.h" #include "DNTableFile.h" #include "DnTableDB.h" #include "DNGameDataManager.h" #include "DnPlayerActor.h" #include "DNGameRoom.h" #include "DNUserSession.h" #include "DNMasterConnection.h" #include "DNMasterConnectionManager.h" #include "DNLogConnection.h" #include "DnDropItem.h" #include "DnItemTask.h" #include "DNDBConnectionManager.h" #include "DNDBConnection.h" #include "DNIsolate.h" #if defined( PRE_ADD_NEWCOMEBACK ) #include "DnBlow.h" #endif CDnPartyTask::CDnPartyTask(CDNGameRoom * pRoom) : CTask( pRoom ) , CMultiSingleton( pRoom ) { //m_nPartyIndex = 0; m_nEnteredGateIndex = -1; m_bSyncComplete = false; m_nRandomSeed = 0; m_bWaitGate = false; //m_nZoneCountTick = 0; //m_nZoneEnterMapIdx = m_nZoneEnterGate = -1; m_bHoldSharingReversionItem = false; } CDnPartyTask::~CDnPartyTask() { } bool CDnPartyTask::Initialize() { m_Random.srand(timeGetTime()); return true; } void CDnPartyTask::Process( LOCAL_TIME LocalTime, float fDelta ) { ULONG nCurTick = GetRoom()->GetGameTick(); DNVector(_KICKMEMBER)::iterator ii; for (ii = m_KickList.begin(); ii != m_KickList.end(); ) { if ((*ii).nKickTick < nCurTick && GetRoom()->GetRoomState() == _GAME_STATE_PLAY) { int nSeq = 0; CDNGameRoom::PartyStruct * pStruct = GetRoom()->GetPartyDatabySessionID((*ii).Kick.nSessionID, nSeq); if (pStruct) { pStruct->pSession->SendBackToVillage( true, (*ii).Kick.cKickKind ); } ii = m_KickList.erase(ii); } else ii++; } ProcessGetReversionItemList(LocalTime, fDelta); /*if (m_nZoneCountTick != 0 && GetRoom()->GetGameTick() > m_nZoneCountTick) { CDnGameTask *pTask = (CDnGameTask *)CTaskManager::GetInstance(GetRoom()).GetTask( "GameTask" ); int nStageConstructionLevel = -1; if( nStageConstructionLevel == -1 ) nStageConstructionLevel = pTask->GetStageConstructionLevel(); if( nStageConstructionLevel == -1 ) nStageConstructionLevel = 0; m_nRandomSeed = CRandom::Seed(GetRoom()); m_nEnteredGateIndex = m_nZoneEnterGate; pTask->SetGateIndex(m_nZoneEnterGate); GetRoom()->InitStateAndSync( m_nZoneEnterMapIdx, m_nZoneEnterGate, CRandom::Seed(GetRoom()), nStageConstructionLevel, true ); m_nZoneCountTick = 0; m_nZoneEnterMapIdx = m_nZoneEnterGate = -1; }*/ } int CDnPartyTask::OnDispatchMessage(CDNUserSession * pSession, int nMainCmd, int nSubCmd, char *pData, int nLen ) { switch( nMainCmd ) { case CS_ROOM: return OnRecvRoomMessage(pSession, nSubCmd, pData, nLen ); case CS_PARTY: return OnRecvPartyMessage(pSession, nSubCmd, pData, nLen ); default : return ERROR_UNKNOWN_HEADER; } return ERROR_NONE; } int CDnPartyTask::OnRecvRoomMessage(CDNUserSession * pSession, int nSubCmd, char *pData, int nLen ) { switch( nSubCmd ) { case eRoom::CS_SYNC_WAIT: return OnRecvRoomSyncWait( pSession, (CSSyncWait*)pData, nLen ); } return ERROR_UNKNOWN_HEADER; } int CDnPartyTask::OnRecvPartyMessage( CDNUserSession *pSession, int nSubCmd, char *pData, int nLen ) { if (pSession->GetState() != SESSION_STATE_GAME_PLAY || pSession->IsCertified() == false) { g_Log.Log(LogType::_MOVEPACKET_SEQ, pSession, L"OnRecvPartyMessage RState[%d] UState[%d] SCMD[%d]\n", GetRoom()->GetRoomState(), pSession->GetState(), nSubCmd); return ERROR_NONE; } switch( nSubCmd ) { case eParty::CS_REFRESHGATEINFO: return OnRecvPartyRefreshGateInfo( pSession, (CSRefreshGateInfo *)pData, nLen ); case eParty::CS_STARTSTAGE: return OnRecvPartyStartStage( pSession, (CSStartStage *)pData, nLen ); case eParty::CS_CANCELSTAGE: return OnRecvPartyCancelStage( pSession, pData, nLen ); case eParty::CS_PARTYMEMBER_KICK: return OnRecvPartyMemberKick(pSession, pData, nLen); case eParty::CS_SELECTDUNGEON: return OnRecvPartySelectDungeon(pSession, pData, nLen); case eParty::CS_PARTYLEADER_SWAP: return OnRecvPartyLeaderSwap(pSession, pData, nLen); case eParty::CS_JOINGETREVERSEITEM: return OnRecvPartyJoinGetReversionItem(pSession, pData); case eParty::CS_ABSENT: return OnRecvPartyMemberAbsent(pSession, (CSMemberAbsent*)pData, nLen); case eParty::CS_PARTYINVITE: return OnRecvPartyInviteMember(pSession, (CSInvitePartyMember*)pData, nLen); case eParty::CS_SWAPMEMBERINDEX: return OnRecvPartySwapMemberIndex(pSession, (CSPartySwapMemberIndex*)pData, nLen); #if defined( PRE_PARTY_DB ) case eParty::CS_PARTYMODIFY: return OnRecvPartyModify( pSession, (CSPartyInfoModify*)pData, nLen ); #endif // #if defined( PRE_PARTY_DB ) #if defined(PRE_MOD_REQ_JOIN_PARTY_ANSWER_MSG_APP) case eParty::CS_PARTYASKJOINDECISION: return OnRecvPartyAskJoinDecision( pSession, (CSPartyAskJoinDecision*)pData, nLen ); #endif case eParty::CS_GAMETOGAMESTAGE_ENTER: return OnRecvGameToGameStageEnter(pSession, (CSGameToGameStageEnter *)pData, nLen); } _DANGER_POINT(); return ERROR_UNKNOWN_HEADER; } int CDnPartyTask::OnRecvRoomSyncWait( CDNUserSession *pSession, CSSyncWait *pPacket, int nLen ) { if (sizeof(CSSyncWait) != nLen) return ERROR_INVALIDPACKET; if (GetRoom()->GetRoomState() == _GAME_STATE_SYNC2SYNC) { pSession->SetSessionState(SESSION_STATE_SYNC_READY_2_DELAY); #ifdef _DEBUG g_Log.Log(LogType::_NORMAL, pSession, L"on PT_GAME_SYNC_WAIT : %s\n", pSession->GetCharacterName()); #endif return ERROR_NONE; } pSession->FlushStoredPacket(); pSession->FlushPacketQueue(); for( DWORD i=0; iGetSessionID() ); int iPrevState = pSession->GetState(); pSession->SetSessionState(SESSION_STATE_READY_TO_PLAY); #ifdef _DEBUG g_Log.Log(LogType::_NORMAL, pSession, L"on PT_GAME_SYNC_WAIT[2] : %s RoomState:%d SessionState=%d\n", pSession->GetCharacterName(), GetRoom()->GetRoomState(), iPrevState ); #endif return ERROR_NONE; } int CDnPartyTask::OnRecvPartyRefreshGateInfo( CDNUserSession *pSession, CSRefreshGateInfo *pPacket, int nLen ) { if (sizeof(CSRefreshGateInfo) != nLen) return ERROR_INVALIDPACKET; CDNGameRoom::PartyStruct *pStruct = GetPartyData( pSession ); if( pStruct ) { if( pSession->GetActorHandle() ) { CDnPlayerActor *pPlayer = (CDnPlayerActor*)pSession->GetActorHandle().GetPointer(); if( pPlayer ) pPlayer->RecvPartyRefreshGateInfo( pPacket->Position ); } pStruct->nEnteredGateIndex = ( pPacket->boEnter ) ? GetCheckGateIndex( pSession ) : -1; if (CheckAndRequestGateIndex(pStruct->nEnteredGateIndex, pSession->GetPartyMemberIndex()) == false) pStruct->nEnteredGateIndex = -1; } else _DANGER_POINT(); //¾ø¾îµµ µÇ´Â°Ç°¡¿ä? return ERROR_NONE; } //rlkt dirty fix int CDnPartyTask::OnRecvGameToGameStageEnter(CDNUserSession *pSession, CSGameToGameStageEnter *pPacket, int nLen) { //if (sizeof(CSGameToGameStageEnter) != nLen) // return ERROR_INVALIDPACKET; //CDnGameTask *pTask = (CDnGameTask *)CTaskManager::GetInstance(GetRoom()).GetTask("GameTask"); //int nMapIndex = pTask->GetMapTableID(); //GateStruct *pStruct = CDnWorld::GetInstance(GetRoom()).GetGateStruct(m_nEnteredGateIndex); //if (m_nEnteredGateIndex == -1 || pStruct == NULL) { // for (DWORD i = 0; iSendCancelStage(ERROR_PARTY_STARTSTAGE_FAIL); // g_Log.Log(LogType::_ERROR, pSession, L"°ÔÀÓÀ» ½ÃÀÛÇÒ ¼ö ¾ø½À´Ï´Ù°¡ ÀÚ²Ù ¶á´Ù À̰гª¿À¸é .......\n"); // } // return ERROR_NONE; //} //return ERROR_NONE; ////cSelectMapIndex /* if (sizeof(CSGameToGameStageEnter) != iLen) return ERROR_INVALIDPACKET; int TargetMapIndex = -1; int TargetGateNo = -1; char m_cGateSelect = pPacket->cSelectMapIndex; SendSelectStage(m_cGateSelect); TargetMapIndex = GetTargetMapIndex(); TargetGateNo = g_pDataManager->GetGateNoByGateNo(GetMapIndex(), m_cGateNo, m_cGateSelect); if (TargetMapIndex <= 0 || m_pField == NULL) { if (GetPartyID() > 0) { CDNParty *pParty = g_pPartyManager->GetParty(GetPartyID()); if (pParty == NULL) return ERROR_PARTY_STARTSTAGE_FAIL; pParty->SendAllCancelStage(ERROR_PARTY_STARTSTAGE_FAIL); } else { m_cGateNo = -1; m_cGateSelect = -1; return ERROR_PARTY_STARTSTAGE_FAIL; } return ERROR_NONE; } // ÆÄƼ°¡ Ready µÈ ÈÄ¿¡ Ŭ¶óÀÌ¾ðÆ®¿¡¼­ ÀÓÀÇ·Î ¿òÁ÷À̰ųª ÇßÀ» °æ¿ì ¿òÁ÷ÀÎ ³ðÀÌ RefreshGateInfo ¸¦ ¿äûÇϸ鼭 // ±× Ŭ¶óÀ̾ðÆ®ÀÇ GateIndex °¡ -1 ÀÌ µÇ¹ö¸°´Ù. // ±×·² °æ¿ì ÆÄƼ¿ø Àü¿øÀÌ ½ÃÀÛÀÌ ¾ÈµÇ±â¶«¿¡ ÀÏ´Ü ¿©±â¼­ ÆÄƼ¿øÁß Ready °¡ Ç®¸°³ðÀÌ ÀÖÀ¸¸é ½ÃÀÛÀ» ¸øÇÏ°Ô ÇÏÀÚ. // ȤÀº StartStage ÇÒ¶§ ´Ù½Ã GateIndex ¿Í RandomSeed ¸¦ º¸³»Á൵ µÇ´Âµ¥.. ÀÌ·² °æ¿ì Ç®¸°³ðÀÌ °Å·¡µûÀ§¸¦ Çϰí // ÀÖ´Ù°¡ °­Á¦·Î À̵¿µÉ ½Ã ¹«½¼ÀÏÀÌ ÀϾÁö ¸ð¸£´Ï ÀÏ´ÜÀº Cancel À» ½ÃŰ´Â ÂÊÀ¸·Î ÇØµÎ´Â °ÍÀÌ ÁÁÀ»µí ÇÔ. // ÀÚ±âÀÚ½Å(¸®´õ ȤÀº °³ÀÎ) Àº À§¿¡¼­ ÀÌ¹Ì °ÔÀÌÆ®°¡ -1 ÀÏ °æ¿ì¿¡ TargetMapIndex °¡ -1 ³ª¿À¸é¼­ Ä˽½µÇ¹Ç·Î ¹«½Ã~ if (g_pMasterConnection->GetActive() == false) return ERROR_GENERIC_MASTERCON_NOT_FOUND; const sChannelInfo * pChannelInfo = g_pMasterConnection->GetChannelInfo(GetChannelID()); if (pChannelInfo == NULL) return ERROR_PARTY_STARTSTAGE_FAIL; int nFarmMapID = -1; bool bEnterFarm = false; bEnterFarm = g_pFarm->GetFarmMapID(pPacket->nFarmDBID, nFarmMapID); GameTaskType::eType TaskType = m_pField->GetGameTaskType(); if (m_nGateType > 0) TaskType = (GameTaskType::eType)m_nGateType; CDNParty* pParty = NULL; #if defined(_FINAL_BUILD) if ((GetAccountLevel() <= AccountLevel_QA) && (GetAccountLevel() >= AccountLevel_New)) { // GM Àº ÆÐ½ºÇÑ´Ù. } else #endif // #if defined(_FINAL_BUILD) { if (!g_pDataManager->CheckChangeMap(GetMapIndex(), TargetMapIndex)) { WCHAR wszBuf[100]; wsprintf(wszBuf, L"VILLAGE Prev[%d]->Next[%d]", GetMapIndex(), TargetMapIndex); GetDBConnection()->QueryAddAbuseLog(this, ABUSE_MOVE_SERVERS, wszBuf); } } if (GetPartyID() > 0) { if (bEnterFarm) return ERROR_PARTY_STARTSTAGE_FAIL; if (m_boPartyLeader == false) return ERROR_PARTY_STARTSTAGE_FAIL; pParty = g_pPartyManager->GetParty(GetPartyID()); if (pParty == NULL) return ERROR_PARTY_STARTSTAGE_FAIL; //ÆÄƼ»óŶó¸é Áߺ¹À̵¿Ã¼Å©¸¦ ÀüÀ¯Àú¿¡ °Éó¼­ ÇØº¸ÀÚ if (pParty->CheckPartyUserStartFlag() == false) { g_Log.Log(LogType::_GAMECONNECTLOG, this, L"CS_STARTSTAGE Repetitive Move\n"); return ERROR_PARTY_STARTSTAGE_FAIL; } if (pParty->DiffMemberGateNo(m_cGateNo)) { if (g_pMasterConnection && g_pMasterConnection->GetActive()) { pParty->SetStartGame(true); pParty->SendSelectStage(m_cGateSelect); g_pMasterConnection->SendReqGameID(TaskType, REQINFO_TYPE_PARTY, pParty->GetPartyID(), GetChannelID(), pParty->GetRandomSeed(), GetMapIndex(), m_cGateNo, pPacket->Difficulty, false, pParty, 0, m_cGateSelect); // GameID¸¦ ¿äû } else { pParty->SendAllCancelStage(ERROR_PARTY_STARTSTAGE_FAIL); return ERROR_NONE; } } else { pParty->SendAllCancelStage(ERROR_PARTY_STARTSTAGE_FAIL); return ERROR_NONE; } } else { if (g_pMasterConnection && g_pMasterConnection->GetActive()) { if (bEnterFarm) { #if defined( PRE_ADD_FARM_DOWNSCALE ) int iAttr = Farm::Attr::None; if (g_pFarm->GetFarmAttr(pPacket->nFarmDBID, iAttr) == false) return ERROR_NONE; #if defined( PRE_ADD_VIP_FARM ) if (iAttr&Farm::Attr::Vip) { if (bIsFarmVip() == false) return ERROR_FARM_INVALID_VIP; } #endif // #if defined( PRE_ADD_VIP_FARM ) if (iAttr&Farm::Attr::GuildChampion) { // ±æµå³óÀå ÀÔÀå °Ë»ç if (GetGuildUID().IsSet() == false || g_pGuildWarManager->GetPreWinGuildUID().IsSet() == false || g_pGuildWarManager->GetPreWinGuildUID() != GetGuildUID()) return ERROR_FARM_ENTERANCE_CONDITION; } SetLastSubVillageMapIndex(GetMapIndex()); g_pMasterConnection->SendReqGameID(GameTaskType::Farm, REQINFO_TYPE_FARM, m_nAccountDBID, GetChannelID(), timeGetTime(), nFarmMapID, 0, CONVERT_TO_DUNGEONDIFFICULTY(0), true, NULL, pPacket->nFarmDBID); } else { g_pMasterConnection->SendReqGameID(TaskType, REQINFO_TYPE_SINGLE, m_nAccountDBID, GetChannelID(), m_nSingleRandomSeed, GetMapIndex(), m_cGateNo, pPacket->Difficulty, false, NULL, 0, m_cGateSelect); // GameID¸¦ ¿äû } } else return ERROR_PARTY_STARTSTAGE_FAIL; } //¿©±â±îÁö ¿À¸é ¸¶½ºÅÍ¿¡ º¸³½°ÍÀÌ´Ù. ¸®Åϸ޼¼Áö¸¦ ¹Þ±âÀü±îÁö´Â Á¦ÇÑ󸮸¦ À§ÇÑ Ç÷¡±×¼¼ÆÃÇØÁÖÀÚ if (pParty) { //pParty°¡ À¯È¿ÇÏ´Ù¸é ÆÄÆ¼´ÜÀ§ À̵¿ÀÌ ÀÌ·ç¾îÁø °ÍÀÌ´Ù. ÆÄƼÀ¯ÀúµéÀÇ Ç÷¡±×¸¦ ¹Ù²Ù¾î ÁØ´Ù. pParty->SetPartyUserStartFlag(true); } else { //¾Æ´Ï¶ó¸é °³ÀÎÀ̵¿ m_bIsStartGame = true; } g_Log.Log(LogType::_NORMAL, this, L"[ADBID:%u, CDBID:%I64d, SID:%u, ObjID:%u] [CS_STARTSTAGE] TargetMap:%d, MapIndex:%d GateNo:%d\r\n", m_nAccountDBID, m_biCharacterDBID, GetSessionID(), m_BaseData.nObjectID, TargetMapIndex, GetMapIndex(), m_cGateNo); return ERROR_NONE;*/ return ERROR_NONE; } int CDnPartyTask::OnRecvPartyStartStage( CDNUserSession *pSession, CSStartStage *pPacket, int nLen ) { if (sizeof(CSStartStage) != nLen) return ERROR_INVALIDPACKET; m_bWaitGate = false; //ÇÃ·Î¿ì º¯°æ ¿ä ŸÀֿ̹¡ ¸¶½ºÅÍ¿¡ ¹°¾î º¾´Ï´Ù. CDnGameTask *pTask = (CDnGameTask *)CTaskManager::GetInstance(GetRoom()).GetTask( "GameTask" ); if( pTask->IsPartyLeader( pSession ) == false ) return ERROR_NONE; int nMapIndex = pTask->GetMapTableID(); GateStruct *pStruct = CDnWorld::GetInstance(GetRoom()).GetGateStruct( m_nEnteredGateIndex ); if( m_nEnteredGateIndex == -1 || pStruct == NULL ) { for( DWORD i=0; iSendCancelStage( ERROR_PARTY_STARTSTAGE_FAIL ); g_Log.Log(LogType::_ERROR, pSession, L"°ÔÀÓÀ» ½ÃÀÛÇÒ ¼ö ¾ø½À´Ï´Ù°¡ ÀÚ²Ù ¶á´Ù À̰гª¿À¸é .......\n"); } return ERROR_NONE; } TDUNGEONDIFFICULTY StageDifficulty = pPacket->Difficulty; if( StageDifficulty >= Dungeon::Difficulty::Max ) StageDifficulty = pTask->GetStageDifficulty(); if( StageDifficulty < Dungeon::Difficulty::Easy ) StageDifficulty = Dungeon::Difficulty::Easy; switch( pStruct->MapType ) { case GlobalEnum::eMapTypeEnum::MAP_VILLAGE: { // ¿î¿µÀÚ³­ÀÔ °°Àº °æ¿ì À¯Àú°¡ ¸¶À»·Î µ¹¾Æ°¥ ¶§ °°ÀÌ º¸³»ÁØ´Ù. if (g_pMasterConnectionManager->SendRequestNextVillageInfo(pSession->GetWorldSetID(), nMapIndex, m_nEnteredGateIndex, pPacket->bReturnVillage, GetRoom()) == false) { for( DWORD i=0; iSendCancelStage( ERROR_GENERIC_MASTERCON_NOT_FOUND ); } break; } case GlobalEnum::eMapTypeEnum::MAP_WORLDMAP: // ¿©±â¼­µÎ ³ªÁß¿¡ ¿ùµå°£ À̵¿ÀÌ Á¤¸» °¡´ÉÇÑÁö Ã¼Å©ÇØÁÖÀÚ. #if defined(PRE_FIX_INITSTATEANDSYNC) GetRoom()->ReserveInitStateAndSync( nMapIndex, m_nEnteredGateIndex, m_nRandomSeed, StageDifficulty, false ); #else GetRoom()->InitStateAndSync( nMapIndex, m_nEnteredGateIndex, m_nRandomSeed, StageDifficulty, false ); #endif //#if defined(PRE_FIX_INITSTATEANDSYNC) break; case GlobalEnum::eMapTypeEnum::MAP_DUNGEON: { if (GetRoom()->IsInviting()) { for( DWORD i=0; iSendCancelStage( ERROR_PARTY_STARTSTAGE_FAIL ); return ERROR_NONE; } #if defined( PRE_PARTY_DB ) if( GetRoom()->bIsExistBreakIntoUser() ) { for( DWORD i=0; iSendCancelStage( ERROR_PARTY_STARTSTAGE_FAIL ); return ERROR_NONE; } #endif // #if defined( PRE_PARTY_DB ) #if defined (PRE_WORLDCOMBINE_PARTY) if( GetRoom()->bIsWorldCombineParty()) { TDUNGEONDIFFICULTY TargetDifficulty = GetRoom()->GetPartyDifficulty(); if (TargetDifficulty != StageDifficulty && TargetDifficulty != Dungeon::Difficulty::Max) { for( DWORD i=0; iSendCancelStage( ERROR_PARTY_STARTSTAGE_FAIL ); return ERROR_NONE; } } #endif // #if defined (PRE_WORLDCOMBINE_PARTY) bool bDirectConnect = false; int nGateIndex = m_nEnteredGateIndex; switch( CDnWorld::GetInstance(GetRoom()).GetMapType() ) { case EWorldEnum::MapTypeDungeon: // ±âÁ¸¿¡ ´øÀüÀÌ¿´À¸¸é °è¼ÓÇØ¼­ ´øÀüÀÇ ·¹º§À» À̾¾ßÇÑ´Ù. StageDifficulty = pTask->GetStageDifficulty(); break; case EWorldEnum::MapTypeWorldMap: case EWorldEnum::MapTypeVillage: // ±âÁ¸¿¡ ¿ùµå¸Ê ȤÀº ¸¶À»ÀÌ¿´À¸¸é // ¿©±â¼­ ½ÃÀÛÇÒ¶§ Àá±ñ üũ.. Ŭ¶ó¹ÏÀ¸¸é ¾ÈµÇ´Ï.. ¿ùµå¸Ê -> ´øÀü µé¾î°¥¶§¸¸ üũÇÏÀÚ. // ¸®ÅϵǸé ÇÒ ¼ö ¾ø´Â ·¹º§À» ¼±ÅÃÇ߰ųª Á¦ÇÑ·¹º§¿¡ °É¸®´Âµ¥µÎ ½ÃÀÛÇѰŴÙ. bool bCheckFatigue = true; #if defined(PRE_ADD_WORLD_EVENT) // ÀÌ°Ç ¾ø¾î Áý´Ï´Ù. #else TEvent * pEvent = GetRoom()->GetApplyEvent(_EVENT_1_FATIGUE); if (pEvent) bCheckFatigue = false; #endif //#if defined(PRE_ADD_WORLD_EVENT) if( m_nEnteredGateIndex != -1 ) { if( pStruct->MapType == EWorldEnum::MapTypeDungeon ) { DungeonGateStruct *pDungeonGate = NULL; short nCancelCode = ERROR_NONE; //bool bCancel = false; if( pStruct->nMapIndex >= DUNGEONGATE_OFFSET ) { pDungeonGate = (DungeonGateStruct *)pStruct; if( pPacket->cSelectDungeonIndex < 0 || pPacket->cSelectDungeonIndex >= (char)pDungeonGate->pVecMapList.size() ) nCancelCode = ERROR_PARTY_STARTSTAGE_FAIL; //bCancel = true; else { pDungeonGate = (DungeonGateStruct *)pDungeonGate->pVecMapList[pPacket->cSelectDungeonIndex]; nGateIndex = pDungeonGate->cStartGateIndex; nMapIndex = pDungeonGate->nMapIndex; bDirectConnect = true; pSession->VerifyValidMap(nMapIndex); } } else { pDungeonGate = (DungeonGateStruct *)pStruct; } if( pDungeonGate->nFatigue[ StageDifficulty ] == 0 ) bCheckFatigue = false; // ÇǷεµ üũ if (bCheckFatigue) { if (CheckPartyFatigue() == false) //´øÀüÀ̶ó¸é ÇǷεµ üũ Çѹø ÇØº»´Ù. { for( DWORD i=0; iSendCancelStage( ERROR_PARTY_STARTSTAGE_FAIL_FATIGUE_SHORTAGE ); return ERROR_NONE; } } switch( pTask->GetGameTaskType() ) { case GameTaskType::DarkLair: StageDifficulty = Dungeon::Difficulty::Abyss; break; } #if defined(PRE_ADD_CHALLENGE_DARKLAIR) if( pDungeonGate->cCanDifficult[ StageDifficulty ] != TRUE ) nCancelCode = ERROR_PARTY_STARTSTAGE_FAIL; if( nCancelCode == ERROR_NONE ) { EWorldEnum::PermitGateEnum PermitFlag = EWorldEnum::PermitEnter; if( g_pDataManager->IsCloseGateByTime(nMapIndex) ) PermitFlag = EWorldEnum::PermitClose; if(PermitFlag == EWorldEnum::PermitEnter) PermitFlag = pDungeonGate->CanEnterDungeon( GetRoom()); if( PermitFlag != EWorldEnum::PermitEnter ) { if( PermitFlag & EWorldEnum::PermitLessPlayerLevel ) nCancelCode = ERROR_PARTY_STARTSTAGE_FAIL_ACTLEVEL_SHORTAGE; else if( PermitFlag & EWorldEnum::PermitExceedTryCount ) nCancelCode = ERROR_PARTY_STARTSTAGE_FAIL_EXCEED_TRY_COUNT; else if( PermitFlag & EWorldEnum::PermitNotEnoughItem ) nCancelCode = ERROR_PARTY_STARTSTAGE_FAIL_DUNGEONNEEDITEM_SHORTAGE; else if( PermitFlag & EWorldEnum::PermitClose ) nCancelCode = ERROR_PARTY_STARTSTAGE_FAIL_NOT_AVAILABLE_TIME; else nCancelCode = ERROR_PARTY_STARTSTAGE_FAIL; } } #else if( nCancelCode == ERROR_NONE && ( pDungeonGate->cCanDifficult[ StageDifficulty ] != TRUE || pDungeonGate->CanEnterDungeon( GetRoom() ) != EWorldEnum::PermitEnter ) ) { nCancelCode = ERROR_PARTY_STARTSTAGE_FAIL_ACTLEVEL_SHORTAGE; } #endif //#if defined(PRE_ADD_CHALLENGE_DARKLAIR) if( nCancelCode != ERROR_NONE ) { for( DWORD i=0; iSendCancelStage( nCancelCode ); } return ERROR_NONE; } #if defined(PRE_ADD_CP_RANK) // ¾îºñ½º À϶§´Â º£½ºÆ® ·©Å· Á¶È¸ÇÑ´Ù. if(pTask->GetGameTaskType() != GameTaskType::DarkLair && StageDifficulty == Dungeon::Difficulty::Abyss) { CDNUserSession* pSession = NULL; bool bFirst = true; for( DWORD i=0; iGetDBConnection()->QueryGetStageClearBest(pSession, nMapIndex); bFirst = false; } pSession->GetDBConnection()->QueryGetStageClearPersonalBest(pSession, nMapIndex); } } } #endif //#if defined(PRE_ADD_CP_RANK) // ½ºÅ×ÀÌÁö ½ÃÀÛ ·Î±× BYTE cThreadID; CDNDBConnection* pDBCon = g_pDBConnectionManager->GetDBConnection( cThreadID ); if( pDBCon ) { pDBCon->QueryAddStageStartLog( cThreadID, GetRoom()->GetWorldSetID(), 0, GetRoom()->GetRoomLogIndex(), GetRoom()->GetPartyLogIndex(), static_cast(GetUserCount()), nMapIndex, static_cast(StageDifficulty+1) ); GetRoom()->SetStageStartLogFlag( true ); GetRoom()->SetStageEndLogFlag( false ); } } } break; } #if defined(PRE_FIX_INITSTATEANDSYNC) GetRoom()->ReserveInitStateAndSync( nMapIndex, nGateIndex, m_nRandomSeed, StageDifficulty, bDirectConnect ); #else GetRoom()->InitStateAndSync( nMapIndex, nGateIndex, m_nRandomSeed, StageDifficulty, bDirectConnect ); #endif //#if defined(PRE_FIX_INITSTATEANDSYNC) } break; default: { // Map Type is Unknown for( DWORD i=0; iSendCancelStage( ERROR_PARTY_STARTSTAGE_FAIL ); } g_Log.Log(LogType::_ERROR, pSession, L"°ÔÀÓÀ» ½ÃÀÛÇÒ ¼ö ¾ø½À´Ï´Ù°¡ ÀÚ²Ù ¶á´Ù À̰гª¿À¸é ÃÂ.......\n"); } break; } return ERROR_NONE; } int CDnPartyTask::OnRecvPartyCancelStage( CDNUserSession *pSession, char *pPacket, int nLen ) { if (nLen != 0) return ERROR_INVALIDPACKET; m_bWaitGate = false; for( DWORD i=0; iSendCancelStage( ERROR_NONE ); } return ERROR_NONE; } int CDnPartyTask::OnRecvPartyMemberKick(CDNUserSession * pSession, char * pPacket, int nLen) { CSPartyMemberKick * pKick = (CSPartyMemberKick*)pPacket; if (sizeof(CSPartyMemberKick) != nLen) return ERROR_INVALIDPACKET; CDNGameRoom::PartyStruct * pPartyStruct = GetPartyData(pSession); if (pPartyStruct && pPartyStruct->bLeader == true) { if (pPartyStruct->nEnteredGateIndex != -1) //°ÔÀÌÆ®¿¡ ¼­ÀÖÁö ¾Ê¾Æ¾ß °¡´É~ { _DANGER_POINT(); //Ŭ¶óÀÌ¾ðÆ®¿¡¼­ º¸³»¸é ¾ÈµÇ´Â°Å¶ó ´Ü°Å return ERROR_NONE; } //Á¤»óÀÌ¸é ¹Ù·Î ÇÏÁö ¸»°í 5ÃÊ µÚ¿¡ Ç϶ø´Ï´Ù ”î! int nSeq = 0; CDNGameRoom::PartyStruct * pStruct = GetRoom()->GetPartyDatabySessionID(pKick->nSessionID, nSeq); if (pStruct) { if (pStruct->pSession->GetAbsent() == false) return ERROR_NONE; _KICKMEMBER kick; memset(&kick, 0, sizeof(kick)); kick.nKickTick = GetRoom()->GetGameTick() + (5 * 1000); kick.nSessionID = pSession->GetSessionID(); kick.nAccountDBID = pSession->GetAccountDBID(); kick.cWorldID = (BYTE)pSession->GetWorldSetID(); kick.biCharacterDBID = pSession->GetCharacterDBID(); memcpy(&kick.Kick, pKick, sizeof(CSPartyMemberKick)); m_KickList.push_back(kick); pStruct->pSession->SendCountDownMsg(true, 5, 3537, 2); } } return ERROR_NONE; } int CDnPartyTask::OnRecvPartySelectDungeon(CDNUserSession * pSession, char * pPacket, int nLen) { CSSelectDunGeon * pMsg = (CSSelectDunGeon*)pPacket; if (sizeof(CSSelectDunGeon) != nLen) return ERROR_INVALIDPACKET; for( DWORD i=0; iSendSelectDungeonInfo(pMsg->nMapIndex, pMsg->cDiffyculty); } return ERROR_NONE; } int CDnPartyTask::OnRecvPartyLeaderSwap(CDNUserSession * pSession, char * pPacket, int nLen) { CSPartyLeaderSwap * pSwap = (CSPartyLeaderSwap*)pPacket; if (sizeof(CSPartyLeaderSwap) != nLen) return ERROR_INVALIDPACKET; if (GetRoom()) { int nSeq = 0; CDNGameRoom::PartyStruct * pLeaderStruct = GetRoom()->GetPartyDatabySessionID(pSession->GetSessionID(), nSeq); if ( pLeaderStruct && pLeaderStruct->bLeader == true) { int nNewSeq = 0; CDNGameRoom::PartyStruct * pNewLeaderStruct = GetRoom()->GetPartyDatabySessionID(pSwap->nSessionID, nNewSeq); if (pNewLeaderStruct) { if (pNewLeaderStruct->pSession->bIsGMTrace()) return ERROR_PARTY_LEADER_APPOINTMENTFAIL; pLeaderStruct->bLeader = false; pNewLeaderStruct->bLeader = true; UpdateGateInfo(); for(DWORD i=0; iSendSwapPartyLeader(pSwap->nSessionID, ERROR_NONE); } #ifdef PRE_FIX_PARTY_STAGECLEAR_CHANGEMASTER CDnGameTask *pTask = static_cast(GetRoom()->GetTaskMng()->GetTask( "GameTask" )); if( pTask ) { pTask->SetWarpDungeonClearToLeaderCheck(true); } #endif return ERROR_NONE; } } } pSession->SendSwapPartyLeader(0, ERROR_PARTY_LEADER_APPOINTMENTFAIL); return ERROR_NONE; } void CDnPartyTask::RequestPartyMember() { int nCnt = 0; UINT nMember[PARTYMAX]; memset(nMember, 0, sizeof(nMember)); for( DWORD i=0; iGetSessionID(); nCnt++; } } for( DWORD i=0; i(GetRoom()->GetTaskMng()->GetTask( "GameTask" )); if( pTask ) { pTask->RequestGateInfo(); } _RequestSyncStartMsg(); } void CDnPartyTask::_RequestSyncStartMsg() { for( UINT i=0 ; iOnRequestSyncStartMsg( pGameSession ); } } bool CDnPartyTask::CheckPartyFatigue() { #if defined( PRE_USA_FATIGUE ) for( DWORD i=0; iSetNoFatigueEnter( false ); if ((GetUserData(i)->GetFatigue() <= 0) && (GetUserData(i)->GetWeeklyFatigue() <= 0) && (GetUserData(i)->GetPCBangFatigue() <= 0) && (GetUserData(i)->GetEventFatigue() <= 0) && (GetUserData(i)->GetVIPFatigue() <= 0)) GetUserData(i)->SetNoFatigueEnter( true ); } return true; #else for( DWORD i=0; iGetFatigue() <= 0) && (GetUserData(i)->GetWeeklyFatigue() <= 0) && (GetUserData(i)->GetPCBangFatigue() <= 0) && (GetUserData(i)->GetEventFatigue() <= 0) && (GetUserData(i)->GetVIPFatigue() <= 0)) return false; } return true; #endif // #if defined( PRE_USA_FATIGUE ) } bool CDnPartyTask::CheckAndRequestGateIndex(int nGateNo, int nMemberIdx) { if( m_bWaitGate ) return false; char cGateNo[PARTYMAX]; memset(cGateNo, -1, sizeof(cGateNo)); if( GetRoom() && GetRoom()->bIsFarmRoom() ) return false; // ´©±º°¡ ³­ÀÔÇÏ´Â ³à¼®ÀÌ ÀÖÀ¸¸é °ÔÀÌÆ® À̵¿ ¸øÇÏ°Ô ¸·´Â´Ù. if (GetRoom()) { bool bCheck = false; int nRet = ERROR_NONE; if (GetRoom()->bIsExistBreakIntoUser()) { #if !defined( _FINAL_BUILD ) g_Log.Log( LogType::_NORMAL, L"´©±º°¡ ³­ÀÔÇÏ´Â ³à¼®ÀÌ ÀÖÀ¸¸é °ÔÀÌÆ® À̵¿ ¸øÇÏ°Ô ¸·´Â´Ù.\r\n" ); #endif bCheck = true; nRet = ERROR_PARTY_REFRESHGATEFAIL_REQRETREAT; } if (GetRoom()->IsInviting()) { #if !defined( _FINAL_BUILD ) g_Log.Log( LogType::_NORMAL, L"ÃÊ´ëÁßÀ̶ó¸é °ÔÀÌÆ®À̵¿À» ¸·´Â´Ù.\r\n" ); #endif bCheck = true; nRet = ERROR_PARTY_REFRESHGATEFAIL_REQRETREAT; } if (IsPartySharingReversionItem()) { bCheck = true; nRet = ERROR_PARTY_DUNGEONWARPOUT_FAIL_ITEMSHARING; } if (bCheck) { //¿¡·¯°¡ ¹ß»ýÇß´Ù¸é °ÔÀÌÆ®°ªÀ» ³Ö¾î¼­ º¸³»ÁØ´Ù. if (nGateNo >= 0 && nMemberIdx >= 0 && nMemberIdx < PARTYMAX) cGateNo[nMemberIdx] = (char)nGateNo; SendRefreshGate(cGateNo, nRet); return false; } } bool bAllSame = false; std::vector> vGate; std::vector>::iterator ii; CDnGameTask *pTask = (CDnGameTask *)CTaskManager::GetInstance(GetRoom()).GetTask( "GameTask" ); m_nEnteredGateIndex = -1; pTask->SetGateIndex( -1 ); int nDeadCount = 0; int nGMCount = 0; int nUserCount = GetUserCount(); for(int i = 0; i < nUserCount; i++) { if(GetUserData(i)->GetActorHandle() && GetUserData(i)->GetActorHandle()->IsDie()) { nDeadCount++; continue; } if( GetUserData(i)->bIsGMTrace() ) { ++nGMCount; continue; } int nMemberIndex = GetRoom()->GetPartyIndex() > 0 ? GetUserData(i)->GetPartyMemberIndex() : i; if (nMemberIndex < 0) continue; cGateNo[nMemberIndex] = (char)GetPartyData(i)->nEnteredGateIndex; if (cGateNo[nMemberIndex] != -1) { if (vGate.size() <= 0) vGate.push_back(std::make_pair(cGateNo[nMemberIndex], 1)); else { for (ii = vGate.begin(); ii != vGate.end(); ii++) if ((*ii).first == cGateNo[nMemberIndex]) (*ii).second++; } } } //°ÔÀÌÆ® Á¤º¸¸¦ ¾÷µ¥ÀÌÆ® ½ÃÄÑÁØ´Ù. SendRefreshGate(cGateNo, ERROR_NONE); //¾î¶²°É ¸¸Á·ÇÏ´ÂÁö ã´Â´Ù. int nTargetGate = -1; for (ii = vGate.begin(); ii != vGate.end(); ii++) { if ((*ii).second == (nUserCount - nDeadCount - nGMCount)) { bAllSame = true; nTargetGate = (*ii).first; } } char cDungeonEnterCount = 0; char cCanEnter[5][5] = { false, }; char cPermitFlag[5] = { EWorldEnum::PermitEnter, }; if (bAllSame) { if( nTargetGate != -1 ) { GateStruct *pStruct = CDnWorld::GetInstance(GetRoom()).GetGateStruct( nTargetGate ); if( pStruct && pStruct->PermitFlag != EWorldEnum::PermitEnter ) return false; #if defined( PRE_PARTY_DB ) if( pStruct->MapType == EWorldEnum::MapTypeVillage ) { int iPermitLevel = g_pDataManager->GetMapPermitLevel( pStruct->nMapIndex ); for( DWORD i=0 ; iGetLevel() < iPermitLevel ) return false; } } #endif // #if defined( PRE_PARTY_DB ) } m_nRandomSeed = CRandom::Seed(GetRoom());//_rand(GetRoom()); m_nEnteredGateIndex = nTargetGate; pTask->SetGateIndex( nTargetGate ); if( nTargetGate != -1 ) { GateStruct *pStruct = CDnWorld::GetInstance(GetRoom()).GetGateStruct( nTargetGate ); if( pStruct ) { if( pStruct->MapType == EWorldEnum::MapTypeDungeon ) { m_nRandomSeed = pTask->CheckRecoveryDungeonHistorySeed( pStruct->nMapIndex, m_nRandomSeed ); // ´øÀü ÀÔ±¸ÀÏ °æ¿ì¿¡´Â GateInfo ¿¡ CanEnter °ü·Ã Á¤º¸µµ º¸³»ÁÖµµ·Ï ÇÏÀÚ. if( CDnWorld::GetInstance(GetRoom()).GetMapType() == EWorldEnum::MapTypeWorldMap ) { DungeonGateStruct *pDungeonStruct = (DungeonGateStruct *)pStruct; if( pStruct->nMapIndex >= DUNGEONGATE_OFFSET ) { cDungeonEnterCount = (char)pDungeonStruct->pVecMapList.size(); for( int i=0; ipVecMapList[i])->cCanDifficult, sizeof(bool)*5 ); cPermitFlag[i] = ((DungeonGateStruct *)pDungeonStruct->pVecMapList[i])->PermitFlag; } } else { cDungeonEnterCount = 1; memcpy( cCanEnter[0], pDungeonStruct->cCanDifficult, sizeof(char)*5 ); cPermitFlag[0] = pDungeonStruct->PermitFlag; } } } } } for( DWORD i=0; iSendGateInfo( -1, (char)nTargetGate, cDungeonEnterCount, (char*)cCanEnter, (char*)cPermitFlag ); } m_bWaitGate = true; } return true; } /* void CDnPartyTask::CalcDungeonEnterGateCondition( CDnWorld::DungeonGateStruct *pStruct, short &nDungeonEnterPermit ) { //´øÀü ÀÔÀå½Ã ÇÊ¿ä¾ÆÀÌÅÛ°Ë»ç UINT nNeedItemID = pStruct->nNeedItemID; int nNeedItemCount = pStruct->nNeedItemCount; if (nNeedItemID > 0) { for( DWORD j=0; jGetItem()->GetInventoryItemCount(nNeedItemID) >= nNeedItemCount ? ERROR_NONE : ERROR_PARTY_STARTSTAGE_FAIL_DUNGEONNEEDITEM_SHORTAGE; if( nDungeonEnterPermit != ERROR_NONE ) break; } } } */ int CDnPartyTask::GetCheckGateIndex( CDNUserSession *pSession ) { if( !pSession ) return -1; if( !pSession->GetActorHandle() ) return -1; if (!GetRoom()) return -1; CDnPlayerActor *pPlayer = (CDnPlayerActor*)pSession->GetActorHandle().GetPointer(); if(! pPlayer ) return -1; if( pPlayer->IsDie() || pPlayer->IsHit() ) return -1; for( DWORD i=0; ipGateArea ) continue; if( !pStruct->pGateArea->IsActive() ) continue; if( pStruct->pGateArea->CheckArea( *pPlayer->GetStaticPosition(), true ) == false ) continue; return (int)pStruct->cGateIndex; } return -1; } //void CDnPartyTask::ResetSync() //{ // m_bSyncComplete = false; // for( DWORD i=0; ipSession->SetSessionState(SESSION_STATE_READY_TO_SYNC); // //bSync = false; // } //} void CDnPartyTask::ResetGateIndex() { m_bWaitGate = false; m_nEnteredGateIndex = -1; for( DWORD i=0; inEnteredGateIndex = -1; } } void CDnPartyTask::OutPartyMember( UINT nOutPartyMemberUID, UINT nNewLeaderUID, char cKickKind ) { CDNUserSession *pSession; CDNUserSession *pOutSession = GetRoom()->GetUserSession( nOutPartyMemberUID ); if (pOutSession) pOutSession->SetOutedMember(); #if defined( PRE_PARTY_DB ) if(pOutSession) { if ( pOutSession->GetGameRoom()->GetGameType() != REQINFO_TYPE_SINGLE ) { DelPartyMemberDB( pOutSession ); } } #endif for( DWORD i=0; iGetGameRoom()->GetGameType() != REQINFO_TYPE_SINGLE || pSession->bIsGMTrace() || pSession->GetGameRoom()->bIsFarmRoom() ) bSendPartyOut = true; if( pOutSession && pOutSession->bIsGMTrace() ) bSendPartyOut = true; #if defined( PRE_WORLDCOMBINE_PARTY ) if(pSession->GetOutedMember() && pSession->GetSessionID() != nOutPartyMemberUID) bSendPartyOut = false; #endif if( bSendPartyOut ) pSession->SendPartyOut(ERROR_NONE, cKickKind, nOutPartyMemberUID); if (pSession->GetSessionID() == nOutPartyMemberUID) { #if !defined( PRE_PARTY_DB ) if (GetUserCountWithoutPartyOutUser() == 1) { // ÆÄƼ Á¾·á ·Î±× BYTE cThreadID; CDNDBConnection* pDBCon = g_pDBConnectionManager->GetDBConnection( cThreadID ); if( pDBCon ) pDBCon->QueryAddPartyEndLog( cThreadID, GetRoom()->GetWorldSetID(), 0, GetRoom()->GetPartyLogIndex() ); } #endif continue; } if (nNewLeaderUID > 0) { pSession->SendChangeLeader(nNewLeaderUID); #ifdef PRE_FIX_PARTY_STAGECLEAR_CHANGEMASTER CDnGameTask *pTask = static_cast(GetRoom()->GetTaskMng()->GetTask( "GameTask" )); if( pTask ) { pTask->SetWarpDungeonClearToLeaderCheck(true); } #endif } } #if defined( PRE_ADD_NEWCOMEBACK ) if( pOutSession && pOutSession->GetComebackAppellation() > 0 ) { DelPartyMemberAppellation( pOutSession->GetComebackAppellation() ); } #endif } void CDnPartyTask::UpdateGateInfo() { CDnGameTask *pTask = (CDnGameTask *)CTaskManager::GetInstance(GetRoom()).GetTask( "GameTask" ); // Refresh ÇØº¸°í °ÔÀÌÆ®ÀÇ º¯°æ»çÇ×ÀÌ »ý°åÀ¸¸é °ÔÀÌÆ®ÀÎÆ÷¸¦ º¸³½´Ù. if( CDnWorld::GetInstance(GetRoom()).GetMapType() == EWorldEnum::MapTypeWorldMap ) { CDnGameTask *pLocalTask = (CDnGameTask *)CTaskManager::GetInstance(GetRoom()).GetTask( "GameTask" ); // ³ª°¬À»¶§´Â °ÔÀÌÆ®ÀÇ º¯È­°¡ ¾ø´õ·¹µµ ¸®Ç÷¹½¬ ÈÄ º¸³»Áà¾ß ÇÑ´Ù. // Á¶°ÇÀÌ ¾ÈµÇ´Â ³ðµéÀÇ ¸®½ºÆ®¸¦ °»½ÅÇØ¾ßÇϱ⠶§¹®. if üũ ÇÏÁö¸»ÀÚ. CDnWorld::GetInstance(GetRoom()).RefreshGate( pLocalTask->GetMapTableID() ); CDnWorld::GetInstance(GetRoom()).RefreshDungeonDifficult( pLocalTask->GetMapTableID() ); pLocalTask->RequestGateInfo(); } // ´øÀü ÀÔÀå »óÅ¿´´Ù¸é ĵ½½ÇØÁØ´Ù. if( m_bWaitGate ) { m_bWaitGate = false; for( DWORD i=0; iSendCancelStage( ERROR_PARTY_STARTSTAGE_FAIL ); } } // ´øÀü Ŭ¸®¾î »óÅ¿´´Ù¸é °¢ »óÅ¿¡ µû¶ó ó¸®ÇØÁØ´Ù. pTask->RefreshDungeonClearState(); } #define MAX_DUPLICATE_DICE_COUNT 5 #define MAX_SERVER_DICE_WAIT_MSEC 60 void CDnPartyTask::AddRequestGetReversionItemUserInfo(ReversionItemGetUnit& unit, bool bSendUserJoin) { unit.userInfo.clear(); if (!unit.hDropItem) { return; } UINT i = 0; for (; i < GetUserCount() ; ++i) { CDNUserSession* pGameSession = GetUserData(i); if (GetRoom() && pGameSession ) { if (pGameSession->bIsGMTrace()) continue; if( !pGameSession->GetActorHandle() ) continue; CDnPlayerActor *pPlayer = static_cast(pGameSession->GetActorHandle().GetPointer()); if (pPlayer->IsDie()) continue; ReversionItemGetUserInfo getUserinfo; getUserinfo.sessionID = pGameSession->GetSessionID(); unit.userInfo.push_back(getUserinfo); if (bSendUserJoin) pGameSession->SendRequestJoinGetReversionItem(unit.itemInfo, unit.hDropItem->GetUniqueID()); } } } void CDnPartyTask::AddRequestGetReversionItem(const TItem& itemInfo, DnDropItemHandle hDropItem) { // todo : set? if (IsEnableAddRequestGetReversionItem(hDropItem) == false) return; ReversionItemGetUnit unit; unit.itemInfo = itemInfo; unit.hDropItem = hDropItem; AddRequestGetReversionItemUserInfo(unit, m_RequestGetReversionItemList.empty()); m_RequestGetReversionItemList.push_back(unit); } void CDnPartyTask::SendRequestJointGetReversionItem(const TItem& orgItemInfo, const DWORD& dropUniqueID) { UINT i = 0; TItem itemInfo = orgItemInfo; for (; i < GetUserCount() ; ++i) { CDNUserSession* pGameSession = GetUserData(i); if (GetRoom() && pGameSession ) { if (pGameSession->bIsGMTrace()) continue; if( !pGameSession->GetActorHandle() ) continue; CDnPlayerActor *pPlayer = static_cast(pGameSession->GetActorHandle().GetPointer()); if (pPlayer->IsDie()) continue; pGameSession->SendRequestJoinGetReversionItem(itemInfo, dropUniqueID); } } } bool CDnPartyTask::IsEnableAddRequestGetReversionItem(DnDropItemHandle hDropItem) { if (!hDropItem) return false; std::deque::iterator iter = m_RequestGetReversionItemList.begin(); for (; iter != m_RequestGetReversionItemList.end(); ++iter) { ReversionItemGetUnit& info = *iter; if (!info.hDropItem) return false; if (info.hDropItem->GetUniqueID() == hDropItem->GetUniqueID()) return false; } return true; } bool CDnPartyTask::IsSameDiceNumber(const std::vector& userList, int diceNumber) const { std::vector::const_iterator iter = userList.begin(); for (; iter != userList.end(); ++iter) { const ReversionItemGetUserInfo& curUserInfo = *iter; if (curUserInfo.diceValue == diceNumber) return true; } return false; } int CDnPartyTask::Dice(const std::vector& userList) { int i = 0; int diceValue = 0; for (; i < MAX_DUPLICATE_DICE_COUNT; ++i) { diceValue = m_Random.rand(0, MAXPARTYDICEGAMENUMBER); if (IsSameDiceNumber(userList, diceValue) == false) break; } if (i >= MAX_DUPLICATE_DICE_COUNT) { _DANGER_POINT(); return 0; // You are REALLY Unlucky guy! } return diceValue; } int CDnPartyTask::OnRecvPartyJoinGetReversionItem(CDNUserSession *pSession, char *pPacket) { CSJoinGetReversionItem* pJoinGet = (CSJoinGetReversionItem*)pPacket; if (m_RequestGetReversionItemList.empty()) { _DANGER_POINT(); return ERROR_ITEM_FAIL; } if (pSession && pJoinGet) { int diceValue = 0; ReversionItemGetUnit& current = m_RequestGetReversionItemList.front(); std::vector& curUserList = current.userInfo; std::vector::iterator iter = curUserList.begin(); for (; iter != curUserList.end(); ++iter) { ReversionItemGetUserInfo& info = *iter; if (info.sessionID == pSession->GetSessionID()) { #ifdef PRE_FIX_RECURSIVE_DICE if (info.bJoinDecided) return ERROR_NONE; #endif diceValue = info.diceValue = (pJoinGet->bJoin) ? Dice(curUserList) : -1; info.bJoinDecided = true; break; } } UINT i = 0; for (; i < GetUserCount() ; ++i) { CDNUserSession* pGameSession = GetUserData(i); if (GetRoom() && pGameSession) { int weight = 0; if (GetRoom()->bIsPartyJobDice() ) { if (pSession) { if (g_pDataManager->IsItemNeedJobHistory(current.itemInfo.nItemID, pSession->GetStatusData()->cJobArray, true)) weight = MAXPARTYDICEGAMENUMBER + 1; } } pGameSession->SendRollDiceForGetReversionItem(pSession->GetSessionID(), pJoinGet->bJoin, diceValue + weight); } } } return ERROR_NONE; } void CDnPartyTask::ClearReversionItemList() { std::deque::iterator iter = m_RequestGetReversionItemList.begin(); for (; iter != m_RequestGetReversionItemList.end(); ++iter) { ReversionItemGetUnit& unit = *iter; SAFE_RELEASE_SPTR(unit.hDropItem); } m_RequestGetReversionItemList.clear(); m_bHoldSharingReversionItem = false; } void CDnPartyTask::ProcessGetReversionItemList(LOCAL_TIME LocalTime, float fDelta) { if (m_RequestGetReversionItemList.empty() == false && m_bHoldSharingReversionItem == false) { DWORD decideUserCount = 0; ReversionItemGetUserInfo winnerInfo; ReversionItemGetUnit& current = m_RequestGetReversionItemList.front(); std::vector& curUserList = current.userInfo; std::vector::iterator iter = curUserList.begin(); for (; iter != curUserList.end();) { ReversionItemGetUserInfo& userInfo = *iter; int partyIdx = 0; if (GetRoom()->GetUserSession(userInfo.sessionID) == NULL || GetRoom()->GetPartyDatabySessionID(userInfo.sessionID, partyIdx) == NULL) { iter = curUserList.erase(iter); continue; } if (userInfo.bJoinDecided != false) { if (userInfo.diceValue >= 0) { int jobWeight = 0; if (GetRoom() && GetRoom()->bIsPartyJobDice() ) { CDNUserSession* pSession = GetRoom()->GetUserSession(userInfo.sessionID); if (pSession) { if (g_pDataManager->IsItemNeedJobHistory(current.itemInfo.nItemID, pSession->GetStatusData()->cJobArray, true)) jobWeight = MAXPARTYDICEGAMENUMBER + 1; } } int resultValue = userInfo.diceValue + jobWeight; if (resultValue > winnerInfo.diceValue) { winnerInfo = userInfo; winnerInfo.diceValue = resultValue; } } ++decideUserCount; } ++iter; } /* if (decideUserCount > (int)curUserList.size()) { _DANGER_POINT(); return; } */ if (decideUserCount >= (int)curUserList.size() || current.time > MAX_SERVER_DICE_WAIT_MSEC) { if (winnerInfo.IsEmpty() == false) { CDNUserSession* pWinnerSession = GetRoom()->GetUserSession(winnerInfo.sessionID); if (pWinnerSession) { int cSlotIndex = -1; // ½ÇÁ¦·Î ¾ÆÀÌÅÛ ¸ÔÀº³ð¿¡°Ô¸¸ SC_ITEM °ü·Ã ¸Þ¼¼Áö°¡ °¡°í // [´©°¡] [¾î¶² ¾Æ¾ÆÅÛ]À» ¸Ô¾ú½À´Ï´Ù. ¶ó´Â ¸Þ¼¼Áö¸¦ µû·Î º¸³»±âµµ ¹¹ÇÏ´Ï // DropItem ¿¡°Ô º¸³¾¶§ Á¤º¸¸¦ °¡Ä¡ º¸³»ÁÖµµ·Ï ÇÑ´Ù. char cLootRule = ITEMLOOTRULE_NONE; DnActorHandle hActor = pWinnerSession->GetActorHandle(); DWORD dwOnwerID = hActor->GetUniqueID(); if (current.hDropItem) { current.hDropItem->SetOwnerUniqueID(dwOnwerID); current.hDropItem->LockReversionItem(false); CDnItemTask::GetInstance(GetRoom()).PickUpItem( hActor, current.hDropItem, ITEMLOOTRULE_NONE ); } UINT i = 0; for (; i < GetUserCount() ; ++i) { CDNUserSession* pGameSession = GetUserData(i); if (GetRoom() && pGameSession) { DWORD sessionId = UINT_MAX; if (current.hDropItem) sessionId = current.hDropItem->GetUniqueID(); pGameSession->SendResultGetReversionItem(pWinnerSession->GetSessionID(), current.itemInfo, sessionId); } } m_RequestGetReversionItemList.pop_front(); if (m_RequestGetReversionItemList.empty() == false) { ReversionItemGetUnit& unit = m_RequestGetReversionItemList.front(); if (!unit.hDropItem) { g_Log.Log(LogType::_DANGERPOINT, pWinnerSession, L"ProcessGetReversionItemList nItemID:%d m_RequestGetReversionItemList.size(%d) UserCount(%d) == userInfoCount(%d) RState[%d] UState[%d] \n", unit.itemInfo.nItemID, m_RequestGetReversionItemList.size(), GetUserCount(), unit.userInfo.size(), GetRoom()->GetRoomState(), pWinnerSession->GetState()); } else { SendRequestJointGetReversionItem(unit.itemInfo, unit.hDropItem->GetUniqueID()); } } } else { _DANGER_POINT(); } } else { UINT i = 0; for (; i < GetUserCount() ; ++i) { CDNUserSession* pGameSession = GetUserData(i); if (GetRoom() && pGameSession) pGameSession->SendResultGetReversionItem(0, current.itemInfo, UINT_MAX); } if (current.hDropItem) current.hDropItem->LockReversionItem(false); m_RequestGetReversionItemList.pop_front(); if (m_RequestGetReversionItemList.empty() == false) { ReversionItemGetUnit& unit = m_RequestGetReversionItemList.front(); if (!unit.hDropItem) { g_Log.Log(LogType::_DANGERPOINT, L"ProcessGetReversionItemList(NoWINNER_Info) nItemID:%d m_RequestGetReversionItemList.size(%d) UserCount(%d) == userInfoCount(%d) RState[%d]\n", unit.itemInfo.nItemID, m_RequestGetReversionItemList.size(), GetUserCount(), unit.userInfo.size(), GetRoom()->GetRoomState()); } else { SendRequestJointGetReversionItem(unit.itemInfo, unit.hDropItem->GetUniqueID()); } } } OutputDebug("---------- DICE END ----------\n"); } current.time += fDelta; } } bool CDnPartyTask::IsPartySharingReversionItem() const { return (m_RequestGetReversionItemList.empty() == false); } void CDnPartyTask::SendRefreshGate(char * pGateNo, int nRet) { //°ÔÀÌÆ® Á¤º¸¸¦ ¾÷µ¥ÀÌÆ® ½ÃÄÑÁØ´Ù. int nUserCount = GetRoom()->GetPartyIndex() > 0 ? GetRoom()->GetPartyMemberMax() : GetUserCount(); for(int i = 0; i < (int)GetUserCount(); i++) { GetUserData(i)->SendRefreshGateInfo(pGateNo, nUserCount, nRet); } } void CDnPartyTask::HoldSharingReversionItem() { if (m_RequestGetReversionItemList.empty() == false) { ReversionItemGetUnit& current = m_RequestGetReversionItemList.front(); current.time = 0; m_bHoldSharingReversionItem = true; } } void CDnPartyTask::PickOutInvalidReversionItemUnit() { std::deque::iterator riguIter = m_RequestGetReversionItemList.begin(); for (; riguIter != m_RequestGetReversionItemList.end();) { ReversionItemGetUnit& rigu = (*riguIter); if (!rigu.hDropItem) riguIter = m_RequestGetReversionItemList.erase(riguIter); else ++riguIter; } } void CDnPartyTask::ReleaseSharingReversionItem() { if (m_RequestGetReversionItemList.empty() == false && m_bHoldSharingReversionItem) { if (GetRoom() == NULL) return; PickOutInvalidReversionItemUnit(); if (m_RequestGetReversionItemList.empty() == false) { ReversionItemGetUnit& current = m_RequestGetReversionItemList.front(); std::vector::iterator iter = current.userInfo.begin(); for (; iter != current.userInfo.end();) { ReversionItemGetUserInfo& curUserInfo = *iter; CDNUserSession* pGameSession = GetRoom()->GetUserSession(curUserInfo.sessionID); if (pGameSession) { if (curUserInfo.bJoinDecided == false) pGameSession->SendRequestJoinGetReversionItem(current.itemInfo, current.hDropItem->GetUniqueID()); } else { iter = current.userInfo.erase(iter); continue; } ++iter; } } m_bHoldSharingReversionItem = false; } } int CDnPartyTask::OnRecvPartyMemberAbsent(CDNUserSession * pSession, CSMemberAbsent * pPacket, int nLen) { pSession->SetAbsent(pPacket->cAbsentFlag == 0 ? true : false); UINT i = 0; for (; i < GetUserCount() ; ++i) { CDNUserSession* pGameSession = GetUserData(i); if (GetRoom() && pGameSession) pGameSession->SendMemberAbsent(pSession->GetSessionID(), pPacket->cAbsentFlag); } return ERROR_NONE; } int CDnPartyTask::OnRecvPartyInviteMember(CDNUserSession * pSession, CSInvitePartyMember * pPacket, int nLen) { if (sizeof(CSInvitePartyMember) - sizeof(pPacket->wszBuf) + (pPacket->cInviteMemberSize * sizeof(WCHAR)) != nLen) return ERROR_INVALIDPACKET; if (pPacket->cInviteMemberSize <= 0 || pPacket->cInviteMemberSize >= NAMELENMAX) { pSession->SendPartyInviteFail(ERROR_PARTY_INVITEFAIL); return ERROR_NONE; } if (GetRoom()->IsInviting()) { pSession->SendPartyInviteFail(ERROR_PARTY_INVITEFAIL_ALREADYINVITED); return ERROR_NONE; } if (GetEnteredGate() != -1) { pSession->SendPartyInviteFail(ERROR_PARTY_INVITEFAIL); return ERROR_NONE; } WCHAR wszName[NAMELENMAX]; memset(wszName, 0, sizeof(wszName)); _wcscpy(wszName, NAMELENMAX, pPacket->wszBuf, pPacket->cInviteMemberSize); if (!__wcsicmp_l(wszName, pSession->GetCharacterName())) { _DANGER_POINT(); pSession->SendPartyInviteFail(ERROR_PARTY_INVITEFAIL); return ERROR_GENERIC_UNKNOWNERROR; } if (GetRoom()->GetGameType() != REQINFO_TYPE_PARTY) { pSession->SendPartyInviteFail(ERROR_PARTY_INVITEFAIL); return ERROR_GENERIC_UNKNOWNERROR; } if (CDnWorld::GetInstance(GetRoom()).GetMapType()!= GlobalEnum::eMapTypeEnum::MAP_WORLDMAP) { pSession->SendPartyInviteFail(ERROR_PARTY_INVITEFAIL); return ERROR_GENERIC_UNKNOWNERROR; } if (pSession->GetIsolate()->IsIsolateItem(wszName)) { pSession->SendIsolateResult(ERROR_ISOLATE_REQUESTFAIL); return ERROR_GENERIC_UNKNOWNERROR; } if( IsPartyLeader(pSession) == false ) { pSession->SendPartyInviteFail(ERROR_PARTY_INVITEFAIL); return ERROR_GENERIC_UNKNOWNERROR; } #if defined( PRE_WORLDCOMBINE_PARTY ) if( GetRoom()->bIsWorldCombineParty() ) { pSession->SendPartyInviteFail(ERROR_PARTY_INVITEFAIL); return ERROR_GENERIC_UNKNOWNERROR; } #endif // #if defined( PRE_WORLDCOMBINE_PARTY ) #if defined( PRE_PARTY_DB ) if (GetRoom()->GetUserCount()+GetRoom()->GetBreakIntoUserCount() >= PARTYCOUNTMAX || (int)GetRoom()->GetUserCount()+GetRoom()->GetBreakIntoUserCount() >= GetRoom()->GetPartyMemberMax()) #else if (GetRoom()->GetUserCount() >= PARTYCOUNTMAX || (int)GetRoom()->GetUserCount() >= GetRoom()->GetPartyMemberMax()) #endif // #if defined( PRE_PARTY_DB ) { pSession->SendPartyInviteFail(ERROR_PARTY_INVITEFAIL); return ERROR_GENERIC_UNKNOWNERROR; } CDnGameTask *pTask = (CDnGameTask *)CTaskManager::GetInstance(GetRoom()).GetTask( "GameTask" ); if (pTask == NULL) { pSession->SendPartyInviteFail(ERROR_PARTY_INVITEFAIL); return ERROR_GENERIC_UNKNOWNERROR; } int nPermitCnt = g_pDataManager->GetMapPermitPartyCount(pTask->GetMapTableID()); if (nPermitCnt > 0 && nPermitCnt <= (int)GetRoom()->GetUserCountWithoutGM()) { pSession->SendPartyInviteFail(ERROR_PARTY_INVITEFAIL); return ERROR_NONE; } int nClassPassArr[PERMITMAPPASSCLASSMAX]; int nPermitLevel = 0; memset(nClassPassArr, 0, sizeof(nClassPassArr)); pTask->GetPermitPassClassIDs(nClassPassArr, PERMITMAPPASSCLASSMAX); nPermitLevel = pTask->GetPermitMapLevel(); //±âº»ÀûÀ¸·Î °Ë»çÇÒ °ÍÀ» ´Ù ÇÑÈÄ¿¡~ ¸¶½ºÅÍ¿¡ ³¯·ÁÁØ´Ù. bool bret = g_pMasterConnectionManager->SendInvitePartyMember(GetRoom(), pSession->GetWorldSetID(), pTask->GetMapTableID(), pSession->GetGameRoom()->GetPartyChannelID(), pSession->GetAccountDBID(), pSession->GetCharacterName(), wszName, nClassPassArr, nPermitLevel); if (bret) { if (GetRoom()->SetInviteCharacterName(wszName) == false) _DANGER_POINT(); //ÀÌ·³¾Èµ¥À×~ } return ERROR_NONE; } int CDnPartyTask::OnRecvPartySwapMemberIndex(CDNUserSession * pSession, CSPartySwapMemberIndex * pPacket, int nLen) { if (GetRoom()->GetPartyIndex() == 0) { //°ÅÁþ¸»ÇÏ´Â ¾î¸°ÀÌ´Â Áö¿Á°¡¿ä. pSession->SendPartySwapMemberIndex(NULL, ERROR_PARTY_SWAPINDEX_FAIL); return ERROR_NONE; } if (GetRoom()->IsPartyLeader(pSession->GetSessionID()) == false) { pSession->SendPartySwapMemberIndex(NULL, ERROR_PARTY_SWAPINDEX_FAIL); return ERROR_NONE; } if (GetRoom()->PartySwapMemberIndex(pPacket) == false) pSession->SendPartySwapMemberIndex(NULL, ERROR_PARTY_SWAPINDEX_FAIL); return ERROR_NONE; } #if defined( PRE_PARTY_DB ) int CDnPartyTask::OnRecvPartyModify(CDNUserSession * pSession, CSPartyInfoModify * pPacket, int nLen) { if (GetRoom()->GetPartyIndex() <= 0) return ERROR_NONE; if (GetRoom()->IsPartyLeader(pSession->GetSessionID()) == false) return ERROR_NONE; // ¿ùµåÁ¸ÀÎÁö °Ë»ç const TMapInfo* pMapInfo = g_pDataManager->GetMapInfo( pSession->GetMapIndex() ); if( pMapInfo == NULL ) return ERROR_NONE; if( pMapInfo->MapType != GlobalEnum::MAP_WORLDMAP ) return ERROR_NONE; // °ÔÀÓ¼­¹ö¿¡¼­´Â BitFlag ¿É¼ÇÁß Party::BitFlag::WorldmapAllow Bit ¸¸ º¯°æ °¡´ÉÇÏ´Ù. int iBitFlag = GetRoom()->GetPartyStructData().iBitFlag; if( pPacket->iBitFlag&Party::BitFlag::WorldmapAllow && !(GetRoom()->GetPartyStructData().iBitFlag&Party::BitFlag::WorldmapAllow) ) { iBitFlag |= Party::BitFlag::WorldmapAllow; } else if( !(pPacket->iBitFlag&Party::BitFlag::WorldmapAllow) && GetRoom()->GetPartyStructData().iBitFlag&Party::BitFlag::WorldmapAllow ) { iBitFlag &= ~Party::BitFlag::WorldmapAllow; } else { return ERROR_NONE; } pSession->GetDBConnection()->QueryModParty( pSession, GetRoom()->GetPartyStructData(), iBitFlag ); return ERROR_NONE; } #if defined(PRE_MOD_REQ_JOIN_PARTY_ANSWER_MSG_APP) int CDnPartyTask::OnRecvPartyAskJoinDecision(CDNUserSession * pSession, CSPartyAskJoinDecision * pPacket, int nLen) { if (GetRoom()->GetPartyIndex() <= 0) { pSession->SendAskJoinResult(ERROR_PARTY_ASKJOIN_RESULT_AGREE_FAIL); return ERROR_NONE; } if (GetRoom()->IsPartyLeader(pSession->GetSessionID()) == false) { pSession->SendAskJoinResult(ERROR_PARTY_ASKJOIN_RESULT_AGREE_FAIL); return ERROR_NONE; } // ¿ùµåÁ¸ÀÎÁö °Ë»ç const TMapInfo* pMapInfo = g_pDataManager->GetMapInfo( pSession->GetMapIndex() ); if( pMapInfo == NULL || pMapInfo->MapType != GlobalEnum::MAP_WORLDMAP ) { pSession->SendAskJoinResult(ERROR_PARTY_ASKJOIN_RESULT_AGREE_FAIL); return ERROR_NONE; } // »óźÎÅÍ Ç®¾îÁØ´Ù. pSession->IsWindowStateNoneSet(WINDOW_ISACCEPT); if(pPacket->cRet == 0) g_pMasterConnectionManager->SendResPartyAskJoin( pSession->GetWorldSetID(), ERROR_PARTY_ASKJOIN_RESULT_PARTYLEADER_DENIED, 0, pPacket->wszPartyAsker ); else g_pMasterConnectionManager->SendAskJoinAgreeInfo( pSession->GetWorldSetID(), pPacket->wszPartyAsker, GetRoom()->GetPartyStructData().PartyID, GetRoom()->GetPartyStructData().iPassword ); return ERROR_NONE; } #endif //#if defined(PRE_MOD_REQ_JOIN_PARTY_ANSWER_MSG_APP) void CDnPartyTask::AddPartyDB( CDNUserSession* pBreakIntoSession ) { if( pBreakIntoSession || GetRoom()->GetGameType() != REQINFO_TYPE_PARTY ) return; #if defined( PRE_WORLDCOMBINE_PARTY ) if( GetRoom()->bIsWorldCombineParty() == true ) { Party::Data PartyData = GetRoom()->GetPartyStructData(); GetRoom()->GetDBConnection()->QueryAddWorldParty( g_Config.nManagedID, Party::LocationType::Worldmap, PartyData.iLocationID, &PartyData ); return; } #endif CDNUserSession * pSession = NULL; for(int i=0;i<(int)GetUserCount();i++) { if( GetUserData(i) != NULL ) { CDNGameRoom::PartyStruct *pStruct = GetPartyData( GetUserData(i) ); if(pStruct->bLeader) { pSession = GetUserData(i); break; } } } if(pSession) { Party::AddPartyAndMemberGame PartyData; memset(&PartyData, 0, sizeof(PartyData)); PartyData.PartyData = GetRoom()->GetPartyStructData(); GetRoom()->CopyPartyKickedMemberList( PartyData.nKickedMemberList ); int nCount = 0; for(int i=0;i<(int)GetUserCount();i++) { if( GetUserData(i) != NULL ) { CDNGameRoom::PartyStruct *pStruct = GetPartyData( GetUserData(i) ); if( !pStruct->bLeader && pStruct->pSession ) { PartyData.biCharacterDBID[nCount] = pStruct->pSession->GetCharacterDBID(); PartyData.nSessionID[nCount] = pStruct->pSession->GetSessionID(); #if defined( PRE_ADD_NEWCOMEBACK ) if( pStruct->pSession->GetComebackAppellation() > 0 ) PartyData.bCheckComebackAppellation[nCount] = true; #endif nCount++; } } } int iMapIndex = 0; if( GetRoom()->m_bDirectConnect ) { iMapIndex = GetRoom()->m_iMapIdx; } else { char szLabel[MAX_PATH]; DNTableFileFormat *pSox = GetDNTable( CDnTableDB::TMAP ); sprintf_s( szLabel, "_Gate%d_MapIndex_txt", GetRoom()->m_iGateIdx ); char* pszGateMapIndexs = pSox->GetFieldFromLablePtr( GetRoom()->m_iMapIdx, szLabel )->GetString(); std::vector vGateMapIndexs; TokenizeA(pszGateMapIndexs, vGateMapIndexs, ";"); if (GetRoom()->m_iGateSelect < vGateMapIndexs.size()) iMapIndex = atoi(vGateMapIndexs[GetRoom()->m_iGateSelect].c_str()); else return; } GetRoom()->GetDBConnection()->QueryAddPartyAndMemberGame( pSession, g_Config.nManagedID, Party::LocationType::Worldmap, iMapIndex, &PartyData, GetRoom()->GetRoomID() ); } } void CDnPartyTask::AddPartyMemberDB( CDNUserSession* pSession ) { CDNDBConnection* pDBCon = GetRoom()->GetDBConnection(); if( pDBCon && GetRoom()->GetPartyIndex() > 0 ) { pDBCon->QueryJoinParty( pSession, GetRoom()->GetWorldSetID(), GetRoom()->GetPartyIndex(), GetRoom()->GetPartyMemberMax() ); } } void CDnPartyTask::DelPartyDB() { CDNDBConnection* pDBCon = GetRoom()->GetDBConnection(); if( pDBCon && GetRoom()->GetPartyIndex() > 0 ) { pDBCon->QueryDelParty( GetRoom()->GetWorldSetID(), GetRoom()->GetPartyIndex() ); } } void CDnPartyTask::DelPartyMemberDB( CDNUserSession *pSession ) { if( !pSession || GetRoom()->GetPartyIndex() == 0 ) return; if (pSession->GetGameRoom()->GetGameType() != REQINFO_TYPE_SINGLE) { if( pSession->GetDBConnection() ) pSession->GetDBConnection()->QueryOutParty( GetRoom()->GetWorldSetID(), pSession->GetAccountDBID(), pSession->GetCharacterDBID(), pSession->GetSessionID(), GetRoom()->GetPartyIndex(), Party::QueryOutPartyType::Disconnect ); } } #endif // #if defined( PRE_PARTY_DB ) #if defined( PRE_ADD_NAMEDITEM_SYSTEM ) void CDnPartyTask::ApplyPartyEffectSkillItemData( CSUseItem *pPacket, TItemData *pItemData, UINT nUseSessionID, EffectSkillNameSpace::ShowEffectType::eType eType, bool bSendDB, bool bUseItem ) { CDNUserSession * pSession = NULL; for(int i=0;i<(int)GetUserCount();i++) { if( GetUserData(i) != NULL ) { pSession = GetUserData(i); pSession->GetItem()->ApplyPartyEffectSkillItemData(pPacket, pItemData, nUseSessionID, eType, bSendDB, bUseItem); } } } #endif #if defined( PRE_ADD_NEWCOMEBACK ) bool CDnPartyTask::CheckPartyMemberAppellation( int nAppellationID ) { CDNUserSession * pSession = NULL; if( nAppellationID > 0 ) { for(int i=0;i<(int)GetUserCount();i++) { if( GetUserData(i) != NULL ) { pSession = GetUserData(i); if(pSession) { if( pSession->GetComebackAppellation() == nAppellationID && !pSession->GetOutedMember() ) { return true; } } } } } else { for(int i=0;i<(int)GetUserCount();i++) { if( GetUserData(i) != NULL ) { pSession = GetUserData(i); if(pSession) { if( pSession->GetComebackAppellation() > 0 && !pSession->GetOutedMember() ) { return true; } } } } } return false; } void CDnPartyTask::DelPartyMemberAppellation( int nAppellationID ) { if( !CheckPartyMemberAppellation( nAppellationID ) ) { TAppellationData *pAData = g_pDataManager->GetAppellationData( nAppellationID ); if( pAData ) { TItemData* pBuffItemData = g_pDataManager->GetItemData( pAData->nSkillItemID ); if(pBuffItemData) { CDNUserSession * pSession = NULL; for(int i=0;i<(int)GetUserCount();i++) { if( GetUserData(i) != NULL ) { pSession = GetUserData(i); if(pSession && pSession->GetPlayerActor() ) { TEffectSkillData* EffectSkill = pSession->GetItem()->GetEffectSkillItem( EffectSkillNameSpace::SearchType::SkillID, pBuffItemData->nSkillID ); if( EffectSkill ) { CDNUserSession::RemoveEffectSkill(pSession->GetPlayerActor(), EffectSkill); pSession->GetItem()->DelEffectSkillItem( pBuffItemData->nSkillID ); } } } } if( !CheckPartyMemberAppellation(0) && GetRoom() ) GetRoom()->SetComebackParty(false); } } } } void CDnPartyTask::ApplyJoinMemberAppellation( CDNUserSession * pSession ) { if( !pSession ) return; CDNUserSession *pUserObj = NULL; float fValue = 0.f; for(int i=0;i<(int)GetUserCount();i++) { if( GetUserData(i) != NULL ) { pUserObj = GetUserData(i); if( pUserObj->GetComebackAppellation() > 0 ) { TAppellationData *pAData = g_pDataManager->GetAppellationData( pUserObj->GetComebackAppellation() ); if( pAData ) { if( pAData->nSkillItemID > 0 ) { CSUseItem pPacket; memset(&pPacket, 0, sizeof(pPacket)); pPacket.biInvenSerial = pSession->GetItem()->MakeItemSerial(); TItemData* pBuffItemData = g_pDataManager->GetItemData( pAData->nSkillItemID ); if( pBuffItemData && g_pDataManager->IsUseItemAllowMapTypeCheck( pBuffItemData->nItemID, GetRoom()->m_iMapIdx ) ) pSession->GetItem()->ApplyPartyEffectSkillItemData(&pPacket, pBuffItemData, pSession->GetSessionID(), EffectSkillNameSpace::ShowEffectType::NONEEFFECT, false, true); } } } } } } float CDnPartyTask::GetPlayerDropUpBlowValue() { CDNUserSession * pSession = NULL; float fValue = 0.f; for(int i=0;i<(int)GetUserCount();i++) { if( GetUserData(i) != NULL ) { pSession = GetUserData(i); if( pSession->GetPlayerActor() ) { if ( pSession->GetPlayerActor()->IsAppliedThisStateBlow(STATE_BLOW::BLOW_270)) { DNVector(DnBlowHandle) vlBlows; pSession->GetPlayerActor()->GatherAppliedStateBlowByBlowIndex(STATE_BLOW::BLOW_270, vlBlows); { int nCount = (int)vlBlows.size(); for (int j = 0; j < nCount; ++j) { DnBlowHandle hBlow = vlBlows[j]; if (hBlow && hBlow->IsEnd() == false) { fValue += hBlow->GetFloatValue(); } } } // µå¶ø·ü Áõ°¡´Â ÇÑ¸í¸¸ À־ ¹Ù·Î ¸®ÅϽÃÅ´ return fValue; } } } } return fValue; } #endif