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

Commit

Permalink
[fixing respawn delay issue]
Browse files Browse the repository at this point in the history
so the issue seemed to be due to togglePatch not being called, added a few logs + renamed the method to verify that
  • Loading branch information
Prevter committed May 17, 2024
1 parent 18986fa commit abf587f
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/shared/hacks/respawn-delay/respawn-delay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ namespace openhack::hacks {
float RespawnDelay::delay = 0.5f;
static ToggleComponent* s_respawnDelay = nullptr;

inline void togglePatch() {
if (!s_respawnDelay) return;
void toggleDelayPatch() {
L_TRACE("Toggling Respawn Delay patch");
if (!s_respawnDelay) {
L_WARN("Respawn Delay not initialized");
return;
}
bool enabled = config::get<bool>("hack.respawn_delay.enabled");
s_respawnDelay->applyPatch(enabled);
bool success = s_respawnDelay->applyPatch(enabled);
if (success) {
L_INFO("Respawn Delay patch {}!", enabled ? "enabled" : "disabled");
} else {
L_WARN("Failed to patch Respawn Delay");
}
}

void RespawnDelay::onInit() {
Expand Down Expand Up @@ -53,15 +62,19 @@ namespace openhack::hacks {
}

// Merge opcodes and customBypass
L_TRACE("Merging opcodes and customBypass ({} + {})", opcodes.size(), customBypass.size());
opcodes.insert(opcodes.end(), customBypass.begin(), customBypass.end());
L_TRACE("Merged opcodes size: {}", opcodes.size());
s_respawnDelay = new ToggleComponent("", "", opcodes);
togglePatch();
L_TRACE("Respawn Delay initialized");
toggleDelayPatch();
L_TRACE("Respawn Delay patched");

// Initialize keybind
menu::keybinds::setKeybindCallback("respawn_delay.enabled", []() {
bool enabled = !config::get<bool>("hack.respawn_delay.enabled");
config::set("hack.respawn_delay.enabled", enabled);
togglePatch();
toggleDelayPatch();
});
}

Expand All @@ -71,7 +84,7 @@ namespace openhack::hacks {
menu::keybinds::addMenuKeybind("respawn_delay.enabled", "Respawn Delay", [](){
bool enabled = !config::get<bool>("hack.respawn_delay.enabled");
config::set("hack.respawn_delay.enabled", enabled);
togglePatch();
toggleDelayPatch();
});
});
if (gui::toggleSetting("Respawn Delay", "hack.respawn_delay.enabled", []() {
Expand All @@ -82,7 +95,7 @@ namespace openhack::hacks {
gui::tooltip("The delay before respawning");
gui::width();
}, ImVec2(0, 0))) {
togglePatch();
toggleDelayPatch();
}
}

Expand Down

0 comments on commit abf587f

Please sign in to comment.