From e673301dfb35ddec72c6c7bff2ae9ceb6f0a225a Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Tue, 28 Nov 2023 00:31:33 +0200 Subject: [PATCH] renders: fix maps with hardcoded image extensions --- src/client/refresh/files/stb.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/client/refresh/files/stb.c b/src/client/refresh/files/stb.c index 0a26d681..38b48644 100644 --- a/src/client/refresh/files/stb.c +++ b/src/client/refresh/files/stb.c @@ -597,6 +597,7 @@ R_LoadImage(const char *name, const char* namewe, const char *ext, imagetype_t t /* original name */ image = LoadImage_Ext(name, namewe, ext, type, r_retexturing, load_image); + /* pcx check */ if (!image) { @@ -672,7 +673,6 @@ GetSkyImage(const char *skyname, const char* surfname, qboolean palettedtexture, struct image_s * GetTexImage(const char *name, findimage_t find_image) { - struct image_s *image = NULL; char pathname[MAX_QPATH]; /* Quake 2 */ @@ -688,10 +688,36 @@ R_FindPic(const char *name, findimage_t find_image) if ((name[0] != '/') && (name[0] != '\\')) { char pathname[MAX_QPATH]; + char namewe[MAX_QPATH]; + const char* ext; + + ext = COM_FileExtension(name); + if(!ext[0]) + { + /* file has no extension */ + strncpy(namewe, name, MAX_QPATH); + } + else + { + int len; + + len = strlen(name); + + /* Remove the extension */ + memset(namewe, 0, MAX_QPATH); + memcpy(namewe, name, len - (strlen(ext) + 1)); + } /* Quake 2 */ - Com_sprintf(pathname, sizeof(pathname), "pics/%s.pcx", name); + Com_sprintf(pathname, sizeof(pathname), "pics/%s.pcx", namewe); image = find_image(pathname, it_pic); + + /* Heretic 2 */ + if (!image) + { + Com_sprintf(pathname, sizeof(pathname), "pics/misc/%s.m32", name); + image = find_image(pathname, it_pic); + } } else {