Register FAQ Search Today's Posts Mark Forums Read
Go Back   JazzJackrabbit Community Forums » Open Forums » JCS & Scripting

J2L Data5 technical details

Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,983

Violet CLM has disabled reputation

Jun 23, 2017, 03:01 PM
Violet CLM is online now
Reply With Quote
J2L Data5 technical details

MLLE does some tricky things with J2L files and I thought it was important to document them somewhere easily visible, in the interest of transparency and encouraging other developers and that kind of thing. This thread should suffice.

Point 1: J2L files have a discontinuous pair of shorts Security1 and Security2 which are combined to form a long, typically 0x00000000. When you save a passworded level in JCS, that long is 0xBA00BE00 instead. Notably, whenever the long is of form 0xBA##BE## (with any hexadecimal numbers in place of the ##s) and the level is not passworded, JCS will be unable to open the level and will instead claim that the security envelope has been damaged. This is a known method of marking that a level should not be edited in JCS lest JCS mess it up somehow by resaving it.

Point 2: Even if a J2L file contains any number of bytes after the fourth zlib stream, JJ2 will not read any of them. It cares only whether the CRC is properly calculated for those bytes.

Therefore, MLLE version 2.3 introduces a new magic number, 0xBACABEEF, which it will use for the Security shorts of levels that are intended only to be opened in MLLE. Moreover, if a level uses any security number other than 0x00000000, 0xBA00BE00, or 0xBACABEEF, MLLE (as well as JCS) will refuse to open it.

When MLLE uses the 0xBACABEEF security number, it is in order to append a fifth zlib-compressed data stream, "Data5," to the end of the J2L, which is read only by MLLE and by an angelscript library that MLLE generates. Data5 is preceded by a sixteen byte header: the magic characters "MLLE"; a four byte version string; a four byte integer of Data5's compressed length; and a four byte integer of Data5's uncompressed length. If the bytes after Data4 take any other form, MLLE will ignore them. (The purpose of MLLE's Data5 is that levels with it also have their .j2as edited to #include an angelscript library, which opens the level and gets various important instructions out of that Data5 section.)

Therefore, if you want to create your own extended J2L format and don't want MLLE to mess it up, make your own security number with the format 0xBA##BE## and write whatever arbitrary data you want (which shouldn't begin with "MLLE" etc.) after Data4.


ETA: I am also reserving the number 0xBA01BE01 to designate a level that is used (by MLLE) indirectly but cannot directly be opened in an editor.
__________________

Last edited by Violet CLM; Jul 28, 2017 at 10:13 AM.
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

All times are GMT -8. The time now is 09:26 AM.