
Originally Posted by
Dumle
@imboredare you, Already checked the database, thanks anyway ^^
@GlaphanKing Yeah I know, I've checked that. But the stacking is not implented yet(or atleast not at rev 20 o.o). In the part of inventory.cpp where the stacking should be it's a function that makes a new slot. Or am I just a failed programmer? :3
Atm, my stacking function gets the amount of the item in the slot, deletes the slot makes a new slot with the amount:"amount_list.at(index) + item->getAmount()". But I don't understand why it dosen't work with other slots than "0"?
Should I post the full code? :)
Btw, how's the development going? ;3
Code:
/**
* Moving an item around in the inventory
**/
bool Inventory::moveItem(Player* player, unsigned char* packet, int len){
int oldSlot = getByte(packet+1);
int newSlot = getByte(packet+2);
if(oldSlot==newSlot)
return true;
PlayerInventory* inventory = player->inv;
Item* item = inventory->getItemBySlot(oldSlot);
Item* item2 = inventory->getItemBySlot(newSlot);
if(item==NULL)
return true;
// remove used old slot and add it in the unused slot
if(item2==NULL)
{
inventory->removeUsedSlot(oldSlot);
}
else
{
if(item2->getItemId()!=item->getItemId())
{
item2->setSlot(oldSlot);
InventoryPacket::updateSlot(player,item2,oldSlot);
}
else
{
if(item2->getAmount()==item2->getItemData()->maxItems)
{
item2->setSlot(oldSlot);
InventoryPacket::updateSlot(player,item2,oldSlot);
}
else
{
int qtychange = item2->getAmount()+item->getAmount();
if(qtychange > item2->getItemData()->maxItems)
{
int moveamt = item2->getItemData()->maxItems-item2->getAmount();
int newamt = moveamt-item->getAmount();
item->setAmount(newamt);
item2->setAmount(item2->getAmount()+moveamt);
InventoryPacket::updateSlot(player,item2,newSlot);
}
else
{
item2->setAmount(item2->getAmount()+item->getAmount());
item->setAmount(0);
inventory->removeUsedSlot(item->getSlot());
inventory->removeItem(item);
InventoryPacket::updateSlot(player,item2,newSlot);
InventoryPacket::updateSlot(player,item,oldSlot);
return true;
}
}
}
}
inventory->addUsedSlot(newSlot);
item->setSlot(newSlot);
InventoryPacket::updateSlot(player,item,oldSlot);
return true;
}
That was the stacking code I implemented
int qtychange = item2->getAmount()+item->getAmount();
starts around there