Ejemplo n.º 1
0
// 현재 대전자가 모두 존재하면 대전 시작
void	CGuildCombat1to1::GuildCombat1to1War()
{
	CUser* pUser0 = NULL;
	CUser* pUser1 = NULL;

	if( (int)( m_vecTenderGuild[m_nIndex[0]].vecMemberId.size() ) > m_nProgWarCount	)
		pUser0 = (CUser*)prj.GetUserByID( m_vecTenderGuild[m_nIndex[0]].vecMemberId[m_nProgWarCount] );
	if( (int)( m_vecTenderGuild[m_nIndex[1]].vecMemberId.size() ) > m_nProgWarCount	)
		pUser1 = (CUser*)prj.GetUserByID( m_vecTenderGuild[m_nIndex[1]].vecMemberId[m_nProgWarCount] );

	// 양쪽 대전자가 모두 존재하면 대전 시작
	if( IsPossibleUser( pUser0 ) && IsPossibleUser( pUser1 ) )
	{
		g_dpDBClient.SendGC1to1WarPerson( m_vecTenderGuild[m_nIndex[0]].ulGuildId, m_vecTenderGuild[m_nIndex[0]].vecMemberId[m_nProgWarCount], 'N' );
		g_dpDBClient.SendGC1to1WarPerson( m_vecTenderGuild[m_nIndex[1]].ulGuildId, m_vecTenderGuild[m_nIndex[1]].vecMemberId[m_nProgWarCount], 'N' );
		SetTeleportToWarStage( pUser0 );	// 대전장으로 텔레포트
		SetTeleportToWarStage( pUser1 );	// 대전장으로 텔레포트 

		m_nState = GC1TO1WAR_WAR;
		m_nWaitTime = (int)g_GuildCombat1to1Mng.m_Lua.GetGlobalNumber( "WarTime" );
		m_dwTime = GetTickCount();
		SendNowStateAllPlayer();
		SendWarResultAllPlayer();	// 대전 시작 알림
	}
	else
		GuildCombat1to1WarWait();

}
Ejemplo n.º 2
0
// 승자에게 칩지급하고 메세지 출력(패자는 메세지만 출력)
void	CGuildCombat1to1::SetWinChip( CUser* pUserWin, CUser* pUserLost, BOOL bDraw, BOOL bDiag )
{
	if( bDraw )	// 비겼을 때(칩 지급 안하고 메세지만 출력)
	{
		if( bDiag )	// 개인 승패만 메세지 박스 출력
		{
			if( IsPossibleUser( pUserWin ) )
				pUserWin->AddDiagText( prj.GetText( TID_GAME_GUILDCOMBAT_1TO1_WARDRAW ) );
			if( IsPossibleUser( pUserLost ) )
				pUserLost->AddDiagText( prj.GetText( TID_GAME_GUILDCOMBAT_1TO1_WARDRAW ) );
		}
		return;
	}

	if( IsPossibleUser( pUserWin ) )
	{
		CItemElem itemElem;
		itemElem.m_dwItemId = II_CHP_RED;
		itemElem.m_nItemNum = GetChipNum();
		if( itemElem.m_nItemNum < 1 )
			itemElem.m_nItemNum = 1;
		itemElem.m_bCharged = itemElem.GetProp()->bCharged;
		itemElem.SetSerialNumber();

		LogItemInfo aLogItem;
		aLogItem.Action = "W";
		aLogItem.Gold = pUserWin->GetItemNum( II_CHP_RED );
		aLogItem.Gold2 = pUserWin->GetItemNum( II_CHP_RED ) + itemElem.m_nItemNum;
		aLogItem.Gold_1 = itemElem.m_nItemNum;
		aLogItem.SendName = pUserWin->GetName();
		aLogItem.WorldId = pUserWin->GetWorld()->m_dwWorldID;
				
		if( pUserWin->CreateItem( &itemElem ) )
		{
			aLogItem.RecvName = "GUILDCOMBAT1TO1_CHIP";
			if( !bDiag )
				aLogItem.RecvName = "GUILDCOMBAT1TO1_G_CHIP";
		}
		else	// 지급 실패시(인벤토리가 꽉찼거나 등의 이유로...) 메일로 지급
		{
			g_dpDBClient.SendQueryPostMail( pUserWin->m_idPlayer, 0, itemElem, 0, itemElem.GetProp()->szName, (char*)GETTEXT( TID_GAME_GUILDCOMBAT1TO1_WINCHIPPOST ) );
			//pUserWin->AddDefinedText( TID_GAME_MINIGAME_ITEM_POST );
			aLogItem.RecvName = "GUILDCOMBAT1TO1_CHIP_POST";
			if( !bDiag )
				aLogItem.RecvName = "GUILDCOMBAT1TO1_CHIP_G_POST";
		}
		
		if( bDiag ) // 개인 승패만 메세지 박스 출력
		{
			CString strTemp;
			strTemp.Format( prj.GetText( TID_GAME_GUILDCOMBAT_1TO1_WARWIN ), GetChipNum() );
			pUserWin->AddDiagText( strTemp );
		}
			
		g_DPSrvr.OnLogItem( aLogItem, &itemElem, itemElem.m_nItemNum );
	}

	if( IsPossibleUser( pUserLost ) && bDiag )
		pUserLost->AddDiagText( prj.GetText( TID_GAME_GUILDCOMBAT_1TO1_WARLOST ) );
}
Ejemplo n.º 3
0
// 입찰 취소 
void	CGuildCombat1to1Mng::SetCancelTenderGuild( CUser* pUser )
{
	if( m_nState != GC1TO1_CLOSE )
	{
		pUser->AddDiagText( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_NOTENDER ) );
		return;
	}

	// 길드마스터만 입찰 취소 가능
	if( !IsGuildMaster( pUser ) )
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_NOTMASTER );
		return;
	}

	CGuild* pGuild = pUser->GetGuild();
	if( pGuild )
	{
		for( vector<__GC1TO1TENDER>::iterator it=m_vecTenderGuild.begin(); it!=m_vecTenderGuild.end(); it++ )
		{
			if( (*it).ulGuildId == pGuild->GetGuildId() )
			{
				int nReturnGold = (int)( (*it).nPenya * ( (float)m_nCancelReturnRate / 100 ) );
				//인벤 꽉 찼을때 예외처리 해야함..
				int nTotal = pUser->GetGold() + nReturnGold;
				if( nReturnGold > 0 && nTotal < 0 )	// overflow
				{
					pUser->AddDefinedText( TID_GAME_LACKSPACE );
					return;
				}

				pUser->AddGold( nReturnGold );
			
				g_dpDBClient.SendGC1to1Tender( 'U', (*it).ulGuildId, (*it).nPenya, 'C' );
				m_vecTenderGuild.erase( it );
				
				CString strTemp;
				strTemp.Format( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_CANCELTENDER ), nReturnGold );
				pUser->AddDiagText( strTemp );

				// 로그 남김(아이템로그)
				LogItemInfo aLogItem;
				aLogItem.Action = "9";
				aLogItem.SendName = pUser->GetName();
				aLogItem.RecvName = "GUILDCOMBAT1TO1_CANCELRETURN";
				aLogItem.WorldId = pUser->GetWorld()->GetID();
				//aLogItem.ItemName = "SEED";
				_stprintf( aLogItem.szItemName, "%d", II_GOLD_SEED1 );
				aLogItem.Gold = pUser->GetGold() - nReturnGold;
				aLogItem.Gold2 = pUser->GetGold();
				aLogItem.Gold_1 = nReturnGold;
				g_DPSrvr.OnLogItem( aLogItem );
				break;
			}
		}
	}
}
Ejemplo n.º 4
0
void __SetQuest( DWORD dwIdMover, int nQuest )
{
	QuestProp* pQuestProp	= prj.m_aPropQuest.GetAt( nQuest );
	CUser* pUser	= prj.GetUser( dwIdMover );
	if( pQuestProp )
		pUser->AddDefinedText( TID_EVE_STARTQUEST, "\"%s\"", pQuestProp->m_szTitle );
	QUEST quest;
	if( pUser->SetQuest( nQuest, 0, &quest ) )
		pUser->AddSetQuest( &quest );
	g_dpDBClient.CalluspLoggingQuest( pUser->m_idPlayer, nQuest, 10 );
}
Ejemplo n.º 5
0
//
// 파티원들에게 bWin에 따라 승/패 사실을 알리고 듀얼을 종료시킴.
//
void CParty::DoDuelResult( CParty *pDuelOther, BOOL bWin, int nAddFame, float fSubFameRatio )
{
	CUser *pMember;
	int		i;
	
	for( i = 0; i < m_nSizeofMember; i ++ )
	{
		pMember = g_UserMng.GetUserByPlayerID( m_aMember[i].m_uPlayerId );
		if( IsValidObj( pMember ) )
		{
			pMember->AddDuelPartyResult( pDuelOther, bWin );		// 각 멤버들에게 승/패 사실을 알림. / 상대파티원 리스트도 보냄.
			pMember->ClearDuelParty();

			if( bWin )
			{
				pMember->m_nFame += nAddFame;	// 이긴측이면 명성 증가
				pMember->AddDefinedText( TID_GAME_GETFAMEPOINT, "%d", nAddFame );	// xxx 명성 포인트가 증가
#ifdef __WORLDSERVER
				g_dpDBClient.SendLogPkPvp( pMember, NULL, nAddFame, 'E' );
#endif // __WORLDSERVER
			} 
			else
			{
				int nDecVal;
				fSubFameRatio = fSubFameRatio / 100.0f;	// 비율로 환산.
				nDecVal = (int)(pMember->m_nFame * fSubFameRatio);
				if( nDecVal == 0 )	nDecVal = 1;
				pMember->m_nFame -= nDecVal;
				if( pMember->m_nFame < 0 )	pMember->m_nFame = 0;
				pMember->AddDefinedText( TID_GAME_DECFAMEPOINT, "%d", nDecVal );	// xxx 명성 포인트가 감소.
#ifdef __WORLDSERVER
				g_dpDBClient.SendLogPkPvp( NULL, pMember, nAddFame, 'E' );
#endif // __WORLDSERVER
			}
			
			// 바뀐 명성치를 pMember의 주위에 날려줌.
			g_UserMng.AddSetFame( pMember, pMember->m_nFame );
		}
	}
	m_idDuelParty = 0;
}
Ejemplo n.º 6
0
int __SetQuestState( DWORD dwIdMover, int nQuest, int nState )
{
	CUser* pUser	= prj.GetUser( dwIdMover );
	if( nState == QS_END )
	{
		QuestProp* pQuestProp = prj.m_aPropQuest.GetAt( nQuest );
		if( pQuestProp )
		{
			if( nQuest !=  QUEST_CREGUILD )
				pUser->AddDefinedText( TID_EVE_ENDQUEST, "\"%s\"", pQuestProp->m_szTitle );
		}
		g_dpDBClient.CalluspLoggingQuest( pUser->m_idPlayer, nQuest, 20 );
	}
	else
	if( nState == QS_BEGIN )
	{
		g_dpDBClient.CalluspLoggingQuest( pUser->m_idPlayer, nQuest, 10 );
	}
	QUEST quest;
	if( pUser->SetQuest( nQuest, nState, &quest ) )
		pUser->AddSetQuest( &quest );
	return 1;
}
Ejemplo n.º 7
0
void CQuiz::CloseQuizEvent()
{
	SetRun( FALSE );
	SetNextTime( 0 );
	SetState( QE_CLOSE );
	m_bSelectLog = FALSE;
	m_nQuizCount = 0;
	Clear();
	RemoveNPC();
	g_dpDBClient.SendQuizEventState( QE_CLOSE, g_uIdofMulti, 0, m_nQuizCount );
	CWorld* pWorld = g_WorldMng.GetWorld( WI_WORLD_QUIZ );
	if( pWorld )
	{
		for( DWORD i = 0; i < pWorld->m_dwObjNum; ++i )
		{
			if( IsInQuizEventPlayer( pWorld, nDefaultLayer, i ) )
				GoOut( static_cast<CUser*>( pWorld->m_apObject[i] ) );
		}
	}
}
Ejemplo n.º 8
0
void CQuiz::OpenQuizEvent()
{
	if( m_nState != QE_CLOSE )
		return;

	if( IsAutoMode() )
	{
		if( m_nChannel == g_uIdofMulti )
			m_bRun = TRUE;
	}
	else
		m_bRun = TRUE;

	if( m_bRun )
	{
		InitQuizData( GetType() );
		SetNPC();
		SetNextTime( GetTickCount() + m_dwEntranceTime );
		SetState( QE_OPEN );
		g_dpDBClient.SendQuizEventState( QE_OPEN, g_uIdofMulti );
	}
}
Ejemplo n.º 9
0
// 모든 대전장의 길드대전이 끝났다.
void	CGuildCombat1to1Mng::GuildCombat1to1AllClose()
{
	ClearTime();
	m_nState = GC1TO1_CLOSE;
	for( int i=0; i<(int)( m_vecTenderGuild.size() ); i++ )
	{
		CGuild* pGuild = g_GuildMng.GetGuild( m_vecTenderGuild[i].ulGuildId );
		if( pGuild )
		{
			for( map<u_long, CGuildMember*>::iterator it=pGuild->m_mapPMember.begin(); it!=pGuild->m_mapPMember.end(); it++ )
			{
				CUser* pUser = (CUser*)prj.GetUserByID( it->first );
				if( IsValidObj(pUser) )
					SendNowState( pUser );
			}
		}
	}

	m_vecGuilCombat1to1.clear();
	m_vecTenderGuild.clear();
	g_dpDBClient.SendGC1to1StateToDBSrvr();
}
Ejemplo n.º 10
0
void ExitInstance( void )
{
	g_dpCoreSrvr.DeleteDPObject();
	g_DPCacheSrvr.DeleteDPObject();
	g_dpLoginSrvr.DeleteDPObject();
	g_dpDatabaseClient.DeleteDPObject();

	g_PartyMng.Clear();

	g_PlayerMng.Free();

	SAFE_DELETE( CParty::m_pPool );
	SAFE_DELETE( CPlayer::m_pPool );
	g_GuildMng.m_AddRemoveLock.Enter( theLineFile );
	g_GuildWarMng.Clear();
	g_GuildMng.m_AddRemoveLock.Leave( theLineFile );

	g_GuildMng.Clear();
	SAFE_DELETE( CGuildMember::sm_pPool );
	SAFE_DELETE( CGuild::sm_pPool );

	UninitializeNetLib();
}
Ejemplo n.º 11
0
// 각 대전장의 1:1길드대전 시작
void	CGuildCombat1to1Mng::GuildCombat1to1War()
{
	ClearTime();
	m_nState = GC1TO1_WAR;
	for( int i=0; i<(int)( m_vecTenderGuild.size() ); i++ )
	{
		for( int j=0; j<(int)( m_vecTenderGuild[i].vecMemberId.size() ); j++ )
		{
			CUser* pUser = (CUser*)prj.GetUserByID( m_vecTenderGuild[i].vecMemberId[j] );
			if( IsValidObj( pUser ) )
				SendNowState( pUser );
		}
	}

	for( int i=0; i<(int)( m_vecGuilCombat1to1.size() ); i++ )
	{
		DWORD dwWorldId = m_vecTenderGuild[m_vecGuilCombat1to1[i].m_nIndex[0]].dwWorldId;
		u_long uGuildId_0 = m_vecTenderGuild[m_vecGuilCombat1to1[i].m_nIndex[0]].ulGuildId;
		u_long uGuildId_1 = m_vecTenderGuild[m_vecGuilCombat1to1[i].m_nIndex[1]].ulGuildId;
		g_dpDBClient.SendGC1to1WarGuild( dwWorldId, uGuildId_0, uGuildId_1, 'W' );

		m_vecGuilCombat1to1[i].GuildCombat1to1WarWait();
	}
}
Ejemplo n.º 12
0
// 최근 경기 결과를 저장한다.
void	CGuildCombat1to1::SetLastWinState( int nIndex )
{
	// 생명수 초기화
	for( int i=0; i<2; i++ )
		m_vecTenderGuild[m_nIndex[i]].nNowPlayerLife = g_GuildCombat1to1Mng.m_nPlayerLife;

	switch( nIndex )
	{
		case 0 :	// 0이 이겼을 때
			m_vecTenderGuild[m_nIndex[0]].nLastWinState = g_GuildCombat1to1Mng.GC1TO1_PLAYER_WIN;
			if( (int)( m_vecTenderGuild[m_nIndex[0]].vecMemberId.size() ) > m_nProgWarCount	)
				g_dpDBClient.SendGC1to1WarPerson( m_vecTenderGuild[m_nIndex[0]].ulGuildId, m_vecTenderGuild[m_nIndex[0]].vecMemberId[m_nProgWarCount], 'W' );
			m_vecTenderGuild[m_nIndex[1]].nLastWinState = g_GuildCombat1to1Mng.GC1TO1_PLAYER_LOSE;
			if( (int)( m_vecTenderGuild[m_nIndex[1]].vecMemberId.size() ) > m_nProgWarCount	)
				g_dpDBClient.SendGC1to1WarPerson( m_vecTenderGuild[m_nIndex[1]].ulGuildId, m_vecTenderGuild[m_nIndex[1]].vecMemberId[m_nProgWarCount], 'L' );
			break;

		case 1 :	// 1이 이겼을 때
			m_vecTenderGuild[m_nIndex[0]].nLastWinState = g_GuildCombat1to1Mng.GC1TO1_PLAYER_LOSE;
			if( (int)( m_vecTenderGuild[m_nIndex[0]].vecMemberId.size() ) > m_nProgWarCount	)
				g_dpDBClient.SendGC1to1WarPerson( m_vecTenderGuild[m_nIndex[0]].ulGuildId, m_vecTenderGuild[m_nIndex[0]].vecMemberId[m_nProgWarCount], 'L' );
			m_vecTenderGuild[m_nIndex[1]].nLastWinState = g_GuildCombat1to1Mng.GC1TO1_PLAYER_WIN;
			if( (int)( m_vecTenderGuild[m_nIndex[1]].vecMemberId.size() ) > m_nProgWarCount	)
				g_dpDBClient.SendGC1to1WarPerson( m_vecTenderGuild[m_nIndex[1]].ulGuildId, m_vecTenderGuild[m_nIndex[1]].vecMemberId[m_nProgWarCount], 'W' );
			break;

		case 2 :	// 비겼을 때
			m_vecTenderGuild[m_nIndex[0]].nLastWinState = g_GuildCombat1to1Mng.GC1TO1_PLAYER_DRAW;
			if( (int)( m_vecTenderGuild[m_nIndex[0]].vecMemberId.size() ) > m_nProgWarCount	)
				g_dpDBClient.SendGC1to1WarPerson( m_vecTenderGuild[m_nIndex[0]].ulGuildId, m_vecTenderGuild[m_nIndex[0]].vecMemberId[m_nProgWarCount], 'D' );
			m_vecTenderGuild[m_nIndex[1]].nLastWinState = g_GuildCombat1to1Mng.GC1TO1_PLAYER_DRAW;
			if( (int)( m_vecTenderGuild[m_nIndex[1]].vecMemberId.size() ) > m_nProgWarCount	)
				g_dpDBClient.SendGC1to1WarPerson( m_vecTenderGuild[m_nIndex[1]].ulGuildId, m_vecTenderGuild[m_nIndex[1]].vecMemberId[m_nProgWarCount], 'D' );
			break;
	}
}
Ejemplo n.º 13
0
// 입찰 및 입찰금 순서로 정렬
void	CGuildCombat1to1Mng::SetTenderGuild( CUser* pUser, int nPenya )
{
	if( !g_eLocal.GetState( EVE_GUILDCOMBAT1TO1 ) )
		return;
	
	if( m_nState != GC1TO1_CLOSE )
	{
		pUser->AddDiagText( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_NOTENDER ) );
		return;
	}
	
	// 길드대전에 입찰한 길드는 입찰할 수 없다.
	if( IsGCTenderGuild( pUser ) )
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_ISGCTENDER );
		return;
	}
	
	// 길드마스터만 입찰 가능
	if( !IsGuildMaster( pUser ) )
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_NOTMASTER );
		return;
	}

	// 참가할 수 있는 최소 길드레벨 검사...
	if( pUser->GetGuild()->m_nLevel < m_nGuildLevel )
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_LOWGUILDLEVEL, "%d", m_nGuildLevel );
		return;
	}
	
	// 최소 입찰 페냐 보다 많아야 한다.
	if( nPenya < m_nJoinPenya )
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_LIMIT_MIN );
		return;
	}

	// 로그 남길 준비(아이템로그)
	LogItemInfo aLogItem;
	aLogItem.Action = "9";
	aLogItem.SendName = pUser->GetName();
	aLogItem.RecvName = "GUILDCOMBAT1TO1";
	aLogItem.WorldId = pUser->GetWorld()->GetID();
	//aLogItem.ItemName = "SEED";
	_stprintf( aLogItem.szItemName, "%d", II_GOLD_SEED1 );
	
	int nIndex = GetTenderGuildIndexByUser( pUser );
	if( nIndex != NULL_ID ) // 이미 입찰한 길드는 더많은 금액으로 입찰해야 한다.
	{
		if( m_vecTenderGuild[nIndex].nPenya < nPenya )
		{
			if( (DWORD)( nPenya ) > (DWORD)(pUser->GetGold() + m_vecTenderGuild[nIndex].nPenya) )
			{
				pUser->AddDefinedText( TID_GAME_LACKMONEY );	// 페냐가 부족하다.
				return;
			}

			pUser->AddGold( m_vecTenderGuild[nIndex].nPenya - nPenya );
			CString strTemp;
			strTemp.Format( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_MORETENDER ), nPenya - m_vecTenderGuild[nIndex].nPenya, nPenya );
			pUser->AddDiagText( strTemp );
			m_vecTenderGuild[nIndex].nPenya = nPenya;
			// 로그 남김
			aLogItem.Gold = pUser->GetGold() + (nPenya - m_vecTenderGuild[nIndex].nPenya) ;
			aLogItem.Gold2 = pUser->GetGold();
			aLogItem.Gold_1 = m_vecTenderGuild[nIndex].nPenya - nPenya;
			g_DPSrvr.OnLogItem( aLogItem );
			g_dpDBClient.SendGC1to1Tender( 'U', pUser->m_idGuild, nPenya, 'T' );
		}
		else // 기존보다 더 많은 페냐 입찰 요구
		{
			pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_MORE_CURRENT_REQUEST );
			return;
		}
	}
	else	// 처음 입찰하는 길드이면..
	{
		if( nPenya > pUser->GetGold() )	// 페냐 부족
		{
			pUser->AddDefinedText( TID_GAME_LACKMONEY );
			return;
		}

		__GC1TO1TENDER	TenderGuild;
		TenderGuild.ulGuildId = pUser->m_idGuild;
		TenderGuild.nPenya = nPenya;
		m_vecTenderGuild.push_back( TenderGuild );
		pUser->AddGold( -nPenya );
		CString strTemp;
		strTemp.Format( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_TENDERPENYA ), nPenya );
		pUser->AddDiagText( strTemp );
		// 로그 남김
		aLogItem.Gold = pUser->GetGold() + nPenya;
		aLogItem.Gold2 = pUser->GetGold();
		aLogItem.Gold_1 = -nPenya;
		g_DPSrvr.OnLogItem( aLogItem );
		g_dpDBClient.SendGC1to1Tender( 'I', pUser->m_idGuild, nPenya, 'T' );
	}

	// 입찰금 순서로 정렬
	if( m_vecTenderGuild.size() < 2 )
		return;
	for( int i=0; i<(int)( m_vecTenderGuild.size()-1 ); i++ )
	{
		for( int j=0; j<(int)( m_vecTenderGuild.size()-i-1 ); j++ )
		{
			if( m_vecTenderGuild[j].nPenya < m_vecTenderGuild[j+1].nPenya )
			{
				__GC1TO1TENDER temp = m_vecTenderGuild[j];
				m_vecTenderGuild[j] = m_vecTenderGuild[j+1];
				m_vecTenderGuild[j+1] = temp;
			}
		}
	}
}
Ejemplo n.º 14
0
void CQuiz::Process()
{
	DWORD dwTick = GetTickCount();
	vector<QUIZLIST>::iterator it = m_vecQuizList.begin();
	
	switch( m_nState )
	{
	case QE_CLOSE:
		// 퀴즈 이벤트 종료. 모든 유저 밖으로 이동
		if( dwTick > GetNextTime() )
			CloseQuizEvent();

		break;

	case QE_OPEN:
		{
			if( dwTick > GetNextTime() )
			{
				if( !m_vecQuizList.size() )
				{
					Error( "Quiz List Load Failed!" );
					CloseQuizEvent();
					return;
				}
				if( (int)( m_vecQuizList.size() ) < m_nQuizSize )
					break;
				BOOL bAble = FALSE;
				int nUser = 0;
				CWorld* pWorld = g_WorldMng.GetWorld( WI_WORLD_QUIZ );
				if( pWorld )
				{
					for( DWORD i = 0; i < pWorld->m_dwObjNum; ++i )
					{
						if( IsInQuizEventPlayer( pWorld, nDefaultLayer, i ) )
						{
							static_cast<CUser*>( pWorld->m_apObject[i] )->AddQuizEventMessage( prj.GetText( TID_GAME_QUIZ_WAIT_QUESTION ) );
							bAble = TRUE;
							++nUser;
						}
					}
				}
				if( !bAble )
				{
					CloseQuizEvent();
					return;
				}

				if( nUser <= LIMIT_USER_COUNT )
					m_bSelectLog = TRUE;

				SetNextTime( dwTick + m_dwWaitTime );
				SetState( QE_QUESTION );
				g_dpDBClient.SendQuizEventState( QE_QUESTION, g_uIdofMulti );
			}
		}
		
		break;

	case QE_QUESTION:
		// 문제 출제
		if( dwTick > GetNextTime() )
		{
			// UI
			CWorld* pWorld = g_WorldMng.GetWorld( WI_WORLD_QUIZ );
			if( pWorld )
			{
				for( DWORD i = 0; i < pWorld->m_dwObjNum; ++i )
				{
					if( IsInQuizEventPlayer( pWorld, nDefaultLayer, i ) )
					{
						static_cast<CUser*>( pWorld->m_apObject[i] )->AddQuizEventMessage( prj.GetText( TID_GAME_QUIZ_QUESTION ), QE_QUESTION );
						static_cast<CUser*>( pWorld->m_apObject[i] )->AddQuizQuestion( GetType(), it->strQuestion, m_dwQuestionTime / SEC(1) );
					}
				}
			}

			SetNextTime( dwTick + m_dwQuestionTime );
			SetState( QE_CORRECT_ANSWER );
			g_dpDBClient.SendQuizEventState( QE_CORRECT_ANSWER, g_uIdofMulti );
			++m_nQuizCount;
		}
		
		break;
		
	case QE_CORRECT_ANSWER:
		// 정답 공개
		if( dwTick > GetNextTime() )
		{
/*			// 유저 이동 불가 - object
			DWORD dwId	= NULL;
			
			if( GetType() == TYPE_OX )
				dwId = 1116;
			else
				dwId = 1115;
			
			m_pVObj = CreateObj( D3DDEVICE, OT_OBJ, dwId );
			if( !m_pVObj )
				return;
			
			m_pVObj->SetPos( m_sQuizData.vQuizZonePos );
			m_pVObj->UpdateLocalMatrix();
			CWorld* pWorld = g_WorldMng.GetWorld( WI_WORLD_QUIZ );
			if( pWorld )
				pWorld->ADDOBJ( m_pVObj, TRUE, nDefaultLayer );
			
			if( GetType() == TYPE_4C )
			{
				m_pHObj = CreateObj( D3DDEVICE, OT_OBJ, dwId );
				if( !m_pHObj )
					return;
				
				m_pHObj->SetPos( m_sQuizData.vQuizZonePos );
				m_pHObj->SetAngle( 90 );
				m_pHObj->UpdateLocalMatrix();
				CWorld* pWorld = g_WorldMng.GetWorld( WI_WORLD_QUIZ );
				if( pWorld )
					pWorld->ADDOBJ( m_pHObj, TRUE, nDefaultLayer );
			}*/

			// 문제 풀이 종료 메세지
			CString str_Message;
			str_Message.Format( prj.GetText( TID_GAME_QUIZ_END_SOLVE_QUESTION ), m_nQuizCount );

			// 정답 메세지
			CString strMessage;
			if( GetType() == TYPE_OX )
			{
				if( it->nCorrect == 1 )
					strMessage.Format( prj.GetText( TID_GAME_QUIZ_CORRECT_ANSWER_OX ), 'O' );
				else
					strMessage.Format( prj.GetText( TID_GAME_QUIZ_CORRECT_ANSWER_OX ), 'X' );
			}
			else if( GetType() == TYPE_4C )
				strMessage.Format( prj.GetText( TID_GAME_QUIZ_CORRECT_ANSWER_4C ), it->nCorrect );

			D3DXVECTOR3 vPos = m_sQuizData.aExamplePos[(*it).nCorrect - 1];
			g_UserMng.AddWorldCreateSfxObj( XI_QUIZCORRECTANSWER, vPos.x, vPos.y, vPos.z, FALSE, WI_WORLD_QUIZ );
			
			CWorld* pWorld = g_WorldMng.GetWorld( WI_WORLD_QUIZ );
			if( pWorld )
			{
				for( DWORD i = 0; i < pWorld->m_dwObjNum; ++i )
				{
					if( IsInQuizEventPlayer( pWorld, nDefaultLayer, i ) )
					{
						static_cast<CUser*>( pWorld->m_apObject[i] )->AddQuizEventMessage( str_Message, QE_CORRECT_ANSWER );
						static_cast<CUser*>( pWorld->m_apObject[i] )->AddQuizEventMessage( strMessage );
					}
				}
			}

			SetNextTime( dwTick + m_dwWaitTime );
			SetState( QE_DROP_OUT );
			g_dpDBClient.SendQuizEventState( QE_DROP_OUT, g_uIdofMulti );
		}
		
		break;
		
	case QE_DROP_OUT:
		if( dwTick > GetNextTime() )
		{
			// 탈락자 대기존으로 이동
			DropOutWrongUser( (*it).nQuizId, (*it).nCorrect );
			m_vecQuizList.erase( it );
		}
		
		break;
		
	case QE_CLOSE_WAIT:
		{
			// 문제가 요구치 보다 많이 남아있을 시 대기존 개방
			if( m_vecQuizList.size() > REMAIN_QUIZ )
			{
				CWorld* pWorld = g_WorldMng.GetWorld( WI_WORLD_QUIZ );
				if( pWorld )
				{
					for( DWORD i = 0; i < pWorld->m_dwObjNum; ++i )
					{
						if( IsInQuizEventPlayer( pWorld, nDefaultLayer, i ) )
						{
							static_cast<CUser*>( pWorld->m_apObject[i] )->AddQuizEventMessage( prj.GetText( TID_GAME_QUIZ_WATCHINGZONE_OPEN ), QE_WATCHINGZONE_OPEN );
							static_cast<CUser*>( pWorld->m_apObject[i] )->AddQuizEventMessage( prj.GetText( TID_GAME_QUIZ_TELEPORT_QUIZZONE ) );
						}
					}
				}
				
				SetNextTime( dwTick + m_dwWatchingZoneOpenTime );
				SetState( QE_WATCHINGZONE_OPEN );
				m_bSelectLog = FALSE;
				m_nQuizCount = 0;
				g_dpDBClient.SendQuizEventState( QE_WATCHINGZONE_OPEN, g_uIdofMulti );
			}
			// 문제가 요구치 보다 적을 시 퀴즈 이벤트 종료
			else
			{
				g_DPCoreClient.SendQuizSystemMessage( TID_GAME_QUIZ_CLOSING, TRUE, g_uIdofMulti );
				SetNextTime( dwTick + m_dwCloseWaitTime );
				SetState( QE_CLOSE );
				g_dpDBClient.SendQuizEventState( QE_CLOSE_WAIT, g_uIdofMulti );
			}
		}
		
		break;

	case QE_WATCHINGZONE_OPEN:
		// 대기존 개방
		if( dwTick > GetNextTime() )
		{
			BOOL bAble = FALSE;
			int nUser = 0;
			CWorld* pWorld = g_WorldMng.GetWorld( WI_WORLD_QUIZ );
			if( pWorld )
			{
				for( DWORD i = 0; i < pWorld->m_dwObjNum; ++i )
				{
					if( IsInQuizEventPlayer( pWorld, nDefaultLayer, i ) )
					{
						static_cast<CUser*>( pWorld->m_apObject[i] )->AddQuizEventMessage( prj.GetText( TID_GAME_QUIZ_WAIT_QUESTION ) );
						//if( static_cast<CUser*>( pWorld->m_apObject[i] )->IsAuthHigher( AUTH_GAMEMASTER ) == FALSE )
						if( GetZoneType( static_cast<CMover*>( pWorld->m_apObject[i] ) ) == ZONE_QUIZ )
						{
							bAble = TRUE;
							++nUser;
						}
					}
				}
			}
			if( bAble )
			{
				SetNextTime( dwTick + m_dwWaitTime );
				SetState( QE_QUESTION );
				if( nUser <= LIMIT_USER_COUNT )
					m_bSelectLog = TRUE;
			}
			else
			{
				CloseQuizEvent();
				return;
			}
		}

		break;
	}
}
Ejemplo n.º 15
0
//int __EndQuest( int nPcId, int nQuestId, BOOL IsEndQuestCondition = TRUE )
int __EndQuest( int nPcId, int nQuestId, BOOL IsEndQuestCondition )
{
	int nNum;
	QuestProp* pQuestProp = prj.m_aPropQuest.GetAt( nQuestId );

	if( pQuestProp )
	{
		CUser* pUser = prj.GetUser( nPcId );
		if( IsEndQuestCondition )
		{
			if( __IsEndQuestCondition( pUser, nQuestId ) == 0 )
				return FALSE;
		}
		// 보상 아이템 갯수 만큼, 인벤토리 여유가 있는가?
		int nItemNum = 0;
		for( int i = 0; i < pQuestProp->m_nEndRewardItemNum; i++ )
		{
			QuestPropItem* pEndRewardItem = &pQuestProp->m_paEndRewardItem[ i ];
			if( pEndRewardItem->m_nSex == -1 || pEndRewardItem->m_nSex == pUser->GetSex() )
			{
				if( pEndRewardItem->m_nType == 0 )
				{
					if( pEndRewardItem->m_nJobOrItem == -1 || pEndRewardItem->m_nJobOrItem == pUser->GetJob() )
					{
						if( pEndRewardItem->m_nItemIdx )
						{
							ItemProp* pItemProp = prj.GetItemProp(  pEndRewardItem->m_nItemIdx );
							int nDiv = pEndRewardItem->m_nItemNum / pItemProp->dwPackMax;
							int nSur = pEndRewardItem->m_nItemNum % pItemProp->dwPackMax;
							if( nSur ) nDiv++;
							nItemNum += nDiv;
						}
					}
				}
				else
				if( pEndRewardItem->m_nType == 1 )
				{
					if( pEndRewardItem->m_nJobOrItem == -1 || pUser->GetItemNum( pEndRewardItem->m_nJobOrItem ) )
					{
						if( pEndRewardItem->m_nItemIdx )
						{
							ItemProp* pItemProp = prj.GetItemProp(  pEndRewardItem->m_nItemIdx );
							int nDiv = pEndRewardItem->m_nItemNum / pItemProp->dwPackMax;
							int nSur = pEndRewardItem->m_nItemNum % pItemProp->dwPackMax;
							if( nSur ) nDiv++;
							nItemNum += nDiv;
						}
					}
				}
			}
		}
		if( nItemNum > pUser->m_Inventory.GetEmptyCount() ) 
		{
			pUser->AddDefinedText( TID_QUEST_NOINVENTORYSPACE ); // 인벤토리 공간이 없어서 퀘스트를 완료할 수 없습니다.
			RunScriptFunc rsf;
			rsf.wFuncType		= FUNCTYPE_EXIT;
			pUser->AddRunScriptFunc( rsf );
			return FALSE;
		}
		////////////////////////////
		// 보상 지급 
		////////////////////////////
		for( i = 0; i < pQuestProp->m_nEndRewardItemNum; i++ )
		{
			QuestPropItem* pEndRewardItem = &pQuestProp->m_paEndRewardItem[ i ];
			if( pEndRewardItem->m_nSex == -1 || pEndRewardItem->m_nSex == pUser->GetSex() )
			{
				if( pEndRewardItem->m_nType == 0 )
				{
					if( pEndRewardItem->m_nJobOrItem == -1 || pEndRewardItem->m_nJobOrItem == pUser->GetJob() )
					{
						if( pEndRewardItem->m_nItemIdx )
						{
							int nItemNum = pEndRewardItem->m_nItemNum;
#ifdef __JEFF_11
#if __VER >= 13 // __CHIPI_QUESTITEM_FLAG
							__CreateItem( nPcId, pEndRewardItem->m_nItemIdx, nItemNum, pEndRewardItem->m_nAbilityOption, pEndRewardItem->m_byFlag );
#else // __CHIPI_QUESTITEM_FLAG
							__CreateItem( nPcId, pEndRewardItem->m_nItemIdx, nItemNum, pEndRewardItem->m_nAbilityOption );
#endif // __CHIPI_QUESTITEM_FLAG
#else	// __JEFF_11
							__CreateItem( nPcId, pEndRewardItem->m_nItemIdx, nItemNum );
#endif	// __JEFF_11
						}
					}
				}
				else
				if( pEndRewardItem->m_nType == 1 )
				{
					if( pEndRewardItem->m_nJobOrItem == -1 || pUser->GetItemNum( pEndRewardItem->m_nJobOrItem ) )
					{
						if( pEndRewardItem->m_nItemIdx )
						{
							int nItemNum = pEndRewardItem->m_nItemNum;
#ifdef __JEFF_11
#if __VER >= 13 // __CHIPI_QUESTITEM_FLAG
							__CreateItem( nPcId, pEndRewardItem->m_nItemIdx, nItemNum, pEndRewardItem->m_nAbilityOption, pEndRewardItem->m_byFlag );
#else // __CHIPI_QUESTITEM_FLAG
							__CreateItem( nPcId, pEndRewardItem->m_nItemIdx, nItemNum, pEndRewardItem->m_nAbilityOption );
#endif // __CHIPI_QUESTITEM_FLAG
#else	// __JEFF_11
							__CreateItem( nPcId, pEndRewardItem->m_nItemIdx, nItemNum );
#endif	// __JEFF_11
						}
					}
				}
			}
		}
#if __VER >= 9	// __PET_0410
		if( pQuestProp->m_bEndRewardPetLevelup )
			pUser->PetLevelup();
#endif	// __PET_0410
		if(	pQuestProp->m_nEndRewardGoldMin )
		{
			nNum = pQuestProp->m_nEndRewardGoldMax - pQuestProp->m_nEndRewardGoldMin + 1; 
			int nGold = pQuestProp->m_nEndRewardGoldMin + xRandom( nNum ); 
			pUser->AddGold( nGold );
			pUser->AddGoldText( nGold );
		}
		if(	pQuestProp->m_nEndRewardExpMin )
		{
			nNum = pQuestProp->m_nEndRewardExpMax - pQuestProp->m_nEndRewardExpMin + 1; 
			int nExp = pQuestProp->m_nEndRewardExpMin + xRandom( nNum ); 
			if( pUser->AddExperience( nExp, TRUE, FALSE ) )
				pUser->LevelUpSetting();
			else
				pUser->ExpUpSetting();
			
			pUser->AddSetExperience( pUser->GetExp1(), (WORD)pUser->m_nLevel, pUser->m_nSkillPoint, pUser->m_nSkillLevel );
			pUser->AddDefinedText( TID_GAME_REAPEXP );
		}
		if( pQuestProp->m_nEndRewardSkillPoint )
		{
			pUser->AddSkillPoint( pQuestProp->m_nEndRewardSkillPoint );
			pUser->AddSetExperience( pUser->GetExp1(), (WORD)pUser->m_nLevel, pUser->m_nSkillPoint, pUser->m_nSkillLevel );
			g_dpDBClient.SendLogSkillPoint( LOG_SKILLPOINT_GET_QUEST, pQuestProp->m_nEndRewardSkillPoint, (CMover*)pUser, NULL );
		}

#if __VER >= 8 // __S8_PK
		if( pQuestProp->m_nEndRewardPKValueMin || pQuestProp->m_nEndRewardPKValueMax )
		{
			if( pQuestProp->m_nEndRewardPKValueMin <= pQuestProp->m_nEndRewardPKValueMax )
			{
				int nPKValue = pUser->GetPKValue() - xRandom( pQuestProp->m_nEndRewardPKValueMin, pQuestProp->m_nEndRewardPKValueMax + 1 );
				if( nPKValue < 0 )
					nPKValue = 0;
				pUser->SetPKValue( nPKValue );
				pUser->AddPKValue();
				g_dpDBClient.SendLogPkPvp( (CMover*)pUser, NULL, 0, 'P' );
#if __VER >= 13 // __HONORABLE_TITLE			// 달인
				pUser->CheckHonorStat();
				g_UserMng.AddHonorTitleChange( pUser, pUser->m_nHonor);
#endif	// __HONORABLE_TITLE			// 달인
			}
		}
#else // __VER >= 8 // __S8_PK
		if( pQuestProp->m_nEndRewardKarmaStyle )
		{
			if( pQuestProp->m_nEndRewardKarmaStyle == 1 )
				pUser->ChangeSlaughter( CHANGE_SLAUGHTER_SET, NULL, pQuestProp->m_nEndRewardKarmaPoint );
			else
			if( pQuestProp->m_nEndRewardKarmaStyle == 2 )
			{
				int nKarma = pUser->GetKarma();
				pUser->ChangeSlaughter( CHANGE_SLAUGHTER_SET, NULL, nKarma + pQuestProp->m_nEndRewardKarmaPoint ); 
			}
		}
#endif // __VER >= 8 // __S8_PK
#if __VER >= 9 // __S_9_ADD
		if( pQuestProp->m_nEndRewardTeleport != 0 )
			pUser->REPLACE( g_uIdofMulti, pQuestProp->m_nEndRewardTeleport, pQuestProp->m_nEndRewardTeleportPos, REPLACE_NORMAL, nTempLayer );
#endif // __S_9_ADD
		// 시작시 변신을 했으면 종료시 변신 해제시킨다.
		if( pQuestProp->m_nBeginSetDisguiseMoverIndex )
		{
			CUser* pUser = prj.GetUser( nPcId );
			pUser->NoDisguise( NULL );
			g_UserMng.AddNoDisguise( pUser );
		}
#if __VER >= 15 // __CAMPUS
		if( pQuestProp->m_nEndRewardTSP )
			g_dpDBClient.SendUpdateCampusPoint( pUser->m_idPlayer, pQuestProp->m_nEndRewardTSP, TRUE, 'Q' );

		if( pQuestProp->m_nEndRemoveTSP )
			g_dpDBClient.SendUpdateCampusPoint( pUser->m_idPlayer, pQuestProp->m_nEndRemoveTSP, FALSE, 'Q' );
#endif // __CAMPUS
		////////////////////////////
		// 아이템 제거 
		////////////////////////////
		for( i = 0; i < 8; i++ )
		{
			if( pQuestProp->m_nEndRemoveItemIdx[ i ] )
			{
				int nItemNum = pQuestProp->m_nEndRemoveItemNum[ i ];
				if( nItemNum > 0x7fff )		// 삭제될 아이템 개수가 short의 MAX를 넘으면..
				{
					for( ; nItemNum > 0x7fff; )
					{
						pUser->RemoveItemA( pQuestProp->m_nEndRemoveItemIdx[ i ], 0x7fff );
						nItemNum -= 0x7fff;
					}
				}
				pUser->RemoveItemA( pQuestProp->m_nEndRemoveItemIdx[ i ], nItemNum );
			}
		}
		if( pQuestProp->m_nEndRemoveGold )
			__RemoveGold( nPcId, pQuestProp->m_nEndRemoveGold );
		////////////////////////////
		// 퀘스트 제거 (완료,진행 모두 제거함)
		////////////////////////////
		for( i = 0; i < MAX_QUESTREMOVE; i++ )
		{
			if( pQuestProp->m_anEndRemoveQuest[ i ] )
			{
				__RemoveQuest( nPcId, pQuestProp->m_anEndRemoveQuest[ i ] );
			}
		}
		// 퀘스트 종료 
		__SetQuestState( nPcId, nQuestId, QS_END );
	}
	return 1;
}
Ejemplo n.º 16
0
// 1대1 길드대전 오픈
void	CGuildCombat1to1Mng::GuildCombat1to1Open( BOOL bGMText )
{
	if( !g_eLocal.GetState( EVE_GUILDCOMBAT1TO1 ) )
		return;
	
	vector<__GC1TO1TENDER>::iterator it;
	if( !bGMText )
	{
		for( it=m_vecTenderFailGuild.begin(); it!=m_vecTenderFailGuild.end(); it++ )
		{
			// 이전 1:1길드대전에 입찰 실패 길드가 신청금을 수령하지 않았을 경우
			g_dpDBClient.SendGC1to1Tender( 'U', (*it).ulGuildId, (*it).nPenya, 'N' );
		}
		m_vecTenderFailGuild.clear();
	}
	
	// 신청한  길드수가 최소 참여 길드수보다 적을 때
	if( (int)( m_vecTenderGuild.size() ) < m_nMinJoinGuild )
	{
		// 1대1 길드대전 취소 및 연장 처리
		CString strTemp;
		strTemp.Format( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_NOGAME ), m_nMinJoinGuild );
		g_DPCoreClient.SendCaption( strTemp );	
		ClearTime();
		m_nState = GC1TO1_CLOSE;
		return;
	}
	
	// 1:1길드대전 오픈 메세지..
	g_DPCoreClient.SendCaption( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_OPEN ) );
	g_DPCoreClient.SendCaption( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_LINEUP ) );
	
	// 참가자 구성 시간 설정
	m_nState = GC1TO1_OPEN;
	m_nWaitTime = (int)m_Lua.GetGlobalNumber( "MemberLineUpTime" );
	m_dwTime = GetTickCount();	

	// 입찰 순위에 들지 못한 길드 제거
	int nCount = 0;
	for( it=m_vecTenderGuild.begin(); it!=m_vecTenderGuild.end(); )
	{
		nCount++;
		if( nCount <= m_nMaxJoinGuild )
			it++;
		else // 입찰 순위에서 밀려난 경우
		{
			CGuild* pGuild = g_GuildMng.GetGuild( (*it).ulGuildId );
			if( pGuild )
			{
				CUser* pUser = (CUser*)prj.GetUserByID( pGuild->m_idMaster );
				if( IsValidObj( pUser ) )
					pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_FAILTENDER );
			}
			
			g_dpDBClient.SendGC1to1Tender( 'U', (*it).ulGuildId, (*it).nPenya, 'F' );
			m_vecTenderFailGuild.push_back( (*it) );
			it = m_vecTenderGuild.erase( it );
		}
	}		

	// 입찰 순위에는 들어갔지만 상대 길드가 없는 경우(홀수)
	if( m_vecTenderGuild.size() % 2 != 0 )
	{
		it = m_vecTenderGuild.end(); it--;	// 마지막 순위		// 노트 :  rbegin()을 사용하시오.
		CGuild* pGuild = g_GuildMng.GetGuild( (*it).ulGuildId );
		if( pGuild )
		{
			CUser* pUser = (CUser*)prj.GetUserByID( pGuild->m_idMaster );
			if( IsValidObj( pUser ) )
				pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_FAILTENDER );
		}

		g_dpDBClient.SendGC1to1Tender( 'U', (*it).ulGuildId, (*it).nPenya, 'F' );
		m_vecTenderFailGuild.push_back( (*it) );
		m_vecTenderGuild.erase( it );
	}

	// 출전 가능한 길드의 모든 길드원에게 OPEN STATE 알림(길드 마스터는 참가자 구성 시간 출력)
	for( it=m_vecTenderGuild.begin(); it!=m_vecTenderGuild.end(); it++ )
	{
		CGuild* pGuild = g_GuildMng.GetGuild( (*it).ulGuildId );
		if( pGuild )
		{
			for( map<u_long, CGuildMember*>::iterator it2=pGuild->m_mapPMember.begin(); it2!=pGuild->m_mapPMember.end(); it2++ )
			{
				CUser* pUser = (CUser*)prj.GetUserByID( it2->first );
				if( IsValidObj( pUser ) )
					SendNowState( pUser );
			}
		}
	}

	g_dpDBClient.SendGC1to1StateToDBSrvr();	// 1:1길드대전이 오픈되었다고 DBServer에 알림
}
Ejemplo n.º 17
0
void CRunObject::Run( void )
{
	HANDLE hHeartbeat;
	if( !( hHeartbeat = CreateEvent( NULL, FALSE, FALSE, g_sHeartbeat ) ) )
		hHeartbeat	= OpenEvent( EVENT_MODIFY_STATE, FALSE, g_sHeartbeat );
	if( NULL == hHeartbeat )
		Error( "MAPI_E_NOT_ENOUGH_RESOURCES" );
	DWORD dwTickHearbeat = timeGetTime() + SEC( 2 );

	CTimeout	timeoutObject( 67, 0 );
	CTimeout	timeoutReadAgent( 67, 20 );
	CTimeout	timeoutReadCore( 67, 40 );
	CTimeout	timeoutReadTrans( 67, 50 );
	CTimeout	timeoutReadAccount( 67, 60 );
	CTimeout	timeoutRespawn( 1000, 200 );
	CTimeout	timeout( 1000, 600 );
#ifdef __EVENT_1101
	CTimeout	timeoutCallTheRoll( MIN( 1 ), 70 );
#endif	// __EVENT_1101

	DWORD dwCur, dwOld;

	while( WaitForSingleObject( m_hClose, 1 ) != WAIT_OBJECT_0 )
	{
		{
			_PROFILE( "CRunObject::Run()" );
			g_tmCurrent		= timeGetTime();
			g_tCurrent	= time( NULL );
			
			dwCur = g_tmCurrent;
			dwOld = dwCur;

			if( timeoutObject.TimeoutReset( g_tmCurrent ) )
			{
				_PROFILE( "CWorldMng::Process()" );
				g_WorldMng.Process();
				if( g_tmCurrent > dwTickHearbeat )
				{
					SetEvent( hHeartbeat );
					dwTickHearbeat = g_tmCurrent + SEC( 2 );
				}
			}
			
			PROFILE_RUN( r1 );

			if( timeoutReadAgent.TimeoutReset( g_tmCurrent ) )
			{
				_PROFILE( "g_DPSrvr.ReceiveMessage()" );
				g_DPSrvr.ReceiveMessage();
			}

			PROFILE_RUN( r2 );

			if( timeoutReadCore.TimeoutReset( g_tmCurrent ) )
			{
				_PROFILE( "g_DPCoreClient.ReceiveMessage()" );
				g_DPCoreClient.ReceiveMessage();
			}

			PROFILE_RUN( r3 );

			if( timeoutReadTrans.TimeoutReset( g_tmCurrent ) )
			{
				_PROFILE( "g_dpDBClient.ReceiveMessage()" );
				g_dpDBClient.ReceiveMessage();
			}

			PROFILE_RUN( r4 );
		
/*
		#ifdef __GIFTBOX0213
			if( timeoutReadAccount.TimeoutReset( g_tmCurrent ) )
				CDPAccountClient::GetInstance()->ReceiveMessage();
		#endif	// __GIFTBOX0213
*/
		#ifdef __EVENTLUA_KEEPCONNECT
			if( timeoutReadAccount.TimeoutReset( g_tmCurrent ) )
				prj.m_EventLua.KeepConnectEventProcess();
		#endif // __EVENTLUA_KEEPCONNECT
			PROFILE_RUN( r5 );

			if( timeoutRespawn.TimeoutReset( g_tmCurrent ) )
			{
				_PROFILE( "g_WorldMng.Respawn()" );
				u_long uRespawned = g_WorldMng.Respawn();
//				if( uRespawned > 0 )
					SetLogInfo( LOGTYPE_RESPAWN, "Respawn:%d Object:%d", uRespawned, g_WorldMng.GetObjCount() );
			}

			PROFILE_RUN( r6 );
			

			if( timeout.TimeoutReset( g_tmCurrent ) )
			{
				_PROFILE( "1SEC_Process" );
				g_GameTimer.Compute();
				CGuildQuestProcessor::GetInstance()->Process();
				CPartyQuestProcessor::GetInstance()->Process();

				PROFILE_RUN( r7 );

				if( g_eLocal.GetState( EVE_GUILDCOMBAT ) )
					g_GuildCombatMng.Process();
	#if __VER >= 11 // __GUILD_COMBAT_1TO1
				if( g_eLocal.GetState( EVE_GUILDCOMBAT1TO1 ) )
					g_GuildCombat1to1Mng.Process();
	#endif // __GUILD_COMBAT_1TO1

	#if __VER >= 12 // __SECRET_ROOM
				if( g_eLocal.GetState( EVE_SECRETROOM ) )
				{
					_PROFILE( "CSecretRoomMng::Process()" );
					CSecretRoomMng::GetInstance()->Process();
				}
	#endif // __SECRET_ROOM
	#if __VER >= 13 // __RAINBOW_RACE
				if( g_eLocal.GetState( EVE_RAINBOWRACE ) )
				{
					_PROFILE( "CRainbowRaceMng::Process()" );
					CRainbowRaceMng::GetInstance()->Process();
				}
	#endif // __RAINBOW_RACE
	#if __VER >= 14 // __PCBANG
				{
					_PROFILE( "CPCBang::ProcessPCBang()" );
					CPCBang::GetInstance()->ProcessPCBang();
				}
	#endif // __PCBANG
	#if __VER >= 14 // __INSTANCE_DUNGEON
				{
					CInstanceDungeonParty::GetInstance()->Process();
				}
	#endif // __INSTANCE_DUNGEON

	#ifdef __QUIZ
				{
					if( CQuiz::GetInstance()->IsAutoMode() && CQuiz::GetInstance()->IsRun() )
						CQuiz::GetInstance()->Process();
				}
	#endif // __QUIZ

				PROFILE_RUN( r8 );
			
			
				if( g_eLocal.GetState( ENABLE_GUILD_INVENTORY ) )
					g_GuildMng.Process();

				PROFILE_RUN( r9 );

				if( g_eLocal.GetState( EVE_GUILDWAR ) )
					g_GuildWarMng.Process();

				g_PartyMng.PartyMapInfo();

				PROFILE_RUN( r10 );

	#if __VER >= 12 // __RANGDA_0521
				// 랜덤 이벤트 몬스터 초당 1회 틱
				CRangdaController::Instance()->OnTimer();
	#endif	// __RANGDA_0521
	#ifdef __EVENTLUA_SPAWN
				prj.m_EventLua.EventSpawnProcess();
	#endif // __EVENTLUA_SPAWN
			}

#ifdef __EVENT_1101
			if( timeoutCallTheRoll.TimeoutReset( g_tmCurrent ) )	// 1분당 
			{
				CEventGeneric::GetInstance()->CallTheRoll();
	#if __VER >= 12 // __NEW_ITEMCREATEMON_SERVER
				CCreateMonster::GetInstance()->ProcessRemoveMonster();
	#endif // __NEW_ITEMCREATEMON_SERVER
			}
	#endif	// __EVENT_1101

				PROFILE_RUN( r11 );

	#ifdef __EVENT_0117
			CEventGeneric::GetInstance()->Spawn();
	#endif	// __EVENT_0117

			PROFILE_RUN( r12 );
		}
		
		LogPerformance( timeGetTime() );
	
	}
	CLOSE_HANDLE( m_hClose );
	CLOSE_HANDLE( hHeartbeat );
}
Ejemplo n.º 18
0
BOOL CRunObject::Init( void )
{
	if( LoadAIScript() == FALSE )
		return FALSE;

// 
	m_hClose	= CreateEvent( NULL, FALSE, FALSE, NULL );
	DWORD dwThreadId;
	m_hRunObject	= chBEGINTHREADEX( NULL, 0, _Run, (LPVOID)this, 0, &dwThreadId ); 
//
	/*
#ifdef __GIFTBOX0213
	if( !CDPAccountClient::GetInstance()->ConnectToServer( s_szAccountAddr, PN_ACCOUNTSRVR_2, TRUE ) )
	{
		OutputDebugString( "Can't connect to account server." );
		return FALSE;
	}
	CGiftboxMan::GetInstance()->Upload( CDPAccountClient::GetInstance() );
#endif	// __GIFTBOX0213
	*/
	if( !g_DPSrvr.StartServer( (u_short)( g_uKey + PN_WORLDSRVR ), TRUE ) )
	{
		OutputDebugString( "Can't start server." );
		return FALSE;
	}
	if( !g_DPCoreClient.Run( g_szCoreAddr, PN_CORESRVR + 0, g_uKey ) )
	{
		OutputDebugString( "Can't connect to core server." );
		return FALSE;
	}
	if( !g_dpDBClient.ConnectToServer( g_szDBAddr, PN_DBSRVR_1, TRUE ) )
	{
		OutputDebugString( "Can't connect to database server." );
		return FALSE;
	}
	if ( g_eLocal.GetState( ENABLE_GUILD_INVENTORY ) )
		g_dpDBClient.SendQueryGuildBank();
	if( g_eLocal.GetState( EVE_WORMON ) )
		g_dpDBClient.SendQueryGuildQuest();

#if __VER >= 13 // __RAINBOW_RACE
	if( g_eLocal.GetState( EVE_RAINBOWRACE ) )
		g_dpDBClient.SendRainbowRaceReqLoad();
#endif // __RAINBOW_RACE

#ifdef __INVALID_LOGIN_0320
	g_dpDBClient.CalluspXXXMultiServer( g_uIdofMulti, NULL );
#else	// __INVALID_LOGIN_0320
	g_dpDBClient.CalluspXXXMultiServer( g_uIdofMulti, 0 );
#endif	// __INVALID_LOGIN_0320
	if( !CXMasEvent::GetInstance()->LoadScript( "spevent.txt" ) )
	{
		OutputDebugString( "can't read spevent.txt" );
		return FALSE;
	}
	if( g_eLocal.GetState( EVE_SCHOOL ) )
	{
#ifdef __IDC
		if( !CEveSchool::GetInstance()->LoadPos( "..\\script\\school.txt" ) )	//
#else	// __IDC
		if( !CEveSchool::GetInstance()->LoadPos( "school.txt" ) )
#endif	// __IDC
		{
			OutputDebugString( "school.txt not found" );
			return FALSE;
		}
	}
	if( g_eLocal.GetState( EVE_GUILDCOMBAT ) && !g_GuildCombatMng.LoadScript( "GuildCombat.txt" ) )
	{
		OutputDebugString( "GuildCombat.txt not found" );
		return FALSE;
	}
#if __VER >= 12 // __ITEMCREATEMON_S0602
#if __VER < 12 // __NEW_ITEMCREATEMON_SERVER
	if( !g_CreateMonster.LoadScript( "CreateMonster.txt" ) )
	{
		OutputDebugString( "CreateMonster.txt Not Found!" );
		return FALSE;
	}
#endif // __NEW_ITEMCREATEMON_SERVER
#endif // __ITEMCREATEMON_S0602

	return TRUE;
}
Ejemplo n.º 19
0
void ExitInstance( void )
{
	CRunObject::GetInstance()->Close();
	/*
#ifdef __GIFTBOX0213
	CDPAccountClient::GetInstance()->DeleteDPObject();
#endif	// __GIFTBOX0213
	*/

	g_DPSrvr.DeleteDPObject();
	g_DPCoreClient.DeleteDPObject();
	g_dpDBClient.DeleteDPObject();

	g_WorldMng.Free();

#ifndef __VM_0820
#ifndef __MEM_TRACE
	SAFE_DELETE( CUser::m_pPool );	
	SAFE_DELETE( CMover::m_pPool );		
	SAFE_DELETE( CActionMover::m_pPool );
	SAFE_DELETE( CAIMonster::m_pPool );	
	SAFE_DELETE( CItem::m_pPool );	
#endif	// __MEM_TRACE
#endif	// __VM_0820

	g_PartyMng.Clear();
#ifndef __VM_0820
#ifndef __MEM_TRACE
	SAFE_DELETE( CParty::m_pPool );
#endif	// __MEM_TRACE
#endif	// __VM_0820
	g_ChattingMng.Clear();
#ifndef __VM_0820
#ifndef __MEM_TRACE
	SAFE_DELETE( CChatting::m_pPool );
#endif	// __MEM_TRACE
#endif	// __VM_0820
	g_GuildWarMng.Clear();

	g_GuildMng.Clear();

#if __VER >= 13 // __HOUSING
	CHousingMng::GetInstance()->Clear();
#endif	// __HOUSING
#ifndef __VM_0820
#ifndef __MEM_TRACE
	SAFE_DELETE( CGuildMember::sm_pPool );
	SAFE_DELETE( CGuild::sm_pPool );
	SAFE_DELETE( CAIPet::m_pPool );
	SAFE_DELETE( CAIKrrr::m_pPool );
	SAFE_DELETE( CAIGuard::m_pPool );
	SAFE_DELETE( CAIClockWorks::m_pPool );
	SAFE_DELETE( CAIBigMuscle::m_pPool );
	SAFE_DELETE( CAIBear::m_pPool );
#endif	// __MEM_TRACE
#endif	// __VM_0820
	UninitializeNetLib();
	UninitializeScriptLib();

#ifndef __VM_0820
#ifndef __MEM_TRACE
	SAFE_DELETE( CAIPet::m_pPool );
#endif	// __MEM_TRACE
#endif	// __VM_0820
	g_Object3DMng.Destroy();
	prj.m_modelMng.DeleteDeviceObjects();

#if __VER >= 12 // __LORD
	CSLord::Instance()->DestroyColleagues();
#endif	// __LORD
}
Ejemplo n.º 20
0
void CQuiz::DropOutWrongUser( int nQuizId, int nCorrect, int nItemId, int nItemNum )
{
	int nCorrectUser = 0;
	CWorld* pWorld = g_WorldMng.GetWorld( WI_WORLD_QUIZ );
	if( pWorld )
	{
		for( DWORD i = 0; i < pWorld->m_dwObjNum; ++i )
		{
			if( IsInQuizEventPlayer( pWorld, nDefaultLayer, i ) )
			{
				if( m_bSelectLog )
				{
					int nSelect = GetUserSelectExample( static_cast<CUser*>( pWorld->m_apObject[i] ) );
					if( nSelect )
						g_dpDBClient.SendQuizEventSelect( static_cast<CUser*>( pWorld->m_apObject[i] )->m_idPlayer, g_uIdofMulti, nQuizId, nSelect, nCorrect );
				}
				static_cast<CUser*>( pWorld->m_apObject[i] )->AddQuizEventMessage( prj.GetText( TID_GAME_QUIZ_DROP_OUT ), QE_DROP_OUT );
				if( PtInCorrectZoneRect( static_cast<CUser*>( pWorld->m_apObject[i] ), nCorrect ) )
				{
					++nCorrectUser;
					// 091014 - mirchang : 시스템 부하 발생 가능성이 있어 보류
					//if( nItemId > 0 )	// Item Id가 있을시 정답자에게 해당 아이템 지급
					//	g_dpDBClient.SendPostPrizeItem( static_cast<CUser*>( pWorld->m_apObject[i] )->m_idPlayer, nItemId, nItemNum );
				}
			}
		}
		if( nCorrectUser <= LIMIT_USER_COUNT )
			m_bSelectLog = TRUE;
	}
	// 정답자 수가 2명 이상이고 문제가 남아있으면 문제 풀이 단계로 이동
	if( nCorrectUser > 1 && m_vecQuizList.size() > 1 )
	{
		SetNextTime( GetTickCount() + m_dwWaitTime );
		SetState( QE_QUESTION );
		g_dpDBClient.SendQuizEventState( QE_QUESTION, g_uIdofMulti );
	}
	// 우승자 상금 지급 후 진행 여부 판단
	else
	{
		CString strMessage;
		strMessage.Format( prj.GetText( TID_GAME_QUIZ_WINNERCOUNT ), nCorrectUser );
		if( pWorld )
		{
			for( DWORD i = 0; i < pWorld->m_dwObjNum; ++i )
			{
				if( IsInQuizEventPlayer( pWorld, nDefaultLayer, i ) )
				{
					static_cast<CUser*>( pWorld->m_apObject[i] )->AddQuizEventMessage( strMessage, QE_CLOSE_WAIT );
					// 스크립트에 정해진 아이템 지급
					if( PtInCorrectZoneRect( static_cast<CUser*>( pWorld->m_apObject[i] ), nCorrect ) )
						g_dpDBClient.SendPostPrizeItem( static_cast<CUser*>( pWorld->m_apObject[i] )->m_idPlayer, m_dwPrizeItemId, m_nPrizeItemNum );
				}
			}
			g_dpDBClient.SendQuizEventState( QE_WINNER, g_uIdofMulti, nCorrectUser, m_nQuizCount );
		}
		SetState( QE_CLOSE_WAIT );
	}
/*	// 유저 이동 가능 - object
	pWorld->DeleteObj( m_pVObj );
	m_pVObj = NULL;
	if( GetType() == TYPE_4C )
	{
		pWorld->DeleteObj( m_pHObj );
		m_pHObj = NULL;
	}*/
}
Ejemplo n.º 21
0
// 참가자 구성
void	CGuildCombat1to1Mng::SetMemberLineUp( CUser* pUser, vector<u_long>& vecMemberId )
{
	if( m_nState != GC1TO1_OPEN )	// 참가자 구성 시간이 아니다.
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_NOLINEUP );
		return;
	}

	int nIndex = GetTenderGuildIndexByUser( pUser );
	if( nIndex == NULL_ID )	// 입찰되지 않았거나 순위에서 밀린 길드
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_CANNOT_MAKEUP );
		return;
	}

	if( (int)( vecMemberId.size() ) < m_nMinJoinPlayer )	// 최소 참가자 수보다 적다.
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_LOWMINPLAYER, "%d", m_nMinJoinPlayer );
		return;
	}

	if( (int)( vecMemberId.size() ) > m_nMaxJoinPlayer )
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_OVERMAXPLAYER, "%d", m_nMaxJoinPlayer );
		return;
	}

	// 길드마스터 또는 킹핀급만 가능
	CGuild* pGuild = pUser->GetGuild();
	if( pGuild )
	{
		CGuildMember* pGuildMember = pGuild->GetMember( pUser->m_idPlayer );
		if( pGuildMember )
		{
			if( pGuildMember->m_nMemberLv != GUD_MASTER && pGuildMember->m_nMemberLv != GUD_KINGPIN )
			{
				pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_NOLINEUPAUTH );
				return;
			}
		}
	}
			
	BOOL bMasterOrKingpin = FALSE;
	// 최소 참가 레벨 검사
	for( int i=0; i<(int)( vecMemberId.size() ); i++ )
	{
		CUser* pUserTemp = (CUser*)prj.GetUserByID( vecMemberId[i] );
		if( IsValidObj( pUserTemp ) && pUserTemp->GetLevel() < m_nMinJoinPlayerLevel )
		{
			pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_LIMIT_LEVEL_NOTICE );
			return;
		}
		if( IsValidObj( pUserTemp ) && !bMasterOrKingpin )
		{
			CGuildMember* pGuildMember = pGuild->GetMember( pUserTemp->m_idPlayer );
			if( pGuildMember )
				if( pGuildMember->m_nMemberLv == GUD_MASTER || pGuildMember->m_nMemberLv == GUD_KINGPIN )
					bMasterOrKingpin = TRUE;	
		}
	}
	if( !bMasterOrKingpin )
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_HAVENOT_MASTER );
		return;
	}
			
	m_vecTenderGuild[nIndex].vecMemberId.clear();
	m_vecTenderGuild[nIndex].vecMemberId = vecMemberId;
	pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_LINEUPCOMPLETE );
	g_dpDBClient.SendGC1to1LineUp( m_vecTenderGuild[nIndex].ulGuildId, vecMemberId );
}
Ejemplo n.º 22
0
void CGuildWarMng::Result( CGuildWar* pWar, CGuild* pDecl, CGuild* pAcpt, int nType, int nWptDecl, int nWptAcpt )
{
	CGuild* pWin, *pLose;
	switch( nType )
	{
		case WR_DECL_GN:
		case WR_DECL_SR:
		case WR_DECL_AB:
		case WR_DECL_DD:
		case WR_TRUCE:
		case WR_DRAW:
			{
				pWin	= pDecl;
				pLose	= pAcpt;
				break;
			}
		case WR_ACPT_GN:
		case WR_ACPT_SR:
		case WR_ACPT_AB:
		case WR_ACPT_DD:
			{
				pWin	= pAcpt;
				pLose	= pDecl;
				break;
			}
	}

	int nWinPointDecl = 0;
	int nWinPoint = 0;
	
	if( nType < WR_TRUCE )
	{
#ifdef __CORESERVER
		// nWinPoint
		nWinPoint	= (int)( pWin->m_nWinPoint + ( (float)( 10 + pWin->m_nWinPoint ) / (float)( ( (float)( pWin->m_nWinPoint + 4 ) / (float)( pLose->m_nWinPoint + 1 ) ) * 0.05 ) ) + 1 );
		int nMaxWinPoint	= (int)( ( 10 + pWin->m_nWinPoint * 0.05 ) * 5 );
		if( nWinPoint > nMaxWinPoint )
		{
			pWin->m_nWinPoint	+= nMaxWinPoint;
			nWinPointDecl = nMaxWinPoint;
		}
		else
		{
			pWin->m_nWinPoint	+= nWinPoint;
			nWinPointDecl = nWinPoint;
		}
		pWin->m_nWin++;
		nWinPoint	= (int)( ( 10 + pLose->m_nWinPoint * 0.02 ) );
		pLose->m_nWinPoint	-= nWinPoint;
		if( pLose->m_nWinPoint < 0 )
			pLose->m_nWinPoint	= 0;
		pLose->m_nLose++;
#else	// __CORESERVER
		pDecl->m_nWinPoint	= nWptDecl;
		pAcpt->m_nWinPoint	= nWptAcpt;
		pWin->m_nWin++;
		pLose->m_nLose++;
#endif	// __CORESERVER
	}

//	Clean up
	pWin->m_idWar	= 0;
	pWin->m_idEnemyGuild	= 0;
	pLose->m_idWar	= 0;
	pLose->m_idEnemyGuild	= 0;

	for( map<u_long, CGuildMember*>::iterator i = pWin->m_mapPMember.begin();
		i != pWin->m_mapPMember.end(); ++i )
	{
#ifdef __CORESERVER
		CPlayer* pPlayer	= g_PlayerMng.GetPlayer( i->second->m_idPlayer );
		if( pPlayer )	pPlayer->m_idWar	= 0;
#endif	// __CORESERVER
#ifdef __WORLDSERVER
		CUser* pUser	= g_UserMng.GetUserByPlayerID( i->second->m_idPlayer );
		if( IsValidObj( pUser ) )
		{
			pUser->m_idWar	= 0;
			g_UserMng.AddSetWar( pUser, 0 );
			pUser->SetPKTargetLimit( 10 );
		}
#endif	// __WORLDSERVER
	}
	for( i	= pLose->m_mapPMember.begin(); i != pLose->m_mapPMember.end(); ++i )
	{
#ifdef __CORESERVER
		CPlayer* pPlayer	= g_PlayerMng.GetPlayer( i->second->m_idPlayer );
		if( pPlayer )	pPlayer->m_idWar	= 0;
#endif	// __CORESERVER
#ifdef __WORLDSERVER
		CUser* pUser	= g_UserMng.GetUserByPlayerID( i->second->m_idPlayer );
		if( IsValidObj( pUser ) )
		{
			pUser->m_idWar	= 0;
			g_UserMng.AddSetWar( pUser, 0 );
			pUser->SetPKTargetLimit( 10 );
		}
#endif	// __WORLDSERVER
	}
#ifdef __CORESERVER
	g_dpCoreSrvr.SendWarEnd( pWar->m_idWar, pDecl->m_nWinPoint, pAcpt->m_nWinPoint, nType );
	g_DPCacheSrvr.SendWarEnd( pWar->m_idWar, pDecl->m_nWinPoint, pAcpt->m_nWinPoint, nType );
	int nDBType	= nType;
	switch( nType )
	{
		case WR_DECL_AB:
		case WR_DECL_DD:
			nDBType	= WR_DECL_GN;
			break;
		case WR_ACPT_AB:
		case WR_ACPT_DD:
			nDBType	= WR_ACPT_GN;
			break;
	}
	g_dpDatabaseClient.SendWarEnd( pWar->m_idWar, pDecl->m_idGuild, pAcpt->m_idGuild, pDecl->m_nWinPoint, pAcpt->m_nWinPoint, nDBType, pWar->m_time, pDecl->m_nWinPoint, pAcpt->m_nWinPoint, nWinPointDecl, nWinPoint );
#endif	// __CORESERVER
#ifdef __CLIENT
	char lpString[1024]	= { 0, };
	switch ( nType )
	{
		case WR_DECL_GN:
		case WR_ACPT_GN:
			{
				sprintf( lpString, prj.GetText( TID_GAME_GUILDWARWIN ), pDecl->m_szGuild, pAcpt->m_szGuild, pWin->m_szGuild, prj.GetText( TID_GAME_GUILDWARWIN_MASTER ) );
				g_WndMng.PutString( lpString , NULL, prj.GetTextColor( TID_GAME_GUILDWARWIN ) );
				break;
			}
		case WR_DECL_SR:
		case WR_ACPT_SR:
			{
				sprintf( lpString, prj.GetText( TID_GAME_GUILDWARWIN ), pDecl->m_szGuild, pAcpt->m_szGuild, pWin->m_szGuild, prj.GetText( TID_GAME_GUILDWARWIN_GIVEUP ) );
				g_WndMng.PutString( lpString , NULL, prj.GetTextColor( TID_GAME_GUILDWARWIN ) );
				break;
			}
		case WR_DECL_AB:
		case WR_ACPT_AB:
			{
				sprintf( lpString, prj.GetText( TID_GAME_GUILDWARWIN ), pDecl->m_szGuild, pAcpt->m_szGuild, pWin->m_szGuild, prj.GetText( TID_GAME_GUILDWARWIN_TIMEUP ) );
				g_WndMng.PutString( lpString , NULL, prj.GetTextColor( TID_GAME_GUILDWARWIN ) );
				break;
			}
		case WR_ACPT_DD:
		case WR_DECL_DD:
			{
				sprintf( lpString, prj.GetText( TID_GAME_GUILDWARWIN ), pDecl->m_szGuild, pAcpt->m_szGuild, pWin->m_szGuild, prj.GetText( TID_GAME_GUILDWARWIN_KILLNUM ) );
				g_WndMng.PutString( lpString , NULL, prj.GetTextColor( TID_GAME_GUILDWARWIN ) );
				break;
			}
		case WR_TRUCE:
			{
				char lpString[1024]	= { 0, };
				sprintf( lpString, prj.GetText( TID_GAME_GUILDWARPEACE ), pDecl->m_szGuild, pAcpt->m_szGuild );
				g_WndMng.PutString( lpString , NULL, prj.GetTextColor( TID_GAME_GUILDWARPEACE ) );
				break;
			}
		case WR_DRAW:
			{
				char lpString[1024]	= { 0, };
				sprintf( lpString, prj.GetText( TID_GAME_GUILDWARDRAW ), pDecl->m_szGuild, pAcpt->m_szGuild );
				g_WndMng.PutString( lpString , NULL, prj.GetTextColor( TID_GAME_GUILDWARDRAW ) );
				break;
			}
	}
#endif	// __CLIENT
	RemoveWar( pWar->m_idWar );
}
Ejemplo n.º 23
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message) 
	{
		case WM_TIMER:
			{
				WORD wTimerID	= wParam;
				switch( wTimerID )
				{
					case 0:
						g_dpDBClient.SendPing();
						g_DPCoreClient.SendPing();
						break;
					case 1:
						// g_UserMng.OutputStatistics();
						break;
				}
				break;
			}
		case WM_COMMAND:
			wmId    = LOWORD(wParam);
			wmEvent = HIWORD(wParam); 
			switch (wmId)
			{
				case IDM_EXIT:
				   DestroyWindow(hWnd);
				   break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_PAINT:
			hdc = BeginPaint( hWnd, &ps );
			OnPaint( hdc );
			EndPaint( hWnd, &ps );
			break;
		case WM_LBUTTONDOWN:
			CRunObject::GetInstance()->ToggleProfiling();
#ifdef __MEM_TRACE
#ifndef _DEBUG
			CMemTrace::Instance()->Print();
#endif	// _DEBUG
#endif	// __MEM_TRACE
#ifdef __VM_0819
			CVMLog::Instance()->Log();
#endif	// __VM_0819
			break;
		case WM_RBUTTONDOWN:
#ifdef __NEW_PROFILE
			CProfileInfo::GetInstance()->SetToggleProfiling();
#endif // __NEW_PROFILE
			break;
		case WM_DESTROY:
			KillTimer( g_hMainWnd, 0 );
			KillTimer( g_hMainWnd, 1 );
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
Ejemplo n.º 24
0
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
	HWND hWnd;

   hInst = hInstance; // Store instance handle in our global variable

	hMainWnd	= hWnd	=
		CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

	int x = 0, y = 416;
	SetWindowPos( hWnd, NULL, x, y, 400, 416, SWP_SHOWWINDOW );

	g_GameTimer.Compute();
	SetTimer( hWnd, TIMER_ID_DEFAULT, 1000, NULL );

#if !defined(__INTERNALSERVER)
	SetTimer( hWnd, TIMER_ID_WANTED, g_uWantedElapse, NULL );
#endif

#ifdef __EVENT0913
	SetTimer( hWnd, TIMER_ID_EVENT0913, 1000, NULL );
#endif	// __EVENT0913
#ifdef __EVENT1206
	SetTimer( hWnd, TIMER_ID_EVENT1206, 1000 * 60, NULL );
#endif	// __EVENT1206

	SetTimer( hWnd, TIMER_ID_EVENT, 1000 * 60, NULL );

	g_MyTrace.Initialize( hWnd, "SquireD", RGB( 0xff, 0xff, 0xff ), RGB( 0x00, 0x00, 0x00 ) );

	CTime time	= CTime::GetCurrentTime();
	g_MyTrace.Add( 0, FALSE, "%s", time.Format( "%Y/%m/%d %H:%M:%S" ) );
	g_MyTrace.AddLine( '\0' );

#ifndef _DEBUG
//	InitEH();
#endif	// _DEBUG

	g_TickCount.Start();

	if( !Script( "CoreServer.ini" ) )
	{
		return FALSE;
	}
	
	if( InitializeNetLib() == FALSE )
		return FALSE;

	if( !g_dpCoreSrvr.StartServer( PN_CORESRVR + 0 ) )
		return FALSE;

	if( !g_DPCacheSrvr.StartServer( PN_CORESRVR + 1 ) )
		return FALSE;

	if( !g_dpLoginSrvr.StartServer( PN_CORESRVR + 2 ) )
		return FALSE;

	if( !g_dpDatabaseClient.ConnectToServer( szDataBaseAddr, PN_DBSRVR_2, FALSE ) )
	{
		Error( "Not TransServer Connect" );
		return FALSE;
	}

	if( !g_PartyMng.CreateWorkers() )
	{
		assert( 0 );
	}

#ifdef __ENVIRONMENT_EFFECT
	if( CEnvironment::GetInstance()->CreateWorkers() == FALSE )
	{
		assert( 0 );
	}
#else // __ENVIRONMENT_EFFECT
	if( !g_Environment.CreateWorkers() )
	{
		assert( 0 );
	}
#endif // __ENVIRONMENT_EFFECT

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}