Page 1 of 1

Issue with DiskSavedGameDataStorer

Posted: Sun Jul 29, 2018 6:27 am
by Snebjorn
Hi,

I think there might be a problem with DiskSavedGameDataStorer. It looks like it computes slot indices incorrectly for saveinfo.dat by using slotNumber - 1 when slotNumber is already zero-based (first save file name is save_0.dat), which causes an error when it tries to access index -1 in m_savedGameInfo.

Only noticed this after I switched from player prefs to DiskSavedGameDataStorer for debugging purposes. Have fixed it for now by not subtracting 1 in the methods UpdateSavedGameInfoToFile and HasDataInSlot, and it seems to work correctly now, but I'm a bit worried that it might break something else.

Re: Issue with DiskSavedGameDataStorer

Posted: Sun Jul 29, 2018 9:17 am
by Tony Li
Hi,

I'll include a fix in version 2.0.3, being released tomorrow. In the meantime, your fix should work without breaking anything.

Re: Issue with DiskSavedGameDataStorer

Posted: Sun Jul 29, 2018 9:25 am
by Snebjorn
Super - thanks!

Re: Issue with DiskSavedGameDataStorer

Posted: Sun Jul 29, 2018 9:37 am
by Snebjorn
Oh, by the way: the issue I was originally trying to track down was caused by this:

https://issuetracker.unity3d.com/issues ... et-4-dot-6

Posting this here as a warning to others: if you set your project to use .NET 4.x equivalent as the scripting runtime version and run with a non-English OS locale setting that uses commas instead of dots for decimal separation, JSON serialisation of save data breaks, and it can't be parsed correctly when the save system tries to read it.

Problem still present in Unity 2018.2.1f1.

Re: Issue with DiskSavedGameDataStorer

Posted: Sun Jul 29, 2018 10:57 am
by Tony Li
Thanks for sharing that. Version 2.0.1 had to implement a similar fix for the Lua interpreter with .NET 4.6.

Version 2.0.3 adds a Binary Data Serializer component that you can use instead of JSON Data Serializer to avoid the issue. It's also more compact, although it's not human-readable for debugging.