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

📄 cguild.cpp

📁 韩国英雄王座倒闭后流出来部分源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
////////////////////////////////////////////////////////////////////////////////////////
//	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 ;

	

⌨️ 快捷键说明

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