• 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

Member
Joined
Jul 14, 2020
Messages
12
Reaction score
7
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;
}
 
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:

View attachment 78012

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.
I had this same problem on OTX 2 (based on TFS 0.X), here's solution for OTX:

 
Opa @potinho não consegui compilar, será que fiz algo de errado?

1>------ Compilação iniciada: Projeto: theforgottenserver, Configuração: Versão x64 ------
1> Construção iniciada em 27/12/2024 10:24:15.
1>InitializeBuildStatus:
1> Criando "x64\Release\theforgottenserver.unsuccessfulbuild" porque "AlwaysCreate" foi especificado.
1>ClCompile:
1> container.cpp
1>.. \container.cpp(342): erro C2374: 'destThing': redefinição; inicialização múltipla
1> .. \container.cpp(341) : ver declaração de 'destThing'
1>.. \container.cpp(431): erro C2374: 'n': redefinição; inicialização múltipla
1> .. \container.cpp(430) : ver declaração de «n»
1>.. \container.cpp(437): erro C2440: '=': não é possível converter de 'uint32_t' para 'int32_t'
1>
1> Falha na compilação.
1>
1>Tempo decorrido 00:00:04.62
========== Compilação: 0 bem-sucedida, 1 com falha, 0 atualizada, 0 ignorada ==========
 
Back
Top