From 3918d3ba3483c2b6b35547209e01418c811adec4 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Fri, 27 Jul 2012 08:57:52 +0200 Subject: [PATCH] Change the VERSION number from float to string Using a float number as version number is a bad idea. Correct this long standing problem by changing it to a string. If we ever want to compare version numbers, 2 integer constants "MAJOR_VERSION" and "MINOR_VERSION" should be added. --- src/client/cl_console.c | 2 +- src/common/header/common.h | 4 +++- src/common/misc.c | 2 +- src/sdl/refresh.c | 2 +- src/server/sv_conless.c | 2 +- src/unix/main.c | 2 +- src/unix/signalhandler.c | 4 ++-- src/windows/system.c | 2 +- 8 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/client/cl_console.c b/src/client/cl_console.c index bc55530f..e96108b2 100644 --- a/src/client/cl_console.c +++ b/src/client/cl_console.c @@ -624,7 +624,7 @@ Con_DrawConsole(float frac) SCR_AddDirtyPoint(0, 0); SCR_AddDirtyPoint(viddef.width - 1, lines - 1); - Com_sprintf(version, sizeof(version), "Yamagi Quake II v%4.2f", VERSION); + Com_sprintf(version, sizeof(version), "Yamagi Quake II v%s", VERSION); for (x = 0; x < 21; x++) { diff --git a/src/common/header/common.h b/src/common/header/common.h index 080d2f93..99672ba9 100644 --- a/src/common/header/common.h +++ b/src/common/header/common.h @@ -32,7 +32,9 @@ #include "shared.h" #include "crc.h" -#define VERSION 4.90 +/* Should have 4 characters. */ +#define VERSION "4.90" + #define BASEDIRNAME "baseq2" #if defined __linux__ diff --git a/src/common/misc.c b/src/common/misc.c index 1805a066..fdde28a0 100644 --- a/src/common/misc.c +++ b/src/common/misc.c @@ -241,7 +241,7 @@ Qcommon_Init(int argc, char **argv) dedicated = Cvar_Get("dedicated", "0", CVAR_NOSET); #endif - s = va("%4.2f %s %s %s", VERSION, CPUSTRING, __DATE__, BUILDSTRING); + s = va("%s %s %s %s", VERSION, CPUSTRING, __DATE__, BUILDSTRING); Cvar_Get("version", s, CVAR_SERVERINFO | CVAR_NOSET); if (dedicated->value) diff --git a/src/sdl/refresh.c b/src/sdl/refresh.c index ebd6d65f..47f64d07 100644 --- a/src/sdl/refresh.c +++ b/src/sdl/refresh.c @@ -292,7 +292,7 @@ GLimp_InitGraphics(qboolean fullscreen) #endif /* Window title */ - snprintf(title, sizeof(title), "Yamagi Quake II %4.2f", VERSION); + snprintf(title, sizeof(title), "Yamagi Quake II %s", VERSION); SDL_WM_SetCaption(title, title); /* No cursor */ diff --git a/src/server/sv_conless.c b/src/server/sv_conless.c index 050e7379..e643b7b9 100644 --- a/src/server/sv_conless.c +++ b/src/server/sv_conless.c @@ -172,7 +172,7 @@ SVC_DirectConnect(void) if (version != PROTOCOL_VERSION) { Netchan_OutOfBandPrint(NS_SERVER, adr, - "print\nServer is version %4.2f.\n", VERSION); + "print\nServer is version %s.\n", VERSION); Com_DPrintf(" rejected connect from version %i\n", version); return; } diff --git a/src/unix/main.c b/src/unix/main.c index 8ee990d3..4c90042b 100644 --- a/src/unix/main.c +++ b/src/unix/main.c @@ -68,7 +68,7 @@ main(int argc, char **argv) /* enforce C locale */ setenv("LC_ALL", "C", 1); - printf("\nYamagi Quake II v%4.2f\n", VERSION); + printf("\nYamagi Quake II v%s\n", VERSION); printf("=====================\n\n"); #ifndef DEDICATED_ONLY diff --git a/src/unix/signalhandler.c b/src/unix/signalhandler.c index 15e48161..a0b55d42 100644 --- a/src/unix/signalhandler.c +++ b/src/unix/signalhandler.c @@ -47,7 +47,7 @@ printBacktrace(int sig) strings = backtrace_symbols(array, size); printf("Product: Yamagi Quake II\n"); - printf("Version: %4.2f\n", VERSION); + printf("Version: %s\n", VERSION); printf("Plattform: %s\n", BUILDSTRING); printf("Architecture: %s\n", CPUSTRING); printf("Compiler: %s\n", __VERSION__); @@ -68,7 +68,7 @@ void printBacktrace(int sig) { printf("Product: Yamagi Quake II\n"); - printf("Version: %4.2f\n", VERSION); + printf("Version: %s\n", VERSION); printf("Plattform: %s\n", BUILDSTRING); printf("Architecture: %s\n", CPUSTRING); printf("Compiler: %s\n", __VERSION__); diff --git a/src/windows/system.c b/src/windows/system.c index 19560477..76321eb8 100644 --- a/src/windows/system.c +++ b/src/windows/system.c @@ -711,7 +711,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, Sys_RedirectStdout(); #endif - printf("Yamagi Quake II v%4.2f\n", VERSION); + printf("Yamagi Quake II v%s\n", VERSION); printf("=====================\n\n"); #ifndef DEDICATED_ONLY