From 3a2b432ea6cc126ab7fccdafd46c3ed9a3f35bd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1zaro=20Vieira?= Date: Sun, 9 Apr 2017 13:37:12 -0300 Subject: [PATCH] Fix 'common' save backup/restore for 'this user' --- src/savemng.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/savemng.c b/src/savemng.c index 9757ae6..fcb5bb9 100644 --- a/src/savemng.c +++ b/src/savemng.c @@ -335,13 +335,15 @@ void backupSavedata(Title* title, u8 slot, bool allusers, bool common) { if (!allusers && !isWii) { char usrPath[16]; getUserID(usrPath); - sprintf(dstPath + strlen(dstPath), "/%s", usrPath); - u32 offset = strlen(srcPath); + u32 srcOffset = strlen(srcPath); + u32 dstOffset = strlen(dstPath); if (common) { - strcpy(srcPath + offset, "/common"); + strcpy(srcPath + srcOffset, "/common"); + strcpy(dstPath + dstOffset, "/common"); if (DumpDir(srcPath, dstPath)!=0) promptError("Common save not found."); } - sprintf(srcPath + offset, "/%s", usrPath); + sprintf(srcPath + srcOffset, "/%s", usrPath); + sprintf(dstPath + dstOffset, "/%s", usrPath); } if (DumpDir(srcPath, dstPath)!=0) promptError("Backup failed. DO NOT restore from this slot."); @@ -366,13 +368,15 @@ void restoreSavedata(Title* title, u8 slot, bool allusers, bool common) { if (!allusers && !isWii) { char usrPath[16]; getUserID(usrPath); - sprintf(dstPath + strlen(dstPath), "/%s", usrPath); - u32 offset = strlen(srcPath); + u32 srcOffset = strlen(srcPath); + u32 dstOffset = strlen(dstPath); if (common) { - strcpy(srcPath + offset, "/common"); + strcpy(srcPath + srcOffset, "/common"); + strcpy(dstPath + dstOffset, "/common"); if (DumpDir(srcPath, dstPath)!=0) promptError("Common save not found."); } - sprintf(srcPath + offset, "/%s", usrPath); + sprintf(srcPath + srcOffset, "/%s", usrPath); + sprintf(dstPath + dstOffset, "/%s", usrPath); } if (DumpDir(srcPath, dstPath)!=0) promptError("Restore failed.");