diff --git a/Source/Core/Core/Slippi/SlippiGameFileLoader.cpp b/Source/Core/Core/Slippi/SlippiGameFileLoader.cpp index 4986ddbede..96a59964f0 100644 --- a/Source/Core/Core/Slippi/SlippiGameFileLoader.cpp +++ b/Source/Core/Core/Slippi/SlippiGameFileLoader.cpp @@ -9,67 +9,60 @@ #include "Core/HW/DVD/DVDThread.h" #include "Core/System.h" -std::string getFilePath(std::string fileName) +std::string getFilePath(std::string file_name) { - std::string dirPath = File::GetSysDirectory(); + std::string dir_path = File::GetSysDirectory(); - std::string filePath = dirPath + "GameFiles/GALE01/" + fileName; // TODO: Handle other games? + std::string file_path = dir_path + "GameFiles/GALE01/" + file_name; // TODO: Handle other games? - if (File::Exists(filePath)) + if (File::Exists(file_path)) { - return filePath; + return file_path; } - filePath = filePath + ".diff"; - if (File::Exists(filePath)) + file_path = file_path + ".diff"; + if (File::Exists(file_path)) { - return filePath; + return file_path; } return ""; } -u32 SlippiGameFileLoader::LoadFile(std::string fileName, std::string& data) +u32 SlippiGameFileLoader::LoadFile(std::string file_name, std::string& data) { - if (fileCache.count(fileName)) + if (file_cache.count(file_name)) { - data = fileCache[fileName]; - return (u32)data.size(); + data = file_cache[file_name]; + return static_cast(data.size()); } - INFO_LOG_FMT(SLIPPI, "Loading file: {}", fileName.c_str()); + INFO_LOG_FMT(SLIPPI, "Loading file: {}", file_name.c_str()); - std::string gameFilePath = getFilePath(fileName); - if (gameFilePath.empty()) + std::string game_file_path = getFilePath(file_name); + if (game_file_path.empty()) { - fileCache[fileName] = ""; + file_cache[file_name] = ""; data = ""; return 0; } - std::string fileContents; - - // Don't read MxDt.dat because our Launcher may not have successfully deleted it and - // loading the old one from the file system would break m-ex based ISOs - if (fileName != "MxDt.dat") - { - File::ReadFileToString(gameFilePath, fileContents); - } + std::string file_contents; // If the file was a diff file and the game is running, load the main file from ISO and apply // patch - if (gameFilePath.substr(gameFilePath.length() - 5) == ".diff" && + if (game_file_path.substr(game_file_path.length() - 5) == ".diff" && Core::GetState() == Core::State::Running) { std::vector buf; INFO_LOG_FMT(SLIPPI, "Will process diff"); - Core::System::GetInstance().GetDVDThread().ReadFile(fileName, buf); - std::string diffContents = fileContents; - decoder.Decode((char*)buf.data(), buf.size(), diffContents, &fileContents); + Core::System::GetInstance().GetDVDThread().ReadFile(file_name, buf); + std::string diff_contents = file_contents; + decoder.Decode((char*)buf.data(), buf.size(), diff_contents, &file_contents); } - fileCache[fileName] = fileContents; - data = fileCache[fileName]; - INFO_LOG_FMT(SLIPPI, "File size: {}", (u32)data.size()); - return (u32)data.size(); + file_cache[file_name] = file_contents; + data = file_cache[file_name]; + INFO_LOG_FMT(SLIPPI, "File size: {}", static_cast(data.size())); + return static_cast(data.size()); } diff --git a/Source/Core/Core/Slippi/SlippiGameFileLoader.h b/Source/Core/Core/Slippi/SlippiGameFileLoader.h index d066ab9236..4e16faf8d8 100644 --- a/Source/Core/Core/Slippi/SlippiGameFileLoader.h +++ b/Source/Core/Core/Slippi/SlippiGameFileLoader.h @@ -9,9 +9,9 @@ class SlippiGameFileLoader { public: - u32 LoadFile(std::string fileName, std::string& contents); + u32 LoadFile(std::string file_name, std::string& contents); protected: - std::unordered_map fileCache; + std::unordered_map file_cache; open_vcdiff::VCDiffDecoder decoder; };