Skip to content

Commit

Permalink
Update main.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiLko authored Feb 25, 2024
1 parent 8e927ff commit 19dc13b
Showing 1 changed file with 34 additions and 9 deletions.
43 changes: 34 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,16 +1118,49 @@ class $modify(PauseLayer) {
}

};
void onReset() {
if (recorder.state != state::off && restart != false) {
restart = false;
}

if (recorder.state != state::off) {
checkUI();
playerHolding = false;
if (!isAndroid) leftOver = 0.f;
}

if (isAndroid) androidAction = nullptr;

if (safeModeEnabled && !isAndroid && mod->getSettingValue<bool>("auto_safe_mode")) {
safeModeEnabled = false;
safeMode::updateSafeMode();
}

if (playedMacro) playedMacro = false;


if (recorder.state == state::playing) {
playingAction = false;
releaseKeys();
recorder.currentAction = 0;
if (mod->getSettingValue<bool>("speedhack_audio")) {
FMOD::ChannelGroup* channel;
FMODAudioEngine::sharedEngine()->m_system->getMasterChannelGroup(&channel);
channel->setPitch(1);
}
}
}
class $modify(PlayerObject) {
void playerDestroyed(bool p0) {
if (isAndroid) androidAction = nullptr;
if (isAndroid && mod->getSettingValue<bool>("auto_safe_mode") && playedMacro) {
noDelayedReset = true;
onReset();
return PlayLayer::get()->resetLevel();
}
if ((!mod->getSettingValue<bool>("instant_respawn") || recorder.state == state::off))
return PlayerObject::playerDestroyed(p0);
onReset();
return PlayLayer::get()->resetLevel();
}
void playDeathEffect() {
Expand Down Expand Up @@ -1181,7 +1214,6 @@ class $modify(GJBaseGameLayer) {
GJBaseGameLayer::handleButton(holding,button,player1);

if (androidAction != nullptr) {
if (androidAction->frame == recorder.currentFrame()) {
if (mod->getSettingValue<bool>("ignore_inputs"))
GJBaseGameLayer::handleButton(holding,button,player1);
if (androidAction->p1.xPos != 0) {
Expand All @@ -1196,8 +1228,8 @@ class $modify(GJBaseGameLayer) {

}
}
}
}
androidAction = nullptr;
} else GJBaseGameLayer::handleButton(holding,button,player1);

} else if (recorder.state == state::recording) {
Expand Down Expand Up @@ -1622,7 +1654,6 @@ class $modify(EndLevelLayer) {
clearState(false);
}
};
int syncCooldown = 0;
int holdCooldown = 0;
class $modify(CCScheduler) {
void update(float dt) {
Expand Down Expand Up @@ -1666,12 +1697,6 @@ class $modify(CCScheduler) {
}
}
leftOver += (dt - dt2 * mult);
if (recorder.state == state::playing && !PlayLayer::get()->m_levelSettings->m_platformerMode) {
syncCooldown++;
if (syncCooldown >= 20 && leftOver > 1) {
syncCooldown = 0;
}
}
}
};

Expand Down

0 comments on commit 19dc13b

Please sign in to comment.