summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2023-08-02 00:26:07 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2023-08-02 21:02:31 +0100
commitc4ad8846190d6bdfb06e54548242c07713bc095d (patch)
tree93be6a24c6fe0aaaac8084c442f771d5764074bb /src
parentef84ee88045a509acb65c148220ad12b81a35b80 (diff)
Filter out graphics backend window title suffixes
Diffstat (limited to 'src')
-rw-r--r--src/gameinfo.c14
1 files 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 <string.h>
+
#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;