Jump to content

Save file corruptions


Recommended Posts

I've been having some serious problems with save files being corrupted, as of late. Definitely something related to saving and loading of games, according to the error page text.

 

I've been able to determine that it's not the vanilla game, vanilla works just fine. So, therefore, it must be one of the 60-70ish mods i've acrued going over both the Klei webs and t he Steam workshop.

 

I'm going through the painstaking process of trying to pin down the mods now, but i'd like to know, has anyone else been having save corruption problems with a certain mod/combination of mods? Anything that might help narrow this down at all would be great :\

 

For the sake of completeness, the error page text:

 

data/scripts/saveindex.lua:363: Corrupt Save file[survival_1]
LUA ERROR stack traceback:
=|C| in function 'assert'
data/scripts/saveindex.lua(363,1)
 =|C| in function 'GetPersistentString'
data/scripts/saveindex.lua(344,1) in function 'GetSaveData'
data/scripts/gamelogic.lua(902,1) in function 'DoLoadWorld'
data/scripts/gamelogic.lua(949,1) in function 'LoadSlot'
data/scripts/gamelogic.lua(1013,1) in function 'DoResetAction'
data/scripts/gamelogic.lua(1048,1) in function 'complete_callback'
Link to comment
Share on other sites

Any mod that contains an OnLoad or OnSave function may be causing this. Look for mods that updated recently, especially if they changed onload and onsave. If a mod updates its onsave/onload functions in the wrong way, the game can crash because the data saved is old version and data loaded is new version.

Link to comment
Share on other sites

On the mod side of this. I've found it's a good practice to throw in 

if not data.value then    inst.value = defaultvalueelse    inst.value = data.valueend

For values introduced in a version. Keep it around for at least a version number. 

Link to comment
Share on other sites

Any mod that contains an OnLoad or OnSave function may be causing this. Look for mods that updated recently, especially if they changed onload and onsave. If a mod updates its onsave/onload functions in the wrong way, the game can crash because the data saved is old version and data loaded is new version.

 

....A lot of the mods were updated recently D:

 

Well, Revamped Blowdarts appears to have OnSave and OnLoad. I guess i'll see if that's the offender.

Link to comment
Share on other sites

Thanks for letting me know @Silentdarkness1, this is a big problem.

To the modders: is the problem occurring because my mod overrode a onsave / onload function for one the game's native components? Can I just move the onsave / onload to a custom component? Or can the problem still occur if we include ANY onsave / onload functions at all in the mod? If including any onsave / onload functions is a problem, is there another way to save custom data?

 

Cheers in advance :)

Link to comment
Share on other sites

@chromiumboy

I can't be specific unless @Silentdarkness1 shares the mod list he's using, but the issue is probably caused by the fact that you're not really preserving how the OnSave/OnLoad functions for the fueled component work. You're always saving the currentfuel field, unlike the vanilla function which only does so if it's different than the maximum fuel. This leads to a savedata corruption if a fueled component has infinite fuel, such as in the Link mod.

It'd be much better to not override the OnSave/OnLoad functions, instead just patching them. You could use this as a replacement for your fueledpostinit function:

function fueledpostinit(Fueled)	-- Add secondary fuel type	Fueled.secondaryfueltype = nil		-- Patch the save function	local oldOnSave = Fueled.OnSave	Fueled.OnSave = function(self)		local data = oldOnSave(self) or {}		data.secondaryfueltype = self.secondaryfueltype		return data	end			-- Patch the load function	local oldOnLoad = Fueled.OnLoad	Fueled.OnLoad = function(self, data)		oldOnLoad(self, data)		if data then			self.secondaryfueltype = data.secondaryfueltype		end	end		-- Patch the fuel acceptance function	local oldCanAcceptFuelItem = Fueled.CanAcceptFuelItem	Fueled.CanAcceptFuelItem = function(self, item)		if oldCanAcceptFuelItem(self, item) then			return self.secondaryfueltype == nil or item:HasTag(self.secondaryfueltype)		end	end	endAddComponentPostInit("fueled", fueledpostinit)
Link to comment
Share on other sites

Thanks for letting me know @Silentdarkness1, this is a big problem.

To the modders: is the problem occurring because my mod overrode a onsave / onload function for one the game's native components? Can I just move the onsave / onload to a custom component? Or can the problem still occur if we include ANY onsave / onload functions at all in the mod? If including any onsave / onload functions is a problem, is there another way to save custom data?

 

Cheers in advance :-)

 

Hello!

So is there any progress with that? Is the problem solved? If so, perhaps getting mod back to the Steam Workshop could be fine? :)

PS Like the idea of that mod so much, but can't use it, mentioning the problem discussed here.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...