static int LoadTape_INFO(File *file, int chunk_size, struct TapeInfo *tape)
{
+ char *level_identifier = NULL;
int level_identifier_size;
int i;
level_identifier_size = getFile16BitBE(file);
- tape->level_identifier =
- checked_realloc(tape->level_identifier, level_identifier_size);
+ level_identifier = checked_malloc(level_identifier_size);
for (i = 0; i < level_identifier_size; i++)
- tape->level_identifier[i] = getFile8Bit(file);
+ level_identifier[i] = getFile8Bit(file);
+
+ strncpy(tape->level_identifier, level_identifier, MAX_FILENAME_LEN);
+ tape->level_identifier[MAX_FILENAME_LEN] = '\0';
+
+ checked_free(level_identifier);
tape->level_nr = getFile16BitBE(file);
tape.length_seconds = 0;
if (leveldir_current)
- setString(&tape.level_identifier, leveldir_current->identifier);
+ {
+ strncpy(tape.level_identifier, leveldir_current->identifier,
+ MAX_FILENAME_LEN);
+ tape.level_identifier[MAX_FILENAME_LEN] = '\0';
+ }
tape.level_nr = level_nr;
tape.pos[tape.counter].delay = 0;
static void CopyTape(struct TapeInfo *tape_from, struct TapeInfo *tape_to)
{
- if (tape_to->level_identifier != NULL)
- checked_free(tape_to->level_identifier);
-
*tape_to = *tape_from;
-
- tape_to->level_identifier = getStringCopy(tape_from->level_identifier);
}
static void SwapTapes(struct TapeInfo *t1, struct TapeInfo *t2)
int game_version; // game release version the tape was created with
int engine_version; // game engine version the tape was recorded with
- char *level_identifier;
+ char level_identifier[MAX_FILENAME_LEN + 1];
int level_nr;
unsigned int random_seed;
unsigned int date;