patches: unify patch application verbosity

PCSX2 applies patches from several sources: GameIndex.dbf, cheats folder,
widescreen patches folder and widescreen patches zip (cheats_ws.zip).

all these patche sources are typically applied whenever any kind of
configuration changes (e.g. aspect ratio etc), depending on config.

typically we want to display all this info at the console/log only on boot,
unless we're in Devel mode or if the user enables the verbose console.

this patch unifies all the verbosity related prints to use PatchesCon, where
this object is controlled according to the conditions (devel mode, boot time,
console mode).

it replaces passing around a "verbose" and includes some more prints which did
not adhere to this policy earlier (e.g. the patches lines were only printed
if verbose console was enabled - now they also print on boot).

warnings and errors are unmodified and always print to the console.
This commit is contained in:
Avi Halachmi (:avih) 2015-02-21 15:59:36 +02:00
parent 330d14941f
commit 56b2c009cd
3 changed files with 39 additions and 20 deletions

View File

@ -197,13 +197,13 @@ 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())) {
DevCon.WriteLn(Color_Green, L"Found %s file: '%s'", WX_STR(friendlyName), WX_STR(buffer));
PatchesCon->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;
DevCon.WriteLn((loaded ? Color_Green : Color_Gray), L"Loaded %d %s from '%s' at '%s'",
PatchesCon->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 ++;
}
@ -230,15 +230,14 @@ 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()) {
DevCon.WriteLn(Color_Green, L"Loading patch '%s' from archive '%s'",
WX_STR(entry->GetName()), WX_STR(cheatsArchiveFilename));
PatchesCon->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());
}
}
}
return cheatnumber - before;
}
@ -259,10 +258,10 @@ int LoadCheats(wxString name, const wxDirName& folderName, const wxString& frien
// This check only tests the default cheats folder, so the message it produces is possibly misleading.
if (folderName.ToString().IsSameAs(PathDefs::GetCheats().ToString()) && numberFoundCheatsFiles == 0) {
wxString pathName = Path::Combine(folderName, name.MakeUpper() + L".pnach");
Console.WriteLn(Color_Gray, L"Not found %s file: %s", WX_STR(friendlyName), WX_STR(pathName));
PatchesCon->WriteLn(Color_Gray, L"Not found %s file: %s", WX_STR(friendlyName), WX_STR(pathName));
}
DevCon.WriteLn((loaded ? Color_Green : Color_Gray), L"Overall %d %s loaded", loaded, WX_STR(friendlyName));
PatchesCon->WriteLn((loaded ? Color_Green : Color_Gray), L"Overall %d %s loaded", loaded, WX_STR(friendlyName));
return loaded;
}
@ -285,7 +284,7 @@ namespace PatchFunc
{
void comment( const wxString& text1, const wxString& text2 )
{
DevCon.WriteLn(L"comment: " + text2);
PatchesCon->WriteLn(L"comment: " + text2);
}
struct PatchPieces
@ -313,7 +312,7 @@ 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);
PatchesCon->WriteLn(cmd + L" " + param);
try
{

View File

@ -70,3 +70,4 @@ extern void ApplyPatch(int place = 1);
extern void ApplyCheat(int place = 1);
extern void _ApplyPatch(IniPatch *p);
extern const IConsoleWriter *PatchesCon;

View File

@ -213,7 +213,7 @@ void AppCoreThread::OnPause()
// Load Game Settings found in database
// (game fixes, round modes, clamp modes, etc...)
// Returns number of gamefixes set
static int loadGameSettings(Pcsx2Config& dest, const Game_Data& game, bool verbose = true) {
static int loadGameSettings(Pcsx2Config& dest, const Game_Data& game) {
if( !game.IsOk() ) return 0;
int gf = 0;
@ -223,7 +223,7 @@ static int loadGameSettings(Pcsx2Config& dest, const Game_Data& game, bool verbo
SSE_RoundMode eeRM = (SSE_RoundMode)game.getInt("eeRoundMode");
if (EnumIsValid(eeRM))
{
if(verbose) Console.WriteLn("(GameDB) Changing EE/FPU roundmode to %d [%s]", eeRM, EnumToString(eeRM));
PatchesCon->WriteLn("(GameDB) Changing EE/FPU roundmode to %d [%s]", eeRM, EnumToString(eeRM));
dest.Cpu.sseMXCSR.SetRoundMode(eeRM);
++gf;
}
@ -234,7 +234,7 @@ static int loadGameSettings(Pcsx2Config& dest, const Game_Data& game, bool verbo
SSE_RoundMode vuRM = (SSE_RoundMode)game.getInt("vuRoundMode");
if (EnumIsValid(vuRM))
{
if(verbose) Console.WriteLn("(GameDB) Changing VU0/VU1 roundmode to %d [%s]", vuRM, EnumToString(vuRM));
PatchesCon->WriteLn("(GameDB) Changing VU0/VU1 roundmode to %d [%s]", vuRM, EnumToString(vuRM));
dest.Cpu.sseVUMXCSR.SetRoundMode(vuRM);
++gf;
}
@ -242,7 +242,7 @@ static int loadGameSettings(Pcsx2Config& dest, const Game_Data& game, bool verbo
if (game.keyExists("eeClampMode")) {
int clampMode = game.getInt("eeClampMode");
if(verbose) Console.WriteLn("(GameDB) Changing EE/FPU clamp mode [mode=%d]", clampMode);
PatchesCon->WriteLn("(GameDB) Changing EE/FPU clamp mode [mode=%d]", clampMode);
dest.Cpu.Recompiler.fpuOverflow = (clampMode >= 1);
dest.Cpu.Recompiler.fpuExtraOverflow = (clampMode >= 2);
dest.Cpu.Recompiler.fpuFullMode = (clampMode >= 3);
@ -251,7 +251,7 @@ static int loadGameSettings(Pcsx2Config& dest, const Game_Data& game, bool verbo
if (game.keyExists("vuClampMode")) {
int clampMode = game.getInt("vuClampMode");
if(verbose) Console.WriteLn("(GameDB) Changing VU0/VU1 clamp mode [mode=%d]", clampMode);
PatchesCon->WriteLn("(GameDB) Changing VU0/VU1 clamp mode [mode=%d]", clampMode);
dest.Cpu.Recompiler.vuOverflow = (clampMode >= 1);
dest.Cpu.Recompiler.vuExtraOverflow = (clampMode >= 2);
dest.Cpu.Recompiler.vuSignOverflow = (clampMode >= 3);
@ -261,7 +261,7 @@ static int loadGameSettings(Pcsx2Config& dest, const Game_Data& game, bool verbo
if (game.keyExists("mvuFlagSpeedHack")) {
bool vuFlagHack = game.getInt("mvuFlagSpeedHack") ? 1 : 0;
if(verbose) Console.WriteLn("(GameDB) Changing mVU flag speed hack [mode=%d]", vuFlagHack);
PatchesCon->WriteLn("(GameDB) Changing mVU flag speed hack [mode=%d]", vuFlagHack);
dest.Speedhacks.vuFlagHack = vuFlagHack;
gf++;
}
@ -275,7 +275,7 @@ static int loadGameSettings(Pcsx2Config& dest, const Game_Data& game, bool verbo
{
bool enableIt = game.getBool(key);
dest.Gamefixes.Set(id, enableIt);
if(verbose) Console.WriteLn(L"(GameDB) %s Gamefix: " + key, enableIt ? L"Enabled" : L"Disabled" );
PatchesCon->WriteLn(L"(GameDB) %s Gamefix: " + key, enableIt ? L"Enabled" : L"Disabled");
gf++;
// The LUT is only used for 1 game so we allocate it only when the gamefix is enabled (save 4MB)
@ -293,6 +293,24 @@ static int loadGameSettings(Pcsx2Config& dest, const Game_Data& game, bool verbo
// File scope since it gets reset externally when rebooting
static wxString curGameKey;
// PatchesCon points to either Console or ConsoleWriter_Null, such that if we're in Devel mode
// or the user enabled the devel/verbose console it prints all patching info whenever it's applied,
// else it prints the patching info only once - right after boot.
const IConsoleWriter *PatchesCon = &Console;
static void SetupPatchesCon(bool verbose)
{
bool devel = false;
#ifdef PCSX2_DEVBUILD
devel = true;
#endif
if (verbose || DevConWriterEnabled || devel)
PatchesCon = &Console;
else
PatchesCon = &ConsoleWriter_Null;
}
void AppCoreThread::ApplySettings( const Pcsx2Config& src )
{
// 'fixup' is the EmuConfig we're going to upload to the emulator, which very well may
@ -336,6 +354,8 @@ void AppCoreThread::ApplySettings( const Pcsx2Config& src )
const wxString newGameKey( SysGetDiscID() );
const bool verbose( newGameKey != curGameKey );
SetupPatchesCon(verbose);
curGameKey = newGameKey;
if (!curGameKey.IsEmpty())
@ -353,9 +373,9 @@ void AppCoreThread::ApplySettings( const Pcsx2Config& src )
if (EmuConfig.EnablePatches) {
if (int patches = InitPatches(gameCRC, game)) {
gamePatch.Printf(L" [%d Patches]", patches);
if (verbose) Console.WriteLn(Color_Green, "(GameDB) Patches Loaded: %d", patches);
PatchesCon->WriteLn(Color_Green, "(GameDB) Patches Loaded: %d", patches);
}
if (int fixes = loadGameSettings(fixup, game, verbose)) {
if (int fixes = loadGameSettings(fixup, game)) {
gameFixes.Printf(L" [%d Fixes]", fixes);
}
}
@ -398,8 +418,7 @@ 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)) {
if (verbose || DevConWriterEnabled)
Console.WriteLn(Color_Green, "(Wide Screen Cheats DB) Patches Loaded: %d", numberDbfCheatsLoaded);
PatchesCon->WriteLn(Color_Green, "(Wide Screen Cheats DB) Patches Loaded: %d", numberDbfCheatsLoaded);
gameWsHacks.Printf(L" [%d widescreen hacks]", numberDbfCheatsLoaded);
}
}