From 6305d8d61e94b3ae9fb8cbe9671642bde9bf133e Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Mon, 19 Jan 2015 01:00:08 +0200 Subject: [PATCH] patches: reduce console noise for patches/cheats, verbose with ELF-log 1. When changing settings, such as aspect ratio, patches message was spamming the console, now they don't. 2. Added more verbose patches messages when ELF-log is enabled at the console. These messages now show whenever patches/cheats are applied, including when changing settings such as aspect ratio. 3. When rebooting the same game again, some of the cheats messages were not displayed since it's the same CRC and the logic thought it should remain quiet, now verbose gets reset on boot which will show all patches messages correctly. 4. Errors/warnings stay the same and not afected by this change. --- pcsx2/Patch.cpp | 28 ++++++++++++++++++++-------- pcsx2/gui/AppCoreThread.cpp | 18 ++++++++++++------ 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/pcsx2/Patch.cpp b/pcsx2/Patch.cpp index fbf3519cb3..cab0015df7 100644 --- a/pcsx2/Patch.cpp +++ b/pcsx2/Patch.cpp @@ -27,6 +27,10 @@ #include #include +bool ElfConActive() { + return SysConsole.ELF.IsActive(); +} + IniPatch Patch[ MAX_PATCH ]; IniPatch Cheat[ MAX_CHEAT ]; @@ -197,14 +201,17 @@ static int LoadCheatsFiles(const wxDirName& folderName, wxString& fileSpec, cons bool found = dir.GetFirst(&buffer, L"*", wxDIR_FILES); while (found) { if (buffer.Upper().Matches(fileSpec.Upper())) { - Console.WriteLn(Color_Green, L"Found %s file: '%s'", WX_STR(friendlyName), WX_STR(buffer)); + if (ElfConActive()) + Console.WriteLn(Color_Green, L"Found %s file: '%s'", WX_STR(friendlyName), WX_STR(buffer)); int before = cheatnumber; f.Open(Path::Combine(dir.GetName(), buffer)); inifile_process(f); f.Close(); int loaded = cheatnumber - before; - Console.WriteLn((loaded ? Color_Green : Color_Gray), L"Loaded %d %s from '%s' at '%s'", - loaded, WX_STR(friendlyName), WX_STR(buffer), WX_STR(folderName.ToString())); + if (ElfConActive()) { + Console.WriteLn((loaded ? Color_Green : Color_Gray), L"Loaded %d %s from '%s' at '%s'", + loaded, WX_STR(friendlyName), WX_STR(buffer), WX_STR(folderName.ToString())); + } numberFoundCheatsFiles ++; } found = dir.GetNext(&buffer); @@ -230,8 +237,10 @@ int LoadCheatsFromZip(wxString gameCRC, const wxString& cheatsArchiveFilename) { wxString name = entry->GetName(); name.MakeUpper(); if (name.Find(gameCRC) == 0 && name.Find(L".PNACH")+6u == name.Length()) { - Console.WriteLn(Color_Green, L"Loading patch '%s' from archive '%s'", - WX_STR(entry->GetName()), WX_STR(cheatsArchiveFilename)); + if (ElfConActive()) { + Console.WriteLn(Color_Green, L"Loading patch '%s' from archive '%s'", + WX_STR(entry->GetName()), WX_STR(cheatsArchiveFilename)); + } wxTextInputStream pnach(zip); while (!zip.Eof()) { inifile_processString(pnach.ReadLine()); @@ -262,7 +271,8 @@ int LoadCheats(wxString name, const wxDirName& folderName, const wxString& frien Console.WriteLn(Color_Gray, L"Not found %s file: %s", WX_STR(friendlyName), WX_STR(pathName)); } - Console.WriteLn((loaded ? Color_Green : Color_Gray), L"Overall %d %s loaded", loaded, WX_STR(friendlyName)); + if (ElfConActive()) + Console.WriteLn((loaded ? Color_Green : Color_Gray), L"Overall %d %s loaded", loaded, WX_STR(friendlyName)); return loaded; } @@ -285,7 +295,8 @@ namespace PatchFunc { void comment( const wxString& text1, const wxString& text2 ) { - Console.WriteLn( L"comment: " + text2 ); + if (ElfConActive()) + Console.WriteLn(L"comment: " + text2); } struct PatchPieces @@ -313,7 +324,8 @@ namespace PatchFunc // (translated) messages for display in a popup window then we'll have to upgrade the // exception a little bit. - DevCon.WriteLn(cmd + L" " + param); + if (ElfConActive()) + Console.WriteLn(cmd + L" " + param); try { diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index 4243a3bf45..075e8ec849 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -287,13 +287,14 @@ static int loadGameSettings(Pcsx2Config& dest, const Game_Data& game, bool verbo return gf; } +// Used to track the current game serial/id, and used to disable verbose logging of +// applied patches if the game info hasn't changed. (avoids spam when suspending/resuming +// or using TAB or other things), but gets verbose again when booting (even if the same game). +// File scope since it gets reset externally when rebooting +static wxString curGameKey; + void AppCoreThread::ApplySettings( const Pcsx2Config& src ) { - // Used to track the current game serial/id, and used to disable verbose logging of - // applied patches if the game info hasn't changed. (avoids spam when suspending/resuming - // or using TAB or other things). - static wxString curGameKey; - // 'fixup' is the EmuConfig we're going to upload to the emulator, which very well may // differ from the user-configured EmuConfig settings. So we make a copy here and then // we apply the commandline overrides and database gamefixes, and then upload 'fixup' @@ -397,7 +398,8 @@ void AppCoreThread::ApplySettings( const Pcsx2Config& src ) wxString cheats_ws_archive = Path::Combine(PathDefs::GetProgramDataDir(), wxFileName(L"cheats_ws.zip")); if (numberDbfCheatsLoaded = LoadCheatsFromZip(gameCRC, cheats_ws_archive)) { - Console.WriteLn(Color_Green, "(Wide Screen Cheats DB) Patches Loaded: %d", numberDbfCheatsLoaded); + if (verbose || SysConsole.ELF.IsActive()) + Console.WriteLn(Color_Green, "(Wide Screen Cheats DB) Patches Loaded: %d", numberDbfCheatsLoaded); gameWsHacks.Printf(L" [%d widescreen hacks]", numberDbfCheatsLoaded); } } @@ -482,6 +484,10 @@ void AppCoreThread::VsyncInThread() void AppCoreThread::GameStartingInThread() { + // Make AppCoreThread::ApplySettings get verbose again even if we're booting + // the same game, by making it think that the current CRC is a new one. + curGameKey = L""; + // Simulate a Close/Resume, so that settings get re-applied and the database // lookups and other game-based detections are done.