Widescreen hacks db: change from dbf to normal zip (also replaced the dbf with a zip of current ws hacks).

Logic stays the same as before: If no ws hack is loaded from the normal cheats_ws folder, they try finding ws hacks at the zip.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5836 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
avihal@gmail.com 2014-01-25 21:13:52 +00:00
parent d89d02a59f
commit 980229ce5b
6 changed files with 28 additions and 21317 deletions

File diff suppressed because it is too large Load Diff

BIN
bin/cheats_ws.zip Normal file

Binary file not shown.

View File

@ -1,18 +0,0 @@
%~d0
cd %~p0
set db=cheats_ws.dbf
del %db%
@echo off
echo Creating %db%
for %%f in (*.pnach) do (
echo Processing %%f
echo //IMPORT-START:%%f>> %db%
echo [patches=%%~nf]>> %db%
type %%f>> %db%
echo.>> %db%
echo [/patches]>> %db%
echo //IMPORT-END:%%f>> %db%
echo.>> %db%
echo.>> %db%
)

View File

@ -20,9 +20,11 @@
#include "IopCommon.h"
#include "Patch.h"
#include "GameDatabase.h"
#include <wx/textfile.h>
#include <wx/dir.h>
#include <wx/textfile.h>
#include <wx/txtstrm.h>
#include <wx/zipstrm.h>
IniPatch Patch[ MAX_PATCH ];
IniPatch Cheat[ MAX_CHEAT ];
@ -206,51 +208,32 @@ static int LoadCheatsFiles(const wxDirName& folderName, wxString& fileSpec, cons
return cheatnumber - before;
}
// This routine loads cheats from a dbf file
// This routine loads cheats from a zip file
// Returns number of cheats loaded
// Note: Should be called after InitPatches()
// expected DB format of section(s) to be loaded:
//[patches=ABCDE1234<anything can come here upto EOL>
// <patch file content, possibly multiline, possibly with comments>
//[/patches]
// DB file notes: 1. no spaces around the '='. 2. CRC should be in upper case padded with 0s to 8 chars
int LoadCheatsFromDbf(wxString gameCRC, const wxString& cheatsDbfFilename) {
// Note: only load cheats from the root folder of the zip
int LoadCheatsFromZip(wxString gameCRC, const wxString& cheatsArchiveFilename) {
gameCRC.MakeUpper();
if (!gameCRC.Length()) {
Console.WriteLn(Color_Gray, "Cheats: No CRC, using 00000000 instead.");
gameCRC = L"00000000";
}
wxTextFile db(cheatsDbfFilename);
db.Open();
int before = cheatnumber;
wxString line;
bool insideCurrentGame = false;
bool first = true;
while (true) {
if (first) line = db.GetFirstLine();
else line = db.GetNextLine();
first = false;
if (insideCurrentGame) {
if (line.Find(L"[/patches]") == 0) {
insideCurrentGame = false;
continue;
std::auto_ptr<wxZipEntry> entry;
wxFFileInputStream in(cheatsArchiveFilename);
wxZipInputStream zip(in);
while (entry.reset(zip.GetNextEntry()), entry.get() != NULL)
{
wxString name = entry->GetName();
name.MakeUpper();
if (name.Find(gameCRC) == 0 && name.Find(L".PNACH") == name.Length()-6) {
Console.WriteLn(Color_Gray, "Loading patch '%s' from archive '%s'",
entry->GetName().To8BitData(), cheatsArchiveFilename.To8BitData());
wxTextInputStream pnach(zip);
while (!zip.Eof()) {
inifile_processString(pnach.ReadLine());
}
inifile_processString(line);
} else if (line.Find(wxString(L"[patches=") + gameCRC) == 0) {
insideCurrentGame = true;
}
if (db.Eof()) break;
}
db.Close();
return cheatnumber - before;
}
@ -260,11 +243,6 @@ int LoadCheatsFromDbf(wxString gameCRC, const wxString& cheatsDbfFilename) {
// Note: Should be called after InitPatches()
int LoadCheats(wxString name, const wxDirName& folderName, const wxString& friendlyName)
{
if (!name.Length()) {
Console.WriteLn(Color_Gray, "Cheats: No CRC, using 00000000 instead.");
name = L"00000000";
}
int loaded = 0;
wxString filespec = name + L"*.pnach";

View File

@ -59,7 +59,7 @@ namespace PatchFunc
extern void ResetCheatsCount();
extern int LoadCheats(wxString name, const wxDirName& folderName, const wxString& friendlyName);
extern int LoadCheatsFromDbf(wxString gameCRC, const wxString& cheatsDbfFilename);
extern int LoadCheatsFromZip(wxString gameCRC, const wxString& cheatsArchiveFilename);
extern void inifile_command(bool isCheat, const wxString& cmd);
extern void inifile_trim(wxString& buffer);

View File

@ -357,6 +357,11 @@ void AppCoreThread::ApplySettings( const Pcsx2Config& src )
}
ResetCheatsCount();
//Till the end of this function, emtry CRC will be 00000000
if (!gameCRC.Length()) {
Console.WriteLn(Color_Gray, "Cheats: No CRC, using 00000000 instead.");
gameCRC = L"00000000";
}
// regular cheat patches
if (EmuConfig.EnableCheats) {
if (numberLoadedCheats = LoadCheats(gameCRC, PathDefs::GetCheats(), L"Cheats")) {
@ -369,9 +374,9 @@ void AppCoreThread::ApplySettings( const Pcsx2Config& src )
if (numberLoadedWideScreenPatches = LoadCheats(gameCRC, PathDefs::GetCheatsWS(), L"Widescreen hacks")) {
gameWsHacks.Printf(L" [%d widescreen hacks]", numberLoadedWideScreenPatches);
} else {
// No ws cheat files found at the cheats_ws folder, try the ws cheats db file.
wxString cheats_wsDbf = Path::Combine(((wxFileName)wxStandardPaths::Get().GetExecutablePath()).GetPath(), L"cheats_ws.dbf");
if (numberDbfCheatsLoaded = LoadCheatsFromDbf(gameCRC, cheats_wsDbf)) {
// No ws cheat files found at the cheats_ws folder, try the ws cheats zip file.
wxString cheats_ws_archive = Path::Combine(((wxFileName)wxStandardPaths::Get().GetExecutablePath()).GetPath(), L"cheats_ws.zip");
if (numberDbfCheatsLoaded = LoadCheatsFromZip(gameCRC, cheats_ws_archive)) {
Console.WriteLn(Color_Green, "(Wide Screen Cheats DB) Patches Loaded: %d", numberDbfCheatsLoaded);
gameWsHacks.Printf(L" [%d widescreen hacks]", numberDbfCheatsLoaded);
}