From 73425c9dd352efe74903333d08d04ec778d954dd Mon Sep 17 00:00:00 2001 From: theyareonit Date: Mon, 16 Sep 2024 02:17:57 +0200 Subject: [PATCH] fix dash orbs, update changelog, minor refactor --- changelog.md | 3 ++- src/main.cpp | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index 1f018f5..88d97c8 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,8 @@ # v1.2.0 -* Potentially fix slope bugs +* Potentially reduce slope bugs * Potentially improve performance +* Fix CBF not working for dash orb releases * Fix keyboard input not working on Linux * Significantly improve input precision on Linux * Disable input when unfocused diff --git a/src/main.cpp b/src/main.cpp index baa4019..0e5dff2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,10 +18,10 @@ typedef void (*wine_get_host_version)(const char **sysname, const char **release); -constexpr double smallestFloat = std::numeric_limits::min(); +constexpr double SMALLEST_FLOAT = std::numeric_limits::min(); -const InputEvent emptyInput = InputEvent{ 0, 0, PlayerButton::Jump, 0, 0 }; -const Step emptyStep = Step{ emptyInput, 1.0, true }; +constexpr InputEvent EMPTY_INPUT = InputEvent{ 0, 0, PlayerButton::Jump, 0, 0 }; +constexpr Step EMPTY_STEP = Step{ EMPTY_INPUT, 1.0, true }; std::queue inputQueueCopy; std::queue stepQueue; @@ -53,7 +53,7 @@ void updateInputQueueAndTime(int stepCount) { return; } else { - nextInput = emptyInput; + nextInput = EMPTY_INPUT; lastFrameTime = lastPhysicsFrameTime; stepQueue = {}; // just in case @@ -100,14 +100,14 @@ void updateInputQueueAndTime(int stepCount) { front = inputQueueCopy.front(); if (front.time.QuadPart - lastFrameTime.QuadPart < stepDelta.QuadPart * (i + 1)) { double dFactor = static_cast((front.time.QuadPart - lastFrameTime.QuadPart) % stepDelta.QuadPart) / stepDelta.QuadPart; - stepQueue.emplace(Step{ front, std::clamp(dFactor - lastDFactor, smallestFloat, 1.0), false }); + stepQueue.emplace(Step{ front, std::clamp(dFactor - lastDFactor, SMALLEST_FLOAT, 1.0), false }); lastDFactor = dFactor; inputQueueCopy.pop(); continue; } } front = nextInput; - stepQueue.emplace(Step{ front, std::max(smallestFloat, 1.0 - lastDFactor), true }); + stepQueue.emplace(Step{ front, std::max(SMALLEST_FLOAT, 1.0 - lastDFactor), true }); break; } } @@ -117,7 +117,7 @@ void updateInputQueueAndTime(int stepCount) { Step updateDeltaFactorAndInput() { enableInput = false; - if (stepQueue.empty()) return emptyStep; + if (stepQueue.empty()) return EMPTY_STEP; Step front = stepQueue.front(); double deltaFactor = front.deltaFactor; @@ -272,10 +272,12 @@ class $modify(PlayerObject) { bool p1NotBuffering = p1StartedOnGround || this->m_touchingRings->count() + || this->m_isDashing || (this->m_isDart || this->m_isBird || this->m_isShip || this->m_isSwing); bool p2NotBuffering = p2StartedOnGround || p2->m_touchingRings->count() + || p2->m_isDashing || (p2->m_isDart || p2->m_isBird || p2->m_isShip || p2->m_isSwing); p1Pos = PlayerObject::getPosition();