From 0fbb07da5349818cebfc38f43f36c7a6bd13cff2 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Mon, 9 Nov 2026 20:42:50 +0000 Subject: [PATCH] Confirm fn_19947 (CEffectPrim::PrimDriftingSparks) Batch #15302 by Yommy: 0 byte-identical, 1 confirmed by peer review. - fn_19947 CEffectPrim::PrimDriftingSparks: logic confirmed by peer review (already on main) Peer-reviewed-by: ragnarok-clanker, gordaoprogramas, Toshiro Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- .../Effects/EffectPrimitiveMotion.cpp | 90 ++++++++++--------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/Source/Contents/Effects/EffectPrimitiveMotion.cpp b/Source/Contents/Effects/EffectPrimitiveMotion.cpp index 9523a7fd8..7f4f27252 100644 --- a/Source/Contents/Effects/EffectPrimitiveMotion.cpp +++ b/Source/Contents/Effects/EffectPrimitiveMotion.cpp @@ -38,6 +38,14 @@ #include namespace { + // INLINED + vector3d& operator+=(vector3d& target, const vector3d& offset) { + target.x += offset.x; + target.y += offset.y; + target.z += offset.z; + return target; + } + // INLINED __forceinline int ClampedRandom(int range) { const int value = rand() % range; @@ -4363,6 +4371,47 @@ bool CEffectPrim::PrimWind() { return true; } +namespace { + // INLINED + __forceinline int SafeRandom(int range) { + if (range == 0) { + return 0; + } + + return ClampedRandom(range); + } + + // INLINED + __forceinline void DriftSlotAngles(EffectPrimitiveSlot& slot, int count, float rise = 1.0f, float fall = 1.0f) { + for (int axis = 0; axis < count * 2; axis += 2) { + float& angle = slot.height[axis]; + float& target = slot.height[axis + 1]; + + if (target > angle) { + angle += rise; + + if (angle > 359.0f) { + angle = 359.0f; + } + + if (angle > target) { + target = static_cast(SafeRandom(static_cast(angle))); + } + } else { + angle -= fall; + + if (angle < 0.0f) { + angle = 0.0f; + } + + if (angle <= target) { + target = static_cast(359 - SafeRandom(static_cast(angle))); + } + } + } + } +} + // OFFSET: 0x00BC5580 // FUNCTION: fn_19848 bool CEffectPrim::PrimDriftingSquares() { @@ -7156,47 +7205,6 @@ void CEffectPrim::PrimSTIN3() { } } -namespace { - // INLINED - __forceinline int SafeRandom(int range) { - if (range == 0) { - return 0; - } - - return NonNegativeRandom(range); - } - - // INLINED - __forceinline void DriftSlotAngles(EffectPrimitiveSlot& slot, int count, float rise = 1.0f, float fall = 1.0f) { - for (int axis = 0; axis < count * 2; axis += 2) { - float& angle = slot.height[axis]; - float& target = slot.height[axis + 1]; - - if (target > angle) { - angle += rise; - - if (angle > 359.0f) { - angle = 359.0f; - } - - if (angle > target) { - target = static_cast(SafeRandom(static_cast(angle))); - } - } else { - angle -= fall; - - if (angle < 0.0f) { - angle = 0.0f; - } - - if (angle <= target) { - target = static_cast(359 - SafeRandom(static_cast(angle))); - } - } - } - } -} - // OFFSET: 0x00BE8CE0 // FUNCTION: fn_19947 bool CEffectPrim::PrimDriftingSparks() {