Skip to content

Commit 6b480b2

Browse files
agamacheKenix3
authored andcommitted
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 <[email protected]>
1 parent 3f5af8e commit 6b480b2

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

soh/soh.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@
941941
<ClCompile Include="src\overlays\misc\ovl_kaleido_scope\z_lmap_mark.c" />
942942
<ClCompile Include="src\overlays\misc\ovl_kaleido_scope\z_lmap_mark_data.c" />
943943
<ClCompile Include="src\overlays\misc\ovl_map_mark_data\z_map_mark_data.c" />
944+
944945
</ItemGroup>
945946
<ItemGroup>
946947
<ClInclude Include="soh\Enhancements\cosmetics\CosmeticsEditor.h" />

soh/soh/Enhancements/randomizer/3drando/rando_main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// #include <soh/Enhancements/randomizer.h>
88
#include <Cvar.h>
99
#include <GameSettings.h>
10+
#define NOGDI
11+
#define WIN32_LEAN_AND_MEAN
12+
#include <GlobalCtx2.h>
1013

1114
#define TICKS_PER_SEC 268123480.0
1215

@@ -18,7 +21,7 @@ void RandoMain::GenerateRando(std::unordered_map<RandomizerSettingKey, u8> cvarS
1821
// std::string settingsFileName = "./randomizer/latest_settings.json";
1922
// CVar_SetString("gLoadedPreset", settingsFileName.c_str());
2023

21-
std::string fileName = GenerateRandomizer(cvarSettings);
24+
std::string fileName = Ship::GlobalCtx2::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings).c_str());
2225
CVar_SetString("gSpoilerLog", fileName.c_str());
2326

2427
Game::SaveSettings();

soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
#include <filesystem>
2727
#include <variables.h>
2828

29+
#define NOGDI
30+
#define WIN32_LEAN_AND_MEAN
31+
#include "GlobalCtx2.h"
32+
2933
using json = nlohmann::json;
3034

3135
json jsonData;
@@ -721,12 +725,13 @@ const char* SpoilerLog_Write(int language) {
721725
//WriteShuffledEntrances(spoilerLog);
722726
WriteAllLocations(language);
723727

724-
if (!std::filesystem::exists("./Randomizer")) {
725-
std::filesystem::create_directory("./Randomizer");
728+
if (!std::filesystem::exists(Ship::GlobalCtx2::GetPathRelativeToAppDirectory("Randomizer"))) {
729+
std::filesystem::create_directory(Ship::GlobalCtx2::GetPathRelativeToAppDirectory("Randomizer"));
726730
}
727731

728732
std::string jsonString = jsonData.dump(4);
729-
std::ofstream jsonFile("./Randomizer/" + Settings::seed + ".json");
733+
std::ofstream jsonFile(Ship::GlobalCtx2::GetPathRelativeToAppDirectory(
734+
(std::string("Randomizer/") + std::string(Settings::seed) + std::string(".json")).c_str()));
730735
jsonFile << std::setw(4) << jsonString << std::endl;
731736
jsonFile.close();
732737

0 commit comments

Comments
 (0)