Skip to content

Commit

Permalink
Update FromSoftware Auto Backup Tool.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
uuu00000tw authored Mar 27, 2024
1 parent 4907d96 commit 5b1e1af
Showing 1 changed file with 53 additions and 50 deletions.
103 changes: 53 additions & 50 deletions FromSoftware Auto Backup Tool/FromSoftware Auto Backup Tool.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// FromSoftware Auto Backup Tool - oniichi
// Release # 1.0
// Changelog:
// Added all FromSoftware games to map
// Release # 1.1
// Changelog: https://www.notion.so/FromSoftware-games-auto-backup-tool-fdb275a157c74e49bd57a752bf90a6a6

#include <iostream>
#include <map>
Expand All @@ -20,7 +19,7 @@ std::map<std::string, std::string> GameCodes{
{ "1R", "Dark Souls: Remastered"},
{ "2", "Dark Souls II"},
{ "2S", "Dark Souls II: Scholar of the First Sin"},
{ "3", "Dark Souls 3"},
{ "3", "Dark Souls III"},
{ "E", "Elden Ring"},
{ "S", "Sekiro: Shadows Die Twice"},
{ "A", "Armored Core VI: FIRES OF RUBICON"}
Expand All @@ -38,39 +37,37 @@ int main()
// Declare variables used within the application
// ------------------------------------------------------------------------------------------------

string filePath; // file path
string desPath; // destination for the backups
int numberSaves; // number of saves
int interval; // how often to backup saves
char pathbuffer[100]; // holds where the saves are currently saved when read in from the ini file
char backupbuffer[100]; // holds where the backups are to be saved from the ini file
char currSave[100]; // holds where the current save is at in the counter
int totalSaves; // total number of saves
string DSSAVE = "DRAKS0005.sl2"; // Name of initital save if Dark Souls I
string DSRSAVE = "DRAKS0005.sl2"; // Name of initital save if Dark Souls I: Remastered
string DS2SAVE = "DARKSII0000.sl2"; // Name of initital save if Dark Souls
string DS2SOFSSAVE = "DS2SOFS0000.sl2"; // Name of initital save if Dark Souls : Scholar of the First Sin
string filePath; // file path
string desPath; // destination for the backups
int numberSaves; // number of saves
int interval; // how often to backup saves
char pathbuffer[100]; // holds where the saves are currently saved when read in from the ini file
char backupbuffer[100]; // holds where the backups are to be saved from the ini file
char currSave[100]; // holds where the current save is at in the counter
int totalSaves; // total number of saves
string DSSAVE = "DRAKS0005.sl2"; // Name of initital save if Dark Souls : Prepare To Die Edition
string DSRSAVE = "DRAKS0005.sl2"; // Name of initital save if Dark Souls : Remastered
string DS2SAVE = "DARKSII0000.sl2"; // Name of initital save if Dark Souls II
string DS2SOFSSAVE = "DS2SOFS0000.sl2"; // Name of initital save if Dark Souls II: Scholar of the First Sin
string DS3SAVE = "DS30000.sl2"; // Name of initial save if Dark Souls III
string ERSAVE = "ER0000.sl2"; // Name of initial save if Elden Ring
string SEKIRORSAVE = "S0000.sl2"; // Name of initial save if Sekiro: Shadows Die Twice
string AC6ERSAVE = "AC60000.sl2"; // Name of initial save if Armored Core VI: FIRES OF RUBICON
string SEKIRORSAVE = "S0000.sl2"; // Name of initial save if Sekiro: Shadows Die Twice
string AC6ERSAVE = "AC60000.sl2"; // Name of initial save if Armored Core VI: FIRES OF RUBICON
string GAMESAVE;
string BACKUP;
string fsgame; // Which Dark Souls are you running
string fsgamename;
string fsgame; // Which game are you playing
string fsgamename; // Name of game which are you playing
string dsVersion;
string deletionBackup; // Backup to get rid of when over the limit
int deletionNum; // Number of the backup to get rid of when deleted
char deletionNumber[100]; // Number of the backup to get rid of when deleted (for the deletion step)
char currentSaveNum[999]; // Number of saves present
bool debug = false; // Debug information
string deletionBackup; // Backup to get rid of when over the limit
int deletionNum; // Number of the backup to get rid of when deleted
char deletionNumber[100]; // Number of the backup to get rid of when deleted (for the deletion step)
char currentSaveNum[999]; // Number of saves present
bool debug = false; // Debug mode

// ------------------------------------------------------------------------------------------------
// load settings from the ini file
// Welcome page
// ------------------------------------------------------------------------------------------------
debug = GetPrivateProfileIntA("FSABT", "debug", 0, ".\\settings.ini"); // Turn on debug information
if (debug)
cout << " ** DEBUG MODE IS CURRENTLY ENABLED ** " << endl;

std::cout << R"(
## ## ## ###### ##### ###### ## #### ### ## ## ## ######
#### ## ## # ## # ## ## ## ## #### ## ## ## ## ## ## ## ##
Expand All @@ -83,7 +80,7 @@ int main()
)" << endl;
while (fsgame.empty()) {

cout << "FromSoftware Auto Backup Tool V1.0" << endl;
cout << "FromSoftware Auto Backup Tool V1.1" << endl;
cout << "-------------------------------------" << endl;
for (const std::pair<string, string>& pair : GameCodes) {
const string& code = pair.first;
Expand All @@ -103,14 +100,20 @@ int main()
}
fsgamename = GameCodes[fsgame];
}

numberSaves = GetPrivateProfileIntA("FSABT", "max_saves", 5, ".\\settings.ini"); // Get the # of saves

// ------------------------------------------------------------------------------------------------
// load settings from the ini file
// ------------------------------------------------------------------------------------------------
debug = GetPrivateProfileIntA("FSABT", "debug", 0, ".\\settings.ini"); // Turn on debug information
if (debug)
cout << " ** DEBUG MODE IS CURRENTLY ENABLED ** " << endl;
numberSaves = GetPrivateProfileIntA("FSABT", "max_saves", 5, ".\\settings.ini"); // Get the number of saves
interval = GetPrivateProfileIntA("FSABT", "interval_minutes", 10, ".\\settings.ini"); // Get the frequency of saves

if (fsgame == "1")
{
//Dark Souls
GetPrivateProfileStringA("FSABT", "save_path_ds", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path for the backups
GetPrivateProfileStringA("FSABT", "save_path_ds", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path of the save file
GetPrivateProfileStringA("FSABT", "backup_path_ds", "failed", backupbuffer, 100, ".\\settings.ini"); // Get the path for the backups
totalSaves = GetPrivateProfileIntA("FSABT", "totalsaves1", 0, ".\\settings.ini"); // Get the number that the saves are currently on
BACKUP = "DRAKS0005 BACKUP - ";
Expand All @@ -119,7 +122,7 @@ int main()
else if (fsgame == "1R")
{
//Dark Souls: Remastered
GetPrivateProfileStringA("FSABT", "save_path_dsr", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path for the backups
GetPrivateProfileStringA("FSABT", "save_path_dsr", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path of the save file
GetPrivateProfileStringA("FSABT", "backup_path_dsr", "failed", backupbuffer, 100, ".\\settings.ini"); // Get the path for the backups
totalSaves = GetPrivateProfileIntA("FSABT", "totalsaves1R", 0, ".\\settings.ini"); // Get the number that the saves are currently on
BACKUP = "DRAKS0005 BACKUP - ";
Expand All @@ -128,7 +131,7 @@ int main()
else if (fsgame == "2")
{
//Dark Souls 2
GetPrivateProfileStringA("FSABT", "save_path_ds2", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path for the backups
GetPrivateProfileStringA("FSABT", "save_path_ds2", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path of the save file
GetPrivateProfileStringA("FSABT", "backup_path_ds2", "failed", backupbuffer, 100, ".\\settings.ini"); // Get the path for the backups
totalSaves = GetPrivateProfileIntA("FSABT", "totalsaves2", 0, ".\\settings.ini"); // Get the number that the saves are currently on
BACKUP = "DARKSII0000 BACKUP - ";
Expand All @@ -137,7 +140,7 @@ int main()
else if (fsgame == "2S")
{
//Dark Souls 2: Scholar of the First Sin
GetPrivateProfileStringA("FSABT", "save_path_ds2S", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path for the backups
GetPrivateProfileStringA("FSABT", "save_path_ds2S", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path of the save file
GetPrivateProfileStringA("FSABT", "backup_path_ds2S", "failed", backupbuffer, 100, ".\\settings.ini"); // Get the path for the backups
totalSaves = GetPrivateProfileIntA("FSABT", "totalsaves2S", 0, ".\\settings.ini"); // Get the number that the saves are currently on
BACKUP = "DS2SOFS0000 BACKUP - ";
Expand All @@ -146,7 +149,7 @@ int main()
else if (fsgame == "3")
{
//Dark Souls 3
GetPrivateProfileStringA("FSABT", "save_path_ds3", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path for the backups
GetPrivateProfileStringA("FSABT", "save_path_ds3", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path of the save file
GetPrivateProfileStringA("FSABT", "backup_path_ds3", "failed", backupbuffer, 100, ".\\settings.ini"); // Get the path for the backups
totalSaves = GetPrivateProfileIntA("FSABT", "totalsaves3", 0, ".\\settings.ini"); // Get the number that the saves are currently on
BACKUP = "DS30000 BACKUP - ";
Expand All @@ -155,7 +158,7 @@ int main()
else if (fsgame == "E")
{
//Elden Ring"
GetPrivateProfileStringA("FSABT", "save_path_ER", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path for the backups
GetPrivateProfileStringA("FSABT", "save_path_ER", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path of the save file
GetPrivateProfileStringA("FSABT", "backup_path_ER", "failed", backupbuffer, 100, ".\\settings.ini"); // Get the path for the backups
totalSaves = GetPrivateProfileIntA("FSABT", "totalsavesE", 0, ".\\settings.ini"); // Get the number that the saves are currently on
BACKUP = "ER0000 BACKUP - ";
Expand All @@ -164,7 +167,7 @@ int main()
else if (fsgame == "S")
{
//Sekiro: Shadows Die Twice
GetPrivateProfileStringA("FSABT", "save_path_S", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path for the backups
GetPrivateProfileStringA("FSABT", "save_path_S", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path of the save file
GetPrivateProfileStringA("FSABT", "backup_path_S", "failed", backupbuffer, 100, ".\\settings.ini"); // Get the path for the backups
totalSaves = GetPrivateProfileIntA("FSABT", "totalsavesS", 0, ".\\settings.ini"); // Get the number that the saves are currently on
BACKUP = "S0000 BACKUP - ";
Expand All @@ -173,15 +176,15 @@ int main()
else if (fsgame == "A")
{
//Armored Core VI: FIRES OF RUBICON
GetPrivateProfileStringA("FSABT", "save_path_AC6", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path for the backups
GetPrivateProfileStringA("FSABT", "save_path_AC6", "failed", pathbuffer, 100, ".\\settings.ini"); // Get the path of the save file
GetPrivateProfileStringA("FSABT", "backup_path_AC6", "failed", backupbuffer, 100, ".\\settings.ini"); // Get the path for the backups
totalSaves = GetPrivateProfileIntA("FSABT", "totalsavesA", 0, ".\\settings.ini"); // Get the number that the saves are currently on
BACKUP = "AC60000 BACKUP - ";
GAMESAVE = AC6ERSAVE;
};

// ------------------------------------------------------------------------------------------------
// Initital Screen
// Process activate
// ------------------------------------------------------------------------------------------------

cout << "-------------------------------------" << endl;
Expand Down Expand Up @@ -215,14 +218,14 @@ int main()
// ------------------------------------------------------------------------------------------------

int counter = totalSaves;
int waitTime = 60000 * interval; // Converts time from the ini to the appropriate format
int waitTime = 60000 * interval; // Converts time from the ini to the appropriate format
while (true) {
Sleep(waitTime); // Wait the appropriate time before creating another backup
counter++; // Increase the counter for keeping track of the current backup
Sleep(waitTime); // Wait the appropriate time before creating another backup
counter++; // Increase the counter for keeping track of the current backup
cout << "Back up # " << counter << " has been created." << endl;
_itoa_s(counter, currSave, 10);
desPath = backupbuffer + BACKUP + currSave + ".sl2";
CopyFileA(filePath.c_str(), desPath.c_str(), false); // Creates the backup
CopyFileA(filePath.c_str(), desPath.c_str(), false); // Creates the backup

_itoa_s(counter, currentSaveNum, 10);
if (fsgame == "1")
Expand Down Expand Up @@ -256,12 +259,12 @@ int main()
cout << " ** DEBUG: totalSaves being written to file: " << currentSaveNum << endl;
}
//cout << "-----DEBUG INFORMATION: CURRENT SAVE STEP: " << currentSaveNum << endl;
if (counter > numberSaves) { // Deletion of old saves
deletionNum = counter - numberSaves; // Select the oldest save in the folder
_itoa_s(deletionNum, deletionNumber, 10); // Convert to the appropriate formation
deletionBackup = backupbuffer + BACKUP + deletionNumber + ".sl2"; // Create the file name that needs to be deleted
if (counter > numberSaves) { // Deletion of old saves
deletionNum = counter - numberSaves; // Select the oldest save in the folder
_itoa_s(deletionNum, deletionNumber, 10); // Convert to the appropriate formation
deletionBackup = backupbuffer + BACKUP + deletionNumber + ".sl2"; // Create the file name that needs to be deleted
cout << "Old backup has been removed (#" << deletionNumber << ")" << endl;
DeleteFileA(deletionBackup.c_str()); // Deletes the oldest save
DeleteFileA(deletionBackup.c_str()); // Deletes the oldest save
}

}
Expand Down

0 comments on commit 5b1e1af

Please sign in to comment.