本文整理汇总了C++中Inventory::getWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::getWidth方法的具体用法?C++ Inventory::getWidth怎么用?C++ Inventory::getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::getWidth方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
void ActionRedeemMotorcycle::execute (Creature * pCreature1 , Creature* pCreature2)
throw(Error)
{
__BEGIN_TRY
Assert(pCreature1 != NULL);
Assert(pCreature2 != NULL);
Assert(pCreature1->isNPC());
Assert(pCreature2->isPC());
Player* pPlayer = pCreature2->getPlayer();
Assert(pPlayer != NULL);
// 일단 클라이언트를 위해 ok패킷을 하나 날려주고...
GCNPCResponse answerOKpkt;
pPlayer->sendPacket(&answerOKpkt);
// 플레이어가 슬레이어인지 검사한다.
if (pCreature2->isSlayer())
{
Slayer* pSlayer = dynamic_cast<Slayer*>(pCreature2);
Zone* pZone = pSlayer->getZone();
Inventory* pInventory = pSlayer->getInventory();
uint InvenWidth = pInventory->getWidth();
uint InvenHeight = pInventory->getHeight();
Item* pItem = NULL;
Inventory* pBeltInventory = NULL;
uint BeltInvenWidth = 0;
uint BeltInvenHeight = 0;
Item* pBelt = NULL;
pBelt = pSlayer->getWearItem(Slayer::WEAR_BELT);
if(pBelt != NULL)
{
pBeltInventory = ((Belt*)pBelt)->getInventory();
BeltInvenWidth = pBeltInventory->getWidth();
BeltInvenHeight = pBeltInventory->getHeight();
}
// 인벤토리를 검색한다.
for (uint y=0; y<InvenHeight; y++)
{
for (uint x=0; x<InvenWidth; x++)
{
// x, y에 아이템이 있다면...
if (pInventory->hasItem(x, y))
{
pItem = pInventory->getItem(x, y);
if (load(pItem, pSlayer, pZone, pSlayer->getX(), pSlayer->getY()))
{
return;
}
}
}
}
if(pBelt != NULL)
{
// 벨트를 검색한다
for (uint y = 0; y < BeltInvenHeight; y++)
{
for(uint x = 0; x < BeltInvenWidth; x++)
{
if(pBeltInventory->hasItem(x, y))
{
pItem= pBeltInventory->getItem(x, y);
if (load(pItem, pSlayer, pZone, pSlayer->getX(), pSlayer->getY()))
{
return;
}
}
}
}
}
}
else // 뱀파이어라면...오토바이를 찾아줄 이유가 있을까?
{
}
__END_CATCH
}
示例2: executeOpAllSkull
//////////////////////////////////////////////////////////////////////////////
//
// 해골 한꺼번에 팔기를 실행한다.
//
//////////////////////////////////////////////////////////////////////////////
void CGShopRequestSellHandler::executeOpAllSkull (CGShopRequestSell* pPacket , Player* pPlayer)
throw(ProtocolException , Error)
{
__BEGIN_TRY __BEGIN_DEBUG_EX
#ifdef __GAME_SERVER__
ObjectID_t NPCID = pPacket->getObjectID();
GamePlayer* pGamePlayer = dynamic_cast<GamePlayer*>(pPlayer);
Creature* pCreature = pGamePlayer->getCreature();
PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pCreature);
Zone* pZone = pPC->getZone();
if (pZone == NULL) return sendFailPacket(pPacket, pPlayer);
Creature* pNPCBase = NULL;
/*
try
{
pNPCBase = pZone->getCreature(NPCID);
}
catch (NoSuchElementException & nsee)
{
pNPCBase = NULL;
}
*/
// NoSuch제거. by sigi. 2002.5.2
pNPCBase = pZone->getCreature(NPCID);
if (pNPCBase == NULL || !pNPCBase->isNPC()) return sendFailPacket(pPacket, pPlayer);
NPC* pNPC = dynamic_cast<NPC*>(pNPCBase);
Inventory* pInventory = pPC->getInventory();
// by sigi. 2002.9.4
//Gold_t playerMoney = pPC->getGold();
Price_t itemPrice = 0;
Item* pItem = NULL;
for (uint y=0; y<pInventory->getHeight(); y++)
{
for (uint x=0; x<pInventory->getWidth(); x++)
{
pItem = pInventory->getItem(x, y);
// 아이템이 존재하고, 해골이라면...
if (pItem != NULL && pItem->getItemClass() == Item::ITEM_CLASS_SKULL)
{
// 아이템 가격을 계산해서 플레이어의 돈에다 더한다.
//itemPrice = g_pPriceManager->getPrice(pItem, pNPC->getMarketCondBuy(), SHOP_RACK_NORMAL, pPC) * pItem->getNum();
//playerMoney += itemPrice;
// by sigi. 2002.9.4
itemPrice += g_pPriceManager->getPrice(pItem, pNPC->getMarketCondBuy(), SHOP_RACK_NORMAL, pPC) * pItem->getNum();
// 인벤토리 및 DB에서 아이템을 삭제한다.
pInventory->deleteItem(x, y);
pItem->destroy();
SAFE_DELETE(pItem);
}
}
}
itemPrice = itemPrice * (g_pVariableManager->getHeadPriceBonus() / 100);
// 플레이어에게 물건값을 지불한다.
//pPC->setGoldEx(playerMoney);
// by sigi. 2002.9.4
pPC->increaseGoldEx(itemPrice);
// 물건을 산 플레이어에게 GCShopSellOK를...보낸다.
GCShopSellOK okpkt;
okpkt.setObjectID(NPCID);
okpkt.setShopVersion(pNPC->getShopVersion(SHOP_RACK_NORMAL));
okpkt.setItemObjectID(0);
okpkt.setPrice(pPC->getGold());
pPlayer->sendPacket(&okpkt);
#endif
__END_DEBUG_EX __END_CATCH
}
示例3: execute
void CGDisplayItemHandler::execute (CGDisplayItem* pPacket , Player* pPlayer)
throw(Error)
{
__BEGIN_TRY __BEGIN_DEBUG_EX
#ifdef __GAME_SERVER__
//#ifndef __TEST_SERVER__
// return;
//#endif
Assert(pPacket != NULL);
Assert(pPlayer != NULL);
GamePlayer* pGamePlayer = dynamic_cast<GamePlayer*>(pPlayer);
Assert(pGamePlayer != NULL);
PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pGamePlayer->getCreature());
Assert(pPC != NULL);
Inventory* pInventory = pPC->getInventory();
Assert(pInventory != NULL);
Store* pStore = pPC->getStore();
Assert(pStore != NULL);
GCSystemMessage errorMsg;
GCNoticeEvent errorNotice;
if (pPacket->getIndex() > MAX_ITEM_NUM )
{
filelog("Store.log", "[%s:%s] (%u) 잘못된 인덱스입니다.",
pGamePlayer->getID().c_str(), pPC->getName().c_str(), pPacket->getIndex());
return;
}
if (pPacket->getX() >= pInventory->getWidth() || pPacket->getY() >= pInventory->getHeight() )
{
filelog("Store.log", "[%s:%s] (%u,%u) 인벤토리 좌표를 잘못 보내줬습니다..",
pGamePlayer->getID().c_str(), pPC->getName().c_str(), pPacket->getX(), pPacket->getY());
return;
}
Item* pItem = pInventory->getItem(pPacket->getX(), pPacket->getY());
if (pItem == NULL || pItem->getObjectID() != pPacket->getItemObjectID() )
{
filelog("Store.log", "[%s:%s] (%u, %u) : %u 아이템 좌표가 잘못되었거나 오브젝트 아이디가 잘못되었습니다.",
pGamePlayer->getID().c_str(), pPC->getName().c_str(), pPacket->getX(), pPacket->getY(), pPacket->getItemObjectID());
return;
}
if (pPC->getZone()->getTradeManager()->getTradeInfo(pPC->getName() ) != NULL )
{
filelog("Store.log", "[%s:%s] : 거래중에는 물건을 올려놓을 수 없습니다.",
pGamePlayer->getID().c_str(), pPC->getName().c_str());
return;
}
if (pStore->hasItem(pItem ) )
{
filelog("Store.log", "[%s:%s] (%u, %u) 이미 아이템이 상점에 있습니다.",
pGamePlayer->getID().c_str(), pPC->getName().c_str(), pItem->getObjectID(), pPacket->getIndex());
// errorMsg.setMessage("이미 진열된 아이템입니다.");
errorNotice.setCode(NOTICE_EVENT_ALREADY_DISPLAYED);
pGamePlayer->sendPacket(&errorNotice);
return;
}
if (pItem->isTimeLimitItem() || !canSell(pItem ) || !canTrade(pItem ) || !canTradeInventoryItem(pItem ) )
{
filelog("Store.log", "[%s:%s] (%s) 팔 수 없는 아이템입니다.",
pGamePlayer->getID().c_str(), pPC->getName().c_str(), pItem->toString().c_str());
// errorMsg.setMessage("판매할 수 없는 아이템입니다.");
errorNotice.setCode(NOTICE_EVENT_CANNOT_SELL);
pGamePlayer->sendPacket(&errorNotice);
return;
}
BYTE result = pStore->setStoreItem(pPacket->getIndex(), pItem, pPacket->getPrice());
if ( result != 0 )
{
filelog("Store.log", "[%s:%s] (%u) 아이템을 놓을 수 없습니다.",
pGamePlayer->getID().c_str(), pPC->getName().c_str(), result);
return;
}
GCMyStoreInfo gcInfo;
gcInfo.setStoreInfo(&(pStore->getStoreInfo()));
pGamePlayer->sendPacket(&gcInfo);
if (pStore->isOpen() )
{
GCAddStoreItem gcAdd;
gcAdd.setOwnerObjectID(pPC->getObjectID());
gcAdd.setIndex(pPacket->getIndex());
pStore->getStoreItem(pPacket->getIndex() ).makeStoreItemInfo(gcAdd.getItem());
pPC->getZone()->broadcastPacket(pPC->getX(), pPC->getY(), &gcAdd, pPC);
}
#endif // __GAME_SERVER__
//.........这里部分代码省略.........
示例4: executeNormal
//////////////////////////////////////////////////////////////////////////////
//
// 일반 아이템을 처리한다.
//
//////////////////////////////////////////////////////////////////////////////
void CGShopRequestSellHandler::executeNormal (CGShopRequestSell* pPacket , Player* pPlayer)
throw(ProtocolException , Error)
{
__BEGIN_TRY __BEGIN_DEBUG_EX
#ifdef __GAME_SERVER__
ObjectID_t NPCID = pPacket->getObjectID();
ObjectID_t ITEMOID = pPacket->getItemObjectID();
GamePlayer* pGamePlayer = dynamic_cast<GamePlayer*>(pPlayer);
Creature* pCreature = pGamePlayer->getCreature();
PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pCreature);
BYTE index = 0;
bool bSpecialItem = false;
Zone* pZone = pPC->getZone();
if (pZone == NULL) return sendFailPacket(pPacket, pPlayer);
Creature* pNPCBase = NULL;
/*
try
{
pNPCBase = pZone->getCreature(NPCID);
}
catch (NoSuchElementException & nsee)
{
pNPCBase = NULL;
}
*/
// NoSuch제거. by sigi. 2002.5.2
pNPCBase = pZone->getCreature(NPCID);
if (pNPCBase == NULL || !pNPCBase->isNPC()) return sendFailPacket(pPacket, pPlayer);
NPC* pNPC = dynamic_cast<NPC*>(pNPCBase);
// 플레이어가 팔려고 하는 아이템을 가지고 있는지 검사
Inventory* pInventory = pPC->getInventory();
//Gold_t playerMoney = pPC->getGold();
Item* pItem = pInventory->getItemWithObjectID(ITEMOID);
ItemNum_t itemNumber = pItem->getNum();
Price_t itemPrice = g_pPriceManager->getPrice(pItem, pNPC->getMarketCondBuy(), SHOP_RACK_NORMAL, pPC) * itemNumber;
// 플레이어의 인벤토리에 아이템을 제거한다.
pInventory->deleteItem(ITEMOID);
pItem->whenPCLost(pPC);
if (!pItem->destroy()) {
filelog("shopDBBug.txt", "NoSuchItemInDB-destroy: %s", pItem->toString().c_str());
throw DisconnectException("아이템 지울려는데 DB에 없다.");
}
// 만약 벨트라면 안에 있는 포션을 삭제해준다.
// DB에서 지우는 것은 Belt::destroy()를 부르는 것만으로 포션까지 삭제된다.
if (pItem->getItemClass() == Item::ITEM_CLASS_BELT) {
Inventory* pBeltInventory = dynamic_cast<Belt*>(pItem)->getInventory();
for (int y=0; y<pBeltInventory->getHeight(); y++) {
for (int x=0; x<pBeltInventory->getWidth(); x++) {
Item* pBeltItem = pBeltInventory->getItem(x, y);
if (pBeltItem != NULL) {
pBeltInventory->deleteItem(x, y);
SAFE_DELETE(pBeltItem);
}
}
}
}
// Skull 일 경우 Variable Manager 에서 머리값 배수 값으로 가격을 새로 계산한다
if (pItem->getItemClass() == Item::ITEM_CLASS_SKULL)
itemPrice = itemPrice * (g_pVariableManager->getHeadPriceBonus() / 100);
// ItemTrace Log 를 남겨야 한다면 남긴다
if (pItem != NULL && pItem->isTraceItem() )
remainTraceLog(pItem, pCreature->getName() , pNPC->getName(), ITEM_LOG_DELETE, DETAIL_SHOPSELL);
// 플레이어에게 물건값을 지불한다.
// pPC->setGoldEx(playerMoney+itemPrice);
// by sigi. 2002.9.4
pPC->increaseGoldEx(itemPrice);
// 플레이어가 물건 팔 때 처리할 것들을 처리한다.
pPC->sellItem(pItem);
if (pItem->getItemClass() == Item::ITEM_CLASS_MOON_CARD && pItem->getItemType() == 4)
addOlympicStat(pPC, 4, (uint)(itemNumber));
bool bClearDefaultOptionTypes = false;
if (pItem->getItemClass() == Item::ITEM_CLASS_EVENT_ITEM && pItem->getItemType() >= 32 && pItem->getItemType() <= 36)
bClearDefaultOptionTypes = true;
// NPC에게 자리가 충분하다면 플레이어가 판 아이템을 보관한다.
// 운영자 명령어로 만든 아이템은 바로 없앤다.
// 단 스페셜 아이템만을 보관한다. 노말 아이템은 그냥 버림.
//.........这里部分代码省略.........
示例5: execute
void ActionSearchMotorcycle::execute (Creature * pCreature1 , Creature* pCreature2)
throw(Error)
{
__BEGIN_TRY
Assert(pCreature1 != NULL);
Assert(pCreature2 != NULL);
Assert(pCreature1->isNPC());
Assert(pCreature2->isPC());
Player* pPlayer = pCreature2->getPlayer();
Assert(pPlayer != NULL);
// 일단 클라이언트를 위해 ok패킷을 하나 날려주고...
GCNPCResponse answerOKpkt;
pPlayer->sendPacket(&answerOKpkt);
// 플레이어가 슬레이어인지 검사한다.
if (pCreature2->isSlayer())
{
Slayer* pSlayer = dynamic_cast<Slayer*>(pCreature2);
Inventory* pInventory = pSlayer->getInventory();
uint InvenWidth = pInventory->getWidth();
uint InvenHeight = pInventory->getHeight();
Item* pItem = NULL;
uint motorZoneID = 0;
uint motorX = 0;
uint motorY = 0;
Inventory* pBeltInventory = NULL;
uint BeltInvenWidth = 0;
uint BeltInvenHeight = 0;
Item* pBelt = NULL;
pBelt = pSlayer->getWearItem(Slayer::WEAR_BELT);
if(pBelt != NULL)
{
pBeltInventory = ((Belt*)pBelt)->getInventory();
BeltInvenWidth = pBeltInventory->getWidth();
BeltInvenHeight = pBeltInventory->getHeight();
}
// 인벤토리를 검색한다.
for (uint y=0; y<InvenHeight; y++)
{
for (uint x=0; x<InvenWidth; x++)
{
// x, y에 아이템이 있다면...
if (pInventory->hasItem(x, y))
{
pItem = pInventory->getItem(x, y);
if (search(pItem, motorZoneID, motorX, motorY))
{
GCSearchMotorcycleOK okpkt;
okpkt.setZoneID(motorZoneID);
okpkt.setX(motorX);
okpkt.setY(motorY);
pPlayer->sendPacket(&okpkt);
return;
}
}
}
}
if(pBelt != NULL)
{
// 인벤토리를 검색한다.
for (uint y=0; y<BeltInvenHeight; y++)
{
for (uint x=0; x<BeltInvenWidth; x++)
{
// x, y에 아이템이 있다면...
if (pBeltInventory->hasItem(x, y))
{
pItem = pBeltInventory->getItem(x, y);
if (search(pItem, motorZoneID, motorX, motorY))
{
GCSearchMotorcycleOK okpkt;
okpkt.setZoneID(motorZoneID);
okpkt.setX(motorX);
okpkt.setY(motorY);
pPlayer->sendPacket(&okpkt);
return;
}
}
}
}
}
}
else // 뱀파이어라면...오토바이를 찾아줄 이유가 있을까?
{
}
GCSearchMotorcycleFail failpkt;
pPlayer->sendPacket(&failpkt);
__END_CATCH
}
示例6: 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++) {
//.........这里部分代码省略.........
示例7: execute
void CGAddInventoryToMouseHandler::execute(CGAddInventoryToMouse* pPacket , Player* pPlayer)
throw(ProtocolException, Error)
{
__BEGIN_TRY __BEGIN_DEBUG_EX
#ifdef __GAME_SERVER__
GamePlayer* pGamePlayer = dynamic_cast<GamePlayer*>(pPlayer);
Assert(pGamePlayer != NULL);
Creature* pCreature = pGamePlayer->getCreature();
Assert(pCreature != NULL);
PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pCreature);
Assert(pPC != NULL);
Zone* pZone = pPC->getZone();
Assert(pZone != NULL);
if (pPC->getStore()->isOpen() )
{
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
CoordInven_t InvenX = pPacket->getX();
CoordInven_t InvenY = pPacket->getY();
ObjectID_t ItemOID = pPacket->getObjectID();
Inventory* pInventory = pPC->getInventory();
Assert(pInventory != NULL);
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 )
{
CoordInven_t X, Y;
pInventoryItem = dynamic_cast<SubInventory*>(pInventory->findItemOID(pPacket->getInventoryItemObjectID(), X, Y ));
if (pInventoryItem == NULL )
{
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
pInventory = pInventoryItem->getInventory();
invenID = pInventoryItem->getItemID();
}
*/
// 인벤토리 좌표를 넘어가면 곤란하다...
if (InvenX >= pInventory->getWidth() || InvenY >= pInventory->getHeight())
{
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
Item* pItem = pInventory->getItem(InvenX, InvenY);
Item* pExtraSlotItem = pPC->getExtraInventorySlotItem();
if (pPC->getStore()->hasItem(pItem ) )
{
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
// 더하고자 하는 아이템이 없거나, 이미 마우스에 뭔가가 붙어있다면
// 들 수 없다.
if (pItem == NULL || pExtraSlotItem != NULL)
{
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
// 일반적인 아이템 마우스 더하기 루틴
if (ItemOID != 0)
{
// OID가 일치하지 않으면 곤란하다...
if (pItem->getObjectID() != ItemOID)
{
GCCannotAdd _GCCannotAdd;
_GCCannotAdd.setObjectID(pPacket->getObjectID());
pPlayer->sendPacket(&_GCCannotAdd);
return;
}
pInventory->deleteItem(pItem->getObjectID());
pPC->addItemToExtraInventorySlot(pItem);
//pItem->save(pPC->getName(), STORAGE_EXTRASLOT, 0, 0, 0);
// item저장 최적화. by sigi. 2002.5.13
//.........这里部分代码省略.........
示例8: execute
void CGUseMessageItemFromInventoryHandler::execute(CGUseMessageItemFromInventory* 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);
Assert(pGamePlayer != NULL);
Creature* pCreature = pGamePlayer->getCreature();
Assert(pCreature != NULL);
Assert(pCreature->isPC());
PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pCreature);
Assert(pPC != NULL);
Inventory* pInventory = pPC->getInventory();
Zone* pZone = pPC->getZone();
Assert(pInventory != NULL);
Assert(pZone != NULL);
CoordInven_t InvenX = pPacket->getX();
CoordInven_t InvenY = pPacket->getY();
// 인벤토리 좌표를 넘어가는 영역이라면 안 된다.
if (InvenX >= pInventory->getWidth() || InvenY >= pInventory->getHeight())
{
GCCannotUse _GCCannotUse;
_GCCannotUse.setObjectID(pPacket->getObjectID());
pGamePlayer->sendPacket(&_GCCannotUse);
return;
}
// 인벤토리에 그 아이템이 없다면 에러다.
Item* pItem = pInventory->getItem(InvenX, InvenY);
if (pItem == NULL)
{
GCCannotUse _GCCannotUse;
_GCCannotUse.setObjectID(pPacket->getObjectID());
pGamePlayer->sendPacket(&_GCCannotUse);
return;
}
// 인벤토리에 있는 아이템의 Object를 받는다.
ObjectID_t ItemObjectID = pItem->getObjectID();
// OID가 일치하지 않거나, 사용할 수 없는 아이템이라면 에러다.
if (ItemObjectID != pPacket->getObjectID() || !isUsableItem(pItem, pCreature))
{
GCCannotUse _GCCannotUse;
_GCCannotUse.setObjectID(pPacket->getObjectID());
pGamePlayer->sendPacket(&_GCCannotUse);
return;
}
if (pPC->getStore()->getItemIndex(pItem) != 0xff )
{
GCCannotUse _GCCannotUse;
_GCCannotUse.setObjectID(pPacket->getObjectID());
pGamePlayer->sendPacket(&_GCCannotUse);
return;
}
// 아이템의 종류에 따라, 처리 함수를 분기시켜 준다.
switch (pItem->getItemClass())
{
case Item::ITEM_CLASS_EVENT_TREE:
executeEventTree(pPacket, pPlayer);
break;
default:
{
//Assert(false);
// by sigi. 2002.12.25
filelog("useItemError.txt", "[CGUseMessageItemFromInventory] No Such ItemClassHandler=%s, owner=%s", ItemClass2ShortString[pItem->getItemClass()].c_str(), pCreature->getName().c_str());
GCCannotUse _GCCannotUse;
_GCCannotUse.setObjectID(pPacket->getObjectID());
pGamePlayer->sendPacket(&_GCCannotUse);
}
return;
}
#endif
__END_DEBUG_EX __END_CATCH
}