From 978b325a300a0a1e54b026d31d1a9c41116bfcac Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Mon, 19 Sep 2022 22:53:38 -0400 Subject: [PATCH] Fixes save lag on Switch (#1499) * Greatly improves saving speed on the Switch. * Fixes build on non-switch platforms. --- soh/soh/SaveManager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 922103a10..52cba1f5e 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -479,14 +479,21 @@ void SaveManager::SaveFile(int fileNum) { section.second.second(); } +#ifdef __SWITCH__ + const char* json_string = baseBlock.dump(4).c_str(); + FILE* w = fopen(GetFileName(fileNum).c_str(), "w"); + fwrite(json_string, sizeof(char), strlen(json_string), w); + fclose(w); +#else + std::ofstream output(GetFileName(fileNum)); #ifdef __WIIU__ alignas(0x40) char buffer[8192]; output.rdbuf()->pubsetbuf(buffer, sizeof(buffer)); #endif - output << std::setw(4) << baseBlock << std::endl; +#endif InitMeta(fileNum); }