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

📄 gcupdateinfo.cpp

📁 dk1游戏的原代码文件,完整.编译系统redhat7.3,mysql 3.23 ,luascript v4.0 support
💻 CPP
字号:
//-------------------------------------------------------------------------------- // // Filename    : GCUpdateInfo.cpp // Written By  : reiot@ewestsoft.com// Description : // //--------------------------------------------------------------------------------// include files#include "GCUpdateInfo.h"#include "PCSlayerInfo2.h"#include "PCVampireInfo2.h"#include "PCOustersInfo2.h"#include "Assert.h"// for client.. by sigi#ifndef SAFE_DELETE	#define SAFE_DELETE(p)	if (p!=NULL) { delete p; p=NULL; }#endif//--------------------------------------------------------------------------------// constructor//--------------------------------------------------------------------------------GCUpdateInfo::GCUpdateInfo ()	throw (): m_pPCInfo(NULL), m_pInventoryInfo(NULL), m_pGearInfo(NULL), m_pExtraInfo(NULL), m_pEffectInfo(NULL), m_hasMotorcycle(false), m_pRideMotorcycleInfo(NULL), m_fPremium(0){}//--------------------------------------------------------------------------------// destructor//--------------------------------------------------------------------------------GCUpdateInfo::~GCUpdateInfo ()	throw (){	SAFE_DELETE(m_pPCInfo);	SAFE_DELETE(m_pInventoryInfo);	SAFE_DELETE(m_pGearInfo);	SAFE_DELETE(m_pExtraInfo);	SAFE_DELETE(m_pEffectInfo);	SAFE_DELETE(m_pRideMotorcycleInfo);	// 辑滚 率俊辑绰 粮 郴何俊辑 NPCInfo狼 府胶飘啊 粮犁茄促.	// 捞 府胶飘绰 泅犁肺辑绰 阂函捞促. 弊矾骨肺 概锅 NPCInfo甫	// new肺 积己窍咯, GCUpdateInfo俊促 持绢林绊, 促矫 delete窍绰 巴篮	// 加档 搁俊辑 好阑 锭 惑寸洒 颊秦促. 弊贰辑 GCUpdateInfo 救俊	// 乐绰 NPCInfoList俊绰 Zone狼 NPCInfoList狼 器牢磐甫 弊成	// 傈崔秦 霖促. 弊矾骨肺 辑滚 螟俊辑绰 捞甫 昏力窍搁 救 等促.	// 弊矾唱 努扼捞攫飘俊辑绰 捞甫 昏力秦 拎具 茄促.#ifdef __GAME_CLIENT__	list<NPCInfo*>::iterator itr = m_NPCInfos.begin();	for (; itr != m_NPCInfos.end(); itr++)	{		NPCInfo* pInfo = *itr;		SAFE_DELETE(pInfo);	}#else	m_NPCInfos.clear();#endif}//--------------------------------------------------------------------------------// 涝仿胶飘覆(滚欺)栏肺何磐 单捞鸥甫 佬绢辑 菩哦阑 檬扁拳茄促.//--------------------------------------------------------------------------------void GCUpdateInfo::read ( SocketInputStream & iStream ) 	 throw ( ProtocolException , Error ){	__BEGIN_TRY	//--------------------------------------------------	// read pc type/info	//--------------------------------------------------	char pcType;	iStream.read( pcType );	switch ( pcType ) {		case 'S' :			m_pPCInfo = new PCSlayerInfo2();			break;		case 'V' :			m_pPCInfo = new PCVampireInfo2();			break;		case 'O' :			m_pPCInfo = new PCOustersInfo2();			break;		default :			throw InvalidProtocolException("invalid pc type");	}	m_pPCInfo->read( iStream ); 	m_pInventoryInfo = new InventoryInfo();	m_pInventoryInfo->read( iStream );	m_pGearInfo = new GearInfo();	m_pGearInfo->read( iStream );	m_pExtraInfo = new ExtraInfo();	m_pExtraInfo->read( iStream );	m_pEffectInfo = new EffectInfo();	m_pEffectInfo->read( iStream );	iStream.read( m_hasMotorcycle );	if( m_hasMotorcycle ) {		m_pRideMotorcycleInfo = new RideMotorcycleInfo();		m_pRideMotorcycleInfo->read( iStream );	}	//--------------------------------------------------	// read zone info	//--------------------------------------------------	iStream.read( m_ZoneID );	iStream.read( m_ZoneX );	iStream.read( m_ZoneY );	m_GameTime.read( iStream );	BYTE weather;	iStream.read( weather );	m_Weather = (Weather)weather;	iStream.read( m_WeatherLevel );		iStream.read( m_DarkLevel);	iStream.read( m_LightLevel);	//--------------------------------------------------	// read NPC types	//--------------------------------------------------	iStream.read( m_nNPCs );//	if ( m_nNPCs == 0 )//		throw InvalidProtocolException("m_nNPCs == 0");	if ( m_nNPCs > maxNPCPerZone )		throw InvalidProtocolException("too many NPC types per zone");	for ( uint i = 0 ; i < m_nNPCs ; i ++ )		iStream.read( m_NPCTypes[i] );	//--------------------------------------------------	// read Monster types	//--------------------------------------------------	iStream.read( m_nMonsters );//	if ( m_nMonsters == 0 )//		throw InvalidProtocolException("m_nMonsters == 0");	if ( m_nMonsters > maxMonsterPerZone )		throw InvalidProtocolException("too many Monster types per zone");	for ( uint j = 0 ; j < m_nMonsters ; j ++ )		iStream.read( m_MonsterTypes[j] );	//////////////////////////////////////////////////	// read npc info	//////////////////////////////////////////////////	BYTE NPCInfoCount = 0;	iStream.read(NPCInfoCount);	for (BYTE nc=0; nc<NPCInfoCount; nc++)	{		NPCInfo* pInfo = new NPCInfo;		pInfo->read(iStream);		addNPCInfo(pInfo);	}			// 辑滚 惑怕	iStream.read( m_ServerStat );	// 橇府固决	iStream.read( m_fPremium );	__END_CATCH}		    //--------------------------------------------------------------------------------// 免仿胶飘覆(滚欺)栏肺 菩哦狼 官捞呈府 捞固瘤甫 焊辰促.//--------------------------------------------------------------------------------void GCUpdateInfo::write ( SocketOutputStream & oStream ) const      throw ( ProtocolException , Error ){	__BEGIN_TRY	//--------------------------------------------------	// write pc type	//--------------------------------------------------	Assert( m_pPCInfo != NULL );	char pcType;	switch ( m_pPCInfo->getPCType() ) {		case PC_SLAYER : 			pcType = 'S'; 			break;		case PC_VAMPIRE : 			pcType = 'V'; 			break;		case PC_OUSTERS :			pcType = 'O';			break;		default : 			throw InvalidProtocolException("invalid pc type");	}		oStream.write( pcType );	m_pPCInfo->write( oStream );	m_pInventoryInfo->write( oStream );	m_pGearInfo->write( oStream );	m_pExtraInfo->write( oStream );	m_pEffectInfo->write( oStream );	oStream.write( m_hasMotorcycle );	if( m_hasMotorcycle ) {		m_pRideMotorcycleInfo->write( oStream );	}	//--------------------------------------------------	// write zone info	//--------------------------------------------------	oStream.write( m_ZoneID );	oStream.write( m_ZoneX );	oStream.write( m_ZoneY );	m_GameTime.write( oStream );	oStream.write( (BYTE)m_Weather );	oStream.write( m_WeatherLevel );	oStream.write( m_DarkLevel );	oStream.write( m_LightLevel );	//--------------------------------------------------	// write NPC types	//--------------------------------------------------	oStream.write( m_nNPCs );//	if ( m_nNPCs == 0 )//		throw InvalidProtocolException("m_nNPCs == 0");	if ( m_nNPCs > maxNPCPerZone )		throw InvalidProtocolException("too many NPC types per zone");	for ( uint i = 0 ; i < m_nNPCs ; i ++ )		oStream.write( m_NPCTypes[i] );	//--------------------------------------------------	// write Monster types	//--------------------------------------------------	oStream.write( m_nMonsters );//	if ( m_nMonsters == 0 )//		throw InvalidProtocolException("m_nMonsters == 0");	if ( m_nMonsters > maxMonsterPerZone )		throw InvalidProtocolException("too many Monster types per zone");	for ( uint j = 0 ; j < m_nMonsters ; j ++ )		oStream.write( m_MonsterTypes[j] );	//////////////////////////////////////////////////	// write npc info	//////////////////////////////////////////////////	BYTE NPCInfoCount = m_NPCInfos.size();	oStream.write(NPCInfoCount);	list<NPCInfo*>::const_iterator itr = m_NPCInfos.begin();	for (; itr != m_NPCInfos.end(); itr++)	{		NPCInfo* pInfo = *itr;		pInfo->write(oStream);	}			// 辑滚 惑怕	oStream.write(m_ServerStat);	// 橇府固决	oStream.write( m_fPremium );	__END_CATCH}//--------------------------------------------------------------------------------// execute packet's handler//--------------------------------------------------------------------------------void GCUpdateInfo::execute ( Player * pPlayer ) 	 throw ( ProtocolException , Error ){	__BEGIN_TRY			GCUpdateInfoHandler::execute( this , pPlayer );	__END_CATCH}//--------------------------------------------------------------------------------// get packet's debug string//--------------------------------------------------------------------------------string GCUpdateInfo::toString () const       throw (){	__BEGIN_TRY			StringStream msg;		msg << "GCUpdateInfo("		<< "PC:" << m_pPCInfo->toString()		<< "EffectInfo:" << m_pEffectInfo->toString()		<< ",ZoneID: " << m_ZoneID		<< ",ZoneX: " << m_ZoneX		<< ",ZoneY: " << m_ZoneY		<< ",GameTime:" << m_GameTime.toString() 		<< ",Weather:" << Weather2String[m_Weather]		<< ",WeatherLevel:" << (int)m_WeatherLevel		<< ",DarkLevel:" << (int)m_DarkLevel		<< ",LightLevel:" << (int)m_LightLevel;	msg << ",nNPCs: " << (int)m_nNPCs;	for ( uint i = 0 ; i < m_nNPCs ; i ++ )		msg << ",NPC[" << i + 1 << "]:" << (int)m_NPCTypes[i];	msg << ",nMonsters:" << (int)m_nMonsters;	for ( uint j = 0 ; j < m_nMonsters ; j ++ )		msg << ",Monster[" << j + 1 << "]:" << (int)m_MonsterTypes[j];	msg << ",NPCInfos:";	list<NPCInfo*>::const_iterator itr = m_NPCInfos.begin();	for (; itr != m_NPCInfos.end(); itr++)	{		NPCInfo* pInfo = *itr;		msg << pInfo->toString();	}	msg << ", ServerStat : " << (int)m_ServerStat;	msg << ", Premium : " << (int)m_fPremium;	msg << ")";	return msg.toString();	__END_CATCH}

⌨️ 快捷键说明

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