⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cfightzone.cpp

📁 韩国英雄王座倒闭后流出来部分源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	_LPSOCKET_FD lpSocketFD ;
	_LPPER_IO_CONTEXT lpSendIOContext ;

	pZemiPacket->dwCommand	= ZP_PVPWIN ;
	pZemiPacket->dwSeq = 15  ;


	pZemiPacket->dwSize	+= ZEMIPACKETHEADER_SIZE ;
	
	
	for(POSITION pos = m_lpListPlayer->GetHeadPosition(); pos != NULL;)
	{
		lpSocketFD = (_LPSOCKET_FD)m_lpListPlayer->GetNext(pos);
		
		/*
		if( !lpSocketFD								) continue;
		if( lpSocketFD->dwMagicNum	!=	MAGIC_NUM	) continue;
		if( lpSocketFD->bClose						) continue;
		if( lpSocketFD->socket == INVALID_SOCKET	) continue;
		*/
		if( !IsSocketValidity( lpSocketFD )	) continue;

		if(sWinTeam >= 0  )
		{
			if (lpSocketFD->pPlayer->m_nTeam == sWinTeam ) 
			{
				pZemiPacket->dwCommand	= ZP_PVPWIN ;
				if( Type == PVP_TYPE_LADDER)
				{
					++lpSocketFD->pPlayer->m_dwPVPWin;
					g_pServer->PacketSend_ChangePlayerBase(lpSocketFD) ;
				}
			}
			else
			{
				pZemiPacket->dwCommand	= ZP_PVPLOSE ;
				if( Type == PVP_TYPE_LADDER)
				{
					++lpSocketFD->pPlayer->m_dwPVPLose;
					g_pServer->PacketSend_ChangePlayerBase(lpSocketFD) ;
				}
			}
		}
		else
		{
			pZemiPacket->dwCommand	= ZP_PVPDRAW ;
		}
		

		// 版扁啊 辆丰 登绰 版快 檬扁拳 
		lpSocketFD->pPlayer->MatchClear(); 
		

		lpSendIOContext = NULL;
		lpSendIOContext = g_pServer->CreateIOContext(WRITE);

		if( lpSendIOContext )
		{
			memcpy( lpSendIOContext->buf , pZemiPacket, pZemiPacket->dwSize );
			lpSendIOContext->dwTotalBytes = pZemiPacket->dwSize;

			g_pServer->Send( lpSocketFD , lpSendIOContext );						
		}
	}	

	g_pServerMem->ZemiPacket_Push(  pZemiPacket );
}


////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
short CFightZone::sCountMember()
{
	int nMemberCount ;

	if( bTeamJoin[0] == false )
		nMemberCount =  -1 ;
	else
		nMemberCount =  MemberCount[0];

	short sTeam =  0 ;


	for(int i = 1 ; i < DEF_MAXTEAM ; ++i )
	{
		if( bTeamJoin[i] == false ) continue ;

		// 贸澜 评焊促 农促.
		if(  MemberCount[i] > nMemberCount  )
		{
			nMemberCount = MemberCount[i] ;
			sTeam = i ;
			continue ;
		}

		// 厚变 版快绰 捞变 评捞 绝促.
		if( nMemberCount == MemberCount[i])
		{
			sTeam = -1 ;
		}
	}

	return  sTeam ; 
}


////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
short CFightZone::sCountKilled()
{
	int nKilledCount  ;

	if( bTeamJoin[0] == false )
		nKilledCount =  -1 ;
	else
		nKilledCount =  KilledCount[0];

	short sTeam =  0 ;

	for(int i = 1 ; i < DEF_MAXTEAM ; ++i )
	{
		if( bTeamJoin[i] == false ) continue ;

		// 贸澜 评焊促 累促 
		if( KilledCount[i] < nKilledCount )
		{
			nKilledCount = KilledCount[i] ;
			sTeam = i  ;
			continue ;
		}

		// 厚变 版快绰 捞变 评捞 绝促.
		if( nKilledCount == KilledCount[i])
		{
			sTeam	= -1 ;
		}
	}

	return  sTeam  ; 
}


////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CFightZone::Send_Score() 
{
	// 矫累登扁 傈捞唱 版扁啊 场抄 版快绰 痢荐甫 焊郴瘤 臼绰促. 
	if((!bIsStartMatch || bIsFightEnd) ) return ;

	_LPZEMIPACKET lpSendPacket	=	g_pServerMem->ZemiPacket_Pop();

		lpSendPacket->dwCommand	= ZP_PVPGAMESCORE ;
		lpSendPacket->dwSize	= sizeof(_ZP_PVPGAMESCORE) ;
	
		_LPZP_PVPGAMESCORE lpPVPScore = (_LPZP_PVPGAMESCORE) lpSendPacket->strPacket ;


		memcpy(lpPVPScore->sMaxMember,sMaxMember	, sizeof(short)*DEF_MAXTEAM) ;
		memcpy(lpPVPScore->sTeamMember,MemberCount	, sizeof(short)*DEF_MAXTEAM) ;
		memcpy(lpPVPScore->sKilledCount,KilledCount	, sizeof(short)*DEF_MAXTEAM) ;

		SendAll_Packet( lpSendPacket );

	g_pServerMem->ZemiPacket_Push(  lpSendPacket );
}



////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CFightZone::Send_Time(BYTE nTime) 
{
	// 版扁 辆丰饶绰 焊尘 鞘夸 绝促.
	if( bIsFightEnd ) return ;

	_LPZEMIPACKET lpSendPacket	=	g_pServerMem->ZemiPacket_Pop();

		lpSendPacket->dwCommand	= ZP_PVPGAMETIME ;
		lpSendPacket->dwSize	= sizeof(_ZP_PVPGAMETIME) ;
	
		_LPZP_PVPGAMETIME lpPVPGameTime = (_LPZP_PVPGAMETIME) lpSendPacket->strPacket ;

		lpPVPGameTime->bIsSyncTime = false ;
		
		switch (nTime)
		{
		case DEF_GAMESTARTTIME:
			lpPVPGameTime->wTime = dwTime - g_lpFightzoneManager->m_dwTimeTick ;
			break;

		case DEF_GAMETIME :
			lpPVPGameTime->bIsSyncTime = true ;

		case DEF_GAMEENDTIME:
			lpPVPGameTime->wTime = (dwTime + wTime*60 - g_lpFightzoneManager->m_dwTimeTick) ;
			break; 

		}

		SendAll_Packet( lpSendPacket );

	g_pServerMem->ZemiPacket_Push(  lpSendPacket );
}

////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CFightZone::Send_PVPInfor()
{

	_LPZEMIPACKET lpSendPacket	=	g_pServerMem->ZemiPacket_Pop();

		lpSendPacket->dwCommand	= ZP_PVPINFOR ;
		lpSendPacket->dwSize	= sizeof(_ZP_PVPINFOR) ;
	
		_LPZP_PVPINFOR lpPVPInfor = (_LPZP_PVPINFOR) lpSendPacket->strPacket ;

		memcpy(lpPVPInfor->cTeamName,cTeamName, sizeof(char)*20*DEF_MAXTEAM) ;
		memcpy(lpPVPInfor->sTeamMember,MemberCount, sizeof(short)*DEF_MAXTEAM) ;

		lpPVPInfor->nRule = m_lpMatch->Rule ;
		lpPVPInfor->nTeam = Team ;
		lpPVPInfor->wTime = wTime*60 ;
		
		SendAll_Packet( lpSendPacket  );

	g_pServerMem->ZemiPacket_Push(  lpSendPacket );
}


////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CFightZone::SendToLobbyAll()
{
	_LPSOCKET_FD lpSocketFD ;
	
	for(POSITION pos = m_lpListPlayer->GetHeadPosition(); pos != NULL;)
	{
		lpSocketFD = (_LPSOCKET_FD)m_lpListPlayer->GetNext(pos);

		if( !lpSocketFD								) continue;
		if( IsBadReadPtr(lpSocketFD, sizeof(_SOCKET_FD) ) )
		{
			MapLog("(X) Fightzone Point Error !!") ;
			continue ;
		}

		/*
		if( lpSocketFD->dwMagicNum	!=	MAGIC_NUM	) continue;
		if( lpSocketFD->bClose						) continue;
		if( lpSocketFD->socket == INVALID_SOCKET	) continue;
		if( !lpSocketFD->pPlayer)					  continue;
		*/
		if( !IsSocketValidity( lpSocketFD )	) continue;	


		lpSocketFD->pPlayer->m_bIsFightZone = false ;
		lpSocketFD->pPlayer->m_dwMatchSEQ = 0 ;
					
		if(lpSocketFD->pPlayer->m_nMapLayer == g_lpFightzoneManager->nLobbyLayer )
			g_pServer->Teleport(lpSocketFD, g_lpFightzoneManager->LobbyPoint,Type) ;
		else 
		{
			if(bIsHidden )
				g_pServer->MapMove(lpSocketFD,  g_lpFightzoneManager->dwHiddenLobbyMapSEQ, g_lpFightzoneManager->LobbyPoint) ;
			else
				g_pServer->MapMove(lpSocketFD,  g_lpFightzoneManager->dwLobbyMapSEQ, g_lpFightzoneManager->LobbyPoint) ;
		}
	}

	m_lpListPlayer->RemoveAll() ;
}


////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CFightZone::Send_NoticeMsg(char * lpMsg )
{
	_LPZEMIPACKET lpSendPacket	=	g_pServerMem->ZemiPacket_Pop();

		lpSendPacket->dwCommand	= ZP_LOGMSG_REP;
		lpSendPacket->dwSize	= sizeof( _ZP_LOGMSG_REP );

		_LPZP_LOGMSG_REP p		= (_LPZP_LOGMSG_REP)(lpSendPacket->strPacket);

		p->dwPlayerHandle		= 0;
		p->nType				= 102;					//	傍瘤 Type

		memcpy( p->strMsg, lpMsg, 100 );				//	Message 郴侩

		SendAll_Packet( lpSendPacket );

	g_pServerMem->ZemiPacket_Push(lpSendPacket) ;
}


////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CFightZone::Send_Msg(_LPSOCKET_FD lpSocketFd, char * lpMsg )
{
	_LPZEMIPACKET lpSendPacket	=	g_pServerMem->ZemiPacket_Pop();

		lpSendPacket->dwCommand	= ZP_LOGMSG_REP;
		lpSendPacket->dwSize	= sizeof( _ZP_LOGMSG_REP );

		_LPZP_LOGMSG_REP p		= (_LPZP_LOGMSG_REP)(lpSendPacket->strPacket);

		p->dwPlayerHandle		= 0;
		p->nType				= 102;					//	傍瘤 Type

		memcpy( p->strMsg, lpMsg, 100 );				//	Message 郴侩

		g_pServer->Send_Single( lpSocketFd , lpSendPacket );

	g_pServerMem->ZemiPacket_Push(lpSendPacket) ;
}

////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CFightZone::Send_NoticeMsgAndChangeMode(char * lpMsg ,bool bIsStarGame)
{
	_LPZEMIPACKET lpSendPacket	=	g_pServerMem->ZemiPacket_Pop();

		lpSendPacket->dwCommand	= ZP_LOGMSG_REP;
		lpSendPacket->dwSize	= sizeof( _ZP_LOGMSG_REP );

		_LPZP_LOGMSG_REP p		= (_LPZP_LOGMSG_REP)(lpSendPacket->strPacket);

		p->dwPlayerHandle		= 0;
		p->nType				= 102;					//	傍瘤 Type

		memcpy( p->strMsg, lpMsg, 100 );				//	Message 郴侩

		SendAll_PacketAndChangeMode( lpSendPacket, bIsStarGame);

	g_pServerMem->ZemiPacket_Push(lpSendPacket) ;
}


////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CFightZone::SendAll_Packet(_LPZEMIPACKET pZemiPacket  )
{
	_LPSOCKET_FD lpSocketFD ;
	_LPPER_IO_CONTEXT lpSendIOContext ;

	pZemiPacket->dwSeq = 13  ;

#ifdef DEF_SECURITYPACKET
	_17Encrypt((unsigned char *)pZemiPacket->strPacket, pZemiPacket->dwSize, pZemiPacket->dwSeq, &pZemiPacket->wCheckSum,NULL,0, pZemiPacket->dwCommand ) ;
#else
	pZemiPacket->wCheckSum	= PacketEncrypt(pZemiPacket->strPacket, pZemiPacket->dwSize, pZemiPacket->dwSeq&31) ;
#endif
	
	pZemiPacket->dwSize += ZEMIPACKETHEADER_SIZE;
	
	for(POSITION pos = m_lpListPlayer->GetHeadPosition(); pos != NULL;)
	{
		lpSocketFD = (_LPSOCKET_FD)m_lpListPlayer->GetNext(pos);

		/*
		if( !lpSocketFD								) continue;
		if( lpSocketFD->dwMagicNum	!=	MAGIC_NUM	) continue;
		if( lpSocketFD->bClose						) continue;
		if( lpSocketFD->socket == INVALID_SOCKET	) continue;
		*/
		if( !IsSocketValidity( lpSocketFD )	) continue;	
				
		lpSendIOContext = NULL;
		lpSendIOContext = g_pServer->CreateIOContext(WRITE);

		if( lpSendIOContext )
		{
			memcpy( lpSendIOContext->buf , pZemiPacket, pZemiPacket->dwSize );
			lpSendIOContext->dwTotalBytes = pZemiPacket->dwSize;

			g_pServer->Send( lpSocketFD , lpSendIOContext );						
		}
	}	
}


////////////////////////////////////////////////////////////////////////////////////////
//	
//
////////////////////////////////////////////////////////////////////////////////////////
void CFightZone::SendAll_PacketAndChangeMode(_LPZEMIPACKET pZemiPacket,bool bIsStarGame )
{
	_LPSOCKET_FD lpSocketFD ;
	_LPPER_IO_CONTEXT lpSendIOContext ;

	pZemiPacket->dwSeq = 14  ;

#ifdef DEF_SECURITYPACKET

	_17Encrypt((unsigned char *)pZemiPacket->strPacket, pZemiPacket->dwSize, pZemiPacket->dwSeq, &pZemiPacket->wCheckSum,NULL,0, pZemiPacket->dwCommand ) ;
	
#else
	pZemiPacket->wCheckSum	= PacketEncrypt(pZemiPacket->strPacket, pZemiPacket->dwSize, pZemiPacket->dwSeq&31) ;
#endif
	
	pZemiPacket->dwSize += ZEMIPACKETHEADER_SIZE;
	
	for(POSITION pos = m_lpListPlayer->GetHeadPosition(); pos != NULL;)
	{
		lpSocketFD = (_LPSOCKET_FD)m_lpListPlayer->GetNext(pos);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -