GG2 can reject maps with newer format numbers than it supports, and can provide legacy loading code for older format numbers
We should try to design the format so that extensions can be done in a backward-compatible way (i.e. every new format should be a superset of the old format). That version mechanism is useful of course, I'm just commenting on the legacy loading code comment.
I agree. I really like how many Javascript libraries handle configuration: the library internally has a Javascript object representing the default configuration which is "patched" by a configuration object provided by the client code. Code that wants all default behavior can pass {} as the configuration object, or it can specify only the settings it wants to change. I'm hoping we can create a similar system here, where new features are optional and when omitted will default to legacy behavior.
name: 'TwoDeeFort-Redux',
JSON-Strings are delimited with double quotes. And names of object attributes are strings as well and follow the same rule. I know some JSON parsers are lenient and will accept this, but there is really no good reason not to strictly follow the standard here.
JSON does not have comments either, but I guess they are only there for discussion
I chose a JSON library that allows for single-quotes, comments, and unquoted keywords because many people like it better that way and it's still valid JavaScript syntax.
For human-authored files, I'm in favor of allowing this looser syntax. That's what I've done for entitytypes.json.
For machine-generated JSON like this leveldata structure, I'm in favor of outputting standards-compliant JSON. But I'll be damned if I'm typing out all those extra quotes myself.
/* other stuff? setup time, respawn wave duration, other timers? */
Doing this properly requires a somewhat complicated default overwriting system - first you would have the game default for those values, overwritten by the user preferences in the ini, overwritten again by the specific map... but what if hosters want to overwrite the map defaults? Add a force-overwrite to the ini? Or add the possibility to write an ini for every map?
TF2 allows some timers to be specified in the map but I can't remember which ones they are. In TF2 CP maps I think each control point has its own map-specified cap duration. I don't know how GG2 does it. I should do more research.
data: 'TODO WHAT FORMAT SHOULD THIS DATA BE IN? MAYBE A BASE64 ENCODED STREAM OF BITS?'
I'm not really fond of adding the image into the JSON, but it we have to do it I'd say make a PNG of the walkmask and base64-encode that. It's going to be smaller (even after deflate-compression of the text chunk) and it's easier to use since we actually want a PNG for loading the mask into GM anyway.
If PNG supported storing several images that would be ideal, but in the absence of that, we could store it in the alpha channel (only works for one walkmask, obviously) or as separate files in a zip archive.
Saving base64-encoded PNGs is fine, too. I'm trying to come up with a system that will work OK without a huge amount of extra work to overcome GM's limitations.
My gut tells me it's a good idea to support multiple collision masks.
I haven't checked if there are any good unzipping extensions for GM. If we ever move away from GM, I'd like to make a zip-based format.