?? cfightzone.cpp
字號:
////////////////////////////////////////////////////////////////////////////////////////
// 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 + -