- Mesaj
- 309
- Çözümler
- 7
- Beğeni
- 94
- Puan
- 724
- Ticaret Puanı
- 0
Arkadaşlar şu kodu eklemem gerekiyor
fakat tam emin olamadım bu fonksiyonda bulunan herşeyimi değiştirmem gerekiyor acaba. İlgili dosyanın bir kısmı aşağıda
aratınca en baştaki fonksiyon çıkıyor acaba buraya kadar komple değiştirmemmi gerekiyor?
C++:
//14. Search function : int CHARACTER::CountSpecifyItem
//14. Replace with :
int CHARACTER::CountSpecifyItem(DWORD vnum) const
{
int count = 0;
LPITEM item;
for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
{
item = GetInventoryItem(i);
if (NULL != item && item->GetVnum() == vnum)
{
// 개인 상점에 등록된 물건이면 넘어간다.
if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
{
continue;
}
else
{
count += item->GetCount();
}
}
}
#ifdef UK_ENABLE_SPECIAL_STORAGE
for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
{
item = GetUpgradeInventoryItem(i);
if (NULL != item && item->GetVnum() == vnum)
{
if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
continue;
else
count += item->GetCount();
}
}
for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
{
item = GetBookInventoryItem(i);
if (NULL != item && item->GetVnum() == vnum)
{
if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
continue;
else
count += item->GetCount();
}
}
for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
{
item = GetStoneInventoryItem(i);
if (NULL != item && item->GetVnum() == vnum)
{
if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
continue;
else
count += item->GetCount();
}
}
#endif
return count;
}
fakat tam emin olamadım bu fonksiyonda bulunan herşeyimi değiştirmem gerekiyor acaba. İlgili dosyanın bir kısmı aşağıda
C++:
int CHARACTER::CountSpecifyItem(DWORD vnum) const
{
int count = 0;
LPITEM item;
for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
{
item = GetInventoryItem(i);
if (NULL != item && item->GetVnum() == vnum)
{
// 개인 상점에 등록된 물건이면 넘어간다.
if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
{
continue;
}
else
{
count += item->GetCount();
}
}
}
return count;
}
void CHARACTER::RemoveSpecifyItem(DWORD vnum, DWORD count)
{
if (0 == count)
return;
for (UINT i = 0; i < INVENTORY_MAX_NUM; ++i)
{
if (NULL == GetInventoryItem(i))
continue;
if (GetInventoryItem(i)->GetVnum() != vnum)
continue;
//개인 상점에 등록된 물건이면 넘어간다. (개인 상점에서 판매될때 이 부분으로 들어올 경우 문제!)
if(m_pkMyShop)
{
bool isItemSelling = m_pkMyShop->IsSellingItem(GetInventoryItem(i)->GetID());
if (isItemSelling)
continue;
}
if (vnum >= 80003 && vnum <= 80007)
LogManager::instance().GoldBarLog(GetPlayerID(), GetInventoryItem(i)->GetID(), QUEST, "RemoveSpecifyItem");
if (count >= GetInventoryItem(i)->GetCount())
{
count -= GetInventoryItem(i)->GetCount();
GetInventoryItem(i)->SetCount(0);
if (0 == count)
return;
}
else
{
GetInventoryItem(i)->SetCount(GetInventoryItem(i)->GetCount() - count);
return;
}
}
// 예외처리가 약하다.
if (count)
sys_log(0, "CHARACTER::RemoveSpecifyItem cannot remove enough item vnum %u, still remain %d", vnum, count);
}
int CHARACTER::CountSpecifyTypeItem(BYTE type) const
{
int count = 0;
for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
{
LPITEM pItem = GetInventoryItem(i);
if (pItem != NULL && pItem->GetType() == type)
{
count += pItem->GetCount();
}
}
return count;
}
void CHARACTER::RemoveSpecifyTypeItem(BYTE type, DWORD count)
{
if (0 == count)
return;
for (UINT i = 0; i < INVENTORY_MAX_NUM; ++i)
{
if (NULL == GetInventoryItem(i))
continue;
if (GetInventoryItem(i)->GetType() != type)
continue;
//개인 상점에 등록된 물건이면 넘어간다. (개인 상점에서 판매될때 이 부분으로 들어올 경우 문제!)
if(m_pkMyShop)
{
bool isItemSelling = m_pkMyShop->IsSellingItem(GetInventoryItem(i)->GetID());
if (isItemSelling)
continue;
}
if (count >= GetInventoryItem(i)->GetCount())
{
count -= GetInventoryItem(i)->GetCount();
GetInventoryItem(i)->SetCount(0);
if (0 == count)
return;
}
else
{
GetInventoryItem(i)->SetCount(GetInventoryItem(i)->GetCount() - count);
return;
}
}
}
void CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip)
{
if (NULL == item)
{
sys_err ("NULL point.");
return;
}
if (item->GetOwner())
{
sys_err ("item %d 's owner exists!",item->GetID());
return;
}
int cell;
if (item->IsDragonSoul())
{
cell = GetEmptyDragonSoulInventory(item);
}
else
{
cell = GetEmptyInventory (item->GetSize());
}
if (cell != -1)
{
if (item->IsDragonSoul())
item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, cell));
else
item->AddToCharacter(this, TItemPos(INVENTORY, cell));
LogManager::instance().ItemLog(this, item, "SYSTEM", item->GetName());
if (item->GetType() == ITEM_USE && item->GetSubType() == USE_POTION)
{
TQuickslot * pSlot;
if (GetQuickslot(0, &pSlot) && pSlot->type == QUICKSLOT_TYPE_NONE)
{
TQuickslot slot;
slot.type = QUICKSLOT_TYPE_ITEM;
slot.pos = cell;
SetQuickslot(0, slot);
}
}
}
else
{
item->AddToGround (GetMapIndex(), GetXYZ());
item->StartDestroyEvent();
if (longOwnerShip)
item->SetOwnership (this, 300);
else
item->SetOwnership (this, 60);
LogManager::instance().ItemLog(this, item, "SYSTEM_DROP", item->GetName());
}
}
LPITEM CHARACTER::AutoGiveItem(DWORD dwItemVnum, BYTE bCount, int iRarePct, bool bMsg)
{
TItemTable * p = ITEM_MANAGER::instance().GetTable(dwItemVnum);
if (!p)
return NULL;
DBManager::instance().SendMoneyLog(MONEY_LOG_DROP, dwItemVnum, bCount);
if (p->dwFlags & ITEM_FLAG_STACKABLE && p->bType != ITEM_BLEND)
{
for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
{
LPITEM item = GetInventoryItem(i);
if (!item)
continue;
if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
{
if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
{
if (bCount < p->alValues[1])
bCount = p->alValues[1];
}
BYTE bCount2 = MIN(200 - item->GetCount(), bCount);
bCount -= bCount2;
item->SetCount(item->GetCount() + bCount2);
if (bCount == 0)
{
if (bMsg)
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
return item;
}
}
}
}
LPITEM item = ITEM_MANAGER::instance().CreateItem(dwItemVnum, bCount, 0, true);
if (!item)
{
sys_err("cannot create item by vnum %u (name: %s)", dwItemVnum, GetName());
return NULL;
}
if (item->GetType() == ITEM_BLEND)
{
for (int i=0; i < INVENTORY_MAX_NUM; i++)
{
LPITEM inv_item = GetInventoryItem(i);
if (inv_item == NULL) continue;
if (inv_item->GetType() == ITEM_BLEND)
{
if (inv_item->GetVnum() == item->GetVnum())
{
if (inv_item->GetSocket(0) == item->GetSocket(0) &&
inv_item->GetSocket(1) == item->GetSocket(1) &&
inv_item->GetSocket(2) == item->GetSocket(2) &&
inv_item->GetCount() < ITEM_MAX_COUNT)
{
inv_item->SetCount(inv_item->GetCount() + item->GetCount());
return inv_item;
}
}
}
}
}
aratınca en baştaki fonksiyon çıkıyor acaba buraya kadar komple değiştirmemmi gerekiyor?
C++:
int CHARACTER::CountSpecifyItem(DWORD vnum) const
{
int count = 0;
LPITEM item;
for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
{
item = GetInventoryItem(i);
if (NULL != item && item->GetVnum() == vnum)
{
// 개인 상점에 등록된 물건이면 넘어간다.
if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
{
continue;
}
else
{
count += item->GetCount();
}
}
}
return count;
}
void CHARACTER::RemoveSpecifyItem(DWORD vnum, DWORD count)
{
if (0 == count)
return;
for (UINT i = 0; i < INVENTORY_MAX_NUM; ++i)
{
if (NULL == GetInventoryItem(i))
continue;
if (GetInventoryItem(i)->GetVnum() != vnum)
continue;
//개인 상점에 등록된 물건이면 넘어간다. (개인 상점에서 판매될때 이 부분으로 들어올 경우 문제!)
if(m_pkMyShop)
{
bool isItemSelling = m_pkMyShop->IsSellingItem(GetInventoryItem(i)->GetID());
if (isItemSelling)
continue;
}
if (vnum >= 80003 && vnum <= 80007)
LogManager::instance().GoldBarLog(GetPlayerID(), GetInventoryItem(i)->GetID(), QUEST, "RemoveSpecifyItem");
if (count >= GetInventoryItem(i)->GetCount())
{
count -= GetInventoryItem(i)->GetCount();
GetInventoryItem(i)->SetCount(0);
if (0 == count)
return;
}
else
{
GetInventoryItem(i)->SetCount(GetInventoryItem(i)->GetCount() - count);
return;
}
}
// 예외처리가 약하다.
if (count)
sys_log(0, "CHARACTER::RemoveSpecifyItem cannot remove enough item vnum %u, still remain %d", vnum, count);
}