本文整理汇总了C++中Inventory::getEmptySlot方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::getEmptySlot方法的具体用法?C++ Inventory::getEmptySlot怎么用?C++ Inventory::getEmptySlot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::getEmptySlot方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
////////////////////////////////////////////////////////////////////////////////
// 액션을 실행한다.
////////////////////////////////////////////////////////////////////////////////
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);
remainTraceLogNew(pItem, pCreature2->getName(), ITL_GET, ITLD_EVENTNPC , pCreature2->getZone()->getZoneID());
}
// 클라이언트에 선물이 추가되었음을 알린다.
GCCreateItem gcCreateItem;
makeGCCreateItem(&gcCreateItem, pItem, X, Y);
pPlayer->sendPacket(&gcCreateItem);
__END_CATCH
}
示例2: executeOpSwapAdvancementItem
//.........这里部分代码省略.........
case Item::ITEM_CLASS_OUSTERS_CHAKRAM:
case Item::ITEM_CLASS_OUSTERS_WRISTLET:
fType = FLAGSET_SWAP_WEAPON;
break;
case Item::ITEM_CLASS_COAT:
case Item::ITEM_CLASS_VAMPIRE_COAT:
case Item::ITEM_CLASS_OUSTERS_COAT:
fType = FLAGSET_SWAP_COAT;
break;
case Item::ITEM_CLASS_TROUSER:
case Item::ITEM_CLASS_OUSTERS_BOOTS:
fType = FLAGSET_SWAP_TROUSER;
break;
default:
break;
}
if (iClass == Item::ITEM_CLASS_MAX || fType == FLAGSET_MAX )
{
sendFailPacket(pPacket, pPlayer);
return;
}
FlagSet* pFlagSet = pPC->getFlagSet();
if (pFlagSet->isOn(fType) )
{
sendFailPacket(pPacket, pPlayer);
return;
}
Item* pNewItem = g_pItemFactoryManager->createItem(iClass, iType, pItem->getOptionTypeList());
if (pNewItem == NULL )
{
sendFailPacket(pPacket, pPlayer);
return;
}
pNewItem->setGrade(iGrade);
_TPOINT tp;
if (!pInventory->getEmptySlot(pNewItem, tp) )
{
SAFE_DELETE(pNewItem);
sendFailPacket(pPacket, pPlayer);
return;
}
filelog("ItemSwap.log", "[%s:%s] %s <-> %s",
pGamePlayer->getID().c_str(), pPC->getName().c_str(), pItem->toString().c_str(), pNewItem->toString().c_str());
pNewItem->setTraceItem(bTraceLog(pNewItem ));
pInventory->deleteItem(ITEMOID);
pItem->whenPCLost(pPC);
if (!pItem->destroy())
{
filelog("shopDBBug.txt", "NoSuchItemInDB-destroy: %s", pItem->toString().c_str());
throw DisconnectException("아이템 지울려는데 DB에 없다.");
}
pZone->registerObject(pNewItem);
GCShopSellOK okpkt;
okpkt.setObjectID(NPCID);
okpkt.setShopVersion(-1);
okpkt.setItemObjectID(ITEMOID);
okpkt.setPrice(0);
pGamePlayer->sendPacket(&okpkt);
// 삭제할 아이템의 ItemTrace Log 를 남겨야 한다면 남긴다
if (pItem != NULL && pItem->isTraceItem() )
{
remainTraceLog(pItem, pCreature->getName() , pNPC->getName(), ITEM_LOG_DELETE, DETAIL_SHOPSELL);
}
// 인벤토리에 추가
Assert(pInventory->addItem(pNewItem, tp ));
// DB 에 생성
pNewItem->create(pPC->getName(), STORAGE_INVENTORY, 0, tp.x, tp.y);
// 교환해줄 아이템의 ItemTrace Log 를 남겨야 한다면 남긴다
if (pNewItem->isTraceItem() )
{
remainTraceLog(pNewItem, pNPC->getName() , pCreature->getName(), ITEM_LOG_CREATE, DETAIL_SHOPBUY);
}
pFlagSet->turnOn(fType);
pFlagSet->save(pPC->getName());
GCCreateItem gcCI;
makeGCCreateItem(&gcCI, pNewItem, tp.x, tp.y);
pGamePlayer->sendPacket(&gcCI);
#endif
__END_CATCH
}
示例3: execute
void CGTameMonsterHandler::execute (CGTameMonster* pPacket , Player* pPlayer)
throw(Error)
{
__BEGIN_TRY
#ifdef __GAME_SERVER__
GamePlayer* pGamePlayer = dynamic_cast<GamePlayer*>(pPlayer);
Assert(pGamePlayer != NULL);
PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pGamePlayer->getCreature());
Assert(pPC != NULL);
Zone* pZone = pPC->getZone();
Assert(pZone != NULL);
Monster* pMonster = dynamic_cast<Monster*>(pZone->getCreature(pPacket->getObjectID() ));
if (pMonster == NULL ) return;
Item* pItem = pPC->getExtraInventorySlotItem();
if (pItem == NULL || pItem->getItemClass() != Item::ITEM_CLASS_PET_FOOD || pItem->getNum() != 1 ) return;
PetFoodInfo* pPetFoodInfo = dynamic_cast<PetFoodInfo*>(g_pPetFoodInfoManager->getItemInfo(pItem->getItemType() ));
Assert(pPetFoodInfo != NULL);
Inventory* pInventory = pPC->getInventory();
if (pInventory == NULL ) return;
ItemType_t petType = PET_COMMON;
PetItem* pPetItem = dynamic_cast<PetItem*>(g_pItemFactoryManager->createItem(Item::ITEM_CLASS_PET_ITEM, petType, list<OptionType_t>() ));
Assert(pPetItem != NULL);
_TPOINT pt;
if (!pInventory->getEmptySlot(pPetItem, pt ) )
{
GCCannotUse gcCannotUse;
pGamePlayer->sendPacket(&gcCannotUse);
SAFE_DELETE(pPetItem);
return;
}
pPC->deleteItemFromExtraInventorySlot();
GCDeleteInventoryItem gcDI;
gcDI.setObjectID(pItem->getObjectID());
pGamePlayer->sendPacket(&gcDI);
pItem->destroy();
SAFE_DELETE(pItem);
/*
* 여기서 뭔가 확인을 해야 한다.
*/
int ratio = rand()%100;
if (g_pVariableManager->getVariable(PET_DAY_EVENT) != 0 )
{
ratio = 100;
}
// 공용 펫만 꼬실 수 있다.
PetTypeInfo* pPetTypeInfo = PetTypeInfoManager::getInstance()->getPetTypeInfo(petType);
if (pPetTypeInfo == NULL || pPetTypeInfo->getOriginalMonsterType() != pMonster->getMonsterType() || ratio >= pPetFoodInfo->getTameRatio() )
{
//cout << "꼬시기 실패 : " << ratio << endl;
SAFE_DELETE(pPetItem);
pMonster->addEnemy(pPC);
return;
}
pZone->deleteCreature(pMonster, pMonster->getX(), pMonster->getY());
SAFE_DELETE(pMonster);
/*
* 여기서 해당 펫의 정보를 가져와야 된다.
*/
PetInfo* pPetInfo = new PetInfo;
pPetInfo->setPetType(petType);
pPetInfo->setPetLevel(0);
pPetInfo->setPetCreatureType(pPetTypeInfo->getPetCreatureType(0));
pPetInfo->setPetAttr(0xff);
pPetInfo->setPetExp(0);
pPetInfo->setPetAttrLevel(0);
pPetInfo->setFoodType(pPetFoodInfo->getItemType());
pPetInfo->setGamble(0);
pPetInfo->setCutHead(0);
pPetInfo->setPetHP(pPetFoodInfo->getPetHP());
pPetInfo->setFeedTime(VSDateTime::currentDateTime());
// 양방향 링크
pPetItem->setPetInfo(pPetInfo);
pPetInfo->setPetItem(pPetItem);
pZone->registerObject(pPetItem);
pInventory->addItem(pPetItem, pt);
Assert(pt.x != -1);
pPetItem->create(pPC->getName(), STORAGE_INVENTORY, 0, pt.x, pt.y);
//.........这里部分代码省略.........
示例4: execute
//.........这里部分代码省略.........
pVampire->setStash(NULL);
/*
// 가비지 교체
while (true)
{
Item* pGarbage = pVampire->popItemFromGarbage();
// 더 이상 없다면 브레이크...
if (pGarbage == NULL) break;
pNewSlayer->addItemToGarbage(pGarbage);
}
*/
// 플래그 셋 교체
pNewSlayer->deleteFlagSet();
pNewSlayer->setFlagSet(pVampire->getFlagSet());
pVampire->setFlagSet(NULL);
Item* pItem = NULL;
_TPOINT point;
// 입고 있는 아이템들을 인벤토리 또는 바닥으로 옮긴다.
for(int part = 0; part < (int)Vampire::VAMPIRE_WEAR_MAX; part++)
{
pItem = pVampire->getWearItem((Vampire::WearPart)part);
if (pItem != NULL)
{
// 먼저 기어에서 삭제하고...
pVampire->deleteWearItem((Vampire::WearPart)part);
// 인벤토리에 자리가 있으면 인벤토리에 더하고...
if (pInventory->getEmptySlot(pItem, point))
{
pInventory->addItem(point.x, point.y, pItem);
pItem->save(pNewSlayer->getName(), STORAGE_INVENTORY, 0, point.x, point.y);
}
// 자리가 없으면 바닥에 떨어뜨린다.
else
{
ZoneCoord_t ZoneX = pVampire->getX();
ZoneCoord_t ZoneY = pVampire->getY();
TPOINT pt;
pt = pZone->addItem(pItem, ZoneX , ZoneY);
if (pt.x != -1)
{
pItem->save("", STORAGE_ZONE, pZone->getZoneID(), pt.x, pt.y);
}
else
{
pItem->destroy();
SAFE_DELETE(pItem);
}
}
}
}
pItem = pVampire->getExtraInventorySlotItem();
if (pItem != NULL)
{
pVampire->deleteItemFromExtraInventorySlot();
示例5: execute
//.........这里部分代码省略.........
pLuaSelectItem = m_pLuaSlayerItem;
luaFileName = m_SlayerFilename;
}
else if (pPC->isVampire() )
{
// 루아에 뱀파이어의 레벨을 set한다.
Vampire* pVampire = dynamic_cast<Vampire*>(pPC);
Assert(pVampire != NULL);
int level = pVampire->getLevel();
m_pLuaVampireItem->setLevel(level);
pLuaSelectItem = m_pLuaVampireItem;
luaFileName = m_VampireFilename;
}
// 루아의 계산 결과를 받아 아이템을 생성한다.
pLuaSelectItem->prepare();
int result = pLuaSelectItem->executeFile(luaFileName);
LuaState::logError(result);
ItemClass = pLuaSelectItem->getItemClass();
ItemType = pLuaSelectItem->getItemType();
OptionType = pLuaSelectItem->getOptionType();
OptionType2 = pLuaSelectItem->getOptionType2();
pLuaSelectItem->clear();
if(ItemClass >= Item::ITEM_CLASS_MAX )
{
filelog("AccountEventItemError.txt", "[ ItemInfo Error ] : ItemClass = %d , ItemType = %d , OptionType = %d", ItemClass, ItemType, OptionType);
GCNPCResponse quit;
quit.setCode(NPC_RESPONSE_QUIT_DIALOGUE);
pPlayer->sendPacket(&quit);
return;
}
// 선물(Item)을 만든다.
list<OptionType_t> optionTypeList;
if (OptionType != 0 ) optionTypeList.push_back(OptionType);
if (OptionType2 != 0 ) optionTypeList.push_back(OptionType2);
pItem = g_pItemFactoryManager->createItem(ItemClass, ItemType, optionTypeList);
Assert(pItem != NULL);
// 인벤토리에 아이템을 넣을 빈 자리를 받아온다.
TPOINT p;
if (!pInventory->getEmptySlot(pItem, p))
{
SAFE_DELETE(pItem);
GCNPCResponse response;
response.setCode(NPC_RESPONSE_NO_EMPTY_SLOT);
pGamePlayer->sendPacket(&response);
GCNPCResponse quit;
quit.setCode(NPC_RESPONSE_QUIT_DIALOGUE);
pPlayer->sendPacket(&quit);
return;
}
// 선물을 인벤토리에 추가한다.
pZone->getObjectRegistry().registerObject(pItem);
pInventory->addItem(p.x, p.y, pItem);
pItem->create(pPC->getName(), STORAGE_INVENTORY, 0, p.x, p.y);
// ItemTraceLog 를 남긴다
if (pItem != NULL && pItem->isTraceItem() )
{
remainTraceLog(pItem, pCreature1->getName(), pCreature2->getName(), ITEM_LOG_CREATE, DETAIL_EVENTNPC);
remainTraceLogNew(pItem, pCreature2->getName(), ITL_GET, ITLD_EVENTNPC, pCreature1->getZone()->getZoneID(), pCreature1->getX(), pCreature1->getY());
}
// 클라이언트에 선물이 추가되었음을 알린다.
GCCreateItem gcCreateItem;
makeGCCreateItem(&gcCreateItem, pItem, p.x, p.y);
pPlayer->sendPacket(&gcCreateItem);
// 선물을 받았다고 Flag 를 켠다.
pGamePlayer->setSpecialEventCount(pGamePlayer->getSpecialEventCount() | m_SpecialEventFlag);
// Flag 를 저장한다.
pGamePlayer->saveSpecialEventCount();
// 보상을 받았다고 클라이언트에 보낸다.
GCNPCResponse response;
response.setCode(NPC_RESPONSE_GIVE_EVENT_ITEM_OK);
pPlayer->sendPacket(&response);
GCNPCResponse quit;
quit.setCode(NPC_RESPONSE_QUIT_DIALOGUE);
pPlayer->sendPacket(&quit);
__END_CATCH
}
示例6: execute
//.........这里部分代码省略.........
LuaState::logError(result);
pLuaSelectItem->clear();
}
Timeval afterTime;
getCurrentTime(afterTime);
cout << "luaExecute time before : " << beforeTime.tv_sec << "." << beforeTime.tv_usec << endl;
cout << "luaExecute time after : " << afterTime.tv_sec << "." << afterTime.tv_usec << endl;
*/
//--------------------------------------------------------
// 루아의 계산 결과를 받아 아이템을 생성한다.
pLuaSelectItem->prepare();
int result = pLuaSelectItem->executeFile(luaFileName);
LuaState::logError(result);
ItemClass = pLuaSelectItem->getItemClass();
ItemType = pLuaSelectItem->getItemType();
OptionType = pLuaSelectItem->getOptionType();
OptionType2 = pLuaSelectItem->getOptionType2();
pLuaSelectItem->clear();
if(ItemClass >= Item::ITEM_CLASS_MAX )
//|| ItemType >= ITEM_TYPE_MAX || ItemType < 0
// || OptionType == 0)
{
filelog("GiveEventItemError.txt", "[ ItemInfo Error ] : ItemClass = %d , ItemType = %d , OptionType = %d", ItemClass, ItemType, OptionType);
GCNPCResponse quit;
quit.setCode(NPC_RESPONSE_QUIT_DIALOGUE);
pPlayer->sendPacket(&quit);
return;
}
// 선물(Item)을 만든다.
list<OptionType_t> optionTypeList;
if (OptionType != 0 ) optionTypeList.push_back(OptionType);
if (OptionType2 != 0 ) optionTypeList.push_back(OptionType2);
pItem = g_pItemFactoryManager->createItem(ItemClass, ItemType, optionTypeList);
Assert(pItem != NULL);
_TPOINT pt;
if (!pInventory->getEmptySlot(pItem, pt))
{
SAFE_DELETE(pItem);
GCNPCResponse response;
response.setCode(NPC_RESPONSE_NO_EMPTY_SLOT);
pPlayer->sendPacket(&response);
GCNPCResponse quit;
quit.setCode(NPC_RESPONSE_QUIT_DIALOGUE);
pPlayer->sendPacket(&quit);
return;
}
CoordInven_t X = pt.x;
CoordInven_t Y = pt.y;
// 선물을 인벤토리에 추가한다.
pZone->getObjectRegistry().registerObject(pItem);
pInventory->addItem(X, Y, pItem);
pItem->create(pPC->getName(), STORAGE_INVENTORY, 0, X, Y);
// ItemTraceLog 를 남긴다
if (pItem != NULL && pItem->isTraceItem() )
{
remainTraceLog(pItem, pCreature1->getName(), pCreature2->getName(), ITEM_LOG_CREATE, DETAIL_EVENTNPC);
remainTraceLogNew(pItem, pCreature2->getName(), ITL_GET, ITLD_EVENTNPC, pCreature1->getZone()->getZoneID(), pCreature1->getX(), pCreature1->getY());
}
// 클라이언트에 선물이 추가되었음을 알린다.
GCCreateItem gcCreateItem;
makeGCCreateItem(&gcCreateItem, pItem, X, Y);
pPlayer->sendPacket(&gcCreateItem);
// Flag을 켠다.
pFlagSet->turnOn(m_FlagSetType);
// Flag을 저장한다.
pFlagSet->save(pPC->getName());
// 아이템 교환이 이루어 졌다고 클라이언트에 알린다.
GCNPCResponse response;
response.setCode(NPC_RESPONSE_GIVE_EVENT_ITEM_OK);
pPlayer->sendPacket(&response);
GCNPCResponse quit;
quit.setCode(NPC_RESPONSE_QUIT_DIALOGUE);
pPlayer->sendPacket(&quit);
__END_CATCH
}