diff --git a/CMake/lus-cvars.cmake b/CMake/lus-cvars.cmake index f6a036479..c64782e75 100644 --- a/CMake/lus-cvars.cmake +++ b/CMake/lus-cvars.cmake @@ -1,7 +1,5 @@ set(CVAR_VSYNC_ENABLED "${CVAR_PREFIX_SETTING}.VsyncEnabled" CACHE STRING "") set(CVAR_Z_FIGHTING_MODE "${CVAR_PREFIX_SETTING}.ZFightingMode" CACHE STRING "") -set(CVAR_NEW_FILE_DROPPED "${CVAR_PREFIX_GENERAL}.NewFileDropped" CACHE STRING "") -set(CVAR_DROPPED_FILE "${CVAR_PREFIX_GENERAL}.DroppedFile" CACHE STRING "") set(CVAR_INTERNAL_RESOLUTION "${CVAR_PREFIX_SETTING}.InternalResolution" CACHE STRING "") set(CVAR_MSAA_VALUE "${CVAR_PREFIX_SETTING}.MSAAValue" CACHE STRING "") set(CVAR_SDL_WINDOWED_FULLSCREEN "${CVAR_PREFIX_SETTING}.SdlWindowedFullscreen" CACHE STRING "") diff --git a/CMakeLists.txt b/CMakeLists.txt index ec9f14f5b..cf9c55b5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.26.0 FATAL_ERROR) set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE) set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use") +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") diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index 7277b2dfb..19851f690 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -4,6 +4,7 @@ set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE) project(soh LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use") +set(CMAKE_C_STANDARD 23 CACHE STRING "The C standard to use") if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") enable_language(OBJCXX) @@ -511,10 +512,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") -Wno-parentheses -Wno-narrowing -Wno-missing-braces - -Wno-int-conversion $<$: -Werror-implicit-function-declaration -Wno-incompatible-pointer-types + -Wno-int-conversion > $<$:-fpermissive> $<$: @@ -587,11 +588,11 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") -Wno-parentheses -Wno-narrowing -Wno-missing-braces - -Wno-int-conversion - -Wno-implicit-int $<$: -Werror-implicit-function-declaration + -Wno-implicit-int -Wno-incompatible-pointer-types + -Wno-int-conversion > $<$:-fpermissive> $<$:-Wno-deprecated-enum-enum-conversion> diff --git a/soh/include/functions.h b/soh/include/functions.h index ad615d173..3d1319907 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -15,7 +15,7 @@ extern "C" #include #if defined(INCLUDE_GAME_PRINTF) && defined(_DEBUG) -#define osSyncPrintf(fmt, ...) lusprintf(__FILE__, __LINE__, 0, fmt, __VA_ARGS__) +#define osSyncPrintf(fmt, ...) lusprintf(__FILE__, __LINE__, 0, fmt, ##__VA_ARGS__) #else #define osSyncPrintf(fmt, ...) osSyncPrintfUnused(fmt, ##__VA_ARGS__) #endif @@ -1378,7 +1378,7 @@ void func_800AA0B4(); void func_800AA0F0(void); u32 func_800AA148(); void func_800AA15C(); -void func_800AA16C(); +void Rumble_ClearRequests(); void func_800AA178(u32); View* View_New(GraphicsContext* gfxCtx); void View_Free(View* view); diff --git a/soh/include/z64.h b/soh/include/z64.h index 83e1498db..53b76e8fb 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -544,7 +544,7 @@ typedef enum { LANGUAGE_MAX } Language; -#define TODO_TRANSLATE "__Translate_This__" +#define TODO_TRANSLATE "TranslateThis" // TODO get these properties from the textures themselves #define FONT_CHAR_TEX_WIDTH 16 diff --git a/soh/include/z64animation.h b/soh/include/z64animation.h index b61627a27..3edba982d 100755 --- a/soh/include/z64animation.h +++ b/soh/include/z64animation.h @@ -245,27 +245,30 @@ typedef void (*PostCurveLimbDraw)(struct PlayState* play, SkelAnimeCurve* skelCu typedef s32 (*AnimUpdateFunc)(); typedef struct SkelAnime { - /* 0x00 */ u8 limbCount; // Number of limbs in the skeleton - /* 0x01 */ u8 mode; // See `AnimationMode` - /* 0x02 */ u8 dListCount; // Number of display lists in a flexible skeleton - /* 0x03 */ s8 taper; // Tapering to use when morphing between animations. Only used by Door_Warp1. - /* 0x04 */ void** skeleton; // An array of pointers to limbs. Can be StandardLimb, LodLimb, or SkinLimb. - /* 0x08 */ void* animation; // Can be an AnimationHeader or LinkAnimationHeader. - /* 0x0C */ f32 startFrame; // In mode ANIMMODE_LOOP_PARTIAL*, start of partial loop. - /* 0x10 */ f32 endFrame; // In mode ANIMMODE_ONCE*, Update returns true when curFrame is equal to this. In mode ANIMMODE_LOOP_PARTIAL*, end of partial loop. - /* 0x14 */ f32 animLength; // Total number of frames in the current animation. - /* 0x18 */ f32 curFrame; // Current frame in the animation - /* 0x1C */ f32 playSpeed; // Multiplied by R_UPDATE_RATE / 3 to get the animation's frame rate. + /* 0x00 */ u8 limbCount; // Number of limbs in the skeleton + /* 0x01 */ u8 mode; // See `AnimationMode` + /* 0x02 */ u8 dListCount; // Number of display lists in a flexible skeleton + /* 0x03 */ s8 taper; // Tapering to use when morphing between animations. Only used by Door_Warp1. + /* 0x04 */ void** skeleton; // An array of pointers to limbs. Can be StandardLimb, LodLimb, or SkinLimb. + /* 0x08 */ void* animation; // Can be an AnimationHeader or LinkAnimationHeader. + /* 0x0C */ f32 startFrame; // In mode ANIMMODE_LOOP_PARTIAL*, start of partial loop. + /* 0x10 */ f32 endFrame; // In mode ANIMMODE_ONCE*, Update returns true when curFrame is equal to this. In mode ANIMMODE_LOOP_PARTIAL*, end of partial loop. + /* 0x14 */ f32 animLength; // Total number of frames in the current animation. + /* 0x18 */ f32 curFrame; // Current frame in the animation + /* 0x1C */ f32 playSpeed; // Multiplied by R_UPDATE_RATE / 3 to get the animation's frame rate. /* 0x20 */ Vec3s* jointTable; // Current translation of model and rotations of all limbs /* 0x24 */ Vec3s* morphTable; // Table of values used to morph between animations - /* 0x28 */ f32 morphWeight; // Weight of the current animation morph as a fraction in [0,1] - /* 0x2C */ f32 morphRate; // Reciprocal of the number of frames in the morph - /* 0x30 */ s32 (*update)(); // Can be Loop, Partial loop, Play once, Morph, or Tapered morph. Link only has Loop, Play once, and Morph. - /* 0x34 */ s8 initFlags; // Flags used when initializing Link's skeleton - /* 0x35 */ u8 moveFlags; // Flags used for animations that move the actor in worldspace. - /* 0x36 */ s16 prevRot; // Previous rotation in worldspace. - /* 0x38 */ Vec3s prevTransl; // Previous modelspace translation. - /* 0x3E */ Vec3s baseTransl; // Base modelspace translation. + /* 0x28 */ f32 morphWeight; // Weight of the current animation morph as a fraction in [0,1] + /* 0x2C */ f32 morphRate; // Reciprocal of the number of frames in the morph + /* 0x30 */ union { + s32 (*normal)(struct SkelAnime*); // Can be Loop, Partial loop, Play once, Morph, or Tapered morph + s32 (*link)(struct PlayState*, struct SkelAnime*); // Can be Loop, Play once, or Morph + } update; + /* 0x34 */ s8 initFlags; // Flags used when initializing Link's skeleton + /* 0x35 */ u8 movementFlags; // Flags used for animations that move the actor in worldspace. + /* 0x36 */ s16 prevRot; // Previous rotation in worldspace. + /* 0x38 */ Vec3s prevTransl; // Previous modelspace translation. + /* 0x3E */ Vec3s baseTransl; // Base modelspace translation. SkeletonHeader* skeletonHeader; } SkelAnime; // size = 0x44 diff --git a/soh/soh/Enhancements/TimeSavers/FasterHeavyBlockLift.cpp b/soh/soh/Enhancements/TimeSavers/FasterHeavyBlockLift.cpp index 10a22d903..97c253073 100644 --- a/soh/soh/Enhancements/TimeSavers/FasterHeavyBlockLift.cpp +++ b/soh/soh/Enhancements/TimeSavers/FasterHeavyBlockLift.cpp @@ -41,7 +41,7 @@ void FasterHeavyBlockLift_Register() { LinkAnimationHeader* anim = va_arg(args, LinkAnimationHeader*); // Same actor is used for small and large silver rocks, use actor params to identify large ones - bool isLargeSilverRock = interactActorId == ACTOR_EN_ISHI && interactRangeActor->params & 1 == 1; + bool isLargeSilverRock = (interactActorId == ACTOR_EN_ISHI) && ((interactRangeActor->params & 1) == 1); if (CVarGetInteger(CVAR_ENHANCEMENT("FasterHeavyBlockLift"), 0) && (isLargeSilverRock || interactActorId == ACTOR_BG_HEAVY_BLOCK)) { *should = false; diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp index 9865615bd..4cf1f389d 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -265,6 +265,9 @@ void Draw_SfxTab(const std::string& tabId, SeqType type, const std::string& tabN } } + auto playingFromMenu = CVarGetInteger(CVAR_AUDIO("Playing"), 0); + auto currentBGM = func_800FA0B4(SEQ_PLAYER_BGM_MAIN); + // Longest text in Audio Editor ImVec2 columnSize = ImGui::CalcTextSize("Navi - Look/Hey/Watchout (Target Enemy)"); ImGui::BeginTable(tabId.c_str(), 3, ImGuiTableFlags_SizingFixedFit); @@ -291,10 +294,13 @@ void Draw_SfxTab(const std::string& tabId, SeqType type, const std::string& tabN const std::string lockedButton = ICON_FA_LOCK + hiddenKey; const std::string unlockedButton = ICON_FA_UNLOCK + hiddenKey; const int currentValue = CVarGetInteger(cvarKey.c_str(), defaultValue); + const bool isCurrentlyPlaying = currentValue == playingFromMenu || seqData.sequenceId == currentBGM; ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::Text("%s", seqData.label.c_str()); + ImGui::TextColored( + UIWidgets::ColorValues.at(isCurrentlyPlaying ? UIWidgets::Colors::Yellow : UIWidgets::Colors::White), "%s", + seqData.label.c_str()); ImGui::TableNextColumn(); ImGui::PushItemWidth(-FLT_MIN); const int initialValue = map.contains(currentValue) ? currentValue : defaultValue; diff --git a/soh/soh/Enhancements/controls/InputViewer.cpp b/soh/soh/Enhancements/controls/InputViewer.cpp index 5df02f5da..1fbab40c2 100644 --- a/soh/soh/Enhancements/controls/InputViewer.cpp +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -49,14 +49,14 @@ void InputViewer::RenderButton(std::string btnTexture, std::string btnOutlineTex if (outlineMode == BUTTON_OUTLINE_ALWAYS_SHOWN || (outlineMode == BUTTON_OUTLINE_NOT_PRESSED && !state) || (outlineMode == BUTTON_OUTLINE_PRESSED && state)) { ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(btnOutlineTexture), size, - ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } // Render button if pressed if (state) { ImGui::SetCursorPos(pos); ImGui::SetNextItemAllowOverlap(); ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(btnTexture), size, - ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } } @@ -201,7 +201,7 @@ void InputViewer::DrawElement() { // Background ImGui::Image( Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Input-Viewer-Background"), - scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } // A/B @@ -352,7 +352,7 @@ void InputViewer::DrawElement() { ImGui::SetCursorPos(aPos); ImGui::Image( Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Analog-Stick Outline"), - scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } const int analogStickMode = CVarGetInteger(CVAR_INPUT_VIEWER("AnalogStick.VisibilityMode"), STICK_MODE_ALWAYS_SHOWN); @@ -363,7 +363,7 @@ void InputViewer::DrawElement() { ImVec2(aPos.x + maxStickDistance * ((float)(pads[0].stick_x) / MAX_AXIS_RANGE) * scale, aPos.y - maxStickDistance * ((float)(pads[0].stick_y) / MAX_AXIS_RANGE) * scale)); ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Analog-Stick"), - scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } // Right Stick @@ -376,7 +376,7 @@ void InputViewer::DrawElement() { ImGui::SetCursorPos(aPos); ImGui::Image( Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Right-Stick Outline"), - scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } const int rightStickMode = CVarGetInteger(CVAR_INPUT_VIEWER("RightStick.VisibilityMode"), STICK_MODE_ALWAYS_HIDDEN); @@ -387,7 +387,7 @@ void InputViewer::DrawElement() { ImVec2(aPos.x + maxRightStickDistance * ((float)(pads[0].right_stick_x) / MAX_AXIS_RANGE) * scale, aPos.y - maxRightStickDistance * ((float)(pads[0].right_stick_y) / MAX_AXIS_RANGE) * scale)); ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Right-Stick"), - scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f)); } // Analog stick angle text diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 3f77d1ed4..8a8227073 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -642,10 +642,14 @@ void SohInputEditorWindow::DrawStickSection(uint8_t port, uint8_t stick, int32_t ImGui::SameLine(); ImGui::BeginGroup(); - DrawStickDirectionLine(ICON_FA_ARROW_UP, port, stick, Ship::UP, color); - DrawStickDirectionLine(ICON_FA_ARROW_DOWN, port, stick, Ship::DOWN, color); - DrawStickDirectionLine(ICON_FA_ARROW_LEFT, port, stick, Ship::LEFT, color); - DrawStickDirectionLine(ICON_FA_ARROW_RIGHT, port, stick, Ship::RIGHT, color); + DrawStickDirectionLine(StringHelper::Sprintf("%s##%d", ICON_FA_ARROW_UP, stick).c_str(), port, stick, Ship::UP, + color); + DrawStickDirectionLine(StringHelper::Sprintf("%s##%d", ICON_FA_ARROW_DOWN, stick).c_str(), port, stick, Ship::DOWN, + color); + DrawStickDirectionLine(StringHelper::Sprintf("%s##%d", ICON_FA_ARROW_LEFT, stick).c_str(), port, stick, Ship::LEFT, + color); + DrawStickDirectionLine(StringHelper::Sprintf("%s##%d", ICON_FA_ARROW_RIGHT, stick).c_str(), port, stick, + Ship::RIGHT, color); ImGui::EndGroup(); ImGui::SetNextItemOpen(true, ImGuiCond_Once); if (ImGui::TreeNode(StringHelper::Sprintf("Analog Stick Options##%d", id).c_str())) { @@ -1335,12 +1339,12 @@ void SohInputEditorWindow::DrawOcarinaControlPanel() { ImGui::AlignTextToFramePadding(); ImGui::BulletText("Disable song detection"); - DrawButtonLine(ICON_FA_BAN, 0, BTN_CUSTOM_OCARINA_DISABLE_SONGS); + DrawButtonLine(ICON_FA_BAN "##DisableSongDetection", 0, BTN_CUSTOM_OCARINA_DISABLE_SONGS); ImGui::AlignTextToFramePadding(); ImGui::BulletText("Pitch"); - DrawButtonLine(ICON_FA_ARROW_UP, 0, BTN_CUSTOM_OCARINA_PITCH_UP); - DrawButtonLine(ICON_FA_ARROW_DOWN, 0, BTN_CUSTOM_OCARINA_PITCH_DOWN); + DrawButtonLine(ICON_FA_ARROW_UP "##Pitch", 0, BTN_CUSTOM_OCARINA_PITCH_UP); + DrawButtonLine(ICON_FA_ARROW_DOWN "##Pitch", 0, BTN_CUSTOM_OCARINA_PITCH_DOWN); if (!CVarGetInteger(CVAR_SETTING("CustomOcarina.Enabled"), 0)) { ImGui::EndDisabled(); diff --git a/soh/soh/Enhancements/custom-message/CustomMessageManager.cpp b/soh/soh/Enhancements/custom-message/CustomMessageManager.cpp index 1a6f9ce62..27b080358 100644 --- a/soh/soh/Enhancements/custom-message/CustomMessageManager.cpp +++ b/soh/soh/Enhancements/custom-message/CustomMessageManager.cpp @@ -155,12 +155,12 @@ const std::string CustomMessage::GetFrench(MessageFormat format) const { } const std::string CustomMessage::GetForCurrentLanguage(MessageFormat format) const { - return GetForLanguage(((Language)gSaveContext.language == LANGUAGE_JPN) ? LANGUAGE_ENG : gSaveContext.language, - format); + return GetForLanguage( + ((Language)gSaveContext.language == LANGUAGE_JPN) ? LANGUAGE_ENG : (Language)gSaveContext.language, format); } const std::string CustomMessage::GetForLanguage(uint8_t language, MessageFormat format) const { - std::string output = messages[language] != TODO_TRANSLATE ? messages[language] : messages[LANGUAGE_ENG]; + std::string output = !messages[language].starts_with(TODO_TRANSLATE) ? messages[language] : messages[LANGUAGE_ENG]; ProcessMessageFormat(output, format); return output; } diff --git a/soh/soh/Enhancements/debugger/actorViewer.cpp b/soh/soh/Enhancements/debugger/actorViewer.cpp index 515da6491..2e94e1391 100644 --- a/soh/soh/Enhancements/debugger/actorViewer.cpp +++ b/soh/soh/Enhancements/debugger/actorViewer.cpp @@ -5,6 +5,7 @@ #include "soh/ActorDB.h" #include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/nametag.h" +#include "soh/ShipInit.hpp" #include #include @@ -13,6 +14,7 @@ #include #include #include +#include #include "soh/OTRGlobals.h" #include "soh/cvar_prefixes.h" @@ -31,6 +33,10 @@ extern PlayState* gPlayState; #define DEKUNUTS_FLOWER 10 #define DEBUG_ACTOR_NAMETAG_TAG "debug_actor_viewer" +#define CVAR_ACTOR_NAME_TAGS(val) CVAR_DEVELOPER_TOOLS("ActorViewer.NameTags." val) +#define CVAR_ACTOR_NAME_TAGS_ENABLED_NAME CVAR_ACTOR_NAME_TAGS("Enabled") +#define CVAR_ACTOR_NAME_TAGS_ENABLED CVarGetInteger(CVAR_ACTOR_NAME_TAGS("Enabled"), 0) + typedef struct { u16 id; u16 params; @@ -67,6 +73,10 @@ const std::string GetActorDescription(u16 id) { return ActorDB::Instance->RetrieveEntry(id).entry.valid ? ActorDB::Instance->RetrieveEntry(id).entry.desc : "???"; } +const std::string GetActorDebugName(u16 id) { + return ActorDB::Instance->RetrieveEntry(id).entry.valid ? ActorDB::Instance->RetrieveEntry(id).entry.name : "???"; +} + template void DrawGroupWithBorder(T&& drawFunc, std::string section) { // First group encapsulates the inner portion and border ImGui::BeginChild(std::string("##" + section).c_str(), ImVec2(0, 0), @@ -812,25 +822,37 @@ std::vector GetActorsWithDescriptionContainingString(std::string s) { } void ActorViewer_AddTagForActor(Actor* actor) { - int val = CVarGetInteger(CVAR_DEVELOPER_TOOLS("ActorViewer.NameTags"), ACTORVIEWER_NAMETAGS_NONE); - auto entry = ActorDB::Instance->RetrieveEntry(actor->id); - std::string tag; - - if (val > 0 && entry.entry.valid) { - switch (val) { - case ACTORVIEWER_NAMETAGS_DESC: - tag = entry.desc; - break; - case ACTORVIEWER_NAMETAGS_NAME: - tag = entry.name; - break; - case ACTORVIEWER_NAMETAGS_BOTH: - tag = entry.name + '\n' + entry.desc; - break; - } - - NameTag_RegisterForActorWithOptions(actor, tag.c_str(), { .tag = DEBUG_ACTOR_NAMETAG_TAG }); + if (!CVarGetInteger(CVAR_ACTOR_NAME_TAGS("Enabled"), 0)) { + return; } + + std::vector parts; + + if (CVarGetInteger(CVAR_ACTOR_NAME_TAGS("DisplayID"), 0)) { + parts.push_back(GetActorDebugName(actor->id)); + } + if (CVarGetInteger(CVAR_ACTOR_NAME_TAGS("DisplayDescription"), 0)) { + parts.push_back(GetActorDescription(actor->id)); + } + if (CVarGetInteger(CVAR_ACTOR_NAME_TAGS("DisplayCategory"), 0)) { + parts.push_back(acMapping[actor->category]); + } + if (CVarGetInteger(CVAR_ACTOR_NAME_TAGS("DisplayParams"), 0)) { + parts.push_back(fmt::format("0x{:04X} ({})", (u16)actor->params, actor->params)); + } + + std::string tag = ""; + for (size_t i = 0; i < parts.size(); i++) { + if (i != 0) { + tag += "\n"; + } + tag += parts.at(i); + } + + bool withZBuffer = CVarGetInteger(CVAR_ACTOR_NAME_TAGS("WithZBuffer"), 0); + + NameTag_RegisterForActorWithOptions(actor, tag.c_str(), + { .tag = DEBUG_ACTOR_NAMETAG_TAG, .noZBuffer = !withZBuffer }); } void ActorViewer_AddTagForAllActors() { @@ -881,6 +903,57 @@ void ActorViewerWindow::DrawElement() { } lastSceneId = gPlayState->sceneNum; + if (ImGui::BeginChild("options", ImVec2(0, 0), ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeY)) { + bool toggled = false; + bool optionChange = false; + + ImGui::SeparatorText("Options"); + + toggled = UIWidgets::CVarCheckbox("Actor Name Tags", CVAR_ACTOR_NAME_TAGS("Enabled"), + { { .tooltip = "Adds \"name tags\" above actors for identification" } }); + + ImGui::SameLine(); + + UIWidgets::Button("Display Items", { { .tooltip = "Click to add display items on the name tags" } }); + + if (ImGui::BeginPopupContextItem(nullptr, ImGuiPopupFlags_MouseButtonLeft | ImGuiPopupFlags_NoReopen)) { + optionChange |= UIWidgets::CVarCheckbox("ID", CVAR_ACTOR_NAME_TAGS("DisplayID")); + optionChange |= UIWidgets::CVarCheckbox("Description", CVAR_ACTOR_NAME_TAGS("DisplayDescription")); + optionChange |= UIWidgets::CVarCheckbox("Category", CVAR_ACTOR_NAME_TAGS("DisplayCategory")); + optionChange |= UIWidgets::CVarCheckbox("Params", CVAR_ACTOR_NAME_TAGS("DisplayParams")); + + ImGui::EndPopup(); + } + + optionChange |= UIWidgets::CVarCheckbox( + "Name tags with Z-Buffer", CVAR_ACTOR_NAME_TAGS("WithZBuffer"), + { { .tooltip = "Allow name tags to be obstructed when behind geometry and actors" } }); + + if (toggled || optionChange) { + bool tagsEnabled = CVarGetInteger(CVAR_ACTOR_NAME_TAGS("Enabled"), 0); + bool noOptionsEnabled = !CVarGetInteger(CVAR_ACTOR_NAME_TAGS("DisplayID"), 0) && + !CVarGetInteger(CVAR_ACTOR_NAME_TAGS("DisplayDescription"), 0) && + !CVarGetInteger(CVAR_ACTOR_NAME_TAGS("DisplayCategory"), 0) && + !CVarGetInteger(CVAR_ACTOR_NAME_TAGS("DisplayParams"), 0); + + // Save the user an extra click and prevent adding "empty" tags by enabling, + // disabling, or setting an option based on what changed + if (tagsEnabled && noOptionsEnabled) { + if (toggled) { + CVarSetInteger(CVAR_ACTOR_NAME_TAGS("DisplayID"), 1); + } else { + CVarSetInteger(CVAR_ACTOR_NAME_TAGS("Enabled"), 0); + } + } else if (optionChange && !tagsEnabled && !noOptionsEnabled) { + CVarSetInteger(CVAR_ACTOR_NAME_TAGS("Enabled"), 1); + } + + NameTag_RemoveAllByTag(DEBUG_ACTOR_NAMETAG_TAG); + ActorViewer_AddTagForAllActors(); + } + } + ImGui::EndChild(); + PushStyleCombobox(THEME_COLOR); if (ImGui::BeginCombo("Actor Type", acMapping[category])) { for (int i = 0; i < acMapping.size(); i++) { @@ -1160,20 +1233,6 @@ void ActorViewerWindow::DrawElement() { ImGui::TreePop(); } PopStyleHeader(); - - static std::unordered_map nameTagOptions = { - { 0, "None" }, - { 1, "Short Description" }, - { 2, "Actor ID" }, - { 3, "Both" }, - }; - - if (CVarCombobox( - "Actor Name Tags", CVAR_DEVELOPER_TOOLS("ActorViewer.NameTags"), nameTagOptions, - ComboboxOptions().Color(THEME_COLOR).Tooltip("Adds \"name tags\" above actors for identification"))) { - NameTag_RemoveAllByTag(DEBUG_ACTOR_NAMETAG_TAG); - ActorViewer_AddTagForAllActors(); - } } else { ImGui::Text("Global Context needed for actor info!"); if (needs_reset) { @@ -1190,9 +1249,9 @@ void ActorViewerWindow::DrawElement() { ImGui::EndDisabled(); } -void ActorViewerWindow::InitElement() { - GameInteractor::Instance->RegisterGameHook([](void* refActor) { - Actor* actor = static_cast(refActor); - ActorViewer_AddTagForActor(actor); - }); +void ActorViewer_RegisterNameTagHooks() { + COND_HOOK(OnActorInit, CVAR_ACTOR_NAME_TAGS_ENABLED, + [](void* actor) { ActorViewer_AddTagForActor(static_cast(actor)); }); } + +RegisterShipInitFunc nametagInit(ActorViewer_RegisterNameTagHooks, { CVAR_ACTOR_NAME_TAGS_ENABLED_NAME }); diff --git a/soh/soh/Enhancements/debugger/actorViewer.h b/soh/soh/Enhancements/debugger/actorViewer.h index 5d5bcdf88..709380544 100644 --- a/soh/soh/Enhancements/debugger/actorViewer.h +++ b/soh/soh/Enhancements/debugger/actorViewer.h @@ -7,6 +7,6 @@ class ActorViewerWindow final : public Ship::GuiWindow { using GuiWindow::GuiWindow; void DrawElement() override; - void InitElement() override; + void InitElement() override{}; void UpdateElement() override{}; }; diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h index e70c0d33e..10655cc35 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h @@ -29,6 +29,7 @@ DEFINE_HOOK(OnShopSlotChange, (uint8_t cursorIndex, int16_t price)); DEFINE_HOOK(OnActorInit, (void* actor)); DEFINE_HOOK(OnActorUpdate, (void* actor)); DEFINE_HOOK(OnActorKill, (void* actor)); +DEFINE_HOOK(OnActorDestroy, (void* actor)); DEFINE_HOOK(OnEnemyDefeat, (void* actor)); DEFINE_HOOK(OnBossDefeat, (void* actor)); DEFINE_HOOK(OnTimestamp, (u8 item)); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp index 08f2660dd..b31c38b48 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp @@ -122,6 +122,13 @@ void GameInteractor_ExecuteOnActorKill(void* actor) { GameInteractor::Instance->ExecuteHooksForFilter(actor); } +void GameInteractor_ExecuteOnActorDestroy(void* actor) { + GameInteractor::Instance->ExecuteHooks(actor); + GameInteractor::Instance->ExecuteHooksForID(((Actor*)actor)->id, actor); + GameInteractor::Instance->ExecuteHooksForPtr((uintptr_t)actor, actor); + GameInteractor::Instance->ExecuteHooksForFilter(actor); +} + void GameInteractor_ExecuteOnEnemyDefeat(void* actor) { GameInteractor::Instance->ExecuteHooks(actor); GameInteractor::Instance->ExecuteHooksForID(((Actor*)actor)->id, actor); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h index cd8e7962e..a8133820b 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h @@ -31,6 +31,7 @@ void GameInteractor_ExecuteOnCuccoOrChickenHatch(); void GameInteractor_ExecuteOnActorInit(void* actor); void GameInteractor_ExecuteOnActorUpdate(void* actor); void GameInteractor_ExecuteOnActorKill(void* actor); +void GameInteractor_ExecuteOnActorDestroy(void* actor); void GameInteractor_ExecuteOnEnemyDefeat(void* actor); void GameInteractor_ExecuteOnBossDefeat(void* actor); void GameInteractor_ExecuteOnTimestamp(u8 item); diff --git a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h index 597be2a97..12b0e7fb2 100644 --- a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h +++ b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h @@ -519,6 +519,14 @@ typedef enum { // - `*BgHeavyBlock` VB_FREEZE_LINK_FOR_BLOCK_THROW, + // #### `result` + // ```c + // true + // ``` + // #### `args` + // - None + VB_FREEZE_LINK_FOR_FOREST_PILLARS, + // #### `result` // ```c // true @@ -1403,6 +1411,14 @@ typedef enum { // - `*BgTreemouth` VB_PLAY_DEKU_TREE_INTRO_CS, + // #### `result` + // ```c + // true + // ``` + // #### `args` + // - `*DemoKekkai` + VB_PLAY_DISPEL_BARRIER_CS, + // #### `result` // ```c // true @@ -1467,6 +1483,15 @@ typedef enum { // - None VB_PLAY_FIRE_ARROW_CS, + // #### `result` + // ```c + // true + // ``` + // #### `args` + // - `*EnHeishi2` + // - `bool` (clearCamera - true if the code clears a sub-camera, false otherwise) + VB_PLAY_GATE_OPENING_OR_CLOSING_CS, + // #### `result` // ```c // true diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 2c357fd34..a183680a8 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -12,7 +12,6 @@ #include "soh/Enhancements/randomizer/3drando/random.hpp" #include "soh/Enhancements/cosmetics/authenticGfxPatches.h" #include -#include "soh/Enhancements/nametag.h" #include "soh/Enhancements/timesaver_hook_handlers.h" #include "soh/Enhancements/TimeSavers/TimeSavers.h" #include "soh/Enhancements/randomizer/hook_handlers.h" @@ -1090,7 +1089,6 @@ void InitMods() { RegisterRandomizedEnemySizes(); RegisterOpenAllHours(); RegisterToTMedallions(); - NameTag_RegisterHooks(); RegisterFloorSwitchesHook(); RegisterPatchHandHandler(); RegisterHurtContainerModeHandler(); diff --git a/soh/soh/Enhancements/nametag.cpp b/soh/soh/Enhancements/nametag.cpp index 253c0980b..1989b3552 100644 --- a/soh/soh/Enhancements/nametag.cpp +++ b/soh/soh/Enhancements/nametag.cpp @@ -5,7 +5,7 @@ #include "soh/frame_interpolation.h" #include "soh/Enhancements/custom-message/CustomMessageInterfaceAddon.h" #include "soh/Enhancements/game-interactor/GameInteractor.h" -#include "soh/OTRGlobals.h" +#include "soh/ShipUtils.h" extern "C" { #include "z64.h" @@ -26,12 +26,16 @@ typedef struct { int16_t height; // Textbox height int16_t width; // Textbox width int16_t yOffset; // Addition Y offset + uint8_t noZBuffer; // Allow rendering over geometry Mtx* mtx; // Allocated Mtx for rendering Vtx* vtx; // Allocated Vtx for rendering } NameTag; static std::vector nameTags; static std::vector nameTagDl; +static bool sMirrorWorldActive = false; + +void NameTag_RegisterHooks(); void FreeNameTag(NameTag* nameTag) { if (nameTag->vtx != nullptr) { @@ -51,14 +55,14 @@ void DrawNameTag(PlayState* play, const NameTag* nameTag) { } // Name tag is too far away to meaningfully read, don't bother rendering it - if (nameTag->actor->xyzDistToPlayerSq > 200000.0f) { + if (nameTag->actor->xyzDistToPlayerSq > 440000.0f) { return; } // Fade out name tags that are far away float alpha = 1.0f; - if (nameTag->actor->xyzDistToPlayerSq > 160000.0f) { - alpha = (200000.0f - nameTag->actor->xyzDistToPlayerSq) / 40000.0f; + if (nameTag->actor->xyzDistToPlayerSq > 360000.0f) { + alpha = (440000.0f - nameTag->actor->xyzDistToPlayerSq) / 80000.0f; } float scale = 75.0f / 100.f; @@ -79,7 +83,7 @@ void DrawNameTag(PlayState* play, const NameTag* nameTag) { textColor = CVarGetColor(CVAR_COSMETIC("HUD.NameTagActorText.Value"), textColor); } - FrameInterpolation_RecordOpenChild(nameTag->actor, 10); + FrameInterpolation_RecordOpenChild(nameTag->actor, 0); // Prefer the highest between world position and focus position if targetable float posY = nameTag->actor->world.pos.y; @@ -92,7 +96,7 @@ void DrawNameTag(PlayState* play, const NameTag* nameTag) { // Set position, billboard effect, scale (with mirror mode), then center nametag Matrix_Translate(nameTag->actor->world.pos.x, posY, nameTag->actor->world.pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(scale * (CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0) ? -1 : 1), -scale, 1.0f, MTXMODE_APPLY); + Matrix_Scale(scale * (sMirrorWorldActive ? -1.0f : 1.0f), -scale, 1.0f, MTXMODE_APPLY); Matrix_Translate(-(float)nameTag->width / 2, -nameTag->height, 0, MTXMODE_APPLY); Matrix_ToMtx(nameTag->mtx, (char*)__FILE__, __LINE__); @@ -154,15 +158,27 @@ void DrawNameTags() { OPEN_DISPS(gPlayState->state.gfxCtx); // Setup before rendering name tags - Gfx_SetupDL_38Xlu(gPlayState->state.gfxCtx); - nameTagDl.push_back(gsDPSetAlphaDither(G_AD_DISABLE)); - nameTagDl.push_back(gsSPClearGeometryMode(G_SHADE)); + POLY_XLU_DISP = Gfx_SetupDL_39(POLY_XLU_DISP); + nameTagDl.push_back(gsDPSetAlphaCompare(G_AC_NONE)); nameTagDl.push_back( gsDPSetCombineLERP(0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0)); + bool zbufferEnabled = false; + // Add all the name tags for (const auto& nameTag : nameTags) { + // Toggle ZBuffer mode based on last state and next tag + if (zbufferEnabled == nameTag.noZBuffer) { + if (nameTag.noZBuffer) { + nameTagDl.push_back(gsSPClearGeometryMode(G_ZBUFFER)); + zbufferEnabled = false; + } else { + nameTagDl.push_back(gsSPSetGeometryMode(G_ZBUFFER)); + zbufferEnabled = true; + } + } + DrawNameTag(gPlayState, &nameTag); } @@ -189,22 +205,22 @@ void UpdateNameTags() { return aDistToCamera > bDistToCamera; }); + + sMirrorWorldActive = CVarGetInteger(CVAR_ENHANCEMENT("MirroredWorld"), 0); } extern "C" void NameTag_RegisterForActorWithOptions(Actor* actor, const char* text, NameTagOptions options) { std::string processedText = std::string(Interface_ReplaceSpecialCharacters((char*)text)); // Strip out unsupported characters - processedText.erase(std::remove_if(processedText.begin(), processedText.end(), - [](const char& c) { - // 172 is max supported texture for the in-game font system, - // and filter anything less than a space but not the newline or nul - // characters - return (unsigned char)c > 172 || (c < ' ' && c != '\n' && c != '\0'); - }), - processedText.end()); + // 172 is max supported texture for the in-game font system, + // and filter anything less than a space but not the newline or nul characters + processedText.erase( + std::remove_if(processedText.begin(), processedText.end(), + [](const char& c) { return (uint8_t)c > 172 || (c < ' ' && c != '\n' && c != '\0'); }), + processedText.end()); - int16_t numChar = processedText.length(); + size_t numChar = processedText.length(); int16_t numLines = 1; int16_t offsetX = 0; int16_t maxOffsetX = 0; @@ -213,7 +229,7 @@ extern "C" void NameTag_RegisterForActorWithOptions(Actor* actor, const char* te Vtx* vertices = (Vtx*)calloc(sizeof(Vtx[4]), numChar + 1); // Set all the char vtx first to get the total size for the textbox - for (int16_t i = 0; i < numChar; i++) { + for (size_t i = 0; i < numChar; i++) { if (processedText[i] == '\n') { offsetX = 0; numLines++; @@ -249,10 +265,13 @@ extern "C" void NameTag_RegisterForActorWithOptions(Actor* actor, const char* te nameTag.height = height; nameTag.width = width; nameTag.yOffset = options.yOffset; + nameTag.noZBuffer = options.noZBuffer; nameTag.mtx = new Mtx(); nameTag.vtx = vertices; nameTags.push_back(nameTag); + + NameTag_RegisterHooks(); } extern "C" void NameTag_RegisterForActor(Actor* actor, const char* text) { @@ -268,6 +287,8 @@ extern "C" void NameTag_RemoveAllForActor(Actor* actor) { it++; } } + + NameTag_RegisterHooks(); } extern "C" void NameTag_RemoveAllByTag(const char* tag) { @@ -279,6 +300,8 @@ extern "C" void NameTag_RemoveAllByTag(const char* tag) { it++; } } + + NameTag_RegisterHooks(); } void RemoveAllNameTags() { @@ -287,23 +310,49 @@ void RemoveAllNameTags() { } nameTags.clear(); + + NameTag_RegisterHooks(); } -static bool sRegisteredHooks = false; - void NameTag_RegisterHooks() { - if (sRegisteredHooks) { + static HOOK_ID gameStatUpdateHookID = 0; + static HOOK_ID drawHookID = 0; + static HOOK_ID playDestroyHookID = 0; + static HOOK_ID actorDestroyHookID = 0; + static bool sRegisteredHooks = false; + + // Hooks already (un)registered based on nametags + if ((nameTags.size() > 0) == sRegisteredHooks) { + return; + } + + GameInteractor::Instance->UnregisterGameHook(gameStatUpdateHookID); + GameInteractor::Instance->UnregisterGameHook(drawHookID); + GameInteractor::Instance->UnregisterGameHook(playDestroyHookID); + GameInteractor::Instance->UnregisterGameHook(actorDestroyHookID); + gameStatUpdateHookID = 0; + drawHookID = 0; + playDestroyHookID = 0; + actorDestroyHookID = 0; + sRegisteredHooks = false; + + if (nameTags.size() == 0) { return; } sRegisteredHooks = true; // Reorder tags every frame to mimic depth rendering - GameInteractor::Instance->RegisterGameHook([]() { UpdateNameTags(); }); + gameStatUpdateHookID = + GameInteractor::Instance->RegisterGameHook(UpdateNameTags); - // Render name tags at the end of player draw to avoid overflowing the display buffers - GameInteractor::Instance->RegisterGameHook([]() { DrawNameTags(); }); + // Render name tags at the end of the Play World drawing + drawHookID = GameInteractor::Instance->RegisterGameHook(DrawNameTags); // Remove all name tags on play state destroy as all actors are removed anyways - GameInteractor::Instance->RegisterGameHook([]() { RemoveAllNameTags(); }); + playDestroyHookID = GameInteractor::Instance->RegisterGameHook(RemoveAllNameTags); + + // Remove all name tags for actor on destroy + actorDestroyHookID = GameInteractor::Instance->RegisterGameHook( + [](void* actor) { NameTag_RemoveAllForActor((Actor*)actor); }); } diff --git a/soh/soh/Enhancements/nametag.h b/soh/soh/Enhancements/nametag.h index 98b83f7cc..47908e875 100644 --- a/soh/soh/Enhancements/nametag.h +++ b/soh/soh/Enhancements/nametag.h @@ -1,11 +1,16 @@ -#ifndef _NAMETAG_H_ -#define _NAMETAG_H_ -#include +#ifndef NAMETAG_H +#define NAMETAG_H + +#include +#include + +struct Actor; typedef struct { const char* tag; // Tag identifier to filter/remove multiple tags int16_t yOffset; // Additional Y offset to apply for the name tag Color_RGBA8 textColor; // Text color override. Global color is used if alpha is 0 + uint8_t noZBuffer; // Allow rendering over geometry } NameTagOptions; // Register required hooks for nametags on startup @@ -28,4 +33,4 @@ void NameTag_RemoveAllByTag(const char* tag); } #endif -#endif // _NAMETAG_H_ +#endif // NAMETAG_H diff --git a/soh/soh/Enhancements/randomizer/3drando/fill.cpp b/soh/soh/Enhancements/randomizer/3drando/fill.cpp index 899bc17bf..f0954231b 100644 --- a/soh/soh/Enhancements/randomizer/3drando/fill.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/fill.cpp @@ -625,6 +625,8 @@ void ValidateEntrances(bool checkPoeCollectorAccess, bool checkOtherEntranceAcce if (ctx->GetOption(RSK_SHUFFLE_INTERIOR_ENTRANCES).Is(RO_INTERIOR_ENTRANCE_SHUFFLE_OFF)) { Rando::StaticData::RetrieveItem(RG_GUARD_HOUSE_KEY).ApplyEffect(); } + RegionTable(RR_ROOT)->adultNight = true; + RegionTable(RR_ROOT)->adultDay = true; } else { ApplyAllAdvancmentItems(); } @@ -710,11 +712,11 @@ static void PareDownPlaythrough() { auto ctx = Rando::Context::GetInstance(); std::vector toAddBackItem; // Start at sphere before Ganon's and count down - for (int i = ctx->playthroughLocations.size() - 2; i >= 0; i--) { + for (int32_t i = static_cast(ctx->playthroughLocations.size()) - 2; i >= 0; i--) { // Check each item location in sphere std::vector erasableIndices; std::vector sphere = ctx->playthroughLocations.at(i); - for (int j = sphere.size() - 1; j >= 0; j--) { + for (int32_t j = static_cast(sphere.size()) - 1; j >= 0; j--) { RandomizerCheck loc = sphere.at(j); RandomizerGet locGet = ctx->GetItemLocation(loc)->GetPlacedRandomizerGet(); // Copy out item diff --git a/soh/soh/Enhancements/randomizer/3drando/fill.hpp b/soh/soh/Enhancements/randomizer/3drando/fill.hpp index f2028e05d..7e2e99e12 100644 --- a/soh/soh/Enhancements/randomizer/3drando/fill.hpp +++ b/soh/soh/Enhancements/randomizer/3drando/fill.hpp @@ -72,4 +72,4 @@ void GeneratePlaythrough(); bool CheckBeatable(RandomizerGet ignore = RG_NONE); -void ValidateEntrances(bool checkPoeCollectorAccess, bool checkOtherEntranceAccess); \ No newline at end of file +void ValidateEntrances(bool checkPoeCollectorAccess, bool checkOtherEntranceAccess); diff --git a/soh/soh/Enhancements/randomizer/3drando/hint_list.cpp b/soh/soh/Enhancements/randomizer/3drando/hint_list.cpp index a1cb845f3..734ab00bf 100644 --- a/soh/soh/Enhancements/randomizer/3drando/hint_list.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/hint_list.cpp @@ -2467,13 +2467,13 @@ void StaticData::HintTable_Init() { /*german*/ "ein abgelegener Ort", /*french*/ "un lieu isolé")); - hintTextTable[RHT_DUNGEON_ORDINARY] = HintText(CustomMessage(" It's ordinary.", - /*german*/ "&Sieht aus wie immer.", - /*french*/ "&Elle vous semble %rordinaire%w.")); + hintTextTable[RHT_DUNGEON_ORDINARY] = HintText(CustomMessage("&It's %gordinary%w.", + /*german*/ "&Sieht aus %gwie immer%w.", + /*french*/ "&Elle vous semble %gordinaire%w.")); - hintTextTable[RHT_DUNGEON_MASTERFUL] = HintText(CustomMessage(" It's masterful!", - /*german*/ "&Man kann darauf die Worte&%r\"Master Quest\"%w entziffern...", - /*french*/ "&Étrange... les mots %r\"Master&Quest\"%w sont gravés dessus.")); + hintTextTable[RHT_DUNGEON_MASTERFUL] = HintText(CustomMessage("&It's %rmasterful%w!", + /*german*/ "&Man kann darauf die Worte %r\"Master_Quest\"%w entziffern...", + /*french*/ "&Étrange... les mots %r\"Master_Quest\"%w sont gravés dessus.")); // clang-format on } diff --git a/soh/soh/Enhancements/randomizer/3drando/hints.cpp b/soh/soh/Enhancements/randomizer/3drando/hints.cpp index 8e928185f..6a83c498e 100644 --- a/soh/soh/Enhancements/randomizer/3drando/hints.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/hints.cpp @@ -63,11 +63,11 @@ const CustomMessage& HintText::GetAmbiguous(uint8_t selection) const { } uint8_t HintText::GetAmbiguousSize() const { - return ambiguousText.size(); + return static_cast(ambiguousText.size()); } uint8_t HintText::GetObscureSize() const { - return obscureText.size(); + return static_cast(obscureText.size()); } const CustomMessage& HintText::GetHintMessage(uint8_t selection) const { @@ -598,7 +598,7 @@ static void DistributeHints(std::vector& selected, size_t stoneCount, } // if stones are left, assign junk to every remaining stone as a fallback. if (stoneCount > 0) { - selected[selected.size() - 1] += stoneCount; + selected[static_cast(selected.size()) - 1] += static_cast(stoneCount); } } diff --git a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp index 11aa45e30..da1c1fb31 100644 --- a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp @@ -325,7 +325,7 @@ RandomizerGet GetJunkItem() { return RandomElement(JunkPoolItems); } // Ice Trap is the last item in JunkPoolItems, so subtract 1 to never hit that index - uint8_t idx = Random(0, JunkPoolItems.size() - 1); + uint8_t idx = Random(0, static_cast(JunkPoolItems.size()) - 1); return JunkPoolItems[idx]; } diff --git a/soh/soh/Enhancements/randomizer/3drando/menu.cpp b/soh/soh/Enhancements/randomizer/3drando/menu.cpp index 831330571..cf3a0bc3d 100644 --- a/soh/soh/Enhancements/randomizer/3drando/menu.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/menu.cpp @@ -27,7 +27,7 @@ bool GenerateRandomizer(std::set excludedLocations, std::set(time(NULL))); // if a blank seed was entered, make a random one if (seedInput.empty()) { seedInput = std::to_string(rand() % 0xFFFFFFFF); @@ -35,7 +35,7 @@ bool GenerateRandomizer(std::set excludedLocations, std::set T RandomElement(std::vector& vector, bool erase) { - const auto idx = Random(0, vector.size()); + const auto idx = Random(0, static_cast(vector.size())); const T selected = vector[idx]; if (erase) { vector.erase(vector.begin() + idx); diff --git a/soh/soh/Enhancements/randomizer/3drando/shops.cpp b/soh/soh/Enhancements/randomizer/3drando/shops.cpp index 110ab8a76..115f36394 100644 --- a/soh/soh/Enhancements/randomizer/3drando/shops.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/shops.cpp @@ -115,7 +115,7 @@ uint16_t GetPriceFromSettings(Rando::Location* loc, PriceSettingsStruct priceSet if (random < ShopPriceProbability[i]) { // The randomly generated value has surpassed the total probability up to this point, so this is the // generated price i in range [0, 59], output in range [0, 295] in increments of 5 - return i * 5; + return static_cast(i) * 5; } } return 150; @@ -196,7 +196,8 @@ uint16_t GetCheapBalancedPrice() { double random = RandomDouble(); for (size_t i = 0; i < CheapPriceProbability.size(); i++) { if (random < CheapPriceProbability[i]) { - return i * 5; // i in range [0, 19], output in range [0, 95] in increments of 5 + // i in range [0, 19], output in range [0, 95] in increments of 5 + return static_cast(i) * 5; } } return -1; diff --git a/soh/soh/Enhancements/randomizer/Plandomizer.cpp b/soh/soh/Enhancements/randomizer/Plandomizer.cpp index dc32dc999..4e03e8b8f 100644 --- a/soh/soh/Enhancements/randomizer/Plandomizer.cpp +++ b/soh/soh/Enhancements/randomizer/Plandomizer.cpp @@ -632,7 +632,7 @@ void PlandomizerLoadSpoilerLog(std::string logFile) { PlandomizerAddToItemList(plandomizerRandoRetrieveItem(RG_SOLD_OUT)); } } - } catch (nlohmann::json::parse_error& e) { + } catch (nlohmann::json::parse_error&) { Notification::Emit({ .message = "Invalid Spoiler Log Format", .remainingTime = 10.0f }); } } @@ -967,7 +967,7 @@ void PlandomizerDrawOptions() { } ImGui::TableNextColumn(); - size_t index = 0; + int32_t index = 0; PlandoPushImageButtonStyle(); for (auto& hash : plandoHash) { ImGui::PushID(index); @@ -995,7 +995,7 @@ void PlandomizerDrawOptions() { ImGui::PopStyleVar(); if (downRet) { if (hash == 0) { - hash = gSeedTextures.size() - 1; + hash = static_cast(gSeedTextures.size()) - 1; } else { hash--; } diff --git a/soh/soh/Enhancements/randomizer/ShuffleCows.cpp b/soh/soh/Enhancements/randomizer/ShuffleCows.cpp index 203981133..5dfe02b26 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleCows.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleCows.cpp @@ -19,7 +19,7 @@ void EnCow_MoveForRandomizer(EnCow* enCow, PlayState* play) { // Move left cow in lon lon tower enCow->actor.world.pos.x = -229.0f; enCow->actor.world.pos.z = 157.0f; - enCow->actor.shape.rot.y = 15783.0f; + enCow->actor.shape.rot.y = 15783; moved = true; } else if (play->sceneNum == SCENE_STABLE && enCow->actor.world.pos.x == -3 && enCow->actor.world.pos.z == -254) { // Move right cow in lon lon stable @@ -39,7 +39,8 @@ void RegisterShuffleCows() { COND_VB_SHOULD(VB_GIVE_ITEM_FROM_COW, shouldRegister, { EnCow* enCow = va_arg(args, EnCow*); CowIdentity cowIdentity = OTRGlobals::Instance->gRandomizer->IdentifyCow( - gPlayState->sceneNum, enCow->actor.world.pos.x, enCow->actor.world.pos.z); + gPlayState->sceneNum, static_cast(enCow->actor.world.pos.x), + static_cast(enCow->actor.world.pos.z)); // Has this cow already rewarded an item? if (!Flags_GetRandomizerInf(cowIdentity.randomizerInf)) { Flags_SetRandomizerInf(cowIdentity.randomizerInf); diff --git a/soh/soh/Enhancements/randomizer/ShuffleCrates.cpp b/soh/soh/Enhancements/randomizer/ShuffleCrates.cpp index 32548b310..64756213b 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleCrates.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleCrates.cpp @@ -3,6 +3,7 @@ #include "static_data.h" #include #include "global.h" +#include "soh/ResourceManagerHelpers.h" extern "C" { #include "variables.h" @@ -11,7 +12,6 @@ extern "C" { #include "overlays/actors/ovl_Obj_Kibako/z_obj_kibako.h" #include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #include "soh/Enhancements/enhancementTypes.h" -#include "soh/ResourceManagerHelpers.h" extern PlayState* gPlayState; } @@ -195,7 +195,7 @@ void ObjKibako2_RandomizerSpawnCollectible(ObjKibako2* crateActor, PlayState* pl item00->actor.draw = (ActorFunc)EnItem00_DrawRandomizedItem; item00->actor.velocity.y = 8.0f; item00->actor.speedXZ = 2.0f; - item00->actor.world.rot.y = Rand_CenteredFloat(65536.0f); + item00->actor.world.rot.y = static_cast(Rand_CenteredFloat(65536.0f)); } void ObjKibako_RandomizerSpawnCollectible(ObjKibako* smallCrateActor, PlayState* play) { @@ -206,7 +206,7 @@ void ObjKibako_RandomizerSpawnCollectible(ObjKibako* smallCrateActor, PlayState* item00->actor.draw = (ActorFunc)EnItem00_DrawRandomizedItem; item00->actor.velocity.y = 8.0f; item00->actor.speedXZ = 2.0f; - item00->actor.world.rot.y = Rand_CenteredFloat(65536.0f); + item00->actor.world.rot.y = static_cast(Rand_CenteredFloat(65536.0f)); } void ObjKibako2_RandomizerInit(void* actorRef) { diff --git a/soh/soh/Enhancements/randomizer/ShuffleGrass.cpp b/soh/soh/Enhancements/randomizer/ShuffleGrass.cpp index b2e485a34..1aa0970d2 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleGrass.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleGrass.cpp @@ -117,7 +117,7 @@ void EnKusa_RandomizerSpawnCollectible(EnKusa* grassActor, PlayState* play) { item00->actor.draw = (ActorFunc)EnItem00_DrawRandomizedItem; item00->actor.velocity.y = 8.0f; item00->actor.speedXZ = 2.0f; - item00->actor.world.rot.y = Rand_CenteredFloat(65536.0f); + item00->actor.world.rot.y = static_cast(Rand_CenteredFloat(65536.0f)); } void EnKusa_RandomizerInit(void* actorRef) { diff --git a/soh/soh/Enhancements/randomizer/ShufflePots.cpp b/soh/soh/Enhancements/randomizer/ShufflePots.cpp index 09e4db848..c310b0cb2 100644 --- a/soh/soh/Enhancements/randomizer/ShufflePots.cpp +++ b/soh/soh/Enhancements/randomizer/ShufflePots.cpp @@ -48,7 +48,7 @@ void ObjTsubo_RandomizerSpawnCollectible(ObjTsubo* potActor, PlayState* play) { item00->actor.draw = (ActorFunc)EnItem00_DrawRandomizedItem; item00->actor.velocity.y = 8.0f; item00->actor.speedXZ = 2.0f; - item00->actor.world.rot.y = Rand_CenteredFloat(65536.0f); + item00->actor.world.rot.y = static_cast(Rand_CenteredFloat(65536.0f)); } void ObjTsubo_RandomizerInit(void* actorRef) { diff --git a/soh/soh/Enhancements/randomizer/draw.cpp b/soh/soh/Enhancements/randomizer/draw.cpp index 0403966b7..b9cc0b10b 100644 --- a/soh/soh/Enhancements/randomizer/draw.cpp +++ b/soh/soh/Enhancements/randomizer/draw.cpp @@ -597,7 +597,7 @@ extern "C" s32 OverrideLimbDrawBarinade(PlayState* play, s32 limbIndex, Gfx** dL (uintptr_t)Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 8, 16, 1, 0, (play->gameplayFrames * -2) % 64, 16, 16)); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 200); - Matrix_RotateX(-M_PI / 2, MTXMODE_APPLY); + Matrix_RotateX(-M_PIf / 2.0f, MTXMODE_APPLY); } else if ((limbIndex >= 10) && (limbIndex < 20)) { rot->x -= 0x4000; *dList = NULL; @@ -1097,7 +1097,7 @@ extern "C" void Randomizer_DrawBronzeScale(PlayState* play, GetItemEntry* getIte gSPSegment(POLY_XLU_DISP++, 0x08, (uintptr_t)Gfx_TwoTexScroll(play->state.gfxCtx, 0, 1 * (play->state.frames * 2), -1 * (play->state.frames * 2), 64, 64, 1, 1 * (play->state.frames * 4), - 1 * -(play->state.frames * 4), 32, 32)); + -1 * (play->state.frames * 4), 32, 32)); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, (char*)__FILE__, __LINE__), G_MTX_MODELVIEW | G_MTX_LOAD); @@ -1116,7 +1116,7 @@ extern "C" void Randomizer_DrawFishingPoleGI(PlayState* play, GetItemEntry* getI // Draw rod Gfx_SetupDL_25Opa(play->state.gfxCtx); - Matrix_Scale(0.2, 0.2, 0.2, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, (char*)__FILE__, __LINE__), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, (Gfx*)gFishingPoleGiDL); @@ -1126,8 +1126,8 @@ extern "C" void Randomizer_DrawFishingPoleGI(PlayState* play, GetItemEntry* getI Matrix_Scale(5.0f, 5.0f, 5.0f, MTXMODE_APPLY); pos = { 0.0f, -25.5f, -4.0f }; Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_APPLY); - Matrix_RotateZ(-M_PI_2, MTXMODE_APPLY); - Matrix_RotateY(-M_PI_2 - 0.2f, MTXMODE_APPLY); + Matrix_RotateZ(-M_PI_2f, MTXMODE_APPLY); + Matrix_RotateY(-M_PI_2f - 0.2f, MTXMODE_APPLY); Matrix_Scale(0.006f, 0.006f, 0.006f, MTXMODE_APPLY); Gfx_SetupDL_25Opa(play->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, (char*)__FILE__, __LINE__), @@ -1140,7 +1140,7 @@ extern "C" void Randomizer_DrawFishingPoleGI(PlayState* play, GetItemEntry* getI gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, (char*)__FILE__, __LINE__), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, (Gfx*)gFishingLureHookDL); - Matrix_RotateZ(M_PI_2, MTXMODE_APPLY); + Matrix_RotateZ(M_PI_2f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, (char*)__FILE__, __LINE__), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, (Gfx*)gFishingLureHookDL); @@ -1149,7 +1149,7 @@ extern "C" void Randomizer_DrawFishingPoleGI(PlayState* play, GetItemEntry* getI gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, (char*)__FILE__, __LINE__), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, (Gfx*)gFishingLureHookDL); - Matrix_RotateZ(M_PI / 2, MTXMODE_APPLY); + Matrix_RotateZ(M_PIf / 2.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, (char*)__FILE__, __LINE__), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, (Gfx*)gFishingLureHookDL); diff --git a/soh/soh/Enhancements/randomizer/hint.cpp b/soh/soh/Enhancements/randomizer/hint.cpp index d81e94f2f..3b1cb23f4 100644 --- a/soh/soh/Enhancements/randomizer/hint.cpp +++ b/soh/soh/Enhancements/randomizer/hint.cpp @@ -226,7 +226,8 @@ uint8_t Hint::GetNumberOfMessages() const { if (numMessages == 0) { numMessages = 1; // RANDOTODO make std::max actually fucking work for 3 arguments } - return numMessages; + // RANDOTODO will number of messages always be u8? + return static_cast(numMessages); } const std::vector Hint::GetAllMessageStrings(MessageFormat format) const { diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index 63a1917bb..c2b7e7b32 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -1013,7 +1013,7 @@ void RandomizerOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_l if (item00->itemEntry.getItemId == GI_SWORD_BGS) { gSaveContext.bgsFlag = true; } - Item_Give(gPlayState, item00->itemEntry.itemId); + Item_Give(gPlayState, static_cast(item00->itemEntry.itemId)); } else if (item00->itemEntry.modIndex == MOD_RANDOMIZER) { if (item00->itemEntry.getItemId == RG_ICE_TRAP) { gSaveContext.ship.pendingIceTrapCount++; @@ -2137,23 +2137,23 @@ void RandomizerOnActorInitHandler(void* actorRef) { void RandomizerOnGameFrameUpdateHandler() { if (Flags_GetRandomizerInf(RAND_INF_HAS_INFINITE_QUIVER)) { - AMMO(ITEM_BOW) = CUR_CAPACITY(UPG_QUIVER); + AMMO(ITEM_BOW) = static_cast(CUR_CAPACITY(UPG_QUIVER)); } if (Flags_GetRandomizerInf(RAND_INF_HAS_INFINITE_BOMB_BAG)) { - AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); + AMMO(ITEM_BOMB) = static_cast(CUR_CAPACITY(UPG_BOMB_BAG)); } if (Flags_GetRandomizerInf(RAND_INF_HAS_INFINITE_BULLET_BAG)) { - AMMO(ITEM_SLINGSHOT) = CUR_CAPACITY(UPG_BULLET_BAG); + AMMO(ITEM_SLINGSHOT) = static_cast(CUR_CAPACITY(UPG_BULLET_BAG)); } if (Flags_GetRandomizerInf(RAND_INF_HAS_INFINITE_STICK_UPGRADE)) { - AMMO(ITEM_STICK) = CUR_CAPACITY(UPG_STICKS); + AMMO(ITEM_STICK) = static_cast(CUR_CAPACITY(UPG_STICKS)); } if (Flags_GetRandomizerInf(RAND_INF_HAS_INFINITE_NUT_UPGRADE)) { - AMMO(ITEM_NUT) = CUR_CAPACITY(UPG_NUTS); + AMMO(ITEM_NUT) = static_cast(CUR_CAPACITY(UPG_NUTS)); } if (Flags_GetRandomizerInf(RAND_INF_HAS_INFINITE_MAGIC_METER)) { @@ -2165,7 +2165,7 @@ void RandomizerOnGameFrameUpdateHandler() { } if (Flags_GetRandomizerInf(RAND_INF_HAS_INFINITE_MONEY)) { - gSaveContext.rupees = CUR_CAPACITY(UPG_WALLET); + gSaveContext.rupees = static_cast(CUR_CAPACITY(UPG_WALLET)); } if (!Flags_GetRandomizerInf(RAND_INF_HAS_WALLET)) { diff --git a/soh/soh/Enhancements/randomizer/location_access.cpp b/soh/soh/Enhancements/randomizer/location_access.cpp index 80fe62e50..aa32add42 100644 --- a/soh/soh/Enhancements/randomizer/location_access.cpp +++ b/soh/soh/Enhancements/randomizer/location_access.cpp @@ -10,9 +10,10 @@ #include "soh/Enhancements/debugger/performanceTimer.h" #include +#include +#include "3drando/shops.hpp" extern "C" { -extern SaveContext gSaveContext; extern PlayState* gPlayState; } @@ -45,17 +46,71 @@ bool LocationAccess::ConditionsMet(Region* parentRegion, bool calculatingAvailab conditionsMet = true; } - return conditionsMet && - (calculatingAvailableChecks || CanBuy()); // TODO: run CanBuy when price is known due to settings + return conditionsMet && CanBuy(calculatingAvailableChecks); } -bool LocationAccess::CanBuy() const { - return CanBuyAnother(location); +static uint16_t GetMinimumPrice(const Rando::Location* loc) { + extern PriceSettingsStruct shopsanityPrices; + extern PriceSettingsStruct scrubPrices; + extern PriceSettingsStruct merchantPrices; + PriceSettingsStruct priceSettings = loc->GetRCType() == RCTYPE_SHOP ? shopsanityPrices + : loc->GetRCType() == RCTYPE_SCRUB ? scrubPrices + : merchantPrices; + + auto ctx = Rando::Context::GetInstance(); + switch (ctx->GetOption(priceSettings.main).Get()) { + case RO_PRICE_VANILLA: + return loc->GetVanillaPrice(); + case RO_PRICE_CHEAP_BALANCED: + return 0; + case RO_PRICE_BALANCED: + return 0; + case RO_PRICE_FIXED: + return ctx->GetOption(priceSettings.fixedPrice).Get() * 5; + case RO_PRICE_RANGE: { + uint16_t range1 = ctx->GetOption(priceSettings.range1).Get() * 5; + uint16_t range2 = ctx->GetOption(priceSettings.range1).Get() * 5; + return range1 < range2 ? range1 : range2; + } + case RO_PRICE_SET_BY_WALLET: { + if (ctx->GetOption(priceSettings.noWallet).Get()) { + return 0; + } else if (ctx->GetOption(priceSettings.childWallet).Get()) { + return 1; + } else if (ctx->GetOption(priceSettings.adultWallet).Get()) { + return 100; + } else if (ctx->GetOption(priceSettings.giantWallet).Get()) { + return 201; + } else { + return 501; + } + } + default: + return 0; + } +} + +bool LocationAccess::CanBuy(bool calculatingAvailableChecks) const { + const auto& loc = Rando::StaticData::GetLocation(location); + const auto& itemLoc = OTRGlobals::Instance->gRandoContext->GetItemLocation(location); + + if (loc->GetRCType() == RCTYPE_SHOP || loc->GetRCType() == RCTYPE_SCRUB || loc->GetRCType() == RCTYPE_MERCHANT) { + // Checks should only be identified while playing + if (calculatingAvailableChecks && itemLoc->GetCheckStatus() != RCSHOW_IDENTIFIED) { + return CanBuyAnother(GetMinimumPrice(loc)); + } else { + return CanBuyAnother(itemLoc->GetPrice()); + } + } + + return true; } bool CanBuyAnother(RandomizerCheck rc) { - uint16_t price = ctx->GetItemLocation(rc)->GetPrice(); + return CanBuyAnother(ctx->GetItemLocation(rc)->GetPrice()); +} +bool CanBuyAnother(uint16_t price) { if (price > 500) { return logic->HasItem(RG_TYCOON_WALLET); } else if (price > 200) { @@ -275,7 +330,7 @@ bool BeanPlanted(const RandomizerRegion region) { if (gPlayState != nullptr && gPlayState->sceneNum == sceneID) { swch = gPlayState->actorCtx.flags.swch; } else if (sceneID != SCENE_ID_MAX) { - swch = gSaveContext.sceneFlags[sceneID].swch; + swch = Rando::Context::GetInstance()->GetLogic()->GetSaveContext()->sceneFlags[sceneID].swch; } else { swch = 0; } @@ -486,17 +541,17 @@ std::string CleanCheckConditionString(std::string condition) { } namespace Regions { -const auto GetAllRegions() { +auto GetAllRegions() { static const size_t regionCount = RR_MAX - (RR_NONE + 1); static std::array allRegions = {}; - static bool intialized = false; - if (!intialized) { + static bool initialized = false; + if (!initialized) { for (size_t i = 0; i < regionCount; i++) { allRegions[i] = (RandomizerRegion)((RR_NONE + 1) + i); } - intialized = true; + initialized = true; } return allRegions; @@ -635,7 +690,7 @@ std::vector GetShuffleableEntrances(Rando::EntranceType type, Rando::Entrance* GetEntrance(RandomizerRegion source, RandomizerRegion destination) { for (auto& exit : RegionTable(source)->exits) { - if (exit.GetConnectedRegionKey() == destination) { + if (exit.GetOriginalConnectedRegionKey() == destination) { return &exit; } } diff --git a/soh/soh/Enhancements/randomizer/location_access.h b/soh/soh/Enhancements/randomizer/location_access.h index c2828ea97..a7a7d97af 100644 --- a/soh/soh/Enhancements/randomizer/location_access.h +++ b/soh/soh/Enhancements/randomizer/location_access.h @@ -100,9 +100,10 @@ class LocationAccess { std::string condition_str; // Makes sure shop locations are buyable - bool CanBuy() const; + bool CanBuy(bool calculatingAvailableChecks) const; }; +bool CanBuyAnother(uint16_t price); bool CanBuyAnother(RandomizerCheck rc); namespace Rando { diff --git a/soh/soh/Enhancements/randomizer/location_access/dungeons/bottom_of_the_well.cpp b/soh/soh/Enhancements/randomizer/location_access/dungeons/bottom_of_the_well.cpp index 44c3fa817..8a8393ba1 100644 --- a/soh/soh/Enhancements/randomizer/location_access/dungeons/bottom_of_the_well.cpp +++ b/soh/soh/Enhancements/randomizer/location_access/dungeons/bottom_of_the_well.cpp @@ -25,7 +25,6 @@ void RegionTable_Init_BottomOfTheWell() { }, { //Locations LOCATION(RC_BOTTOM_OF_THE_WELL_FRONT_CENTER_BOMBABLE_CHEST, logic->HasExplosives()), - LOCATION(RC_BOTTOM_OF_THE_WELL_FREESTANDING_KEY, (logic->HasItem(RG_BRONZE_SCALE) || logic->LoweredWaterInsideBotw) && logic->CanUse(RG_STICKS) || logic->CanUse(RG_DINS_FIRE)), LOCATION(RC_BOTTOM_OF_THE_WELL_UNDERWATER_FRONT_CHEST, logic->LoweredWaterInsideBotw), LOCATION(RC_BOTTOM_OF_THE_WELL_UNDERWATER_LEFT_CHEST, logic->LoweredWaterInsideBotw), LOCATION(RC_BOTTOM_OF_THE_WELL_NEAR_ENTRANCE_POT_1, logic->CanBreakPots()), diff --git a/soh/soh/Enhancements/randomizer/location_access/dungeons/fire_temple.cpp b/soh/soh/Enhancements/randomizer/location_access/dungeons/fire_temple.cpp index c3ccf27c6..764a78a1c 100644 --- a/soh/soh/Enhancements/randomizer/location_access/dungeons/fire_temple.cpp +++ b/soh/soh/Enhancements/randomizer/location_access/dungeons/fire_temple.cpp @@ -20,7 +20,7 @@ void RegionTable_Init_FireTemple() { //Exits Entrance(RR_FIRE_TEMPLE_ENTRYWAY, []{return true;}), Entrance(RR_FIRE_TEMPLE_NEAR_BOSS_ROOM, []{return logic->FireTimer() >= 24;}), - Entrance(RR_FIRE_TEMPLE_LOOP_ENEMIES, []{return Here(RR_FIRE_TEMPLE_FIRST_ROOM, []{return logic->CanUse(RG_MEGATON_HAMMER);}) && (logic->SmallKeys(RR_FIRE_TEMPLE, 8) || !logic->IsKeysanity);}), + Entrance(RR_FIRE_TEMPLE_LOOP_ENEMIES, []{return Here(RR_FIRE_TEMPLE_FIRST_ROOM, []{return logic->CanUse(RG_MEGATON_HAMMER);}) && (logic->SmallKeys(RR_FIRE_TEMPLE, 8) || !logic->IsFireLoopLocked);}), Entrance(RR_FIRE_TEMPLE_LOOP_EXIT, []{return true;}), Entrance(RR_FIRE_TEMPLE_BIG_LAVA_ROOM, []{return logic->SmallKeys(RR_FIRE_TEMPLE, 2) && logic->FireTimer() >= 24;}), }); @@ -43,7 +43,7 @@ void RegionTable_Init_FireTemple() { areaTable[RR_FIRE_TEMPLE_LOOP_ENEMIES] = Region("Fire Temple Loop Enemies", "Fire Temple", {RA_FIRE_TEMPLE}, NO_DAY_NIGHT_CYCLE, {}, {}, { //Exits - Entrance(RR_FIRE_TEMPLE_FIRST_ROOM, []{return logic->SmallKeys(RR_FIRE_TEMPLE, 8) || !logic->IsKeysanity;}), + Entrance(RR_FIRE_TEMPLE_FIRST_ROOM, []{return logic->SmallKeys(RR_FIRE_TEMPLE, 8) || !logic->IsFireLoopLocked;}), Entrance(RR_FIRE_TEMPLE_LOOP_TILES, []{return Here(RR_FIRE_TEMPLE_LOOP_ENEMIES, []{return logic->CanKillEnemy(RE_TORCH_SLUG) && logic->CanKillEnemy(RE_FIRE_KEESE);});}), }); diff --git a/soh/soh/Enhancements/randomizer/location_access/dungeons/water_temple.cpp b/soh/soh/Enhancements/randomizer/location_access/dungeons/water_temple.cpp index 457b3a016..3acf5d74a 100644 --- a/soh/soh/Enhancements/randomizer/location_access/dungeons/water_temple.cpp +++ b/soh/soh/Enhancements/randomizer/location_access/dungeons/water_temple.cpp @@ -658,7 +658,7 @@ void RegionTable_Init_WaterTemple() { areaTable[RR_WATER_TEMPLE_MQ_DRAGON_ROOM_ALCOVE] = Region("Water Temple MQ Dragon Room Alcove", "Water Temple", {RA_WATER_TEMPLE}, NO_DAY_NIGHT_CYCLE, { //Events - EventAccess(&logic->MQWaterDragonTorches, []{return true;}), + EventAccess(&logic->MQWaterDragonTorches, []{return logic->HasFireSource();}), }, { //Locations diff --git a/soh/soh/Enhancements/randomizer/logic.cpp b/soh/soh/Enhancements/randomizer/logic.cpp index 4c66089c1..4b9dc0c9f 100644 --- a/soh/soh/Enhancements/randomizer/logic.cpp +++ b/soh/soh/Enhancements/randomizer/logic.cpp @@ -1386,6 +1386,7 @@ bool Logic::SmallKeys(RandomizerRegion dungeon, uint8_t requiredAmountGlitchless static_cast(GlitchDifficulty::INTERMEDIATE) || GetDifficultyValueFromString(GlitchHover) >= static_cast(GlitchDifficulty::INTERMEDIATE))) { return FireTempleKeys >= requiredAmountGlitched; }*/ + // If the Fire Temple loop lock is removed, Small key Count is set to 1 before starting return GetSmallKeyCount(SCENE_FIRE_TEMPLE) >= requiredAmountGlitchless; case RR_WATER_TEMPLE: @@ -1813,7 +1814,7 @@ void Logic::ApplyItemEffect(Item& item, bool state) { if (randoGet == RG_BOTTLE_WITH_BIG_POE) { BigPoes++; } - mSaveContext->inventory.items[slot] = itemId; + mSaveContext->inventory.items[slot] = static_cast(itemId); } break; case RG_RUTOS_LETTER: SetRandoInf(RAND_INF_OBTAINED_RUTOS_LETTER, state); @@ -2305,7 +2306,7 @@ void Logic::SetEventChkInf(int32_t flag, bool state) { } uint8_t Logic::GetGSCount() { - return mSaveContext->inventory.gsTokens; + return static_cast(mSaveContext->inventory.gsTokens); } uint8_t Logic::GetAmmo(uint32_t item) { @@ -2333,9 +2334,9 @@ void Logic::Reset() { StartPerformanceTimer(PT_LOGIC_RESET); memset(inLogic, false, sizeof(inLogic)); // Settings-dependent variables - IsKeysanity = ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_ANYWHERE) || - ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_ANYWHERE) || - ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_ANYWHERE); + IsFireLoopLocked = ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_ANYWHERE) || + ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_OVERWORLD) || + ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_ANY_DUNGEON); // AmmoCanDrop = /*AmmoDrops.IsNot(AMMODROPS_NONE)*/ false; TODO: AmmoDrop setting @@ -2397,7 +2398,7 @@ void Logic::Reset() { // If not keysanity, start with 1 logical key to account for automatically unlocking the basement door in vanilla // FiT - if (!IsKeysanity && ctx->GetDungeon(Rando::FIRE_TEMPLE)->IsVanilla()) { + if (!IsFireLoopLocked && ctx->GetDungeon(Rando::FIRE_TEMPLE)->IsVanilla()) { SetSmallKeyCount(SCENE_FIRE_TEMPLE, 1); } @@ -2498,6 +2499,7 @@ void Logic::Reset() { ForestOpenBossCorridor = false; ShadowTrialFirstChest = false; MQGTGMazeSwitch = false; + MQGTGRightSideSwitch = false; GTGPlatformSilverRupees = false; MQJabuHolesRoomDoor = false; JabuWestTentacle = false; diff --git a/soh/soh/Enhancements/randomizer/logic.h b/soh/soh/Enhancements/randomizer/logic.h index 9ce913d7f..da78e7f3a 100644 --- a/soh/soh/Enhancements/randomizer/logic.h +++ b/soh/soh/Enhancements/randomizer/logic.h @@ -59,7 +59,7 @@ class Logic { bool LightTrialClear = false; // Logical keysanity - bool IsKeysanity = false; + bool IsFireLoopLocked = false; // Bottle Count uint8_t Bottles = 0; diff --git a/soh/soh/Enhancements/randomizer/option.cpp b/soh/soh/Enhancements/randomizer/option.cpp index bec719d4b..f027fd066 100644 --- a/soh/soh/Enhancements/randomizer/option.cpp +++ b/soh/soh/Enhancements/randomizer/option.cpp @@ -83,11 +83,11 @@ void Option::RestoreDelayedOption() { contextSelection = delayedSelection; } -void Option::SetContextIndex(size_t idx) { +void Option::SetContextIndex(uint8_t idx) { // TODO: Set to Context's OptionValue array. contextSelection = idx; - if (contextSelection > options.size() - 1) { - contextSelection = options.size() - 1; + if (contextSelection > static_cast(options.size() - 1)) { + contextSelection = static_cast(options.size() - 1); } } @@ -105,7 +105,7 @@ bool Option::IsHidden() const { void Option::ChangeOptions(std::vector opts) { if (GetOptionIndex() >= opts.size()) { - CVarSetInteger(cvarName.c_str(), opts.size() - 1); + CVarSetInteger(cvarName.c_str(), static_cast(opts.size() - 1)); } options = std::move(opts); } @@ -206,8 +206,8 @@ bool Option::RenderCheckbox() { bool Option::RenderCombobox() { bool changed = false; uint8_t selected = CVarGetInteger(cvarName.c_str(), defaultOption); - if (selected >= options.size()) { - selected = options.size(); + if (selected >= static_cast(options.size())) { + selected = static_cast(options.size()); CVarSetInteger(cvarName.c_str(), selected); changed = true; Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); @@ -231,13 +231,13 @@ bool Option::RenderSlider() { bool changed = false; int val = CVarGetInteger(cvarName.c_str(), defaultOption); if (val > options.size() - 1) { - val = options.size() - 1; + val = static_cast(options.size()) - 1; changed = true; } UIWidgets::IntSliderOptions widgetOptions = UIWidgets::IntSliderOptions() .Color(THEME_COLOR) .Min(0) - .Max(options.size() - 1) + .Max(static_cast(options.size() - 1)) .Tooltip(description.c_str()) .Format(options[val].c_str()) .DefaultValue(defaultOption); diff --git a/soh/soh/Enhancements/randomizer/option.h b/soh/soh/Enhancements/randomizer/option.h index 507729498..55a06ed86 100644 --- a/soh/soh/Enhancements/randomizer/option.h +++ b/soh/soh/Enhancements/randomizer/option.h @@ -241,11 +241,11 @@ class Option { void RestoreDelayedOption(); /** - * @brief Set the rando context index for this Option. Also calls `SetVariable()`. + * @brief Set the rando context index for this Option. * * @param idx the index to set as the selected index. */ - void SetContextIndex(size_t idx); + void SetContextIndex(uint8_t idx); /** * @brief Hides this Option in the menu. (Not currently being used afaik, we prefer to diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 831b0cea7..4537f4c2c 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -65,7 +65,7 @@ const std::string Randomizer::NaviRandoMessageTableID = "RandomizerNavi"; const std::string Randomizer::IceTrapRandoMessageTableID = "RandomizerIceTrap"; const std::string Randomizer::randoMiscHintsTableID = "RandomizerMiscHints"; -static const char* englishRupeeNames[190] = { +static const char* englishRupeeNames[188] = { "[P]", "Bad RNG Rolls", "Baht", @@ -111,8 +111,6 @@ static const char* englishRupeeNames[190] = { "Dimes", "Dinars", "DNA", - "Doge", - "Dogecoin", "Doll Hairs", "Dollars", "Dollarydoos", @@ -258,25 +256,25 @@ static const char* englishRupeeNames[190] = { "Zorkmids", }; -static const char* germanRupeeNames[80] = { - "Baht", "Bananen", "Bitcoin", "Bonbons", "Bratwürste", "Brause UFOs", "Brötchen", "Cent", - "Diamanten", "Dinar", "Diridari", "Dogecoin", "Dollar", "Draken", "ECU", "Elexit", - "Erz", "Erzbrocken", "Euro", "EXP", "Forint", "Franken", "Freunde", "Gil", - "Gold", "Groschen", "Gulden", "Gummibären", "Heller", "Juwelen", "Karolin", "Kartoffeln", - "Kies", "Knete", "Knochen", "Kohle", "Kraniche", "Kreuzer", "Kronen", "Kronkorken", - "Kröten", "Lira", "Mark", "Mäuse", "Monde", "Moorhühner", "Moos", "Münzen", - "Naira", "Penunze", "Pesa", "Pfandflaschen", "Pfennig", "Pfund", "Pilze", "Plastiks", - "Pokédollar", "Radieschen", "Rand", "Rappen", "Real", "Rial", "Riyal", "Rubine", - "Rupien", "Saphire", "Schilling", "Seelen", "Septime", "Smaragde", "Steine", "Sterne", - "Sternis", "Tael", "Taler", "Wagenchips", "Won", "Yen", "Yuan", "Zenny", +static const char* germanRupeeNames[79] = { + "Baht", "Bananen", "Bitcoin", "Bonbons", "Bratwürste", "Brause UFOs", "Brötchen", "Cent", + "Diamanten", "Dinar", "Diridari", "Dollar", "Draken", "ECU", "Elexit", "Erz", + "Erzbrocken", "Euro", "EXP", "Forint", "Franken", "Freunde", "Gil", "Gold", + "Groschen", "Gulden", "Gummibären", "Heller", "Juwelen", "Karolin", "Kartoffeln", "Kies", + "Knete", "Knochen", "Kohle", "Kraniche", "Kreuzer", "Kronen", "Kronkorken", "Kröten", + "Lira", "Mark", "Mäuse", "Monde", "Moorhühner", "Moos", "Münzen", "Naira", + "Penunze", "Pesa", "Pfandflaschen", "Pfennig", "Pfund", "Pilze", "Plastiks", "Pokédollar", + "Radieschen", "Rand", "Rappen", "Real", "Rial", "Riyal", "Rubine", "Rupien", + "Saphire", "Schilling", "Seelen", "Septime", "Smaragde", "Steine", "Sterne", "Sternis", + "Tael", "Taler", "Wagenchips", "Won", "Yen", "Yuan", "Zenny", }; -static const char* frenchRupeeNames[40] = { - "Anneaux", "Baguettes", "Balles", "Bananes", "Bitcoin", "Blés", "Bling", "Capsules", - "Centimes", "Champignons", "Clochettes", "Crédits", "Croissants", "Diamants", "Dogecoin", "Dollars", - "Émeraudes", "Éthers", "Étoiles", "Euros", "Florens", "Francs", "Galds", "Gils", - "Grouses", "Halos", "Joyaux", "Lunes", "Mailles", "Munnies", "Orbes", "Orens", - "Pépètes", "Pièces", "Plastyks", "Pokédollars", "Pokémon", "Radis", "Rubis", "Zennies", +static const char* frenchRupeeNames[39] = { + "Anneaux", "Baguettes", "Balles", "Bananes", "Bitcoin", "Blés", "Bling", "Capsules", + "Centimes", "Champignons", "Clochettes", "Crédits", "Croissants", "Diamants", "Dollars", "Émeraudes", + "Éthers", "Étoiles", "Euros", "Florens", "Francs", "Galds", "Gils", "Grouses", + "Halos", "Joyaux", "Lunes", "Mailles", "Munnies", "Orbes", "Orens", "Pépètes", + "Pièces", "Plastyks", "Pokédollars", "Pokémon", "Radis", "Rubis", "Zennies", }; Randomizer::Randomizer() { @@ -357,9 +355,12 @@ std::unordered_map getItemIdToItemId = { { GI_CLAIM_CHECK, ITEM_CLAIM_CHECK }, }; +#ifdef _MSC_VER #pragma optimize("", off) +#else #pragma GCC push_options #pragma GCC optimize("O0") +#endif bool Randomizer::SpoilerFileExists(const char* spoilerFileName) { if (strcmp(spoilerFileName, "") != 0) { std::ifstream spoilerFileStream(SohUtils::Sanitize(spoilerFileName)); @@ -372,8 +373,11 @@ bool Randomizer::SpoilerFileExists(const char* spoilerFileName) { return false; } -#pragma GCC pop_options +#ifdef _MSC_VER #pragma optimize("", on) +#else +#pragma GCC pop_options +#endif void Randomizer::LoadHintMessages() { auto ctx = Rando::Context::GetInstance(); @@ -3506,9 +3510,9 @@ CrateIdentity Randomizer::IdentifyCrate(s32 sceneNum, s32 posX, s32 posZ) { crateSceneNum = SCENE_MARKET_DAY; } else if (sceneNum == SCENE_GERUDOS_FORTRESS && gPlayState->linkAgeOnLoad == 1 && posX == 310) { if (posZ == -1830) { - posZ = -1842.0f; + posZ = -1842; } else if (posZ == -1770) { - posZ = -1782.0f; + posZ = -1782; } } @@ -3734,13 +3738,15 @@ void RandomizerSettingsWindow::DrawElement() { } UIWidgets::Spacer(0); - ImGui::BeginDisabled((gSaveContext.gameMode != GAMEMODE_FILE_SELECT) || GameInteractor::IsSaveLoaded()); - if (UIWidgets::Button("Generate Randomizer", - UIWidgets::ButtonOptions().Size(ImVec2(250.f, 0.f)).Color(THEME_COLOR))) { + UIWidgets::ButtonOptions options = UIWidgets::ButtonOptions().Size(ImVec2(250.f, 0.f)).Color(THEME_COLOR); + options.Disabled((gSaveContext.gameMode != GAMEMODE_FILE_SELECT) || GameInteractor::IsSaveLoaded()); + if (options.disabled) { + options.DisabledTooltip("Must be on File Select to generate a randomizer seed."); + } + if (UIWidgets::Button("Generate Randomizer", options)) { ctx->SetSpoilerLoaded(false); GenerateRandomizer(CVarGetInteger(CVAR_RANDOMIZER_SETTING("ManualSeedEntry"), 0) ? seedString : ""); } - ImGui::EndDisabled(); ImGui::SameLine(); if (!CVarGetInteger(CVAR_RANDOMIZER_SETTING("DontGenerateSpoiler"), 0)) { @@ -4100,7 +4106,7 @@ void RandomizerSettingsWindow::DrawElement() { Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } - if (ImGui::BeginTable("trickTags", showTag.size(), + if (ImGui::BeginTable("trickTags", static_cast(showTag.size()), ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Borders)) { for (auto [rtTag, isShown] : showTag) { @@ -4523,6 +4529,9 @@ CustomMessage Randomizer::GetMapGetItemMessageWithHint(GetItemEntry itemEntry) { messageEntry.Replace("[[typeHint]]", Rando::StaticData::hintTextTable[RHT_DUNGEON_ORDINARY].GetHintMessage()); } + // BUG: the icon is not in the message yet so are not accounted for, so overflows are possible + messageEntry.AutoFormat(); + return messageEntry; } @@ -5572,7 +5581,7 @@ void RandomizerSettingsWindow::InitElement() { // (special cases for rando items) void Randomizer_GameplayStats_SetTimestamp(uint16_t item) { - u32 time = GAMEPLAYSTAT_TOTAL_TIME; + u32 time = static_cast(GAMEPLAYSTAT_TOTAL_TIME); // Have items in Link's pocket shown as being obtained at 0.1 seconds if (time == 0) { @@ -5868,7 +5877,7 @@ extern "C" u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) { case RG_GREG_RUPEE: Rupees_ChangeBy(1); Flags_SetRandomizerInf(RAND_INF_GREG_FOUND); - gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_FOUND_GREG] = GAMEPLAYSTAT_TOTAL_TIME; + gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_FOUND_GREG] = static_cast(GAMEPLAYSTAT_TOTAL_TIME); break; case RG_TRIFORCE_PIECE: gSaveContext.ship.quest.data.randomizer.triforcePiecesCollected++; @@ -5877,7 +5886,8 @@ extern "C" u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) { // Teleport to credits when goal is reached. if (gSaveContext.ship.quest.data.randomizer.triforcePiecesCollected == (OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED) + 1)) { - gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_TRIFORCE_COMPLETED] = GAMEPLAYSTAT_TOTAL_TIME; + gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_TRIFORCE_COMPLETED] = + static_cast(GAMEPLAYSTAT_TOTAL_TIME); gSaveContext.ship.stats.gameComplete = 1; Flags_SetRandomizerInf(RAND_INF_GRANT_GANONS_BOSSKEY); Play_PerformSave(play); @@ -5910,12 +5920,12 @@ extern "C" u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) { case RG_DEKU_STICK_BAG: Inventory_ChangeUpgrade(UPG_STICKS, 1); INV_CONTENT(ITEM_STICK) = ITEM_STICK; - AMMO(ITEM_STICK) = CUR_CAPACITY(UPG_STICKS); + AMMO(ITEM_STICK) = static_cast(CUR_CAPACITY(UPG_STICKS)); break; case RG_DEKU_NUT_BAG: Inventory_ChangeUpgrade(UPG_NUTS, 1); INV_CONTENT(ITEM_NUT) = ITEM_NUT; - AMMO(ITEM_NUT) = CUR_CAPACITY(UPG_NUTS); + AMMO(ITEM_NUT) = static_cast(CUR_CAPACITY(UPG_NUTS)); break; default: LUSLOG_WARN("Randomizer_Item_Give didn't have behaviour specified for getItemId=%d", item); diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index aa0dceda8..4d2164b99 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -1892,16 +1892,16 @@ static std::set rainbowCVars = { int hue = 0; void RainbowTick() { - float freqHue = hue * 2 * M_PI / (360 * CVarGetFloat(CVAR_COSMETIC("RainbowSpeed"), 0.6f)); + float freqHue = hue * 2 * M_PIf / (360 * CVarGetFloat(CVAR_COSMETIC("RainbowSpeed"), 0.6f)); for (auto& cvar : rainbowCVars) { if (CVarGetInteger((cvar + ".Rainbow").c_str(), 0) == 0) { continue; } Color_RGBA8 newColor; - newColor.r = sin(freqHue + 0) * 127 + 128; - newColor.g = sin(freqHue + (2 * M_PI / 3)) * 127 + 128; - newColor.b = sin(freqHue + (4 * M_PI / 3)) * 127 + 128; + newColor.r = static_cast(sin(freqHue + 0) * 127) + 128; + newColor.g = static_cast(sin(freqHue + (2 * M_PI / 3)) * 127) + 128; + newColor.b = static_cast(sin(freqHue + (4 * M_PI / 3)) * 127) + 128; newColor.a = 255; CVarSetColor((cvar + ".Value").c_str(), newColor); @@ -1967,7 +1967,7 @@ void RecalculateAvailableChecks() { StartPerformanceTimer(PT_RECALCULATE_AVAILABLE_CHECKS); std::vector targetLocations; - targetLocations.reserve(RR_MAX); + targetLocations.reserve(RC_MAX); for (auto& location : Rando::StaticData::GetLocationTable()) { RandomizerCheck rc = location.GetRandomizerCheck(); Rando::ItemLocation* itemLocation = OTRGlobals::Instance->gRandoContext->GetItemLocation(rc); @@ -1979,15 +1979,8 @@ void RecalculateAvailableChecks() { std::vector availableChecks = ReachabilitySearch(targetLocations, RG_NONE, true); for (auto& rc : availableChecks) { - const auto& location = Rando::StaticData::GetLocation(rc); const auto& itemLocation = OTRGlobals::Instance->gRandoContext->GetItemLocation(rc); - if (location->GetRCType() == RCTYPE_SHOP && itemLocation->GetCheckStatus() == RCSHOW_IDENTIFIED) { - if (CanBuyAnother(rc)) { - itemLocation->SetAvailable(true); - } - } else { - itemLocation->SetAvailable(true); - } + itemLocation->SetAvailable(true); } totalChecksAvailable = 0; @@ -2114,7 +2107,10 @@ void CheckTrackerSettingsWindow::DrawElement() { "with your current progress.") .Color(THEME_COLOR))) { enableAvailableChecks = CVarGetInteger(CVAR_TRACKER_CHECK("EnableAvailableChecks"), 0); - RecalculateAvailableChecks(); + + if (GameInteractor::IsSaveLoaded(true)) { + RecalculateAvailableChecks(); + } } ImGui::EndDisabled(); diff --git a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp index b71bae5b3..eaa928705 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp @@ -382,7 +382,7 @@ const EntranceData entranceData[] = { }; // Check if Link is in the area and return that scene/entrance for tracking -s8 LinkIsInArea(const EntranceData* entrance) { +int16_t LinkIsInArea(const EntranceData* entrance) { bool result = false; if (gPlayState == nullptr) { diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 9b7b1fd39..bd26b1d44 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -670,17 +670,17 @@ void DrawItemCount(ItemTrackerItem item, bool hideMax) { void DrawEquip(ItemTrackerItem item) { bool hasEquip = HasEquipment(item); - int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36); + float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( hasEquip && IsValidSaveFile() ? item.name : item.nameFaded), - ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); + ImVec2(iconSize, iconSize), ImVec2(0.0f, 0.0f), ImVec2(1, 1)); Tooltip(SohUtils::GetItemName(item.id).c_str()); } void DrawQuest(ItemTrackerItem item) { bool hasQuestItem = HasQuestItem(item); - int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36); + float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); ImGui::BeginGroup(); ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( hasQuestItem && IsValidSaveFile() ? item.name : item.nameFaded), @@ -698,7 +698,7 @@ void DrawQuest(ItemTrackerItem item) { void DrawItem(ItemTrackerItem item) { uint32_t actualItemId = GameInteractor::IsSaveLoaded() ? INV_CONTENT(item.id) : ITEM_NONE; - int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36); + float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); bool hasItem = actualItemId != ITEM_NONE; std::string itemName = ""; @@ -1015,7 +1015,7 @@ void DrawBottle(ItemTrackerItem item) { item = actualItemTrackerItemMap[actualItemId]; } - int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36); + float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); @@ -1027,7 +1027,7 @@ void DrawDungeonItem(ItemTrackerItem item) { uint32_t itemId = item.id; ImU32 dungeonColor = IM_COL_WHITE; uint32_t bitMask = 1 << (item.id - ITEM_KEY_BOSS); // Bitset starts at ITEM_KEY_BOSS == 0. the rest are sequential - int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36); + float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); bool hasItem = GameInteractor::IsSaveLoaded() ? (bitMask & gSaveContext.inventory.dungeonItems[item.data]) : false; bool hasSmallKey = GameInteractor::IsSaveLoaded() ? ((gSaveContext.inventory.dungeonKeys[item.data]) >= 0) : false; ImGui::BeginGroup(); @@ -1078,19 +1078,19 @@ void DrawDungeonItem(ItemTrackerItem item) { } void DrawSong(ItemTrackerItem item) { - int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36); + float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); ImVec2 p = ImGui::GetCursorScreenPos(); bool hasSong = HasSong(item); ImGui::SetCursorScreenPos(ImVec2(p.x + 6, p.y)); ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( hasSong && IsValidSaveFile() ? item.name : item.nameFaded), - ImVec2(iconSize / 1.5, iconSize), ImVec2(0, 0), ImVec2(1, 1)); + ImVec2(iconSize / 1.5f, iconSize), ImVec2(0, 0), ImVec2(1, 1)); Tooltip(SohUtils::GetQuestItemName(item.id).c_str()); } void DrawNotes(bool resizeable = false) { ImGui::BeginGroup(); - int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36); + float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); int iconSpacing = CVarGetInteger(CVAR_TRACKER_ITEM("IconSpacing"), 12); struct ItemTrackerNotes { @@ -1113,7 +1113,7 @@ void DrawNotes(bool resizeable = false) { } }; ImVec2 size = resizeable ? ImVec2(-FLT_MIN, ImGui::GetContentRegionAvail().y) - : ImVec2(((iconSize + iconSpacing) * 6) - 8, 200); + : ImVec2(((iconSize + iconSpacing) * 6) - 8.0f, 200.0f); if (GameInteractor::IsSaveLoaded()) { if (ItemTrackerNotes::TrackerNotesInputTextMultiline("##ItemTrackerNotes", &itemTrackerNotes, size, ImGuiInputTextFlags_AllowTabInput)) { @@ -1185,7 +1185,7 @@ void EndFloatingWindows() { * Takes in a vector of ItemTrackerItem and draws them in rows of N items */ void DrawItemsInRows(std::vector items, int columns = 6) { - int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36); + float iconSize = static_cast(CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36)); int iconSpacing = CVarGetInteger(CVAR_TRACKER_ITEM("IconSpacing"), 12); int topPadding = (CVarGetInteger(CVAR_TRACKER_ITEM("WindowType"), TRACKER_WINDOW_FLOATING) == TRACKER_WINDOW_WINDOW) ? 20 : 0; @@ -1194,7 +1194,7 @@ void DrawItemsInRows(std::vector items, int columns = 6) { int row = i / columns; int column = i % columns; ImGui::SetCursorPos( - ImVec2((column * (iconSize + iconSpacing) + 8), (row * (iconSize + iconSpacing)) + 8 + topPadding)); + ImVec2((column * (iconSize + iconSpacing) + 8.0f), (row * (iconSize + iconSpacing)) + 8.0f + topPadding)); items[i].drawFunc(items[i]); } } @@ -1208,10 +1208,10 @@ void DrawItemsInACircle(std::vector items) { int iconSpacing = CVarGetInteger(CVAR_TRACKER_ITEM("IconSpacing"), 12); ImVec2 max = ImGui::GetWindowContentRegionMax(); - float radius = (iconSize + iconSpacing) * 2; + float radius = (iconSize + iconSpacing) * 2.0f; for (int i = 0; i < items.size(); i++) { - float angle = (float)i / items.size() * 2.0f * M_PI; + float angle = static_cast(i / items.size() * 2.0f * M_PI); float x = (radius / 2.0f) * cos(angle) + max.x / 2.0f; float y = (radius / 2.0f) * sin(angle) + max.y / 2.0f; ImGui::SetCursorPos(ImVec2(x - (CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36) - 8) / 2.0f, y + 4)); @@ -1225,14 +1225,12 @@ void DrawItemsInACircle(std::vector items) { * to then call DrawItemsInRows */ std::vector GetDungeonItemsVector(std::vector dungeons, int columns = 6) { - int iconSize = CVarGetInteger(CVAR_TRACKER_ITEM("IconSize"), 36); - int iconSpacing = CVarGetInteger(CVAR_TRACKER_ITEM("IconSpacing"), 12); std::vector dungeonItems = {}; int rowCount = 0; for (int i = 0; i < dungeons.size(); i++) { if (dungeons[i].items.size() > rowCount) - rowCount = dungeons[i].items.size(); + rowCount = static_cast(dungeons[i].items.size()); } for (int i = 0; i < rowCount; i++) { @@ -1469,7 +1467,7 @@ void ItemTrackerSaveFile(SaveContext* saveContext, int sectionID, bool fullSave) void ItemTrackerLoadFile() { std::string initialTrackerNotes = ""; SaveManager::Instance->LoadData("personalNotes", initialTrackerNotes); - itemTrackerNotes.resize(initialTrackerNotes.length() + 1); + itemTrackerNotes.resize(static_cast(initialTrackerNotes.length() + 1)); if (initialTrackerNotes != "") { SohUtils::CopyStringToCharArray(itemTrackerNotes.Data, initialTrackerNotes.c_str(), itemTrackerNotes.size()); } else { @@ -1532,8 +1530,9 @@ void ItemTrackerWindow::DrawElement() { if (CVarGetInteger(CVAR_TRACKER_ITEM("DisplayType.Notes"), SECTION_DISPLAY_HIDDEN) == SECTION_DISPLAY_MAIN_WINDOW && - CVarGetInteger(CVAR_TRACKER_ITEM("DisplayType.Main"), TRACKER_DISPLAY_ALWAYS) == - TRACKER_DISPLAY_ALWAYS) { + (CVarGetInteger(CVAR_TRACKER_ITEM("WindowType"), TRACKER_WINDOW_FLOATING) == TRACKER_WINDOW_FLOATING && + CVarGetInteger(CVAR_TRACKER_ITEM("DisplayType.Main"), TRACKER_DISPLAY_ALWAYS) == + TRACKER_DISPLAY_ALWAYS)) { DrawNotes(); } EndFloatingWindows(); @@ -1642,7 +1641,10 @@ void ItemTrackerWindow::DrawElement() { if (CVarGetInteger(CVAR_TRACKER_ITEM("DisplayType.Notes"), SECTION_DISPLAY_HIDDEN) == SECTION_DISPLAY_SEPARATE && - CVarGetInteger(CVAR_TRACKER_ITEM("DisplayType.Main"), TRACKER_DISPLAY_ALWAYS) == TRACKER_DISPLAY_ALWAYS) { + (CVarGetInteger(CVAR_TRACKER_ITEM("WindowType"), TRACKER_WINDOW_FLOATING) == TRACKER_WINDOW_WINDOW || + (CVarGetInteger(CVAR_TRACKER_ITEM("WindowType"), TRACKER_WINDOW_FLOATING) == TRACKER_WINDOW_FLOATING && + CVarGetInteger(CVAR_TRACKER_ITEM("DisplayType.Main"), TRACKER_DISPLAY_ALWAYS) != + TRACKER_DISPLAY_COMBO_BUTTON))) { ImGui::SetNextWindowSize(ImVec2(400, 300), ImGuiCond_FirstUseEver); BeginFloatingWindows("Personal Notes", ImGuiWindowFlags_NoFocusOnAppearing); DrawNotes(true); @@ -1943,7 +1945,10 @@ void ItemTrackerSettingsWindow::DrawElement() { shouldUpdateVectors = true; } - if (CVarGetInteger(CVAR_TRACKER_ITEM("DisplayType.Main"), TRACKER_DISPLAY_ALWAYS) == TRACKER_DISPLAY_ALWAYS) { + if (CVarGetInteger(CVAR_TRACKER_ITEM("WindowType"), TRACKER_WINDOW_FLOATING) == TRACKER_WINDOW_WINDOW || + (CVarGetInteger(CVAR_TRACKER_ITEM("WindowType"), TRACKER_WINDOW_FLOATING) == TRACKER_WINDOW_FLOATING && + CVarGetInteger(CVAR_TRACKER_ITEM("DisplayType.Main"), TRACKER_DISPLAY_ALWAYS) != + TRACKER_DISPLAY_COMBO_BUTTON)) { if (CVarCombobox("Personal notes", CVAR_TRACKER_ITEM("DisplayType.Notes"), displayTypes, ComboboxOptions() .DefaultIndex(SECTION_DISPLAY_HIDDEN) diff --git a/soh/soh/Enhancements/randomizer/savefile.cpp b/soh/soh/Enhancements/randomizer/savefile.cpp index cb8c7eaef..aede3484b 100644 --- a/soh/soh/Enhancements/randomizer/savefile.cpp +++ b/soh/soh/Enhancements/randomizer/savefile.cpp @@ -22,7 +22,7 @@ void StartingItemGive(GetItemEntry getItemEntry, RandomizerCheck randomizerCheck if (getItemEntry.getItemId == GI_SWORD_BGS) { gSaveContext.bgsFlag = true; } - Item_Give(NULL, getItemEntry.itemId); + Item_Give(NULL, static_cast(getItemEntry.itemId)); } else if (getItemEntry.modIndex == MOD_RANDOMIZER) { if (getItemEntry.getItemId == RG_ICE_TRAP) { gSaveContext.ship.pendingIceTrapCount++; @@ -269,9 +269,9 @@ extern "C" void Randomizer_InitSaveFile() { // Remove One Time Scrubs with Scrubsanity off if (Randomizer_GetSettingValue(RSK_SHUFFLE_SCRUBS) == RO_SCRUBS_OFF) { - Flags_SetRandomizerInf(RAND_INF_SCRUBS_PURCHASED_LW_DEKU_SCRUB_NEAR_BRIDGE); - Flags_SetRandomizerInf(RAND_INF_SCRUBS_PURCHASED_LW_DEKU_SCRUB_GROTTO_FRONT); - Flags_SetRandomizerInf(RAND_INF_SCRUBS_PURCHASED_HF_DEKU_SCRUB_GROTTO); + Flags_SetItemGetInf(ITEMGETINF_DEKU_SCRUB_HEART_PIECE); + Flags_SetInfTable(INFTABLE_BOUGHT_STICK_UPGRADE); + Flags_SetInfTable(INFTABLE_BOUGHT_NUT_UPGRADE); } int startingAge = OTRGlobals::Instance->gRandoContext->GetOption(RSK_SELECTED_STARTING_AGE).Get(); diff --git a/soh/soh/Enhancements/randomizer/settings.cpp b/soh/soh/Enhancements/randomizer/settings.cpp index 0b4700035..81f118770 100644 --- a/soh/soh/Enhancements/randomizer/settings.cpp +++ b/soh/soh/Enhancements/randomizer/settings.cpp @@ -24,7 +24,7 @@ std::vector NumOpts(const int min, const int max, const int step = } std::vector MultiVecOpts(const std::vector>& optionsVector) { - uint32_t totalSize = 0; + size_t totalSize = 0; for (const auto& vector : optionsVector) { totalSize += vector.size(); } @@ -250,7 +250,7 @@ void Settings::CreateOptions() { OPT_U8(RSK_LACS_REWARD_COUNT, "GCBK Reward Count", {NumOpts(0, 10)}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("LacsRewardCount"), "", WidgetType::Slider, 9, true); OPT_U8(RSK_LACS_DUNGEON_COUNT, "GCBK Dungeon Count", {NumOpts(0, 9)}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("LacsDungeonCount"), "", WidgetType::Slider, 8, true); OPT_U8(RSK_LACS_TOKEN_COUNT, "GCBK Token Count", {NumOpts(0, 100)}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("LacsTokenCount"), "", WidgetType::Slider, 100, true); - OPT_U8(RSK_LACS_OPTIONS, "GCBK LACS Reward Options", {"Standard Reward", "Greg as Reward", "Greg as Wildcard"}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("LacsRewardOptions"), "", WidgetType::Combobox, RO_LACS_STANDARD_REWARD); + OPT_U8(RSK_LACS_OPTIONS, "GCBK LACS Reward Options", {"Standard Reward", "Greg as Reward", "Greg as Wildcard"}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("LacsRewardOptions"), mOptionDescriptions[RSK_LACS_OPTIONS], WidgetType::Combobox, RO_LACS_STANDARD_REWARD); OPT_U8(RSK_KEYRINGS, "Key Rings", {"Off", "Random", "Count", "Selection"}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("ShuffleKeyRings"), mOptionDescriptions[RSK_KEYRINGS], WidgetType::Combobox, RO_KEYRINGS_OFF); OPT_U8(RSK_KEYRINGS_RANDOM_COUNT, "Keyring Dungeon Count", {NumOpts(0, 9)}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("ShuffleKeyRingsRandomCount"), "", WidgetType::Slider, 8); OPT_U8(RSK_KEYRINGS_GERUDO_FORTRESS, "Gerudo Fortress Keyring", {"No", "Random", "Yes"}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("ShuffleKeyRingsGerudoFortress"), "", WidgetType::Combobox, 0); @@ -2638,7 +2638,7 @@ void Context::FinalizeSettings(const std::set& excludedLocation mqSet += 1; break; case RO_MQ_SET_RANDOM: - randMQOption.push_back(i); + randMQOption.push_back(static_cast(i)); dungeons[i]->SetDungeonKnown(false); break; default: @@ -2659,7 +2659,7 @@ void Context::FinalizeSettings(const std::set& excludedLocation // otherwise, make everything a possibility and unknown } else { for (size_t i = 0; i < dungeons.size(); i++) { - randMQOption.push_back(i); + randMQOption.push_back(static_cast(i)); dungeons[i]->SetDungeonKnown(false); mOptions[dungeons[i]->GetMQSetting()].Set(RO_MQ_SET_RANDOM); } diff --git a/soh/soh/Enhancements/timesaver_hook_handlers.cpp b/soh/soh/Enhancements/timesaver_hook_handlers.cpp index b738e2fc1..9f488efce 100644 --- a/soh/soh/Enhancements/timesaver_hook_handlers.cpp +++ b/soh/soh/Enhancements/timesaver_hook_handlers.cpp @@ -13,12 +13,14 @@ extern "C" { #include "src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.h" #include "src/overlays/actors/ovl_En_Owl/z_en_owl.h" #include "src/overlays/actors/ovl_En_Go2/z_en_go2.h" +#include "src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.h" #include "src/overlays/actors/ovl_En_Ko/z_en_ko.h" #include "src/overlays/actors/ovl_En_Ma1/z_en_ma1.h" #include "src/overlays/actors/ovl_En_Ru2/z_en_ru2.h" #include "src/overlays/actors/ovl_En_Zl4/z_en_zl4.h" #include "src/overlays/actors/ovl_En_Box/z_en_box.h" #include "src/overlays/actors/ovl_Demo_Im/z_demo_im.h" +#include "src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.h" #include "src/overlays/actors/ovl_En_Sa/z_en_sa.h" #include "src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.h" #include "src/overlays/actors/ovl_En_Tk/z_en_tk.h" @@ -217,6 +219,25 @@ void TimeSaverOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_li if (CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.SkipCutscene.Entrances"), IS_RANDO) && (entranceFlag != EVENTCHKINF_EPONA_OBTAINED) && entranceIndex != ENTR_SPIRIT_TEMPLE_BOSS_ENTRANCE) { *should = false; + + // Check for dispulsion of Ganon's Tower barrier + switch (entranceIndex) { + case ENTR_INSIDE_GANONS_CASTLE_2: + case ENTR_INSIDE_GANONS_CASTLE_3: + case ENTR_INSIDE_GANONS_CASTLE_4: + case ENTR_INSIDE_GANONS_CASTLE_5: + case ENTR_INSIDE_GANONS_CASTLE_6: + case ENTR_INSIDE_GANONS_CASTLE_7: + if (Flags_GetEventChkInf(EVENTCHKINF_COMPLETED_FOREST_TRIAL) && + Flags_GetEventChkInf(EVENTCHKINF_COMPLETED_WATER_TRIAL) && + Flags_GetEventChkInf(EVENTCHKINF_COMPLETED_SHADOW_TRIAL) && + Flags_GetEventChkInf(EVENTCHKINF_COMPLETED_FIRE_TRIAL) && + Flags_GetEventChkInf(EVENTCHKINF_COMPLETED_LIGHT_TRIAL) && + Flags_GetEventChkInf(EVENTCHKINF_COMPLETED_SPIRIT_TRIAL)) { + Flags_SetEventChkInf(EVENTCHKINF_DISPELLED_GANONS_TOWER_BARRIER); + } + break; + } } break; } @@ -275,6 +296,11 @@ void TimeSaverOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_li } switch (actor->id) { case ACTOR_OBJ_SWITCH: { + if ((actor->params == 8224 && gPlayState->sceneNum == SCENE_DODONGOS_CAVERN) || + (actor->params == 6979 && gPlayState->sceneNum == SCENE_WATER_TEMPLE) && + CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.SkipCutscene.GlitchAiding"), 0)) { + break; + } ObjSwitch* switchActor = (ObjSwitch*)actor; switchActor->cooldownTimer = 0; *should = false; @@ -349,6 +375,11 @@ void TimeSaverOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_li } break; } + case VB_FREEZE_LINK_FOR_FOREST_PILLARS: + if (CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.SkipCutscene.OnePoint"), IS_RANDO)) { + *should = false; + } + break; case VB_SHOW_TITLE_CARD: if (CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.DisableTitleCard"), IS_RANDO)) { *should = false; @@ -441,6 +472,26 @@ void TimeSaverOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_li *should = false; } break; + case VB_PLAY_DISPEL_BARRIER_CS: { + if (CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.SkipCutscene.OnePoint"), IS_RANDO)) { + static s16 trialEntrances[] = { + 0, + ENTR_INSIDE_GANONS_CASTLE_3, + ENTR_INSIDE_GANONS_CASTLE_6, + ENTR_INSIDE_GANONS_CASTLE_5, + ENTR_INSIDE_GANONS_CASTLE_4, + ENTR_INSIDE_GANONS_CASTLE_7, + ENTR_INSIDE_GANONS_CASTLE_2, + }; + RateLimitedSuccessChime(); + DemoKekkai* kekkai = va_arg(args, DemoKekkai*); + gPlayState->nextEntranceIndex = trialEntrances[kekkai->actor.params]; + gPlayState->transitionTrigger = TRANS_TRIGGER_START; + gPlayState->transitionType = TRANS_TYPE_FADE_BLACK; + *should = false; + } + break; + } case VB_OWL_INTERACTION: { if (CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.SkipOwlInteractions"), IS_RANDO) && *should) { EnOwl* enOwl = va_arg(args, EnOwl*); @@ -720,6 +771,18 @@ void TimeSaverOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_li break; } + case VB_PLAY_GATE_OPENING_OR_CLOSING_CS: { + if (CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.SkipMiscInteractions"), IS_RANDO)) { + EnHeishi2* enHeishi2 = va_arg(args, EnHeishi2*); + enHeishi2->unk_2F2[0] = 0; + + // The second argument determines whether the vanilla code should be run anyway. It + // should be set to `true` ONLY IF said code calls `Play_ClearCamera`, false otherwise. + bool clearCamera = (bool)va_arg(args, int); + *should = clearCamera && enHeishi2->cameraId != MAIN_CAM; + } + break; + } case VB_PLAY_RAINBOW_BRIDGE_CS: { if (CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.SkipCutscene.Story"), IS_RANDO)) { *should = false; diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 87cb361e1..e5906778f 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -40,6 +40,7 @@ #include "z64.h" #include "macros.h" #include "Fonts.h" +#include "window/FileDropMgr.h" #include "window/gui/resource/Font.h" #include #include "Enhancements/custom-message/CustomMessageManager.h" @@ -51,7 +52,7 @@ #include "Extractor/Extract.h" #endif -#include +#include #ifdef __APPLE__ #include @@ -307,6 +308,7 @@ OTRGlobals::OTRGlobals() { context->InitGfxDebugger(); context->InitConfiguration(); context->InitConsoleVariables(); + context->InitFileDropMgr(); // tell LUS to reserve 3 SoH specific threads (Game, Audio, Save) context->InitResourceManager(OTRFiles, {}, 3); @@ -1434,13 +1436,13 @@ extern "C" void Graph_StartFrame() { } #endif - if (CVarGetInteger(CVAR_NEW_FILE_DROPPED, 0)) { - std::string filePath = SohUtils::Sanitize(CVarGetString(CVAR_DROPPED_FILE, "")); + auto dropMgr = Ship::Context::GetInstance()->GetFileDropMgr(); + if (dropMgr->FileDropped()) { + std::string filePath = dropMgr->GetDroppedFile(); if (!filePath.empty()) { GameInteractor::Instance->ExecuteHooks(filePath); } - CVarClear(CVAR_NEW_FILE_DROPPED); - CVarClear(CVAR_DROPPED_FILE); + dropMgr->ClearDroppedFile(); } } @@ -1899,7 +1901,7 @@ extern "C" void OTRControllerCallback(uint8_t rumble) { } extern "C" float OTRGetAspectRatio() { - return gfx_current_dimensions.aspect_ratio; + return Ship::Context::GetInstance()->GetWindow()->GetAspectRatio(); } extern "C" float OTRGetDimensionFromLeftEdge(float v) { @@ -1912,12 +1914,34 @@ extern "C" float OTRGetDimensionFromRightEdge(float v) { // Gets the width of the current render target area extern "C" uint32_t OTRGetGameRenderWidth() { - return gfx_current_dimensions.width; + auto fastWnd = dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + auto intP = fastWnd->GetInterpreterWeak().lock(); + + if (!intP) { + assert(false && "Lost reference to Fast::Interpreter"); + return 320; + } + + uint32_t height, width; + intP->GetCurDimensions(&width, &height); + + return width; } // Gets the height of the current render target area extern "C" uint32_t OTRGetGameRenderHeight() { - return gfx_current_dimensions.height; + auto fastWnd = dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + auto intP = fastWnd->GetInterpreterWeak().lock(); + + if (!intP) { + assert(false && "Lost reference to Fast::Interpreter"); + return 240; + } + + uint32_t height, width; + intP->GetCurDimensions(&width, &height); + + return height; } f32 floorf(f32 x); // RANDOTODO False positive error "allowing all exceptions is incompatible with previous function" @@ -2423,15 +2447,15 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) { // animation until the text box auto-dismisses. // RANDOTODO: Implement a way to determine if an item came from a skulltula and // inject the auto-dismiss control code if it did. - if (CVarGetInteger(CVAR_ENHANCEMENT("SkulltulaFreeze"), 0) != 0 && - !(IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_TOKENS) != RO_TOKENSANITY_OFF)) { + bool gsTokensShuffled = Randomizer_GetSettingValue(RSK_SHUFFLE_TOKENS) != RO_TOKENSANITY_OFF; + if (CVarGetInteger(CVAR_ENHANCEMENT("SkulltulaFreeze"), 0) != 0 && !(IS_RANDO && gsTokensShuffled)) { textId = TEXT_GS_NO_FREEZE; } else { textId = TEXT_GS_FREEZE; } // In vanilla, GS token count is incremented prior to the text box displaying // In rando we need to bump the token count by one to show the correct count - s16 gsCount = gSaveContext.inventory.gsTokens + (IS_RANDO ? 1 : 0); + s16 gsCount = gSaveContext.inventory.gsTokens + ((IS_RANDO && gsTokensShuffled) ? 1 : 0); messageEntry = CustomMessageManager::Instance->RetrieveMessage(customMessageTableID, textId, MF_FORMATTED); messageEntry.Replace("[[gsCount]]", std::to_string(gsCount)); } else if (CVarGetInteger(CVAR_ENHANCEMENT("SkulltulaFreeze"), 0) != 0 && @@ -2496,11 +2520,23 @@ extern "C" void EntranceTracker_SetLastEntranceOverride(s16 entranceIndex) { } extern "C" void Gfx_RegisterBlendedTexture(const char* name, u8* mask, u8* replacement) { - gfx_register_blended_texture(name, mask, replacement); + if (auto intP = dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()) + ->GetInterpreterWeak() + .lock()) { + intP->RegisterBlendedTexture(name, mask, replacement); + } else { + assert(false && "Lost reference to Fast::Interpreter"); + } } extern "C" void Gfx_UnregisterBlendedTexture(const char* name) { - gfx_unregister_blended_texture(name); + if (auto intP = dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()) + ->GetInterpreterWeak() + .lock()) { + intP->UnregisterBlendedTexture(name); + } else { + assert(false && "Lost reference to Fast::Interpreter"); + } } extern "C" void Gfx_TextureCacheDelete(const uint8_t* texAddr) { @@ -2514,7 +2550,13 @@ extern "C" void Gfx_TextureCacheDelete(const uint8_t* texAddr) { texAddr = (const uint8_t*)ResourceMgr_GetResourceDataByNameHandlingMQ(imgName); } - gfx_texture_cache_delete(texAddr); + if (auto intP = dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()) + ->GetInterpreterWeak() + .lock()) { + intP->TextureCacheDelete(texAddr); + } else { + assert(false && "Lost reference to Fast::Interpreter"); + } } void SoH_ProcessDroppedFiles(std::string filePath) { diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 6f83d78ad..2d1464e47 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -15,6 +15,11 @@ #define BTN_CUSTOM_OCARINA_PITCH_UP ((CONTROLLERBUTTONS_T)0x00400000) #define BTN_CUSTOM_OCARINA_PITCH_DOWN ((CONTROLLERBUTTONS_T)0x00800000) +#define M_PIf 3.14159265358979323846f +#define M_PI_2f 1.57079632679489661923f // pi/2 +#define M_SQRT2f 1.41421356237309504880f +#define M_SQRT1_2f 0.70710678118654752440f /* 1/sqrt(2) */ + #ifdef __cplusplus #include #include "Enhancements/savestates.h" diff --git a/soh/soh/ResourceManagerHelpers.cpp b/soh/soh/ResourceManagerHelpers.cpp index e1074e517..57e0ab270 100644 --- a/soh/soh/ResourceManagerHelpers.cpp +++ b/soh/soh/ResourceManagerHelpers.cpp @@ -11,7 +11,7 @@ #include "resource/type/Array.h" #include "resource/type/Skeleton.h" #include "resource/type/PlayerAnimation.h" -#include +#include #include extern "C" PlayState* gPlayState; @@ -292,7 +292,7 @@ extern "C" char* ResourceMgr_LoadPlayerAnimByName(const char* animPath) { } extern "C" void ResourceMgr_PushCurrentDirectory(char* path) { - gfx_push_current_dir(path); + Fast::gfx_push_current_dir(path); } extern "C" Gfx* ResourceMgr_LoadGfxByName(const char* path) { diff --git a/soh/soh/SohGui/ImGuiUtils.cpp b/soh/soh/SohGui/ImGuiUtils.cpp index 87a8b20e6..ab3d8f59c 100644 --- a/soh/soh/SohGui/ImGuiUtils.cpp +++ b/soh/soh/SohGui/ImGuiUtils.cpp @@ -1,5 +1,6 @@ #include "ImGuiUtils.h" #include +#include #include "assets/soh_assets.h" #include "soh/Enhancements/randomizer/rando_hash.h" diff --git a/soh/soh/SohGui/Menu.h b/soh/soh/SohGui/Menu.h index 139f90030..a7facffd1 100644 --- a/soh/soh/SohGui/Menu.h +++ b/soh/soh/SohGui/Menu.h @@ -2,7 +2,7 @@ #define MENU_H #include -#include "graphic/Fast3D/gfx_rendering_api.h" +#include "graphic/Fast3D/backends/gfx_rendering_api.h" #include "MenuTypes.h" namespace Ship { diff --git a/soh/soh/SohGui/ResolutionEditor.cpp b/soh/soh/SohGui/ResolutionEditor.cpp index d33a7b43c..41026e1e2 100644 --- a/soh/soh/SohGui/ResolutionEditor.cpp +++ b/soh/soh/SohGui/ResolutionEditor.cpp @@ -3,7 +3,8 @@ #include #include "soh/SohGui/UIWidgets.hpp" -#include +#include +#include #include "soh/OTRGlobals.h" #include "soh/SohGui/SohMenu.h" #include "soh/SohGui/SohGui.hpp" @@ -86,6 +87,16 @@ static bool disabled_pixelCount; using namespace UIWidgets; +static std::weak_ptr mInterpreter; + +std::shared_ptr GetInterpreter() { + auto intP = mInterpreter.lock(); + if (!intP) { + assert(false && "Lost reference to Fast::Interpreter"); + } + return intP; +} + void ResolutionCustomWidget(WidgetInfo& info) { ImGui::BeginDisabled(disabled_everything); // Vertical Resolution @@ -368,18 +379,23 @@ void ResolutionCustomWidget(WidgetInfo& info) { } void RegisterResolutionWidgets() { + auto fastWnd = dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + mInterpreter = fastWnd->GetInterpreterWeak(); + WidgetPath path = { "Settings", "Graphics", SECTION_COLUMN_2 }; // Resolution visualiser mSohMenu->AddWidget(path, "Viewport dimensions: {} x {}", WIDGET_TEXT) .RaceDisable(false) .PreFunc([](WidgetInfo& info) { + auto gfx_current_game_window_viewport = GetInterpreter().get()->mGameWindowViewport; info.name = fmt::format("Viewport dimensions: {} x {}", gfx_current_game_window_viewport.width, gfx_current_game_window_viewport.height); }); mSohMenu->AddWidget(path, "Internal resolution: {} x {}", WIDGET_TEXT) .RaceDisable(false) .PreFunc([](WidgetInfo& info) { + auto gfx_current_dimensions = GetInterpreter().get()->mCurDimensions; info.name = fmt::format("Internal resolution: {} x {}", gfx_current_dimensions.width, gfx_current_dimensions.height); }); @@ -486,6 +502,7 @@ void RegisterResolutionWidgets() { } } else if (showHorizontalResField) { // Show calculated aspect ratio if (item_aspectRatio) { + auto gfx_current_dimensions = GetInterpreter().get()->mCurDimensions; ImGui::Dummy({ 0, 2 }); const float resolvedAspectRatio = (float)gfx_current_dimensions.width / gfx_current_dimensions.height; @@ -539,6 +556,8 @@ void UpdateResolutionVars() { short integerScale_maximumBounds = 1; // can change when window is resized // This is mostly just for UX purposes, as Fit Automatically logic is part of LUS. + auto gfx_current_game_window_viewport = GetInterpreter().get()->mGameWindowViewport; + auto gfx_current_dimensions = GetInterpreter().get()->mCurDimensions; if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) > ((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) { // Scale to window height diff --git a/soh/soh/SohGui/SohGui.cpp b/soh/soh/SohGui/SohGui.cpp index 7eb3fc6c7..e9b27eda1 100644 --- a/soh/soh/SohGui/SohGui.cpp +++ b/soh/soh/SohGui/SohGui.cpp @@ -11,10 +11,9 @@ #include #include #include -#include #ifdef __APPLE__ -#include "graphic/Fast3D/gfx_metal.h" +#include "graphic/Fast3D/backends/gfx_metal.h" #endif #ifdef __SWITCH__ diff --git a/soh/soh/SohGui/SohMenu.h b/soh/soh/SohGui/SohMenu.h index eb3b1f4f7..362cc4721 100644 --- a/soh/soh/SohGui/SohMenu.h +++ b/soh/soh/SohGui/SohMenu.h @@ -4,7 +4,7 @@ #include #include "UIWidgets.hpp" #include "Menu.h" -#include "graphic/Fast3D/gfx_rendering_api.h" +#include "graphic/Fast3D/backends/gfx_rendering_api.h" #include "soh/cvar_prefixes.h" #include "soh/Enhancements/enhancementTypes.h" #include "soh/Enhancements/Presets/Presets.h" @@ -53,9 +53,9 @@ static const std::unordered_map menuThemeOptions = { }; static const std::unordered_map textureFilteringMap = { - { FILTER_THREE_POINT, "Three-Point" }, - { FILTER_LINEAR, "Linear" }, - { FILTER_NONE, "None" }, + { Fast::FILTER_THREE_POINT, "Three-Point" }, + { Fast::FILTER_LINEAR, "Linear" }, + { Fast::FILTER_NONE, "None" }, }; static const std::unordered_map logLevels = { diff --git a/soh/soh/SohGui/SohMenuBar.cpp b/soh/soh/SohGui/SohMenuBar.cpp index aa747c168..418d02eb5 100644 --- a/soh/soh/SohGui/SohMenuBar.cpp +++ b/soh/soh/SohGui/SohMenuBar.cpp @@ -5,7 +5,7 @@ #include #include "UIWidgets.hpp" #include "include/z64audio.h" -#include "graphic/Fast3D/gfx_rendering_api.h" +#include "graphic/Fast3D/backends/gfx_rendering_api.h" #include "soh/OTRGlobals.h" #include "soh/SaveManager.h" #include "z64.h" diff --git a/soh/soh/SohGui/SohMenuEnhancements.cpp b/soh/soh/SohGui/SohMenuEnhancements.cpp index 95c942d37..edfb1052f 100644 --- a/soh/soh/SohGui/SohMenuEnhancements.cpp +++ b/soh/soh/SohGui/SohMenuEnhancements.cpp @@ -336,8 +336,8 @@ void SohMenu::AddMenuEnhancements() { .CVar(CVAR_ENHANCEMENT("TimeSavers.SkipCutscene.GlitchAiding")) .Options(CheckboxOptions().Tooltip( "Don't skip cutscenes that are associated with useful glitches. Currently, it is " - "only the Fire Temple Darunia CS, Forest Temple Poe Sisters CS, and the Box Skip One " - "Point in Jabu.")); + "only the Fire Temple Darunia CS, Forest Temple Poe Sisters CS, Dodongo Boss " + "Door Switch CS, Water Temple Dragon Switch CS, and the Box Skip One Point in Jabu.")); AddWidget(path, "Text", WIDGET_SEPARATOR_TEXT); AddWidget(path, "Skip Pickup Messages", WIDGET_CVAR_CHECKBOX) diff --git a/soh/soh/resource/importer/ArrayFactory.cpp b/soh/soh/resource/importer/ArrayFactory.cpp index 0d80d1ef4..0762704ff 100644 --- a/soh/soh/resource/importer/ArrayFactory.cpp +++ b/soh/soh/resource/importer/ArrayFactory.cpp @@ -20,7 +20,7 @@ ResourceFactoryBinaryArrayV0::ReadResource(std::shared_ptr file, for (uint32_t i = 0; i < array->ArrayCount; i++) { if (array->ArrayType == ArrayResourceType::Vertex) { // OTRTODO: Implement Vertex arrays as just a vertex resource. - F3DVtx data; + Fast::F3DVtx data; data.v.ob[0] = reader->ReadInt16(); data.v.ob[1] = reader->ReadInt16(); data.v.ob[2] = reader->ReadInt16(); diff --git a/soh/soh/resource/importer/CollisionHeaderFactory.cpp b/soh/soh/resource/importer/CollisionHeaderFactory.cpp index 35e51d2af..39bf885a0 100644 --- a/soh/soh/resource/importer/CollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/CollisionHeaderFactory.cpp @@ -1,6 +1,7 @@ #include "soh/resource/importer/CollisionHeaderFactory.h" #include "soh/resource/type/CollisionHeader.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr diff --git a/soh/soh/resource/importer/PathFactory.cpp b/soh/soh/resource/importer/PathFactory.cpp index 6848fde30..945e36c5f 100644 --- a/soh/soh/resource/importer/PathFactory.cpp +++ b/soh/soh/resource/importer/PathFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/Path.h" #include "soh/resource/logging/PathLogger.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr diff --git a/soh/soh/resource/importer/SceneFactory.cpp b/soh/soh/resource/importer/SceneFactory.cpp index 9f79cd80c..730842b7e 100644 --- a/soh/soh/resource/importer/SceneFactory.cpp +++ b/soh/soh/resource/importer/SceneFactory.cpp @@ -1,4 +1,5 @@ #include "spdlog/spdlog.h" +#include #include "soh/resource/type/SohResourceType.h" #include "soh/resource/importer/SceneFactory.h" #include "soh/resource/type/Scene.h" diff --git a/soh/soh/resource/importer/SkeletonFactory.cpp b/soh/soh/resource/importer/SkeletonFactory.cpp index 108d600de..56338cd03 100644 --- a/soh/soh/resource/importer/SkeletonFactory.cpp +++ b/soh/soh/resource/importer/SkeletonFactory.cpp @@ -1,6 +1,7 @@ #include "soh/resource/importer/SkeletonFactory.h" #include "soh/resource/type/Skeleton.h" #include +#include #include namespace SOH { diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.cpp b/soh/soh/resource/importer/SkeletonLimbFactory.cpp index 7b58976ab..731892f2a 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.cpp +++ b/soh/soh/resource/importer/SkeletonLimbFactory.cpp @@ -1,6 +1,7 @@ #include "soh/resource/importer/SkeletonLimbFactory.h" #include "soh/resource/type/SkeletonLimb.h" #include "spdlog/spdlog.h" +#include #include "libultraship/libultraship.h" namespace SOH { diff --git a/soh/soh/resource/importer/TextFactory.cpp b/soh/soh/resource/importer/TextFactory.cpp index 54ed691f8..0a2c1afb4 100644 --- a/soh/soh/resource/importer/TextFactory.cpp +++ b/soh/soh/resource/importer/TextFactory.cpp @@ -1,6 +1,7 @@ #include "soh/resource/importer/TextFactory.h" #include "soh/resource/type/Text.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr diff --git a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp index b54f1cade..f96d541f5 100644 --- a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/EndMarker.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr EndMarkerFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp index 94eb62f14..5b9f851d1 100644 --- a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetActorList.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr SetActorListFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp index 70b045d07..5a6d35cc2 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetAlternateHeaders.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include #include "libultraship/libultraship.h" namespace SOH { diff --git a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp index 318f6d4fe..e2f4de65b 100644 --- a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetCameraSettings.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp index c348b8986..cc0a7b005 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp @@ -3,6 +3,7 @@ #include "soh/resource/logging/SceneCommandLoggers.h" #include "libultraship/libultraship.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr diff --git a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp index eb54b0a22..ed08c88be 100644 --- a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetCsCamera.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr SetCsCameraFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp index 20f96ec46..a8883b2e4 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp @@ -3,6 +3,7 @@ #include "soh/resource/logging/SceneCommandLoggers.h" #include #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr SetCutscenesFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp index f71925bdd..3352a2ef2 100644 --- a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetEchoSettings.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr SetEchoSettingsFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp index e033e7d79..eab272b89 100644 --- a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetEntranceList.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr SetEntranceListFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp index cc0128a4f..a1cb515ff 100644 --- a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetExitList.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr SetExitListFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp index 9ef1e944f..ebb819634 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetLightList.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr SetLightListFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp index 545d24f69..01c5d59e1 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetLightingSettings.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr diff --git a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp index 05e3169ce..2f6bf5568 100644 --- a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetMesh.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include #include "libultraship/libultraship.h" namespace SOH { diff --git a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp index 37d340e36..fbee15e8a 100644 --- a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetObjectList.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr SetObjectListFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp index 084d05aae..62a3d0d7f 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetPathways.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include #include namespace SOH { diff --git a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp index de9a01e77..9b18593f5 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetRoomBehavior.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr SetRoomBehaviorFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp index cc03b9f12..7925a012f 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetRoomList.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr SetRoomListFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp index 5168b8c32..a071cc4d0 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetSkyboxModifier.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp index e5d3c55c3..3434505cb 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetSkyboxSettings.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr diff --git a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp index 6826eae4c..a72acce8c 100644 --- a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetSoundSettings.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr SetSoundSettingsFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp index 44adb5d28..2877dc88a 100644 --- a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetSpecialObjects.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr diff --git a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp index 3a8c885ac..d370cde2b 100644 --- a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetStartPositionList.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr diff --git a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp index 2a3ec29cf..714570208 100644 --- a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetTimeSettings.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr SetTimeSettingsFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp index e026302a0..fd028b6e3 100644 --- a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetTransitionActorList.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr diff --git a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp index 7c810c233..86f0af515 100644 --- a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp @@ -2,6 +2,7 @@ #include "soh/resource/type/scenecommand/SetWindSettings.h" #include "soh/resource/logging/SceneCommandLoggers.h" #include "spdlog/spdlog.h" +#include namespace SOH { std::shared_ptr SetWindSettingsFactory::ReadResource(std::shared_ptr initData, diff --git a/soh/soh/resource/logging/PathLogger.cpp b/soh/soh/resource/logging/PathLogger.cpp index 437815000..47b0081f3 100644 --- a/soh/soh/resource/logging/PathLogger.cpp +++ b/soh/soh/resource/logging/PathLogger.cpp @@ -1,5 +1,6 @@ #include "soh/resource/type/Path.h" #include "spdlog/spdlog.h" +#include namespace SOH { void LogPathAsXML(std::shared_ptr resource) { diff --git a/soh/soh/resource/logging/SceneCommandLoggers.cpp b/soh/soh/resource/logging/SceneCommandLoggers.cpp index b0821bdb9..8a464172d 100644 --- a/soh/soh/resource/logging/SceneCommandLoggers.cpp +++ b/soh/soh/resource/logging/SceneCommandLoggers.cpp @@ -24,6 +24,7 @@ #include "soh/resource/type/scenecommand/SetTransitionActorList.h" #include "soh/resource/type/scenecommand/SetWindSettings.h" #include "spdlog/spdlog.h" +#include #include namespace SOH { diff --git a/soh/soh/resource/type/Array.cpp b/soh/soh/resource/type/Array.cpp index d9c3b1cb4..a4bbc0e5e 100644 --- a/soh/soh/resource/type/Array.cpp +++ b/soh/soh/resource/type/Array.cpp @@ -23,7 +23,7 @@ size_t Array::GetPointerSize() { size_t typeSize = 0; switch (ArrayType) { case ArrayResourceType::Vertex: - typeSize = sizeof(F3DVtx); + typeSize = sizeof(Fast::F3DVtx); break; case ArrayResourceType::Scalar: default: diff --git a/soh/soh/resource/type/Array.h b/soh/soh/resource/type/Array.h index cefea1bc8..c7d15a22a 100644 --- a/soh/soh/resource/type/Array.h +++ b/soh/soh/resource/type/Array.h @@ -2,7 +2,10 @@ #include "resource/Resource.h" +namespace Fast { union F3DVtx; +} + namespace SOH { typedef union ScalarData { uint8_t u8; @@ -80,6 +83,6 @@ class Array : public Ship::Resource { size_t ArrayCount; // OTRTODO: Should be a vector of resource pointers... std::vector Scalars; - std::vector Vertices; + std::vector Vertices; }; } // namespace SOH diff --git a/soh/soh/stubs.c b/soh/soh/stubs.c index 56013e56f..118b36e72 100644 --- a/soh/soh/stubs.c +++ b/soh/soh/stubs.c @@ -145,7 +145,47 @@ void Audio_osWritebackDCache(void* mem, s32 size) { } s32 osAiSetFrequency(u32 freq) { - return 1; + // this is based off the math from the original method + /* + + s32 osAiSetFrequency(u32 frequency) { + u8 bitrate; + f32 dacRateF = ((f32)osViClock / frequency) + 0.5f; + u32 dacRate = dacRateF; + + if (dacRate < 132) { + return -1; + } + + bitrate = (dacRate / 66); + if (bitrate > 16) { + bitrate = 16; + } + + HW_REG(AI_DACRATE_REG, u32) = dacRate - 1; + HW_REG(AI_BITRATE_REG, u32) = bitrate - 1; + return osViClock / (s32)dacRate; + } + + */ + + // bitrate is unused + + // osViClock comes from + // #define VI_NTSC_CLOCK 48681812 /* Hz = 48.681812 MHz */ + // s32 osViClock = VI_NTSC_CLOCK; + + // frequency was originally 32000 + + // given all of that, dacRate is + // (u32)(((f32)48681812 / 32000) + 0.5f) + // which evaluates to 1521 (which is > 132) + + // this leaves us with a final calculation of + // 48681812 / 1521 + // which evaluates to 32006 + + return 32006; } void osInvalDCache(void* vaddr, s32 nbytes) { diff --git a/soh/src/code/code_800A9F30.c b/soh/src/code/code_800A9F30.c index d0ca380f4..2eba3774c 100644 --- a/soh/src/code/code_800A9F30.c +++ b/soh/src/code/code_800A9F30.c @@ -84,7 +84,7 @@ void func_800AA15C(void) { D_80160FD0.unk_104 = 2; } -void func_800AA16C(void) { +void Rumble_ClearRequests(void) { D_80160FD0.unk_104 = 0; } diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 3ca67ad3b..ac9e4f3f6 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -3466,6 +3466,9 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) { player = GET_PLAYER(play); + // Execute before actor memory is freed + GameInteractor_ExecuteOnActorDestroy(actor); + dbEntry = ActorDB_Retrieve(actor->id); if (HREG(20) != 0) { diff --git a/soh/src/code/z_kankyo.c b/soh/src/code/z_kankyo.c index 090cce962..d78a93c6c 100644 --- a/soh/src/code/z_kankyo.c +++ b/soh/src/code/z_kankyo.c @@ -892,7 +892,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex if ((((void)0, gSaveContext.gameMode) != GAMEMODE_NORMAL) && (((void)0, gSaveContext.gameMode) != GAMEMODE_END_CREDITS)) { - func_800AA16C(play); + Rumble_ClearRequests(); } if (pauseCtx->state == 0) { diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 3423855b6..cc6245241 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -4113,7 +4113,8 @@ void Interface_DrawItemButtons(PlayState* play) { if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) { X_Margins_CD = Left_HUD_Margin; }; - C_Down_BTN_Pos[0] = (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0) + X_Margins_CD); + C_Down_BTN_Pos[0] = + OTRGetDimensionFromLeftEdge(CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosX"), 0) + X_Margins_CD); } else if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.PosType"), 0) == ANCHOR_RIGHT) { if (CVarGetInteger(CVAR_COSMETIC("HUD.CDownButton.UseMargins"), 0) != 0) { X_Margins_CD = Right_HUD_Margin; diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index c5c600459..58829aee8 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -1289,12 +1289,12 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx** D_80160000 = &this->meleeWeaponInfo[2].base; if (!LINK_IS_ADULT) { - if (!(this->skelAnime.moveFlags & 4) || (this->skelAnime.moveFlags & 1)) { + if (!(this->skelAnime.movementFlags & 4) || (this->skelAnime.movementFlags & 1)) { pos->x *= 0.64f; pos->z *= 0.64f; } - if (!(this->skelAnime.moveFlags & 4) || (this->skelAnime.moveFlags & 2)) { + if (!(this->skelAnime.movementFlags & 4) || (this->skelAnime.movementFlags & 2)) { pos->y *= 0.64f; } } diff --git a/soh/src/code/z_skelanime.c b/soh/src/code/z_skelanime.c index 0773eb4e0..e9f84980c 100644 --- a/soh/src/code/z_skelanime.c +++ b/soh/src/code/z_skelanime.c @@ -1170,9 +1170,9 @@ void SkelAnime_InitLink(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeade */ void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { - skelAnime->update = LinkAnimation_Loop; + skelAnime->update.link = LinkAnimation_Loop; } else { - skelAnime->update = LinkAnimation_Once; + skelAnime->update.link = LinkAnimation_Once; } skelAnime->morphWeight = 0.0f; } @@ -1182,7 +1182,7 @@ void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { * finishes. */ s32 LinkAnimation_Update(PlayState* play, SkelAnime* skelAnime) { - return skelAnime->update(play, skelAnime); + return skelAnime->update.link(play, skelAnime); } /** @@ -1294,7 +1294,7 @@ void LinkAnimation_Change(PlayState* play, SkelAnime* skelAnime, LinkAnimationHe SkelAnime_CopyFrameTable(skelAnime, skelAnime->morphTable, skelAnime->jointTable); morphFrames = -morphFrames; } else { - skelAnime->update = LinkAnimation_Morph; + skelAnime->update.link = LinkAnimation_Morph; AnimationContext_SetLoadFrame(play, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->morphTable); } @@ -1559,11 +1559,11 @@ s32 SkelAnime_InitSkin(PlayState* play, SkelAnime* skelAnime, SkeletonHeader* sk */ void SkelAnime_SetUpdate(SkelAnime* skelAnime) { if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { - skelAnime->update = SkelAnime_LoopFull; + skelAnime->update.normal = SkelAnime_LoopFull; } else if (skelAnime->mode <= ANIMMODE_ONCE_INTERP) { - skelAnime->update = SkelAnime_Once; + skelAnime->update.normal = SkelAnime_Once; } else { - skelAnime->update = SkelAnime_LoopPartial; + skelAnime->update.normal = SkelAnime_LoopPartial; } } @@ -1572,7 +1572,7 @@ void SkelAnime_SetUpdate(SkelAnime* skelAnime) { * finishes. */ s32 SkelAnime_Update(SkelAnime* skelAnime) { - return skelAnime->update(skelAnime); + return skelAnime->update.normal(skelAnime); } /** @@ -1741,10 +1741,10 @@ void Animation_ChangeImpl(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames = -morphFrames; } else { if (taper != ANIMTAPER_NONE) { - skelAnime->update = SkelAnime_MorphTaper; + skelAnime->update.normal = SkelAnime_MorphTaper; skelAnime->taper = taper; } else { - skelAnime->update = SkelAnime_Morph; + skelAnime->update.normal = SkelAnime_Morph; } SkelAnime_GetFrameData(animation, startFrame, skelAnime->limbCount, skelAnime->morphTable); } @@ -1895,7 +1895,7 @@ void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle) { f32 sin; f32 cos; - if (skelAnime->moveFlags & ANIM_FLAG_NOMOVE) { + if (skelAnime->movementFlags & ANIM_FLAG_NOMOVE) { diff->x = diff->z = 0.0f; } else { x = skelAnime->jointTable[0].x; @@ -1917,8 +1917,8 @@ void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle) { skelAnime->jointTable[0].x = skelAnime->baseTransl.x; skelAnime->prevTransl.z = skelAnime->jointTable[0].z; skelAnime->jointTable[0].z = skelAnime->baseTransl.z; - if (skelAnime->moveFlags & ANIM_FLAG_UPDATEY) { - if (skelAnime->moveFlags & ANIM_FLAG_NOMOVE) { + if (skelAnime->movementFlags & ANIM_FLAG_UPDATEY) { + if (skelAnime->movementFlags & ANIM_FLAG_NOMOVE) { diff->y = 0.0f; } else { diff->y = skelAnime->jointTable[0].y - skelAnime->prevTransl.y; @@ -1929,7 +1929,7 @@ void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle) { diff->y = 0.0f; skelAnime->prevTransl.y = skelAnime->jointTable[0].y; } - skelAnime->moveFlags &= ~ANIM_FLAG_NOMOVE; + skelAnime->movementFlags &= ~ANIM_FLAG_NOMOVE; } /** diff --git a/soh/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c b/soh/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c index 04aff53be..692497415 100644 --- a/soh/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c +++ b/soh/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c @@ -6,6 +6,7 @@ #include "z_bg_mori_kaitenkabe.h" #include "objects/object_mori_objects/object_mori_objects.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #define FLAGS 0 @@ -97,7 +98,9 @@ void BgMoriKaitenkabe_Wait(BgMoriKaitenkabe* this, PlayState* play) { if ((this->timer > (28 - CVarGetInteger(CVAR_ENHANCEMENT("FasterBlockPush"), 0) * 4)) && !Player_InCsMode(play)) { BgMoriKaitenkabe_SetupRotate(this); - Player_SetCsActionWithHaltedActors(play, &this->dyna.actor, 8); + if (GameInteractor_Should(VB_FREEZE_LINK_FOR_FOREST_PILLARS, true)) { + Player_SetCsActionWithHaltedActors(play, &this->dyna.actor, 8); + } Math_Vec3f_Copy(&this->lockedPlayerPos, &player->actor.world.pos); push.x = Math_SinS(this->dyna.unk_158); push.y = 0.0f; @@ -131,7 +134,9 @@ void BgMoriKaitenkabe_Rotate(BgMoriKaitenkabe* this, PlayState* play) { Math_StepToF(&this->rotSpeed, 0.6f, 0.02f); if (Math_StepToF(&this->rotYdeg, this->rotDirection * 45.0f, this->rotSpeed)) { BgMoriKaitenkabe_SetupWait(this); - Player_SetCsActionWithHaltedActors(play, thisx, 7); + if (GameInteractor_Should(VB_FREEZE_LINK_FOR_FOREST_PILLARS, true)) { + Player_SetCsActionWithHaltedActors(play, thisx, 7); + } if (this->rotDirection > 0.0f) { thisx->home.rot.y += 0x2000; } else { @@ -148,7 +153,9 @@ void BgMoriKaitenkabe_Rotate(BgMoriKaitenkabe* this, PlayState* play) { this->dyna.unk_150 = 0.0f; player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; } - Math_Vec3f_Copy(&player->actor.world.pos, &this->lockedPlayerPos); + if (GameInteractor_Should(VB_FREEZE_LINK_FOR_FOREST_PILLARS, true)) { + Math_Vec3f_Copy(&player->actor.world.pos, &this->lockedPlayerPos); + } } void BgMoriKaitenkabe_Update(Actor* thisx, PlayState* play) { diff --git a/soh/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c b/soh/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c index 44b67f1bb..29debf9d6 100644 --- a/soh/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c +++ b/soh/src/overlays/actors/ovl_Demo_Ec/z_demo_ec.c @@ -175,19 +175,19 @@ void DemoEc_UpdateBgFlags(DemoEc* this, PlayState* play) { } void func_8096D594(DemoEc* this, PlayState* play) { - this->skelAnime.moveFlags |= 3; + this->skelAnime.movementFlags |= 3; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } void func_8096D5D4(DemoEc* this, PlayState* play) { this->skelAnime.baseTransl = this->skelAnime.jointTable[0]; this->skelAnime.prevTransl = this->skelAnime.jointTable[0]; - this->skelAnime.moveFlags |= 3; + this->skelAnime.movementFlags |= 3; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } void func_8096D64C(DemoEc* this, PlayState* play) { - this->skelAnime.moveFlags |= 3; + this->skelAnime.movementFlags |= 3; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } diff --git a/soh/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c b/soh/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c index 825ee35dc..e7ba4364e 100644 --- a/soh/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c +++ b/soh/src/overlays/actors/ovl_Demo_Ik/z_demo_ik.c @@ -55,12 +55,12 @@ s32 DemoIk_CheckCue(PlayState* play, u16 action, s32 index) { } void DemoIk_SetMove(DemoIk* this, PlayState* play) { - this->skelAnime.moveFlags |= 1; + this->skelAnime.movementFlags |= 1; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } void DemoIk_EndMove(DemoIk* this) { - this->skelAnime.moveFlags &= ~1; + this->skelAnime.movementFlags &= ~1; } f32 DemoIk_GetCurFrame(DemoIk* this) { diff --git a/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c b/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c index ad1c76a3d..3d50bf330 100644 --- a/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c +++ b/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c @@ -7,6 +7,7 @@ #include "z_demo_kekkai.h" #include "objects/object_demo_kekkai/object_demo_kekkai.h" #include "scenes/dungeons/ganontika/ganontika_scene.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/ResourceManagerHelpers.h" #define FLAGS (ACTOR_FLAG_UPDATE_CULLING_DISABLED | ACTOR_FLAG_DRAW_CULLING_DISABLED) @@ -257,13 +258,15 @@ void DemoKekkai_TrialBarrierIdle(Actor* thisx, PlayState* play) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider1.base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); if (this->collider2.base.acFlags & AC_HIT) { - Sfx_PlaySfxCentered(NA_SE_SY_CORRECT_CHIME); - // "I got it" - LOG_STRING("当ったよ"); - this->actor.update = DemoKekkai_TrialBarrierDispel; - this->timer = 0; - play->csCtx.segment = SEGMENTED_TO_VIRTUAL(sSageCutscenes[this->actor.params]); - gSaveContext.cutsceneTrigger = 1; + if (GameInteractor_Should(VB_PLAY_DISPEL_BARRIER_CS, true, this)) { + Sfx_PlaySfxCentered(NA_SE_SY_CORRECT_CHIME); + // "I got it" + LOG_STRING("当ったよ"); + this->actor.update = DemoKekkai_TrialBarrierDispel; + this->timer = 0; + play->csCtx.segment = SEGMENTED_TO_VIRTUAL(sSageCutscenes[this->actor.params]); + gSaveContext.cutsceneTrigger = 1; + } } CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); func_8002F974(&this->actor, NA_SE_EV_TOWER_ENERGY - SFX_FLAG); diff --git a/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.h b/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.h index 4e4a06c18..a8df145c2 100644 --- a/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.h +++ b/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.h @@ -6,7 +6,7 @@ struct DemoKekkai; -typedef void (*DemoKekkaiUpdateFunc)(struct DemoKekkai* this, PlayState* play); +typedef void (*DemoKekkaiUpdateFunc)(struct DemoKekkai* thisx, PlayState* play); typedef struct DemoKekkai { /* 0x0000 */ Actor actor; diff --git a/soh/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c b/soh/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c index 61a10b056..192d749d4 100644 --- a/soh/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c +++ b/soh/src/overlays/actors/ovl_En_Heishi2/z_en_heishi2.c @@ -314,19 +314,21 @@ void func_80A5372C(EnHeishi2* this, PlayState* play) { f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->unk_2F2[0] = 200; - this->cameraId = Play_CreateSubCamera(play); - Play_ChangeCameraStatus(play, MAIN_CAM, CAM_STAT_WAIT); - Play_ChangeCameraStatus(play, this->cameraId, CAM_STAT_ACTIVE); - this->unk_280.x = 947.0f; - this->unk_280.y = 1195.0f; - this->unk_280.z = 2682.0f; + if (GameInteractor_Should(VB_PLAY_GATE_OPENING_OR_CLOSING_CS, true, this, false)) { + this->unk_2F2[0] = 200; + this->cameraId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, MAIN_CAM, CAM_STAT_WAIT); + Play_ChangeCameraStatus(play, this->cameraId, CAM_STAT_ACTIVE); + this->unk_280.x = 947.0f; + this->unk_280.y = 1195.0f; + this->unk_280.z = 2682.0f; - this->unk_28C.x = 1164.0f; - this->unk_28C.y = 1145.0f; - this->unk_28C.z = 3014.0f; + this->unk_28C.x = 1164.0f; + this->unk_28C.y = 1145.0f; + this->unk_28C.z = 3014.0f; - Play_CameraSetAtEye(play, this->cameraId, &this->unk_280, &this->unk_28C); + Play_CameraSetAtEye(play, this->cameraId, &this->unk_280, &this->unk_28C); + } this->actionFunc = func_80A53850; } @@ -334,11 +336,15 @@ void func_80A53850(EnHeishi2* this, PlayState* play) { BgSpot15Saku* gate; SkelAnime_Update(&this->skelAnime); - Play_CameraSetAtEye(play, this->cameraId, &this->unk_280, &this->unk_28C); + if (GameInteractor_Should(VB_PLAY_GATE_OPENING_OR_CLOSING_CS, true, this, false)) { + Play_CameraSetAtEye(play, this->cameraId, &this->unk_280, &this->unk_28C); + } gate = (BgSpot15Saku*)this->gate; if ((this->unk_2F2[0] == 0) || (gate->unk_168 == 0)) { - Play_ClearCamera(play, this->cameraId); - Play_ChangeCameraStatus(play, MAIN_CAM, CAM_STAT_ACTIVE); + if (GameInteractor_Should(VB_PLAY_GATE_OPENING_OR_CLOSING_CS, true, this, true)) { + Play_ClearCamera(play, this->cameraId); + Play_ChangeCameraStatus(play, MAIN_CAM, CAM_STAT_ACTIVE); + } Message_CloseTextbox(play); this->unk_30C = 1; Player_SetCsActionWithHaltedActors(play, NULL, 7); @@ -479,23 +485,25 @@ void func_80A53DF8(EnHeishi2* this, PlayState* play) { f32 frameCount = Animation_GetLastFrame(&gEnHeishiIdleAnim); Animation_Change(&this->skelAnime, &gEnHeishiIdleAnim, 1.0f, 0.0f, (s16)frameCount, ANIMMODE_LOOP, -10.0f); - this->unk_2F2[0] = 200; - this->cameraId = Play_CreateSubCamera(play); - Play_ChangeCameraStatus(play, MAIN_CAM, CAM_STAT_WAIT); - Play_ChangeCameraStatus(play, this->cameraId, CAM_STAT_ACTIVE); - this->unk_2BC.x = -71.0f; - this->unk_280.x = -71.0f; - this->unk_2BC.y = 571.0f; - this->unk_280.y = 571.0f; - this->unk_2BC.z = -1487.0f; - this->unk_280.z = -1487.0f; - this->unk_298.x = 181.0f; - this->unk_28C.x = 181.0f; - this->unk_298.y = 417.0f; - this->unk_28C.y = 417.0f; - this->unk_298.z = -1079.0f; - this->unk_28C.z = -1079.0f; - Play_CameraSetAtEye(play, this->cameraId, &this->unk_280, &this->unk_28C); + if (GameInteractor_Should(VB_PLAY_GATE_OPENING_OR_CLOSING_CS, true, this, false)) { + this->unk_2F2[0] = 200; + this->cameraId = Play_CreateSubCamera(play); + Play_ChangeCameraStatus(play, MAIN_CAM, CAM_STAT_WAIT); + Play_ChangeCameraStatus(play, this->cameraId, CAM_STAT_ACTIVE); + this->unk_2BC.x = -71.0f; + this->unk_280.x = -71.0f; + this->unk_2BC.y = 571.0f; + this->unk_280.y = 571.0f; + this->unk_2BC.z = -1487.0f; + this->unk_280.z = -1487.0f; + this->unk_298.x = 181.0f; + this->unk_28C.x = 181.0f; + this->unk_298.y = 417.0f; + this->unk_28C.y = 417.0f; + this->unk_298.z = -1079.0f; + this->unk_28C.z = -1079.0f; + Play_CameraSetAtEye(play, this->cameraId, &this->unk_280, &this->unk_28C); + } this->actionFunc = func_80A53F30; } @@ -503,11 +511,15 @@ void func_80A53F30(EnHeishi2* this, PlayState* play) { BgGateShutter* gate; SkelAnime_Update(&this->skelAnime); - Play_CameraSetAtEye(play, this->cameraId, &this->unk_280, &this->unk_28C); + if (GameInteractor_Should(VB_PLAY_GATE_OPENING_OR_CLOSING_CS, true, this, false)) { + Play_CameraSetAtEye(play, this->cameraId, &this->unk_280, &this->unk_28C); + } gate = (BgGateShutter*)this->gate; if ((this->unk_2F2[0] == 0) || (gate->openingState == 0)) { - Play_ClearCamera(play, this->cameraId); - Play_ChangeCameraStatus(play, MAIN_CAM, CAM_STAT_ACTIVE); + if (GameInteractor_Should(VB_PLAY_GATE_OPENING_OR_CLOSING_CS, true, this, true)) { + Play_ClearCamera(play, this->cameraId); + Play_ChangeCameraStatus(play, MAIN_CAM, CAM_STAT_ACTIVE); + } if ((this->unk_30A != 2)) { if (this->unk_30A == 0) { this->actor.textId = 0x2015; diff --git a/soh/src/overlays/actors/ovl_En_In/z_en_in.c b/soh/src/overlays/actors/ovl_En_In/z_en_in.c index e84d4d8ff..18903bfbb 100644 --- a/soh/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/soh/src/overlays/actors/ovl_En_In/z_en_in.c @@ -342,7 +342,7 @@ void func_80A795C8(EnIn* this, PlayState* play) { void func_80A79690(SkelAnime* skelAnime, EnIn* this, PlayState* play) { if (skelAnime->baseTransl.y < skelAnime->jointTable[0].y) { - skelAnime->moveFlags |= 3; + skelAnime->movementFlags |= 3; AnimationContext_SetMoveActor(play, &this->actor, skelAnime, 1.0f); } } diff --git a/soh/src/overlays/actors/ovl_En_Nb/z_en_nb.c b/soh/src/overlays/actors/ovl_En_Nb/z_en_nb.c index 73c966288..5acfe5a80 100644 --- a/soh/src/overlays/actors/ovl_En_Nb/z_en_nb.c +++ b/soh/src/overlays/actors/ovl_En_Nb/z_en_nb.c @@ -743,7 +743,7 @@ void EnNb_InitDemo6KInConfrontation(EnNb* this, PlayState* play) { } void func_80AB2688(EnNb* this, PlayState* play) { - this->skelAnime.moveFlags |= 1; + this->skelAnime.movementFlags |= 1; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } diff --git a/soh/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c b/soh/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c index d70e0af12..e03a8ed20 100644 --- a/soh/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c +++ b/soh/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c @@ -393,17 +393,17 @@ s32 EnRu1_UpdateSkelAnime(EnRu1* this) { } void func_80AEB364(EnRu1* this, PlayState* play) { - this->skelAnime.moveFlags |= 1; + this->skelAnime.movementFlags |= 1; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } void func_80AEB3A4(EnRu1* this, PlayState* play) { - this->skelAnime.moveFlags |= 1; + this->skelAnime.movementFlags |= 1; func_80AEB364(this, play); } void func_80AEB3CC(EnRu1* this) { - this->skelAnime.moveFlags &= ~0x1; + this->skelAnime.movementFlags &= ~0x1; } void func_80AEB3DC(EnRu1* this, PlayState* play) { @@ -464,7 +464,7 @@ void func_80AEB6E0(EnRu1* this, PlayState* play) { SkelAnime* skelAnime = &this->skelAnime; if (skelAnime->baseTransl.y < skelAnime->jointTable[0].y) { - skelAnime->moveFlags |= 3; + skelAnime->movementFlags |= 3; AnimationContext_SetMoveActor(play, &this->actor, skelAnime, 1.0f); } } @@ -475,13 +475,13 @@ void func_80AEB738(EnRu1* this, PlayState* play) { skelAnime->baseTransl = skelAnime->jointTable[0]; skelAnime->prevTransl = skelAnime->jointTable[0]; if (skelAnime->baseTransl.y < skelAnime->jointTable[0].y) { - skelAnime->moveFlags |= 3; + skelAnime->movementFlags |= 3; AnimationContext_SetMoveActor(play, &this->actor, skelAnime, 1.0f); } } void func_80AEB7D0(EnRu1* this) { - this->skelAnime.moveFlags &= ~0x3; + this->skelAnime.movementFlags &= ~0x3; } f32 func_80AEB7E0(CsCmdActorCue* csCmdNPCAction, PlayState* play) { diff --git a/soh/src/overlays/actors/ovl_En_Test/z_en_test.c b/soh/src/overlays/actors/ovl_En_Test/z_en_test.c index 72969cc2e..0bcf45a8b 100644 --- a/soh/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/soh/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -1595,7 +1595,7 @@ void func_8086318C(EnTest* this, PlayState* play) { void EnTest_SetupRecoil(EnTest* this) { this->meleeWeaponState = 0; - this->skelAnime.moveFlags = 2; + this->skelAnime.movementFlags = 2; this->unk_7C8 = 0x13; this->skelAnime.playSpeed = -1.0f; this->skelAnime.startFrame = this->skelAnime.curFrame; diff --git a/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c b/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c index 30f035c5d..84500db21 100644 --- a/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c +++ b/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c @@ -249,25 +249,25 @@ void func_80B3C8CC(EnXc* this, PlayState* play) { SkelAnime* skelAnime = &this->skelAnime; if (skelAnime->jointTable[0].y >= skelAnime->baseTransl.y) { - skelAnime->moveFlags |= 3; + skelAnime->movementFlags |= 3; AnimationContext_SetMoveActor(play, &this->actor, skelAnime, 1.0f); } } void func_80B3C924(EnXc* this, PlayState* play) { - this->skelAnime.moveFlags |= 3; + this->skelAnime.movementFlags |= 3; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } void func_80B3C964(EnXc* this, PlayState* play) { this->skelAnime.baseTransl = this->skelAnime.jointTable[0]; this->skelAnime.prevTransl = this->skelAnime.jointTable[0]; - this->skelAnime.moveFlags |= 3; + this->skelAnime.movementFlags |= 3; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } void func_80B3C9DC(EnXc* this) { - this->skelAnime.moveFlags &= ~0x3; + this->skelAnime.movementFlags &= ~0x3; } void func_80B3C9EC(EnXc* this) { diff --git a/soh/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c b/soh/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c index 380f80bc9..c02744959 100644 --- a/soh/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c +++ b/soh/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c @@ -348,7 +348,7 @@ void func_80B4B834(CsCmdActorCue* npcAction, Vec3f* pos) { } void func_80B4B874(EnZl1* this, PlayState* play) { - this->skelAnime.moveFlags |= 1; + this->skelAnime.movementFlags |= 1; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } diff --git a/soh/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c b/soh/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c index 42a3942dd..aab3e9505 100644 --- a/soh/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c +++ b/soh/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c @@ -305,7 +305,7 @@ void EnZl4_UpdateFace(EnZl4* this) { } void EnZl4_SetMove(EnZl4* this, PlayState* play) { - this->skelAnime.moveFlags |= 1; + this->skelAnime.movementFlags |= 1; AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } diff --git a/soh/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c b/soh/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c index a3541a246..34606904b 100644 --- a/soh/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c +++ b/soh/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c @@ -53,12 +53,12 @@ void ObjHsblock_SetupAction(ObjHsblock* this, ObjHsblockActionFunc actionFunc) { this->actionFunc = actionFunc; } -void func_80B93B68(ObjHsblock* this, PlayState* play, CollisionHeader* collision, s32 moveFlags) { +void func_80B93B68(ObjHsblock* this, PlayState* play, CollisionHeader* collision, s32 movementFlags) { s32 pad; CollisionHeader* colHeader = NULL; s32 pad2[2]; - DynaPolyActor_Init(&this->dyna, moveFlags); + DynaPolyActor_Init(&this->dyna, movementFlags); CollisionHeader_GetVirtual(collision, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); if (this->dyna.bgId == BG_ACTOR_MAX) { diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index d97dcdc08..6cc57ca22 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -1926,14 +1926,14 @@ void Player_ZeroRootLimbYaw(Player* this) { * it can also be called within action functions to change animations in the middle of an action. */ void Player_FinishAnimMovement(Player* this) { - if (this->skelAnime.moveFlags != 0) { + if (this->skelAnime.movementFlags != 0) { Player_ApplyYawFromAnim(this); this->skelAnime.jointTable[0].x = this->skelAnime.baseTransl.x; this->skelAnime.jointTable[0].z = this->skelAnime.baseTransl.z; - if (this->skelAnime.moveFlags & 8) { - if (this->skelAnime.moveFlags & 2) { + if (this->skelAnime.movementFlags & 8) { + if (this->skelAnime.movementFlags & 2) { this->skelAnime.jointTable[0].y = this->skelAnime.prevTransl.y; } } else { @@ -1942,7 +1942,7 @@ void Player_FinishAnimMovement(Player* this) { Player_ResetAnimMovement(this); - this->skelAnime.moveFlags = 0; + this->skelAnime.movementFlags = 0; } } @@ -1958,7 +1958,7 @@ void Player_FinishAnimMovement(Player* this) { void Player_ApplyAnimMovementScaledByAge(Player* this, s32 movementFlags) { Vec3f diff; - this->skelAnime.moveFlags = movementFlags; + this->skelAnime.movementFlags = movementFlags; this->skelAnime.prevTransl = this->skelAnime.baseTransl; SkelAnime_UpdateTranslation(&this->skelAnime, &diff, this->actor.shape.rot.y); @@ -2005,7 +2005,7 @@ void Player_ApplyAnimMovementScaledByAge(Player* this, s32 movementFlags) { void Player_StartAnimMovement(PlayState* play, Player* this, s32 flags) { if (flags & PLAYER_ANIM_MOVEMENT_RESET_BY_AGE) { Player_ResetAnimMovementScaledByAge(this); - } else if ((flags & PLAYER_ANIM_MOVEMENT_RESET) || (this->skelAnime.moveFlags != 0)) { + } else if ((flags & PLAYER_ANIM_MOVEMENT_RESET) || (this->skelAnime.movementFlags != 0)) { // If AnimMovement is already in use when this function is called and // `PLAYER_ANIM_MOVEMENT_RESET_BY_AGE` is not set, then this case will be used. Player_ResetAnimMovement(this); @@ -2017,7 +2017,7 @@ void Player_StartAnimMovement(PlayState* play, Player* this, s32 flags) { } // Remove Player specific flags by masking the lower byte before setting to `skelAnime.movementFlags` - this->skelAnime.moveFlags = flags /*&& 0xFF*/; + this->skelAnime.movementFlags = flags /*&& 0xFF*/; Player_ZeroSpeedXZ(this); AnimationContext_DisableQueue(play); @@ -3138,7 +3138,7 @@ s32 func_80835588(Player* this, PlayState* play) { void Player_SetParallel(Player* this) { this->stateFlags1 |= PLAYER_STATE1_PARALLEL; - if (!(this->skelAnime.moveFlags & 0x80) && (this->actor.bgCheckFlags & 0x200) && + if (!(this->skelAnime.movementFlags & 0x80) && (this->actor.bgCheckFlags & 0x200) && (sShapeYawToTouchedWall < 0x2000)) { // snap to the wall this->yaw = this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; @@ -3362,14 +3362,14 @@ s32 Player_SetupAction(PlayState* play, Player* this, PlayerActionFunc actionFun void Player_SetupActionPreserveAnimMovement(PlayState* play, Player* this, PlayerActionFunc actionFunc, s32 flags) { s32 savedMovementFlags; - savedMovementFlags = this->skelAnime.moveFlags; + savedMovementFlags = this->skelAnime.movementFlags; // Setting `skelAnime.movementFlags` to 0 will prevent `Player_FinishAnimMovement` from ending // AnimMovement when `Player_SetupAction` is called. - this->skelAnime.moveFlags = 0; + this->skelAnime.movementFlags = 0; Player_SetupAction(play, this, actionFunc, flags); - this->skelAnime.moveFlags = savedMovementFlags; + this->skelAnime.movementFlags = savedMovementFlags; } /** @@ -5779,7 +5779,7 @@ void func_8083AA10(Player* this, PlayState* play) { return; } - if (!(this->stateFlags3 & PLAYER_STATE3_MIDAIR) && !(this->skelAnime.moveFlags & 0x80) && + if (!(this->stateFlags3 & PLAYER_STATE3_MIDAIR) && !(this->skelAnime.movementFlags & 0x80) && (Player_Action_8084411C != this->actionFunc) && (Player_Action_80844A44 != this->actionFunc)) { if ((sPrevFloorProperty == 7) || (this->meleeWeaponState != 0)) { @@ -6927,7 +6927,7 @@ void func_8083D53C(PlayState* play, Player* this) { } } else if ((this->stateFlags1 & PLAYER_STATE1_IN_WATER) && (this->actor.yDistToWater < this->ageProperties->unk_24)) { - if ((this->skelAnime.moveFlags == 0) && (this->currentBoots != PLAYER_BOOTS_IRON)) { + if ((this->skelAnime.movementFlags == 0) && (this->currentBoots != PLAYER_BOOTS_IRON)) { Player_SetupTurnInPlace(play, this, this->actor.shape.rot.y); } func_8083D0A8(play, this, this->actor.velocity.y); @@ -12059,7 +12059,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { func_8084FF7C(this); } - if (!(this->skelAnime.moveFlags & 0x80)) { + if (!(this->skelAnime.movementFlags & 0x80)) { if (((this->actor.bgCheckFlags & 1) && (sFloorType == 5) && (this->currentBoots != PLAYER_BOOTS_IRON)) || ((this->currentBoots == PLAYER_BOOTS_HOVER || GameInteractor_GetSlipperyFloorActive()) && !(this->stateFlags1 & (PLAYER_STATE1_IN_WATER | PLAYER_STATE1_IN_CUTSCENE)))) { @@ -12246,9 +12246,9 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { Player_UpdateCamAndSeqModes(play, this); - if (this->skelAnime.moveFlags & 8) { + if (this->skelAnime.movementFlags & 8) { AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, - (this->skelAnime.moveFlags & 4) ? 1.0f : this->ageProperties->unk_08); + (this->skelAnime.movementFlags & 4) ? 1.0f : this->ageProperties->unk_08); } Player_UpdateShapeYaw(this, play); @@ -13113,7 +13113,7 @@ void Player_Action_Talk(Player* this, PlayState* play) { } else if (func_808332B8(this)) { Player_Action_8084D610(this, play); } else if (!Player_CheckHostileLockOn(this) && LinkAnimation_Update(play, &this->skelAnime)) { - if (this->skelAnime.moveFlags != 0) { + if (this->skelAnime.movementFlags != 0) { Player_FinishAnimMovement(this); if ((this->talkActor->category == ACTORCAT_NPC) && (this->heldItemAction != PLAYER_IA_FISHING_POLE)) { @@ -13551,8 +13551,8 @@ void Player_Action_8084C760(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { if (!(this->stateFlags1 & PLAYER_STATE1_LOADING)) { - if (this->skelAnime.moveFlags != 0) { - this->skelAnime.moveFlags = 0; + if (this->skelAnime.movementFlags != 0) { + this->skelAnime.movementFlags = 0; return; } @@ -15261,7 +15261,7 @@ void Player_Action_808502D0(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { if (!Player_ActionHandler_7(this, play)) { - u8 sp43 = this->skelAnime.moveFlags; + u8 sp43 = this->skelAnime.movementFlags; LinkAnimationHeader* sp3C; if (Player_CheckHostileLockOn(this)) { @@ -15271,7 +15271,7 @@ void Player_Action_808502D0(Player* this, PlayState* play) { } func_80832318(this); - this->skelAnime.moveFlags = 0; + this->skelAnime.movementFlags = 0; if ((sp3C == &gPlayerAnim_link_fighter_Lpower_jump_kiru_end) && (this->modelAnimType != PLAYER_ANIMTYPE_3)) { @@ -15280,7 +15280,7 @@ void Player_Action_808502D0(Player* this, PlayState* play) { func_8083A098(this, sp3C, play); - this->skelAnime.moveFlags = sp43; + this->skelAnime.movementFlags = sp43; this->stateFlags3 |= PLAYER_STATE3_FINISHED_ATTACKING; } } else if (this->heldItemAction == PLAYER_IA_HAMMER) { @@ -16553,7 +16553,7 @@ void func_80852A54(PlayState* play, Player* this, CsCmdActorCue* cue) { func_808529D0(play, this, cue); } - this->skelAnime.moveFlags = 0; + this->skelAnime.movementFlags = 0; Player_ZeroRootLimbYaw(this); } @@ -16564,7 +16564,7 @@ void func_80852B4C(PlayState* play, Player* this, CsCmdActorCue* cue, struct_808 arg3->func(play, this, cue); } - if ((D_80858AA0 & 4) && !(this->skelAnime.moveFlags & 4)) { + if ((D_80858AA0 & 4) && !(this->skelAnime.movementFlags & 4)) { this->skelAnime.morphTable[0].y /= this->ageProperties->unk_08; D_80858AA0 = 0; } @@ -16603,7 +16603,7 @@ void func_80852C50(PlayState* play, Player* this, CsCmdActorCue* cue) { } } - D_80858AA0 = this->skelAnime.moveFlags; + D_80858AA0 = this->skelAnime.movementFlags; Player_FinishAnimMovement(this); osSyncPrintf("TOOL MODE=%d\n", sp24); @@ -16626,7 +16626,7 @@ void func_80852C50(PlayState* play, Player* this, CsCmdActorCue* cue) { void Player_Action_CsAction(Player* this, PlayState* play) { if (this->csAction != this->prevCsAction) { - D_80858AA0 = this->skelAnime.moveFlags; + D_80858AA0 = this->skelAnime.movementFlags; Player_FinishAnimMovement(this); this->prevCsAction = this->csAction;