diff --git a/soh/soh/Enhancements/Difficulty/PermanentLosses.cpp b/soh/soh/Enhancements/Difficulty/PermanentLosses.cpp index 4c66849057..c6cb701fea 100644 --- a/soh/soh/Enhancements/Difficulty/PermanentLosses.cpp +++ b/soh/soh/Enhancements/Difficulty/PermanentLosses.cpp @@ -38,9 +38,9 @@ static void UpdatePermanentHeartLossState() { uint8_t startingHealth = 16 * (IS_RANDO ? (OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_STARTING_HEARTS) + 1) : 3); - uint8_t newCapacity = startingHealth + (heartContainers * 16) + ((heartPieces - (heartPieces % 4)) * 4); - gSaveContext.healthCapacity = MAX(newCapacity, gSaveContext.healthCapacity); - gSaveContext.health = MIN(gSaveContext.health, gSaveContext.healthCapacity); + s16 newCapacity = startingHealth + (heartContainers * 16) + ((heartPieces - (heartPieces % 4)) * 4); + gSaveContext.healthCapacity = std::max(newCapacity, gSaveContext.healthCapacity); + gSaveContext.health = std::min(gSaveContext.health, gSaveContext.healthCapacity); hasAffectedHealth = false; } @@ -52,7 +52,7 @@ static void UpdateHealthCapacity() { if (gSaveContext.healthCapacity > 16 && gSaveContext.healthCapacity - gSaveContext.health >= 16) { gSaveContext.healthCapacity -= 16; - gSaveContext.health = MIN(gSaveContext.health, gSaveContext.healthCapacity); + gSaveContext.health = std::min(gSaveContext.health, gSaveContext.healthCapacity); hasAffectedHealth = true; } } diff --git a/soh/soh/Enhancements/TimeSavers/MarketSneak.cpp b/soh/soh/Enhancements/TimeSavers/MarketSneak.cpp index bd74d0d59b..f1b6a731d9 100644 --- a/soh/soh/Enhancements/TimeSavers/MarketSneak.cpp +++ b/soh/soh/Enhancements/TimeSavers/MarketSneak.cpp @@ -3,6 +3,7 @@ #include "soh/ShipInit.hpp" #include "soh/Enhancements/randomizer/randomizer.h" #include "soh/Enhancements/randomizer/randomizer_entrance.h" +#include "soh/Enhancements/custom-message/CustomMessageTypes.h" extern "C" { #include diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 0f399c5ed7..cd733e97e6 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -4,6 +4,7 @@ #include "soh/Enhancements/game-interactor/GameInteractor.h" #include +#include #include #include "soh/SohGui/UIWidgets.hpp" @@ -507,14 +508,9 @@ void CosmeticsUpdateTick() { newColor.a = 255; // For alpha supported options, retain the last set alpha instead of overwriting if (cosmeticOption.supportsAlpha) { - newColor.a = static_cast(cosmeticOption.currentColor.w * 255.0f); + newColor.a = CVarGetColor(cosmeticOption.valuesCvar, cosmeticOption.defaultColor).a; } - cosmeticOption.currentColor.x = newColor.r / 255.0f; - cosmeticOption.currentColor.y = newColor.g / 255.0f; - cosmeticOption.currentColor.z = newColor.b / 255.0f; - cosmeticOption.currentColor.w = newColor.a / 255.0f; - CVarSetColor(cosmeticOption.valuesCvar, newColor); } // If we don't want the rainbow color on items to be synced, offset the index for each item in the loop. @@ -822,10 +818,11 @@ void ApplyOrResetCustomGfxPatches(bool manualChange) { gsDPSetGrayscaleColor(color.r, color.g, color.b, 255)); PATCH_GFX(gLinkChildHylianShieldSwordAndSheathFarDL, "Swords_KokiriHilt8", swordsKokiriHilt.changedCvar, 4, gsDPSetGrayscaleColor(color.r, color.g, color.b, 255)); PATCH_GFX(gGiKokiriSwordDL, "Swords_KokiriHilt9", - swordsKokiriHilt.changedCvar, 64, gsDPSetPrimColor(0, 0, MAX(color.r - 50, 0), MAX(color.g - 50, 0), - MAX(color.b - 50, 0), 255)); PATCH_GFX(gGiKokiriSwordDL, "Swords_KokiriHilt10", - swordsKokiriHilt.changedCvar, 66, gsDPSetEnvColor(MAX(color.r - 50, 0) / 3, MAX(color.g - 50, 0) / 3, - MAX(color.b - 50, 0) / 3, 255)); PATCH_GFX(gGiKokiriSwordDL, "Swords_KokiriHilt11", + swordsKokiriHilt.changedCvar, 64, gsDPSetPrimColor(0, 0, std::max(color.r - 50, 0), + std::max(color.g - 50, 0), std::max(color.b - 50, 0), 255)); PATCH_GFX(gGiKokiriSwordDL, "Swords_KokiriHilt10", + swordsKokiriHilt.changedCvar, 66, gsDPSetEnvColor(std::max(color.r - 50, 0) / 3, + std::max(color.g - 50, 0) / 3, std::max(color.b - 50, 0) / 3, 255)); PATCH_GFX(gGiKokiriSwordDL, + "Swords_KokiriHilt11", swordsKokiriHilt.changedCvar, 162, gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); PATCH_GFX(gGiKokiriSwordDL, "Swords_KokiriHilt12", swordsKokiriHilt.changedCvar, 164, gsDPSetEnvColor(color.r / 3, color.g / 3, color.b / 3, 255)); @@ -1068,18 +1065,20 @@ void ApplyOrResetCustomGfxPatches(bool manualChange) { if (manualChange || CVarGetInteger(equipmentSlingshotBody.rainbowCvar, 0)) { Color_RGBA8 color = CVarGetColor(equipmentSlingshotBody.valuesCvar, equipmentSlingshotBody.defaultColor); PATCH_GFX(gGiSlingshotDL, "Equipment_SlingshotBody1", - equipmentSlingshotBody.changedCvar, 10, gsDPSetPrimColor(0, 0, MAX(color.r - 100, 0), MAX(color.g - 100, 0), - MAX(color.b - 100, 0), 255)); PATCH_GFX(gGiSlingshotDL, "Equipment_SlingshotBody2", - equipmentSlingshotBody.changedCvar, 12, gsDPSetEnvColor(MAX(color.r - 100, 0) / 3, MAX(color.g - 100, 0) / 3, - MAX(color.b - 100, 0) / 3, 255)); PATCH_GFX(gGiSlingshotDL, "Equipment_SlingshotBody3", + equipmentSlingshotBody.changedCvar, 10, gsDPSetPrimColor(0, 0, std::max(color.r - 100, 0), + std::max(color.g - 100, 0), std::max(color.b - 100, 0), 255)); PATCH_GFX(gGiSlingshotDL, "Equipment_SlingshotBody2", + equipmentSlingshotBody.changedCvar, 12, gsDPSetEnvColor(std::max(color.r - 100, 0) / 3, + std::max(color.g - 100, 0) / 3, std::max(color.b - 100, 0) / 3, 255)); PATCH_GFX(gGiSlingshotDL, + "Equipment_SlingshotBody3", equipmentSlingshotBody.changedCvar, 74, gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); PATCH_GFX(gGiSlingshotDL, "Equipment_SlingshotBody4", equipmentSlingshotBody.changedCvar, 76, gsDPSetEnvColor(color.r / 3, color.g / 3, color.b / 3, 255)); PATCH_GFX(gGiSlingshotDL, "Equipment_SlingshotBody5", - equipmentSlingshotBody.changedCvar, 128, gsDPSetPrimColor(0, 0, MAX(color.r - 100, 0), MAX(color.g - 100, 0), - MAX(color.b - 100, 0), 255)); PATCH_GFX(gGiSlingshotDL, "Equipment_SlingshotBody6", - equipmentSlingshotBody.changedCvar, 130, gsDPSetEnvColor(MAX(color.r - 100, 0) / 3, MAX(color.g - 100, 0) / 3, - MAX(color.b - 100, 0) / 3, 255)); PATCH_GFX(gLinkChildRightArmStretchedSlingshotDL, "Equipment_SlingshotBody7", + equipmentSlingshotBody.changedCvar, 128, gsDPSetPrimColor(0, 0, std::max(color.r - 100, 0), + std::max(color.g - 100, 0), std::max(color.b - 100, 0), 255)); PATCH_GFX(gGiSlingshotDL, "Equipment_SlingshotBody6", + equipmentSlingshotBody.changedCvar, 130, gsDPSetEnvColor(std::max(color.r - 100, 0) / 3, + std::max(color.g - 100, 0) / 3, std::max(color.b - 100, 0) / 3, 255)); + PATCH_GFX(gLinkChildRightArmStretchedSlingshotDL, "Equipment_SlingshotBody7", equipmentSlingshotBody.changedCvar, 4, gsDPSetGrayscaleColor(color.r, color.g, color.b, 255)); PATCH_GFX(gLinkChildRightHandHoldingSlingshotNearDL, "Equipment_SlingshotBody8", equipmentSlingshotBody.changedCvar, 4, gsDPSetGrayscaleColor(color.r, color.g, color.b, 255)); @@ -1267,9 +1266,9 @@ void ApplyOrResetCustomGfxPatches(bool manualChange) { gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); PATCH_GFX(gGiGreenRupeeInnerColorDL, "Consumable_GreenRupee2", consumableGreenRupee.changedCvar, 4, gsDPSetEnvColor(color.r / 5, color.g / 5, color.b / 5, 255)); - PATCH_GFX( - gGiGreenRupeeOuterColorDL, "Consumable_GreenRupee3", consumableGreenRupee.changedCvar, 3, - gsDPSetPrimColor(0, 0, MIN(color.r + 100, 255), MIN(color.g + 100, 255), MIN(color.b + 100, 255), 255)); + PATCH_GFX(gGiGreenRupeeOuterColorDL, "Consumable_GreenRupee3", consumableGreenRupee.changedCvar, 3, + gsDPSetPrimColor(0, 0, std::min(color.r + 100, 255), std::min(color.g + 100, 255), + std::min(color.b + 100, 255), 255)); PATCH_GFX(gGiGreenRupeeOuterColorDL, "Consumable_GreenRupee4", consumableGreenRupee.changedCvar, 4, gsDPSetEnvColor(color.r * 0.75f, color.g * 0.75f, color.b * 0.75f, 255)); @@ -1293,9 +1292,9 @@ void ApplyOrResetCustomGfxPatches(bool manualChange) { gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); PATCH_GFX(gGiBlueRupeeInnerColorDL, "Consumable_BlueRupee2", consumableBlueRupee.changedCvar, 4, gsDPSetEnvColor(color.r / 5, color.g / 5, color.b / 5, 255)); - PATCH_GFX( - gGiBlueRupeeOuterColorDL, "Consumable_BlueRupee3", consumableBlueRupee.changedCvar, 3, - gsDPSetPrimColor(0, 0, MIN(color.r + 100, 255), MIN(color.g + 100, 255), MIN(color.b + 100, 255), 255)); + PATCH_GFX(gGiBlueRupeeOuterColorDL, "Consumable_BlueRupee3", consumableBlueRupee.changedCvar, 3, + gsDPSetPrimColor(0, 0, std::min(color.r + 100, 255), std::min(color.g + 100, 255), + std::min(color.b + 100, 255), 255)); PATCH_GFX(gGiBlueRupeeOuterColorDL, "Consumable_BlueRupee4", consumableBlueRupee.changedCvar, 4, gsDPSetEnvColor(color.r * 0.75f, color.g * 0.75f, color.b * 0.75f, 255)); } @@ -1306,9 +1305,9 @@ void ApplyOrResetCustomGfxPatches(bool manualChange) { gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); PATCH_GFX(gGiRedRupeeInnerColorDL, "Consumable_RedRupee2", consumableRedRupee.changedCvar, 4, gsDPSetEnvColor(color.r / 5, color.g / 5, color.b / 5, 255)); - PATCH_GFX( - gGiRedRupeeOuterColorDL, "Consumable_RedRupee3", consumableRedRupee.changedCvar, 3, - gsDPSetPrimColor(0, 0, MIN(color.r + 100, 255), MIN(color.g + 100, 255), MIN(color.b + 100, 255), 255)); + PATCH_GFX(gGiRedRupeeOuterColorDL, "Consumable_RedRupee3", consumableRedRupee.changedCvar, 3, + gsDPSetPrimColor(0, 0, std::min(color.r + 100, 255), std::min(color.g + 100, 255), + std::min(color.b + 100, 255), 255)); PATCH_GFX(gGiRedRupeeOuterColorDL, "Consumable_RedRupee4", consumableRedRupee.changedCvar, 4, gsDPSetEnvColor(color.r * 0.75f, color.g * 0.75f, color.b * 0.75f, 255)); } @@ -1319,9 +1318,9 @@ void ApplyOrResetCustomGfxPatches(bool manualChange) { gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); PATCH_GFX(gGiPurpleRupeeInnerColorDL, "Consumable_PurpleRupee2", consumablePurpleRupee.changedCvar, 4, gsDPSetEnvColor(color.r / 5, color.g / 5, color.b / 5, 255)); - PATCH_GFX( - gGiPurpleRupeeOuterColorDL, "Consumable_PurpleRupee3", consumablePurpleRupee.changedCvar, 3, - gsDPSetPrimColor(0, 0, MIN(color.r + 100, 255), MIN(color.g + 100, 255), MIN(color.b + 100, 255), 255)); + PATCH_GFX(gGiPurpleRupeeOuterColorDL, "Consumable_PurpleRupee3", consumablePurpleRupee.changedCvar, 3, + gsDPSetPrimColor(0, 0, std::min(color.r + 100, 255), std::min(color.g + 100, 255), + std::min(color.b + 100, 255), 255)); PATCH_GFX(gGiPurpleRupeeOuterColorDL, "Consumable_PurpleRupee4", consumablePurpleRupee.changedCvar, 4, gsDPSetEnvColor(color.r * 0.75f, color.g * 0.75f, color.b * 0.75f, 255)); } @@ -1332,9 +1331,9 @@ void ApplyOrResetCustomGfxPatches(bool manualChange) { gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); PATCH_GFX(gGiGoldRupeeInnerColorDL, "Consumable_GoldRupee2", consumableGoldRupee.changedCvar, 4, gsDPSetEnvColor(color.r / 5, color.g / 5, color.b / 5, 255)); - PATCH_GFX( - gGiGoldRupeeOuterColorDL, "Consumable_GoldRupee3", consumableGoldRupee.changedCvar, 3, - gsDPSetPrimColor(0, 0, MIN(color.r + 100, 255), MIN(color.g + 100, 255), MIN(color.b + 100, 255), 255)); + PATCH_GFX(gGiGoldRupeeOuterColorDL, "Consumable_GoldRupee3", consumableGoldRupee.changedCvar, 3, + gsDPSetPrimColor(0, 0, std::min(color.r + 100, 255), std::min(color.g + 100, 255), + std::min(color.b + 100, 255), 255)); PATCH_GFX(gGiGoldRupeeOuterColorDL, "Consumable_GoldRupee4", consumableGoldRupee.changedCvar, 4, gsDPSetEnvColor(color.r * 0.75f, color.g * 0.75f, color.b * 0.75f, 255)); } @@ -2016,17 +2015,13 @@ void DrawSillyTab() { // allows you create and use multiple shades of the same color. void CopyMultipliedColor(CosmeticOption& cosmeticOptionSrc, CosmeticOption& cosmeticOptionTarget, float amount = 0.75f) { + Color_RGBA8 srcColor = CVarGetColor(cosmeticOptionSrc.valuesCvar, cosmeticOptionSrc.defaultColor); Color_RGBA8 newColor; - newColor.r = static_cast(MIN((cosmeticOptionSrc.currentColor.x * 255.0f) * amount, 255)); - newColor.g = static_cast(MIN((cosmeticOptionSrc.currentColor.y * 255.0f) * amount, 255)); - newColor.b = static_cast(MIN((cosmeticOptionSrc.currentColor.z * 255.0f) * amount, 255)); + newColor.r = static_cast(std::min(srcColor.r * amount, 255.0f)); + newColor.g = static_cast(std::min(srcColor.g * amount, 255.0f)); + newColor.b = static_cast(std::min(srcColor.b * amount, 255.0f)); newColor.a = 255; - cosmeticOptionTarget.currentColor.x = newColor.r / 255.0f; - cosmeticOptionTarget.currentColor.y = newColor.g / 255.0f; - cosmeticOptionTarget.currentColor.z = newColor.b / 255.0f; - cosmeticOptionTarget.currentColor.w = newColor.a / 255.0f; - CVarSetColor(cosmeticOptionTarget.valuesCvar, newColor); CVarSetInteger((cosmeticOptionTarget.rainbowCvar), 0); CVarSetInteger((cosmeticOptionTarget.changedCvar), 1); @@ -2052,7 +2047,6 @@ void ApplySideEffects(CosmeticOption& cosmeticOption) { if (cosmeticOption.label == "Bow Body") { CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Equipment.BowTips"), 0.5f); CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Equipment.BowHandle"), 1.0f); - CopyMultipliedColor(cosmeticOption, cosmeticOption, 4.0f); } else if (cosmeticOption.label == "Idle Primary") { CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Navi.IdleSecondary"), 0.5f); } else if (cosmeticOption.label == "Enemy Primary") { @@ -2099,14 +2093,9 @@ void RandomizeColor(CosmeticOption& cosmeticOption, bool manual = true) { newColor.a = 255; // For alpha supported options, retain the last set alpha instead of overwriting if (cosmeticOption.supportsAlpha) { - newColor.a = static_cast(cosmeticOption.currentColor.w * 255.0f); + newColor.a = CVarGetColor(cosmeticOption.valuesCvar, cosmeticOption.defaultColor).a; } - cosmeticOption.currentColor.x = newColor.r / 255.0f; - cosmeticOption.currentColor.y = newColor.g / 255.0f; - cosmeticOption.currentColor.z = newColor.b / 255.0f; - cosmeticOption.currentColor.w = newColor.a / 255.0f; - CVarSetColor(cosmeticOption.valuesCvar, newColor); CVarSetInteger(cosmeticOption.rainbowCvar, 0); CVarSetInteger(cosmeticOption.changedCvar, 1); @@ -2206,87 +2195,71 @@ void CosmeticsEditorWindow::ApplyDungeonKeyColors() { // Forest Temple CVarSetColor(cosmeticOptions["Key.ForestSmallBody"].valuesCvar, { 4, 195, 46, 255 }); CVarSetInteger(cosmeticOptions["Key.ForestSmallBody"].changedCvar, 1); - cosmeticOptions["Key.ForestSmallBody"].currentColor = { 4 / 255.0f, 195 / 255.0f, 46 / 255.0f, 255 / 255.0f }; ResetColor(cosmeticOptions.at("Key.ForestSmallEmblem")); ResetColor(cosmeticOptions.at("Key.ForestBossBody")); CVarSetColor(cosmeticOptions["Key.ForestBossGem"].valuesCvar, { 0, 255, 0, 255 }); CVarSetInteger(cosmeticOptions["Key.ForestBossGem"].changedCvar, 1); - cosmeticOptions["Key.ForestBossGem"].currentColor = { 0, 255 / 255.0f, 0, 255 / 255.0f }; // Fire Temple CVarSetColor(cosmeticOptions["Key.FireSmallBody"].valuesCvar, { 237, 95, 95, 255 }); CVarSetInteger(cosmeticOptions["Key.FireSmallBody"].changedCvar, 1); - cosmeticOptions["Key.FireSmallBody"].currentColor = { 237 / 255.0f, 95 / 255.0f, 95 / 255.0f, 255 / 255.0f }; ResetColor(cosmeticOptions.at("Key.FireSmallEmblem")); ResetColor(cosmeticOptions.at("Key.FireBossBody")); CVarSetColor(cosmeticOptions["Key.FireBossGem"].valuesCvar, { 255, 30, 0, 255 }); CVarSetInteger(cosmeticOptions["Key.FireBossGem"].changedCvar, 1); - cosmeticOptions["Key.FireBossGem"].currentColor = { 255 / 255.0f, 30 / 255.0f, 0, 255 / 255.0f }; // Water Temple CVarSetColor(cosmeticOptions["Key.WaterSmallBody"].valuesCvar, { 85, 180, 223, 255 }); CVarSetInteger(cosmeticOptions["Key.WaterSmallBody"].changedCvar, 1); - cosmeticOptions["Key.WaterSmallBody"].currentColor = { 85 / 255.0f, 180 / 255.0f, 223 / 255.0f, 255 / 255.0f }; ResetColor(cosmeticOptions.at("Key.WaterSmallEmblem")); ResetColor(cosmeticOptions.at("Key.WaterBossBody")); CVarSetColor(cosmeticOptions["Key.WaterBossGem"].valuesCvar, { 0, 137, 255, 255 }); CVarSetInteger(cosmeticOptions["Key.WaterBossGem"].changedCvar, 1); - cosmeticOptions["Key.WaterBossGem"].currentColor = { 0, 137 / 255.0f, 255 / 255.0f, 255 / 255.0f }; // Spirit Temple CVarSetColor(cosmeticOptions["Key.SpiritSmallBody"].valuesCvar, { 222, 158, 47, 255 }); CVarSetInteger(cosmeticOptions["Key.SpiritSmallBody"].changedCvar, 1); - cosmeticOptions["Key.SpiritSmallBody"].currentColor = { 222 / 255.0f, 158 / 255.0f, 47 / 255.0f, 255 / 255.0f }; ResetColor(cosmeticOptions.at("Key.SpiritSmallEmblem")); ResetColor(cosmeticOptions.at("Key.SpiritBossBody")); CVarSetColor(cosmeticOptions["Key.SpiritBossGem"].valuesCvar, { 255, 85, 0, 255 }); CVarSetInteger(cosmeticOptions["Key.SpiritBossGem"].changedCvar, 1); - cosmeticOptions["Key.SpiritBossGem"].currentColor = { 255 / 255.0f, 85 / 255.0f, 0, 255 / 255.0f }; // Shadow Temple CVarSetColor(cosmeticOptions["Key.ShadowSmallBody"].valuesCvar, { 126, 16, 177, 255 }); CVarSetInteger(cosmeticOptions["Key.ShadowSmallBody"].changedCvar, 1); - cosmeticOptions["Key.ShadowSmallBody"].currentColor = { 126 / 255.0f, 16 / 255.0f, 177 / 255.0f, 255 / 255.0f }; ResetColor(cosmeticOptions.at("Key.ShadowSmallEmblem")); ResetColor(cosmeticOptions.at("Key.ShadowBossBody")); CVarSetColor(cosmeticOptions["Key.ShadowBossGem"].valuesCvar, { 153, 0, 255, 255 }); CVarSetInteger(cosmeticOptions["Key.ShadowBossGem"].changedCvar, 1); - cosmeticOptions["Key.ShadowBossGem"].currentColor = { 153 / 255.0f, 0, 255 / 255.0f, 255 / 255.0f }; // Ganon's Tower CVarSetColor(cosmeticOptions["Key.GanonsSmallBody"].valuesCvar, { 80, 80, 80, 255 }); CVarSetInteger(cosmeticOptions["Key.GanonsSmallBody"].changedCvar, 1); - cosmeticOptions["Key.GanonsSmallBody"].currentColor = { 80 / 255.0f, 80 / 255.0f, 80 / 255.0f, 255 / 255.0f }; ResetColor(cosmeticOptions.at("Key.GanonsSmallEmblem")); CVarSetColor(cosmeticOptions["Key.GanonsBossBody"].valuesCvar, { 80, 80, 80, 255 }); CVarSetInteger(cosmeticOptions["Key.GanonsBossBody"].changedCvar, 1); - cosmeticOptions["Key.GanonsBossBody"].currentColor = { 80 / 255.0f, 80 / 255.0f, 80 / 255.0f, 255 / 255.0f }; CVarSetColor(cosmeticOptions["Key.GanonsBossGem"].valuesCvar, { 255, 0, 0, 255 }); CVarSetInteger(cosmeticOptions["Key.GanonsBossGem"].changedCvar, 1); - cosmeticOptions["Key.GanonsBossGem"].currentColor = { 255 / 255.0f, 0, 0, 255 / 255.0f }; // Bottom of the Well CVarSetColor(cosmeticOptions["Key.WellSmallBody"].valuesCvar, { 227, 110, 255, 255 }); CVarSetInteger(cosmeticOptions["Key.WellSmallBody"].changedCvar, 1); - cosmeticOptions["Key.WellSmallBody"].currentColor = { 227 / 255.0f, 110 / 255.0f, 255 / 255.0f, 255 / 255.0f }; ResetColor(cosmeticOptions.at("Key.WellSmallEmblem")); // Gerudo Training Ground CVarSetColor(cosmeticOptions["Key.GTGSmallBody"].valuesCvar, { 221, 212, 60, 255 }); CVarSetInteger(cosmeticOptions["Key.GTGSmallBody"].changedCvar, 1); - cosmeticOptions["Key.GTGSmallBody"].currentColor = { 221 / 255.0f, 212 / 255.0f, 60 / 255.0f, 255 / 255.0f }; ResetColor(cosmeticOptions.at("Key.GTGSmallEmblem")); // Gerudo Fortress CVarSetColor(cosmeticOptions["Key.FortSmallBody"].valuesCvar, { 255, 255, 255, 255 }); CVarSetInteger(cosmeticOptions["Key.FortSmallBody"].changedCvar, 1); - cosmeticOptions["Key.FortSmallBody"].currentColor = { 255 / 255.0f, 255 / 255.0f, 255 / 255.0f, 255 / 255.0f }; ResetColor(cosmeticOptions.at("Key.FortSmallEmblem")); } @@ -2522,17 +2495,6 @@ void RegisterOnGameFrameUpdateHook() { } void CosmeticsEditorWindow::InitElement() { - // Convert the `current color` into the format that the ImGui color picker expects - for (auto& [id, cosmeticOption] : cosmeticOptions) { - Color_RGBA8 defaultColor = { cosmeticOption.defaultColor.r, cosmeticOption.defaultColor.g, - cosmeticOption.defaultColor.b, cosmeticOption.defaultColor.a }; - Color_RGBA8 cvarColor = CVarGetColor(cosmeticOption.valuesCvar, defaultColor); - - cosmeticOption.currentColor.x = cvarColor.r / 255.0f; - cosmeticOption.currentColor.y = cvarColor.g / 255.0f; - cosmeticOption.currentColor.z = cvarColor.b / 255.0f; - cosmeticOption.currentColor.w = cvarColor.a / 255.0f; - } Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ScanCustomCosmetics(); ApplyOrResetCustomGfxPatches(); diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.h b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.h index 3a4e74bb2c..8219b18f3b 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.h +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.h @@ -45,10 +45,8 @@ Color_RGBA8 CosmeticsEditor_GetDefaultValue(const char* id); { \ id, { \ CVAR_COSMETIC(id), CVAR_COSMETIC(id ".Value"), CVAR_COSMETIC(id ".Rainbow"), CVAR_COSMETIC(id ".Locked"), \ - CVAR_COSMETIC(id ".Changed"), label, group, \ - ImVec4(defaultColor.r / 255.0f, defaultColor.g / 255.0f, defaultColor.b / 255.0f, \ - defaultColor.a / 255.0f), \ - defaultColor, supportsAlpha, supportsRainbow, advancedOption \ + CVAR_COSMETIC(id ".Changed"), label, group, defaultColor, supportsAlpha, supportsRainbow, \ + advancedOption \ } \ } @@ -60,7 +58,6 @@ typedef struct { const char* changedCvar; std::string label; CosmeticGroup group; - ImVec4 currentColor; Color_RGBA8 defaultColor; bool supportsAlpha; bool supportsRainbow; @@ -70,13 +67,6 @@ typedef struct { extern std::map cosmeticOptions; inline void ResetColor(CosmeticOption& cosmeticOption) { - Color_RGBA8 defaultColor = { cosmeticOption.defaultColor.r, cosmeticOption.defaultColor.g, - cosmeticOption.defaultColor.b, cosmeticOption.defaultColor.a }; - cosmeticOption.currentColor.x = defaultColor.r / 255.0f; - cosmeticOption.currentColor.y = defaultColor.g / 255.0f; - cosmeticOption.currentColor.z = defaultColor.b / 255.0f; - cosmeticOption.currentColor.w = defaultColor.a / 255.0f; - CVarClear(cosmeticOption.changedCvar); CVarClear(cosmeticOption.rainbowCvar); CVarClear(cosmeticOption.lockedCvar); @@ -134,19 +124,8 @@ inline CosmeticOption MakeCosmeticOption(const char* cvar, const char* valuesCva const char* lockedCvar, const char* changedCvar, const char* label, CosmeticGroup group, Color_RGBA8 defaultColor, bool supportsAlpha, bool supportsRainbow, bool advancedOption) { - return CosmeticOption{ cvar, - valuesCvar, - rainbowCvar, - lockedCvar, - changedCvar, - label, - group, - ImVec4(defaultColor.r / 255.0f, defaultColor.g / 255.0f, defaultColor.b / 255.0f, - defaultColor.a / 255.0f), - defaultColor, - supportsAlpha, - supportsRainbow, - advancedOption }; + return CosmeticOption{ cvar, valuesCvar, rainbowCvar, lockedCvar, changedCvar, label, + group, defaultColor, supportsAlpha, supportsRainbow, advancedOption }; } typedef struct { diff --git a/soh/soh/Enhancements/randomizer/Messages/MerchantMessages.cpp b/soh/soh/Enhancements/randomizer/Messages/MerchantMessages.cpp index abefcd6021..70829f2330 100644 --- a/soh/soh/Enhancements/randomizer/Messages/MerchantMessages.cpp +++ b/soh/soh/Enhancements/randomizer/Messages/MerchantMessages.cpp @@ -11,6 +11,7 @@ #include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/ObjectExtension/ObjectExtension.h" #include "soh/Enhancements/randomizer/randomizer.h" +#include "soh/Enhancements/custom-message/CustomMessageTypes.h" extern "C" { #include diff --git a/soh/soh/Enhancements/randomizer/Messages/Miscellaneous.cpp b/soh/soh/Enhancements/randomizer/Messages/Miscellaneous.cpp index 1dc3ac80b7..bc874da881 100644 --- a/soh/soh/Enhancements/randomizer/Messages/Miscellaneous.cpp +++ b/soh/soh/Enhancements/randomizer/Messages/Miscellaneous.cpp @@ -7,6 +7,7 @@ #include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/randomizer/randomizer.h" +#include "soh/Enhancements/custom-message/CustomMessageTypes.h" extern "C" { #include diff --git a/soh/soh/Enhancements/randomizer/ShuffleBeggar.cpp b/soh/soh/Enhancements/randomizer/ShuffleBeggar.cpp index 78af322a3a..c17ac45eb2 100644 --- a/soh/soh/Enhancements/randomizer/ShuffleBeggar.cpp +++ b/soh/soh/Enhancements/randomizer/ShuffleBeggar.cpp @@ -1,6 +1,7 @@ #include #include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/randomizer/randomizer.h" +#include "soh/Enhancements/custom-message/CustomMessageTypes.h" #include "soh/Enhancements/randomizer/RCToRandInf.h" extern "C" { diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index 405fa1cf3b..e27452a274 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -8,7 +8,6 @@ #include #include #include "soh/Enhancements/item-tables/ItemTableTypes.h" -#include "../custom-message/CustomMessageTypes.h" #define MAX_SEED_STRING_SIZE 1024 diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index e58cd15a08..747066fd4a 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -25,6 +25,7 @@ #include "3drando/fill.hpp" #include "soh/Enhancements/debugger/performanceTimer.h" #include "soh/Enhancements/randomizer/randomizer.h" +#include "soh/Enhancements/custom-message/CustomMessageTypes.h" #include "soh/ObjectExtension/ObjectExtension.h" #include "location.h" #include "item_location.h" diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 08e4ce650b..986b9fd157 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -603,7 +603,7 @@ ItemTrackerNumbers GetItemCurrentAndMax(ItemTrackerItem item) { case ITEM_KEY_SMALL: // Though the ammo/capacity naming doesn't really make sense for keys, we are // hijacking the same system to display key counts as there are enough similarities - result.currentAmmo = MAX(gSaveContext.inventory.dungeonKeys[item.data], 0); + result.currentAmmo = std::max(gSaveContext.inventory.dungeonKeys[item.data], (s8)0); result.currentCapacity = Rando::GetSceneTotalSmallKeys(&gSaveContext, (SceneID)item.data); result.maxCapacity = Rando::GetSceneSmallKeyMax((SceneID)item.data); if (item.data == SCENE_FIRE_TEMPLE && IS_RANDO && @@ -1441,7 +1441,7 @@ std::vector GetDungeonItemsVector(std::vector i) { switch (dungeons[j].items[i]) { case ITEM_KEY_SMALL: diff --git a/soh/soh/Enhancements/savestates.cpp b/soh/soh/Enhancements/savestates.cpp index d099d3453a..7ff4062511 100644 --- a/soh/soh/Enhancements/savestates.cpp +++ b/soh/soh/Enhancements/savestates.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -342,7 +343,7 @@ void SaveState::SaveTransitionActors(void) { } void SaveState::LoadTransitionActors(void) { - u32 numActors = MIN(info->transitionActorCount_copy, gPlayState->transiActorCtx.numActors); + u32 numActors = std::min(info->transitionActorCount_copy, gPlayState->transiActorCtx.numActors); for (u32 i = 0; i < numActors; i++) { gPlayState->transiActorCtx.list[i].id = info->transitionActorIds_copy[i]; } diff --git a/soh/soh/Network/Anchor/Packets/UpdateTeamState.cpp b/soh/soh/Network/Anchor/Packets/UpdateTeamState.cpp index b05ab6f021..fb8331903c 100644 --- a/soh/soh/Network/Anchor/Packets/UpdateTeamState.cpp +++ b/soh/soh/Network/Anchor/Packets/UpdateTeamState.cpp @@ -6,6 +6,7 @@ #include "soh/Enhancements/randomizer/randomizer.h" extern "C" { +#include "macros.h" #include "variables.h" extern PlayState* gPlayState; } diff --git a/soh/soh/ShipUtils.cpp b/soh/soh/ShipUtils.cpp index ef6a1358f5..e85956045d 100644 --- a/soh/soh/ShipUtils.cpp +++ b/soh/soh/ShipUtils.cpp @@ -1,4 +1,5 @@ #include "ShipUtils.h" +#include #include #include #include "soh_assets.h" @@ -19,15 +20,14 @@ constexpr f32 fourByThree = 4.0f / 3.0f; // Gets the additional ratio of the screen compared to the original 4:3 ratio, clamping to 1 if smaller extern "C" f32 Ship_GetExtendedAspectRatioMultiplier() { f32 currentRatio = OTRGetAspectRatio(); - return MAX(currentRatio / fourByThree, 1.0f); + return std::max(currentRatio / fourByThree, 1.0f); } // Enables Extended Culling options on specific actors by applying an inverse ratio of the draw distance slider // to the projected Z value of the actor. This tricks distance checks without having to replace hardcoded values. // Requires that Ship_ExtendedCullingActorRestoreProjectedPos is called within the same function scope. extern "C" void Ship_ExtendedCullingActorAdjustProjectedZ(Actor* actor) { - s32 multiplier = CVarGetInteger("gEnhancements.Graphics.IncreaseActorDrawDistance", 1); - multiplier = MAX(multiplier, 1); + s32 multiplier = std::max(CVarGetInteger("gEnhancements.Graphics.IncreaseActorDrawDistance", 1), 1); if (multiplier > 1) { actor->projectedPos.z /= multiplier; }