There's JSON object in the WZ 3.1+ JS API that can stringify to and parse from JSON. So I assume there's something lurking in there already that could be used.
When I first saw the ini file format being used, I asked if we could use JSON instead. But having now worked with ini format a bit more, I must admit I quite like it - it's a very clean way to define settings.
In terms of JSON, I think it would make sense to use JSON to store JS objects in
save games. Currently there's some
ultra-weird gumpf that goes in to the ini file with lots of escaping. Using JSON.stringify(), which automatically removes functions and anything else that you wouldn't want to go in to an ini file, would make JS objects persisted in save games much easier to read and debug.
When a saved game is loaded, you'd just cycle through all the properties in the [globals_N] section, and pseudo code to restore the properties would be something like this:
Code: Select all
for each player (N):
load their section of the ini [globals_N]:
for each property in that section:
global[propertyName] = JSON.parse(iniSection[propertyName])
More info on the JS API's JSON object:
https://developer.mozilla.org/en/docs/JSON
Note: I've already used it extensively in my
Babel API (
source,
unit tests).
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO