mirror of https://github.com/PCSX2/pcsx2.git
Fix patch application, which I broke in r3273. :)
DevNote: Adding SysForwardDefs.h, which I'm going to use for forward declaring a bunch of PCSX2 classes and other simple dependency-free include content. This is the SysCore version of AppForwardDefs, and hopefully helps minimize header file hell. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3276 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
d24a15e0f9
commit
67ddabd231
|
@ -51,8 +51,8 @@ void BaseGameDatabaseImpl::updateGame(const Game_Data& game)
|
|||
}
|
||||
|
||||
// Searches the current game's data to see if the given key exists
|
||||
bool Game_Data::keyExists(const wxChar* key) {
|
||||
KeyPairArray::iterator it( kList.begin() );
|
||||
bool Game_Data::keyExists(const wxChar* key) const {
|
||||
KeyPairArray::const_iterator it( kList.begin() );
|
||||
for ( ; it != kList.end(); ++it) {
|
||||
if (it[0].CompareKey(key)) {
|
||||
return true;
|
||||
|
@ -73,8 +73,8 @@ void Game_Data::deleteKey(const wxChar* key) {
|
|||
}
|
||||
|
||||
// Gets a string representation of the 'value' for the given key
|
||||
wxString Game_Data::getString(const wxChar* key) {
|
||||
KeyPairArray::iterator it( kList.begin() );
|
||||
wxString Game_Data::getString(const wxChar* key) const {
|
||||
KeyPairArray::const_iterator it( kList.begin() );
|
||||
for ( ; it != kList.end(); ++it) {
|
||||
if (it[0].CompareKey(key)) {
|
||||
return it[0].value;
|
||||
|
|
|
@ -95,9 +95,9 @@ struct Game_Data
|
|||
kList.clear();
|
||||
}
|
||||
|
||||
bool keyExists(const wxChar* key);
|
||||
bool keyExists(const wxChar* key) const;
|
||||
void deleteKey(const wxChar* key);
|
||||
wxString getString(const wxChar* key);
|
||||
wxString getString(const wxChar* key) const;
|
||||
void writeString(const wxString& key, const wxString& value);
|
||||
void writeBool(const wxString& key, bool value);
|
||||
|
||||
|
@ -105,46 +105,46 @@ struct Game_Data
|
|||
return !id.IsEmpty();
|
||||
}
|
||||
|
||||
bool sectionExists(const wxChar* key, const wxString& value) {
|
||||
bool sectionExists(const wxChar* key, const wxString& value) const {
|
||||
return keyExists(wxsFormat(L"[%s%s%s]", key, value.IsEmpty() ? L"" : L" = ", value.c_str()));
|
||||
}
|
||||
|
||||
wxString getSection(const wxChar* key, const wxString& value) {
|
||||
wxString getSection(const wxChar* key, const wxString& value) const {
|
||||
return getString(wxsFormat(L"[%s%s%s]", key, value.IsEmpty() ? L"" : L" = ", value.c_str()));
|
||||
}
|
||||
|
||||
// Gets an integer representation of the 'value' for the given key
|
||||
int getInt(const wxChar* key) {
|
||||
int getInt(const wxChar* key) const {
|
||||
return wxStrtoul(getString(key), NULL, 0);
|
||||
}
|
||||
|
||||
// Gets a u8 representation of the 'value' for the given key
|
||||
u8 getU8(const wxChar* key) {
|
||||
u8 getU8(const wxChar* key) const {
|
||||
return (u8)wxAtoi(getString(key));
|
||||
}
|
||||
|
||||
// Gets a bool representation of the 'value' for the given key
|
||||
bool getBool(const wxChar* key) {
|
||||
bool getBool(const wxChar* key) const {
|
||||
return !!wxAtoi(getString(key));
|
||||
}
|
||||
|
||||
bool keyExists(const char* key) {
|
||||
bool keyExists(const char* key) const {
|
||||
return keyExists(fromUTF8(key));
|
||||
}
|
||||
|
||||
wxString getString(const char* key) {
|
||||
wxString getString(const char* key) const {
|
||||
return getString(fromUTF8(key));
|
||||
}
|
||||
|
||||
int getInt(const char* key) {
|
||||
int getInt(const char* key) const {
|
||||
return getInt(fromUTF8(key));
|
||||
}
|
||||
|
||||
u8 getU8(const char* key) {
|
||||
u8 getU8(const char* key) const {
|
||||
return getU8(fromUTF8(key));
|
||||
}
|
||||
|
||||
bool getBool(const char* key) {
|
||||
bool getBool(const char* key) const {
|
||||
return getBool(fromUTF8(key));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -131,18 +131,16 @@ void TrimPatches(wxString& s)
|
|||
|
||||
// This routine loads patches from the game database
|
||||
// Returns number of patches loaded
|
||||
int InitPatches(const wxString& name)
|
||||
int InitPatches(const wxString& crc, const Game_Data& game)
|
||||
{
|
||||
bool patchFound = false;
|
||||
wxString patch;
|
||||
patchnumber = 0;
|
||||
|
||||
if (IGameDatabase* GameDB = AppHost_GetGameDatabase() )
|
||||
if (game.IsOk())
|
||||
{
|
||||
Game_Data game;
|
||||
if (GameDB->findGame(game,name)) {
|
||||
if (game.sectionExists(L"patches", name)) {
|
||||
patch = game.getSection(L"patches", name);
|
||||
if (game.sectionExists(L"patches", crc)) {
|
||||
patch = game.getSection(L"patches", crc);
|
||||
patchFound = true;
|
||||
}
|
||||
else if (game.keyExists(L"[patches]")) {
|
||||
|
@ -150,7 +148,6 @@ int InitPatches(const wxString& name)
|
|||
patchFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (patchFound) {
|
||||
Console.WriteLn(Color_Green, "Patch found in the Database!");
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __PATCH_H__
|
||||
#define __PATCH_H__
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Pcsx2Defs.h"
|
||||
#include "SysForwardDefs.h"
|
||||
|
||||
#define MAX_PATCH 512
|
||||
#define MAX_CHEAT 1024
|
||||
|
@ -56,16 +57,14 @@ namespace PatchFunc
|
|||
PATCHTABLEFUNC cheat;
|
||||
}
|
||||
|
||||
int InitCheats(const wxString& name);
|
||||
void inifile_command(bool isCheat, const wxString& cmd);
|
||||
void inifile_trim(wxString& buffer);
|
||||
extern int InitCheats(const wxString& name);
|
||||
extern void inifile_command(bool isCheat, const wxString& cmd);
|
||||
extern void inifile_trim(wxString& buffer);
|
||||
|
||||
int InitPatches(const wxString& name);
|
||||
int AddPatch(int Mode, int Place, int Address, int Size, u64 data);
|
||||
void ResetPatch(void);
|
||||
void ApplyPatch(int place = 1);
|
||||
void ApplyCheat(int place = 1);
|
||||
void _ApplyPatch(IniPatch *p);
|
||||
|
||||
#endif /* __PATCH_H__ */
|
||||
extern int InitPatches(const wxString& name, const Game_Data& game);
|
||||
extern int AddPatch(int Mode, int Place, int Address, int Size, u64 data);
|
||||
extern void ResetPatch(void);
|
||||
extern void ApplyPatch(int place = 1);
|
||||
extern void ApplyCheat(int place = 1);
|
||||
extern void _ApplyPatch(IniPatch *p);
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
static const int PCSX2_VersionHi = 0;
|
||||
static const int PCSX2_VersionMid = 9;
|
||||
static const int PCSX2_VersionLo = 7;
|
||||
|
||||
class SysCoreThread;
|
||||
class CpuInitializerSet;
|
||||
|
||||
struct Game_Data;
|
|
@ -15,17 +15,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "SysForwardDefs.h"
|
||||
|
||||
#include "Utilities/SafeArray.h"
|
||||
#include "Utilities/Threading.h" // to use threading stuff, include the Threading namespace in your file.
|
||||
#include "CDVD/CDVDaccess.h"
|
||||
|
||||
static const int PCSX2_VersionHi = 0;
|
||||
static const int PCSX2_VersionMid = 9;
|
||||
static const int PCSX2_VersionLo = 7;
|
||||
|
||||
class SysCoreThread;
|
||||
class CpuInitializerSet;
|
||||
|
||||
typedef SafeArray<u8> VmStateBuffer;
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
|
|
@ -266,7 +266,7 @@ void AppCoreThread::ApplySettings( const Pcsx2Config& src )
|
|||
}
|
||||
|
||||
if (EmuConfig.EnablePatches) {
|
||||
if (int patches = InitPatches(gameCRC)) {
|
||||
if (int patches = InitPatches(gameCRC, game)) {
|
||||
gamePatch.Printf(L" [%d Patches]", patches);
|
||||
}
|
||||
if (int fixes = loadGameSettings(fixup, GameDB)) {
|
||||
|
|
|
@ -475,6 +475,10 @@
|
|||
RelativePath="..\..\Stats.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\SysForwardDefs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\System.h"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue