From 76a75efef1962c8c36a9f5602021920b348dadf4 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 26 Aug 2018 01:17:20 +0100 Subject: [PATCH] pcsx2: Remove GameDB write related code There's no use for it now that the database editor has been removed. Also remove the Game_Data POD comment because I don't think it makes sense and remove an unused variable. --- pcsx2/GameDatabase.cpp | 29 ------------------ pcsx2/GameDatabase.h | 28 ------------------ pcsx2/gui/AppGameDatabase.cpp | 55 ----------------------------------- pcsx2/gui/AppGameDatabase.h | 5 ---- 4 files changed, 117 deletions(-) diff --git a/pcsx2/GameDatabase.cpp b/pcsx2/GameDatabase.cpp index 4cce4ac893..8abf7464ed 100644 --- a/pcsx2/GameDatabase.cpp +++ b/pcsx2/GameDatabase.cpp @@ -80,20 +80,6 @@ Game_Data* BaseGameDatabaseImpl::createNewGame( const wxString& id ) return retval; } -void BaseGameDatabaseImpl::updateGame(const Game_Data& game) -{ - GameDataHash::const_iterator iter( gHash.find(game.id) ); - - if( iter == gHash.end() ) { - *(createNewGame( game.id )) = game; - } - else - { - // Re-assign existing vector/array entry! - *gHash[game.id] = game; - } -} - // Searches the current game's data to see if the given key exists bool Game_Data::keyExists(const wxChar* key) const { for (auto it = kList.begin(); it != kList.end(); ++it) { @@ -104,16 +90,6 @@ bool Game_Data::keyExists(const wxChar* key) const { return false; } -// Totally Deletes the specified key/pair value from the current game's data -void Game_Data::deleteKey(const wxChar* key) { - for (auto it = kList.begin(); it != kList.end(); ++it) { - if (it->CompareKey(key)) { - kList.erase(it); - return; - } - } -} - // Gets a string representation of the 'value' for the given key wxString Game_Data::getString(const wxChar* key) const { for (auto it = kList.begin(); it != kList.end(); ++it) { @@ -138,8 +114,3 @@ void Game_Data::writeString(const wxString& key, const wxString& value) { kList.push_back(key_pair(key, value)); } } - -// Write a bool value to the specified key -void Game_Data::writeBool(const wxString& key, bool value) { - writeString(key, value ? L"1" : L"0"); -} \ No newline at end of file diff --git a/pcsx2/GameDatabase.h b/pcsx2/GameDatabase.h index 13095b67ea..6d8d2db098 100644 --- a/pcsx2/GameDatabase.h +++ b/pcsx2/GameDatabase.h @@ -60,35 +60,11 @@ struct key_pair { bool IsOk() const { return !key.IsEmpty(); } - - wxString toString() const { - if (key[0] == '[') { - pxAssertDev( key.EndsWith(L"]"), "Malformed multiline key detected: missing end bracket!" ); - - // Terminating tag must be written without the "rvalue" -- in the form of: - // [/patches] - // Use Mid() to strip off the left and right side brackets. - wxString midLine(key.Mid(1, key.Length()-2)); - wxString keyLvalue(midLine.BeforeFirst(L'=').Trim(true).Trim(false)); - - return wxsFormat( L"%s\n%s[/%s]\n", - key.c_str(), value.c_str(), keyLvalue.c_str() - ); - } - else { - // Note: 6 char padding on the l-value makes things look nicer. - return wxsFormat(L"%-6s = %s\n", key.c_str(), value.c_str() ); - } - - } }; // -------------------------------------------------------------------------------------- // Game_Data // -------------------------------------------------------------------------------------- -// This container is more or less required to be a simple struct (POD classification) -- -// no virtuals and no inheritance. This is because it is used in a std::vector, so POD -// makes things... smoother. struct Game_Data { wxString id; // Serial Identification Code @@ -109,10 +85,8 @@ struct Game_Data } bool keyExists(const wxChar* key) const; - void deleteKey(const wxChar* key); wxString getString(const wxChar* key) const; void writeString(const wxString& key, const wxString& value); - void writeBool(const wxString& key, bool value); bool IsOk() const { return !id.IsEmpty(); @@ -183,7 +157,6 @@ public: virtual wxString getBaseKey() const=0; virtual bool findGame(Game_Data& dest, const wxString& id)=0; virtual Game_Data* createNewGame( const wxString& id )=0; - virtual void updateGame(const Game_Data& game)=0; }; typedef std::unordered_map GameDataHash; @@ -213,7 +186,6 @@ public: bool findGame(Game_Data& dest, const wxString& id); Game_Data* createNewGame( const wxString& id ); - void updateGame(const Game_Data& game); }; extern IGameDatabase* AppHost_GetGameDatabase(); diff --git a/pcsx2/gui/AppGameDatabase.cpp b/pcsx2/gui/AppGameDatabase.cpp index 50a58c200f..cfe8c240fa 100644 --- a/pcsx2/gui/AppGameDatabase.cpp +++ b/pcsx2/gui/AppGameDatabase.cpp @@ -42,7 +42,6 @@ public: { } - wxString ReadHeader(); void ReadGames(); protected: @@ -97,38 +96,10 @@ void DBLoaderHelper::extract() { if( m_keyPair.value.IsEmpty() ) doError(true); } -wxString DBLoaderHelper::ReadHeader() -{ - wxString header; - header.reserve(2048); - - while(!m_reader.Eof()) { - pxReadLine(m_reader, m_dest, m_intermediate); - m_dest.Trim(false).Trim(true); - if( !(m_dest.IsEmpty() || m_dest.StartsWith(L"--") || m_dest.StartsWith( L"//" ) || m_dest.StartsWith( L";" )) ) break; - header += m_dest + L'\n'; - } - - if( !m_dest.IsEmpty() ) - { - m_keyPair.Clear(); - if( !extractMultiLine() ) extract(); - } - return header; -} - void DBLoaderHelper::ReadGames() { Game_Data* game = NULL; - if (m_keyPair.IsOk()) - { - game = m_gamedb.createNewGame(m_keyPair.value); - game->writeString(m_keyPair.key, m_keyPair.value); - //if( m_keyPair.CompareKey(m_gamedb.getBaseKey()) ) - // game.id = m_keyPair.value; - } - while(!m_reader.Eof()) { // Fill game data, find new game, repeat... pthread_testcancel(); pxReadLine(m_reader, m_dest, m_intermediate); @@ -187,7 +158,6 @@ AppGameDatabase& AppGameDatabase::LoadFromFile(const wxString& _file, const wxSt DBLoaderHelper loader( reader, *this ); u64 qpc_Start = GetCPUTicks(); - header = loader.ReadHeader(); loader.ReadGames(); u64 qpc_end = GetCPUTicks(); @@ -197,31 +167,6 @@ AppGameDatabase& AppGameDatabase::LoadFromFile(const wxString& _file, const wxSt return *this; } -// Saves changes to the database - -void AppGameDatabase::SaveToFile(const wxString& file) { - wxFFileOutputStream writer( file ); - pxWriteMultiline(writer, header); - - for(uint blockidx=0; blockidx<=m_BlockTableWritePos; ++blockidx) - { - if( !m_BlockTable[blockidx] ) continue; - - const uint endidx = (blockidx == m_BlockTableWritePos) ? m_CurBlockWritePos : m_GamesPerBlock; - - for( uint gameidx=0; gameidxtoString() ); - } - - pxWriteLine(writer, L"---------------------------------------------"); - } - } -} - AppGameDatabase* Pcsx2App::GetGameDatabase() { pxAppResources& res( GetResourceCache() ); diff --git a/pcsx2/gui/AppGameDatabase.h b/pcsx2/gui/AppGameDatabase.h index 389cea1767..b9cbece440 100644 --- a/pcsx2/gui/AppGameDatabase.h +++ b/pcsx2/gui/AppGameDatabase.h @@ -41,10 +41,6 @@ class AppGameDatabase : public BaseGameDatabaseImpl { -protected: - wxString header; // Header of the database - wxString baseKey; // Key to separate games by ("Serial") - public: AppGameDatabase() {} virtual ~AppGameDatabase() { @@ -55,7 +51,6 @@ public: } AppGameDatabase& LoadFromFile(const wxString& file = Path::Combine( PathDefs::GetProgramDataDir(), wxFileName(L"GameIndex.dbf") ), const wxString& key = L"Serial" ); - void SaveToFile(const wxString& file = Path::Combine( PathDefs::GetProgramDataDir(), wxFileName(L"GameIndex.dbf")) ); }; static wxString compatToStringWX(int compat) {