diff --git a/CMake/logging.cmake b/CMake/logging.cmake new file mode 100644 index 000000000..268ad27b4 --- /dev/null +++ b/CMake/logging.cmake @@ -0,0 +1,20 @@ +set(SPDLOG_LEVEL_TRACE 0) +set(SPDLOG_LEVEL_DEBUG 1) +set(SPDLOG_LEVEL_INFO 2) +set(SPDLOG_LEVEL_WARN 3) +set(SPDLOG_LEVEL_ERROR 4) +set(SPDLOG_LEVEL_CRITICAL 5) +set(SPDLOG_LEVEL_OFF 6) +set(LOG_LEVELS "SPDLOG_LEVEL_TRACE;SPDLOG_LEVEL_DEBUG;SPDLOG_LEVEL_INFO;SPDLOG_LEVEL_WARN;SPDLOG_LEVEL_ERROR;SPDLOG_LEVEL_CRITICAL;SPDLOG_LEVEL_OFF") +set(LOG_LEVEL SPDLOG_LEVEL_TRACE CACHE STRING "The spdlog level that prints will be logged out. Overridden to SPDLOG_LEVEL_ERROR on Release builds.") +set_property(CACHE LOG_LEVEL PROPERTY STRINGS ${LOG_LEVELS}) +if(NOT LOG_LEVEL IN_LIST LOG_LEVELS) + message(FATAL_ERROR "LOG_LEVEL must be one of ${LOG_LEVELS}") +endif() +set(SPDLOG_ACTIVE_LEVEL ${${LOG_LEVEL}}) +set(LOG_LEVEL_GAME_PRINTS ${SPDLOG_LEVEL_OFF}) + +add_compile_definitions( + LOG_LEVEL_GAME_PRINTS=${LOG_LEVEL_GAME_PRINTS} + SPDLOG_ACTIVE_LEVEL=${SPDLOG_ACTIVE_LEVEL} +) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 64008668b..9608da56f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,10 @@ set(CMAKE_C_STANDARD 23 CACHE STRING "The C standard to use") set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version") -project(Ship VERSION 9.1.0 LANGUAGES C CXX) +project(Ship VERSION 9.1.1 LANGUAGES C CXX) include(CMake/soh-cvars.cmake) include(CMake/lus-cvars.cmake) +include(CMake/logging.cmake) option(SUPPRESS_WARNINGS "Suppress warnings in LUS and src (decomp)" ON) if(SUPPRESS_WARNINGS) diff --git a/libultraship b/libultraship index 5f4be9b6f..17a0b7939 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 5f4be9b6f5f74917c303ab8b66a0b2f4ef91613d +Subproject commit 17a0b7939bd05f5e617cef89457ca43774fc9a9f diff --git a/soh/assets/custom/presets/Main Randomizer.json b/soh/assets/custom/presets/Main Randomizer.json index 2982a8b72..fae2fe957 100644 --- a/soh/assets/custom/presets/Main Randomizer.json +++ b/soh/assets/custom/presets/Main Randomizer.json @@ -16,6 +16,7 @@ "ClimbSpeed": 3, "CrawlSpeed": 2, "CreditsFix": 1, + "CuccosToReturn": 1, "CustomizeFishing": 1, "CustomizeFrogsOcarinaGame": 1, "CustomizeOcarinaGame": 1, diff --git a/soh/include/functions.h b/soh/include/functions.h index 9d96a3c8b..11dbf8c81 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -13,8 +13,8 @@ extern "C" #include #include -#if defined(INCLUDE_GAME_PRINTF) && defined(_DEBUG) -#define osSyncPrintf(fmt, ...) lusprintf(__FILE__, __LINE__, 0, fmt, ##__VA_ARGS__) +#if (LOG_LEVEL_GAME_PRINTS >= SPDLOG_ACTIVE_LEVEL) && !(LOG_LEVEL_GAME_PRINTS >= 6) +#define osSyncPrintf(...) lusprintf(__FILE__, __LINE__, LOG_LEVEL_GAME_PRINTS , __VA_ARGS__) #else #define osSyncPrintf(fmt, ...) osSyncPrintfUnused(fmt, ##__VA_ARGS__) #endif diff --git a/soh/soh/Enhancements/mod_menu.cpp b/soh/soh/Enhancements/mod_menu.cpp index 9e3fda114..e60eee7e9 100644 --- a/soh/soh/Enhancements/mod_menu.cpp +++ b/soh/soh/Enhancements/mod_menu.cpp @@ -55,6 +55,7 @@ void SetEnabledModsCVarValue() { } CVarSetString(CVAR_ENABLED_MODS_NAME, s.c_str()); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } void AfterModChange() { @@ -128,8 +129,9 @@ void UpdateModFiles(bool init = false, bool reset = false) { disabledModFiles.clear(); unsupportedFiles.clear(); filePaths.clear(); - std::string modsPath = Ship::Context::LocateFileAcrossAppDirs("mods", appShortName); bool changed = false; + std::string modsPath = Ship::Context::LocateFileAcrossAppDirs("mods", appShortName); + std::map tempMods; if (modsPath.length() > 0 && std::filesystem::exists(modsPath)) { std::vector enabledFiles; if (std::filesystem::is_directory(modsPath)) { @@ -147,11 +149,17 @@ void UpdateModFiles(bool init = false, bool reset = false) { bool enabled = std::find(enabledModFiles.begin(), enabledModFiles.end(), filename) != enabledModFiles.end(); if (!enabled) { - enabledModFiles.push_back(filename); - changed = true; + tempMods.emplace(p.path().lexically_normal().generic_string(), filename); } filePaths.emplace(filename, p.path()); } + if (tempMods.size() > 0) { + changed = true; + for (auto [path, name] : tempMods) { + enabledModFiles.push_back(name); + } + tempMods.clear(); + } if (init) { std::vector enabledTemp(enabledModFiles); for (std::string mod : enabledTemp) { @@ -159,13 +167,14 @@ void UpdateModFiles(bool init = false, bool reset = false) { GetArchiveManager()->AddArchive(filePaths.at(mod).generic_string()); } else { enabledModFiles.erase(std::find(enabledModFiles.begin(), enabledModFiles.end(), mod)); + changed = true; } } } } - } - if (changed) { - SetEnabledModsCVarValue(); + if (changed) { + SetEnabledModsCVarValue(); + } } } diff --git a/soh/soh/Enhancements/randomizer/context.cpp b/soh/soh/Enhancements/randomizer/context.cpp index 898c9ea38..ef6808625 100644 --- a/soh/soh/Enhancements/randomizer/context.cpp +++ b/soh/soh/Enhancements/randomizer/context.cpp @@ -186,7 +186,6 @@ void Context::GenerateLocationPool() { location.GetRandomizerCheck() == RC_LW_DEKU_SCRUB_NEAR_BRIDGE || location.GetRandomizerCheck() == RC_HF_DEKU_SCRUB_GROTTO)) || (location.GetRCType() == RCTYPE_ADULT_TRADE && mOptions[RSK_SHUFFLE_ADULT_TRADE].Is(RO_GENERIC_OFF)) || - (location.GetRCType() == RCTYPE_SONG_LOCATION && mOptions[RSK_SHUFFLE_SONGS].Is(RO_SONG_SHUFFLE_OFF)) || (location.GetRCType() == RCTYPE_COW && mOptions[RSK_SHUFFLE_COWS].Is(RO_GENERIC_OFF)) || (location.GetRandomizerCheck() == RC_LH_HYRULE_LOACH && mOptions[RSK_FISHSANITY].IsNot(RO_FISHSANITY_HYRULE_LOACH)) || diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index 04ce7f1c8..82a9336fa 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -2187,7 +2187,8 @@ void RandomizerOnActorInitHandler(void* actorRef) { } // Turn MQ switch into toggle - if (actor->id == ACTOR_OBJ_SWITCH && gPlayState->sceneNum == SCENE_BOTTOM_OF_THE_WELL && (actor->params & 7) == 3) { + if (actor->id == ACTOR_OBJ_SWITCH && gPlayState->sceneNum == SCENE_BOTTOM_OF_THE_WELL && + (actor->params & 0x3f07) == 0x303) { auto dungeon = OTRGlobals::Instance->gRandoContext->GetDungeons()->GetDungeonFromScene(SCENE_BOTTOM_OF_THE_WELL); if (dungeon->IsMQ()) { diff --git a/soh/soh/Enhancements/randomizer/location_access/overworld/zoras_river.cpp b/soh/soh/Enhancements/randomizer/location_access/overworld/zoras_river.cpp index bfd228523..db8c3cce1 100644 --- a/soh/soh/Enhancements/randomizer/location_access/overworld/zoras_river.cpp +++ b/soh/soh/Enhancements/randomizer/location_access/overworld/zoras_river.cpp @@ -32,7 +32,7 @@ void RegionTable_Init_ZoraRiver() { EventAccess(LOGIC_GOSSIP_STONE_FAIRY, []{return logic->CallGossipFairy();}), EventAccess(LOGIC_BEAN_PLANT_FAIRY, []{return logic->IsChild && logic->CanUse(RG_MAGIC_BEAN) && logic->CanUse(RG_SONG_OF_STORMS);}), EventAccess(LOGIC_BUTTERFLY_FAIRY, []{return logic->CanUse(RG_STICKS);}), - EventAccess(LOGIC_BUG_SHRUB, []{return logic->CanCutShrubs();}), + EventAccess(LOGIC_BUG_SHRUB, []{return logic->CanCutShrubs() && (logic->IsChild || logic->CanUse(RG_HOVER_BOOTS) || ctx->GetTrickOption(RT_ZR_LOWER));}), }, { //Locations LOCATION(RC_ZR_MAGIC_BEAN_SALESMAN, logic->IsChild), @@ -61,7 +61,7 @@ void RegionTable_Init_ZoraRiver() { LOCATION(RC_ZR_BENEATH_WATERFALL_RIGHT_RUPEE, logic->IsAdult && (logic->HasItem(RG_BRONZE_SCALE) || logic->CanUse(RG_IRON_BOOTS) || logic->CanUse(RG_BOOMERANG))), LOCATION(RC_ZR_NEAR_GROTTOS_GOSSIP_STONE, true), LOCATION(RC_ZR_NEAR_DOMAIN_GOSSIP_STONE, true), - LOCATION(RC_ZR_NEAR_FREESTANDING_POH_GRASS, logic->CanCutShrubs()), + LOCATION(RC_ZR_NEAR_FREESTANDING_POH_GRASS, (logic->CanCutShrubs() && (logic->IsChild || logic->CanUse(RG_HOVER_BOOTS) || ctx->GetTrickOption(RT_ZR_LOWER))) || logic->CanUse(RG_BOOMERANG)), }, { //Exits Entrance(RR_ZR_FRONT, []{return true;}), diff --git a/soh/soh/Enhancements/randomizer/static_data.cpp b/soh/soh/Enhancements/randomizer/static_data.cpp index 1becef894..ba2dff847 100644 --- a/soh/soh/Enhancements/randomizer/static_data.cpp +++ b/soh/soh/Enhancements/randomizer/static_data.cpp @@ -225,7 +225,7 @@ StaticData::PopulateTranslationMap(std::unordered_map i if (output.contains(string)) { if (output[string] != key) { // RANDOTODO should this cause an error of some kind? - SPDLOG_DEBUG("\tREPEATED STRING IN " + message.GetEnglish(MF_CLEAN) + "\n\n"); + SPDLOG_DEBUG("REPEATED STRING IN " + message.GetEnglish(MF_CLEAN)); } } else { output[string] = key; @@ -244,7 +244,7 @@ StaticData::PopulateTranslationMap(std::unordered_map #include #include +#include #include "Enhancements/gameconsole.h" #ifdef _WIN32 @@ -319,8 +320,13 @@ void OTRGlobals::Initialize() { context->InitCrashHandler(); context->InitConsole(); +#if (_DEBUG) + int defaultLogLevel = 0; +#else + int defaultLogLevel = 2; +#endif Ship::Context::GetInstance()->GetLogger()->set_level( - (spdlog::level::level_enum)CVarGetInteger(CVAR_DEVELOPER_TOOLS("LogLevel"), 1)); + (spdlog::level::level_enum)CVarGetInteger(CVAR_DEVELOPER_TOOLS("LogLevel"), defaultLogLevel)); Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v"); auto sohInputEditorWindow =