Skip to content

Commit 7fcc225

Browse files
authored
remove trophy sets (#198)
1 parent bf8efa6 commit 7fcc225

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

include/saves.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ int orbis_UpdateSaveParams(const save_entry_t* save, const char* title, const ch
317317

318318
int trophy_lock(const save_entry_t* game, int trp_id, int grp_id, int type);
319319
int trophy_unlock(const save_entry_t* game, int trp_id, int grp_id, int type);
320+
int trophySet_delete(const save_entry_t* game);
320321

321322
int vmc_export_psv(const char* save, const char* out_path);
322323
int vmc_export_psu(const char* path, const char* output);

source/exec_cmd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,9 @@ static int deleteSave(const save_entry_t* save)
945945
else if (save->flags & SAVE_FLAG_PS2)
946946
ret = vmc_delete_save(save->dir_name);
947947

948+
else if (save->flags & SAVE_FLAG_TROPHY)
949+
ret = trophySet_delete(save);
950+
948951
else if (save->flags & SAVE_FLAG_PS4)
949952
{
950953
if (save->flags & SAVE_FLAG_HDD)

source/menu_main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ static void SetMenu(int id)
181181
case MENU_USB_SAVES:
182182
ReloadUserSaves(&usb_saves);
183183
break;
184+
185+
case MENU_TROPHIES:
186+
ReloadUserSaves(&trophies);
187+
break;
184188
}
185189

186190
selected_entry->flags ^= SAVE_FLAG_UPDATED;

source/saves.c

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,45 @@ int trophy_lock(const save_entry_t* game, int trp_id, int grp_id, int type)
483483
return 1;
484484
}
485485

486+
int trophySet_delete(const save_entry_t* game)
487+
{
488+
char dbpath[256];
489+
sqlite3 *db;
490+
491+
snprintf(dbpath, sizeof(dbpath), TROPHY_DB_PATH, apollo_config.user_id);
492+
if ((db = open_sqlite_db(dbpath)) == NULL)
493+
return 0;
494+
495+
char* query = sqlite3_mprintf("DELETE FROM tbl_trophy_title WHERE (id=%d);\n"
496+
"DELETE FROM tbl_trophy_title_entry WHERE (id=%d);\n"
497+
"DELETE FROM tbl_trophy_flag WHERE (title_id=%d);",
498+
game->blocks, game->blocks, game->blocks);
499+
500+
if (sqlite3_exec(db, query, NULL, NULL, NULL) != SQLITE_OK)
501+
{
502+
LOG("Error updating '%s': %s", game->title_id, sqlite3_errmsg(db));
503+
sqlite3_free(query);
504+
sqlite3_close(db);
505+
return 0;
506+
}
507+
508+
LOG("Saving database to %s", dbpath);
509+
sqlite3_memvfs_dump(db, NULL, dbpath);
510+
sqlite3_free(query);
511+
sqlite3_close(db);
512+
513+
snprintf(dbpath, sizeof(dbpath), TROPHY_PATH_HDD "%s/sealedkey", apollo_config.user_id, game->title_id);
514+
unlink_secure(dbpath);
515+
516+
snprintf(dbpath, sizeof(dbpath), TROPHY_PATH_HDD "%s/trophy.img", apollo_config.user_id, game->title_id);
517+
unlink_secure(dbpath);
518+
519+
*strrchr(dbpath, '/') = 0;
520+
rmdir(dbpath);
521+
522+
return 1;
523+
}
524+
486525
int orbis_SaveDelete(const save_entry_t *save)
487526
{
488527
OrbisSaveDataDelete del;
@@ -1060,6 +1099,15 @@ int ReadTrophies(save_entry_t * game)
10601099
trophy = _createCmdCode(PATCH_COMMAND, CHAR_ICON_SIGN " Apply Changes to Trophy Set", CMD_UPDATE_TROPHY);
10611100
list_append(game->codes, trophy);
10621101

1102+
trophy = _createCmdCode(PATCH_COMMAND, CHAR_ICON_USER " View Trophy Set Details", CMD_VIEW_DETAILS);
1103+
list_append(game->codes, trophy);
1104+
1105+
trophy = _createCmdCode(PATCH_COMMAND, CHAR_ICON_WARN " Delete Trophy Set", CMD_DELETE_SAVE);
1106+
list_append(game->codes, trophy);
1107+
1108+
trophy = _createCmdCode(PATCH_NULL, "----- " UTF8_CHAR_STAR " File Backup " UTF8_CHAR_STAR " -----", CMD_CODE_NULL);
1109+
list_append(game->codes, trophy);
1110+
10631111
trophy = _createCmdCode(PATCH_COMMAND, CHAR_ICON_COPY " Backup Trophy files to USB", CMD_CODE_NULL);
10641112
trophy->file = strdup(game->path);
10651113
trophy->options_count = 1;
@@ -1074,9 +1122,6 @@ int ReadTrophies(save_entry_t * game)
10741122
asprintf(&trophy->options->value[2], "%c", CMD_EXPORT_ZIP_HDD);
10751123
list_append(game->codes, trophy);
10761124

1077-
trophy = _createCmdCode(PATCH_NULL, "----- " UTF8_CHAR_STAR " File Backup " UTF8_CHAR_STAR " -----", CMD_CODE_NULL);
1078-
list_append(game->codes, trophy);
1079-
10801125
trophy = _createCmdCode(PATCH_COMMAND, CHAR_ICON_COPY " Export decrypted trophy files", CMD_CODE_NULL);
10811126
trophy->options_count = 1;
10821127
trophy->options = _getFileOptions(game->path, "*", CMD_DECRYPT_FILE);

0 commit comments

Comments
 (0)