Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Jul 21, 2024
1 parent 7bd34e5 commit 05fa64f
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 85 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.4.9

- Fixed CPS and FPS counter being broken
- Fixed dying in noclip causing fps to be wrong
- Added **One Attempt Practice Complete**

# 1.4.8

- Removed all imgui code so that wine players can use qolmod
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "3.2.0",
"version": "v1.4.8",
"version": "v1.4.9",
"gd": {
"win": "2.206",
"android": "2.206"
Expand Down
46 changes: 0 additions & 46 deletions src/AttemptAtReversingDialogObject.h

This file was deleted.

1 change: 1 addition & 0 deletions src/Client/ClientSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class ClientUtils
level->modules.push_back(new Module("Jump Hack", "jump-hack", "Allows you to jump infinitely"));

level->modules.push_back(new Module("Pause Countdown", "pause-countdown", "Shows a countdown for 3 seconds when you unpause a level"));
level->modules.push_back(new Module("1 Attempt Practice", "practice-complete", "Allows you to complete a level in practice mode if you beat it in >cr>one<c/> attempt", true));
//level->modules.push_back(new Module("Frame Stepper", "frame-stepper", "Step the game through frames by tapping a button"));


Expand Down
2 changes: 1 addition & 1 deletion src/Client/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void Module::addHookRaw(Result<Hook*> hook)
if (!hook.isOk() || !hook.has_value())
return log::error("Error adding hook: {}", hook.err());

addHook(hook.unwrap());
addHook(hook.unwrapOr(nullptr));
}

void Module::addHook(Hook* hook)
Expand Down
20 changes: 20 additions & 0 deletions src/Hacks/Frame Stepper/FrameStepper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*#include <Geode/Geode.hpp>
#include <Geode/modify/PlayLayer.hpp>
#include <Geode/modify/GJBaseGameLayer.hpp>
#include "../../Client/Client.h"
using namespace geode::prelude;
bool enabled()
{
return CCKeyboardDispatcher::get()->getShiftKeyPressed();
}
class $modify (GJBaseGameLayer)
{
virtual void update(float p0)
{
if (enabled())
return GJBaseGameLayer::update(p0);
}
};*/
37 changes: 37 additions & 0 deletions src/Hacks/PracticeComplete.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <Geode/Geode.hpp>
#include <Geode/modify/PlayLayer.hpp>
#include "../Client/Client.h"

using namespace geode::prelude;

class $modify (PlayLayer)
{
struct Fields
{
bool hasRespawnedWithCheckpoint;
};

void resetLevel()
{
m_fields->hasRespawnedWithCheckpoint = false;

PlayLayer::resetLevel();
}

void loadFromCheckpoint(CheckpointObject* cp)
{
m_fields->hasRespawnedWithCheckpoint = true;

PlayLayer::loadFromCheckpoint(cp);
}

void levelComplete()
{
if (m_isPracticeMode)
m_isPracticeMode = m_fields->hasRespawnedWithCheckpoint;

PlayLayer::levelComplete();
}

QOLMOD_MOD_HOOK("practice-complete", "PlayLayer::levelComplete")
};
2 changes: 1 addition & 1 deletion src/Hacks/SafeMode/SafeMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void SafeMode::updateIndicator()
if (auto l = a->sLabels[0])
l->setColor(colourForState());

a->update(1);
a->update(-1);
a->reorderSides();
a->reorderPosition();
}
Expand Down
10 changes: 8 additions & 2 deletions src/Hacks/TPSBypass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ void updateTPSPatches(bool tpsEnabled)
{
for (auto catgirl : patches)
{
Mod::get()->disownPatch(catgirl); // goodbye cutie you will be very missed :3c
if (catgirl)
Mod::get()->disownPatch(catgirl); // goodbye cutie you will be very missed :3c
}

patches.clear();
Expand All @@ -40,7 +41,12 @@ void updateTPSPatches(bool tpsEnabled)
if (tpsEnabled)
{
#ifdef GEODE_IS_WINDOWS
//patches.push_back(Mod::get()->patch(reinterpret_cast<void*>(geode::base::get() + 0x5ec6d0), geode::toByteArray<double>(1.0f / tps)).unwrap());
//auto array = geode::toByteArray<float>(1.0f / tps);

//DWORD old_prot;
//VirtualProtect(reinterpret_cast<void*>(geode::base::get() + 0x5ec6d0), array.size(), PAGE_EXECUTE_READWRITE, &old_prot);
//patches.push_back(createPatchSafe(reinterpret_cast<void*>(geode::base::get() + 0x5ec6d0), array));
//VirtualProtect(reinterpret_cast<void*>(geode::base::get() + 0x5ec6d0), array.size(), old_prot, &old_prot);
#endif

#ifdef GEODE_IS_ANDROID32
Expand Down
85 changes: 53 additions & 32 deletions src/Labels/Labels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool StatusNode::init()

hidden = Mod::get()->getSavedValue<bool>("hide-labels");

update(1.0f);
update(-1.0f);
updateVis();

reorderSides();
Expand Down Expand Up @@ -254,14 +254,9 @@ void StatusNode::update(float dt)
sLabels[3]->setString((numToString(as<NoclipPlayLayer*>(PlayLayer::get())->m_fields->d, 0) + (as<NoclipPlayLayer*>(PlayLayer::get())->m_fields->d == 1 ? std::string(" Death") : std::string(" Deaths"))).c_str());
sLabels[4]->setString((std::string("Attempt ") + std::to_string(attPL->m_fields->attemptCount)).c_str());

std::stringstream ss;
//ss << "Frame: " << numToString(GJReplayManager::frame) << ", Delta: " << numToString(GJReplayManager::dt, 4);

std::stringstream inp;
//inp << GJReplayManager::replay.inputs.size() << (GJReplayManager::replay.inputs.size() == 1 ? " Input" : " Inputs") << ", " << GJReplayManager::replay.frames.size() << (GJReplayManager::replay.frames.size() == 1 ? " Frame" : " Frames");

std::string b = (std::string("Frame Fixes: ") + (Mod::get()->getSavedValue<bool>("frame-fixes") ? "Enabled" : "Disabled") + std::string(", Click Fixes: ") + (Mod::get()->getSavedValue<bool>("click-fixes") ? "Enabled" : "Disabled"));
sLabels[5]->setString(ss.str().c_str());
sLabels[5]->setString("");
//sLabels[6]->setString(b.c_str());
//sLabels[7]->setString(inp.str().c_str());
auto v2 = as<InputModule*>(message->options[1])->text.c_str();
Expand All @@ -281,7 +276,23 @@ void StatusNode::update(float dt)
as<NoclipPlayLayer*>(PlayLayer::get())->m_fields->isDead = false;
}

sLabels[1]->setString(std::to_string((int)roundf(CCDirector::sharedDirector()->m_fFrameRate)).append(" FPS").c_str());
if (dt != -1)
{
_timeLeft -= dt / CCScheduler::get()->getTimeScale();
_accum += 1 / (dt / CCScheduler::get()->getTimeScale());
_frames++;

if (_timeLeft <= 0) {
float fps = _accum / _frames;

sLabels[1]->setString((std::to_string(as<int>(roundf(fps))) + std::string(" FPS")).c_str());
//CCLOG("Average FPS: %.2f", fps);

_timeLeft = _updateInterval;
_accum = 0;
_frames = 0;
}
}

for (size_t i = 0; i < cps.size(); i++)
{
Expand All @@ -290,10 +301,7 @@ void StatusNode::update(float dt)

cps.erase(std::remove_if(cps.begin(), cps.end(), [](float i){ return i < 0; }), cps.end());


auto cpsTotalStr = cpsM->options[1]->enabled ? "/" + std::to_string(totalCPS) : "";

sLabels[8]->setString((std::to_string(as<int>(cps.size()))).append(cpsTotalStr).append(" CPS").c_str());
sLabels[8]->setString((cpsM->options[1]->enabled ? fmt::format("{} / {} CPS", cps.size(), totalClicks) : fmt::format("{} CPS", cps.size(), totalClicks)).c_str());

updateVis();
}
Expand All @@ -303,24 +311,35 @@ void StatusNode::updateCPS(float dt)

}

class $modify (GJBaseGameLayer) {
void handleButton(bool down, int button, bool isPlayer1) {
GJBaseGameLayer::handleButton(down, button, isPlayer1);
if (!PlayLayer::get()) return;
if (down) {
if (button == 1 && isPlayer1) {
if (auto stn = StatusNode::get()) {
stn->cps.push_back(1);
stn->totalCPS++;

stn->sLabels[8]->stopAllActions();
stn->sLabels[8]->setColor(ccc3(0, 255, 0));
}
class $modify (PlayerObject)
{
void pushButton(PlayerButton p0)
{
PlayerObject::pushButton(p0);

if (p0 == PlayerButton::Jump && PlayLayer::get() && PlayLayer::get()->m_player1 == this)
{
if (auto stn = StatusNode::get())
{
stn->cps.push_back(1);
stn->totalClicks++;

stn->sLabels[8]->stopAllActions();
stn->sLabels[8]->setColor(ccc3(0, 255, 0));
}
} else if (button == 1 && isPlayer1) {
if (auto stn = StatusNode::get()) {
}
}

void releaseButton(PlayerButton p0)
{
PlayerObject::releaseButton(p0);

if (p0 == PlayerButton::Jump && PlayLayer::get())
{
if (auto stn = StatusNode::get())
{
stn->sLabels[8]->stopAllActions();
stn->sLabels[8]->runAction(CCTintTo::create(0.1, 255, 255, 255));
stn->sLabels[8]->runAction(CCTintTo::create(1, 255, 255, 255));
}
}
}
Expand All @@ -342,11 +361,13 @@ class $modify (PlayLayer)

return true;
}
void resetLevel() {

void resetLevel()
{
PlayLayer::resetLevel();
if(auto stn = StatusNode::get()) {
stn->totalCPS = 0;
}

if (StatusNode::get())
StatusNode::get()->totalClicks = 0;
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/Labels/Labels.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class StatusNode : public CCNode
int _frames;

std::vector<float> cps;
int totalCPS = 0;
int totalClicks = 0;

std::string formatTime(float time) {
// Convert float time to milliseconds
Expand Down
10 changes: 10 additions & 0 deletions src/Utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@ float roundUpToMultipleOf2(float num)
float scaleFloat(float v, float min, float max)
{
return (max - min) * v + min;
}

geode::Patch* createPatchSafe(void *address, const geode::ByteVector &data)
{
auto patch = geode::Mod::get()->patch(address, data);

if (patch.has_error())
geode::log::error("Failed to apply patch: {}, data: {}, error: {}", address, data, patch.err());

return patch.unwrapOr(nullptr);
}
3 changes: 2 additions & 1 deletion src/Utils/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ static void onModify(auto& self) { \
}

float roundUpToMultipleOf2(float num);
float scaleFloat(float v, float min, float max);
float scaleFloat(float v, float min, float max);
geode::Patch* createPatchSafe(void *address, const geode::ByteVector &data);

0 comments on commit 05fa64f

Please sign in to comment.