From c4ad8846190d6bdfb06e54548242c07713bc095d Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Wed, 2 Aug 2023 00:26:07 +0100 Subject: Filter out graphics backend window title suffixes --- src/gameinfo.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gameinfo.c b/src/gameinfo.c index 9a6686e..10959a6 100644 --- a/src/gameinfo.c +++ b/src/gameinfo.c @@ -14,6 +14,8 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#include + #include "engineapi.h" #include "errmsg.h" #include "gamedata.h" @@ -68,9 +70,17 @@ bool gameinfo_init(void) { // XXX: this same FindWindow call happens in ac.c - maybe factor out? void *gamewin = FindWindowW(L"Valve001", 0); // assuming: all games/mods use narrow chars only; this won't fail. - GetWindowTextA(gamewin, title, sizeof(title)); + int len = GetWindowTextA(gamewin, title, sizeof(title)); + // argh, why did they start doing this, it's so pointless! + // hopefully nobody included these suffixes in their mod names, lol + if (len > 13 && !memcmp(title + len - 13, " - Direct3D 9", 13)) { + title[len - 13] = '\0'; + } + else if (len > 9 && !memcmp(title + len - 9, " - Vulkan", 9)) { + title[len - 9] = '\0'; + } #else -#erorr TODO(linux): grab window handle and title from SDL (a bit involved...) +#error TODO(linux): grab window handle and title from SDL (a bit involved...) #endif } return true; -- cgit v1.2.3