• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Compiling Stackable items in container bug

Dankoo

Active Member
Joined
Sep 4, 2010
Messages
1,007
Reaction score
27
Ok, let's suppose this is my bag:

35k205s.jpg


Oh, just found 10 gps *-*

"You cannot put more objects in this container."

o54wf6.jpg


Resuming: When container is full (like a bag with 8 items, or a backpack with 20 items), and there's stackable items, I can't add stackable items anymore, even if it didn't reach 100 units.. Gotcha?

Searched and couldn't find the solution for this, and since I'm not into C++, hard to solve by my own, without help.. So I came here (again) ^_^
 
Yes, using autostack

[and it's working fine... The problem is when I try to add items when container is full. Can't add more items, if even there's less than 100 units of that stackable item - confusing lol]
 
[cpp]/
if(item->isStackable())
{
uint32_t n = 0;
if(index == INDEX_WHEREEVER)
{
//Iterate through every item and check how much free stackable slots there is.
uint32_t slotIndex = 0;
for(ItemList::const_iterator cit = itemlist.begin(); cit != itemlist.end(); ++cit, ++slotIndex)
{
if((*cit) != item && (*cit)->getID() == item->getID() && (*cit)->getItemCount() < 100)
{
uint32_t remainder = (100 - (*cit)->getItemCount());
if(__queryAdd(slotIndex, item, remainder, flags) == RET_NOERROR)
n += remainder;
}
}
}
else
{
const Thing* destThing = __getThing(index);
const Item* destItem = NULL;
if(destThing)
destItem = destThing->getItem();

if(destItem && destItem->getID() == item->getID() && destItem->getItemCount() < 100)
{
uint32_t remainder = 100 - destItem->getItemCount();
if(__queryAdd(index, item, remainder, flags) == RET_NOERROR)
n = remainder;
}
}

maxQueryCount = freeSlots * 100 + n;
if(maxQueryCount < count)
return RET_CONTAINERNOTENOUGHROOM;
}[/cpp]
debug
 
Now I can only put stackable items in containers '-'

Nothing happens when I drag an non-stackable item to a container

Plus, bug remains... Can't add more items when bag is full, even if there's less than 100 units

It should fill up to 100 units then say "You cannot add more items in this container"
 
it wasn't a fix, i said you were supposed to debug the code which looks like that (i don't know which rev are you using, i took it from some 4xxx)

use std::cout or something to find out which part of code is being executed, and then which function/logical operation fails. cant do it now because i'm busy as always
 
Ok, container.cpp from REV 3884:

[cpp] if(item->isStackable())
{
uint32_t n = 0;
if(index == INDEX_WHEREEVER)
{
//Iterate through every item and check how much free stackable slots there is.
uint32_t slotIndex = 0;
for(ItemList::const_iterator cit = itemlist.begin(); cit != itemlist.end(); ++cit, ++slotIndex)
{
if((*cit) != item && (*cit)->getID() == item->getID() && (*cit)->getItemCount() < 100)
{
uint32_t remainder = (100 - (*cit)->getItemCount());
if(__queryAdd(slotIndex, item, remainder, flags) == RET_NOERROR)
n += remainder;
}
}
}
else
{
const Thing* destThing = __getThing(index);
const Item* destItem = NULL;
if(destThing)
destItem = destThing->getItem();

if(destItem && destItem->getID() == item->getID() && destItem->getItemCount() < 100)
{
uint32_t remainder = 100 - destItem->getItemCount();
if(__queryAdd(index, item, remainder, flags) == RET_NOERROR)
n = remainder;
}
}

maxQueryCount = freeSlots * 100 + n;
if(maxQueryCount < count)
return RET_CONTAINERNOTENOUGHROOM;
}
else
{
maxQueryCount = freeSlots;
if(maxQueryCount == 0)
return RET_CONTAINERNOTENOUGHROOM;
}[/cpp]

container.cpp from last REV:

[cpp] if(item->isStackable())
{
uint32_t n = 0;
if(index == INDEX_WHEREEVER)
{
//Iterate through every item and check how much free stackable slots there is.
uint32_t slotIndex = 0;
for(ItemList::const_iterator cit = itemlist.begin(); cit != itemlist.end(); ++cit, ++slotIndex)
{
if((*cit) != item && (*cit)->getID() == item->getID() && (*cit)->getItemCount() < 100)
{
uint32_t remainder = (100 - (*cit)->getItemCount());
if(__queryAdd(slotIndex, item, remainder, flags) == RET_NOERROR)
n += remainder;
}
}
}
else
{
const Thing* destThing = __getThing(index);
const Item* destItem = NULL;
if(destThing)
destItem = destThing->getItem();

if(destItem && destItem->getID() == item->getID() && destItem->getItemCount() < 100)
{
uint32_t remainder = 100 - destItem->getItemCount();
if(__queryAdd(index, item, remainder, flags) == RET_NOERROR)
n = remainder;
}
}

maxQueryCount = freeSlots * 100 + n;
if(maxQueryCount < count)
return RET_CONTAINERNOTENOUGHROOM;
}
else
{
maxQueryCount = freeSlots;
if(maxQueryCount == 0)
return RET_CONTAINERNOTENOUGHROOM;
}[/cpp]

Is this bug fixed already?

I'll study the code here... Though I have 0 knowledge on C++ lol

------- edit ------

lol it's the same code... Bug still persists then

Cyk, the difference for the script you posted is that it's missing this part:

[cpp] else
{
maxQueryCount = freeSlots;
if(maxQueryCount == 0)
return RET_CONTAINERNOTENOUGHROOM;
}[/cpp]

Or maybe I copy/pasted wrong and missed this part, that's why unstackable items are not being dragged to containers after these changes you recommended xD

PS: It's not about lazyness, but I have no idea how to debug.. Should it appear on console? The error

:s
 
Hey Cyk, maybe somethign like:

[cpp] maxQueryCount = freeSlots;
if(maxQueryCount == 0)
return RET_CONTAINERNOTENOUGHROOM;
}[/cpp]

The last part of the code.

[cpp] maxQueryCount = freeSlots;
if(MaxQueryCount == 0 && 100 - destItem->getItemCount())
return RET_CONTAINERNOTENOUGHROOM;
}[/cpp]

? '-' dtk lol, just trying to help
 
ya, ugly bug that persists in newer revs, should be fixed *-*

Doesn't seems very hard, for those who have hard C++ knowledge
 
Back
Top