Skip to content

Commit

Permalink
fix bi autofavoriting level lists
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Aug 19, 2024
1 parent ea51bc8 commit c37be8a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
14 changes: 14 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ void BI_DLL fixLevelLists() {
LLM->m_localLists->removeObject(list);
}
}

log::info("Deleting level lists semi-favorited by incorrectly expecting 2.200 behavior");
auto GLM = GameLevelManager::sharedState();

std::vector<gd::string> toRemove;

auto lists2 = CCDictionaryExt<gd::string, GJLevelList*>(GLM->m_favoriteLists);
for(auto [key,value] : lists2) {
if(!value->m_favorite) toRemove.push_back(key);
}

for(auto key : toRemove) {
GLM->m_favoriteLists->removeObjectForKey(key);
}
}

class BI_DLL $modify(MenuLayer) {
Expand Down
15 changes: 8 additions & 7 deletions src/utils/ServerUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ void ServerUtils::getLevelLists(GJSearchObject* searchObject, std::function<void
}

auto task = s_requests[requestKey].map([callback, key, requestKey, cacheLevels](web::WebResponse* response) {
auto GLM = GameLevelManager::sharedState();

std::unique_lock lock(s_requestsMutex);
s_requests.erase(requestKey);
lock.unlock();
Expand Down Expand Up @@ -145,15 +147,12 @@ void ServerUtils::getLevelLists(GJSearchObject* searchObject, std::function<void
std::stringstream responseStream(responseString);
std::string levelData;
std::string userData;
std::string songData;
std::string pageData;

getline(responseStream, levelData, '#');
getline(responseStream, userData, '#');
getline(responseStream, pageData, '#');

MusicDownloadManager::sharedState()->createSongsInfo(songData, "");

std::stringstream userStream(userData);
std::string currentUser;
while(getline(userStream, currentUser, '|')) {
Expand All @@ -162,7 +161,7 @@ void ServerUtils::getLevelLists(GJSearchObject* searchObject, std::function<void
int userID = std::stoi(info[0]);
int accountID = std::stoi(info[2]);

if(userID > 0) GameLevelManager::sharedState()->storeUserName(userID, accountID, info[1]);
if(userID > 0) GLM->storeUserName(userID, accountID, info[1]);
}

std::stringstream levelStream(levelData);
Expand All @@ -173,11 +172,13 @@ void ServerUtils::getLevelLists(GJSearchObject* searchObject, std::function<void
}

CCArray* levelArray = CCArray::create();
for(auto level : *levels) levelArray->addObject(level);
for(auto level : *levels) {
levelArray->addObject(level);
GLM->updateSavedLevelList(level);
}

GameLevelManager::sharedState()->saveFetchedLevelLists(levelArray);
if(cacheLevels) {
if(key.length() < 255) GameLevelManager::sharedState()->storeSearchResult(levelArray, pageData, key.c_str());
if(key.length() < 255) GLM->storeSearchResult(levelArray, pageData, key.c_str());
else s_cache[key] = levelArray;
}

Expand Down

0 comments on commit c37be8a

Please sign in to comment.