Skip to content

Commit

Permalink
fix dash orbs, update changelog, minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
theyareonit committed Sep 16, 2024
1 parent b364054 commit 73425c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 9 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

typedef void (*wine_get_host_version)(const char **sysname, const char **release);

constexpr double smallestFloat = std::numeric_limits<float>::min();
constexpr double SMALLEST_FLOAT = std::numeric_limits<float>::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<struct InputEvent> inputQueueCopy;
std::queue<struct Step> stepQueue;
Expand Down Expand Up @@ -53,7 +53,7 @@ void updateInputQueueAndTime(int stepCount) {
return;
}
else {
nextInput = emptyInput;
nextInput = EMPTY_INPUT;
lastFrameTime = lastPhysicsFrameTime;
stepQueue = {}; // just in case

Expand Down Expand Up @@ -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<double>((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;
}
}
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 73425c9

Please sign in to comment.