?? cfightzone.cpp
字號:
_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 ;
// 貿(mào)瀾 評焊促 農(nóng)促.
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 ;
// 貿(mào)瀾 評焊促 累促
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);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -