Jump to content

regrowthmanager causes crash if can't find data for regrowth type after reloading


Tykvesh
  • Fixed

regrowthmanager component has SetRegrowthForType function, which can be used for creating custom regrowth type;

If any custom regrowth timer been started while saving and then custom regrowth type been removed (for example, mod with custom SetRegrowthForType been disabled)  - regrowthmanager will cause crash while loading:

Spoiler

[string "scripts/components/regrowthmanager.lua"]:180: attempt to index field '?' (a nil value)
LUA ERROR stack traceback:
    scripts/components/regrowthmanager.lua:180 in (method) LongUpdate (Lua) <177-222>
    scripts/entityscript.lua:1575 in (method) LongUpdate (Lua) <1568-1578>
    scripts/prefabs/world.lua:222 in (method) PostInit (Lua) <217-237>
    scripts/gamelogic.lua:698 in (upvalue) DoInitGame (Lua) <563-766>
    scripts/gamelogic.lua:798 in (upvalue) cb (Lua) <793-799>
    scripts/saveindex.lua:285 in () ? (Lua) <267-286>
    =[C]:-1 in (method) GetPersistentString (C) <-1--1>
    scripts/saveindex.lua:267 in (method) GetSaveDataFile (Lua) <266-287>
    scripts/saveindex.lua:293 in (method) GetSaveData (Lua) <289-297>
    scripts/gamelogic.lua:800 in (upvalue) DoLoadWorld (Lua) <792-801>
    scripts/gamelogic.lua:841 in (upvalue) LoadSlot (Lua) <836-847>
    scripts/gamelogic.lua:896 in (upvalue) DoResetAction (Lua) <851-932>

It's actually not a bug, because it only affects modding. (but I really wish that component should forget timer if can't find regrowth type for it while loading)

* * *

How to reproduce:

Spoiler

It is an example for modmain.lua:


AddComponentPostInit("regrowthmanager", function(self)
	self:SetRegrowthForType("cactus", TUNING.CARROT_REGROWTH_TIME, "cactus", function() return 1 end)
end)

AddPrefabPostInit("cactus", function(inst)
	inst:ListenForEvent("onremove", function(inst) GLOBAL.TheWorld:PushEvent("beginregrowth", inst) end)
end)

Remove any cactus in the world to start the regrowth timer. Save the server and disable the mod. Try to load the server.

 


Steps to Reproduce
See spoiler above



User Feedback


A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.

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