mirror of
https://github.com/TobyAdd/GDH.git
synced 2025-09-06 21:11:41 +00:00
new tps implementation (beta)
This commit is contained in:
21
src/gui.cpp
21
src/gui.cpp
@@ -377,19 +377,18 @@ void Gui::Render() {
|
||||
|
||||
}
|
||||
else if (windowName == "Framerate") {
|
||||
// bool tps_enabled = config.get<bool>("tps_enabled", false);
|
||||
// float tps_value = config.get<float>("tps_value", 60.f);;
|
||||
bool tps_enabled = config.get<bool>("tps_enabled", false);
|
||||
float tps_value = config.get<float>("tps_value", 60.f);;
|
||||
|
||||
// ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (35 + 5) * m_scale);
|
||||
// if (ImGui::DragFloat("##tps_value", &tps_value, 1, 1, FLT_MAX, "%0.f TPS"))
|
||||
// config.set<float>("tps_value", tps_value);
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (35 + 5) * m_scale);
|
||||
if (ImGui::DragFloat("##tps_value", &tps_value, 1, 1, FLT_MAX, "%0.f TPS"))
|
||||
config.set<float>("tps_value", tps_value);
|
||||
|
||||
// ImGui::SameLine();
|
||||
// if (ImGuiH::Checkbox("##tps_enabled", &tps_enabled, m_scale))
|
||||
// config.set<bool>("tps_enabled", tps_enabled);
|
||||
|
||||
// if (ImGui::IsItemHovered())
|
||||
// ImGui::SetTooltip("Multiplies the number of ticks per second, used mainly for botting\n(not recommended for normal use as it ruins the game's performance)");
|
||||
ImGui::SameLine();
|
||||
if (ImGuiH::Checkbox("##tps_enabled", &tps_enabled, m_scale)) {
|
||||
config.set<bool>("tps_enabled", tps_enabled);
|
||||
hacks.TPSBypass_Init(tps_enabled);
|
||||
}
|
||||
|
||||
bool speedhack_enabled = config.get<bool>("speedhack_enabled", false);
|
||||
float speedhack_value = config.get<float>("speedhack_value", 1.f);
|
||||
|
@@ -8,6 +8,8 @@
|
||||
#include "popupSystem.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
int m_exceptedTicks = 0;
|
||||
|
||||
void Hacks::Init() {
|
||||
m_windows = {
|
||||
{"Core", 10, 10, 200, 230,
|
||||
@@ -134,6 +136,10 @@ void Hacks::Init() {
|
||||
};
|
||||
|
||||
auto &config = Config::get();
|
||||
|
||||
if (config.get<bool>("tps_enabled", false)) {
|
||||
TPSBypass_Init(true);
|
||||
}
|
||||
|
||||
SetCustomWindowHandlerByConfig("layout_mode", [this, &config]() {
|
||||
auto &gui = Gui::get();
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <vector>
|
||||
|
||||
enum cheat_state
|
||||
{
|
||||
@@ -35,6 +35,8 @@ struct window {
|
||||
float orig_w, orig_h;
|
||||
};
|
||||
|
||||
extern int m_exceptedTicks;
|
||||
|
||||
class Hacks {
|
||||
public:
|
||||
static Hacks& get() {
|
||||
@@ -57,6 +59,40 @@ public:
|
||||
cheat_state preCheatState = cheat_state::legit;
|
||||
cheat_state cheatState = cheat_state::legit;
|
||||
cheat_state cheatingCheck();
|
||||
|
||||
|
||||
bool TPSBypass_Init(bool enable = true) {
|
||||
auto exceptedTicksAddr = (uintptr_t)&m_exceptedTicks;
|
||||
std::vector<uint8_t> patchBytes;
|
||||
|
||||
// mov rax, exceptedTicks (48 B8 + 8 byte address)
|
||||
patchBytes.push_back(0x48);
|
||||
patchBytes.push_back(0xB8);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
patchBytes.push_back((exceptedTicksAddr >> (i * 8)) & 0xFF);
|
||||
}
|
||||
|
||||
// mov r11d, [rax] (44 8B 18)
|
||||
patchBytes.push_back(0x44);
|
||||
patchBytes.push_back(0x8B);
|
||||
patchBytes.push_back(0x18);
|
||||
|
||||
for (int i = 0; i < 54; i++) {
|
||||
patchBytes.push_back(0x90); // NOP
|
||||
}
|
||||
|
||||
uintptr_t offset = geode::base::get() + 0x232294;
|
||||
static auto result1 = geode::Mod::get()->patch((void*)(offset), patchBytes);
|
||||
static auto patch1 = result1.isErr() ? nullptr : result1.unwrap();
|
||||
if (patch1) {
|
||||
if (enable) (void)patch1->enable();
|
||||
else (void)patch1->disable();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
Hacks() = default;
|
||||
|
||||
|
@@ -786,6 +786,11 @@ class $modify(MyEndLevelLayer, EndLevelLayer) {
|
||||
};
|
||||
|
||||
class $modify(MyGJBaseGameLayer, GJBaseGameLayer) {
|
||||
struct Fields {
|
||||
float m_extraDt = 0.f;
|
||||
float m_visualDt = 0.f;
|
||||
};
|
||||
|
||||
static void onModify(auto& self) {
|
||||
(void) self.setHookPriority("GJBaseGameLayer::update", 0x99999);
|
||||
}
|
||||
@@ -824,6 +829,7 @@ class $modify(MyGJBaseGameLayer, GJBaseGameLayer) {
|
||||
}
|
||||
|
||||
void update(float dt) {
|
||||
auto fields = m_fields.self();
|
||||
auto& engine = ReplayEngine::get();
|
||||
auto& config = Config::get();
|
||||
|
||||
@@ -832,6 +838,26 @@ class $modify(MyGJBaseGameLayer, GJBaseGameLayer) {
|
||||
|
||||
if (config.get<bool>("jump_hack", false))
|
||||
m_player1->m_isOnGround = true;
|
||||
|
||||
if (config.get<bool>("tps_enabled", false)) {
|
||||
#ifdef GEODE_IS_WINDOWS
|
||||
// float timeWarp = m_gameState.m_timeWarp;
|
||||
// float adjustedDt = dt / timeWarp;
|
||||
|
||||
// m_fields->m_extraDt += adjustedDt;
|
||||
fields->m_extraDt += dt;
|
||||
|
||||
float tps_value = config.get<float>("tps_value", 60.f);
|
||||
float new_dt = 1.f / tps_value;
|
||||
auto ticks = std::round(m_fields->m_extraDt / new_dt);
|
||||
auto totalDt = ticks * new_dt;
|
||||
fields->m_extraDt -= totalDt;
|
||||
m_exceptedTicks = ticks;
|
||||
|
||||
fields->m_visualDt = totalDt;
|
||||
// m_fields->m_visualDt = totalDt * timeWarp;
|
||||
#endif
|
||||
}
|
||||
|
||||
GJBaseGameLayer::update(dt);
|
||||
|
||||
|
Reference in New Issue
Block a user