本文整理汇总了C++中Inventory::addItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::addItem方法的具体用法?C++ Inventory::addItem怎么用?C++ Inventory::addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::addItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InventoryL_AddItem
static int InventoryL_AddItem(lua_State* luaVM)
{
bool success = false;
const int nargs = lua_gettop(luaVM);
Inventory* inv;
if(nargs > 1)
{
inv = luaW_to<Inventory>(luaVM, 1);
switch(nargs)
{
case 2:
{
success = inv->addItem(lua_tonumber(luaVM, 2));
break;
}
case 3:
{
success = inv->addItem(lua_tonumber(luaVM, 2), lua_tonumber(luaVM, 3));
break;
}
}
}
lua_pushboolean(luaVM, success);
return 1;
}
示例2: onTimeElapsed
void Game::onTimeElapsed() {
Inventory inventory;
inventory.addItem(InventoryItem(SWAP_BONUS_IDENTIFIER, swapRemaining));
inventory.addItem(InventoryItem(CHANGE_BONUS_IDENTIFIER, changeRemaining));
inventory.addItem(InventoryItem(REMOVE_BONUS_IDENTIFIER, removeRemaining));
gameSpice->updateInventory(inventory);
auto gameSpice = GameSpice::getInstance();
gameSpice->addFund(Fund(score), [&] (Fund f) {});
gameSpice->getHighScore(GAMESPICE_LEADERBOARD_ID, [&] (HighScore s) {
submitScore();
int oldScore = s.getScore();
bool isNewHighScore = score > oldScore;
auto scene = isNewHighScore ? NewHighScore::scene() : GameOver::scene();
GameManager::sharedGameManager()->runScene(scene);
});
}
示例3: punch
int punch(v3f dir,
const ToolCapabilities *toolcap,
ServerActiveObject *puncher,
float time_from_last_punch)
{
// Take item into inventory
ItemStack item = createItemStack();
Inventory *inv = puncher->getInventory();
if(inv != NULL)
{
std::string wieldlist = puncher->getWieldList();
ItemStack leftover = inv->addItem(wieldlist, item);
puncher->setInventoryModified();
if(leftover.empty())
{
m_removed = true;
}
else
{
m_itemstring = leftover.getItemString();
m_itemstring_changed = true;
}
}
return 0;
}
示例4: addAllItemsTo
void Inventory::addAllItemsTo(Inventory& target) const
{
std::map<std::string, unsigned int>::const_iterator iter = m_Items.begin();
while (iter!=m_Items.end())
{
target.addItem(iter->first, iter->second);
++iter;
}//while
}
示例5: askForBlock
void CoinNodeAbstractListener::askForBlock(const std::string& hash)
{
InventoryItem block(MSG_BLOCK, uchar_vector(hash));
Inventory inv;
inv.addItem(block);
GetDataMessage getData(inv);
CoinNodeMessage msg(this->getMagic(), &getData);
this->sendMessage(msg);
}
示例6: addItem
//add item
int Script::addItem(lua_State* L){
short tx = (short)luaL_checknumber(L, 1);
short ty = (short)luaL_checknumber(L, 2);
string name = string(luaL_checkstring(L, 3));
Item it = Templates::instance()->searchItem(name);
Creature* creat = dynamic_cast<Creature*>(wrld.getObject(Vector2D(tx,ty)));
Inventory* inv = creat->getInventory();
inv->addItem(it);
return 0;
}
示例7: 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
}
示例8: Inventory_add_item
/**
* Attempts to add an item to the inventory at the given location, returns true
* if the space required for the item was available.
*
* @param Item item The item to add to the inventory.
* @param integer x The x location to add the item at.
* @param integer y The y location to add the item at.
* @returns boolean True if the item was added to the inventory successfully.
*/
int Inventory_add_item(lua_State *lua)
{
Inventory *inv = castUData<Inventory>(lua, 1);
if (inv)
{
Item *item = castUData<Item>(lua, 2);
if (item)
{
int args = lua_gettop(lua);
if (args == 2)
{
lua_pushboolean(lua, inv->addItem(item));
return 1;
}
else if (args == 4 && lua_isnum(lua, 3) && lua_isnum(lua, 4))
{
lua_pushboolean(lua, inv->addItem(item, lua_tointeger(lua, 3), lua_tointeger(lua, 4)));
return 1;
}
}
return LuaState::expectedArgs(lua, "add_item", 2, "Item item", "Item item, integer x, integer y");
}
return LuaState::expectedContext(lua, "add_item", "Inventory");
}
示例9: run
void StoreTab::run(Inventory &stationData)
{
//run through the store tab
//uis tend to have a ton of bloated code
loadInventories(playerData.getConvertedInventory(), stationData.getConvertedInventory());
playerCash->setText((stringw(L"Your Credits :") + stringw(playerData.getCredits())).c_str());
int index = playerInventory->getSelected();
//this is needed to maintain syncing between the index and objectmanager enum
std::vector<ObjectManager::E_ITEM_LIST> syncedInventory = playerData.getConvertedInventoryNoSpaces();
if (index != -1) {
//has something selected so we load its information
selectedValue->setText((stringw(L"Value :") + stringw(ObjectManager::itemList[syncedInventory[index]]->getPrice())).c_str());
selectedWeight->setText((stringw(L"Weight :") + stringw(ObjectManager::itemList[syncedInventory[index]]->getWeight())).c_str());
selectedDescription->setText(ObjectManager::itemList[syncedInventory[index]]->getDesc());
if (sellButton->isPressed()) {
//sell selected item
playerData.addCredits(ObjectManager::itemList[syncedInventory[index]]->getPrice());
playerData.removeItem(syncedInventory[index]);
stationData.addItem(syncedInventory[index], 1);
playerInventory->clear();
stationInventory->clear();
}
} else {
//reset text if nothing is selected
selectedValue->setText(L"Value :");
selectedWeight->setText(L"Weight :");
selectedDescription->setText(L"");
}
index = stationInventory->getSelected();
syncedInventory = stationData.getConvertedInventoryNoSpaces();
if (index != -1) {
//has something selected so we load its information
selectedValue->setText((stringw(L"Value :") + stringw(ObjectManager::itemList[syncedInventory[index]]->getPrice())).c_str());
selectedWeight->setText((stringw(L"Weight :") + stringw(ObjectManager::itemList[syncedInventory[index]]->getWeight())).c_str());
selectedDescription->setText(ObjectManager::itemList[syncedInventory[index]]->getDesc());
if (buyButton->isPressed()) {
//sell selected item
playerData.addCredits(-ObjectManager::itemList[syncedInventory[index]]->getPrice());
playerData.addItem(syncedInventory[index], 1);
stationData.removeItem(syncedInventory[index]);
playerInventory->clear();
stationInventory->clear();
}
}
}
示例10: execute
//.........这里部分代码省略.........
//pItem->save(pSlayer->getName(), STORAGE_EXTRASLOT, 0, 0, 0);
// item저장 최적화. by sigi. 2002.5.13
sprintf(pField, "Num=%d, Storage=%d", NewNum, STORAGE_EXTRASLOT);
pItem->tinysave(pField);
Success = true;
}
else // 숫자가 9개를 넘지 않을 때.
{
pSlayer->deleteItemFromExtraInventorySlot();
pPrevItem->setNum(pPrevItem->getNum() + pItem->getNum());
pBeltInventory->increaseNum(pItem->getNum());
pBeltInventory->increaseWeight(pItem->getWeight()* pItem->getNum());
//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", pPrevItem->getNum(), STORAGE_BELT, pBelt->getItemID(), SlotID);
pPrevItem->tinysave(pField);
pItem->destroy();
SAFE_DELETE(pItem);
Success = true;
}
}
else // 클래스랑 타입이 같지 않을때
{
// 마우스에 달려있는 아이템과 벨트에 있는 아이템을 제거한다.
pSlayer->deleteItemFromExtraInventorySlot();
pBeltInventory->deleteItem(pPrevItem->getObjectID());
// 둘의 위치를 바꿔 준다.
pSlayer->addItemToExtraInventorySlot(pPrevItem);
pBeltInventory->addItem(SlotID , 0 , pItem);
// DB에다가 저장을 한다.
//pPrevItem->save(pSlayer->getName(), STORAGE_EXTRASLOT, 0, 0, 0);
// item저장 최적화. by sigi. 2002.5.13
char pField[80];
sprintf(pField, "Storage=%d", STORAGE_EXTRASLOT);
pPrevItem->tinysave(pField);
//pItem->save(pSlayer->getName(), STORAGE_BELT , pBelt->getItemID(), SlotID, 0);
// item저장 최적화. by sigi. 2002.5.13
sprintf(pField, "Storage=%d, StorageID=%lu, X=%d", STORAGE_BELT, pBelt->getItemID(), SlotID);
pItem->tinysave(pField);
Success = true;
}
}
else // 슬랏에 아무런 기존의 아이템이 없을때.
{
// Inventory에 특정 아이템을 넣는다.
pBeltInventory->addItem(SlotID, 0 , pItem);
// 넣기에 성공하면 마우스에 달려있는 아이템을 없앤다.
pSlayer->deleteItemFromExtraInventorySlot();
//pItem->save(pSlayer->getName(), STORAGE_BELT, pBelt->getItemID(), SlotID, 0);
// item저장 최적화. by sigi. 2002.5.13
char pField[80];
sprintf(pField, "Storage=%d, StorageID=%lu, X=%d", STORAGE_BELT, pBelt->getItemID(), SlotID);
pItem->tinysave(pField);
Success = true;
示例11: execute
//.........这里部分代码省略.........
{
// 루아의 계산 결과를 받아 아이템을 생성한다.
pLuaSelectItem->prepare();
int result = pLuaSelectItem->executeFile(luaFileName);
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();
pLuaSelectItem->clear();
if(ItemClass >= Item::ITEM_CLASS_MAX )
//|| ItemType >= ITEM_TYPE_MAX || ItemType < 0
// || OptionType == 0)
{
filelog("XMasEventError.txt", "[ ItemInfo Error ] : ItemClass = %d , ItemType = %d , OptionType = %d", ItemClass, ItemType, OptionType);
GCNPCResponse quit;
quit.setCode(NPC_RESPONSE_QUIT_DIALOGUE);
pPlayer->sendPacket(&quit);
return;
}
// 클라이언트에 선물상자를 지우도록 한다.
GCDeleteInventoryItem gcDeleteInventoryItem;
gcDeleteInventoryItem.setObjectID(pGiftBoxItem->getObjectID());
pPlayer->sendPacket(&gcDeleteInventoryItem);
// 선물상자를 지운다.
pInventory->deleteItem(X, Y);
// ItemTraceLog 를 남긴다
if (pGiftBoxItem != NULL && pGiftBoxItem->isTraceItem() )
{
remainTraceLog(pGiftBoxItem, pCreature2->getName(), pCreature1->getName(), ITEM_LOG_DELETE, DETAIL_EVENTNPC);
}
pGiftBoxItem->destroy();
SAFE_DELETE(pGiftBoxItem);
// 선물(Item)을 만든다.
list<OptionType_t> optionTypeList;
if (OptionType != 0 )
optionTypeList.push_back(OptionType);
pItem = g_pItemFactoryManager->createItem(ItemClass, ItemType, optionTypeList);
Assert(pItem != NULL);
// 선물을 인벤토리에 추가한다.
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);
}
// 클라이언트에 선물이 추가되었음을 알린다.
GCCreateItem gcCreateItem;
makeGCCreateItem(&gcCreateItem, pItem, X, Y);
pPlayer->sendPacket(&gcCreateItem);
// Flag을 켠다.
pFlagSet->turnOn(FLAGSET_TRADE_GIFT_BOX_2002_12);
// Flag을 저장한다.
pFlagSet->save(pPC->getName());
// 아이템 교환이 이루어 졌다고 클라이언트에 알린다.
GCNPCResponse response;
response.setCode(NPC_RESPONSE_TRADE_GIFT_BOX_OK);
pPlayer->sendPacket(&response);
GCNPCResponse quit;
quit.setCode(NPC_RESPONSE_QUIT_DIALOGUE);
pPlayer->sendPacket(&quit);
__END_CATCH
}
示例12: execute
//.........这里部分代码省略.........
it.ItemType = getUpgradeItemType(it.ItemClass, it.ItemType, 1);
}
*/
pItem1 = g_pItemFactoryManager->createItem(it.ItemClass, it.ItemType, it.OptionType);
Assert(pItem1 != NULL);
}
}
if (pItem1 == NULL)
{
StringStream msg;
msg << "ActionTradeLairItem: "
<< (int)it.ItemClass << ", "
<< (int)it.ItemType << ", "
<< (int)it.bCreateOption << ", "
<< getOptionTypeToString(it.OptionType);
filelog("tradeLairItemBUG.txt", "%s", msg.toString().c_str());
GCSystemMessage gcSystemMessage;
gcSystemMessage.setMessage(g_pStringPool->getString(STRID_ITEM_CREATE_ERROR ));
pPlayer->sendPacket(&gcSystemMessage);
GCNPCResponse response;
response.setCode(NPC_RESPONSE_QUIT_DIALOGUE);
pPlayer->sendPacket(&response);
return;
}
}
TPOINT pt;
pItem1->setGrade(min(7,ItemGradeManager::Instance().getRandomBeadGrade()));
pZone->registerObject(pItem1);
// 만약 inventory에 공간이 있다면, 넣는다.
if(pInventory->addItem(pItem1, pt))
{
pItem1->create(pPC->getName(), STORAGE_INVENTORY, 0, pt.x, pt.y);
GCCreateItem gcCreateItem;
/* gcCreateItem.setObjectID(pItem1->getObjectID());
gcCreateItem.setItemClass(pItem1->getItemClass());
gcCreateItem.setItemType(pItem1->getItemType());
gcCreateItem.setOptionType(pItem1->getOptionTypeList());
gcCreateItem.setDurability(pItem1->getDurability());
gcCreateItem.setItemNum(pItem1->getNum());
gcCreateItem.setInvenX(pt.x);
gcCreateItem.setInvenY(pt.y);
gcCreateItem.setGrade(pItem1->getGrade());*/
makeGCCreateItem(&gcCreateItem, pItem1, pt.x, pt.y);
pPlayer->sendPacket(&gcCreateItem);
// ItemTraceLog 를 남긴다
if (pItem1 != NULL && pItem1->isTraceItem() )
{
remainTraceLog(pItem1, pCreature1->getName(), pCreature2->getName(), ITEM_LOG_CREATE, DETAIL_EVENTNPC);
}
// 기존의 아이템을 없앤다
GCDeleteInventoryItem gcDeleteInventoryItem;
gcDeleteInventoryItem.setObjectID(pMasterItem->getObjectID());
pPlayer->sendPacket(&gcDeleteInventoryItem);
// 서버에서 없애준다.
pInventory->deleteItem(pMasterItem->getObjectID()); // 좌표로 바꿔주면 좋을건데..
// ItemTraceLog 를 남긴다
if (pMasterItem != NULL && pMasterItem->isTraceItem() )
{
remainTraceLog(pMasterItem, pCreature2->getName(), pCreature1->getName(), ITEM_LOG_DELETE, DETAIL_EVENTNPC);
}
pMasterItem->destroy();
SAFE_DELETE(pMasterItem);
// 사용자에게 성공 메시지 출력
// StringStream message;
// message << "성공적으로 교환되었습니다";
GCSystemMessage gcSystemMessage;
gcSystemMessage.setMessage(g_pStringPool->getString(STRID_TRADE_SUCCESS ));
pPlayer->sendPacket(&gcSystemMessage);
}
else
{
// StringStream buf;
// buf << "인벤토리에 공간이 부족합니다";
GCSystemMessage gcSystemMessage;
gcSystemMessage.setMessage(g_pStringPool->getString(STRID_NOT_ENOUGH_INVENTORY_SPACE ));
pPlayer->sendPacket(&gcSystemMessage);
}
GCNPCResponse response;
response.setCode(NPC_RESPONSE_QUIT_DIALOGUE);
pPlayer->sendPacket(&response);
__END_CATCH
}
示例13: 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
}
示例14: 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
}
示例15: execute
//.........这里部分代码省略.........
Tile& tile = pZone->getTile(x, y);
// 곧 pFromCreature 즉, 원래의 뱀파이어 객체는 지워질 것이므로,
// PCFinder에 들어가 있는 값은 쓰레기 값이 될 것이다.
// 그러므로 뱀파이어 포인터를 지워주고, 새로운 슬레이어 포인터를 더한다.
g_pPCFinder->deleteCreature(pFromCreature->getName());
g_pPCFinder->addCreature(pNewSlayer);
// 길드 현재 접속 멤버 리스트에서 삭제한다.
if (pVampire->getGuildID() != 0 )
g_pGuildManager->getGuild(pVampire->getGuildID() )->deleteCurrentMember(pVampire->getName());
// 인벤토리 교체.
Inventory* pInventory = pVampire->getInventory();
pNewSlayer->setInventory(pInventory);
pVampire->setInventory(NULL);
// 보관함 교체
pNewSlayer->deleteStash();
pNewSlayer->setStash(pVampire->getStash());
pNewSlayer->setStashNum(pVampire->getStashNum());
pNewSlayer->setStashStatus(false);
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();