Implement table saving functionality
This commit is contained in:
@ -55,8 +55,24 @@ static void _run_game(struct game_data *game) {
|
||||
}
|
||||
|
||||
static void _run_tx(struct game_data *game, wchar_t *tableFile) {
|
||||
// Load unpatched base module
|
||||
HMODULE baseModule = LoadLibraryA(game->base_module_name);
|
||||
if (!baseModule) {
|
||||
msg_err_a("Failed to load base module: %s", game->base_module_name);
|
||||
}
|
||||
|
||||
// ...more magic
|
||||
size_t tableSize;
|
||||
void *table = core_perform_tx(&tableSize);
|
||||
|
||||
// Save to file
|
||||
utils_create_dir_recursively(tableFile);
|
||||
utils_save_to_file(tableFile, table, tableSize);
|
||||
|
||||
// Cleanup
|
||||
free(table);
|
||||
|
||||
// The file should now exist: restart and launch the game
|
||||
request_restart();
|
||||
exit(0);
|
||||
}
|
||||
@ -80,10 +96,7 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) {
|
||||
wchar_t tableFile[MAX_PATH];
|
||||
tx_table_file(&game, tableFile);
|
||||
|
||||
// Remove this
|
||||
msg_err_w(tableFile);
|
||||
|
||||
if (1) {
|
||||
if (utils_path_exists(tableFile)) {
|
||||
_run_game(&game);
|
||||
} else {
|
||||
_run_tx(&game, tableFile);
|
||||
|
||||
Reference in New Issue
Block a user