• 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!

TFS 0.X Container bug stackable items 0.4

Guizek69

New Member
Joined
Jul 14, 2020
Messages
10
Reaction score
3
Hello otlanders!

Let's talk about this old and ridiculous bug present in tfs 0.4.

Imagine you have 10 crystal coins in a backpack full of other items.

But then you find a crystal coin on the ground and try to pull it quickly to stack it.
See the result in the image:

erro.png

Does anyone think of a solution?

I'll leave the container.cpp action code in the topic.

I look forward to it, thank you very much.
ReturnValue Container::__queryMaxCount(int32_t index, const Thing* thing, uint32_t count,
uint32_t& maxQueryCount, uint32_t flags) const
{
const Item* item = thing->getItem();
if(!item)
{
maxQueryCount = 0;
return RET_NOTPOSSIBLE;
}

if(((flags & FLAG_NOLIMIT) == FLAG_NOLIMIT))
{
maxQueryCount = std::max((uint32_t)1, count);
return RET_NOERROR;
}

int32_t freeSlots = std::max((int32_t)(capacity() - size()), (int32_t)0);
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;
}

return RET_NOERROR;
}
 

Similar threads

Back
Top