Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
slope bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Prevter committed May 1, 2024
1 parent b96603a commit 9a684b1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"geode": "2.0.0-beta.24",
"geode": "2.0.0-beta.25",
"gd": {
"win": "2.204"
},
Expand Down
17 changes: 17 additions & 0 deletions src/geode/hooks/GJBaseGameLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "../../shared/hacks/display/display.hpp"

#include <Geode/modify/GJBaseGameLayer.hpp>
#include <Geode/modify/GameObject.hpp>

namespace openhack::hooks::GJBaseGameLayerHook {
void processCommands(GJBaseGameLayer *self) {
Expand All @@ -19,13 +20,29 @@ namespace openhack::hooks::GJBaseGameLayerHook {
}

namespace openhack::hooks {
static bool s_insideDebugUpdate = false;

struct GJBaseGameLayerHook2 : geode::Modify<GJBaseGameLayerHook2, GJBaseGameLayer> {
void update(float dt) {
hacks::FrameStepper::gameUpdate(&dt);
hacks::Display::schedulerUpdate(dt, [&](float dt) {
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<GameObjectBugfixHook, GameObject> {
void determineSlopeDirection() {
if (s_insideDebugUpdate) return;
GameObject::determineSlopeDirection();
}
};
}

Expand Down
20 changes: 20 additions & 0 deletions src/standalone/hooks/GJBaseGameLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "hooks.hpp"
#include <dash/hook/GJBaseGameLayer.hpp>
#include <dash/hook/GameObject.hpp>

#include "../../shared/hacks/labels/labels.hpp"
#include "../../shared/hacks/noclip-limit/noclip-limit.hpp"
Expand All @@ -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);
}
}

0 comments on commit 9a684b1

Please sign in to comment.