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

Commit

Permalink
refactor SimpleHacks and other files
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaghettDev committed Mar 11, 2024
1 parent 23d1f10 commit 9e43d72
Show file tree
Hide file tree
Showing 17 changed files with 137 additions and 135 deletions.
28 changes: 14 additions & 14 deletions src/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void Common::calculateFramerate()
bool vsync = GameManager::get()->getGameVariable("0030");
CCApplication::sharedApplication()->toggleVerticalSync(vsync);

if(vsync)
if (vsync)
return;

float framerate = 60.f;
Expand Down Expand Up @@ -125,9 +125,9 @@ float Common::getTPS()
tps = Settings::get<float>("general/tps/value", 240.f);
else
tps = 240.f;
if(Macrobot::playerMode == Macrobot::PLAYBACK)
if (Macrobot::playerMode == Macrobot::PLAYBACK)
tps = Macrobot::macro.framerate;
if(tps < 1.f)
if (tps < 1.f)
tps = 1.f;

return tps;
Expand Down Expand Up @@ -202,15 +202,15 @@ void Common::updateCheating()

PlayLayer* pl = PlayLayer::get();

if(pl)
if (pl)
{
int levelID = pl->m_level->m_levelID;
if(levelID <= 97454394 && levelID != 0 && tps > 360)
if (levelID <= 97454394 && levelID != 0 && tps > 360)
{
isCheating = true;
return;
}
else if((levelID > 97454394 || levelID == 0) && tps > 240)
else if ((levelID > 97454394 || levelID == 0) && tps > 240)
{
isCheating = true;
return;
Expand All @@ -234,7 +234,7 @@ class $modify(PlayLayer)
doLoop |= setting;
}

if(!doLoop)
if (!doLoop)
return;

int cameraSection = MBO(int, this, 10676);
Expand All @@ -244,35 +244,35 @@ class $modify(PlayLayer)

for(int i = cameraSection; i < cameraSectionLast; i++)
{
if(sections.size() <= i)
if (sections.size() <= i)
continue;

auto s0 = sections.at(i);

if(!s0)
if (!s0)
continue;

bool hasObjects = false;

for(int j = 0; j < s0->size(); j++)
{
if(s0->size() <= j)
if (s0->size() <= j)
continue;

auto s1 = s0->at(j);
if(!s1)
if (!s1)
continue;

for(int k = 0; k < s1->size(); k++)
{
if(s1->size() <= k)
if (s1->size() <= k)
continue;

hasObjects = true;
auto obj = s1->at(k);
for(auto &pair : Common::sectionLoopFunctions)
{
if(Settings::get<bool>(pair.second, false))
if (Settings::get<bool>(pair.second, false))
pair.first(obj);
}
}
Expand All @@ -299,7 +299,7 @@ class $modify(MenuLayer)

void Common::uncompleteLevel()
{
if(!PlayLayer::get())
if (!PlayLayer::get())
{
FLAlertLayer::create("Error", "Enter a level first!", "Ok")->show();
return;
Expand Down
22 changes: 11 additions & 11 deletions src/GUI/Blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class $modify(CCEGLView) {
{
CCEGLView::resizeWindow(width, height);

if(gdRenderTexture)
if (gdRenderTexture)
gdRenderTexture->resize({(float)width, (float)height});
}
};
Expand All @@ -37,16 +37,16 @@ class $modify(CCNode) {

bool blur = Settings::get<bool>("menu/blur/enabled", false) || Settings::get<bool>("menu/blur/gd", false);

if(this != (CCNode*)CCDirector::sharedDirector()->getRunningScene() || !GUI::shouldRender() || !blur || !blurProgram)
if (this != (CCNode*)CCDirector::sharedDirector()->getRunningScene() || !GUI::shouldRender() || !blur || !blurProgram)
{
CCNode::visit();
return;
}

if(!compiled)
if (!compiled)
Blur::compileBlurShader();

if(!gdRenderTexture)
if (!gdRenderTexture)
{
auto winSize = CCDirector::sharedDirector()->getOpenGLView()->getViewPortRect();
gdRenderTexture = RenderTexture::create({winSize.size.width, winSize.size.height});
Expand All @@ -63,7 +63,7 @@ class $modify(CCNode) {
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture);
glBindTexture(GL_TEXTURE_2D, gdRenderTexture->getTexture());

if(blurGD)
if (blurGD)
{
blurProgram->use();
setBlurUniforms();
Expand Down Expand Up @@ -147,7 +147,7 @@ void Blur::compileBlurShader()
{
bool blur = Settings::get<bool>("menu/blur/enabled", false) || Settings::get<bool>("menu/blur/gd", false);

if(compiled || !blur)
if (compiled || !blur)
return;

blurProgram = new cocos2d::CCGLProgram();
Expand Down Expand Up @@ -197,22 +197,22 @@ void Blur::setBlurUniforms()
float blurSize = Settings::get<float>("menu/blur/size", 1.f);
int blurSteps = Settings::get<int>("menu/blur/steps", 10);

if(darknessUniform == -1)
if (darknessUniform == -1)
darknessUniform = blurProgram->getUniformLocationForName("blurDarkness");
else
blurProgram->setUniformLocationWith1f(darknessUniform, blurDarkness);

if(stepsUniform == -1)
if (stepsUniform == -1)
stepsUniform = blurProgram->getUniformLocationForName("blurSteps");
else
blurProgram->setUniformLocationWith1i(stepsUniform, blurSteps);

if(sizeUniform == -1)
if (sizeUniform == -1)
sizeUniform = blurProgram->getUniformLocationForName("blurSize");
else
blurProgram->setUniformLocationWith1f(sizeUniform, blurSize);

if(amountUniform == -1)
if (amountUniform == -1)
amountUniform = blurProgram->getUniformLocationForName("blurAmount");
else
blurProgram->setUniformLocationWith1f(amountUniform, blurAmount);
Expand All @@ -237,7 +237,7 @@ void Blur::resetCallback(const ImDrawList*, const ImDrawCmd*)

void Blur::blurWindowBackground()
{
if(!blurProgram || !gdRenderTexture)
if (!blurProgram || !gdRenderTexture)
return;

ImVec2 screen_size = ImGui::GetIO().DisplaySize;
Expand Down
2 changes: 1 addition & 1 deletion src/GUI/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ImVec2 GUI::getJsonPosition(const std::string& name)

auto winSize = CCDirector::sharedDirector()->getOpenGLView()->getViewPortRect();

if(windowPositions[name]["x"] > 1 || windowPositions[name]["y"] > 1)
if (windowPositions[name]["x"] > 1 || windowPositions[name]["y"] > 1)
winSize.size = cocos2d::CCSize(1.f, 1.f);

return {windowPositions[name]["x"].get<float>() * winSize.size.width, windowPositions[name]["y"].get<float>() * winSize.size.height};
Expand Down
4 changes: 2 additions & 2 deletions src/GUI/Shortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ void GUI::Shortcut::renderWindow()

bool vsync = GameManager::get()->getGameVariable("0030");

if(GUI::checkbox("Vsync", &vsync))
if (GUI::checkbox("Vsync", &vsync))
{
GameManager::get()->setGameVariable("0030", vsync);
Common::calculateFramerate();
}

if(GUI::button("Uncomplete Level"))
if (GUI::button("Uncomplete Level"))
Common::uncompleteLevel();

if (GUI::button("Toggle Practice") && PlayLayer::get())
Expand Down
4 changes: 2 additions & 2 deletions src/GUI/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ void Window::draw()
float windowTransparency = Settings::get<float>("menu/window/opacity", 0.98f);
float blurDarkness = Settings::get<float>("menu/blur/darkness", 1.f);

if(blurEnabled)
if (blurEnabled)
ImGui::SetNextWindowBgAlpha(blurGD ? (blurDarkness - 0.1f) : 1);
else
ImGui::SetNextWindowBgAlpha(windowTransparency);

ImGui::Begin(name.c_str(), (bool*)0, flags);

if(blurEnabled && !blurGD)
if (blurEnabled && !blurGD)
Blur::blurWindowBackground();

if (ImGui::IsMouseDragging(0, 0.1f) && ImGui::IsWindowFocused())
Expand Down
12 changes: 6 additions & 6 deletions src/Hacks/AutoDeafen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ class $modify(PlayLayer)

bool enabled = Settings::get<bool>("level/auto_deafen/enabled", false);

if(!enabled)
if (!enabled)
return;

float deafenPercent = Settings::get<float>("level/auto_deafen/percent", 50.f);

float percent = PlayLayer::getCurrentPercent();

if(!this->m_player1->m_isDead && !this->m_player2->m_isDead && percent > deafenPercent && !AutoDeafen::deafened)
if (!this->m_player1->m_isDead && !this->m_player2->m_isDead && percent > deafenPercent && !AutoDeafen::deafened)
{
AutoDeafen::toggleDeafen();
AutoDeafen::deafened = true;
Expand All @@ -43,7 +43,7 @@ class $modify(PlayLayer)
{
PlayLayer::destroyPlayer(p0, p1);

if(p0 && p0->m_isDead && AutoDeafen::deafened)
if (p0 && p0->m_isDead && AutoDeafen::deafened)
{
AutoDeafen::toggleDeafen();
AutoDeafen::deafened = false;
Expand All @@ -54,7 +54,7 @@ class $modify(PlayLayer)
{
PlayLayer::resetLevel();

if(AutoDeafen::deafened)
if (AutoDeafen::deafened)
{
AutoDeafen::toggleDeafen();
AutoDeafen::deafened = false;
Expand All @@ -65,7 +65,7 @@ class $modify(PlayLayer)
{
PlayLayer::levelComplete();

if(AutoDeafen::deafened)
if (AutoDeafen::deafened)
{
AutoDeafen::toggleDeafen();
AutoDeafen::deafened = false;
Expand All @@ -76,7 +76,7 @@ class $modify(PlayLayer)
{
PlayLayer::onQuit();

if(AutoDeafen::deafened)
if (AutoDeafen::deafened)
{
AutoDeafen::toggleDeafen();
AutoDeafen::deafened = false;
Expand Down
10 changes: 5 additions & 5 deletions src/Hacks/HitboxMultiplier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ void scaleRect(cocos2d::CCRect* r, float a, float b)

void HitboxMultiplier::scaleHazard(GameObject* hazard)
{
if(hazard->m_objectType != GameObjectType::Hazard && hazard->m_objectType != GameObjectType::AnimatedHazard)
if (hazard->m_objectType != GameObjectType::Hazard && hazard->m_objectType != GameObjectType::AnimatedHazard)
return;

float scaleHazards[2] = {Settings::get<float>("level/hitbox_multiplier/scale_hazards/x", 1.f), Settings::get<float>("level/hitbox_multiplier/scale_hazards/y", 1.f)};

cocos2d::CCRect rect = (MBO(cocos2d::CCRect, hazard, 728));

if(rect.origin.x == 0 && rect.origin.y == 0 || rect.size.width == 0 && rect.size.height == 0)
if (rect.origin.x == 0 && rect.origin.y == 0 || rect.size.width == 0 && rect.size.height == 0)
return;

if(!memberRectForObject.contains(hazard))
if (!memberRectForObject.contains(hazard))
memberRectForObject[hazard] = rect;
else
rect = memberRectForObject[hazard];
Expand All @@ -67,7 +67,7 @@ class $modify(GameObject)
{
bool enabled = Settings::get<bool>("level/hitbox_multiplier", false);

if(!enabled)
if (!enabled)
return reinterpret_cast<cocos2d::CCRect const& (__thiscall*)(GameObject*)>(base::get() + 0x13a570)(this);

bool all = Settings::get<bool>("level/hitbox_multiplier/scale_all", false);
Expand All @@ -77,7 +77,7 @@ class $modify(GameObject)
float scaleSlopes[2] = {Settings::get<float>("level/hitbox_multiplier/scale_slopes/x", 1.f), Settings::get<float>("level/hitbox_multiplier/scale_slopes/y", 1.f)};
float scalePlayer[2] = {Settings::get<float>("level/hitbox_multiplier/scale_player/x", 1.f), Settings::get<float>("level/hitbox_multiplier/scale_player/y", 1.f)};

if((PlayerObject*)this == GameManager::get()->getGameLayer()->m_player1 || (PlayerObject*)this == GameManager::get()->getGameLayer()->m_player2)
if ((PlayerObject*)this == GameManager::get()->getGameLayer()->m_player1 || (PlayerObject*)this == GameManager::get()->getGameLayer()->m_player2)
{
x = scalePlayer[0];
y = scalePlayer[1];
Expand Down
22 changes: 11 additions & 11 deletions src/Hacks/Labels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ class $modify(PlayLayer)
setupLabel(
"Best Run",
[&](cocos2d::CCLabelBMFont* pointer) {
if(bestRun.first == 0)
if (bestRun.first == 0)
{
if(bestRun.second == 0)
if (bestRun.second == 0)
pointer->setString("Best Run: None");
else
pointer->setString(fmt::format("Best Run: {}%", (int)bestRun.second).c_str());
Expand All @@ -181,9 +181,9 @@ class $modify(PlayLayer)
setupLabel(
"Macro Info",
[&](cocos2d::CCLabelBMFont* pointer) {
if(Macrobot::playerMode == Macrobot::PLAYBACK)
if (Macrobot::playerMode == Macrobot::PLAYBACK)
pointer->setString(fmt::format("Playing {}/{}", Macrobot::actionIndex, Macrobot::macro.inputs.size()).c_str());
else if(Macrobot::playerMode == Macrobot::RECORDING)
else if (Macrobot::playerMode == Macrobot::RECORDING)
pointer->setString(fmt::format("Recording {}", Macrobot::macro.inputs.size()).c_str());
else
pointer->setString("");
Expand All @@ -202,28 +202,28 @@ class $modify(PlayLayer)

void destroyPlayer(PlayerObject* player, GameObject* object)
{
if(!anticheatSpike && frames < 5)
if (!anticheatSpike && frames < 5)
anticheatSpike = object;

if(object == anticheatSpike)
if (object == anticheatSpike)
return PlayLayer::destroyPlayer(player, object);

if(noclipDead)
if (noclipDead)
JsonPatches::togglePatch(JsonPatches::player, "NoClip", false);

PlayLayer::destroyPlayer(player, object);

if(noclipDead)
if (noclipDead)
JsonPatches::togglePatch(JsonPatches::player, "NoClip", true);

if(player && player->m_isDead)
if (player && player->m_isDead)
{
currentRun.second = this->getCurrentPercent();

float currentRunTotal = currentRun.second - currentRun.first;
float bestRunTotal = bestRun.second - bestRun.first;

if(currentRunTotal > bestRunTotal)
if (currentRunTotal > bestRunTotal)
bestRun = currentRun;
}

Expand All @@ -237,7 +237,7 @@ class $modify(PlayLayer)

float currentRunTotal = currentRun.second - currentRun.first;
float bestRunTotal = bestRun.second - bestRun.first;
if(currentRunTotal > bestRunTotal)
if (currentRunTotal > bestRunTotal)
bestRun = currentRun;
}

Expand Down
Loading

0 comments on commit 9e43d72

Please sign in to comment.