]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
misc: engine version string polishing
authorbones_was_here <bones_was_here@xonotic.au>
Tue, 7 May 2024 04:34:30 +0000 (14:34 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Thu, 9 May 2024 03:07:37 +0000 (13:07 +1000)
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 <bones_was_here@xonotic.au>
builddate.c
com_game.c
csprogs.c
host.c
host.h
prvm_edict.c

index 7106dc9b669e41a19a90e92c539e150da6f6f1cd..268a9614b35aadf1a2a2d22f7ef39e5fb0af0630 100644 (file)
@@ -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
 ;
index 74ca8552af296c973a97bceb5660804141cbce64..2969d3913a7b73a9de30d7ba2b909f83c22507a3 100644 (file)
@@ -180,6 +180,8 @@ double_break:
                Con_Printf("\n");
 
                Con_Printf("gamename for server filtering: %s\n", gamenetworkfiltername);
+
+               Host_UpdateVersion();
        }
        return ret;
 }
index da5bd77eeff2f768aa7b3a723166a58c0eddc915..ac2fbf1ba062063b2da56541053575529be59f20 100644 (file)
--- 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 7ce6406d21faeee15b6749d5b9ba9b0431b8d565..7853682274ca4090ec49a981e3ecdcee09afd1d6 100644 (file)
--- 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 779ccc842b370af6082205885ac2e6619334632b..d826c0b4d7534b61a97065f89ad19ac0fdd7224f 100644 (file)
--- 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;
index 8b847f7be41ebf21044b3061aea0a99c3177db5a..4b732742fada18c2a07e3c8665dca09defbe47a8 100644 (file)
@@ -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.