From 3bce5f43553d67b4c64bc2e30ec6486c9893e117 Mon Sep 17 00:00:00 2001 From: Viper <100521306+Cosmella-v@users.noreply.github.com> Date: Sat, 18 Apr 2026 15:32:34 +0100 Subject: [PATCH 1/3] Fix index increment for coin sprite IDs Fixed controller issues by adjusting index increment for coin sprites. --- src/EndLevelLayer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EndLevelLayer.cpp b/src/EndLevelLayer.cpp index 684cad5..daa2708 100644 --- a/src/EndLevelLayer.cpp +++ b/src/EndLevelLayer.cpp @@ -132,6 +132,7 @@ using namespace geode::node_ids; for (int i = 1; i < currentCoin; i++) { if (child->getID().empty() && child->getPosition() == coinPos[i - 1]) { child->setID(fmt::format("coin-{}-sprite", i)); + idx += 1; // fix the controller issues overriding it hopefully } } } From c73d5b0aa3f42560e06ab108a45b069cae88c0fa Mon Sep 17 00:00:00 2001 From: Cosmella-v Date: Sat, 18 Apr 2026 16:57:08 +0100 Subject: [PATCH 2/3] Make the code worse for speed --- src/EndLevelLayer.cpp | 50 +++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/src/EndLevelLayer.cpp b/src/EndLevelLayer.cpp index daa2708..887d391 100644 --- a/src/EndLevelLayer.cpp +++ b/src/EndLevelLayer.cpp @@ -112,9 +112,10 @@ using namespace geode::node_ids; leaderboardButton->setID("practice-retry-button"); } - int currentCoin = 1; + int currentCoin = 0; + auto mainLayerChildren = CCArrayExt(m_mainLayer->getChildren()); std::vector coinPos; - for (auto child : CCArrayExt(m_mainLayer->getChildren())) { + for (auto child : mainLayerChildren) { for (auto framename : { "secretCoin_b_01_001.png", "secretCoin_2_b_01_001.png" @@ -127,24 +128,42 @@ using namespace geode::node_ids; } } } - - for (auto child : CCArrayExt(m_mainLayer->getChildren())) { - for (int i = 1; i < currentCoin; i++) { - if (child->getID().empty() && child->getPosition() == coinPos[i - 1]) { - child->setID(fmt::format("coin-{}-sprite", i)); - idx += 1; // fix the controller issues overriding it hopefully - } - } - } - + /* + i was using it for a fullbreak but also goto aftercoinIDS is faster since + it doesn't make sense to add coins if there are none since it will already do this + in the for loop + */ + int matchedCoins = 0; // remove the "jump from this goto statement to its label is a Microsoft extension [-Wmicrosoft-goto]" + if (currentCoin <= 0) goto aftercoinIDS; + // fun fact the controller icon is always set before this one for (auto child : CCArrayExt(m_coinsToAnimate)) { - for (int i = 1; i < currentCoin; i++) { - if (child->getID().empty() && child->getPosition() == coinPos[i - 1]) { + for (int i = 0; i < currentCoin; i++) { + if (child->getID().empty() && child->getPosition() == coinPos[i]) { child->setID(fmt::format("coin-{}-sprite", i)); + matchedCoins++; + break; } } } - + // idx should be kept the same + if (matchedCoins >= currentCoin) goto aftercoinIDS; + + // idx is after all the other ids, controller icons are always set after these for some reason? + for (int fl = idx; fl < mainLayerChildren.size(); fl++) { + auto child = mainLayerChildren[fl]; + for (int i = 0; i < currentCoin; i++) { + if (child->getID().empty() && child->getPosition() == coinPos[i]) { + child->setID(fmt::format("coin-{}-sprite", i)); + idx = fl+1; + matchedCoins++; + if (matchedCoins >= currentCoin) { + goto aftercoinIDS; // i wanted a double break whatever + } + break; // already set a id to this thing + }; + }; + }; + aftercoinIDS: if (PlatformToolbox::isControllerConnected()) { setIDs( m_mainLayer, @@ -154,7 +173,6 @@ using namespace geode::node_ids; ); idx += 2; } - // original code by alphalaneous, adapted to node IDs by raydeeux std::reverse(nodesToMove.begin(), nodesToMove.end()); From 5dbba1d0de74d70e577f4860ac1a0533074c93ad Mon Sep 17 00:00:00 2001 From: Cosmella-v Date: Thu, 6 Aug 2026 18:16:41 +0100 Subject: [PATCH 3/3] Remove the gotos --- src/EndLevelLayer.cpp | 64 ++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/src/EndLevelLayer.cpp b/src/EndLevelLayer.cpp index 887d391..49323a9 100644 --- a/src/EndLevelLayer.cpp +++ b/src/EndLevelLayer.cpp @@ -112,7 +112,7 @@ using namespace geode::node_ids; leaderboardButton->setID("practice-retry-button"); } - int currentCoin = 0; + int currentCoin = 1; // this is so the first id is coin-1 auto mainLayerChildren = CCArrayExt(m_mainLayer->getChildren()); std::vector coinPos; for (auto child : mainLayerChildren) { @@ -128,42 +128,38 @@ using namespace geode::node_ids; } } } - /* - i was using it for a fullbreak but also goto aftercoinIDS is faster since - it doesn't make sense to add coins if there are none since it will already do this - in the for loop - */ - int matchedCoins = 0; // remove the "jump from this goto statement to its label is a Microsoft extension [-Wmicrosoft-goto]" - if (currentCoin <= 0) goto aftercoinIDS; - // fun fact the controller icon is always set before this one - for (auto child : CCArrayExt(m_coinsToAnimate)) { - for (int i = 0; i < currentCoin; i++) { - if (child->getID().empty() && child->getPosition() == coinPos[i]) { - child->setID(fmt::format("coin-{}-sprite", i)); - matchedCoins++; - break; + + if (currentCoin > 1) { + int matchedCoins = 1; + // fun fact the controller icon is always set before this one + for (auto child : CCArrayExt(m_coinsToAnimate)) { + for (int i = 1; i < currentCoin; i++) { + if (child->getID().empty() && child->getPosition() == coinPos[i-1]) { + child->setID(fmt::format("coin-{}-sprite", i)); + matchedCoins++; + break; + } } } - } - // idx should be kept the same - if (matchedCoins >= currentCoin) goto aftercoinIDS; - - // idx is after all the other ids, controller icons are always set after these for some reason? - for (int fl = idx; fl < mainLayerChildren.size(); fl++) { - auto child = mainLayerChildren[fl]; - for (int i = 0; i < currentCoin; i++) { - if (child->getID().empty() && child->getPosition() == coinPos[i]) { - child->setID(fmt::format("coin-{}-sprite", i)); - idx = fl+1; - matchedCoins++; - if (matchedCoins >= currentCoin) { - goto aftercoinIDS; // i wanted a double break whatever - } - break; // already set a id to this thing + // idx should not be kept the same if they are not matching + if (matchedCoins < currentCoin) { + // idx is after all the other ids, controller icons are always set after these for some reason? + for (int fl = idx; fl < mainLayerChildren.size(); fl++) { + if (matchedCoins >= currentCoin) { + break; // escape if finished + }; + auto child = mainLayerChildren[fl]; + for (int i = 1; i < currentCoin; i++) { + if (child->getID().empty() && child->getPosition() == coinPos[i-1]) { + child->setID(fmt::format("coin-{}-sprite", i)); + idx = fl+1; + matchedCoins++; + break; + }; + }; }; - }; - }; - aftercoinIDS: + } + } if (PlatformToolbox::isControllerConnected()) { setIDs( m_mainLayer,