From 06338d864f15f6c923f0ed9ee2b8259a8b8b5a2d Mon Sep 17 00:00:00 2001 From: agamache Date: Thu, 14 Jul 2022 00:56:29 -0400 Subject: [PATCH] Fixes macOS randomizer functionality with App Directory (#761) * Fixes macOS randomizer functionality with App Directory * Fix windows build * Update soh/soh/Enhancements/randomizer/3drando/rando_main.cpp * Update soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp * Revert band-aid fix Co-authored-by: Kenix3 --- soh/soh.vcxproj | 1 + .../Enhancements/randomizer/3drando/rando_main.cpp | 5 ++++- .../Enhancements/randomizer/3drando/spoiler_log.cpp | 11 ++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/soh/soh.vcxproj b/soh/soh.vcxproj index c305b03b1..5a293d3f0 100644 --- a/soh/soh.vcxproj +++ b/soh/soh.vcxproj @@ -941,6 +941,7 @@ + diff --git a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp index a936b6567..e14cf502d 100644 --- a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp @@ -7,6 +7,9 @@ // #include #include #include +#define NOGDI +#define WIN32_LEAN_AND_MEAN +#include #define TICKS_PER_SEC 268123480.0 @@ -18,7 +21,7 @@ void RandoMain::GenerateRando(std::unordered_map cvarS // std::string settingsFileName = "./randomizer/latest_settings.json"; // CVar_SetString("gLoadedPreset", settingsFileName.c_str()); - std::string fileName = GenerateRandomizer(cvarSettings); + std::string fileName = Ship::GlobalCtx2::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings).c_str()); CVar_SetString("gSpoilerLog", fileName.c_str()); Game::SaveSettings(); diff --git a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp index 24662f1d7..5deea4088 100644 --- a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp @@ -26,6 +26,10 @@ #include #include +#define NOGDI +#define WIN32_LEAN_AND_MEAN +#include "GlobalCtx2.h" + using json = nlohmann::json; json jsonData; @@ -721,12 +725,13 @@ const char* SpoilerLog_Write(int language) { //WriteShuffledEntrances(spoilerLog); WriteAllLocations(language); - if (!std::filesystem::exists("./Randomizer")) { - std::filesystem::create_directory("./Randomizer"); + if (!std::filesystem::exists(Ship::GlobalCtx2::GetPathRelativeToAppDirectory("Randomizer"))) { + std::filesystem::create_directory(Ship::GlobalCtx2::GetPathRelativeToAppDirectory("Randomizer")); } std::string jsonString = jsonData.dump(4); - std::ofstream jsonFile("./Randomizer/" + Settings::seed + ".json"); + std::ofstream jsonFile(Ship::GlobalCtx2::GetPathRelativeToAppDirectory( + (std::string("Randomizer/") + std::string(Settings::seed) + std::string(".json")).c_str())); jsonFile << std::setw(4) << jsonString << std::endl; jsonFile.close();