actiongiveitem.cpp

来自「dk1游戏的原代码文件,完整.编译系统redhat7.3,mysql 3.23 」· C++ 代码 · 共 111 行

CPP
111
字号
////////////////////////////////////////////////////////////////////////////////// Filename    : ActionGiveItem.cpp// Written By  : // Description :////////////////////////////////////////////////////////////////////////////////#include "ActionGiveItem.h"#include "Creature.h"#include "PlayerCreature.h"#include "GamePlayer.h"#include "ItemFactoryManager.h"#include "Inventory.h"#include "ItemUtil.h"#include "Zone.h"#include "PacketUtil.h"#include "Gpackets/GCCreateItem.h"////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////void ActionGiveItem::read (PropertyBuffer & propertyBuffer)    throw (Error){    __BEGIN_TRY	try 	{		m_ItemClass = (Item::ItemClass)propertyBuffer.getPropertyInt("ItemClass");		m_ItemType = (ItemType_t)propertyBuffer.getPropertyInt("ItemType");	} 	catch (NoSuchElementException & nsee)	{		throw Error(nsee.toString());	}	    __END_CATCH}////////////////////////////////////////////////////////////////////////////////// 咀记阑 角青茄促.////////////////////////////////////////////////////////////////////////////////void ActionGiveItem::execute (Creature * pCreature1 , Creature * pCreature2) 	throw (Error){	__BEGIN_TRY	Assert(pCreature2 != NULL);	Assert(pCreature2->isPC());	PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pCreature2);	Assert( pPC != NULL );	Player* pPlayer = pCreature2->getPlayer();	Assert( pPlayer != NULL );	list<OptionType_t> optionTypeList;	Item* pItem = g_pItemFactoryManager->createItem( m_ItemClass, m_ItemType, optionTypeList );	Assert( pItem != NULL );		_TPOINT pt;	Inventory* pInventory = pPC->getInventory();	Assert( pInventory != NULL );		if (!pInventory->getEmptySlot(pItem, pt))	{		// ConditionHasInvenSpace 牧叼记苞 馆靛矫 窃膊 结具父 茄促.		throw Error("ActionGiveItem: 力惯 ConditionHasInvenSpace尔 鞍捞 静磊. 牢亥配府俊 磊府绝促.");	}	CoordInven_t X = pt.x;	CoordInven_t Y = pt.y;	pPC->getZone()->getObjectRegistry().registerObject( pItem );	pInventory->addItem( X, Y, pItem );	pItem->create( pPC->getName(), STORAGE_INVENTORY, 0, X, Y );	if ( pItem != NULL && pItem->isTraceItem() )	{		remainTraceLog( pItem, "ActionGiveItem", pCreature2->getName(), ITEM_LOG_CREATE, DETAIL_EVENTNPC);	}	// 努扼捞攫飘俊 急拱捞 眠啊登菌澜阑 舅赴促.	GCCreateItem gcCreateItem;	makeGCCreateItem( &gcCreateItem, pItem, X, Y );	pPlayer->sendPacket(&gcCreateItem);	__END_CATCH}////////////////////////////////////////////////////////////////////////////////// get debug string////////////////////////////////////////////////////////////////////////////////string ActionGiveItem::toString () const 	throw (){	__BEGIN_TRY	StringStream msg;	msg << "ActionGiveItem("	    << ")";	return msg.toString();	__END_CATCH}

⌨️ 快捷键说明

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