From 92d6c2b7b0143945033b10bb99596c89a1cea5fc Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Sep 2025 10:15:20 +0200 Subject: [PATCH 1/2] make patch/pixel conversion account for padding data/no data just set everything to transparent pixel 247 (0xf7) so we neither write nor read garbage data and just can cut it out as transparent during pixel to patch conversion --- src/r_patch.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/r_patch.c b/src/r_patch.c index 3f7fdc983..d8e0b94f3 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -491,6 +491,16 @@ void *R_PixelsToPatch(UINT8 *raw, INT16 width, INT16 height, INT16 leftoffset, I for (y = 0; y < height; y++) { UINT8 pixel = raw[((y * width) + x)]; + UINT8 opaque = (pixel != 0xf7); // If not 247 (0xf7), we have a pixel + + // End span if we have a transparent pixel + if (!opaque) + { + if (startofspan) + WRITEUINT8(imgptr, 0); + startofspan = NULL; + continue; + } // Start new column if we need to if (!startofspan || spanSize == 255) @@ -728,6 +738,9 @@ void R_PatchToPixels(patch_t *patch, UINT8 *dst) { const INT16 width = patch->width; + // init out destination to cyan so we can easily check for it when we convert it back to a patch + memset(dst, 0xf7, (width * patch->height)); // should this be here or should this be taken care of before passing it? + for (INT32 x = 0; x < width; ++x) { INT32 y = 0; From 85cac497ea2e1ef1a7ca793ae4abfb8d31710b7d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Sep 2025 12:25:41 +0200 Subject: [PATCH 2/2] fixup building map title string for serverinfo fixes numerous issues, like zonetitle not appearing on bots and serverinfo screen and generally making this more sane by appending stuff if needed also fixes "Zone" not displaying in serverinfo screen --- src/d_clisrv.c | 69 +++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f8bf137f9..67799fd62 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1341,7 +1341,11 @@ static inline void CL_DrawConnectionStatus(void) patch_t *current_map = W_LumpExists(map) ? W_CachePatchName(map, PU_CACHE) : W_CachePatchName("BLANKLVL", PU_CACHE); V_DrawSmallScaledPatch(10, 18, 0, current_map); - V_DrawThinString(12 + 80, 38, V_ALLOWLOWERCASE, va("%s", serverlist[joinnode].info.maptitle)); + if (serverlist[joinnode].info.iszone) + V_DrawThinString(12 + 80, 38, V_ALLOWLOWERCASE, va("%s Zone", serverlist[joinnode].info.maptitle)); + else + V_DrawThinString(12 + 80, 38, V_ALLOWLOWERCASE, va("%s", serverlist[joinnode].info.maptitle)); + V_DrawThinString(12 + 80, 48, V_ALLOWLOWERCASE, va("%s", Gametype_Names[serverlist[joinnode].info.gametype])); if (fileneedednum > 0) @@ -1581,59 +1585,38 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) CopyCaretColors(netbuffer->u.serverinfo.servername, cv_servername.string, MAXSERVERNAME); - strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), 7); + strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), sizeof(netbuffer->u.serverinfo.mapname)-1); - M_Memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, 16); + M_Memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, sizeof(netbuffer->u.serverinfo.mapmd5)); - if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) && !(mapheaderinfo[prevmap]->zonttl[0])) - netbuffer->u.serverinfo.iszone = 1; - else - netbuffer->u.serverinfo.iszone = 0; + netbuffer->u.serverinfo.iszone = 0; - memset(netbuffer->u.serverinfo.maptitle, 0, 33); + memset(netbuffer->u.serverinfo.maptitle, 0, sizeof(netbuffer->u.serverinfo.maptitle)); memset(netbuffer->u.serverinfo.httpsource, 0, MAX_MIRROR_LENGTH); if (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) && mapheaderinfo[gamemap-1]->lvlttl[0]) { - //strncpy(netbuffer->u.serverinfo.maptitle, (char *)mapheaderinfo[gamemap-1]->lvlttl, 33); - // set up the levelstring - if (netbuffer->u.serverinfo.iszone || (mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) + strncpy(netbuffer->u.serverinfo.maptitle, mapheaderinfo[gamemap-1]->lvlttl, sizeof(netbuffer->u.serverinfo.maptitle)-1); + + if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) { - if (mapheaderinfo[gamemap-1]->actnum[0]) - snprintf(netbuffer->u.serverinfo.maptitle, - 33, - "%s %s", - mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->actnum); + if (mapheaderinfo[gamemap-1]->zonttl[0]) + { + strncat(netbuffer->u.serverinfo.maptitle, " ", sizeof(netbuffer->u.serverinfo.maptitle)-1); + strncat(netbuffer->u.serverinfo.maptitle, mapheaderinfo[gamemap-1]->zonttl, + sizeof(netbuffer->u.serverinfo.maptitle)-1); + } else - snprintf(netbuffer->u.serverinfo.maptitle, - 33, - "%s", - mapheaderinfo[gamemap-1]->lvlttl); + { + netbuffer->u.serverinfo.iszone = 1; // ms and clients will append this themselves + } } - else + + if (mapheaderinfo[gamemap-1]->actnum[0]) { - if (mapheaderinfo[gamemap-1]->actnum[0]) - { - if (snprintf(netbuffer->u.serverinfo.maptitle, - 33, - "%s %s %s", - mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl, mapheaderinfo[gamemap-1]->actnum) < 0) - { - // If there's an encoding error, send UNKNOWN, we accept that the above may be truncated - strncpy(netbuffer->u.serverinfo.maptitle, "Unknown", 33); - } - } - else - { - if (snprintf(netbuffer->u.serverinfo.maptitle, - 33, - "%s %s", - mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl) < 0) - { - // If there's an encoding error, send UNKNOWN, we accept that the above may be truncated - strncpy(netbuffer->u.serverinfo.maptitle, "Unknown", 33); - } - } + strncat(netbuffer->u.serverinfo.maptitle, " ", sizeof(netbuffer->u.serverinfo.maptitle)-1); + strncat(netbuffer->u.serverinfo.maptitle, mapheaderinfo[gamemap-1]->actnum, + sizeof(netbuffer->u.serverinfo.maptitle)-1); } } else