utils::datafile::Write(saveFile,"save_file_path"_S+std::format("save.{:04}",saveFileID));//Once the hash has been computed and added, save the file a second time.
fileHashWrittenSuccessfully=utils::datafile::Write(saveFile,"save_file_path"_S+std::format("save.{:04}",saveFileID));//Once the hash has been computed and added, save the file a second time.
}
#pragma endregion
#pragma endregion
//WARNING! DO NOT WRITE ANY CODE BELOW HERE!!!!! THE HASH HAS ALREADY BEEN WRITTEN.
//WARNING! DO NOT WRITE ANY CODE BELOW HERE!!!!! THE HASH HAS ALREADY BEEN WRITTEN.
//FILES BECOME CORRUPTED IF THE SAVE FILE IS MODIFIED FROM HERE ONWARDS.
//FILES BECOME CORRUPTED IF THE SAVE FILE IS MODIFIED FROM HERE ONWARDS.
trim(fileHash);//It's possible the expected file hash has a space at the end/beginning that gets stripped out. We want to trim and match that string.
trim(fileHash);//It's possible the expected file hash has a space at the end/beginning that gets stripped out. We want to trim and match that string.
if(!ADMIN_MODE&&expectedFileHash!=fileHash){
if(!ADMIN_MODE&&expectedFileHash!=fileHash){
LOG(std::format("WARNING! Filehash for file {} was not identified as proper! Will not load this file!","save_file_path"_S+std::format("save.{:04}",saveFileID)));
LOG(std::format("WARNING! Filehash for file {} was not identified as proper! Will not load this file!","save_file_path"_S+std::format("save.{:04}",saveFileID)));
return;
return;
}
}
loadFile["Hash"].SetString(expectedFileHash);//Now write the hash back into the file since we tampered with it.
loadFile["Hash"].SetString(expectedFileHash);//Now write the hash back into the file since we tampered with it.