本文整理汇总了C++中Inventory::canAdding方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::canAdding方法的具体用法?C++ Inventory::canAdding怎么用?C++ Inventory::canAdding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::canAdding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
void CGAddMouseToInventoryHandler::execute(CGAddMouseToInventory* pPacket , Player* pPlayer)
throw(ProtocolException, Error)
{
__BEGIN_TRY __BEGIN_DEBUG_EX
#ifdef __GAME_SERVER__
Assert(pPacket != NULL);
Assert(pPlayer != NULL);
try {
GamePlayer* pGamePlayer = dynamic_cast<GamePlayer*>(pPlayer);
Assert(pGamePlayer != NULL);
Creature* pCreature = pGamePlayer->getCreature();
Assert(pCreature != NULL);
Assert(pCreature->isPC());
PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pCreature);
Assert(pPC != NULL);
Zone* pZone = pPC->getZone();
Assert(pZone != NULL);
Inventory* pInventory = pPC->getInventory();
Assert(pInventory != NULL);
Item* pItem = pPC->getExtraInventorySlot()->getItem();
bool Success = false;
if (pItem == NULL) {
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
int invenID = 0;
/* Commenting the SubInventory stuff, since it's not supported by the client we use
SubInventory* pInventoryItem = NULL;
int invenID = 0;
if (pPacket->getInventoryItemObjectID() != 0 )
{
// cout << "서브 인벤토리에 넣기 : " << pPacket->getInventoryItemObjectID() << endl;
CoordInven_t X, Y;
pInventoryItem = dynamic_cast<SubInventory*>(pInventory->findItemOID(pPacket->getInventoryItemObjectID(), X, Y ));
TradeManager* pTradeManager = pZone->getTradeManager();
Assert(pTradeManager != NULL);
if (pInventoryItem == NULL || pItem->getItemClass() == Item::ITEM_CLASS_SUB_INVENTORY || pTradeManager->hasTradeInfo(pPC->getName()) )
{
// cout << "근데 서브 인벤토리가 없다." <<endl;
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
pInventory = pInventoryItem->getInventory();
invenID = pInventoryItem->getItemID();
}
*/
//Item::ItemClass itemClass = pItem->getItemClass();
//ItemType_t itemType = pItem->getItemType();
ObjectID_t itemObjectID = pItem->getObjectID();
CoordInven_t InvenX = pPacket->getInvenX();
CoordInven_t InvenY = pPacket->getInvenY();
if (InvenX >= pInventory->getWidth() || InvenY >= pInventory->getHeight() || itemObjectID != pPacket->getObjectID() ||
!pInventory->canAdding(InvenX, InvenY, pItem)) {
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
TPOINT pt;
pt.x = 99;
pt.y = 99;
// 넣을려는 Inventory Slot의 Item을 받아온다.
Item* pPrevItem = pInventory->searchItem(InvenX, InvenY , pItem, pt);
// 그 장소에 아이템이 있다면
if (pPrevItem != NULL) {
bool bisSame = true;
// 아이템 클래스가 같을때 숫자를 올려 주고 마우스에 있는 것은 없앤다.
if (canStack(pItem, pPrevItem)) {
int MaxStack = ItemMaxStack[pItem->getItemClass()];
VolumeWidth_t ItemWidth = pItem->getVolumeWidth();
VolumeHeight_t ItemHeight = pItem->getVolumeHeight();
VolumeWidth_t InvenWidth = pInventory->getWidth();
VolumeWidth_t InvenHeight= pInventory->getHeight();
if ((InvenX + ItemWidth <= InvenWidth) && (InvenY + ItemHeight <= InvenHeight)) {
for (int x = InvenX; x < (InvenX + ItemWidth); x++) {
for (int y = InvenY; y < (InvenY + ItemHeight); y++) {
//.........这里部分代码省略.........
示例2: execute
void CGAddMouseToQuickSlotHandler::execute (CGAddMouseToQuickSlot* pPacket , Player* pPlayer)
throw(ProtocolException, Error)
{
__BEGIN_TRY __BEGIN_DEBUG_EX
#ifdef __GAME_SERVER__
Assert(pPacket != NULL);
Assert(pPlayer != NULL);
GamePlayer* pGamePlayer = dynamic_cast<GamePlayer*>(pPlayer);
Creature* pCreature = pGamePlayer->getCreature();
bool Success = false;
if (pCreature->isSlayer())
{
Slayer* pSlayer = dynamic_cast<Slayer*>(pCreature);
InventorySlot* pExtraSlot = pSlayer->getExtraInventorySlot();
Item* pItem = pExtraSlot->getItem();
if (pItem == NULL)
{
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
ObjectID_t ItemObjectID = pItem->getObjectID();
SlotID_t SlotID = pPacket->getSlotID();
Item::ItemClass IClass = pItem->getItemClass();
// 아이템의 ObjectID가 일치하는지 체크한다.
if (ItemObjectID != pPacket->getObjectID())
{
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
// 벨트를 입고 있지 않다면 벨트에다 아이템을 더할 수가 없다.
if (!pSlayer->isWear(Slayer::WEAR_BELT))
{
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
// 포션도 아니고, 탄창도 아니라면 더할 수가 없지.
if (IClass != Item::ITEM_CLASS_POTION && IClass != Item::ITEM_CLASS_MAGAZINE && IClass != Item::ITEM_CLASS_EVENT_ETC && IClass != Item::ITEM_CLASS_KEY)
{
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
if (IClass == Item::ITEM_CLASS_EVENT_ETC && pItem->getItemType() < 14 )
{
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
Item* pBelt = pSlayer->getWearItem(Slayer::WEAR_BELT);
Inventory* pBeltInventory = ((Belt*)pBelt)->getInventory();
if (pBeltInventory->canAdding(SlotID, 0, pItem))
{
// 현재 벨트에 있는 Item을 받아온다.
Item* pPrevItem = pBeltInventory->getItem(SlotID, 0);
// 지정한 자리에 아이템이 있다면...
if (pPrevItem != NULL)
{
// 아이템이 완전히 같은 아이템이라면...
if (isStackable(pItem) && isSameItem(pItem, pPrevItem))
{
int MaxStack = ItemMaxStack[pItem->getItemClass()];
if (pItem->getNum() + pPrevItem->getNum() > MaxStack)
{
ItemNum_t CurrentNum = pPrevItem->getNum();
ItemNum_t AddNum = pItem->getNum();
ItemNum_t NewNum = AddNum + CurrentNum - MaxStack;
pPrevItem->setNum(MaxStack);
pItem->setNum(NewNum);
pBeltInventory->increaseNum(MaxStack - CurrentNum);
pBeltInventory->increaseWeight(pItem->getWeight()* (MaxStack - CurrentNum));
//pPrevItem->save(pSlayer->getName(), STORAGE_BELT, pBelt->getItemID(), SlotID, 0);
// item저장 최적화. by sigi. 2002.5.13
char pField[80];
sprintf(pField, "Num=%d, Storage=%d, StorageID=%lu, X=%d", MaxStack, STORAGE_BELT, pBelt->getItemID(), SlotID);
pPrevItem->tinysave(pField);
//pItem->save(pSlayer->getName(), STORAGE_EXTRASLOT, 0, 0, 0);
// item저장 최적화. by sigi. 2002.5.13
//.........这里部分代码省略.........