Issue with DiskSavedGameDataStorer

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Snebjorn
Posts: 12
Joined: Sun Apr 17, 2016 4:33 pm

Issue with DiskSavedGameDataStorer

Post 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.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Issue with DiskSavedGameDataStorer

Post 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.
User avatar
Snebjorn
Posts: 12
Joined: Sun Apr 17, 2016 4:33 pm

Re: Issue with DiskSavedGameDataStorer

Post by Snebjorn »

Super - thanks!
User avatar
Snebjorn
Posts: 12
Joined: Sun Apr 17, 2016 4:33 pm

Re: Issue with DiskSavedGameDataStorer

Post 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.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Issue with DiskSavedGameDataStorer

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