Sign in to follow this  
Cocochu

Does anyone know how to fix this? MOD WARNING CRASH

Recommended Posts

Cocochu    1

image.thumb.png.244795fc70f9c975ee55c87f2812ef69.png

Everytime the host resumes the serve, everyone including host receives this warning... 
How do you fix this?? 

  • Like 1

Share this post


Link to post
Share on other sites
Serpens    570

@CarlZalph

I get the same crash for Chester Family mod.
I currently try to help fixing it, but I have absolutely no clue what the problem is. It was "introduced" with the latest game update.

It is happending when a new chester is first time spawning in (only for clients)

In general all "custom container" code for mods is horrible, right?
There is no tutorial for it and there is also no code from the game you could copy. There are only mods you coudl copy from, but many many many of them have buggy code, like overwriting the WidgetSetup (which I can't beleive that this is the intended way).
And then the problems with replica for clients. really terrible.

The line leading to the crash seems to be a line like this in prefab file:

    if not GLOBAL.TheWorld.ismastersim then
        inst:DoTaskInTime(0, function(inst)  
            inst.replica.container:WidgetSetup("chester")             
        end)
        return inst
    end

You wont find such code in normal chester or in treasurechet or any container, but in most mods which add containers, even if they are the same like chester, because otherwise it crashed for clients.
But now this line is causing crashes, although sometimes only in specific circumstances... not easy...

Edited by Serpens

Share this post


Link to post
Share on other sites
Kooky    4

I'm the creator for the chester family, and my mod uses the code shown below. There is no GLOBAL since that part is meant for in mods where the code is in modmain. So far only 4 of my six chesters have this issue. The reason my mod uses the code below is because the 4 chesters, Cavester, Dubster, Big Daddy, and Stovester, all don't have a morph. Bluster (bluechester) and Afester have the proper code that mirrors chester's because they have morphs. I've found ONE mod so far that doesn't seem to have this issue that adds in it's own custom storage container, the newer cellars mod, but they also went through the painful process of making their own widget, and I don't seem to see anything about theworld.ismastersim anywhere. Then again I was also half awake by the time I found it. I took the time to email klei the other day, but haven't gotten a reply.

    if not TheWorld.ismastersim then
        inst:DoTaskInTime(0, function(inst)  
            inst.replica.container:WidgetSetup("chester")             
        end)
        return inst
    end

Share this post


Link to post
Share on other sites
Serpens    570

@zarklord_kleimore and more mods suffer from this and it is related to the latest QoL update, before everything worked.
But it is also quite likely, that the code from those mods is not the best. But the reason for this is like mentioned above, that there is no game code you could copy for your own containers and there is no tutorial. So everyone is using that code, regardless if it is good or not. ( I mean, why do mods at all need that line "inst.replica.container:WidgetSetup("chester")" while the original files never use this...)

So I would suggest that you check if there was a bug introduced and/or if you can improve the way modders add container widgets (or simply use exisiting ones).

Edited by Serpens

Share this post


Link to post
Share on other sites
penguin0616    1142

If I'm not mistaken, it looks like your mods are attempting to initialize containers again after their netvars have been processed. I presume you're not supposed to do that in the new system thanks to the comment and assertion.

local function InitializeSlots(inst, numslots)
    --Can't re-initialize slots after RegisterNetListeners
    assert(inst._slottasks == nil)

    local curslots = #inst._items
    if numslots > curslots then
        for i = curslots + 1, numslots do
            table.insert(inst._items, table.remove(inst._itemspool, 1))
        end
    elseif numslots < curslots then
        for i = curslots, numslots + 1, -1 do
            table.insert(inst._itemspool, 1, table.remove(inst._items))
        end
    end
end

 

Edited by penguin0616
  • Like 1

Share this post


Link to post
Share on other sites
Kooky    4

Actually penguin, they're not trying to re-initialize anything. This code we've all been using is telling the game to initialize the container in general with whatever widget we have it set at. Deleting said code just stops the mod from working all together. Testing this with my chester family mod, it doesn't happen 100% every single time, it's totally random but it always happens when one of the chesters spawn in. Same goes for any containers being placed.

Also for anyone who wants to know what files were changed with this 'hotfix'... Here's the list of files that were all changed. My friend Rayshen actually went through everything to try and help me figure it all out.

Modified file – bin/dontstarve_dedicated_server_nullrenderer.exe
Modified file – bin/dontstarve_steam.exe (+512 B)
Modified file – data/anim/dynamic/wormwood_cactus_stage2.dyn (-12.33 KiB)
Modified file – data/anim/dynamic/wormwood_shadow_stage2.dyn (-815 B)
Modified file – data/anim/dynamic/wormwood_shadow_stage3.dyn (-575 B)
Modified file – data/anim/dynamic/wormwood_shadow.dyn (-1.45 KiB)
Modified file – data/anim/dynamic/wurt_squid_powerup.dyn (-13.26 KiB)
Modified file – data/anim/dynamic/wurt_squid.dyn (-975 B)
Modified file – data/anim/dynamic/wurt_victorian_powerup.dyn (-65 B)
Modified file – data/anim/dynamic/wurt_victorian.dyn (-53 B)
Modified file – data/databundles/anim_dynamic.zip (-744 B)
Modified file – data/databundles/bigportraits.zip
Modified file – data/databundles/fonts.zip
Modified file – data/databundles/images.zip
Modified file – data/databundles/klump.zip
Modified file – data/databundles/scripts.zip (-10 B)
Modified file – data/databundles/shaders.zip
Modified file – version.txt
Manifest ID changed – 3183916969227434204 › 8258012146002322566

Share this post


Link to post
Share on other sites
penguin0616    1142

@Kooky Assuming that this "chester family mod" spawns multiple chesters, then it certainly seems like an attempt at re-initializing is being made.

Chesters already have their containers initialized, setting up the widget before the net variables are registered, which means the assertion does not fail.
 

Then this code gets run.

10 hours ago, Kooky said:

if not TheWorld.ismastersim then inst:DoTaskInTime(0, function(inst) inst.replica.container:WidgetSetup("chester") end) return inst end

This code attempts to set up chester again, after the net variables have been registered. Once they are registered, the container is not meant to be set up again, but the mod is still doing so.

 

Depending on the order that the scheduled tasks run, the first being the registering of net variables, the second being the mods, the crash may/may not occur, hence your 

1 hour ago, Kooky said:

it doesn't happen 100% every single time, it's totally random but it always happens when one of the chesters spawn in.

 

EDIT: I have contacted you on Discord, I will assist you there.

Edited by penguin0616
  • Like 1

Share this post


Link to post
Share on other sites
Serpens    570

thanks for this tutorial:

so regarding bugfix from the DST devs I can only quote penguin0616:

Quote

there's a "bug" that has existed with containers for a very long time now, and that is that the container param must match the prefab name.

which is still present it seems.

Share this post


Link to post
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
Sign in to follow this