Skip to content

Commit cd9880b

Browse files
committed
fix that damn bug
1 parent 5adc43a commit cd9880b

File tree

6 files changed

+52
-11
lines changed

6 files changed

+52
-11
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# DeathScreenTweaks Changelog
2+
## v1.8.1
3+
- Use sprites for the coins shown in `Show Collected Coins`.
4+
- To restore past behavior, toggle `Use ASCII Art for Coins Instead`.
5+
- Fix a rather mission-critical bug related to finding/locating the "New Best!" node.
26
## v1.8.0
37
- Added iOS JIT-less support.
48
- Added `Customize Position` and `Customize Rotation`.

mod.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,13 @@
240240
},
241241
"showCollectedCoins": {
242242
"name": "Show Collected Coins",
243-
"description": "Shows the coins you had collected during an attempt before dying.\n\nColor of the label adapts to the coin type.",
243+
"description": "Shows the coins you had collected during an attempt before dying.\n\nIf \"Use ASCII Art for Coins Instead\" is enabled, the color of the label adapts to the coin type.",
244+
"type": "bool",
245+
"default": false
246+
},
247+
"useASCIIArtForCoins": {
248+
"name": "Use ASCII Art for Coins Instead",
249+
"description": "Use `[C]` and `[ ]` to indicate collected and uncollected coins instead of in-game sprites.",
244250
"type": "bool",
245251
"default": false
246252
},

src/Manager.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,23 @@ class Manager {
6161
return instance;
6262
}
6363

64+
// something or someone has forced my hand to include this code in this mod of all places... ugh.
65+
// if only robtop made a unique fucking class for "New Best!" so i wouldnt have to suffer rn. >:(
66+
// code yoinked from devtools as always
67+
static std::string getNodeName(CCObject* node) {
68+
#ifdef GEODE_IS_WINDOWS
69+
return typeid(*node).name() + 6;
70+
#else
71+
std::string ret;
72+
73+
int status = 0;
74+
auto demangle = abi::__cxa_demangle(typeid(*node).name(), 0, 0, &status);
75+
if (status == 0) {
76+
ret = demangle;
77+
}
78+
free(demangle);
79+
80+
return ret;
81+
#endif
82+
}
6483
};

src/PlayLayer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class $modify(MyPlayLayer, PlayLayer) {
163163
}
164164
}
165165
void findAndModifyTheNewBestNode() {
166-
if (!getModBool("enabled") || !m_level || m_level->isPlatformer() || m_isPlatformer) return;
166+
if (!getModBool("enabled") || !m_level || m_level->isPlatformer() || m_isPlatformer) return log::info("[MyPlayLayer::findAndModifyTheNewBestNode] aborting mission");
167167

168168
CCNode* newBestNodeProbably = nullptr;
169169
bool hasOrbsLabel = false;
@@ -194,13 +194,14 @@ class $modify(MyPlayLayer, PlayLayer) {
194194
if (!theLastCCNode || theLastCCNode == this->m_uiLayer) continue; // skip UILayer
195195
if (theLastCCNode->getZOrder() != 100) continue;
196196
if (theLastCCNode->getChildrenCount() < 2) continue;
197+
if (Manager::getNodeName(theLastCCNode) != "CCNode" && Manager::getNodeName(theLastCCNode) != "cocos2d::CCNode") continue;
197198
if (getModBool("noVisibleNewBest")) return theLastCCNode->setVisible(false);
198199
if (!isFromZilkoMod) newBestNodeProbably = theLastCCNode;
199200
else theLastCCNode->setVisible(false);
200201
break;
201202
}
202203

203-
if (!newBestNodeProbably || newBestNodeProbably->getUserObject("modified-already"_spr)) return;
204+
if (!newBestNodeProbably || newBestNodeProbably->getUserObject("modified-already"_spr)) return log::info("[MyPlayLayer::findAndModifyTheNewBestNode] found node already");
204205
newBestNodeProbably->setUserObject("modified-already"_spr, CCBool::create(true));
205206

206207
if (!isFromZilkoMod) MyPlayLayer::applyNodeTraitsCustomization(newBestNodeProbably, hasDiamondsOrOrbs);

src/PlayerObject.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ class $modify(MyPlayerObject, PlayerObject) {
1616
}
1717
void playerDestroyed(bool p0) {
1818
PlayerObject::playerDestroyed(p0);
19-
if (!m_gameLayer || m_gameLayer == LevelEditorLayer::get()) return;
19+
if (!this->m_gameLayer || this->m_gameLayer == LevelEditorLayer::get()) return log::info("[PlayerObject::playerDestroyed] returned because of if (!this->m_gameLayer || this->m_gameLayer == LevelEditorLayer::get())");
2020

2121
if (!getBool("enabled")) return;
2222
const auto pl = PlayLayer::get();
23-
if (!pl || this != pl->m_player1) return;
23+
if (!pl || this->m_gameLayer != pl || this != pl->m_player1) return log::info("[PlayerObject::playerDestroyed] returned because of if (!pl || this->m_gameLayer != pl || this != pl->m_player1)");
2424
const auto theLevel = pl->m_level;
25-
if (!theLevel || theLevel->isPlatformer()) return;
26-
if (this == pl->m_player2 && theLevel->m_twoPlayerMode) return;
25+
if (!theLevel || theLevel->isPlatformer()) return log::info("[PlayerObject::playerDestroyed] returned because of if (!theLevel || theLevel->isPlatformer())");
26+
if (this == pl->m_player2 && theLevel->m_twoPlayerMode) return log::info("[PlayerObject::playerDestroyed] returned because of if (this == pl->m_player2 && theLevel->m_twoPlayerMode)");
27+
if (this == pl->m_player2 && pl->m_gameState.m_isDualMode) return log::info("[PlayerObject::playerDestroyed] returned because of if (this == pl->m_player2 && pl->m_gameState.m_isDualMode)");
2728

2829
Manager* manager = Manager::getSharedInstance();
2930
const float plCurrentPercent = pl->getCurrentPercent();
@@ -36,10 +37,16 @@ class $modify(MyPlayerObject, PlayerObject) {
3637
if (!pl->m_isTestMode && !pl->m_isPracticeMode && getBool("alwaysNewBest") && !isNewBest) qualifiedToShowAFakeNewBest = true;
3738
if (getBool("alwaysNewBestPlaytest") && pl->m_isTestMode) qualifiedToShowAFakeNewBest = true;
3839
if (getBool("alwaysNewBestPractice") && pl->m_isPracticeMode) qualifiedToShowAFakeNewBest = true;
39-
log::info("pl->getCurrentPercentInt() <= pl->m_level->m_normalPercent.value(): {}", pl->getCurrentPercentInt() <= pl->m_level->m_normalPercent.value());
40-
log::info("pl->getCurrentPercentInt(): {}", pl->getCurrentPercentInt());
41-
log::info("pl->m_level->m_normalPercent.value(): {}", pl->m_level->m_normalPercent.value());
42-
if (qualifiedToShowAFakeNewBest) pl->showNewBest(false, 0, 0, false, false, false);
40+
log::info("[PlayerObject::playerDestroyed] pl->getCurrentPercentInt() <= pl->m_level->m_normalPercent.value(): {}", pl->getCurrentPercentInt() <= pl->m_level->m_normalPercent.value());
41+
log::info("[PlayerObject::playerDestroyed] pl->getCurrentPercentInt(): {}", pl->getCurrentPercentInt());
42+
log::info("[PlayerObject::playerDestroyed] pl->m_level->m_normalPercent.value(): {}", pl->m_level->m_normalPercent.value());
43+
log::info("[PlayerObject::playerDestroyed] !pl->m_isTestMode && !pl->m_isPracticeMode && getBool(\"alwaysNewBest\") && !isNewBest: {}", !pl->m_isTestMode && !pl->m_isPracticeMode && getBool("alwaysNewBest") && !isNewBest);
44+
log::info("[PlayerObject::playerDestroyed] getBool(\"alwaysNewBestPlaytest\") && pl->m_isTestMode: {}", getBool("alwaysNewBestPlaytest") && pl->m_isTestMode);
45+
log::info("[PlayerObject::playerDestroyed] getBool(\"alwaysNewBestPractice\") && pl->m_isPracticeMode: {}", getBool("alwaysNewBestPractice") && pl->m_isPracticeMode);
46+
if (qualifiedToShowAFakeNewBest) {
47+
log::info("showing fake new best");
48+
pl->showNewBest(false, 0, 0, false, false, false);
49+
}
4350
const auto fmod = FMODAudioEngine::get();
4451
if (!fmod) return;
4552

src/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,8 @@ migration failed, womp womp)";
8080
listenForSettingChanges("custom", [](bool unusedVar) {
8181
managerReset();
8282
});
83+
84+
listenForSettingChanges("logging", [](bool newLogging) {
85+
Mod::get()->setLoggingEnabled(newLogging);
86+
});
8387
}

0 commit comments

Comments
 (0)