From 0a37d478fdfd5e92db19894a7bc88a18fd637c76 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Tue, 7 May 2024 14:34:30 +1000 Subject: [PATCH] misc: engine version string polishing Updates engineversion when changing gamedirs, sets it earlier so it's more likely to be included in crash logs. Includes compiler in buildstring. Makes sure the engine can always be identified as DarkPlaces (many gamename values don't include it) by CSQC and in the console. Logs which API is in use when loading a csprogs. Signed-off-by: bones_was_here --- builddate.c | 24 +++++++++++++++++++----- com_game.c | 2 ++ csprogs.c | 3 ++- host.c | 15 ++++++++++----- host.h | 1 + prvm_edict.c | 3 ++- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/builddate.c b/builddate.c index 7106dc9b..268a9614 100644 --- a/builddate.c +++ b/builddate.c @@ -4,15 +4,29 @@ extern const char *buildstring; const char *buildstring = #ifdef VCREVISION -STRINGIFY(VCREVISION) + STRINGIFY(VCREVISION) #else -"-" + "-" #endif #ifndef NO_BUILD_TIMESTAMPS -//" " __TIME__ -" " __DATE__ +// " " __TIME__ + " " __DATE__ #endif #ifdef BUILDTYPE -" " STRINGIFY(BUILDTYPE) + " " STRINGIFY(BUILDTYPE) +#endif +#ifdef __clang__ // must be first because clang pretends to be GCC 4.2... + " Clang " +// STRINGIFY(__clang_major__) +// "." +// STRINGIFY(__clang_minor__) +#elifdef __GNUC__ + " GCC " +// STRINGIFY(__GNUC__) +// "." +// STRINGIFY(__GNUC_MINOR__) +#elifdef _MSC_VER + " MSC " +// STRINGIFY(_MSC_VER) #endif ; diff --git a/com_game.c b/com_game.c index 74ca8552..2969d391 100644 --- a/com_game.c +++ b/com_game.c @@ -180,6 +180,8 @@ double_break: Con_Printf("\n"); Con_Printf("gamename for server filtering: %s\n", gamenetworkfiltername); + + Host_UpdateVersion(); } return ret; } diff --git a/csprogs.c b/csprogs.c index da5bd77e..ac2fbf1b 100644 --- a/csprogs.c +++ b/csprogs.c @@ -1127,7 +1127,8 @@ void CL_VM_Init (void) if (PRVM_clientfunction(CSQC_Init)) { PRVM_G_FLOAT(OFS_PARM0) = 1.0f; // CSQC_SIMPLE engines always pass 0, FTE always passes 1 - PRVM_G_INT(OFS_PARM1) = PRVM_SetEngineString(prog, gamename); + // always include "DarkPlaces" so it can be recognised when gamename doesn't include it + PRVM_G_INT(OFS_PARM1) = PRVM_SetEngineString(prog, va(vabuf, sizeof(vabuf), "DarkPlaces %s", gamename)); PRVM_G_FLOAT(OFS_PARM2) = 1.0f; // TODO DP versions... prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Init), "QC function CSQC_Init is missing"); } diff --git a/host.c b/host.c index 7ce6406d..78536822 100644 --- a/host.c +++ b/host.c @@ -158,6 +158,11 @@ static void Host_Version_f(cmd_state_t *cmd) Con_Printf("Version: %s\n", engineversion); } +void Host_UpdateVersion(void) +{ + dpsnprintf(engineversion, sizeof(engineversion), "%s %s%s %s", gamename ? gamename : "DarkPlaces", DP_OS_NAME, cls.state == ca_dedicated ? " dedicated" : "", buildstring); +} + static void Host_Framerate_c(cvar_t *var) { if (var->value < 0.00001 && var->value != 0) @@ -293,7 +298,7 @@ static void Host_InitLocal (void) Cvar_RegisterVariable (&r_texture_jpeg_fastpicmip); } -char engineversion[128]; +char engineversion[128]; ///< version string for the corner of the console, crash messages, status command, etc static qfile_t *locksession_fh = NULL; @@ -429,6 +434,10 @@ static void Host_Init (void) if (Sys_CheckParm ("-dedicated") || !cl_available) cls.state = ca_dedicated; + // set and print initial version string (will be updated when gamename is changed) + Host_UpdateVersion(); // checks for cls.state == ca_dedicated + Con_Printf("%s\n", engineversion); + // initialize console command/cvar/alias/command execution systems Cmd_Init(); @@ -448,10 +457,6 @@ static void Host_Init (void) // initialize filesystem (including fs_basedir, fs_gamedir, -game, scr_screenshot_name, gamename) FS_Init(); - // ASAP! construct a version string for the corner of the console and for crash messages - dpsnprintf (engineversion, sizeof (engineversion), "%s %s%s, buildstring: %s", gamename, DP_OS_NAME, cls.state == ca_dedicated ? " dedicated" : "", buildstring); - Con_Printf("%s\n", engineversion); - // initialize process nice level Sys_InitProcessNice(); diff --git a/host.h b/host.h index 779ccc84..d826c0b4 100644 --- a/host.h +++ b/host.h @@ -57,6 +57,7 @@ extern host_static_t host; void Host_Main(void); void Host_Error(const char *error, ...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN; +void Host_UpdateVersion(void); void Host_LockSession(void); void Host_UnlockSession(void); void Host_AbortCurrentFrame(void) DP_FUNC_NORETURN; diff --git a/prvm_edict.c b/prvm_edict.c index 8b847f7b..4b732742 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -2712,7 +2712,8 @@ fail: // init mempools PRVM_MEM_Alloc(prog); - Con_Printf("%s: program loaded (crc %i, size %iK)\n", prog->name, prog->filecrc, (int)(filesize/1024)); + Con_Printf("%s: program loaded (crc %i, size %iK)%s\n", prog->name, prog->filecrc, (int)(filesize/1024), + prog == CLVM_prog ? (prog->flag & PRVM_CSQC_SIMPLE ? " CSQC_SIMPLE" : " EXT_CSQC") : ""); // Inittime is at least the time when this function finished. However, // later events may bump it. -- 2.39.2