jadeite/game_payload/src/game.c

33 lines
708 B
C
Raw Normal View History

2023-06-08 18:44:42 +00:00
#include <msg.h>
2023-06-05 21:23:08 +00:00
#include <game.h>
2023-06-08 15:36:22 +00:00
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 }
};
2023-06-05 21:23:08 +00:00
void game_detect(struct game_data *buf) {
2023-06-08 15:36:22 +00:00
char exePath[MAX_PATH];
GetModuleFileNameA(NULL, exePath, MAX_PATH);
2023-06-05 21:23:08 +00:00
2023-06-08 15:36:22 +00:00
char *exeName = strrchr(exePath, '\\') + 1;
strlwr(exeName);
2023-06-05 21:23:08 +00:00
2023-06-08 15:36:22 +00:00
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;
}
2023-06-05 21:23:08 +00:00
}
2023-06-08 15:36:22 +00:00
2023-06-08 18:44:42 +00:00
msg_err_a("Unknown game: %s", exeName);
2023-06-05 21:23:08 +00:00
}