From 28e47bb8368e2e1dd9fbcd1bcb50a359510bb9ec Mon Sep 17 00:00:00 2001 From: bucanero Date: Tue, 11 Jun 2024 11:08:08 -0300 Subject: [PATCH] clean-up --- include/cheats.h | 2 - include/menu.h | 2 - source/cheats.c | 168 ---------------------------------------------- source/exec_cmd.c | 7 +- 4 files changed, 4 insertions(+), 175 deletions(-) diff --git a/include/cheats.h b/include/cheats.h index 486c9d6..d42a4fd 100644 --- a/include/cheats.h +++ b/include/cheats.h @@ -160,7 +160,6 @@ typedef struct list_t* (*ReadList)(const char*); } game_list_t; -list_t * ReadUsbList(const char* userPath); list_t * ReadUserList(const char* userPath); list_t * ReadOnlineList(const char* urlPath); list_t * ReadBackupList(const char* userPath); @@ -198,7 +197,6 @@ void execCodeCommand(code_entry_t* code, const char* codecmd); uint64_t patch_hash_calc(const game_entry_t* game, const code_entry_t* code); char* mc4_decrypt(const char* data); -int get_save_details(const game_entry_t *save, char** details); int orbis_SaveUmount(const char* mountPath); int orbis_UpdateSaveParams(const char* mountPath, const char* title, const char* subtitle, const char* details); diff --git a/include/menu.h b/include/menu.h index 7eb6279..9ef7381 100644 --- a/include/menu.h +++ b/include/menu.h @@ -153,11 +153,9 @@ void drawEndLogo(); int load_app_settings(app_config_t* config); int save_app_settings(app_config_t* config); -int reset_app_settings(app_config_t* config); int initialize_jbc(); void terminate_jbc(); -int patch_save_libraries(); void initMenuOptions(); #endif diff --git a/source/cheats.c b/source/cheats.c index 4fc70bd..611dc60 100644 --- a/source/cheats.c +++ b/source/cheats.c @@ -1131,26 +1131,6 @@ list_t * ReadUserList(const char* userPath) list = list_alloc(); -/* - item = createGameEntry(CHEAT_FLAG_PS4, CHAR_ICON_COPY " Bulk Cheats Management"); - item->type = FILE_TYPE_MENU; - item->codes = list_alloc(); - item->path = strdup(userPath); -// item->path = (void*) list; //bulk management hack - - cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_SIGN " Resign & Unlock all Saves", CMD_RESIGN_ALL_SAVES); - list_append(item->codes, cmd); - - cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_COPY " Copy all Saves to USB", CMD_CODE_NULL); - cmd->options_count = 1; - cmd->options = _createOptions(2, "Copy Saves to USB", CMD_COPY_SAVES_USB); - list_append(item->codes, cmd); - - cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_LOCK " Dump all Save Fingerprints", CMD_DUMP_FINGERPRINTS); - list_append(item->codes, cmd); - list_append(list, item); -*/ - LOG("Loading JSON files..."); snprintf(fullPath, sizeof(fullPath), "%sjson/", userPath); read_json_games(fullPath, list); @@ -1271,151 +1251,3 @@ list_t * ReadOnlineList(const char* urlPath) check_game_appdb(list); return list; } - -int get_save_details(const game_entry_t* save, char **details) -{ -/* - char sfoPath[256]; - sqlite3 *db; - sqlite3_stmt *res; - - - if (!(save->flags & CHEAT_FLAG_PS4)) - { - asprintf(details, "%s\n\nTitle: %s\n", save->path, save->name); - return 1; - } - - if (save->flags & CHEAT_FLAG_TROPHY) - { - if ((db = open_sqlite_db(save->path)) == NULL) - return 0; - - char* query = sqlite3_mprintf("SELECT id, description, trophy_num, unlocked_trophy_num, progress," - "platinum_num, unlocked_platinum_num, gold_num, unlocked_gold_num, silver_num, unlocked_silver_num," - "bronze_num, unlocked_bronze_num FROM tbl_trophy_title WHERE id = %d", save->blocks); - - if (sqlite3_prepare_v2(db, query, -1, &res, NULL) != SQLITE_OK || sqlite3_step(res) != SQLITE_ROW) - { - LOG("Failed to fetch data: %s", sqlite3_errmsg(db)); - sqlite3_free(query); - sqlite3_close(db); - return 0; - } - - asprintf(details, "Trophy-Set Details\n\n" - "Title: %s\n" - "Description: %s\n" - "NP Comm ID: %s\n" - "Progress: %d/%d - %d%%\n" - "%c Platinum: %d/%d\n" - "%c Gold: %d/%d\n" - "%c Silver: %d/%d\n" - "%c Bronze: %d/%d\n", - save->name, sqlite3_column_text(res, 1), save->title_id, - sqlite3_column_int(res, 3), sqlite3_column_int(res, 2), sqlite3_column_int(res, 4), - CHAR_TRP_PLATINUM, sqlite3_column_int(res, 6), sqlite3_column_int(res, 5), - CHAR_TRP_GOLD, sqlite3_column_int(res, 8), sqlite3_column_int(res, 7), - CHAR_TRP_SILVER, sqlite3_column_int(res, 10), sqlite3_column_int(res, 9), - CHAR_TRP_BRONZE, sqlite3_column_int(res, 12), sqlite3_column_int(res, 11)); - - sqlite3_free(query); - sqlite3_finalize(res); - sqlite3_close(db); - - return 1; - } - - if(save->flags & CHEAT_FLAG_LOCKED) - { - asprintf(details, "%s\n\n" - "Title ID: %s\n" - "Dir Name: %s\n" - "Blocks: %d\n" - "Account ID: %.16s\n", - save->path, - save->title_id, - save->version, - save->blocks, - save->path + 23); - - return 1; - } - - if(save->flags & CHEAT_FLAG_HDD) - { - if ((db = open_sqlite_db(save->path)) == NULL) - return 0; - - char* query = sqlite3_mprintf("SELECT sub_title, detail, free_blocks, size_kib, user_id, account_id FROM savedata " - " WHERE title_id = %Q AND dir_name = %Q", save->title_id, save->version); - - if (sqlite3_prepare_v2(db, query, -1, &res, NULL) != SQLITE_OK || sqlite3_step(res) != SQLITE_ROW) - { - LOG("Failed to fetch data: %s", sqlite3_errmsg(db)); - sqlite3_free(query); - sqlite3_close(db); - return 0; - } - - asprintf(details, "%s\n\n" - "Title: %s\n" - "Subtitle: %s\n" - "Detail: %s\n" - "Dir Name: %s\n" - "Blocks: %d (%d Free)\n" - "Size: %d Kb\n" - "User ID: %08x\n" - "Account ID: %016llx\n", - save->path, save->name, - sqlite3_column_text(res, 0), - sqlite3_column_text(res, 1), - save->version, - save->blocks, sqlite3_column_int(res, 2), - sqlite3_column_int(res, 3), - sqlite3_column_int(res, 4), - sqlite3_column_int64(res, 5)); - - sqlite3_free(query); - sqlite3_finalize(res); - sqlite3_close(db); - - return 1; - } - - snprintf(sfoPath, sizeof(sfoPath), "%s" "sce_sys/param.sfo", save->path); - LOG("Save Details :: Reading %s...", sfoPath); - - sfo_context_t* sfo = sfo_alloc(); - if (sfo_read(sfo, sfoPath) < 0) { - LOG("Unable to read from '%s'", sfoPath); - sfo_free(sfo); - return 0; - } - - char* subtitle = (char*) sfo_get_param_value(sfo, "SUBTITLE"); - char* detail = (char*) sfo_get_param_value(sfo, "DETAIL"); - uint64_t* account_id = (uint64_t*) sfo_get_param_value(sfo, "ACCOUNT_ID"); - sfo_params_ids_t* param_ids = (sfo_params_ids_t*) sfo_get_param_value(sfo, "PARAMS"); - - asprintf(details, "%s\n\n" - "Title: %s\n" - "Subtitle: %s\n" - "Detail: %s\n" - "Dir Name: %s\n" - "Blocks: %d\n" - "User ID: %08x\n" - "Account ID: %016lx\n", - save->path, save->name, - subtitle, - detail, - save->version, - save->blocks, - param_ids->user_id, - *account_id); - - sfo_free(sfo); -*/ - asprintf(details, "%s\n", save->path); - return 1; -} diff --git a/source/exec_cmd.c b/source/exec_cmd.c index 5065c6e..81c88fd 100644 --- a/source/exec_cmd.c +++ b/source/exec_cmd.c @@ -49,7 +49,7 @@ static void togglePatch(const game_entry_t* game, const code_entry_t* code) show_message("Patch \"%s\" %s", code->name, code->activated ? "Enabled" : "Disabled"); } -static void toggleCheatFile(game_entry_t* game) +static void toggleCheatFile(game_entry_t* game, code_entry_t* code) { char file_path[256]; @@ -70,8 +70,9 @@ static void toggleCheatFile(game_entry_t* game) game->flags ^= CHEAT_FLAG_LOCKED; free(game->path); asprintf(&game->path, "%s", file_path); + memcpy(code->name +1, (game->flags & CHEAT_FLAG_LOCKED) ? "Dis" : " En", 3); - show_message("Cheat File \"%s\" %s", game->name, (game->flags & CHEAT_FLAG_LOCKED) ? "Disabled" : "Enabled"); + show_message("Cheat File %s:\n%s", (game->flags & CHEAT_FLAG_LOCKED) ? "Disabled" : "Enabled", game->path); } static void updNetCheats(void) @@ -392,7 +393,7 @@ void execCodeCommand(code_entry_t* code, const char* codecmd) break; case CMD_TOGGLE_CHEAT: - toggleCheatFile(selected_entry); + toggleCheatFile(selected_entry, code); return; case CMD_TOGGLE_PATCH: