Skip to content

Commit

Permalink
Merge pull request #18775 from hrydgard/gameinfocache-fixes
Browse files Browse the repository at this point in the history
GameInfoCache: Keep properly track of what's already loaded, lots of cleanup
  • Loading branch information
hrydgard authored Jan 28, 2024
2 parents 299f9b9 + a5fafb8 commit f9fff42
Show file tree
Hide file tree
Showing 13 changed files with 310 additions and 277 deletions.
7 changes: 7 additions & 0 deletions Common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
} \
static inline bool operator &(const T &lhs, const T &rhs) { \
return ((int)lhs & (int)rhs) != 0; \
} \
static inline T &operator &= (T &lhs, const T &rhs) { \
lhs = (T)((int)lhs & (int)rhs); \
return lhs; \
} \
static inline T operator ~(const T &rhs) { \
return (T)(~((int)rhs)); \
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions UI/BackgroundAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ void BackgroundAudio::Update() {
return;

// Grab some audio from the current game and play it.
std::shared_ptr<GameInfo> gameInfo = g_gameInfoCache->GetInfo(nullptr, bgGamePath_, GAMEINFO_WANTSND);
if (!gameInfo || gameInfo->pending) {
std::shared_ptr<GameInfo> gameInfo = g_gameInfoCache->GetInfo(nullptr, bgGamePath_, GameInfoFlags::SND);
if (!gameInfo->Ready(GameInfoFlags::SND)) {
// Should try again shortly..
return;
}
Expand Down
7 changes: 3 additions & 4 deletions UI/CwCheatScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ CwCheatScreen::~CwCheatScreen() {
}

bool CwCheatScreen::TryLoadCheatInfo() {
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(nullptr, gamePath_, 0);
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(nullptr, gamePath_, GameInfoFlags::PARAM_SFO);
std::string gameID;
if (info && info->paramSFOLoaded) {
gameID = info->paramSFO.GetValueString("DISC_ID");
} else {
if (!info->Ready(GameInfoFlags::PARAM_SFO)) {
return false;
}
gameID = info->paramSFO.GetValueString("DISC_ID");
if ((info->id.empty() || !info->disc_total)
&& gamePath_.FilePathContainsNoCase("PSP/GAME/")) {
gameID = g_paramSFO.GenerateFakeID(gamePath_);
Expand Down
9 changes: 5 additions & 4 deletions UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ void EmuScreen::bootGame(const Path &filename) {
invalid_ = true;

// We don't want to boot with the wrong game specific config, so wait until info is ready.
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(nullptr, filename, 0);
if (!info || info->pending)
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(nullptr, filename, GameInfoFlags::PARAM_SFO);
if (!info->Ready(GameInfoFlags::PARAM_SFO)) {
return;
}

auto sc = GetI18NCategory(I18NCat::SCREEN);
if (info->fileType == IdentifiedFileType::PSP_DISC_DIRECTORY) {
Expand Down Expand Up @@ -953,11 +954,11 @@ class GameInfoBGView : public UI::InertView {

void Draw(UIContext &dc) override {
// Should only be called when visible.
std::shared_ptr<GameInfo> ginfo = g_gameInfoCache->GetInfo(dc.GetDrawContext(), gamePath_, GAMEINFO_WANTBG);
std::shared_ptr<GameInfo> ginfo = g_gameInfoCache->GetInfo(dc.GetDrawContext(), gamePath_, GameInfoFlags::BG);
dc.Flush();

// PIC1 is the loading image, so let's only draw if it's available.
if (ginfo && ginfo->pic1.texture) {
if (ginfo->Ready(GameInfoFlags::BG) && ginfo->pic1.texture) {
Draw::Texture *texture = ginfo->pic1.texture;
if (texture) {
dc.GetDrawContext()->BindTexture(0, texture);
Expand Down
Loading

0 comments on commit f9fff42

Please sign in to comment.