From 99e0c48f7b85e06e25c4d1a96765ba7cad5a41e9 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 10 Jul 2020 22:39:46 -0700 Subject: [PATCH] Fix a lot of stuff related to the version automation --- src/d_clisrv.c | 4 ++-- src/d_main.c | 4 ++++ src/dehacked.c | 2 -- src/doomdef.h | 4 ++++ src/doomtype.h | 4 ++++ src/lua_script.c | 6 ++++++ src/mserv.c | 4 ++-- 7 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c7c5470ae..71e2e947e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2336,8 +2336,8 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room) if (server_list) { char version[8] = ""; -#if VERSION > 0 || SUBVERSION > 0 - snprintf(version, sizeof (version), "%d.%d.%d", VERSION/100, VERSION%100, SUBVERSION); +#ifndef DEVELOP + strcpy(version, SRB2VERSION); #else strcpy(version, GetRevisionString()); #endif diff --git a/src/d_main.c b/src/d_main.c index 22875593c..96167ac0b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -93,6 +93,10 @@ int snprintf(char *str, size_t n, const char *fmt, ...); #include "lua_script.h" +// Version numbers for netplay :upside_down_face: +int VERSION; +int SUBVERSION; + // platform independant focus loss UINT8 window_notinfocus = false; diff --git a/src/dehacked.c b/src/dehacked.c index 99d4883f6..d02dc3d24 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9484,8 +9484,6 @@ struct { {"PUSHACCEL",PUSHACCEL}, {"MODID",MODID}, // I don't know, I just thought it would be cool for a wad to potentially know what mod it was loaded into. {"CODEBASE",CODEBASE}, // or what release of SRB2 this is. - {"VERSION",VERSION}, // Grab the game's version! - {"SUBVERSION",SUBVERSION}, // more precise version number {"NEWTICRATE",NEWTICRATE}, // TICRATE*NEWTICRATERATIO {"NEWTICRATERATIO",NEWTICRATERATIO}, diff --git a/src/doomdef.h b/src/doomdef.h index 50e4b9b77..249bd5128 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -145,6 +145,8 @@ extern char logfilename[1024]; // Otherwise we can't force updates! #endif +#define VERSIONSTRINGW WSTRING (VERSIONSTRING) + /* A custom URL protocol for server links. */ #define SERVER_URL_PROTOCOL "srb2://" @@ -487,6 +489,8 @@ char *sizeu4(size_t num); char *sizeu5(size_t num); // d_main.c +extern int VERSION; +extern int SUBVERSION; extern boolean devparm; // development mode (-debug) // d_netcmd.c extern INT32 cv_debug; diff --git a/src/doomtype.h b/src/doomtype.h index 571e930e0..0aa3e23e0 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -367,4 +367,8 @@ typedef UINT32 tic_t; #define UINT2RGBA(a) (UINT32)((a&0xff)<<24)|((a&0xff00)<<8)|((a&0xff0000)>>8)|(((UINT32)a&0xff000000)>>24) #endif +/* preprocessor dumb and needs second macro to expand input */ +#define WSTRING2(s) L ## s +#define WSTRING(s) WSTRING2 (s) + #endif //__DOOMTYPE__ diff --git a/src/lua_script.c b/src/lua_script.c index 5fb153c0e..9d7d536b9 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -344,6 +344,12 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word,"gravity")) { lua_pushinteger(L, gravity); return 1; + } else if (fastcmp(word,"VERSION")) { + lua_pushinteger(L, VERSION); + return 1; + } else if (fastcmp(word,"SUBVERSION")) { + lua_pushinteger(L, SUBVERSION); + return 1; } else if (fastcmp(word,"VERSIONSTRING")) { lua_pushstring(L, VERSIONSTRING); return 1; diff --git a/src/mserv.c b/src/mserv.c index 05a5344ba..af5690788 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -754,8 +754,8 @@ static INT32 AddToMasterServer(boolean firstadd) strcpy(info->port, int2str(current_port)); strcpy(info->name, cv_servername.string); M_Memcpy(&info->room, & room, sizeof (INT32)); -#if VERSION > 0 || SUBVERSION > 0 - sprintf(info->version, "%d.%d.%d", VERSION/100, VERSION%100, SUBVERSION); +#ifndef DEVELOP + strcpy(info->version, SRB2VERSION); #else // Trunk build, send revision info strcpy(info->version, GetRevisionString()); #endif