+ static struct
+ {
+ char *chunk_name;
+ void (*chunk_loader)(struct LevelInfo *, FILE *);
+ int chunk_length;
+ }
+ chunk_info[] =
+ {
+ { "HEAD", LoadLevel_HEAD, LEVEL_HEADER_SIZE },
+ { "AUTH", LoadLevel_AUTH, MAX_LEVEL_AUTHOR_LEN },
+ { "CONT", LoadLevel_CONT, 4 + MAX_ELEMENT_CONTENTS * 3 * 3 },
+ { "BODY", LoadLevel_BODY, 0 }, /* depends on contents of "HEAD" */
+ { NULL, NULL, 0 }
+ };
+
+ while (getFileChunk(file, chunk, &chunk_length, BYTE_ORDER_BIG_ENDIAN))
+ {
+ int i = 0;
+
+ while (chunk_info[i].chunk_name != NULL &&
+ strcmp(chunk, chunk_info[i].chunk_name) != 0)
+ i++;
+
+ if (chunk_info[i].chunk_name == NULL)
+ {
+ Error(ERR_WARN, "unknown chunk '%s' in level file '%s'",
+ chunk, filename);
+ SkipBytesInFile(file, chunk_length);
+ }
+ else if (chunk_length != chunk_info[i].chunk_length)
+ {
+ Error(ERR_WARN, "wrong size (%d) of chunk '%s' in level file '%s'",
+ chunk_length, chunk, filename);
+ SkipBytesInFile(file, chunk_length);
+ }
+ else
+ {
+ /* call function to load this level chunk */
+ (chunk_info[i].chunk_loader)(&level, file);
+
+ if (strcmp(chunk, "HEAD") == 0)
+ {
+ /* Note: "chunk_length" for CONT and BODY is wrong when elements are
+ stored with 16-bit encoding (and should be twice as big then). */
+
+ chunk_info[3].chunk_length = level.fieldx * level.fieldy;
+ }
+ }
+ }
+
+#if 0