Author Topic: The level format  (Read 3949 times)

Jonathan_NL

  • Sr. Member
  • ****
  • Posts: 488
    • View Profile
The level format
« on: May 27, 2005, 03:26:28 AM »
This is what I think is the final lvl format (stored in LSB first):

int magic == 9;
char background[32];
int tileset, gametype, gametime;
struct { int x1, y1, x2, y2; } rects[64]; /* the colored rects you get when you select a region and press 5678 */
char back[0x10000]; /* encrypted */
char mid[0x10000]; /* encrypted */
char front[0x10000]; /* encrypted */
float unused[3]; /* was start position in older versions (might be int) */
struct { float r, g, b; } backcolor, midcolor, frontcolor, waybackcolor;

int numobjects;
struct {
int type, texture, link;
float x, y, z; /* set z to 0 if you don't want to mess up sticking */
int unused; /* probably something in older versions */
float xscale, yscale;
float mass, friction;
int lighttype;
float red, green, blue, intensity;
int unused; /* probably something in older versions */
} objects[numobjects];

int numropes;
struct {
int type, texture;
int object1, anchor1;
int object2, anchor2;
} ropes[numropes]; /* note that I never tested them... */

struct {
int width;
if(width) { /* if not the texture is what is currently in memory */
int height, unused[2]; /* would be mag and min filters but never got implemented. always GL_LINEAR == 0x2601 */
int tex[width*height]; /* encrypted RGBA */
}
int numlines;
struct { float x1, y1, x2, y2, unused[4]; /* left in from older versions where it was {friction, breakpoint, x, x} */ } lines[numlines];
float friction, breakpoint;
int middamage, foredamage;
float density, drag;
int animation, animatespd;
} tiles[250]; /* tiles 1-250, was 1-255 in older versions but they are now ignored by gish */


(sorry about the spacing, but iB can't do much better)

I won't tell anything about the encryption unless they (CL) allow me to.
I rarely check this forum anymore. Feel free to send me a PM if you want my attention.

Jonathan_NL

  • Sr. Member
  • ****
  • Posts: 488
    • View Profile
The level format
« Reply #1 on: September 15, 2005, 04:11:55 PM »
Josiah/Alex: Do you think the encryption is still useful? Can I add it here?
I rarely check this forum anymore. Feel free to send me a PM if you want my attention.

Kampfschaf

  • Jr. Member
  • **
  • Posts: 15
    • View Profile
The level format
« Reply #2 on: September 16, 2005, 06:01:06 AM »
Very interesting!!! I understand the code! Some changes will make the Game much better ^^ No really... I programmed the GISH Trainer and decompile and use the Hex Codes to change some settings. I think this here is usefull to make much more... So tell more...

Jonathan_NL

  • Sr. Member
  • ****
  • Posts: 488
    • View Profile
The level format
« Reply #3 on: September 16, 2005, 01:08:03 PM »
It's the whole level format. I figured it out mainly by looking with a hexeditor, and writing a program that parsed as much as possible and often presented parts in a better format than the hexeditor. That way I reached the end fairly quickly.
I rarely check this forum anymore. Feel free to send me a PM if you want my attention.

Kampfschaf

  • Jr. Member
  • **
  • Posts: 15
    • View Profile
The level format
« Reply #4 on: September 16, 2005, 02:21:58 PM »
If you would like to make much more hacks please contact me n ICQ: 306155901

I program the Gish Trainer in VB! Maybe we can program a tool to make much more ;)

Jonathan_NL

  • Sr. Member
  • ****
  • Posts: 488
    • View Profile
The level format
« Reply #5 on: September 16, 2005, 04:10:58 PM »
Quote (Kampfschaf @ Sep. 16 2005,10:21)
If you would like to make much more hacks please contact me n ICQ: 306155901

I don't have ICQ.
I program the Gish Trainer in VB!
I used C, and I'm not using Windows.
Maybe we can program a tool to make much more ;)
I don't feel like doing much with it now.
I rarely check this forum anymore. Feel free to send me a PM if you want my attention.

Kampfschaf

  • Jr. Member
  • **
  • Posts: 15
    • View Profile
The level format
« Reply #6 on: September 16, 2005, 05:31:26 PM »
No ICQ? Where you live? ^^

Can you send me you C Code? I can this a little bit! I think i can use this 4 my VB Code a little bit! '<img'> To make the GISH Trainer much better.

Jonathan_NL

  • Sr. Member
  • ****
  • Posts: 488
    • View Profile
The level format
« Reply #7 on: September 16, 2005, 06:13:25 PM »
Quote (Kampfschaf @ Sep. 17 2005,1:31)
No ICQ? Where you live? ^^

In front of my computer. ':laugh:'
Can you send me you C Code? I can this a little bit! I think i can use this 4 my VB Code a little bit! '<img'> To make the GISH Trainer much better.
How would code to read levels help reading player files?
I rarely check this forum anymore. Feel free to send me a PM if you want my attention.

Kampfschaf

  • Jr. Member
  • **
  • Posts: 15
    • View Profile
The level format
« Reply #8 on: September 17, 2005, 06:32:37 AM »
ould like to see the code with you decompile the LevelHexCode!

Jonathan_NL

  • Sr. Member
  • ****
  • Posts: 488
    • View Profile
The level format
« Reply #9 on: September 17, 2005, 10:51:17 AM »
What do you mean? Reading a .pla file works like this:
Code Sample
fp = fopen(path, "rb");
fread(&plastruct, sizeof plastruct, 1, fp); /* making assumptions about struct packing */
fclose(fp);
/* swap bytes on a big-endian machine */

Reading levels works almost the same, but there are points where you depend on previous data, such as lists of dynamic size. That gives:
Code Sample
fread(&lvlstruct, untilfirstlist, 1, fp);
/* swap bytes on a big-endian machine */
int i;
for(i=0; i<numitems; i++) fread(&somewhere, sizeof somewhere, 1, fp);
/* etc */

Of course there should be error checks in a real program.
I rarely check this forum anymore. Feel free to send me a PM if you want my attention.