From 9a684b16b6ee6b881a15a819aa0e1db9af28f821 Mon Sep 17 00:00:00 2001 From: Oleksandr Nemesh Date: Wed, 1 May 2024 20:54:00 +0300 Subject: [PATCH] slope bug fix --- libs/gd.hpp | 2 +- mod.json | 2 +- src/geode/hooks/GJBaseGameLayer.cpp | 17 +++++++++++++++++ src/standalone/hooks/GJBaseGameLayer.cpp | 20 ++++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/libs/gd.hpp b/libs/gd.hpp index 776ca34..0b0f3ff 160000 --- a/libs/gd.hpp +++ b/libs/gd.hpp @@ -1 +1 @@ -Subproject commit 776ca3447be3f3d8cef521f711c6cfb12796aa6d +Subproject commit 0b0f3ff302f2e1524098b2aacf9d96f5369356d0 diff --git a/mod.json b/mod.json index 6386f96..8831844 100644 --- a/mod.json +++ b/mod.json @@ -1,5 +1,5 @@ { - "geode": "2.0.0-beta.24", + "geode": "2.0.0-beta.25", "gd": { "win": "2.204" }, diff --git a/src/geode/hooks/GJBaseGameLayer.cpp b/src/geode/hooks/GJBaseGameLayer.cpp index 13cf297..62c12ec 100644 --- a/src/geode/hooks/GJBaseGameLayer.cpp +++ b/src/geode/hooks/GJBaseGameLayer.cpp @@ -7,6 +7,7 @@ #include "../../shared/hacks/display/display.hpp" #include +#include namespace openhack::hooks::GJBaseGameLayerHook { void processCommands(GJBaseGameLayer *self) { @@ -19,6 +20,8 @@ namespace openhack::hooks::GJBaseGameLayerHook { } namespace openhack::hooks { + static bool s_insideDebugUpdate = false; + struct GJBaseGameLayerHook2 : geode::Modify { void update(float dt) { hacks::FrameStepper::gameUpdate(&dt); @@ -26,6 +29,20 @@ namespace openhack::hooks { GJBaseGameLayer::update(dt); }); } + + // This is used to fix slopes killing the player when entering a mirror portal + void updateDebugDraw() { + s_insideDebugUpdate = true; + GJBaseGameLayer::updateDebugDraw(); + s_insideDebugUpdate = false; + } + }; + + struct GameObjectBugfixHook : geode::Modify { + void determineSlopeDirection() { + if (s_insideDebugUpdate) return; + GameObject::determineSlopeDirection(); + } }; } diff --git a/src/standalone/hooks/GJBaseGameLayer.cpp b/src/standalone/hooks/GJBaseGameLayer.cpp index 8a3828a..3e61273 100644 --- a/src/standalone/hooks/GJBaseGameLayer.cpp +++ b/src/standalone/hooks/GJBaseGameLayer.cpp @@ -1,5 +1,6 @@ #include "hooks.hpp" #include +#include #include "../../shared/hacks/labels/labels.hpp" #include "../../shared/hacks/noclip-limit/noclip-limit.hpp" @@ -24,8 +25,27 @@ namespace openhack::hooks::GJBaseGameLayer { }); } + /// This is used to fix slopes killing the player when entering a mirror portal + + static bool s_insideDebugUpdate = false; + + void updateDebugDraw(gd::GJBaseGameLayer *self) { + s_insideDebugUpdate = true; + gd::hook::GJBaseGameLayer::updateDebugDraw(self); + s_insideDebugUpdate = false; + } + + void determineSlopeDirection(gd::GameObject *self) { + if (s_insideDebugUpdate) return; + gd::hook::GameObject::determineSlopeDirection(self); + } + + /// ========================================================================== + void installHooks() { LOG_HOOK(GJBaseGameLayer, processCommands); LOG_HOOK(GJBaseGameLayer, update); + LOG_HOOK(GJBaseGameLayer, updateDebugDraw); + LOG_HOOK(GameObject, determineSlopeDirection); } }