Page MenuHomeFeedback Tracker

GetInventory().CreateInInventory(...) doesn't respect CanReceiveItemIntoCargo
Assigned, UrgentPublic

Description

This bug has been around for as long as everyone can remember.

CreateInInventory does a FindFirstFreeLocationForNewEntity, a native function, which doesn't check for CanReceiveItemIntoCargo of the inventory owner. This has always caused a lot of grief with all mods which create items (e.g. admin tools, traders, etc. )

We can obviously maybe do some workarounds but the amount of work required for us to make this possible (and every modder would have to) is not feasible. It generally doesn't work well with high population servers having to do some recursive searches for free inventory in script.

An example of vanilla item where this behaviour is not respected is the Barrel. If you use an admin tool to spawn(with player.GetInventory().CreateInInventory) a Barrel, then spawn another, it will spawn it inside the inventory of the first barrel. This also has been causing massive issues in 1.25 where you cannot drop the barrel since it has something in inventory. (which is another issue in itself, always allow us to drop items from hands even if the rule says we couldn't take it in hands)

Could you please add a check for CanReceiveItemIntoCargo in CreateInInventory? A similar function which checks if we can receive any item or specific item type (string or typename) would be useful as well as we don't have the item created yet.

Details

Severity
Major
Resolution
Open
Reproducibility
N/A
Operating System
Windows 10 x64
Category
General

Event Timeline

Helkhiana updated the task description. (Show Details)Thu, May 30, 5:16 PM
Geez changed the task status from New to Assigned.Fri, May 31, 12:05 PM

I just wanted to add something I've noticed. It's related to FindFirstFreeLocation

When splitting an item in inventory, if you have an item with cargo e.g. FirstAidKit, which has CanReceiveItemIntoCargo returning false due to the new rules of AreChildrenAccessible, the new split item still goes inside it's cargo. Yet another example where we don't use CanReceiveItemIntoCargo.

This is also a big issue for us, and we hope there is a fix planned.

ntepup added a subscriber: ntepup.Wed, Jun 19, 12:26 PM