May 14, 2024, 09:18:11 am

The Gang Garrison 2 Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

NOTICE: Wondering where all the forums have gone?

Join the community Discord server!

Pages: [1]

Author Topic: New embedded leveldata format  (Read 5455 times)

cspotcode

  • Coder
  • Administrator
  • *****
  • Karma: 134
  • Offline Offline
  • Posts: 412
New embedded leveldata format
« on: June 05, 2011, 09:36:14 pm »

I'm working on a new JSON-based format for maps.  Basically a GG2 map will be described by a JSON document which lists all entities, walkmask data, and any other level parameters.  This document can be embedded into a PNG file like we've been doing, can be put in a zip with some PNGs, or whatever.

Please tell me what I've done wrong :D

old link http://pastebin.com/fty8wQ9U
EDIT: Moved to Github Gist: https://gist.github.com/1597921
« Last Edit: January 11, 2012, 08:27:57 pm by cspotcode »
Logged
"The knack of flying is learning how to throw yourself at the ground and miss."
- Douglas Adams

MedO

  • Owns this place
  • *****
  • Karma: 151
  • Offline Offline
  • Posts: 1752
Re: New embedded leveldata format
« Reply #1 on: June 06, 2011, 05:02:28 pm »

Quote
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.

Quote
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 :)

Quote
/* 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?

Quote
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.
Logged
Quote from: Alfred North Whitehead
It is the business of the future to be dangerous; and it is among the merits of science that it equips the future for its duties.

Quote from: John Carmack
[...] if you have a large enough codebase, any class of error that is syntactically legal probably exists there.

cspotcode

  • Coder
  • Administrator
  • *****
  • Karma: 134
  • Offline Offline
  • Posts: 412
Re: New embedded leveldata format
« Reply #2 on: June 06, 2011, 06:22:49 pm »

Quote
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.

Quote
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. :D

Quote
/* 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.

Quote
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.
Logged
"The knack of flying is learning how to throw yourself at the ground and miss."
- Douglas Adams

Dusty

  • 2012 Haxxy Award Winner
  • *
  • Karma: -78
  • Offline Offline
  • Posts: 10312
  • Dust in a box under a table
Re: New embedded leveldata format
« Reply #3 on: January 11, 2012, 08:30:48 am »

I thought we were moving away from GM.

Nukleus

  • Guest
Re: New embedded leveldata format
« Reply #4 on: January 11, 2012, 09:29:53 am »

I thought we were moving away from GM.
We can take this new system with us when we go
Logged

Vindicator

  • Developer
  • ******
  • Karma: 84
  • Offline Offline
  • Posts: 2398
    • http://www.kylemoy.org/
Re: New embedded leveldata format
« Reply #5 on: January 11, 2012, 12:59:29 pm »

Why would we need to support multiple collision masks?
Logged

BassMakesPaste

  • Guest
Re: New embedded leveldata format
« Reply #6 on: January 11, 2012, 01:56:52 pm »

Water, hurtboxes, etc can be all maskized.

Also, if we ever want semisolid/dropthrough objects.
« Last Edit: January 11, 2012, 01:57:22 pm by BassMakesPaste »
Logged

Orpheon

  • Moderator
  • *****
  • Karma: 15
  • Offline Offline
  • Posts: 6409
  • Developer
Re: New embedded leveldata format
« Reply #7 on: January 11, 2012, 02:39:27 pm »

What about map foregrounds?
Logged

cspotcode

  • Coder
  • Administrator
  • *****
  • Karma: 134
  • Offline Offline
  • Posts: 412
Re: New embedded leveldata format
« Reply #8 on: January 11, 2012, 08:26:27 pm »

I moved the example files to a Github Gist: https://gist.github.com/1597921

I also added an example of how map foregrounds and backgrounds would work.
Logged
"The knack of flying is learning how to throw yourself at the ground and miss."
- Douglas Adams

Vindicator

  • Developer
  • ******
  • Karma: 84
  • Offline Offline
  • Posts: 2398
    • http://www.kylemoy.org/
Re: New embedded leveldata format
« Reply #9 on: January 11, 2012, 09:39:52 pm »

Water, hurtboxes, etc can be all maskized.

Also, if we ever want semisolid/dropthrough objects.

Ah. That does sound useful, actually.
Logged

NAGN

  • Developer
  • ******
  • Karma: 146
  • Offline Offline
  • Posts: 16150
  • Yeah so now I have an idea
Re: New embedded leveldata format
« Reply #10 on: July 29, 2012, 01:04:40 pm »

So I was wondering if it'll be a good idea embedding the wallmask data directly into the JSON, or if we'll just include the wallmask as another sub data (specified by the map config file, and copied over to the zip/folder, naturally)
Logged

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12532
  • Another one --
Re: New embedded leveldata format
« Reply #11 on: July 29, 2012, 03:14:02 pm »

eew eew why would you store a bitmap embedded in text
embedded bzipped 2-bit png pls
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

NAGN

  • Developer
  • ******
  • Karma: 146
  • Offline Offline
  • Posts: 16150
  • Yeah so now I have an idea
Re: New embedded leveldata format
« Reply #12 on: July 29, 2012, 07:16:18 pm »

you want to embed it directly in the png image, or do you want it to be a seperate file

having it a seperate file might make it easier to edit without recompiling...
Logged

NAGN

  • Developer
  • ******
  • Karma: 146
  • Offline Offline
  • Posts: 16150
  • Yeah so now I have an idea
Re: New embedded leveldata format
« Reply #13 on: July 30, 2012, 03:32:47 am »

good news, I've figured out how to decode the wallmask format in python, thanks to cspotcode's handy docs

http://dl.dropbox.com/u/92157440/thing.txt

the bad news is that we're probably not going to use embedable pngs anymore, but backwards compatibility is nice
Logged
Pages: [1]
 

Page created in 0.029 seconds with 33 queries.