Skip to content

Commit

Permalink
add fix for mac level lists bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Aug 4, 2024
1 parent 65ab8eb commit 77dcefc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ void BI_DLL finishLoadingManagers() {
BetterInfoCache::sharedState()->finishLoading();
}

void BI_DLL fixLevelLists() {
log::info("Deleting level lists created by Mac bug");

auto LLM = LocalLevelManager::sharedState();
auto lists = CCArrayExt<GJLevelList*>(LLM->m_localLists);

std::vector<GJLevelList*> blanks;

for(auto list : lists) {
if(list->m_listID == 0 && list->m_listName.empty() && list->m_levels.empty() && list->m_levelsString.empty()) {
blanks.push_back(list);
}
}

if(blanks.size() > 10) {
for(auto list : blanks) {
LLM->m_localLists->removeObject(list);
}
}
}

class BI_DLL $modify(MenuLayer) {
bool init() {
if(!MenuLayer::init()) return false;
Expand All @@ -36,6 +57,7 @@ class BI_DLL $modify(MenuLayer) {
if(!managersLoaded) {
managersLoaded = true;
finishLoadingManagers();
fixLevelLists();
}

return true;
Expand Down

0 comments on commit 77dcefc

Please sign in to comment.