CwCheats: Retry looking in g_gameInfoCache until the data is there.

Replaces #18733

Fixes at least one instance of #18694, don't know if there are other
causes.
This commit is contained in:
Henrik Rydgård committed 2024-01-20 20:07:38 +01:00
1 parent 97647a561d
commit f1d19cd736
3 files changed
+21 -6

No files matched your search

+11 -2
View File
@@ -47,11 +47,13 @@ CwCheatScreen::~CwCheatScreen() {
delete engine_;
}
void CwCheatScreen::LoadCheatInfo() {
bool CwCheatScreen::TryLoadCheatInfo() {
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(nullptr, gamePath_, 0);
std::string gameID;
if (info && info->paramSFOLoaded) {
gameID = info->paramSFO.GetValueString("DISC_ID");
} else {
return false;
}
if ((info->id.empty() || !info->disc_total)
&& gamePath_.FilePathContainsNoCase("PSP/GAME/")) {
@@ -76,6 +78,7 @@ void CwCheatScreen::LoadCheatInfo() {
// Let's also trigger a reload, in case it changed.
g_Config.bReloadCheats = true;
return true;
}
void CwCheatScreen::CreateViews() {
@@ -86,7 +89,7 @@ void CwCheatScreen::CreateViews() {
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
LoadCheatInfo();
TryLoadCheatInfo(); // in case the info is already in cache.
Margins actionMenuMargins(50, -15, 15, 0);
LinearLayout *leftColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(400, FILL_PARENT));
@@ -134,6 +137,12 @@ void CwCheatScreen::CreateViews() {
}
void CwCheatScreen::update() {
if (gameID_.empty()) {
if (TryLoadCheatInfo()) {
RecreateViews();
}
}
if (fileCheckCounter_++ >= FILE_CHECK_FRAME_INTERVAL && engine_) {
// Check if the file has changed. If it has, we'll reload.
std::string str;