From 6d7af26b6f7a69796b6ec0277c8ed369c4997b2d Mon Sep 17 00:00:00 2001 From: NyteLyte Date: Thu, 28 Nov 2024 18:47:14 +0100 Subject: [PATCH] fix cbf again --- changelog.md | 3 +++ mod.json | 2 +- src/main.cpp | 13 ++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index dd7ce9a..c64daf7 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +# v1.4.2 +- fix the doubling up points with Click Between Frames (again) + # v1.4.1 - fix teleport trigger + spider orb interaction - credit: hiimjustin000 for identifying the cause diff --git a/mod.json b/mod.json index 00bcc08..a797e9c 100644 --- a/mod.json +++ b/mod.json @@ -1,7 +1,7 @@ { "geode": "4.0.1", "gd": {"android": "2.2074", "win": "2.2074"}, - "version": "v1.4.1", + "version": "v1.4.2", "id": "nytelyte.wave_trail_drag_fix", "name": "Wave Trail Drag Fix", "developer": "NyteLyte", diff --git a/src/main.cpp b/src/main.cpp index b82a348..f8dc9a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,8 +33,18 @@ class $modify(WTDFPlayerObject, PlayerObject) { // slopes aren't stored in m_collidedObject for some reason GameObject* collidedSlope = nullptr; + // Click Between Frames messes with the delta factor when collision checking + // so we fetch it from PlayerObject::update and use that inside + // PlayerObject::postCollision instead of the one passed to it + float deltaFactor = 0; }; + static void onModify(auto& self) { + Result res = self.setHookPriorityAfter("PlayerObject::update", "syzzi.click_between_frames"); + if (!res && res != Err("Mod not found")) + log::error("Failed to set hook priority of PlayerObject::update."); + } + void resetObject() { WTDFPlayerObject::Fields defaultFields; *m_fields.operator->() = defaultFields; @@ -53,6 +63,7 @@ class $modify(WTDFPlayerObject, PlayerObject) { PlayerObject::update(deltaFactor); m_fields->nextPosNoCollision = getRealPosition(); m_fields->collidedSlope = nullptr; + m_fields->deltaFactor = deltaFactor; } void postCollision(float deltaFactor) { @@ -119,7 +130,7 @@ class $modify(WTDFPlayerObject, PlayerObject) { // make the error margin inversely proportional to the delta factor // if 2 updates are extremely close together calculating the angle between them may lead to inaccuracies - float errorMargin = 0.004/deltaFactor; + float errorMargin = 0.004/m_fields->deltaFactor; // save the current point as prevPoint only if it is placed as a streak point // this makes it so that even smooth paths where