diff --git a/src/Hacks/AllModesPlatformer.cpp b/src/Hacks/AllModesPlatformer.cpp index ef46c40..d8ce0e4 100644 --- a/src/Hacks/AllModesPlatformer.cpp +++ b/src/Hacks/AllModesPlatformer.cpp @@ -15,30 +15,28 @@ class $modify (GJBaseGameLayer) { for (size_t i = 0; i < p1->size(); i++) { - auto obj = p1->at(i); - - if (!obj) - break; - - if (p0->getObjectRect().intersectsRect(obj->getObjectRect())) + if (auto obj = p1->at(i)) { - if (obj->m_objectType == GameObjectType::WavePortal || obj->m_objectType == GameObjectType::SwingPortal) + if (p0->getObjectRect().intersectsRect(obj->getObjectRect())) { - if(this->canBeActivatedByPlayer(p0, as(obj))) + if (obj->m_objectType == GameObjectType::WavePortal || obj->m_objectType == GameObjectType::SwingPortal) { - this->playerWillSwitchMode(p0, obj); - #ifdef GEODE_IS_WINDOWS - p0->switchedToMode(obj->m_objectType); - - if (obj->m_objectType == GameObjectType::SwingPortal) - p0->toggleSwingMode(true, false); - else - p0->toggleDartMode(true, false); - - #else - this->switchToFlyMode(p0, obj, false, as(obj->m_objectType)); - #endif - obj->playShineEffect(); + if(this->canBeActivatedByPlayer(p0, as(obj))) + { + this->playerWillSwitchMode(p0, obj); + #ifdef GEODE_IS_WINDOWS + p0->switchedToMode(obj->m_objectType); + + if (obj->m_objectType == GameObjectType::SwingPortal) + p0->toggleSwingMode(true, false); + else + p0->toggleDartMode(true, false); + + #else + this->switchToFlyMode(p0, obj, false, as(obj->m_objectType)); + #endif + obj->playShineEffect(); + } } } }