Initial HSR support

This commit is contained in:
mkrsym1
2023-06-08 18:36:22 +03:00
parent 88568b374d
commit 006ff30914
5 changed files with 75 additions and 14 deletions

View File

@ -2,17 +2,31 @@
#include <game.h>
typedef void (*fill_fn)(struct game_data *buf);
struct name_fn_pair {
const char *name;
fill_fn fill;
};
const struct name_fn_pair GAMES[] = {
{ "bh3.exe", &hi3_fill_data },
{ "starrail.exe", &hsr_fill_data }
};
void game_detect(struct game_data *buf) {
wchar_t exePath[MAX_PATH];
GetModuleFileNameW(NULL, exePath, MAX_PATH);
char exePath[MAX_PATH];
GetModuleFileNameA(NULL, exePath, MAX_PATH);
wchar_t *exeName = wcsrchr(exePath, L'\\') + 1;
wcslwr(exeName);
char *exeName = strrchr(exePath, '\\') + 1;
strlwr(exeName);
// Only HI3 is supported for now
if (wcscmp(exeName, L"bh3.exe") == 0) {
hi3_fill_data(buf);
} else {
err_mb_w(L"Unknown game: %ls", exeName);
for (size_t i = 0; i < sizeof(GAMES) / sizeof(struct name_fn_pair); i++) {
if (strcmp(exeName, GAMES[i].name) == 0) {
GAMES[i].fill(buf);
return;
}
}
err_mb_a("Unknown game: %s", exeName);
}