Forgottenserver: player:addItem and player:addItemEx does not drop the item to the ground if there's no space

Created on 15 Oct 2020  路  4Comments  路  Source: otland/forgottenserver

Before creating an issue, please ensure:

  • [x] This is a bug in the software that resides in this repository, and not a
    support matter (use https://otland.net/forums/support.16/ for support)
  • [x] This issue is reproducible without changes to the C++ code in this repository

Steps to reproduce (include any configuration/script required to reproduce)

  1. Download/compile/run the latest version of TFS without performing any changes and create a God
  2. Drop your backpack, put a helmet on and say /i dark helmet (or try to spawn any other item)

Expected behaviour

The item should drop to the ground when there is no space, note that without capacity this works properly

Actual behaviour

The item is not dropped on the map

Environment

Used Docker image provided in this repository

Reproduction environment

Simply use the Docker image provided in this repository

Notes

  • This is an issue with the player:addItem method. It doesn't matter if you pass dropOnMap as true which is the default anyways
  • Does work with insufficient cap
  • Commit I tested this on is 24508912

UPDATE: Temporary workaround

Comment these lines in iologindata.cpp

if (!player->inventory[CONST_SLOT_STORE_INBOX]) {
        player->internalAddThing(CONST_SLOT_STORE_INBOX, Item::CreateItem(ITEM_STORE_INBOX));
}

If you have already created players you will need to delete item 26052 from all off them. Also, not sure if this might cause issues in modern clients, but yeah...

Most helpful comment

Yeah, this makes sense. The fix would be to not iterate this container when getting free slots as it's special and not meant for normal items.

CONST_SLOT_LAST shouldn't probably be CONST_SLOT_STORE_INBOX, but AMMO like before.

I'll push a fix for this soon.

All 4 comments

Some more info. Trading is also broken (if a player has no available slot to receive the item the trade still goes through and the item dissappears)

It seems to be that this commit broke it, due to Container now counting the 40 extra capacity of this new slot .

@EPuncker does this make sense?

Yeah, this makes sense. The fix would be to not iterate this container when getting free slots as it's special and not meant for normal items.

CONST_SLOT_LAST shouldn't probably be CONST_SLOT_STORE_INBOX, but AMMO like before.

I'll push a fix for this soon.

@nekiro Awesome, thanks for working on this!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

conde2 picture conde2  路  6Comments

Zbizu picture Zbizu  路  5Comments

GoularPink picture GoularPink  路  3Comments

souzajunior picture souzajunior  路  4Comments

MillhioreBT picture MillhioreBT  路  4Comments