#define MAX_LINE_LEN 1000 /* maximal input line length */
#define CHUNK_ID_LEN 4 /* IFF style chunk id length */
#define LEVEL_HEADER_SIZE 80 /* size of level file header */
-#define LEVEL_HEADER_UNUSED 17 /* unused level header bytes */
+#define LEVEL_HEADER_UNUSED 16 /* unused level header bytes */
#define TAPE_HEADER_SIZE 20 /* size of tape file header */
#define TAPE_HEADER_UNUSED 7 /* unused tape header bytes */
#define FILE_VERSION_1_0 10 /* old 1.0 file version */
}
}
-static void getFileChunk(FILE *file, char *chunk_buffer, int *chunk_length)
-{
- fgets(chunk_buffer, CHUNK_ID_LEN + 1, file);
-
- *chunk_length =
- (fgetc(file) << 24) |
- (fgetc(file) << 16) |
- (fgetc(file) << 8) |
- (fgetc(file) << 0);
-}
-
-static void putFileChunk(FILE *file, char *chunk_name, int chunk_length)
-{
- fputs(chunk_name, file);
-
- fputc((chunk_length >> 24) & 0xff, file);
- fputc((chunk_length >> 16) & 0xff, file);
- fputc((chunk_length >> 8) & 0xff, file);
- fputc((chunk_length >> 0) & 0xff, file);
-}
-
static void setLevelInfoToDefaults()
{
int i, x, y;
level.dauer_ablenk = 10;
level.amoebe_inhalt = EL_DIAMANT;
level.double_speed = FALSE;
+ level.gravity = FALSE;
for(i=0; i<MAX_LEVEL_NAME_LEN; i++)
level.name[i] = '\0';
/* read chunk "HEAD" */
if (file_version >= FILE_VERSION_1_2)
{
- getFileChunk(file, chunk, &chunk_length);
+ getFileChunk(file, chunk, &chunk_length, BYTE_ORDER_BIG_ENDIAN);
if (strcmp(chunk, "HEAD") || chunk_length != LEVEL_HEADER_SIZE)
{
Error(ERR_WARN, "wrong 'HEAD' chunk of level file '%s'", filename);
level.dauer_ablenk = fgetc(file);
level.amoebe_inhalt = fgetc(file);
level.double_speed = (fgetc(file) == 1 ? TRUE : FALSE);
+ level.gravity = (fgetc(file) == 1 ? TRUE : FALSE);
for(i=0; i<LEVEL_HEADER_UNUSED; i++) /* skip unused header bytes */
fgetc(file);
/* read chunk "BODY" */
if (file_version >= FILE_VERSION_1_2)
{
- getFileChunk(file, chunk, &chunk_length);
+ getFileChunk(file, chunk, &chunk_length, BYTE_ORDER_BIG_ENDIAN);
/* look for optional author chunk */
if (strcmp(chunk, "AUTH") == 0 && chunk_length == MAX_LEVEL_AUTHOR_LEN)
level.author[i] = fgetc(file);
level.author[MAX_LEVEL_NAME_LEN] = 0;
- getFileChunk(file, chunk, &chunk_length);
+ getFileChunk(file, chunk, &chunk_length, BYTE_ORDER_BIG_ENDIAN);
}
/* look for optional content chunk */
for(x=0; x<3; x++)
level.mampfer_inhalt[i][x][y] = fgetc(file);
- getFileChunk(file, chunk, &chunk_length);
+ getFileChunk(file, chunk, &chunk_length, BYTE_ORDER_BIG_ENDIAN);
}
/* next check body chunk identifier and chunk length */
fputs(LEVEL_COOKIE, file); /* file identifier */
fputc('\n', file);
- putFileChunk(file, "HEAD", LEVEL_HEADER_SIZE);
+ putFileChunk(file, "HEAD", LEVEL_HEADER_SIZE, BYTE_ORDER_BIG_ENDIAN);
fputc(level.fieldx, file);
fputc(level.fieldy, file);
fputc(level.dauer_ablenk, file);
fputc(level.amoebe_inhalt, file);
fputc((level.double_speed ? 1 : 0), file);
+ fputc((level.gravity ? 1 : 0), file);
for(i=0; i<LEVEL_HEADER_UNUSED; i++) /* set unused header bytes to zero */
fputc(0, file);
- putFileChunk(file, "AUTH", MAX_LEVEL_AUTHOR_LEN);
+ putFileChunk(file, "AUTH", MAX_LEVEL_AUTHOR_LEN, BYTE_ORDER_BIG_ENDIAN);
for(i=0; i<MAX_LEVEL_AUTHOR_LEN; i++)
fputc(level.author[i], file);
- putFileChunk(file, "CONT", 4 + 8 * 3 * 3);
+ putFileChunk(file, "CONT", 4 + 8 * 3 * 3, BYTE_ORDER_BIG_ENDIAN);
fputc(EL_MAMPFER, file);
fputc(MampferMax, file);
for(x=0; x<3; x++)
fputc(level.mampfer_inhalt[i][x][y], file);
- putFileChunk(file, "BODY", lev_fieldx * lev_fieldy);
+ putFileChunk(file, "BODY", lev_fieldx * lev_fieldy, BYTE_ORDER_BIG_ENDIAN);
for(y=0; y<lev_fieldy; y++)
for(x=0; x<lev_fieldx; x++)