summaryrefslogtreecommitdiffhomepage
path: root/src/gameinfo.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2024-08-03 23:40:31 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2024-08-23 20:37:37 +0100
commit83da606072ce272eb053d4e1497d77e647cfecae (patch)
tree71d0110881ff8685184c5f4ab720cc8d49c24678 /src/gameinfo.c
parentacbd30e0427b16f885f96aed59881ec04eff25bc (diff)
Revise syntax macros and add a ton of branch hints
My new programming style is branch hints. All non-confusing branches must be hinted when I can be bothered. It's faster, sometimes, maybe. Also, start trying to use more signed sizes in at least some of the places where it makes sense. Unsigned sizes are surprisingly error-prone!
Diffstat (limited to 'src/gameinfo.c')
-rw-r--r--src/gameinfo.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/gameinfo.c b/src/gameinfo.c
index d535a44..21205b7 100644
--- a/src/gameinfo.c
+++ b/src/gameinfo.c
@@ -23,6 +23,7 @@
#include "errmsg.h"
#include "gamedata.h"
#include "gametype.h"
+#include "langext.h"
#include "os.h"
#include "vcall.h"
@@ -41,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;
}
@@ -53,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;
}
@@ -73,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)) {