summaryrefslogtreecommitdiffhomepage
path: root/src/gameinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gameinfo.c')
-rw-r--r--src/gameinfo.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/gameinfo.c b/src/gameinfo.c
index 85220a8..21205b7 100644
--- a/src/gameinfo.c
+++ b/src/gameinfo.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2024 Michael Smith <mikesmiffy128@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -15,11 +15,15 @@
*/
#include <string.h>
+#ifdef _WIN32
+#include <Windows.h> // MultiByteToWideChar()
+#endif
#include "engineapi.h"
#include "errmsg.h"
#include "gamedata.h"
#include "gametype.h"
+#include "langext.h"
#include "os.h"
#include "vcall.h"
@@ -38,7 +42,7 @@ const char *gameinfo_title = title;
DECL_VFUNC_DYN(const char *, GetGameDirectory)
bool gameinfo_init(void) {
- if (!has_vtidx_GetGameDirectory) {
+ if_cold (!has_vtidx_GetGameDirectory) {
errmsg_errorx("unsupported VEngineClient interface");
return false;
}
@@ -50,8 +54,8 @@ bool gameinfo_init(void) {
// using e.g. Cyrillic folder names and successfully loading their
// speedgames won't be able to load SST. Thanks Windows!
const char *lcpgamedir = GetGameDirectory(engclient);
- if (!MultiByteToWideChar(CP_ACP, 0, lcpgamedir, strlen(lcpgamedir), gamedir,
- sizeof(gamedir) / sizeof(*gamedir))) {
+ if_cold (!MultiByteToWideChar(CP_ACP, 0, lcpgamedir, strlen(lcpgamedir),
+ gamedir, countof(gamedir))) {
errmsg_errorsys("couldn't convert game directory path character set");
return false;
}
@@ -70,7 +74,7 @@ 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.
- int len = GetWindowTextA(gamewin, title, sizeof(title));
+ int len = GetWindowTextA(gamewin, title, ssizeof(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)) {