Skip to content

Commit 2db8732

Browse files
committed
v1.1.1
1 parent d6b5cca commit 2db8732

15 files changed

Lines changed: 63 additions & 117 deletions

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v1.1.1
2+
3+
* (Hopefully) Finally fixed a bug where levels would be mistakenly marked as completed
4+
15
# v1.1.0
26

37
Major Additions/Changes:

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"ios": "2.2081",
77
"mac": "2.2081"
88
},
9-
"version": "v1.1.0",
9+
"version": "v1.1.1",
1010
"id": "minemaker0430.gddp_integration",
1111
"name": "GDDP - Demon Progression",
1212
"developer": "ItsMochaTheOtter",

src/DPAchievementManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
#include "menus/DPLayer.hpp"
66
#include "popups/StatsPopup.hpp"
77
#include "DPUtils.hpp"
8-
#include "popups/dev/VerificationPopup.hpp"
98

109
using namespace geode::prelude;
1110

1211
$on_game(Loaded) {
12+
DPUtils::verifyCompletedLevels();
1313
DPAchievementManager::get();
1414
}
1515

src/DPUtils.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,46 @@ bool DPUtils::containsString(std::vector<std::string> v, std::string t) {
6767

6868
bool DPUtils::containsJson(std::vector<matjson::Value> v, matjson::Value t) {
6969
return (std::find(v.begin(), v.end(), t) != v.end());
70+
};
71+
72+
void DPUtils::verifyCompletedLevels() {
73+
auto data = Mod::get()->getSavedValue<matjson::Value>("cached-data");
74+
auto completedLvls = Mod::get()->getSavedValue<std::vector<int>>("completed-levels");
75+
76+
// check completed levels in player's save file
77+
auto glm = GameLevelManager::sharedState();
78+
auto glmCompletedLvls = glm->getCompletedLevels(false)->asExt();
79+
80+
// make sure any level that should be there is there
81+
if (glmCompletedLvls.size() > 0) {
82+
for (auto i : glmCompletedLvls) {
83+
auto lvl = static_cast<GJGameLevel*>(i);
84+
auto lvlID = lvl->m_levelID.value();
85+
86+
if (
87+
data["level-data"].contains(std::to_string(lvlID)) &&
88+
lvl->getNormalPercent() >= 100 &&
89+
!DPUtils::containsInt(completedLvls, lvlID)
90+
) {
91+
completedLvls.push_back(lvlID);
92+
}
93+
94+
if (
95+
data["level-data"].contains(std::to_string(lvlID)) &&
96+
lvl->getNormalPercent() < 100 &&
97+
DPUtils::containsInt(completedLvls, lvlID)
98+
) {
99+
completedLvls.erase(DPUtils::findInt(completedLvls, lvlID));
100+
}
101+
}
102+
}
103+
104+
// remove any levels that shouldn't be there
105+
for (auto lvlID : completedLvls) {
106+
if (!data["level-data"].contains(std::to_string(lvlID))) {
107+
completedLvls.erase(DPUtils::findInt(completedLvls, lvlID));
108+
}
109+
}
110+
111+
Mod::get()->setSavedValue<std::vector<int>>("completed-levels", completedLvls);
70112
};

src/DPUtils.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ class DPUtils {
1919
static bool containsInt(std::vector<int>, int);
2020
static bool containsString(std::vector<std::string>, std::string);
2121
static bool containsJson(std::vector<matjson::Value>, matjson::Value);
22+
23+
static void verifyCompletedLevels();
2224
};

src/RecommendedUtils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ above for that skill. its very unlikely that anyone will encounter this scenario
5454
using namespace geode::prelude;
5555

5656
void RecommendedUtils::validateLevels() {
57+
DPUtils::verifyCompletedLevels();
58+
5759
auto data = Mod::get()->getSavedValue<matjson::Value>("cached-data");
5860
auto recommendations = Mod::get()->getSavedValue<matjson::Value>("recommended-levels");
5961
auto completedLvls = Mod::get()->getSavedValue<std::vector<int>>("completed-levels");

src/RouletteUtils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ std::vector<bool> RouletteUtils::fromFlags(std::string flags) {
6868
}
6969

7070
std::vector<int> RouletteUtils::setupLevels(std::vector<matjson::Value> packs, std::string settings, int randomSeed) {
71+
72+
DPUtils::verifyCompletedLevels();
7173

7274
auto settingsBools = fromFlags(settings);
7375
auto completedFlag = settingsBools[2];

src/XPUtils.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -61,48 +61,6 @@ const matjson::Value XPUtils::skills = matjson::makeObject({
6161
})}
6262
});
6363

64-
/*const std::vector<std::string> XPUtils::skillIDs = { "chokepoints", "duals", "fastPaced", "cps", "memory", "nerve", "ship", "swing", "timings", "wave" };
65-
66-
const std::map<std::string, std::string> skillNames = {
67-
{"chokepoints", "Chokepoints"},
68-
{"duals", "Duals"},
69-
{"fastPaced", "Fast Paced"},
70-
{"cps", "High CPS"},
71-
{"memory", "Memory/Learny"},
72-
{"nerve", "Nerve Control"},
73-
{"ship", "Ship"},
74-
{"swing", "Swing"},
75-
{"timings", "Timings"},
76-
{"wave", "Wave"}
77-
};
78-
79-
const std::map<std::string, CCPoint> skillPositions = {
80-
{"chokepoints", {-105.f, 15.f}},
81-
{"duals", {-105.f, -15.f}},
82-
{"fastPaced", {-105.f, -45.f}},
83-
{"cps", {-105.f, -75.f}},
84-
{"memory", {-105.f, -105.f}},
85-
{"nerve", {105.f, 15.f}},
86-
{"ship", {105.f, -15.f}},
87-
{"swing", {105.f, -45.f}},
88-
{"timings", {105.f, -75.f}},
89-
{"wave", {105.f, -105.f}}
90-
};
91-
92-
const std::map<std::string, ccColor3B> skillColors = {
93-
{"chokepoints", ccColor3B{255, 0, 0}},
94-
{"duals", ccColor3B{255, 128, 0}},
95-
{"fastPaced", ccColor3B{255, 255, 0}},
96-
{"cps", ccColor3B{128, 255, 0}},
97-
{"memory", ccColor3B{0, 255, 0}},
98-
{"nerve", ccColor3B{0, 255, 128}},
99-
{"ship", ccColor3B{0, 255, 255}},
100-
{"swing", ccColor3B{0, 128, 255}},
101-
{"timings", ccColor3B{0, 0, 255}},
102-
{"wave", ccColor3B{128, 0, 255}}
103-
};*/
104-
105-
//const std::vector<int> FIBONACCI = {1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181};
10664
const float scaling = (1.f / 500.f);
10765

10866
void XPUtils::getMaxLevels() {

src/hooks/LevelCell.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,6 @@ class $modify(DemonProgression, LevelCell) {
137137
if (data["level-data"].contains(levelID)) {
138138
gddpDiff = data["level-data"][levelID]["difficulty"].as<int>().unwrapOr(0);
139139
skillsets = data["level-data"][levelID]["skillsets"].as<std::vector<std::string>>().unwrapOrDefault();
140-
141-
if (this->m_level->m_normalPercent.value() >= 100) {
142-
auto completedLvls = Mod::get()->getSavedValue<std::vector<int>>("completed-levels");
143-
144-
if (!DPUtils::containsInt(completedLvls, this->m_level->m_levelID.value())) {
145-
completedLvls.insert(completedLvls.begin(), this->m_level->m_levelID.value());
146-
Mod::get()->setSavedValue<std::vector<int>>("completed-levels", completedLvls);
147-
}
148-
}
149140
}
150141

151142
//skillset badges

src/hooks/LevelInfoLayer.cpp

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,6 @@ class $modify(DemonProgression, LevelInfoLayer) {
172172
if (data["level-data"].contains(levelID)) {
173173
gddpDiff = data["level-data"][levelID]["difficulty"].as<int>().unwrapOr(0);
174174
skillsets = data["level-data"][levelID]["skillsets"].as<std::vector<std::string>>().unwrapOrDefault();
175-
176-
if (this->m_level->m_normalPercent.value() == 100) {
177-
auto completedLvls = Mod::get()->getSavedValue<std::vector<int>>("completed-levels");
178-
179-
if (!DPUtils::containsInt(completedLvls, this->m_level->m_levelID.value())) {
180-
completedLvls.insert(completedLvls.begin(), this->m_level->m_levelID.value());
181-
Mod::get()->setSavedValue<std::vector<int>>("completed-levels", completedLvls);
182-
}
183-
}
184175
}
185176

186177
//skillset badges
@@ -387,7 +378,8 @@ class $modify(DemonProgression, LevelInfoLayer) {
387378
}
388379
}
389380
}
390-
381+
382+
DPUtils::verifyCompletedLevels();
391383
}
392384

393385
return true;
@@ -396,34 +388,7 @@ class $modify(DemonProgression, LevelInfoLayer) {
396388
void onBack(CCObject* sender) {
397389
LevelInfoLayer::onBack(sender);
398390

399-
auto data = Mod::get()->getSavedValue<matjson::Value>("cached-data");
400-
401-
//check for errors
402-
auto jsonCheck = checkJson(data, "");
403-
404-
if (!jsonCheck.ok()) {
405-
log::info("Something went wrong validating the GDDP list data.");
406-
407-
return;
408-
}
409-
410-
bool inGDDP = Mod::get()->getSavedValue<bool>("in-gddp");
411-
412-
if (Mod::get()->getSettingValue<bool>("show-outside-menus")) inGDDP = true;
413-
414-
//if gauntlet level, return
415-
if (this->m_level->m_gauntletLevel || this->m_level->m_gauntletLevel2) return;
416-
417-
if (inGDDP && data["level-data"].contains(std::to_string(this->m_level->m_levelID.value()))) {
418-
if (this->m_level->m_normalPercent.value() == 100) {
419-
auto completedLvls = Mod::get()->getSavedValue<std::vector<int>>("completed-levels");
420-
421-
if (!DPUtils::containsInt(completedLvls, this->m_level->m_levelID.value())) {
422-
completedLvls.insert(completedLvls.begin(), this->m_level->m_levelID.value());
423-
Mod::get()->setSavedValue<std::vector<int>>("completed-levels", completedLvls);
424-
}
425-
}
426-
}
391+
DPUtils::verifyCompletedLevels();
427392

428393
return;
429394
}

0 commit comments

Comments
 (0)