?? cguild.cpp
字號:
////////////////////////////////////////////////////////////////////////////////////////
// CGUILD_CPP 2003斥 12巋 12老 陛
//
// by Mun Sung-hun (badajoa2002@hotmail.net)
// Copyright(C) 2003
////////////////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "cguild.h"
#include "MapServerSocket.h"
#include "PacketCrypt.h"
#include "CUdpSocket.h"
#include "CFightzone.h"
#include "17CryptServer.h"
#include "ServerMem.h"
#include "RegCrypt.h"
#include "DBSocket.h"
////////////////////////////////////////////////////////////////////////////////////////
// Global Funcitons
////////////////////////////////////////////////////////////////////////////////////////
extern ServerMem *g_pServerMem; // SERVER MEMORY
extern MapServerSocket *g_pServer; // MAP SERVER
extern _LPUDPSOCKET g_lpUdpSock ; // UDP
extern _LPCFIGHTZONEMANAGER g_lpFightzoneManager ;
extern _LPDBSOCK g_lpDBSock ;
#ifdef DEF_SECURITYPACKET
extern CRegCrypt crypt;
#endif
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
CGuild::CGuild()
{
m_lpListMember = new CXPtrList ;
}
CGuild::~CGuild()
{
if(m_lpListMember)
{
delete m_lpListMember ;
m_lpListMember = NULL ;
}
}
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CGuild::Join(_LPSOCKET_FD lpSocketFD)
{
/*
if( !lpSocketFD ) return;
if( lpSocketFD->dwMagicNum != MAGIC_NUM ) return;
if( lpSocketFD->bClose ) return;
if( lpSocketFD->socket == INVALID_SOCKET ) return;
*/
if( !IsSocketValidity( lpSocketFD ) ) return;
m_lpListMember->AddTail(lpSocketFD ) ;
}
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
bool CGuild::Leave(_LPSOCKET_FD lpSocketFD)
{
m_lpListMember->RemovePtr(lpSocketFD ) ;
if(m_lpListMember->GetCount() == 0)
{
return false;
}
return true ;
}
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CGuild::Destroy()
{
_LPSOCKET_FD lpSocketFD ;
for(POSITION pos = m_lpListMember->GetHeadPosition(); pos != NULL;)
{
lpSocketFD = (_LPSOCKET_FD)m_lpListMember->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;
lpSocketFD->pPlayer->PlayerGuildInfoInit() ;
g_pServer->PacketSend_ChangePlayerBase(lpSocketFD) ;
g_pServer->PacketSend_PlayerUpdate(lpSocketFD) ;
}
m_lpListMember->RemoveAll();
}
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CGuild::Send_GuildPacket(_LPZEMIPACKET pZemiPacket)
{
_LPSOCKET_FD lpSocketFD ;
_LPPER_IO_CONTEXT lpSendIOContext ;
pZemiPacket->dwSeq = 12 ;
#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_lpListMember->GetHeadPosition(); pos != NULL;)
{
lpSocketFD = (_LPSOCKET_FD)m_lpListMember->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 CGuild::Send_ChatMsg( _LPZEMIPACKET pZemiPacket )
{
_LPZP_GUILDMSG_ASK p = (_LPZP_GUILDMSG_ASK) pZemiPacket->strPacket ;
// --------------------------------------------------------------------------------
// 辨靛 盲潑 茄 甘父 焊郴綽芭 (辨靛 啊澇 嘔硼)
// --------------------------------------------------------------------------------
g_lpUdpSock->SendGuildNotice((_LPZP_GUILDMSG_ASK)pZemiPacket->strPacket );
}
////////////////////////////////////////////////////////////////////////////////////////
// 葛電 辨靛盔俊霸 包訪 皋矯瘤 傈價
//
////////////////////////////////////////////////////////////////////////////////////////
void CGuild::Send_NoticeMsg(_LPZEMIPACKET pZemiPacket)
{
_LPZP_GUILDMSG_ASK p = (_LPZP_GUILDMSG_ASK) pZemiPacket->strPacket ;
_LPSOCKET_FD lpSocketFD ;
_LPPER_IO_CONTEXT lpSendIOContext ;
pZemiPacket->dwSeq = 7 ;
#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_lpListMember->GetHeadPosition(); pos != NULL;)
{
lpSocketFD = (_LPSOCKET_FD)m_lpListMember->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 );
}
}
}
#ifdef DEF_GUILDBANK
////////////////////////////////////////////////////////////////////////////////////////
// 辨靛 傍瘤 皋矯瘤甫 World Server俊 傈價竊
//
////////////////////////////////////////////////////////////////////////////////////////
void CGuild::SendWorld_NoticeMsg( char * pMsg )
{
g_lpUdpSock->SendGuildNotice( cGuildName, pMsg );
}
#endif
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CGuild::Send_ChatMsg(char * lpGuildName,char * lpMsg)
{
_LPZEMIPACKET lpSendPacket = g_pServerMem->ZemiPacket_Pop();
lpSendPacket->dwCommand = ZP_GUILDMSG_REP ;
_LPZP_GUILDMSG_REP p = (_LPZP_GUILDMSG_REP) lpSendPacket->strPacket ;
p->nType = 4 ;
memcpy(p->strGuildName,lpGuildName, PLAYERID_LEN );
memcpy(p->strPlayerID,lpGuildName, PLAYERID_LEN );
memcpy(p->strMsg,lpMsg, 100);
lpSendPacket->dwSize = sizeof( _ZP_GUILDMSG_REP );
Send_ChatMsg(lpSendPacket) ;
g_pServerMem->ZemiPacket_Push(lpSendPacket) ;
}
////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////
void CGuild::ChangeGuildMark(char * lpGuildMark)
{
_LPSOCKET_FD lpSocketFD ;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -