当前位置: 首页>>代码示例>>C++>>正文


C++ ItemContainer类代码示例

本文整理汇总了C++中ItemContainer的典型用法代码示例。如果您正苦于以下问题:C++ ItemContainer类的具体用法?C++ ItemContainer怎么用?C++ ItemContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ItemContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Assert

Item*	HumanItemLogic::GetBankItem(Obj_Human* pHuman,UINT BankIndex)
{
	__ENTER_FUNCTION

		Assert(BankIndex<MAX_BANK_SIZE);
	Assert(BankIndex>=0);
	if(BankIndex<0||BankIndex>MAX_BANK_SIZE)
	{
		AssertEx(FALSE,"HumanItemLogic::GetBankItem() BankIndex 不在合法范围 ");
		return NULL;
	}

	ItemContainer*	pBankContainer = pHuman->GetBankContain();

	Assert(pBankContainer);

	if(!pBankContainer)
	{
		return NULL;
	}

	return pBankContainer->GetItem((UINT)BankIndex);

	__LEAVE_FUNCTION

		return NULL;
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例2: _parent

/**
* Initializes all the elements in the Load Craft Loadout window.
*/
CraftEquipmentLoadState::CraftEquipmentLoadState(CraftEquipmentState *parent) : _parent(parent)
{
	_screen = false;

	// Create objects
	_window = new Window(this, 240, 136, 40, 36+1, POPUP_BOTH);
	_txtTitle = new Text(230, 16, 45, 44+3);
	_lstLoadout = new TextList(208, 80, 48, 60);
	_btnCancel = new TextButton(120, 16, 90, 148);

	// Set palette
	setInterface("craftEquipmentLoad");

	add(_window, "window", "craftEquipmentLoad");
	add(_txtTitle, "text", "craftEquipmentLoad");
	add(_lstLoadout, "list", "craftEquipmentLoad");
	add(_btnCancel, "button", "craftEquipmentLoad");

	centerAllSurfaces();

	// Set up objects
	_window->setBackground(_game->getMod()->getSurface("BACK04.SCR"));

	_txtTitle->setAlign(ALIGN_CENTER);
	_txtTitle->setText(tr("STR_LOAD_CRAFT_LOADOUT_TEMPLATE"));

	_lstLoadout->setColumns(1, 192);
	_lstLoadout->setSelectable(true);
	_lstLoadout->setBackground(_window);
	_lstLoadout->setMargin(8);
	_lstLoadout->onMouseClick((ActionHandler)&CraftEquipmentLoadState::lstLoadoutClick);

	_btnCancel->setText(tr("STR_CANCEL_UC"));
	_btnCancel->onMouseClick((ActionHandler)&CraftEquipmentLoadState::btnCancelClick);
	_btnCancel->onKeyboardPress((ActionHandler)&CraftEquipmentLoadState::btnCancelClick, Options::keyCancel);

	for (int i = 0; i < SavedGame::MAX_CRAFT_LOADOUT_TEMPLATES; ++i)
	{
		ItemContainer *item = _game->getSavedGame()->getGlobalCraftLoadout(i);
		if (item->getContents()->empty())
		{
			_lstLoadout->addRow(1, tr("STR_EMPTY_SLOT_N").arg(i + 1).c_str());
		}
		else
		{
			const std::wstring &itemName = _game->getSavedGame()->getGlobalCraftLoadoutName(i);
			if (itemName.empty())
			{
				_lstLoadout->addRow(1, tr("STR_UNNAMED_SLOT_N").arg(i + 1).c_str());
			}
			else
			{
				_lstLoadout->addRow(1, itemName.c_str());
			}
		}
	}
}
开发者ID:Darineth,项目名称:OpenXcom,代码行数:60,代码来源:CraftEquipmentLoadState.cpp

示例3: itemText

QString LastMultipleScoresList::itemText(const ItemContainer &item,
                                         uint row) const
{
//   kDebug(11001) ;
    QString name = item.name();
    if ( name==QLatin1String( "rank" ) )
        return (_scores[row].type()==Won ? i18n("Winner") : QString());
    QVariant v = _scores[row].data(name);
    if ( name==QLatin1String( "name" ) ) return v.toString();
    return item.item()->pretty(row, v);
}
开发者ID:alasin,项目名称:libkdegames,代码行数:11,代码来源:kexthighscore_gui.cpp

示例4: _base

/**
 * Initializes all the elements in the productions start screen.
 * @param game Pointer to the core game.
 * @param base Pointer to the base to get info from.
 * @param item The RuleManufacture to produce.
 */
ManufactureStartState::ManufactureStartState(Base * base, RuleManufacture * item) :  _base(base), _item(item)
{
	_screen = false;

	_window = new Window(this, 320, 160, 0, 20);
	_btnCancel = new TextButton(136, 16, 16, 155);
	_txtTitle = new Text(320, 17, 0, 30);
	_txtManHour = new Text(290, 9, 16, 50);
	_txtCost = new Text(290, 9, 16, 60);
	_txtWorkSpace = new Text(290, 9, 16, 70);

	_txtRequiredItemsTitle = new Text(290, 9, 16, 84);
	_txtItemNameColumn = new Text(60, 16, 30, 92);
	_txtUnitRequiredColumn = new Text(60, 16, 155, 92);
	_txtUnitAvailableColumn = new Text(60, 16, 230, 92);
	_lstRequiredItems = new TextList(270, 40, 30, 108);

	_btnStart = new TextButton(136, 16, 168, 155);

	// Set palette
	setInterface("allocateManufacture");

	add(_window, "window", "allocateManufacture");
	add(_txtTitle, "text", "allocateManufacture");
	add(_txtManHour, "text", "allocateManufacture");
	add(_txtCost, "text", "allocateManufacture");
	add(_txtWorkSpace, "text", "allocateManufacture");
	add(_btnCancel, "button", "allocateManufacture");

	add(_txtRequiredItemsTitle, "text", "allocateManufacture");
	add(_txtItemNameColumn, "text", "allocateManufacture");
	add(_txtUnitRequiredColumn, "text", "allocateManufacture");
	add(_txtUnitAvailableColumn, "text", "allocateManufacture");
	add(_lstRequiredItems, "list", "allocateManufacture");

	add(_btnStart, "button", "allocateManufacture");

	centerAllSurfaces();

	_window->setBackground(_game->getResourcePack()->getSurface("BACK17.SCR"));

	_txtTitle->setText(tr(_item->getName()));
	_txtTitle->setBig();
	_txtTitle->setAlign(ALIGN_CENTER);

	_txtManHour->setText(tr("STR_ENGINEER_HOURS_TO_PRODUCE_ONE_UNIT").arg(_item->getManufactureTime()));

	_txtCost->setText(tr("STR_COST_PER_UNIT_").arg(Text::formatFunding(_item->getManufactureCost())));

	_txtWorkSpace->setText(tr("STR_WORK_SPACE_REQUIRED").arg(_item->getRequiredSpace()));

	_btnCancel->setText(tr("STR_CANCEL_UC"));
	_btnCancel->onMouseClick((ActionHandler)&ManufactureStartState::btnCancelClick);
	_btnCancel->onKeyboardPress((ActionHandler)&ManufactureStartState::btnCancelClick, Options::keyCancel);

	const std::map<std::string, int> & requiredItems (_item->getRequiredItems());
	int availableWorkSpace = _base->getFreeWorkshops();
	bool productionPossible = _game->getSavedGame()->getFunds() > _item->getManufactureCost();
	productionPossible &= (availableWorkSpace > 0);

	_txtRequiredItemsTitle->setText(tr("STR_SPECIAL_MATERIALS_REQUIRED"));
	_txtRequiredItemsTitle->setAlign(ALIGN_CENTER);

	_txtItemNameColumn->setText(tr("STR_ITEM_REQUIRED"));
	_txtItemNameColumn->setWordWrap(true);

	_txtUnitRequiredColumn->setText(tr("STR_UNITS_REQUIRED"));
	_txtUnitRequiredColumn->setWordWrap(true);

	_txtUnitAvailableColumn->setText(tr("STR_UNITS_AVAILABLE"));
	_txtUnitAvailableColumn->setWordWrap(true);

	_lstRequiredItems->setColumns(3, 140, 75, 55);
	_lstRequiredItems->setBackground(_window);

	ItemContainer * itemContainer (base->getItems());
	int row = 0;
	for (std::map<std::string, int>::const_iterator iter = requiredItems.begin();
		iter != requiredItems.end();
		++iter)
	{
		std::wostringstream s1, s2;
		s1 << L'\x01' << iter->second;
		s2 << L'\x01' << itemContainer->getItem(iter->first);
		productionPossible &= (itemContainer->getItem(iter->first) >= iter->second);
		_lstRequiredItems->addRow(3, tr(iter->first).c_str(), s1.str().c_str(), s2.str().c_str());
		row++;
	}
	_txtRequiredItemsTitle->setVisible(!requiredItems.empty());
	_txtItemNameColumn->setVisible(!requiredItems.empty());
	_txtUnitRequiredColumn->setVisible(!requiredItems.empty());
	_txtUnitAvailableColumn->setVisible(!requiredItems.empty());
	_lstRequiredItems->setVisible(!requiredItems.empty());

//.........这里部分代码省略.........
开发者ID:vazub,项目名称:OpenXcom,代码行数:101,代码来源:ManufactureStartState.cpp

示例5: Assert

UINT CGEquipRefiningHandler::Execute( CGEquipRefining* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION

	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;
	Assert( pHuman ) ;

	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}
	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID );

	//切场景时丢弃换装消息
	//交易状态不可操作
	//摆摊状态不可操作

	// 获取炼化的装备
	BYTE iEquipItemPos = pPacket->GetEquipItemPos();
	Assert(iEquipItemPos >= 0 );
	Assert(iEquipItemPos <= MAX_BAG_SIZE);
	
	GCEquipRefining	msg;
	ItemContainer* pBagContainer = HumanItemLogic::GetBagContainer(pHuman, iEquipItemPos);
	if (pBagContainer == NULL)
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRefiningHandler equipment BagIndex is invalid, BagIndex = %d", iEquipItemPos) ;
		msg.SetResult(EQUIPREFINING_NOT_SUCH_ITEM);
		pGamePlayer->SendPacket(&msg);
		return PACKET_EXE_CONTINUE;
	}

	Item* pEquipment = pBagContainer->GetItem(pBagContainer->BagIndex2ConIndex(iEquipItemPos));
	Assert(NULL != pEquipment);
	//一些验证:星级,等级...
	if( NULL == pEquipment || ICLASS_EQUIP != pEquipment->GetItemClass() || !(pEquipment->IsRuler(IRL_DISCARD) )
		|| pEquipment->IsAdsorbMagic()	|| pEquipment->GetRequireLevel() < EQUIP_REFINING_MIN_LEVEL	//已经附魔或者需求等级小于40
		|| 0 == pEquipment->GetEquipGemCount())	//没有镶嵌宝石
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRefiningHandler equipment type is invalid, BagIndex = %d", iEquipItemPos) ;
		msg.SetResult(EQUIPREFINING_NOT_SUCH_ITEM);
		pGamePlayer->SendPacket(&msg);

		return PACKET_EXE_CONTINUE;
	}
	//获取炼化神器
	BYTE iRefiningItemPos = pPacket->GetRefiningItemPos();
	Assert(iRefiningItemPos >= 0 );
	Assert(iRefiningItemPos <= MAX_BAG_SIZE);

	pBagContainer = HumanItemLogic::GetBagContainer(pHuman, iRefiningItemPos);
	if (pBagContainer == NULL)
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRefiningHandler refining BagIndex is invalid, BagIndex = %d", iRefiningItemPos) ;
		msg.SetResult(EQUIPREFINING_NOT_SUCH_ITEM);
		pGamePlayer->SendPacket(&msg);
		return PACKET_EXE_CONTINUE;
	}

	Item* pRefiningItem = pBagContainer->GetItem(pBagContainer->BagIndex2ConIndex(iRefiningItemPos));
	Assert(NULL != pRefiningItem);
	if(NULL == pRefiningItem || pRefiningItem->GetItemClass() != ICLASS_COMITEM || pRefiningItem->GetItemType() != COMITEM_EQUIP_REFINING)
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRefiningHandler refining type is invalid, BagIndex = %d", iRefiningItemPos) ;
		msg.SetResult(EQUIPREFINING_NOT_SUCH_ITEM);
		pGamePlayer->SendPacket(&msg);

		return PACKET_EXE_CONTINUE;
	}
	//逻辑处理 
	COMMITEM_INFO_TB* pGet = g_ItemTable.GetCommItemInfoTB(pRefiningItem->GetItemTableIndex());
	Assert(NULL != pGet);
	if ((pEquipment->GetRequireLevel()-1)/10+1 != pGet->m_nLevel)//验证等级
	{
		msg.SetResult(EQUIPREFINING_NOT_SUCH_ITEM);
		pGamePlayer->SendPacket(&msg);

		return PACKET_EXE_CONTINUE;
	}

	if ( 0 == pEquipment->GetAttrCount())// && pEquipment->GetLevel() 
	{
		msg.SetResult(EQUIPREFINING_NOT_HAVE_ATTR);
		pGamePlayer->SendPacket(&msg);
		return PACKET_EXE_CONTINUE;
	}

	//EQUIP_TB* pGet = g_ItemTable.GetEquipTB(pEquipment->GetItemTableIndex());
	//Assert(NULL != pGet);
	//删除装备和炼化神符道具
	UINT iPrice = pEquipment->GetSellPrice();//保留将要删除的装备属性给后面用
	BYTE iRequireLevel = pEquipment->GetRequireLevel();
	BYTE curEquipPoint = pEquipment->GetEquipPoint();
	BYTE attrCount = 0;
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:wx2Server,代码行数:101,代码来源:CGEqupRefiningHandler.cpp

示例6: Assert

UINT CGUnEquipHandler::Execute( CGUnEquip* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION

	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;
	Assert( pHuman ) ;

	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}

	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;

	HUMAN_EQUIP	EquipPoint = (HUMAN_EQUIP)pPacket->getEquipPoint();

	//Assert( pHuman->GetDB()->GetEquipDB()->IsSet(EquipPoint) ) ;



	Item*	pEquipItem = HumanItemLogic::GetEquip(pHuman,EquipPoint);
	
	if(!pEquipItem)
	{
		Assert(pEquipItem);
		return	PACKET_EXE_CONTINUE;
	}
	if(pEquipItem->IsEmpty())
	{
		return	PACKET_EXE_CONTINUE;
	}

	UCHAR	itemClass = pEquipItem->GetItemClass();
	if(itemClass ==	ICLASS_EQUIP)
	{
		INT		BagIndex;//	=	pHuman->GetFirstEmptyBagIndex();

		ItemContainer*	pEquipContainer = pHuman->GetEquipContain();
		ItemContainer*	pBaseContainer	= pHuman->GetBaseContain();

		if(!pEquipContainer)
		{
			Assert(pEquipItem);
			return	PACKET_EXE_CONTINUE;
		}
		
		BYTE	DeliverBagIndex = pPacket->getBagIndex();

		if(DeliverBagIndex<pBaseContainer->GetContainerSize())
		{
			BagIndex	=	g_ItemOperator.MoveItem(pEquipContainer,
				EquipPoint,
				pBaseContainer,DeliverBagIndex);
		}
		else
		{
			BagIndex	=	g_ItemOperator.MoveItem(pEquipContainer,
							EquipPoint,
							pBaseContainer);
		}
		

		GCUnEquipResult	 Msg;
		if(BagIndex>=0
			&& BagIndex<pBaseContainer->GetContainerSize())
		{
			Msg.setEquipPoint(EquipPoint);
			Msg.setBagIndex(BagIndex);
			Msg.setItemID(pEquipItem->GetGUID());
			Msg.setItemTableIndex(pEquipItem->GetItemTableIndex());
			Msg.setResult(UNEQUIP_SUCCESS);
			pHuman->SetEquipVer(pHuman->GetEquipVer()+1);
			pHuman->ItemEffectFlush();

			pGamePlayer->SendPacket( &Msg ) ;

			//如果可见
			if(pHuman->IsVisualPart(EquipPoint))
			{	
				GCCharEquipment OtherMsg;
				OtherMsg.setObjID(pHuman->GetID());
				//if(EquipPoint == HEQUIP_WEAPON)
				//{
				//	UINT uGemID = GetEquipmentMaxLevelGemID(pEquipItem);
				//	OtherMsg.setID(EquipPoint,pEquipItem->GetItemTableIndex(), uGemID);
				//}
				//else
				//{
					OtherMsg.setID(EquipPoint,pEquipItem->GetItemTableIndex(), -1);
				//}
				pScene->BroadCast(&OtherMsg,pHuman,TRUE);
			}
		}
		else
//.........这里部分代码省略.........
开发者ID:brock7,项目名称:TianLong,代码行数:101,代码来源:CGUnEquipHandler.cpp

示例7: Assert

uint CGExchangeSynchItemIIHandler::Execute( CGExchangeSynchItemII* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION

	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;
	Assert( pHuman ) ;

	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}

	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;

	//验证交易状态
	EXCHANGE_CERTIFY_EACH_OTHER(pHuman)  // 验证交易双方是否掉线合法
	EXCHANGE_CERTIFY_ISLOCK(pHuman)		 // 验证当前人物的交易状态是否已经上锁
	ObjID_t	DestID = pHuman->m_ExchangBox.m_ObjID;
	Obj_Human* pDestHuman = pScene->GetHumanManager()->GetHuman( DestID );
	EXCHANGE_CERTIFY_STATUS(pHuman, EXCHANGE_SYNCH_DATA) // 验证当前人物的交易状态是否正确
	EXCHANGE_CERTIFY_STATUS(pDestHuman, EXCHANGE_SYNCH_DATA)

	//操作
	BYTE		Opt = pPacket->GetOpt();
	BYTE		FromType = pPacket->GetFromType();
	BYTE		ToType = pPacket->GetToType();
	BYTE		FromIndex = pPacket->GetFromIndex();
	BYTE		ToIndex = pPacket->GetToIndex();
	PET_GUID_t	PetGuid = pPacket->GetPetGuid();

	_ITEM				ItemTemp;
	GCExchangeSynchII	Msg;
	GCExchangeError		MsgError;
	ItemContainer*		pExchangeContainer		= &(pHuman->m_ExchangBox.m_Container);
	ItemContainer*		pExchangePetContainer	= &(pHuman->m_ExchangBox.m_PetContainer);

	switch(Opt)
	{
	case OPT_ERROR:
		{
		}
		break;
	case OPT_ADDITEM:
		{
			switch(FromType)
			{
			case POS_BAG:
				{
					//验证位置里是否有东西
					Item* pItem = HumanItemLogic::GetBagItem(pHuman, FromIndex);

                    if ( pItem != NULL && pItem->GetItemClass() == ICLASS_EQUIP)
                    {
                        if(pItem->GetEquipBindLevel()>0) // 装备绑定
                        {
							MsgError.SetID(ERR_ITEM_LOCKED);
							pGamePlayer->SendPacket(&MsgError);
                            g_pLog->FastSaveLog( LOG_FILE_1, "<交易> [%s] 该物品[%d]已绑定,不可交易",	pHuman->GetName(), FromIndex ) ;
                            return PACKET_EXE_CONTINUE;
                        }
                    }
                    
					if (pItem == NULL)
					{
						MsgError.SetID(ERR_ILLEGAL);
						pGamePlayer->SendPacket(&MsgError);
						g_pLog->FastSaveLog( LOG_FILE_1, "<交易> [%s] 背包位置 [%d] 处不存在物品",	pHuman->GetName(), FromIndex ) ;
						return PACKET_EXE_CONTINUE;
					}
					if(pItem->IsEmpty() == FALSE)
					{
						ItemContainer*	pBagContainer = HumanItemLogic::GetBagContainer(pHuman, FromIndex);

						if ( pBagContainer == NULL )
						{
							MsgError.SetID(ERR_ILLEGAL);
							pGamePlayer->SendPacket(&MsgError);
							g_pLog->FastSaveLog( LOG_FILE_1, "<交易> [%s] 背包不存在",	pHuman->GetName() ) ;
							return PACKET_EXE_CONTINUE;
						}

						//先查一遍交易盒中是不是已经有该物品了
						for(INT i = 0; i<EXCHANGE_BOX_SIZE; i++)
						{
							_ITEM_GUID guid = (pBagContainer->GetItem(pBagContainer->BagIndex2ConIndex(FromIndex)))->GetGUID() ;
							if(pExchangeContainer->GetItem(i)->GetGUID() == guid)
							{//物品已经在交易盒中,丢弃该消息
								return PACKET_EXE_CONTINUE ;
							}

						}

						//自动找格
						INT result = 
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:wx2Server,代码行数:101,代码来源:CGExchangeSynchItemIIHandler.cpp

示例8: Assert

uint CGExchangeOkIIIHandler::Execute( CGExchangeOkIII* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION
	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;
	Assert( pHuman ) ;

	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}

	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;

	EXCHANGE_CERTIFY_EACH_OTHER(pHuman)
	ObjID_t	DestID = pHuman->m_ExchangBox.m_ObjID;
	Obj_Character *pTarget = (Obj_Character*)(pScene->GetObjManager()->GetObj( DestID ));
	if(pTarget->GetObjType() != Obj::OBJ_TYPE_HUMAN)
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGExchangeOkIIIHandler: %s ask not a human.", pHuman->GetName() ) ;
		return	PACKET_EXE_CONTINUE;
	}
	Obj_Human* pDestHuman = (Obj_Human*)pTarget;
	if( pDestHuman == NULL )
	{
		Assert(FALSE);
		return PACKET_EXE_CONTINUE;
	}

	// 不同阵营,不让查看
	if( pHuman->IsEnemy( pDestHuman ) )
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGExchangeOkIIIHandler: %s cann't ask %s's detailattr ", pHuman->GetName(), pDestHuman->GetName() ) ;
		return	PACKET_EXE_CONTINUE;
	}

	if(pHuman->m_ExchangBox.m_Status == ServerExchangeBox::EXCHANGE_WAIT_FOR_CONFIRM)
	{
		//设置可以交换
		pHuman->m_ExchangBox.m_Status = ServerExchangeBox::EXCHANGE_CONFIRM_READY;
		if(pDestHuman->m_ExchangBox.m_Status ==  ServerExchangeBox::EXCHANGE_CONFIRM_READY)
		{//可以交换了

			//1.变量初始化
			ItemContainer*		pMyExchangeContainer = &(pHuman->m_ExchangBox.m_Container);
			ItemContainer*		pOtExchangeContainer = &(pDestHuman->m_ExchangBox.m_Container);
			ItemContainer*		pMyExchangePetContainer = &(pHuman->m_ExchangBox.m_PetContainer);
			ItemContainer*		pOtExchangePetContainer = &(pDestHuman->m_ExchangBox.m_PetContainer);

			_EXCHANGE_ITEM_LIST			ItemListMeToOt;
			_EXCHANGE_ITEM_LIST			ItemListOtToMe;

			ItemListMeToOt.Init();
			ItemListOtToMe.Init();

			//2.验证循环
			g_pLog->FastSaveLog( LOG_FILE_1, "<交易> [%s] 与 [%s] 开始验证循环",	pHuman->GetName(), pDestHuman->GetName()) ;
			for(INT i = 0; i<EXCHANGE_BOX_SIZE; i++)
			{
				if(pMyExchangeContainer->GetItem(i)->IsEmpty() == FALSE)
				{
					ItemListMeToOt.AddItem( pMyExchangeContainer->GetItem(i) );
				}
				if(pOtExchangeContainer->GetItem(i)->IsEmpty() == FALSE)
				{
					ItemListOtToMe.AddItem( pOtExchangeContainer->GetItem(i) );
				}
			}

			for(INT i = 0; i<EXCHANGE_PET_BOX_SIZE; i++)
			{
				if(pMyExchangePetContainer->GetItem(i)->IsEmpty() == FALSE)
				{
					ItemListMeToOt.AddItem( pMyExchangePetContainer->GetItem(i) );
				}
				if(pOtExchangePetContainer->GetItem(i)->IsEmpty() == FALSE)
				{
					ItemListOtToMe.AddItem( pOtExchangePetContainer->GetItem(i) );
				}
			}

			if( FALSE == HumanItemLogic::CanReceiveExchangeItemList( pHuman, ItemListOtToMe) )
			{//空间不够
				GCExchangeError MsgSelf;
				MsgSelf.SetID(EXCHANGE_MSG::ERR_NOT_ENOUGHT_ROOM_SELF);
				pHuman->GetPlayer()->SendPacket(&MsgSelf);

				GCExchangeError MsgOther;
				MsgOther.SetID(EXCHANGE_MSG::ERR_NOT_ENOUGHT_ROOM_OTHER);
				pDestHuman->GetPlayer()->SendPacket(&MsgOther);
				
				pHuman->m_ExchangBox.CleanUp();
				pDestHuman->m_ExchangBox.CleanUp();
				g_pLog->FastSaveLog( LOG_FILE_1, "		<交易> [%s] 空间不够", pHuman->GetName()) ;
				return PACKET_EXE_CONTINUE;
//.........这里部分代码省略.........
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:101,代码来源:CGExchangeOkIIIHandler.cpp

示例9: Assert

uint CGEquipExChangePaiTypeHandler::Execute(CGEquipExChangePaiType* pPacket,Player* pPlayer)
{
	__ENTER_FUNCTION

		GamePlayer* pGamePlayer = (GamePlayer*)pPlayer;
	Assert( pGamePlayer );

	Obj_Human* pHuman = pGamePlayer->GetHuman();
	Assert( pHuman );

	Scene* pScene = pHuman->getScene();
	if( pScene==NULL )
	{
		Assert(FALSE);
		return PACKET_EXE_ERROR;
	}

	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID );
	//交易状态不可操作
	if(pHuman->m_ExchangBox.m_Status > 0)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ExchangBox::m_Status>0" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}
	//摆摊状态不可操作
	if(pHuman->m_StallBox.GetStallStatus() == ServerStallBox::STALL_OPEN)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ServerStallBox::STALL_OPEN" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}

	//摆摊不可操作
	if(pHuman->m_StallBox.GetStallStatus() == ServerStallBox::STALL_OPEN)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ServerStallBox::STALL_OPEN" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}

	ObjID_t		NpcObjID=	pPacket->GetUniqueID();
	Obj* pNpcObj = pScene->GetObjManager()->GetObj(NpcObjID);
	if (pNpcObj == NULL)
	{
		return PACKET_EXE_ERROR;
	}
	else
	{
		if( pNpcObj->GetObjType() != Obj::OBJ_TYPE_MONSTER )
		{
			return PACKET_EXE_ERROR;
		}
	}

	FLOAT fDist = MySqrt(pNpcObj->getWorldPos(), pHuman->getWorldPos());

	if(fDist>MAX_NPC_DISTANCE)
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler Out Of Range ObjName = %s", pHuman->GetName()) ;
		return PACKET_EXE_CONTINUE ; 
	}


	EQUIPEXCHANGEPAITTYPE_RESULT	Result = EQUIPEXCHANGEPAITTYPE_FAIL;
	GCEquipExChangePaiTypeResult  ResultPacket;

	Item*		pEquip1Item		= NULL;
	Item*		pEquip2Item		= NULL;
	INT			Equip1Point		= INVALID_ITEM_POS;
	INT			Equip2Point		= INVALID_ITEM_POS;
	if(pPacket->GetEquip1PosType()>=INVALID_ITEM_POS_TYPE)
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler Equip posType error, posType=%d", pPacket->GetEquip1PosType()) ;
		return PACKET_EXE_ERROR;
	}

	if(pPacket->GetEquip1PosType() == ENUM_BAG)
	{
		ItemContainer* pItemContainer1 = HumanItemLogic::GetBagContainer(pHuman,pPacket->GetPos1());
		if( pItemContainer1 == NULL )
		{
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler: BagIndex error, BagIndex=%d", pPacket->GetPos1()) ;
			return PACKET_EXE_ERROR;
		}
		if (!pItemContainer1->IsCanUse())
		{
			Result = EQUIPEXCHANGEPAITTYPE_BAG_INVALID;
			ResultPacket.SetResult(Result);
			pGamePlayer->SendPacket(&ResultPacket);;
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler: ItemContainer is invalid, ContainerType=%d, BagIndex=%d", 
				pItemContainer1->GetContainerType(), pPacket->GetPos1()) ;
				return PACKET_EXE_ERROR;
		}

		pEquip1Item		=	pItemContainer1->GetItem(pItemContainer1->BagIndex2ConIndex(pPacket->GetPos1()));
		if(pEquip1Item->IsEmpty())
		{
			Result = EQUIPEXCHANGEPAITTYPE_EQUIP_FAIL;
			ResultPacket.SetResult(Result);
			pGamePlayer->SendPacket(&ResultPacket);
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler Equip empyty, bagpos=%d", pPacket->GetPos1()) ;
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:wx2Server,代码行数:101,代码来源:CGEquipExChangePaiTypeHandler.cpp

示例10: Assert

UINT CGUseEquipHandler::Execute(CGUseEquip* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION
	
	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;
	Assert( pHuman ) ;
	
	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}

	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;

	//切场景时丢弃换装消息
	if(pGamePlayer->GetPlayerStatus()!=PS_SERVER_NORMAL ||
		!pHuman->IsActiveObj() )
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGUseEquipmentHandler: change scene") ;
		return PACKET_EXE_CONTINUE;
	}

	BYTE  BagIndex = pPacket->getBagIndex();

	if( BagIndex == INVALID_BAG_INDEX )
	{
		Assert(FALSE) ; //包发错了
		return PACKET_EXE_CONTINUE ;
	}
		
	Item* pUseItem = HumanItemLogic::GetItem(pHuman,BagIndex);
	
	GCUseEquipResult Msg;

	//////////////////////////////////////////////////////////////////////////
	//装配条件判断
	UCHAR	itemClass = pUseItem->GetItemClass();

	if(itemClass == ICLASS_EQUIP)
	{
		//需求等级判断
		if(pUseItem->GetRequireLevel()>pHuman->GetLevel())
		{
			Msg.setResult(USEEQUIP_IDENT_FAIL);
			pGamePlayer->SendPacket( &Msg ) ;
		}
		//鉴定判断
		else if(pUseItem->GetItemQual() == EQUALITY_BLUE && pUseItem->GetItemIdent() == FALSE)
		{
			Msg.setResult(USEEQUIP_LEVEL_FAIL);
			pGamePlayer->SendPacket( &Msg ) ;
		}
		else
		{
			
			HUMAN_EQUIP		Equip_Point =(HUMAN_EQUIP)pUseItem->GetEquipPoint();
			//const	_ITEM*			pEquip = pHuman->GetEquip(Equip_Point);
			ItemContainer*	pEquipContainer = pHuman->GetEquipContain();
			
			if(!pEquipContainer)
			{
				Assert(pEquipContainer);
				return PACKET_EXE_CONTINUE;
			}

			Item*	pEquipItem = pEquipContainer->GetItem((UINT)Equip_Point);

			if(!pEquipItem)
			{
				Assert(pEquipItem);
				return PACKET_EXE_CONTINUE;

			}
			
			BOOL			bEquipStatus = (!pEquipItem->IsEmpty());

			ItemContainer*	pBagContainer =
				HumanItemLogic::GetContainer(pHuman,BagIndex);

			if(bEquipStatus)
			{
				//装备上物品,替换下来装备点数据
				
				g_ItemOperator.ExchangeItem(pBagContainer,
											pBagContainer->BagIndex2ConIndex(BagIndex),
											pEquipContainer,
											(UINT)Equip_Point);


			}
			else
			{ 
				//pHuman->GetDB()->OverWriteBag2Equip(BagIndex,Equip_Point);
				g_ItemOperator.MoveItem(pBagContainer,
//.........这里部分代码省略.........
开发者ID:brock7,项目名称:TianLong,代码行数:101,代码来源:CGUseEquipHandler.cpp

示例11: Assert

uint CGStallItemPriceHandler::Execute( CGStallItemPrice* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION
		GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;
	Assert( pHuman ) ;

	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}

	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;

	//操作
	_ITEM_GUID	ItemGuid	=	pPacket->GetObjGUID();
	PET_GUID_t	PetGuid		=	pPacket->GetPetGUID();
	UINT		ItemPrice	=	pPacket->GetPrice();
	UINT		ItemSerial	=	pPacket->GetSerial();

	if(pHuman->m_StallBox.GetStallStatus() != ServerStallBox::STALL_OPEN)
	{
		GCStallError	Msg;
		Msg.SetID(STALL_MSG::ERR_ILLEGAL);
		pGamePlayer->SendPacket(&Msg);
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallItemPriceHandler::ObjName=%s, ERR_ILLEGAL:!= ServerStallBox::STALL_OPEN"
			,pHuman->GetName()) ;
		return PACKET_EXE_CONTINUE ;
	}

	ItemContainer*		pStallContainer		= pHuman->m_StallBox.GetContainer();
	ItemContainer*		pStallPetContainer	= pHuman->m_StallBox.GetPetContainer();
	GCStallError		MsgError;

	if(PetGuid.IsNull())
	{//对物品的价格操作
		INT	IndexInStall	=	pStallContainer->GetIndexByGUID(&ItemGuid);
		if(IndexInStall<0)
		{
			MsgError.SetID(STALL_MSG::ERR_NEED_NEW_COPY);
			pGamePlayer->SendPacket(&MsgError);
			g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallItemPriceHandler::ObjID=%d, ERR_NEED_NEW_COPY: IndexInStall = %d"
				,pHuman->GetID(), IndexInStall) ;
			return PACKET_EXE_CONTINUE ;
		}

		if(pHuman->m_StallBox.GetSerialByIndex(IndexInStall) > ItemSerial)
		{
			MsgError.SetID(STALL_MSG::ERR_NEED_NEW_COPY);
			pGamePlayer->SendPacket(&MsgError);
			g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallItemPriceHandler::ObjID=%d, ERR_NEED_NEW_COPY: ItemSerial = %d, BoxSerial = %d"
				,pHuman->GetID(), ItemSerial, pHuman->m_StallBox.GetSerialByIndex(IndexInStall)) ;
			return PACKET_EXE_CONTINUE ;
		}

		pHuman->m_StallBox.SetPriceByIndex(IndexInStall, ItemPrice);
		pHuman->m_StallBox.IncSerialByIndex(IndexInStall);

		//给Client返回一条消息,告诉Client版本号
		GCStallItemPrice msg;
		msg.SetObjGUID(pPacket->GetObjGUID());
		msg.SetPrice(pPacket->GetPrice());
		msg.SetSerial(pHuman->m_StallBox.GetSerialByIndex(IndexInStall));

		pGamePlayer->SendPacket(&msg);

		g_pLog->FastSaveLog( LOG_FILE_1, "CGStallItemPriceHandler::ObjName=%s, ERR_NEED_NEW_COPY: IndexInStall = %d, ItemPrice = %d"
			,pHuman->GetName(), IndexInStall, ItemPrice) ;
	}
	else
	{//改变宠物价格
		INT	PetIndexInStall	= pStallPetContainer->GetIndexByGUID(&PetGuid);

		if(PetIndexInStall<0)
		{
			MsgError.SetID(STALL_MSG::ERR_NEED_NEW_COPY);
			pGamePlayer->SendPacket(&MsgError);
			g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallItemPriceHandler::ObjName=%s, ERR_NEED_NEW_COPY: PetIndexInStall = %d"
				,pHuman->GetName(), PetIndexInStall) ;
			return PACKET_EXE_CONTINUE ;
		}

		if(pHuman->m_StallBox.GetPetSerialByIndex(PetIndexInStall) != ItemSerial)
		{
			MsgError.SetID(STALL_MSG::ERR_NEED_NEW_COPY);
			pGamePlayer->SendPacket(&MsgError);
			g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallItemPriceHandler::ObjName=%s, ERR_NEED_NEW_COPY: ItemSerial = %d, BoxSerial = %d"
				,pHuman->GetName(), ItemSerial, pHuman->m_StallBox.GetPetSerialByIndex(PetIndexInStall)) ;
			return PACKET_EXE_CONTINUE ;
		}

		pHuman->m_StallBox.SetPetPriceByIndex(PetIndexInStall, ItemPrice);
		pHuman->m_StallBox.IncPetSerialByIndex(PetIndexInStall);

		//给Client返回一条消息,告诉Client版本号
//.........这里部分代码省略.........
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:101,代码来源:CGStallItemPriceHandler.cpp

示例12: Assert

uint CGBankAddItemHandler::Execute( CGBankAddItem* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION

	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;
	Assert( pHuman ) ;

	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}

	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;

	UINT indexFrom = pPacket->GetIndexFrom();
	UINT indexTo   = pPacket->GetIndexTo();

	GCBankAddItem Msg;

	switch(pPacket->GetFromType())
	{
	case CGBankAddItem::EQUIP_POS:
		{
			pHuman->GetDB()->OverWriteEquip2Bank((HUMAN_EQUIP)indexFrom, indexTo);
			Msg.SetFromType(GCBankAddItem::EQUIP_POS);
			Msg.SetIndexFrom(indexFrom);
			Msg.SetIndexTo(indexTo);
		}
		break;
	case CGBankAddItem::BAG_POS:		//Bag->Bank
		{
			ItemContainer *pBankContainer  = pHuman->GetBankContain();
			ItemContainer *pBagContainer = HumanItemLogic::GetContainer(pHuman,indexFrom);

			Item *pBagItem  = pBagContainer->GetItem( pBagContainer->BagIndex2ConIndex(indexFrom) );
			//防止连续点击
			if(pBagItem->IsEmpty())
			{
				g_pLog->FastSaveLog( LOG_FILE_1, "CGBankAddItemHandler too many click") ;
				return PACKET_EXE_CONTINUE;
			}
			//Item *pBankItem = pBankContainer->GetItem( indexTo );

			//合并标志
			INT	 bSplice = 0;
			INT  nSpliceTo = -1;
			UINT TempIndexTo = indexTo;

			//自动搜索空格租赁箱1
			switch(TempIndexTo)
			{
			case CGBankAddItem::AUTO_POS_BOX1:
				{
					//先查询是不是有可以合并的物品,(只在本租赁箱中)
					if( pBagItem->IsCanLay() )
					{
						for( INT i=RENTBOX1_START_INDEX; i<RENTBOX2_START_INDEX; i++ )
						{
							Item *pBankItem = pBankContainer->GetItem(i);
							
							// 验证是否可以叠加成功
							if( pBankItem->GetItemTableIndex() == pBagItem->GetItemTableIndex() && 
								pBankItem->GetLayedNum() + pBagItem->GetLayedNum() <= pBankItem->GetMaxLayedNum() )
							{
								bSplice = 1;
								nSpliceTo = i;
								indexTo = i;
								break;
							}
						}
					}
					//没有可以叠加的物品,就寻找一个空格
					BYTE	indextemp = RENTBOX1_START_INDEX;
					if(0 == bSplice)
					{
						while( ITEMREFPTRISVALID(HumanItemLogic::GetBankItem(pHuman, indextemp))  
							&&  indextemp < RENTBOX2_START_INDEX
							)
						{
							indextemp++;
						}

						if(indextemp == RENTBOX2_START_INDEX)
						{
							indexTo = indextemp-1;
						}
						else
						{
							indexTo = indextemp;
						}
					}
				}
				break;

//.........这里部分代码省略.........
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:101,代码来源:CGBankAddItemHandler.cpp

示例13: Assert

uint CGAskMyBagListHandler::Execute(CGAskMyBagList* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION

	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;
	Assert( pHuman ) ;

	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}

	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;

	
	ASK_BAG_MODE	mode		=	pPacket->GetAskMode();

	GCMyBagList Msg;

	switch(mode) 
	{
	case ASK_ALL:
		{
			_BAG_ITEM		ItemIterator;
			_ITEM_GUID		NullGuid;
			uint			AllAskCount = 0;
			uint            nItemCount  = 0;
			memset(&NullGuid,0,sizeof(_ITEM_GUID));
			

			Msg.SetAskMode(ASK_ALL);

			//读取扩展容器
			ItemContainer* pExtraContainer = pHuman->GetExtraContain();
			Assert(pExtraContainer);
			for( INT i=0; i<pExtraContainer->GetContainerSize(); i++ )
			{
				//临时代码
				Item*	pItem =	HumanItemLogic::GetExtraContainerItem(pHuman,pExtraContainer->ConIndex2BagIndex(i));
				Assert(pItem);

				if(!(pItem->IsEmpty()))
				{
					ItemIterator.m_nndex			=	pExtraContainer->ConIndex2BagIndex(i);
					pItem->SaveValueTo(&ItemIterator.m_nItemData);
					Msg.SetAskItemData(&ItemIterator,nItemCount);
					++nItemCount;
				}

			}
			//读取基本背包
			ItemContainer* pBaseContainer = pHuman->GetBaseContain();
			Assert(pBaseContainer);
			for( INT i=0; i<pBaseContainer->GetContainerSize(); i++ )
			{
				//临时代码
				Item*	pItem =	pBaseContainer->GetItem(i);
				Assert(pItem);

				if(!(pItem->IsEmpty()))
				{
					ItemIterator.m_nndex			=	pBaseContainer->ConIndex2BagIndex(i);
					pItem->SaveValueTo(&ItemIterator.m_nItemData);
					Msg.SetAskItemData(&ItemIterator,nItemCount);
					++nItemCount;
				}
			}

			//读取扩展背包
			for (INT j=0; j<MAX_EXTRA_BAG_NUM; ++j)
			{
				ItemContainer* pBaseContainer = pHuman->GetExtraBagContain(j);
				Assert(pBaseContainer);
				if (pBaseContainer->IsValid())
				{
					for( INT i=0; i<pBaseContainer->GetContainerSize(); i++ )
					{
						//临时代码
						Item*	pItem =	pBaseContainer->GetItem(i);
						Assert(pItem);

						if(!(pItem->IsEmpty()))
						{
							ItemIterator.m_nndex			=	pBaseContainer->ConIndex2BagIndex(i);
							pItem->SaveValueTo(&ItemIterator.m_nItemData);
							Msg.SetAskItemData(&ItemIterator,nItemCount);
							++nItemCount;
						}
					}
				}
			}

			Msg.SetItemCount(nItemCount);

//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:wx2Server,代码行数:101,代码来源:CGAskMyBagListHandler.cpp

示例14: Assert

uint CGStallAddItemHandler::Execute( CGStallAddItem* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION

	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;
	Assert( pHuman ) ;

	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}

	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;

	//操作
	_ITEM_GUID	ItemGuid = pPacket->GetObjGUID();
	UINT		ItemPrice = pPacket->GetPrice();
	BYTE		FromType = pPacket->GetFromType();
	PET_GUID_t	PetGuid  = pPacket->GetPetGUID();

	if(pHuman->m_StallBox.GetStallStatus() != ServerStallBox::STALL_OPEN)
	{
		GCStallError	Msg;
		Msg.SetID(STALL_MSG::ERR_ILLEGAL);
		pGamePlayer->SendPacket(&Msg);
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallAddItemHandler::ObjID=%d ERR_ILLEGAL: != ServerStallBox::STALL_OPEN", pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}
	
	ItemContainer*		pStallContainer		= pHuman->m_StallBox.GetContainer();
	ItemContainer*		pStallPetContainer	= pHuman->m_StallBox.GetPetContainer();

	GCStallError		MsgError;
	GCStallAddItem		MsgAddItem;

	switch(FromType)
	{
	case STALL_MSG::POS_BAG :
		{
			//ItemContainer* pMatContainer	= pHuman->GetMatContain();
			ItemContainer* pBaseContainer	= pHuman->GetBaseContain();
			//ItemContainer* pBagContainer	=	NULL;

			//if(pMatContainer->GetIndexByGUID(&ItemGuid) >= 0)
			//{
			//	pBagContainer = pMatContainer;
			//}
			//else if(pBaseContainer->GetIndexByGUID(&ItemGuid) >=0 )
			//{
			//	pBagContainer = pBaseContainer;
			//}
			//else
			//{//guid非法
			//	Assert(0);
			//	GCStallError	Msg;
			//	Msg.SetID(STALL_MSG::ERR_ILLEGAL);
			//	pGamePlayer->SendPacket(&Msg);
			//	g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallAddItemHandler::ObjID=%d, ERR_ILLEGAL:World = %d, Server = %d, Serial = %d "
			//		,pHuman->GetID(), ItemGuid.m_World, ItemGuid.m_Server, ItemGuid.m_Serial) ;
			//	return PACKET_EXE_CONTINUE ;
			//}

			INT	IndexInBag = pBaseContainer->GetIndexByGUID(&ItemGuid);
			
			//先查一遍摊位盒中是不是已经有该物品了
			for(INT i = 0; i<STALL_BOX_SIZE; i++)
			{
				if(pStallContainer->GetItem(i)->GetGUID() == ItemGuid )
				{//物品已经在t摊位盒中,丢弃该消息
					g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallAddItemHandler::ObjID=%d, Already in box "
						,pHuman->GetID()) ;
					return PACKET_EXE_CONTINUE ;
				}
			}

			//拷贝到摊位盒
			//自动找格
			INT result = 
				g_ItemOperator.CopyItem
				(
				pBaseContainer,
				IndexInBag,
				pStallContainer
				);

			if(result>=0)
			{//拷贝成功,
				//发送消息给双方客户端
				Item* pIt = pStallContainer->GetItem(result);
				if(pIt->IsEmpty() == FALSE)
				{
					//先锁定此物品
					g_ItemOperator.LockItem( pBaseContainer, IndexInBag );

//.........这里部分代码省略.........
开发者ID:yuanxiubin1128,项目名称:mmo-resourse,代码行数:101,代码来源:CGStallAddItemHandler.cpp

示例15: Assert

uint CGEquipLevelupHandler::Execute(CGEquipLevelup* pPacket,Player* pPlayer)
{
	__ENTER_FUNCTION

	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer;
	Assert( pGamePlayer );

	Obj_Human* pHuman = pGamePlayer->GetHuman();
	Assert( pHuman );

	Scene* pScene = pHuman->getScene();
	if( pScene==NULL )
	{
		Assert(FALSE);
		return PACKET_EXE_ERROR;
	}

	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID );

	//交易状态不可操作
	if(pHuman->m_ExchangBox.m_Status > 0)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ExchangBox::m_Status>0" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}
	//摆摊状态不可操作
	if(pHuman->m_StallBox.GetStallStatus() == ServerStallBox::STALL_OPEN)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ServerStallBox::STALL_OPEN" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}

	Item*		pEquipItem		= NULL;
	UINT		EquipPoint		= INVALID_ITEM_POS;
	UINT		BagIndex		= INVALID_ITEM_POS;  
	EQUIPLEVEUP_RESULT nResult	= EQUIPLEVEUP_FAIL;
	GCEquipLevelupResult Msg;
	switch(pPacket->GetEquipPosType())
	{
	case ENUM_EQUIP_POINT:
		{
			EquipPoint = pPacket->GetPos();
			if(EquipPoint>HEQUIP_ADORN2)
			{
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler: EquipPoint error, EquipPoint=%d", EquipPoint) ;
				return PACKET_EXE_ERROR;
			}

			ItemContainer* pEquipContainer = pHuman->GetEquipContain();
			if(NULL==pEquipContainer)
			{
				AssertEx(FALSE,"[CGUseGem]: NULL EquipContainer pointer found!");
			}
			pEquipItem = pEquipContainer->GetItem((UINT)EquipPoint);
			Assert(pEquipItem);
			
			if(pEquipItem->IsEmpty())
			{
				nResult = EQUIPLEVEUP_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler pEquipItem is Null at  EquipPoint= %d", EquipPoint) ;
				return PACKET_EXE_CONTINUE;
			}
			
			Assert (pEquipItem->GetItemClass() == ICLASS_EQUIP);

			if(!(pPacket->getItemID() == pEquipItem->GetGUID()))
			{
				nResult = EQUIPLEVEUP_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler GUID is different ") ;
				return PACKET_EXE_CONTINUE;
			}


		}
		break;
	case ENUM_BAG:
		{
			BagIndex = pPacket->GetPos();
			ItemContainer* pItemContainer = HumanItemLogic::GetBagContainer(pHuman,BagIndex);
			if( pItemContainer == NULL )
			{
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler: BagIndex error, BagIndex=%d", BagIndex) ;
				return PACKET_EXE_ERROR;
			}
			if (!pItemContainer->IsCanUse())
			{
				nResult = EQUIPLEVEUP_BAG_INVALID;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler: ItemContainer is invalid, ContainerType=%d, BagIndex=%d", 
					pItemContainer->GetContainerType(), BagIndex) ;
					return PACKET_EXE_ERROR;
			}

			pEquipItem		=	pItemContainer->GetItem(pItemContainer->BagIndex2ConIndex(BagIndex));
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:wx2Server,代码行数:101,代码来源:CGEquipLevelupHandler.cpp


注:本文中的ItemContainer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。