}
else if (key == KSYM_v)
{
- Debug("event:key:debug", "currently using game engine version %d",
- game.engine_version);
+ Debug("event:key:debug", "currently using game engine version %s",
+ getVersionString(game.engine_version));
return TRUE;
}
return element;
}
-static int getMappedElementByVersion(int element, int game_version)
+static int getMappedElementByVersion(int element, VersionType game_version)
{
// remap some elements due to certain game version
}
PrintLine("-", 79);
- Print("Level xxx (file version %08d, game version %08d)\n",
- level->file_version, level->game_version);
+ Print("Level xxx (file version %s, game version %s)\n",
+ getVersionString(level->file_version),
+ getVersionString(level->game_version));
PrintLine("-", 79);
Print("Level author: '%s'\n", level->author);
if (tape->file_version >= FILE_VERSION_1_2)
{
byte store_participating_players = getFile8Bit(file);
- int engine_version;
+ VersionType engine_version;
// since version 1.2, tapes store which players participate in the tape
tape->num_participating_players = 0;
tape.length_seconds = GetTapeLengthSeconds();
#if 0
- Debug("files:LoadTapeFromFilename", "tape file version: %d",
- tape.file_version);
- Debug("files:LoadTapeFromFilename", "tape game version: %d",
- tape.game_version);
- Debug("files:LoadTapeFromFilename", "tape engine version: %d",
- tape.engine_version);
+ Debug("files:LoadTapeFromFilename", "tape file version: %s",
+ getVersionString(tape.file_version));
+ Debug("files:LoadTapeFromFilename", "tape game version: %s",
+ getVersionString(tape.game_version));
+ Debug("files:LoadTapeFromFilename", "tape engine version: %s",
+ getVersionString(tape.engine_version));
#endif
}
PrintLine("-", 79);
- Print("Tape of Level %03d (file version %08d, game version %08d)\n",
- tape->level_nr, tape->file_version, tape->game_version);
- Print(" (effective engine version %08d)\n",
- tape->engine_version);
+ Print("Tape of Level %03d (file version %s, game version %s)\n",
+ tape->level_nr,
+ getVersionString(tape->file_version),
+ getVersionString(tape->game_version));
+ Print(" (effective engine version %s)\n",
+ getVersionString(tape->engine_version));
Print("Level series identifier: '%s'\n", tape->level_identifier);
Print("Solution tape: %s\n",
}
#if 0
- Debug("game:init:level", "level %d: level.game_version == %06d", level_nr,
- level.game_version);
- Debug("game:init:level", " tape.file_version == %06d",
- tape.file_version);
- Debug("game:init:level", " tape.game_version == %06d",
- tape.game_version);
- Debug("game:init:level", " tape.engine_version == %06d",
- tape.engine_version);
- Debug("game:init:level", " => game.engine_version == %06d [tape mode: %s]",
- game.engine_version, (tape.playing ? "PLAYING" : "RECORDING"));
+ Debug("game:init:level", "level %d: level.game_version == %s", level_nr,
+ getVersionString(level.game_version));
+ Debug("game:init:level", " tape.file_version == %s",
+ getVersionString(tape.file_version));
+ Debug("game:init:level", " tape.game_version == %s",
+ getVersionString(tape.game_version));
+ Debug("game:init:level", " tape.engine_version == %s",
+ getVersionString(tape.engine_version));
+ Debug("game:init:level", " => game.engine_version == %s [tape mode: %s]",
+ getVersionString(game.engine_version), (tape.playing ? "PLAYING" : "RECORDING"));
#endif
// --------------------------------------------------------------------------
boolean use_native_bd_sound_engine;
// constant within running game
- int engine_version;
+ VersionType engine_version;
int emulation;
int initial_move_delay[MAX_PLAYERS];
int initial_move_delay_value[MAX_PLAYERS];
struct LevelInfo_MM
{
- int file_version; // version of file the level was stored with
- int game_version; // version of game engine to play this level
+ VersionType file_version; // version of file the level was stored with
+ VersionType game_version; // version of game engine to play this level
boolean encoding_16bit_field; // level contains 16-bit elements
int fieldx;
// level file functions
// ============================================================================
-static void ReadChunk_MM_VERS(File *file, int *file_version, int *game_version)
+static void ReadChunk_MM_VERS(File *file, VersionType *file_version, VersionType *game_version)
{
- int file_version_major, file_version_minor, file_version_patch;
- int game_version_major, game_version_minor, game_version_patch;
+ VersionSubType file_version_major, file_version_minor, file_version_patch;
+ VersionSubType game_version_major, game_version_minor, game_version_patch;
file_version_major = getFile8Bit(file);
file_version_minor = getFile8Bit(file);
game_version_patch);
}
-static void WriteChunk_MM_VERS(FILE *file, int file_version, int game_version)
+static void WriteChunk_MM_VERS(FILE *file, VersionType file_version, VersionType game_version)
{
- int file_version_major = MM_VERSION_MAJOR(file_version);
- int file_version_minor = MM_VERSION_MINOR(file_version);
- int file_version_patch = MM_VERSION_PATCH(file_version);
- int game_version_major = MM_VERSION_MAJOR(game_version);
- int game_version_minor = MM_VERSION_MINOR(game_version);
- int game_version_patch = MM_VERSION_PATCH(game_version);
+ VersionSubType file_version_major = MM_VERSION_MAJOR(file_version);
+ VersionSubType file_version_minor = MM_VERSION_MINOR(file_version);
+ VersionSubType file_version_patch = MM_VERSION_PATCH(file_version);
+ VersionSubType game_version_major = MM_VERSION_MAJOR(game_version);
+ VersionSubType game_version_minor = MM_VERSION_MINOR(game_version);
+ VersionSubType game_version_patch = MM_VERSION_PATCH(game_version);
fputc(file_version_major, file);
fputc(file_version_minor, file);
clipboard_elements_initialized = TRUE;
}
-void InitElementPropertiesEngine(int engine_version)
+void InitElementPropertiesEngine(VersionType engine_version)
{
static int no_wall_properties[] =
{
void ResolveGroupElement(int);
void InitElementPropertiesStatic(void);
-void InitElementPropertiesEngine(int);
+void InitElementPropertiesEngine(VersionType);
void InitElementPropertiesGfxElement(void);
void ReloadCustomArtwork(int);
return num_bytes;
}
-int getFileVersion(File *file)
+VersionType getFileVersion(File *file)
{
- int version_super = getByteFromFile(file);
- int version_major = getByteFromFile(file);
- int version_minor = getByteFromFile(file);
- int version_patch = getByteFromFile(file);
+ VersionSubType version_super = getByteFromFile(file);
+ VersionSubType version_major = getByteFromFile(file);
+ VersionSubType version_minor = getByteFromFile(file);
+ VersionSubType version_patch = getByteFromFile(file);
- return VERSION_IDENT(version_super, version_major, version_minor,
- version_patch);
+ return VERSION_IDENT(version_super, version_major, version_minor, version_patch);
}
-int putFileVersion(FILE *file, int version)
+int putFileVersion(FILE *file, VersionType version)
{
if (file != NULL)
{
- int version_super = VERSION_SUPER(version);
- int version_major = VERSION_MAJOR(version);
- int version_minor = VERSION_MINOR(version);
- int version_patch = VERSION_PATCH(version);
+ VersionSubType version_super = VERSION_SUPER(version);
+ VersionSubType version_major = VERSION_MAJOR(version);
+ VersionSubType version_minor = VERSION_MINOR(version);
+ VersionSubType version_patch = VERSION_PATCH(version);
fputc(version_super, file);
fputc(version_major, file);
boolean getFileChunk(File *, char *, int *, int);
int putFileChunk(FILE *, char *, int, int);
-int getFileVersion(File *);
-int putFileVersion(FILE *, int);
+VersionType getFileVersion(File *);
+int putFileVersion(FILE *, VersionType);
void ReadBytesFromFile(File *, byte *, unsigned int);
void WriteBytesToFile(FILE *, byte *, unsigned int);
fprintf(file, "\n");
}
-int getFileVersionFromCookieString(const char *cookie)
+VersionType getFileVersionFromCookieString(const char *cookie)
{
const char *ptr_cookie1, *ptr_cookie2;
const char *pattern1 = "_FILE_VERSION_";
const int len_pattern1 = strlen(pattern1);
const int len_pattern2 = strlen(pattern2);
const int len_pattern = len_pattern1 + len_pattern2;
- int version_super, version_major;
+ VersionSubType version_super, version_major;
if (len_cookie <= len_pattern)
return -1;
void SetFilePermissions(char *, int);
void fprintFileHeader(FILE *, char *);
-int getFileVersionFromCookieString(const char *);
+VersionType getFileVersionFromCookieString(const char *);
boolean checkCookieString(const char *, const char *);
char *getFormattedSetupEntry(char *, char *);
char *config_filename, char *userdata_subdir,
char *program_basename, char *program_title,
char *icon_filename, char *cookie_prefix,
- char *program_version_string, int program_version)
+ char *program_version_string, VersionType program_version)
{
program.command_basepath = getBasePath(command_filename);
program.command_basename = getBaseName(command_filename);
}
+// ============================================================================
+// version functions
+// ============================================================================
+
+char *getVersionString(VersionType version)
+{
+ // this function can be called up to ten times before version string gets overwritten
+ static char version_string_array[10][32];
+ static int version_string_nr = 0;
+ char *version_string = version_string_array[version_string_nr];
+
+ version_string_nr = (version_string_nr + 1) % 10;
+
+ sprintf(version_string, "%d.%d.%d.%d",
+ VERSION_PART_1(version),
+ VERSION_PART_2(version),
+ VERSION_PART_3(version),
+ VERSION_PART_4(version));
+
+ return version_string;
+}
+
// ============================================================================
// Emscripten functions
// ============================================================================
// macros for version handling
-#define VERSION_PART_1(x) ((x) / 1000000)
-#define VERSION_PART_2(x) (((x) % 1000000) / 10000)
-#define VERSION_PART_3(x) (((x) % 10000) / 100)
-#define VERSION_PART_4(x) ((x) % 100)
+#define VERSION_PART_1(x) ((VersionSubType)(((x) >> 56) & 0xff))
+#define VERSION_PART_2(x) ((VersionSubType)(((x) >> 48) & 0xff))
+#define VERSION_PART_3(x) ((VersionSubType)(((x) >> 40) & 0xff))
+#define VERSION_PART_4(x) ((VersionSubType)(((x) >> 32) & 0xff))
#define VERSION_SUPER(x) VERSION_PART_1(x)
#define VERSION_MAJOR(x) VERSION_PART_2(x)
#define VERSION_MINOR(x) VERSION_PART_3(x)
#define VERSION_PATCH(x) VERSION_PART_4(x)
-#define VERSION_IDENT(a,b,c,d) ((a) * 1000000 + (b) * 10000 + (c) * 100 + (d))
+
+#define VERSION_IDENT(a,b,c,d) (((VersionType)(a) << 56) | \
+ ((VersionType)(b) << 48) | \
+ ((VersionType)(c) << 40) | \
+ ((VersionType)(d) << 32))
// macros for parent/child process identification
}
+// type definitions
+
+typedef unsigned long VersionType;
+typedef unsigned char VersionSubType;
+
+
// structure definitions
+struct VersionInfo
+{
+ // this structure is currently only used to document the content bytes of "VersionType"
+
+ // standard version info
+ VersionSubType super; // incremented for extraordinary changes (almost never)
+ VersionSubType major; // incremented for major changes
+ VersionSubType minor; // incremented for minor changes
+ VersionSubType patch; // incremented for bug fixes only
+
+ // extended version info
+ VersionSubType stable; // set to "1" for stable versions, "0" for test versions
+ VersionSubType extra; // set to extra (test or pre-release) version number
+ unsigned short build; // set to build number
+};
+
struct ProgramInfo
{
char *command_basepath; // path to the program binary
FILE *log_file; // file handle for log files
FILE *log_file_default; // default log file handle
- int version_super;
- int version_major;
- int version_minor;
- int version_patch;
- int version_ident;
+ VersionSubType version_super;
+ VersionSubType version_major;
+ VersionSubType version_minor;
+ VersionSubType version_patch;
+ VersionType version_ident;
char *version_string;
// function definitions
void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
- char *, int);
+ char *, VersionType);
void InitNetworkInfo(boolean, boolean, boolean, char *, int);
void InitRuntimeInfo(void);
boolean CheckJoystickOpened(int);
void ClearJoystickState(void);
+char *getVersionString(VersionType);
+
void InitEmscriptenFilesystem(void);
void SyncEmscriptenFilesystem(void);
struct ScoreInfo
{
- int file_version; // file format version the score is stored with
- int game_version; // game release version the score was created with
+ VersionType file_version; // file format version the score is stored with
+ VersionType game_version; // game release version the score was created with
char level_identifier[MAX_FILENAME_LEN + 1];
int level_nr;
struct LevelInfo_SP *native_sp_level;
struct LevelInfo_MM *native_mm_level;
- int file_version; // file format version the level is stored with
- int game_version; // game release version the level was created with
+ VersionType file_version; // file format version the level is stored with
+ VersionType game_version; // game release version the level was created with
struct DateInfo creation_date;
NULL
};
- static int patch_version_first[] =
+ static VersionType patch_version_first[] =
{
VERSION_IDENT(0,0,0,0),
VERSION_IDENT(3,3,1,0),
-1
};
- static int patch_version_last[] =
+ static VersionType patch_version_last[] =
{
VERSION_IDENT(9,9,9,9),
VERSION_IDENT(4,0,1,1),
struct TapeInfo
{
- int file_version; // file format version the tape is stored with
- int game_version; // game release version the tape was created with
- int engine_version; // game engine version the tape was recorded with
+ VersionType file_version; // file format version the tape is stored with
+ VersionType game_version; // game release version the tape was created with
+ VersionType engine_version; // game engine version the tape was recorded with
char score_tape_basename[MAX_FILENAME_LEN + 1];
char level_identifier[MAX_FILENAME_LEN + 1];