Wiki downloaded text.xml.bin

You are viewing a static copy of the old 2DBoy forum, which closed in 2010. It is preserved here for historical interest, but it is not possible to reply to topics. For more recent discussion about World of Goo, visit our new forum.
Wiki downloaded text.xml.bindavidc12/19/2008 - 17:01

Hi... Soultaker I think.

Someone was having problems merging addins and we tracked it down to the text.xml.bin file. It looks like the wiki download page is adding a bunch of spaces to the end of the file after "</strings>".

Of course TinyXML doesn't mind this, but Java's XML parser does ("content not allowd in trailing section") and I can't think of an easy way to get around it, so hopefully you can fix your end!

-davidc

Re: Wiki downloaded text.xml.binSoultaker12/19/2008 - 17:14

That's a coincidence; I was just working on the XML page. :)

I'm not sure what you mean though. The plain-text version has no extra data at the end of the file (just a newline character to end the "</strings>" line) and whitespace characters should be allowed at the end of the file anyway.

I think what you are seeing is padding data; it's a bit unclear how this should work (the official files seem to contain 253 bytes for some reason) so I just pad with zeroes, but maybe your decoder doesn't discard those, after which the XML parser treats them as invalid content.

What I've done now, is ensured that the text is padded with newline characters to ensure the data size is a multiple of 16, so no additional padding is needed. This should be safe. Could you try if this works for you?

Re: Wiki downloaded text.xml.bindavidc12/19/2008 - 17:21

Ah, Java treats more than one new line at the end of the file as extra data as well.

The game encryption uses 0xFD to mark the end of the real file (up to 4 of these; the rest is padded 0x00). If the real file was actually a multiple of 16 anyway, it doesn't pad at all.

Here's my code that matches what the game does (I did a unit test that decrypts and re-encrypts all files to check they're identical):

<br />    /* If input was multiple of 16, NO padding. Example: res\levels\BulletinBoardSystem\BulletinBoardSystem.level.bin */<br />    /* Otherwise pad to next 16 byte boundary */<br /><br />    int origSize = inputBytes.length;<br />    if (origSize % 16 != 0) {<br />      int padding = 16 - origSize % 16;<br /><br />      int newSize = origSize + padding;<br /><br />      log.finer("Size " + origSize + " padded with " + padding + " bytes to make " + newSize);<br /><br />      inputBytes = Arrays.copyOf(inputBytes, newSize);<br /><br />      /* Write up to 4 0xFD bytes immediately after the original file. The remainder can stay as the 0x00 provided by Arrays.copyOf. */<br />      for (int i = origSize; i < origSize + 4 && i < newSize; ++i) {<br />        inputBytes[i] = EOF_MARKER;<br />      }<br />    }<br />    else {<br />      log.finer("Size " + origSize + " already multiple of 16, no padding");<br />    }<br />

Re: Wiki downloaded text.xml.binSoultaker12/19/2008 - 17:35

Ah, that's nice to know. I definitely noticed the 253 bytes and cut them off when decoding, but I didn't bother to put them back in when encoding as the game didn't appear to be picky.

I've changed the padding to what you described; does it work for you now?

Re: Wiki downloaded text.xml.bindavidc12/19/2008 - 17:40

Looking good, thanks.