mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 14:23:44 -07:00
clang
This commit is contained in:
parent
5baf024452
commit
336400e4b1
2 changed files with 26 additions and 19 deletions
|
@ -365,13 +365,15 @@ bool Randomizer::SpoilerFileExists(const char* spoilerFileName) {
|
||||||
nlohmann::json contents;
|
nlohmann::json contents;
|
||||||
spoilerFileStream >> contents;
|
spoilerFileStream >> contents;
|
||||||
spoilerFileStream.close();
|
spoilerFileStream.close();
|
||||||
if (contents.contains("version") && strcmp(std::string(contents["version"]).c_str(), (char*)gBuildVersion) == 0) {
|
if (contents.contains("version") &&
|
||||||
|
strcmp(std::string(contents["version"]).c_str(), (char*)gBuildVersion) == 0) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
SohGui::RegisterPopup("Old Spoiler Version", "The spoiler file located at\n" +
|
SohGui::RegisterPopup(
|
||||||
std::string(spoilerFileName) +
|
"Old Spoiler Version",
|
||||||
"\nwas made by an version that doesn't match the currently running version.\n" +
|
"The spoiler file located at\n" + std::string(spoilerFileName) +
|
||||||
"Loading for this file has been cancelled.");
|
"\nwas made by an version that doesn't match the currently running version.\n" +
|
||||||
|
"Loading for this file has been cancelled.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1118,11 +1118,13 @@ void SaveManager::LoadFile(int fileNum) {
|
||||||
if (sectionName == "randomizer") {
|
if (sectionName == "randomizer") {
|
||||||
bool hasStats = saveBlock["sections"].contains("sohStats");
|
bool hasStats = saveBlock["sections"].contains("sohStats");
|
||||||
if (block.value()["data"].contains("aat0") || !hasStats) { // Rachael rando data
|
if (block.value()["data"].contains("aat0") || !hasStats) { // Rachael rando data
|
||||||
SohGui::RegisterPopup("Loading old file", "The file in slot " +
|
SohGui::RegisterPopup(
|
||||||
std::to_string(fileNum + 1) +
|
"Loading old file",
|
||||||
" appears to contain randomizer data, but is a very old format.\n" +
|
"The file in slot " + std::to_string(fileNum + 1) +
|
||||||
"The randomizer data has been removed, and this file will be treated as a vanilla file.\n" +
|
" appears to contain randomizer data, but is a very old format.\n" +
|
||||||
"If this was a randomizer file, the file will not work, and should be deleted.");
|
"The randomizer data has been removed, and this file will be treated as a vanilla "
|
||||||
|
"file.\n" +
|
||||||
|
"If this was a randomizer file, the file will not work, and should be deleted.");
|
||||||
input.close();
|
input.close();
|
||||||
saveMtx.unlock();
|
saveMtx.unlock();
|
||||||
SaveFile(fileNum);
|
SaveFile(fileNum);
|
||||||
|
@ -1132,12 +1134,14 @@ void SaveManager::LoadFile(int fileNum) {
|
||||||
s16 minor = saveBlock["sections"]["sohStats"]["data"]["buildVersionMinor"];
|
s16 minor = saveBlock["sections"]["sohStats"]["data"]["buildVersionMinor"];
|
||||||
s16 patch = saveBlock["sections"]["sohStats"]["data"]["buildVersionPatch"];
|
s16 patch = saveBlock["sections"]["sohStats"]["data"]["buildVersionPatch"];
|
||||||
// block loading outdated rando save
|
// block loading outdated rando save
|
||||||
if (!(major == gBuildVersionMajor && minor == gBuildVersionMinor && patch == gBuildVersionPatch)) {
|
if (!(major == gBuildVersionMajor && minor == gBuildVersionMinor &&
|
||||||
|
patch == gBuildVersionPatch)) {
|
||||||
input.close();
|
input.close();
|
||||||
std::string newFileName = Ship::Context::GetPathRelativeToAppDirectory("Save") +
|
std::string newFileName = Ship::Context::GetPathRelativeToAppDirectory("Save") +
|
||||||
("/file" + std::to_string(fileNum + 1) + "-" + std::to_string(GetUnixTimestamp()) + ".bak");
|
("/file" + std::to_string(fileNum + 1) + "-" +
|
||||||
|
std::to_string(GetUnixTimestamp()) + ".bak");
|
||||||
std::filesystem::path newFile(newFileName);
|
std::filesystem::path newFile(newFileName);
|
||||||
|
|
||||||
#if defined(__SWITCH__) || defined(__WIIU__)
|
#if defined(__SWITCH__) || defined(__WIIU__)
|
||||||
copy_file(fileName.c_str(), newFile.c_str());
|
copy_file(fileName.c_str(), newFile.c_str());
|
||||||
#else
|
#else
|
||||||
|
@ -1145,12 +1149,13 @@ void SaveManager::LoadFile(int fileNum) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::filesystem::remove(fileName);
|
std::filesystem::remove(fileName);
|
||||||
SohGui::RegisterPopup("Outdated Randomizer Save", "The SoH version in the file in slot " +
|
SohGui::RegisterPopup(
|
||||||
std::to_string(fileNum + 1) +
|
"Outdated Randomizer Save",
|
||||||
" does not match the currently running version.\n" +
|
"The SoH version in the file in slot " + std::to_string(fileNum + 1) +
|
||||||
"Non-matching rando saves are unsupported, and the file has been renamed to\n" +
|
" does not match the currently running version.\n" +
|
||||||
" " + newFileName + "\n" +
|
"Non-matching rando saves are unsupported, and the file has been renamed to\n" +
|
||||||
"If this was not in error, the file should be deleted.");
|
" " + newFileName + "\n" +
|
||||||
|
"If this was not in error, the file should be deleted.");
|
||||||
saveMtx.unlock();
|
saveMtx.unlock();
|
||||||
SaveFile(fileNum);
|
SaveFile(fileNum);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue