cllogin.cpp

来自「天之炼狱1服务器端源文件游戏服务端不完整」· C++ 代码 · 共 189 行

CPP
189
字号
//////////////////////////////////////////////////////////////////////////////// Filename    : CLLogin.cpp // Written By  : reiot@ewestsoft.com// Description : //////////////////////////////////////////////////////////////////////////////#include "libcpsso.h"#include "CLLogin.h"#include "Properties.h"void CLLogin::read (SocketInputStream & iStream) 	 throw (ProtocolException , Error){	__BEGIN_TRY#ifdef __LOGIN_SERVER__	if (g_pConfig->getPropertyInt("IsNetMarble")==1)	{		setNetmarble(true);		int szCpsso;		iStream.read(szCpsso);		if ( szCpsso == 0 )			throw InvalidProtocolException("szID == 0");		if ( szCpsso > 2048 )			throw InvalidProtocolException("too large ID length");		iStream.read( m_Cpsso , szCpsso );		char id[30];		char pw[30];		char age[10];		bool bRet = false;		bRet = GetCPCookieValue( m_Cpsso.c_str(), "UserID", id);		if (!bRet)			throw InvalidProtocolException("Name Does Not Exist");		bRet = GetCPCookieValue( m_Cpsso.c_str(), "UniID", pw);		if (!bRet)			throw InvalidProtocolException("UniID Does Not Exist");		bRet = GetCPCookieValue( m_Cpsso.c_str(), "Age", age);		if (!bRet)			throw InvalidProtocolException("Age Does Not Exist");		m_ID = id;		m_Password = pw;		int realage = atoi(age);		// 叼滚彪		cout << "ID : " << m_ID << endl;		cout << "PW : " << m_Password << endl;		cout << "Age : " << realage << endl;		if ( realage > 18 )			setAdult(true);		else			setAdult(false);	}	else#endif	{		setNetmarble(false);		BYTE szID;		iStream.read(szID);		if (szID == 0)			throw InvalidProtocolException("szID == 0");		if (szID > 30)			throw InvalidProtocolException("too large ID length");		iStream.read(m_ID , szID);		BYTE szPassword;		iStream.read(szPassword);		if (szPassword == 0)			throw InvalidProtocolException("szPassword == 0");		if (szPassword > 30)			throw InvalidProtocolException("too large password length");		iStream.read(m_Password , szPassword);		iStream.read((char*)m_cMacAddress, 6 * szBYTE);		/* convert hex -> str */				char	tmpStr[20];		sprintf(tmpStr, "%02x%02x%02x%02x%02x%02x", m_cMacAddress[0],m_cMacAddress[1],m_cMacAddress[2],m_cMacAddress[3],m_cMacAddress[4],m_cMacAddress[5]);		m_strMacAddress	= tmpStr;			}	__END_CATCH}void CLLogin::write (SocketOutputStream & oStream) const      throw (ProtocolException , Error){	__BEGIN_TRY	// 齿付喉狼 Cpsso 包访等 内靛绰 辑滚狼 Write 俊辑绰 绊摹瘤 臼绰促  (静捞瘤 臼栏骨肺 ;;)	// Client 俊辑父 舅酒辑 贸府秦辑 焊郴林档废 茄促.	BYTE szID = m_ID.size();	if (szID == 0)		throw InvalidProtocolException("empty ID");	if (szID > 30)		throw InvalidProtocolException("too large ID length");	oStream.write(szID);	oStream.write(m_ID);	BYTE szPassword = m_Password.size();	if (szPassword == 0)		throw InvalidProtocolException("szPassword == 0");	if (szPassword > 30)		throw InvalidProtocolException("too large password length");	oStream.write(szPassword);	oStream.write(m_Password);	oStream.write((char*)m_cMacAddress, 6 * sizeof(BYTE));	__END_CATCH}void CLLogin::execute (Player* pPlayer) 	 throw (ProtocolException , Error){	__BEGIN_TRY			CLLoginHandler::execute (this , pPlayer);			__END_CATCH}string CLLogin::toString () const	throw (){	StringStream msg;	msg << "CLLogin("		<< "ID:" << m_ID 		<< ",Password:" << m_Password 		<< ")";	return msg.toString();}PacketSize_t CLLogin::getPacketSize() const 	throw(){ 	if (g_pConfig->getPropertyInt("IsNetMarble")==1)	{		return szint + m_Cpsso.size();	}	else	{		return szBYTE + m_ID.size() + szBYTE + m_Password.size() + 6; 	}}bool CLLogin::checkMacAddress(string lastMac) const 	throw() {	bool retValue = false;	if(m_strMacAddress	== lastMac)	retValue = true;		return retValue;     }

⌨️ 快捷键说明

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