Jump to content

Stolen Items on a Despawning Pirate Boat are deleted


Hornete
  • Pending
local function stashloot(inst)

    local ps = TheWorld.components.piratespawner
    if ps then
        local stash = ps:GetCurrentStash()
        if inst.components.inventoryitem then
            if not inst:HasTag("personal_possession") then
                table.insert(stash.loot,inst)
                inst:RemoveFromScene()
            else
                inst:Remove()
            end 
        elseif inst.components.inventory then
            for k,v in pairs(inst.components.inventory.itemslots) do

                if not v:HasTag("personal_possession") then
                    local item = inst.components.inventory:RemoveItemBySlot(k)
                    table.insert(stash.loot,item)
                else
                    v:Remove()
                end
            end
        end
    end
end

local function setpirateboat(boat)

    boat:AddComponent("boatcrew")

    boat:AddComponent("vanish_on_sleep")
    boat.components.vanish_on_sleep.vanishfn = function(inst)
        --local ents = boat.components.walkableplatform:GetEntitiesOnPlatform()
        local x,y,z = inst.Transform:GetWorldPosition()
        local ents = TheSim:FindEntities(x,y,z, inst.components.walkableplatform.platform_radius)
        for i=#ents,1,-1 do
            stashloot(ents[i])
            ents[i]:Remove()
        end
    end
end

in components/piratemanager.lua, you can see the entities on a despawning boat has everything on it stashed into the loot table of the stash, which of course requires the entity to actually exist.

However, for whatever reason the entity is also removed after stashloot is called, causing every item stored in the stash to become invalid, causing a crash when you dig up the stash with those invalid items, and now those items are lost.

unknown.png

An F in the chat for my friends canes, miner hats, dark swords, and lanterns.


Steps to Reproduce

1. Have loot stolen by being on a despawning pirate boat

2. Dig up stash
3. Oopsie crash




User Feedback


There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...