Jump to content

Wurt Marshify Issue


Lunacy420
  • Pending

Server shows an error "unable to connect to server" sometime after casting Marshify in a fight. 

  • First observed in a 600 day relaxed world not using any server commands but with mods for QOL.
  • Recreated bug for testing using c_freecrafting, and c_give functions and removed all mods

Things I did for testing is:

  • Unsubscribed to all mods

  • uninstalled the game

  • deleted all game files including the saves in the documents folder

  • reinstalled the game and verified file integrity


Error in the cave server logs report:

COROUTINE 111669 SCRIPT CRASH:
[string "scripts/components/propagator.lua"]:51: bad argument #2 to 'FindEntities' (number expected, got nil)
LUA ERROR stack traceback:
        =[C] in function 'FindEntities'
        scripts/components/propagator.lua(51,1) in function 'OnRemoveEntity'
        scripts/entityscript.lua(1724,1) in function 'Remove'
        scripts/simutil.lua(585,1)    
[00:20:16]: 
COROUTINE 111669 SCRIPT CRASH:
[string "scripts/components/propagator.lua"]:51: bad argument #2 to 'FindEntities' (number expected, got nil)
LUA ERROR stack traceback:
        =[C] in function 'FindEntities'
        scripts/components/propagator.lua(51,1) in function 'OnRemoveEntity'
        scripts/entityscript.lua(1724,1) in function 'Remove'
        scripts/simutil.lua(585,1)
[00:20:16]: LuaError but no error string


Steps to Reproduce

As Wurt

Happens occasionally when fighting Brightshades:

  • cast Marshify on tamed merms before fighting
  • fight brightshade and there's a chance server crashes

Happens everytime on Toadstool

  • create warrior huts in the caves
  • Tame Warrior Merms
  • cast marshify before fighting
  • fight Toadstool as usual, strike him with a sword, cut down his mushroom trees
  • The bug happens

 

Level progression i had when the crash happen that might be relevant:

  • Merm King has three upgrades on food insight
  • Merm King has three upgrades, armor,crown, and trident
  • Warrior Merms have helmets
  • Spooky 1



User Feedback


The function where the crash is happening is this:

function Propagator:OnRemoveEntity()
    if not (self.inst.components.heater ~= nil and self.inst.components.heater:IsEndothermic()) then
        local x, y, z = self.inst.Transform:GetWorldPosition()
        local prop_range = TheWorld.state.isspring and self.propagaterange * TUNING.SPRING_FIRE_RANGE_MOD or self.propagaterange
        local ents = TheSim:FindEntities(x, y, z, prop_range, nil, nil, TARGET_MELT_ANY_TAGS)
        -- OnRemoveEntity callback makes FindEntities return a nil in the first slot if the entity that was just removed is in the callback so ipairs cannot work here.
        for i = 1, #ents do
            local v = ents[i]
            if v then
                v:PushEvent("stopfiremelt")
                v:RemoveTag("firemelt")
            end
        end
    end
end

It's crashing because y is nil apparently, which makes me think this entity might not be valid when this is running..? As otherwise it'd make no sense for y to be nil.

This might be happening from calling to remove the entity twice somewhere, which isn't good if so.. but it is something that can be tracked at least. I'll make another comment if I find what entity this is happening with.

 

That said, there's also a potential oversight with how this (and how OnRemoveFromEntity) always run the fire melt stuff even if the propagator entity wasn't spreading heat and affecting meltable entities. For both functions, it should probably also be checking for self.spreading, or if the component was updating.

 

Actually.. I'm starting to think it might be a good idea to handle the "startfiremelt" and "stopfiremelt" stuff using a source modifier list on entities that are affected by that stuff.. to only properly start fire melting when a first source is added, and stop fire melting when all sources are removed (or if other conditions trigger, like being put in an inventory or container, handled by the meltable entity itself).

I feel like it'd be a lot more clean rather than the current implementation, where propagator updates of multiple entities can repeatedly enable and disable this stuff in one game update/tick, and could allow the block of code above to be cleaner, so that there's no need to do the specific bit of not using ipairs.

This could also avoid needing to do entity searches for OnRemoveEntity (especially given that it seems like you shouldn't be doing an entity search in the middle of the process of retiring an entity..) or OnUpdate for when stopping "firemelt" stuff, only OnRemoveFromEntity would then need to go through said list to remove itself as a source for affected entities. And as source modifier lists automatically remove sources when they're removed, OnRemoveEntity wouldn't even be needed.

Not only that, using a source modifier list could also allow moving propagators to then check and remove themselves as a source if they entity they were affecting is now out of range of the fire spread.

 

Actually.. on that last point, wait a minute.. that's a HUGE oversight! Once melting starts, it doesn't stop even if the propagator and the affected entity are moved away from each other!

Yeah no.. I know some of what I said is not necessarily connected to the crash, but I do feel like there's a lot that could be cleaned up about this stuff, it's a bit outdated and, the propagator component also tends to be pretty bad for performance when there's many fires active..

 

I feel like ideally, tracking the weird entity that's returning nil y should be done first, then, after this is addressed, do anything of the above to have this whole process be cleaner? Dunno, here's hoping though.

  • Big Ups 1

Share this comment


Link to comment
Share on other sites

Downloaded the update as of February 13 and it looks like this is no longer an issue?
Looks like the bug happens when a merm dies while the marshify was still on. So the error also happens on any other enemies.
I'll leave it to devs to say if this is actually already solved related to the comment above. For now however I was able to play through casting Marshify on toadstool and all other enemies.

Share this comment


Link to comment
Share on other sites

14 hours ago, Lunacy420 said:

Downloaded the update as of February 13 and it looks like this is no longer an issue?
Looks like the bug happens when a merm dies while the marshify was still on. So the error also happens on any other enemies.
I'll leave it to devs to say if this is actually already solved related to the comment above. For now however I was able to play through casting Marshify on toadstool and all other enemies.

The stuff above is definitely still an issue, there's a separate report about it even.

The propagator component definitely needs a lookover in general, but they also need to track whenever an entity is attempted to get removed twice, because it can lead to stuff like this. It's been there it seems, just hidden because the game technically didn't crash, but it's something worth logging and tracking, and even crashing in the dev build.

  • Wavey 2

Share this comment


Link to comment
Share on other sites



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...