Skip to content

Commit

Permalink
patches: reduce console noise for patches/cheats, verbose with ELF-log
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
avih committed Jan 18, 2015
1 parent 9495b8e commit 6305d8d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
28 changes: 20 additions & 8 deletions pcsx2/Patch.cpp
Expand Up @@ -27,6 +27,10 @@
#include <wx/txtstrm.h>
#include <wx/zipstrm.h>

bool ElfConActive() {
return SysConsole.ELF.IsActive();
}

IniPatch Patch[ MAX_PATCH ];
IniPatch Cheat[ MAX_CHEAT ];

Expand Down Expand Up @@ -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);
Expand All @@ -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());
Expand Down Expand Up @@ -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;
}

Expand All @@ -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
Expand Down Expand Up @@ -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
{
Expand Down
18 changes: 12 additions & 6 deletions pcsx2/gui/AppCoreThread.cpp
Expand Up @@ -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'
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit 6305d8d

Please sign in to comment.