]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Fix worldmessage string truncation
authorbones_was_here <bones_was_here@xonotic.au>
Fri, 29 Dec 2023 09:35:25 +0000 (19:35 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Sun, 21 Jan 2024 07:00:45 +0000 (17:00 +1000)
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
client.h
sbar.c
server.h
sv_main.c

index a7b275caa73c589ca04fa14ef318d0e7222447ab..02ac81ff35de02a1407dc236538649e33a6a08f9 100644 (file)
--- a/client.h
+++ b/client.h
@@ -894,7 +894,7 @@ typedef struct client_state_s
        char sound_name[MAX_SOUNDS][MAX_QPATH];
 
        // for display on solo scoreboard
-       char worldmessage[40]; // map title (not related to filename)
+       char worldmessage[MAX_QPATH]; // map title (not related to filename)
        // variants of map name
        char worldbasename[MAX_QPATH]; // %s
        char worldname[MAX_QPATH]; // maps/%s.bsp
diff --git a/sbar.c b/sbar.c
index 88ccfc3134e8d88b9df00d2ba053c830c08ec13c..7b914d84882100e9f61988ff0738c90d854294ec 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -682,7 +682,7 @@ static void Sbar_SoloScoreboard (void)
                Sbar_DrawString(8+22*8, 4, va(vabuf, sizeof(vabuf), "Secrets:%3i", cl.stats[STAT_SECRETS]));
 
        // format is like this: e1m1:The Sligpate Complex
-       dpsnprintf(str, sizeof(str), "%s:%s", cl.worldbasename, cl.worldmessage);
+       dpsnprintf(str, sizeof(str), "%s:%.39s", cl.worldbasename, cl.worldmessage);
 
        // if there's a newline character, terminate the string there
        if (strchr(str, '\n'))
index d1cdb1ab1ebf73cf8f6af16d5f0e07386c543d4c..729418d9410a152713eac3f3d9c5b67f9b244a0d 100644 (file)
--- a/server.h
+++ b/server.h
@@ -108,7 +108,6 @@ typedef struct server_s
        /// map name
        char name[64]; // %s followed by entrance name
        // variants of map name
-       char worldmessage[40]; // map title (not related to filename)
        char worldbasename[MAX_QPATH]; // %s
        char worldname[MAX_QPATH]; // maps/%s.bsp
        char worldnamenoextension[MAX_QPATH]; // maps/%s
index 8dad80edb2893d46ee50fe21c9382567a81502f8..65ba374dc84ffe15bd195b1d5ae8026351dd8679 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -2091,9 +2091,8 @@ void SV_SpawnServer (const char *map)
                }
        }
 
-       // update the map title cvar
-       dp_strlcpy(sv.worldmessage, PRVM_GetString(prog, PRVM_serveredictstring(prog->edicts, message)), sizeof(sv.worldmessage)); // map title (not related to filename)
-       Cvar_SetQuick(&sv_worldmessage, sv.worldmessage);
+       // update the map title cvar (not related to filename)
+       Cvar_SetQuick(&sv_worldmessage, PRVM_GetString(prog, PRVM_serveredictstring(prog->edicts, message)));
 
        Con_Printf("Server spawned.\n");
        NetConn_Heartbeat (2);