Closed Pt-Djefferson closed 4 years ago
I'd probably prefer the old way (despite this obviously being way cleaner solution), because m_StatsDictionary
is in many places, like m_PanelStatsSerialized
and when escaping only m_StatsDictionary
we can deserialize rest of the stuff properly if needed. It's also a bit more bulletproof as if Hinterland decides to put m_StatsDictionary
stuff elsewhere I don't have to do this kind of stuff to the new fields.
On the other hand it seems like Break m_StatsDictionary
isn't working correctly either.
Anyway, empty string isn't valid value for List<SandboxRecord>
, so we need to change the value to null or change the type of m_SandboxRecords
. I changed it to null. m_AllTimeStats is already a string so we don't have to touch that.
Biggest problem with this is that this will break if m_SandboxRecords
will contain more arrays in the future.
There is a way to cut off only m_StatsDictionary
: build a list of replacings in loop ans replace all m_StatsDictionary:{}
by something like m_StatsDictionary:numberOfReplacingInList
. And restore it by numberOfReplacingInList
variable from list before save. It will be more universal. But there will be another problem: in m_SandboxRecord there is a date field and selialization makes it in a bad format.
About escaping forward slashes: in original profile saves all forvard slashes is escaped. And not escaping them may bring profile crash in future.
In other way Newtonsoft.Json is too flexible and I think that all problems can be solved by using right Newtonsoft.Json methods. I will try to find that methods.
About escaping forward slashes: in original profile saves all forvard slashes is escaped. And not escaping them may bring profile crash in future.
Only place where I see forward slashes is the xml document, so it's bit too general to say that they're all escaped. It shouldn't matter if they're escaped probably. If all the forward slashes are really escaped, the same probably applies to saves as well, not just profile.
But there will be another problem: in m_SandboxRecord there is a date field and selialization makes it in a bad format.
Ok nice catch, that might be the only problem, because I don't actually see how cutting whole sections would be better solution. The code can be cleaner but the solution itself wouldn't be better in my opinion. The current solution is to add quotes to the keys which means that after that the data can be parsed properly, and edited if needed.
In other way Newtonsoft.Json is too flexible and I think that all problems can be solved by using right Newtonsoft.Json methods. I will try to find that methods.
Probably, but not sure if it worth the effort unless you see some actual problem with the current solution, apart from the code being pretty ugly.
Merged your quick fix, and fixed the DateTime and dictionary key type and now profiles should work. There shouldn't be any more DateTimes left.
Just replace whole fields m_AllTimeStats and m_SandboxRecords by dummies and bring them back at save time.