Core: Refactor repeating disc id homebrew code.

This commit is contained in:
Unknown W. Brackets 2017-06-02 20:54:28 -07:00
parent dca75437c3
commit 41b485aa0a
8 changed files with 15 additions and 32 deletions

View file

@ -37,6 +37,14 @@ public:
std::vector<std::string> GetKeys();
std::string GenerateFakeID(std::string filename = "");
std::string GetDiscID() {
const std::string discID = GetValueString("DISC_ID");
if (discID.empty()) {
return GenerateFakeID();
}
return discID;
}
bool ReadSFO(const u8 *paramsfo, size_t size);
bool WriteSFO(u8 **paramsfo, size_t *size);

View file

@ -242,10 +242,7 @@ void CPU_Init() {
// Here we have read the PARAM.SFO, let's see if we need any compatibility overrides.
// Homebrew usually has an empty discID, and even if they do have a disc id, it's not
// likely to collide with any commercial ones.
std::string discID = g_paramSFO.GetValueString("DISC_ID");
if (discID.empty()) {
discID = g_paramSFO.GenerateFakeID();
}
std::string discID = g_paramSFO.GetDiscID();
coreParameter.compat.Load(discID);
Memory::Init();

View file

@ -47,10 +47,7 @@ void TextureReplacer::Init() {
}
void TextureReplacer::NotifyConfigChanged() {
gameID_ = g_paramSFO.GetValueString("DISC_ID");
if (gameID_.empty()) {
gameID_ = g_paramSFO.GenerateFakeID();
}
gameID_ = g_paramSFO.GetDiscID();
enabled_ = g_Config.bReplaceTextures || g_Config.bSaveNewTextures;
if (enabled_) {

View file

@ -119,10 +119,6 @@ FramebufferManagerCommon::~FramebufferManagerCommon() {
}
void FramebufferManagerCommon::Init() {
std::string gameId = g_paramSFO.GetValueString("DISC_ID");
if (gameId.empty()) {
gameId = g_paramSFO.GenerateFakeID();
}
BeginFrame();
}

View file

@ -168,10 +168,7 @@ GPU_GLES::GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
textureCacheGL_->NotifyConfigChanged();
// Load shader cache.
std::string discID = g_paramSFO.GetValueString("DISC_ID");
if (discID.empty()) {
discID = g_paramSFO.GenerateFakeID();
}
std::string discID = g_paramSFO.GetDiscID();
if (discID.size()) {
File::CreateFullPath(GetSysDirectory(DIRECTORY_APP_CACHE));
shaderCachePath_ = GetSysDirectory(DIRECTORY_APP_CACHE) + "/" + discID + ".glshadercache";

View file

@ -1336,10 +1336,7 @@ UI::EventReturn DeveloperToolsScreen::OnLoadLanguageIni(UI::EventParams &e) {
}
UI::EventReturn DeveloperToolsScreen::OnOpenTexturesIniFile(UI::EventParams &e) {
std::string gameID = g_paramSFO.GetValueString("DISC_ID");
if (gameID.empty()) {
gameID = g_paramSFO.GenerateFakeID();
}
std::string gameID = g_paramSFO.GetDiscID();
std::string texturesDirectory = GetSysDirectory(DIRECTORY_TEXTURES) + gameID + "/";
bool enabled_ = !gameID.empty();
if (enabled_) {

View file

@ -713,10 +713,7 @@ void TakeScreenshot() {
// First, find a free filename.
int i = 0;
std::string gameId = g_paramSFO.GetValueString("DISC_ID");
if (gameId.empty()) {
gameId = g_paramSFO.GenerateFakeID();
}
std::string gameId = g_paramSFO.GetDiscID();
char filename[2048];
while (i < 10000){

View file

@ -320,10 +320,7 @@ void GamePauseScreen::CreateViews() {
root_->SetDefaultFocusView(continueChoice);
continueChoice->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
std::string gameId = g_paramSFO.GetValueString("DISC_ID");
if (gameId.empty()) {
gameId = g_paramSFO.GenerateFakeID();
}
std::string gameId = g_paramSFO.GetDiscID();
if (g_Config.hasGameConfig(gameId)) {
rightColumnItems->Add(new Choice(pa->T("Game Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings);
rightColumnItems->Add(new Choice(pa->T("Delete Game Config")))->OnClick.Handle(this, &GamePauseScreen::OnDeleteConfig);
@ -424,10 +421,7 @@ void GamePauseScreen::CallbackDeleteConfig(bool yes)
UI::EventReturn GamePauseScreen::OnCreateConfig(UI::EventParams &e)
{
std::string gameId = g_paramSFO.GetValueString("DISC_ID");
if (gameId.empty()) {
gameId = g_paramSFO.GenerateFakeID();
}
std::string gameId = g_paramSFO.GetDiscID();
g_Config.createGameConfig(gameId);
g_Config.changeGameSpecific(gameId);
g_Config.saveGameConfig(gameId);