From 0ebf9c4eddb6611d94af71eb9253027b123b8ef8 Mon Sep 17 00:00:00 2001 From: "Leilani A." <168607226+kaleohanopahala@users.noreply.github.com> Date: Sat, 2 Nov 2024 05:26:57 -0300 Subject: [PATCH 1/3] Update condition.cpp --- src/creatures/combat/condition.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/creatures/combat/condition.cpp b/src/creatures/combat/condition.cpp index e49a6662991..da90b03f65a 100644 --- a/src/creatures/combat/condition.cpp +++ b/src/creatures/combat/condition.cpp @@ -2540,7 +2540,7 @@ void ConditionLight::addCondition(std::shared_ptr creature, const std: const auto &conditionLight = condition->static_self_cast(); lightInfo.level = conditionLight->lightInfo.level; lightInfo.color = conditionLight->lightInfo.color; - lightChangeInterval = ticks / lightInfo.level; + lightChangeInterval = ticks / std::max(1, lightInfo.level); internalLightTicks = 0; creature->setCreatureLight(lightInfo); g_game().changeLight(creature); @@ -2558,9 +2558,13 @@ bool ConditionLight::setParam(ConditionParam_t param, int32_t value) { } switch (param) { - case CONDITION_PARAM_LIGHT_LEVEL: - lightInfo.level = value; + case CONDITION_PARAM_LIGHT_LEVEL: { + if (value < 1) { + g_logger().warn("[ConditionLight::setParam] Trying to set invalid light value: '{}', defaulting to 1.", value); + } + lightInfo.level = std::max(1, static_cast(value)); return true; + } case CONDITION_PARAM_LIGHT_COLOR: lightInfo.color = value; From d557e48338abb9422b0682e4e7f47bbdda2b2fce Mon Sep 17 00:00:00 2001 From: "Leilani A." <168607226+kaleohanopahala@users.noreply.github.com> Date: Sat, 2 Nov 2024 05:27:09 -0300 Subject: [PATCH 2/3] Update condition.hpp --- src/creatures/combat/condition.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/creatures/combat/condition.hpp b/src/creatures/combat/condition.hpp index 1cc798624e3..50d072059a2 100644 --- a/src/creatures/combat/condition.hpp +++ b/src/creatures/combat/condition.hpp @@ -391,7 +391,7 @@ class ConditionLight final : public Condition { bool unserializeProp(ConditionAttr_t attr, PropStream &propStream) override; private: - LightInfo lightInfo; + LightInfo lightInfo { 1, 215 }; uint32_t internalLightTicks = 0; uint32_t lightChangeInterval = 0; }; From adfbcfa055c9a00e7028ed156e1bf29b06ec6451 Mon Sep 17 00:00:00 2001 From: "Leilani A." <168607226+kaleohanopahala@users.noreply.github.com> Date: Sat, 2 Nov 2024 05:53:37 -0300 Subject: [PATCH 3/3] try pass PPA.