From: Holger Schemel Date: Wed, 27 Nov 2024 20:13:58 +0000 (+0100) Subject: added tape file chunk to store extended versions X-Git-Tag: 4.4.0.0-test-4~18 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=4c0a1251b4c56b78d9e89997b0a1d03b9177478a;p=rocksndiamonds.git added tape file chunk to store extended versions --- diff --git a/src/files.c b/src/files.c index 2b7af216..9c8cb98c 100644 --- a/src/files.c +++ b/src/files.c @@ -59,7 +59,8 @@ // (nothing at all if unchanged) #define LEVEL_CHUNK_ELEM_UNCHANGED 0 -#define TAPE_CHUNK_VERS_SIZE 8 // size of file version chunk +#define TAPE_CHUNK_VERS_SIZE 8 // size of standard tape versions chunk +#define TAPE_CHUNK_VERX_SIZE 8 // size of extended tape versions chunk #define TAPE_CHUNK_HEAD_SIZE 20 // size of tape file header #define TAPE_CHUNK_SCRN_SIZE 2 // size of screen size chunk @@ -9332,6 +9333,14 @@ static int LoadTape_HEAD(File *file, int chunk_size, struct TapeInfo *tape) return chunk_size; } +static int LoadTape_VERX(File *file, int chunk_size, struct TapeInfo *tape) +{ + tape->game_version |= getFileVersionExtended(file); + tape->engine_version |= getFileVersionExtended(file); + + return chunk_size; +} + static int LoadTape_SCRN(File *file, int chunk_size, struct TapeInfo *tape) { tape->scr_fieldx = getFile8Bit(file); @@ -9637,6 +9646,7 @@ void LoadTapeFromFilename(char *filename) { { "VERS", TAPE_CHUNK_VERS_SIZE, LoadTape_VERS }, { "HEAD", TAPE_CHUNK_HEAD_SIZE, LoadTape_HEAD }, + { "VERX", TAPE_CHUNK_VERX_SIZE, LoadTape_VERX }, { "SCRN", TAPE_CHUNK_SCRN_SIZE, LoadTape_SCRN }, { "INFO", -1, LoadTape_INFO }, { "BODY", -1, LoadTape_BODY }, @@ -9778,6 +9788,12 @@ static void SaveTape_HEAD(FILE *file, struct TapeInfo *tape) putFileVersion(file, tape->engine_version); } +static void SaveTape_VERX(FILE *file, struct TapeInfo *tape) +{ + putFileVersionExtended(file, tape->game_version); + putFileVersionExtended(file, tape->engine_version); +} + static void SaveTape_SCRN(FILE *file, struct TapeInfo *tape) { putFile8Bit(file, tape->scr_fieldx); @@ -9849,6 +9865,9 @@ void SaveTapeToFilename(char *filename) putFileChunkBE(file, "HEAD", TAPE_CHUNK_HEAD_SIZE); SaveTape_HEAD(file, &tape); + putFileChunkBE(file, "VERX", TAPE_CHUNK_VERX_SIZE); + SaveTape_VERX(file, &tape); + if (checkSaveTape_SCRN(&tape)) { putFileChunkBE(file, "SCRN", TAPE_CHUNK_SCRN_SIZE); diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 9bc779e1..599879eb 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -2237,6 +2237,11 @@ VersionType getFileVersion(File *file) return VERSION_IDENT(version_super, version_major, version_minor, version_patch); } +VersionType getFileVersionExtended(File *file) +{ + return getFileVersion(file) >> 32; +} + int putFileVersion(FILE *file, VersionType version) { if (file != NULL) @@ -2255,6 +2260,11 @@ int putFileVersion(FILE *file, VersionType version) return 4; } +int putFileVersionExtended(FILE *file, VersionType version) +{ + return putFileVersion(file, version << 32); +} + void ReadBytesFromFile(File *file, byte *buffer, unsigned int bytes) { int i; diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 640ef092..26a5168f 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -230,7 +230,9 @@ int putFile32BitInteger(FILE *, int, int); boolean getFileChunk(File *, char *, int *, int); int putFileChunk(FILE *, char *, int, int); VersionType getFileVersion(File *); +VersionType getFileVersionExtended(File *); int putFileVersion(FILE *, VersionType); +int putFileVersionExtended(FILE *, VersionType); void ReadBytesFromFile(File *, byte *, unsigned int); void WriteBytesToFile(FILE *, byte *, unsigned int);