From 087b7e7abfe81dd7f0fdcdea36ac9f245950df1a Mon Sep 17 00:00:00 2001 From: Loki Rautio Date: Sat, 7 Mar 2026 21:12:22 -0600 Subject: Revert "Project modernization (#630)" This code was not tested and breaks in Release builds, reverting to restore functionality of the nightly. All in-game menus do not work and generating a world crashes. This reverts commit a9be52c41a02d207233199e98898fe7483d7e817. --- Minecraft.World/PotionBrewing.cpp | 50 +++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'Minecraft.World/PotionBrewing.cpp') diff --git a/Minecraft.World/PotionBrewing.cpp b/Minecraft.World/PotionBrewing.cpp index bc5fd8c7..8e27a601 100644 --- a/Minecraft.World/PotionBrewing.cpp +++ b/Minecraft.World/PotionBrewing.cpp @@ -186,7 +186,7 @@ int PotionBrewing::getColorValue(vector *effects) int baseColor = colourTable->getColor( eMinecraftColour_Potion_BaseColour ); - if (effects == nullptr || effects->empty()) + if (effects == NULL || effects->empty()) { return baseColor; } @@ -203,9 +203,9 @@ int PotionBrewing::getColorValue(vector *effects) for (int potency = 0; potency <= effect->getAmplifier(); potency++) { - red += static_cast((potionColor >> 16) & 0xff) / 255.0f; - green += static_cast((potionColor >> 8) & 0xff) / 255.0f; - blue += static_cast((potionColor >> 0) & 0xff) / 255.0f; + red += (float) ((potionColor >> 16) & 0xff) / 255.0f; + green += (float) ((potionColor >> 8) & 0xff) / 255.0f; + blue += (float) ((potionColor >> 0) & 0xff) / 255.0f; count++; } } @@ -214,7 +214,7 @@ int PotionBrewing::getColorValue(vector *effects) green = (green / count) * 255.0f; blue = (blue / count) * 255.0f; - return static_cast(red) << 16 | static_cast(green) << 8 | static_cast(blue); + return ((int) red) << 16 | ((int) green) << 8 | ((int) blue); } bool PotionBrewing::areAllEffectsAmbient(vector *effects) @@ -238,7 +238,7 @@ int PotionBrewing::getColorValue(int brew, bool includeDisabledEffects) } vector *effects = getEffects(brew, false); int color = getColorValue(effects); - if(effects != nullptr) + if(effects != NULL) { for(auto& effect : *effects) { @@ -325,16 +325,16 @@ int PotionBrewing::parseEffectFormulaValue(const wstring &definition, int start, } // split by and - size_t andIndex = definition.find_first_of(L'&', start); - if (andIndex != wstring::npos && andIndex < static_cast(end)) + int andIndex = (int)definition.find_first_of(L'&', start); + if (andIndex >= 0 && andIndex < end) { - int leftSide = parseEffectFormulaValue(definition, start, static_cast(andIndex) - 1, brew); + int leftSide = parseEffectFormulaValue(definition, start, andIndex - 1, brew); if (leftSide <= 0) { return 0; } - int rightSide = parseEffectFormulaValue(definition, static_cast(andIndex) + 1, end, brew); + int rightSide = parseEffectFormulaValue(definition, andIndex + 1, end, brew); if (rightSide <= 0) { return 0; @@ -413,16 +413,16 @@ int PotionBrewing::parseEffectFormulaValue(const wstring &definition, int start, } // split by or - size_t orIndex = definition.find_first_of(L'|', start); - if (orIndex != wstring::npos && orIndex < static_cast(end)) + int orIndex = definition.find_first_of(L'|', start); + if (orIndex >= 0 && orIndex < end) { - int leftSide = parseEffectFormulaValue(definition, start, static_cast(orIndex) - 1, brew); + int leftSide = parseEffectFormulaValue(definition, start, orIndex - 1, brew); if (leftSide > 0) { return leftSide; } - int rightSide = parseEffectFormulaValue(definition, static_cast(orIndex) + 1, end, brew); + int rightSide = parseEffectFormulaValue(definition, orIndex + 1, end, brew); if (rightSide > 0) { return rightSide; @@ -430,10 +430,10 @@ int PotionBrewing::parseEffectFormulaValue(const wstring &definition, int start, return 0; } // split by and - size_t andIndex = definition.find_first_of(L'&', start); - if (andIndex != wstring::npos && andIndex < static_cast(end)) + int andIndex = definition.find_first_of(L'&', start); + if (andIndex >= 0 && andIndex < end) { - int leftSide = parseEffectFormulaValue(definition, start, static_cast(andIndex) - 1, brew); + int leftSide = parseEffectFormulaValue(definition, start, andIndex - 1, brew); if (leftSide <= 0) { return 0; @@ -552,13 +552,13 @@ int PotionBrewing::parseEffectFormulaValue(const wstring &definition, int start, vector *PotionBrewing::getEffects(int brew, bool includeDisabledEffects) { - vector *list = nullptr; + vector *list = NULL; //for (MobEffect effect : MobEffect.effects) for(unsigned int i = 0; i < MobEffect::NUM_EFFECTS; ++i) { MobEffect *effect = MobEffect::effects[i]; - if (effect == nullptr || (effect->isDisabled() && !includeDisabledEffects)) + if (effect == NULL || (effect->isDisabled() && !includeDisabledEffects)) { continue; } @@ -570,7 +570,7 @@ vector *PotionBrewing::getEffects(int brew, bool includeDis } wstring durationString = effIt->second; - int duration = parseEffectFormulaValue(durationString, 0, static_cast(durationString.length()), brew); + int duration = parseEffectFormulaValue(durationString, 0, (int)durationString.length(), brew); if (duration > 0) { int amplifier = 0; @@ -578,7 +578,7 @@ vector *PotionBrewing::getEffects(int brew, bool includeDis if (ampIt != potionEffectAmplifier.end()) { wstring amplifierString = ampIt->second; - amplifier = parseEffectFormulaValue(amplifierString, 0, static_cast(amplifierString.length()), brew); + amplifier = parseEffectFormulaValue(amplifierString, 0, (int)amplifierString.length(), brew); if (amplifier < 0) { amplifier = 0; @@ -594,15 +594,15 @@ vector *PotionBrewing::getEffects(int brew, bool includeDis // 3, 8, 13, 18.. minutes duration = (SharedConstants::TICKS_PER_SECOND * 60) * (duration * 3 + (duration - 1) * 2); duration >>= amplifier; - duration = static_cast(Math::round((double)duration * effect->getDurationModifier())); + duration = (int) Math::round((double) duration * effect->getDurationModifier()); if ((brew & THROWABLE_MASK) != 0) { - duration = static_cast(Math::round((double)duration * .75 + .5)); + duration = (int) Math::round((double) duration * .75 + .5); } } - if (list == nullptr) + if (list == NULL) { list = new vector(); } @@ -756,7 +756,7 @@ int PotionBrewing::applyBrew(int currentBrew, const wstring &formula) { int start = 0; - int end = static_cast(formula.length()); + int end = (int)formula.length(); bool hasValue = false; bool isNot = false; -- cgit v1.2.3