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

📄 cfightzone.cpp

📁 韩国英雄王座倒闭后流出来部分源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
////////////////////////////////////////////////////////////////////////////////////////
//	CFIGHTZONE_CPP   2004斥 3岿 8老 陛
//
//	by Mun Sung-hun (badajoa2002@hotmail.net)
//	Copyright(C) 2004
//
//
////////////////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "CFightzone.h"
#include "MapServerSocket.h"
#include "PacketCrypt.h"
#include "DBSocket.h"
#include "ServerMem.h"

#ifdef DEF_SECURITYPACKET
	#include "17CryptServer.h"
	#include "RegCrypt.h"

	extern CRegCrypt crypt;
#endif

////////////////////////////////////////////////////////////////////////////////////////
//	Global Class
////////////////////////////////////////////////////////////////////////////////////////
extern	MapServerSocket		*g_pServer;				//	Map Server 
extern _LPCFIGHTZONEMANAGER g_lpFightzoneManager;
extern _LPDBSOCK			g_lpDBSock ;			// 2003-7-14  badajoa World Server 眠啊

extern	ServerMem			*g_pServerMem;	


CMatch::CMatch()
{

}
CMatch::~CMatch()
{

}



////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CMatch::Clear()
{
	memset(this,0x0,sizeof(CMatch));
}

////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
bool CMatch::bIsLogoutTeam(PlayerInfo * lpPlayer)
{

	BYTE nTeam = lpPlayer->m_nTeam ;

	LogOutTeam( lpPlayer->m_pSocketFD, nTeam)  ;

	if( nTeam == DEF_OBSERVER )
	{
		return false; 
	}

	if (	lpPlayer->m_bIsFightMode== true				&& 
			m_lpFightZone->Type		== PVP_TYPE_LADDER	&& 
			m_lpFightZone->Team		== PVP_TEAM_PERSON )
	{
		++lpPlayer->m_dwPVPLose;
		g_pServer->PacketSend_ChangePlayerBase(lpPlayer->m_pSocketFD) ;
	}

	if(m_lpFightZone->nPlayer <= 0 )  return true ;
	

	if(lpPlayer->m_bIsFightMode == true)
	{
		lpPlayer->MatchClear() ;

		lpPlayer->m_dwMatchSEQ = 0 ;
	}

	if( m_lpFightZone->Team == PVP_TEAM_PARTY)
	{
		if(	lpPlayer->m_dwHandle == MasterHandle[nTeam]  )
		{
			// 颇萍傈牢单 颇萍 付胶磐啊 唱啊搁 官肺 霸烙 场捞促.
			m_lpFightZone->bTeamJoin[nTeam] = false ;
			return true ;
		}
	}

			
	switch( Rule)
	{
		case PVP_RULE_KILLMASTER :
		case PVP_RULE_MASTERKILLCOUNT :
		{
			if(	lpPlayer->m_dwHandle == MasterHandle[nTeam]  )
			{
				++m_lpFightZone->KilledCount[nTeam] ;

				return true ;
			}
		}

		// break 啊 绝促 蝶扼辑 酒贰 风凭档 角青窍霸 等促.
		// 干滚 皑家绰 LogOut team 俊辑 秦霖促. 
		case PVP_RULE_SERVIVAL:
		case PVP_RULE_FFA:	
		case PVP_RULE_NOMAL:
		case PVP_RULE_KILLCOUNT :
		default:
		{
			if(--m_lpFightZone->MemberCount[nTeam]  <= 0 )

			return true;
		}
	}

	return false ;
}


////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
bool CMatch::bIsLoseTeam(PlayerInfo * lpPlayer)
{


	BYTE nTeam = lpPlayer->m_nTeam ;


	if( nTeam == DEF_OBSERVER )
	{
		return false; 
	}

	switch(Rule)
	{
		case PVP_RULE_SERVIVAL:
		case PVP_RULE_FFA:	
		case PVP_RULE_NOMAL:
		{

			lpPlayer->MatchClear(); 

			if( --m_lpFightZone->MemberCount[nTeam]  <= 0 )
			{
				m_lpFightZone->bTeamJoin[nTeam] = false ;

				return true;
			}
		}
		break;

		case PVP_RULE_KILLCOUNT :
		{

			++m_lpFightZone->KilledCount[nTeam] ;

		}
		break;

		case PVP_RULE_KILLMASTER :
		{

			lpPlayer->MatchClear(); 

			if(	lpPlayer->m_dwHandle == MasterHandle[nTeam]  )
			{
				++m_lpFightZone->KilledCount[nTeam ] ;
				m_lpFightZone->bTeamJoin[nTeam] = false ;
				
				return true ;
			}
			
			if (--m_lpFightZone->MemberCount[nTeam]  <= 0)
			{
				m_lpFightZone->bTeamJoin[nTeam] = false ;
				
				return true ;
			}

		}
		break;
	
		case PVP_RULE_MASTERKILLCOUNT :
		{
			if(	lpPlayer->m_dwHandle == MasterHandle[lpPlayer->m_nTeam]  )
				++m_lpFightZone->KilledCount[lpPlayer->m_nTeam] ;

		}
		break;
	}
	
	return false ;
}

////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CMatch::CheckWinTeam() 
{

	switch(Rule)
	{
		case PVP_RULE_SERVIVAL:
		case PVP_RULE_FFA:	
		case PVP_RULE_NOMAL:
		{
			sWinTeam = m_lpFightZone->sCountMember() ;
		}
		break;

		case PVP_RULE_KILLCOUNT :
		{
			sWinTeam = m_lpFightZone->sCountKilled() ;
		}
		break;

		case PVP_RULE_KILLMASTER :
		{
			sWinTeam = m_lpFightZone->sCountKilled() ;
		}
		break;
	
		case PVP_RULE_MASTERKILLCOUNT :
		{
			sWinTeam = m_lpFightZone->sCountKilled() ;
		}
		break;
	}

	
	m_lpFightZone->Send_GameEndMsg(sWinTeam );

	// 辨靛傈篮 泪矫饶 府妮茄促.
	if(m_lpFightZone->Team == PVP_TEAM_GUILD )
		m_lpFightZone->Send_NoticeMsg(MSG_FIGHTZONERECALLMSG) ;


	ErrorMsg("(FZ) Player WinTeam (%d) Match(%d) (%s) Team Killed(%d) Member(%d) (%s) Team Killed(%d) Member(%d) ",
			sWinTeam, m_dwMatchSEQ ,m_lpFightZone->cTeamName[0],  m_lpFightZone->KilledCount[0] , m_lpFightZone->MemberCount[0] 
			,m_lpFightZone->cTeamName[1], m_lpFightZone->KilledCount[1] , m_lpFightZone->MemberCount[1] );

	m_lpFightZone->bIsFightEnd = true	;
}

////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CMatch::CheckWinTeamForLogout() 
{
	sWinTeam = m_lpFightZone->sCountMember() ;
	
	m_lpFightZone->Send_GameEndMsg(sWinTeam );

	// 辨靛傈篮 泪矫饶 府妮茄促.
	if(m_lpFightZone->Team == PVP_TEAM_GUILD )
		m_lpFightZone->Send_NoticeMsg(MSG_FIGHTZONERECALLMSG) ;


	ErrorMsg("(FZ) Player WinTeam (%d) Match(%d) (%s) Team Killed(%d) Member(%d) (%s) Team Killed(%d) Member(%d) ",
			sWinTeam, m_dwMatchSEQ ,m_lpFightZone->cTeamName[0],  m_lpFightZone->KilledCount[0] , m_lpFightZone->MemberCount[0] 
			,m_lpFightZone->cTeamName[1], m_lpFightZone->KilledCount[1] , m_lpFightZone->MemberCount[1] );

	m_lpFightZone->bIsFightEnd = true	;
}

////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
bool CMatch::bCheckLocation(int nLayer,int x, int y)
{
	if (   m_lpFightZone->lpZoneInfor.StartPoint.x <= x && x <= m_lpFightZone->lpZoneInfor.EndPoint.x 
	&& m_lpFightZone->lpZoneInfor.StartPoint.y <= y && y <= m_lpFightZone->lpZoneInfor.EndPoint.y
	&& nLayer == m_lpFightZone->nLayer 
	)
		return true ;
	else 
		return false ;
}

////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CMatch::JoinTeam(_LPSOCKET_FD lpSocketFD, int nTeam)
{
	m_lpFightZone->m_lpListPlayer->AddTail(lpSocketFD ) ;

	// 荤捧厘俊 立加茄 牢盔 
	++m_lpFightZone->nPlayer ;

	if( nTeam == DEF_OBSERVER )
	{
		lpSocketFD->pPlayer->ChangeStatus(STATUS_INVISIBLE) ;
	}
	else
	{
		// 曼啊茄 评狼 牢盔
		++m_lpFightZone->MemberCount[nTeam ];

		// 付胶磐捞搁 
		if(MasterHandle[nTeam] == lpSocketFD->pPlayer->m_dwHandle )
			++m_lpFightZone->sMasterCount ;

	}

	// 版扁 矫累 饶绰 焊尘 鞘夸 绝促.

	if( nTeam == DEF_OBSERVER) 
		m_lpFightZone->Send_PVPInfor() ;
	else if(  !m_lpFightZone->bIsFightStart )
		m_lpFightZone->Send_PVPInfor() ;
	

	if ( m_lpFightZone->dwTime > g_lpFightzoneManager->m_dwTimeTick )
	{
		char cMsg[100] ={0,} ;
		wsprintf(cMsg,MSG_FIGHTZONELOGINMSG, (m_lpFightZone->dwTime -  g_lpFightzoneManager->m_dwTimeTick) ) ; 
		m_lpFightZone->Send_Msg(lpSocketFD,cMsg) ;
		
		if (m_lpFightZone->UsePotion == PVP_POTION_USE)
			m_lpFightZone->Send_Msg(lpSocketFD,MSG_FIGHTZONE_RULE_POTION) ;
		else
			m_lpFightZone->Send_Msg(lpSocketFD,MSG_FIGHTZONE_RULE_NOPOTION) ;

		switch(Rule)
		{
		case PVP_RULE_NOMAL:			wsprintf(cMsg,MSG_FIGHTZONE_RULE_NORMAL			);	break;

		case PVP_RULE_KILLCOUNT:		wsprintf(cMsg,MSG_FIGHTZONE_RULE_KILLCOUNT		);	break;

		case PVP_RULE_KILLMASTER:		wsprintf(cMsg,MSG_FIGHTZONE_RULE_KILLMASTER		);	break;

		case PVP_RULE_MASTERKILLCOUNT:	wsprintf(cMsg,MSG_FIGHTZONE_RULE_MASTERKILLCOUNT);	break;
		}
		
		m_lpFightZone->Send_Msg(lpSocketFD,cMsg) ;
		
		if (Rule == PVP_RULE_KILLCOUNT ||  Rule == PVP_RULE_MASTERKILLCOUNT  )
			m_lpFightZone->Send_Msg(lpSocketFD,MSG_FIGHTZONE_RULE_REVIVE) ;

	}
}

////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CMatch::LogOutTeam(_LPSOCKET_FD lpSocketFD, int nTeam)
{
	m_lpFightZone->m_lpListPlayer->RemovePtr(lpSocketFD ) ;

	if(nTeam == DEF_OBSERVER) return ;

	// 评狼 付胶磐捞搁 
	if(MasterHandle[nTeam] == lpSocketFD->pPlayer->m_dwHandle )
	{
		--m_lpFightZone->sMasterCount ;
	}

	// 版扁 矫累 饶绰 焊尘 鞘夸 绝促.
	if( nTeam == DEF_OBSERVER) 
		m_lpFightZone->Send_PVPInfor() ;
	else if( !m_lpFightZone->bIsFightStart ) 
		m_lpFightZone->Send_PVPInfor() ;
}


CFightZone::~CFightZone()
{
	SAFE_DELETE <CXPtrList>(&m_lpListPlayer) ;
}

CFightZone::CFightZone()
{
	
}

////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CFightZone::Clear()
{
	m_lpMatch	= NULL ;
	nPlayer  = 0 		;	// 荤捧厘俊 立加茄 牢盔 

	bIsStartMatch = false ;
	bIsFightStart = false ;
	bIsFightEnd	= false ;

	sMasterCount = 0 ;

	memset(KilledCount,0x0, sizeof(short) * DEF_MAXTEAM) ;
	memset(MemberCount,0x0, sizeof(short) * DEF_MAXTEAM) ;

	for(int i = 0 ; i < DEF_MAXTEAM ; ++i)
		bTeamJoin[i] = false;

	m_lpListPlayer->RemoveAll();
}


////////////////////////////////////////////////////////////////////////////////////////
//
//	
////////////////////////////////////////////////////////////////////////////////////////
void CFightZone::Send_GameEndMsg(short sWinTeam)
{

	_LPZEMIPACKET pZemiPacket	=	g_pServerMem->ZemiPacket_Pop();

⌨️ 快捷键说明

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