DannyTheDog
New Member
I'm using a 7.7 distro in which I've made runes stackable. Works like a charm.
But, it removes the whole stack when you use a rune, when it should only remove one.
I've been searching through the sources for what I think is the function responsible for this.
Any ideas what I need to change?
But, it removes the whole stack when you use a rune, when it should only remove one.
I've been searching through the sources for what I think is the function responsible for this.
Any ideas what I need to change?
Code:
bool Game::removeItemOfType(Cylinder* cylinder, uint16_t itemId, int32_t count, int32_t subType /*= -1*/, bool onlyContainers /*= false*/)
{
if(cylinder == NULL || ((int32_t)cylinder->__getItemTypeCount(itemId, subType) < count) ){
return false;
}
if(count <= 0){
return true;
}
std::list<Container*> listContainer;
Container* tmpContainer = NULL;
Thing* thing = NULL;
Item* item = NULL;
for(int i = cylinder->__getFirstIndex(); i < cylinder->__getLastIndex() && count > 0;){
if((thing = cylinder->__getThing(i)) && (item = thing->getItem())){
if(!onlyContainers && item->getID() == itemId){
if(item->isStackable()){
if(item->getItemCount() > count){
internalRemoveItem(item, count);
count = 0;
}
else{
count -= item->getItemCount();
internalRemoveItem(item);
}
}
else if(subType == -1 || subType == item->getSubType()){
--count;
internalRemoveItem(item);
}
else //Item has subtype but not the required one.
++i;
}
else{
++i;
if((tmpContainer = item->getContainer())){
listContainer.push_back(tmpContainer);
}
}
}
else{
++i;
}
}
while(!listContainer.empty() && count > 0){
Container* container = listContainer.front();
listContainer.pop_front();
for(int i = 0; i < (int32_t)container->size() && count > 0;){
Item* item = container->getItem(i);
if(item->getID() == itemId){
if(item->isStackable()){
if(item->getItemCount() > count){
internalRemoveItem(item, count);
count = 0;
}
else{
count-= item->getItemCount();
internalRemoveItem(item);
}
}
else if(subType == -1 || subType == item->getSubType()){
--count;
internalRemoveItem(item);
}
else //Item has subtype but not the required one.
++i;
}
else{
++i;
if((tmpContainer = item->getContainer())){
listContainer.push_back(tmpContainer);
}
}
}
}
return (count == 0);
}