Skip to content

Commit bc64c71

Browse files
committed
fuck it dont do it in testmode
1 parent 69ab916 commit bc64c71

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/PlayLayer.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ class $modify(MyPlayLayer, PlayLayer) {
2626
PlayLayer::levelComplete();
2727
Manager::getSharedInstance()->lastDeathPercent = -10.f;
2828
}
29+
void togglePracticeMode(bool practiceMode) {
30+
PlayLayer::togglePracticeMode(practiceMode);
31+
Manager::getSharedInstance()->lastDeathPercent = -10.f;
32+
}
33+
void resetLevelFromStart() {
34+
PlayLayer::resetLevelFromStart();
35+
Manager::getSharedInstance()->lastDeathPercent = -10.f;
36+
}
2937
void updateProgressbar() {
3038
PlayLayer::updateProgressbar();
3139
if (!getModBool("enabled") || m_level->isPlatformer() || !m_player1->m_isDead || m_isPlatformer) return;

src/PlayerObject.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,33 @@ class $modify(MyPlayerObject, PlayerObject) {
2828

2929
const bool isNewBest = MyPlayerObject::isNewBest(pl);
3030
const bool shouldPlayNewBestSFX = getBool("newBestSFX") && isNewBest;
31-
bool qualifiedToShowNewBest = false;
31+
bool qualifiedToShowAFakeNewBest = false;
3232
// splitting it into three if statements for readability
33-
if (!pl->m_isTestMode && !pl->m_isPracticeMode && getBool("alwaysNewBest") && !isNewBest) qualifiedToShowNewBest = true;
34-
if (getBool("alwaysNewBestPlaytest") && pl->m_isTestMode) qualifiedToShowNewBest = true;
35-
if (getBool("alwaysNewBestPractice") && pl->m_isPracticeMode) qualifiedToShowNewBest = true;
33+
if (!pl->m_isTestMode && !pl->m_isPracticeMode && getBool("alwaysNewBest") && !isNewBest) qualifiedToShowAFakeNewBest = true;
34+
if (getBool("alwaysNewBestPlaytest") && pl->m_isTestMode) qualifiedToShowAFakeNewBest = true;
35+
if (getBool("alwaysNewBestPractice") && pl->m_isPracticeMode) qualifiedToShowAFakeNewBest = true;
3636
if (getBool("logging")) {
3737
log::info("pl->getCurrentPercentInt() <= pl->m_level->m_normalPercent.value(): {}", pl->getCurrentPercentInt() <= pl->m_level->m_normalPercent.value());
3838
log::info("pl->getCurrentPercentInt(): {}", pl->getCurrentPercentInt());
3939
log::info("pl->m_level->m_normalPercent.value(): {}", pl->m_level->m_normalPercent.value());
4040
}
41-
if (qualifiedToShowNewBest) pl->showNewBest(true, 0, 0, false, false, false);
42-
if (pl->m_isTestMode || pl->m_isPracticeMode) return; // shouldnt play new best sfx in practice/testmode
41+
if (qualifiedToShowAFakeNewBest) pl->showNewBest(true, 0, 0, false, false, false);
4342
const auto fmod = FMODAudioEngine::get();
4443
if (!fmod) return;
4544

4645
Manager* manager = Manager::getSharedInstance();
4746
const float plCurrentPercent = pl->getCurrentPercent();
4847
const float originalDeathPercent = manager->lastDeathPercent;
4948
const bool shouldActivateSisyphusMode = getBool("sisyphus") && std::abs(originalDeathPercent - plCurrentPercent) <= static_cast<float>(std::clamp(getFloat("sisyphusThreshold"), .01, 10.));
50-
manager->lastDeathPercent = plCurrentPercent;
49+
if (!pl->m_isTestMode) {
50+
manager->lastDeathPercent = plCurrentPercent;
51+
}
5152

5253
const auto system = fmod->m_system;
5354
FMOD::Channel* channel;
5455
FMOD::Sound* sound;
5556

56-
if (const std::filesystem::path& newBestSFXFile = Mod::get()->getConfigDir() / fmt::format("newBest.{}", getString("extension")); shouldPlayNewBestSFX && std::filesystem::exists(newBestSFXFile)) {
57+
if (const std::filesystem::path& newBestSFXFile = Mod::get()->getConfigDir() / fmt::format("newBest.{}", getString("extension")); shouldPlayNewBestSFX && std::filesystem::exists(newBestSFXFile) && !pl->m_isTestMode && !pl->m_isPracticeMode) {
5758
if (getBool("logging")) {
5859
log::info("newBestSFXFile: {}", newBestSFXFile.string());
5960
log::info("getString(\"extension\"): {}", getString("extension"));
@@ -72,7 +73,7 @@ class $modify(MyPlayerObject, PlayerObject) {
7273
sisyphusImage
7374
*/
7475

75-
if (!isNewBest && shouldActivateSisyphusMode) {
76+
if (CCNode* playLayerParent = pl->getParent(); !isNewBest && shouldActivateSisyphusMode && playLayerParent && !pl->m_isTestMode) {
7677
const std::filesystem::path& sisyphusSFXFile = getFile("sisyphusSFX");
7778
const std::filesystem::path& sisyphusImageFile = getFile("sisyphusImage");
7879
const auto extension = sisyphusSFXFile.extension();
@@ -83,7 +84,6 @@ class $modify(MyPlayerObject, PlayerObject) {
8384
channel->setVolume(getInt("sisyphusVolume") / 100.0f);
8485
}
8586
if (getBool("sisyphusAddImage") && std::filesystem::exists(sisyphusImageFile) && sisyphusImageFile.extension() == ".png" && pl->getParent()) {
86-
CCNode* playLayerParent = pl->getParent();
8787
if (CCNode* sisyphusByID = playLayerParent->getChildByID("sisyphus"_spr)) sisyphusByID->removeMeAndCleanup();
8888
else if (CCNode* sisyphusByTag = playLayerParent->getChildByTag(8042025)) sisyphusByTag->removeMeAndCleanup();
8989

0 commit comments

Comments
 (0)