diff --git a/Source/Core/Core/GeckoCodeConfig.cpp b/Source/Core/Core/GeckoCodeConfig.cpp index d11035306f..da296e8aa5 100644 --- a/Source/Core/Core/GeckoCodeConfig.cpp +++ b/Source/Core/Core/GeckoCodeConfig.cpp @@ -16,113 +16,6 @@ namespace Gecko { -std::vector DownloadCodes(std::string gametdb_id, bool* succeeded) -{ - // codes.rc24.xyz is a mirror of the now defunct geckocodes.org. - std::string endpoint{"https://codes.rc24.xyz/txt.php?txt=" + gametdb_id}; - Common::HttpRequest http; - - // The server always redirects once to the same location. - http.FollowRedirects(1); - - const Common::HttpRequest::Response response = http.Get(endpoint); - *succeeded = response.has_value(); - if (!response) - return {}; - - // temp vector containing parsed codes - std::vector gcodes; - - // parse the codes - std::istringstream ss(std::string(response->begin(), response->end())); - - std::string line; - - // seek past the header, get to the first code - std::getline(ss, line); - std::getline(ss, line); - std::getline(ss, line); - - int read_state = 0; - GeckoCode gcode; - - while ((std::getline(ss, line).good())) - { - // Remove \r at the end of the line for files using windows line endings, std::getline only - // removes \n - line = StripSpaces(line); - - if (line.empty()) - { - // add the code - if (!gcode.codes.empty()) - gcodes.push_back(gcode); - gcode = GeckoCode(); - read_state = 0; - continue; - } - - switch (read_state) - { - // read new code - case 0: - { - std::istringstream ssline(line); - // stop at [ character (beginning of contributor name) - std::getline(ssline, gcode.name, '['); - gcode.name = StripSpaces(gcode.name); - gcode.user_defined = true; - // read the code creator name - std::getline(ssline, gcode.creator, ']'); - read_state = 1; - } - break; - - // read code lines - case 1: - { - std::istringstream ssline(line); - std::string addr, data; - - // Some locales (e.g. fr_FR.UTF-8) don't split the string stream on space - // Use the C locale to workaround this behavior - ssline.imbue(std::locale::classic()); - - ssline >> addr >> data; - ssline.seekg(0); - - // check if this line a code, silly, but the dumb txt file comment lines can start with - // valid hex chars :/ - if (8 == addr.length() && 8 == data.length()) - { - GeckoCode::Code new_code; - new_code.original_line = line; - ssline >> std::hex >> new_code.address >> new_code.data; - gcode.codes.push_back(new_code); - } - else - { - gcode.notes.push_back(line); - read_state = 2; // start reading comments - } - } - break; - - // read comment lines - case 2: - // append comment line - gcode.notes.push_back(line); - break; - } - } - - // add the last code - if (!gcode.codes.empty()) - gcodes.push_back(gcode); - - return gcodes; -} - std::vector LoadCodes(const IniFile& globalIni, const IniFile& localIni) { std::vector gcodes; diff --git a/Source/Core/Core/GeckoCodeConfig.h b/Source/Core/Core/GeckoCodeConfig.h index 90f89816ea..bf269e24ee 100644 --- a/Source/Core/Core/GeckoCodeConfig.h +++ b/Source/Core/Core/GeckoCodeConfig.h @@ -13,6 +13,5 @@ class IniFile; namespace Gecko { std::vector LoadCodes(const IniFile& globalIni, const IniFile& localIni); -std::vector DownloadCodes(std::string gametdb_id, bool* succeeded); void SaveCodes(IniFile& inifile, const std::vector& gcodes); } // namespace Gecko diff --git a/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp b/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp index 8ff6c0cb78..934b2e191f 100644 --- a/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp +++ b/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp @@ -75,11 +75,7 @@ void GeckoCodeWidget::CreateWidgets() m_add_code = new QPushButton(tr("&Add New Code...")); m_edit_code = new QPushButton(tr("&Edit Code...")); m_remove_code = new QPushButton(tr("&Remove Code")); - m_download_codes = new QPushButton(tr("Download Codes")); - m_download_codes->setToolTip(tr("Download Codes from the WiiRD Database")); - - m_download_codes->setEnabled(!m_game_id.empty()); m_edit_code->setEnabled(false); m_remove_code->setEnabled(false); @@ -111,7 +107,6 @@ void GeckoCodeWidget::CreateWidgets() btn_layout->addWidget(m_add_code); btn_layout->addWidget(m_edit_code); btn_layout->addWidget(m_remove_code); - btn_layout->addWidget(m_download_codes); layout->addLayout(btn_layout); @@ -131,7 +126,6 @@ void GeckoCodeWidget::ConnectWidgets() connect(m_add_code, &QPushButton::clicked, this, &GeckoCodeWidget::AddCode); connect(m_remove_code, &QPushButton::clicked, this, &GeckoCodeWidget::RemoveCode); connect(m_edit_code, &QPushButton::clicked, this, &GeckoCodeWidget::EditCode); - connect(m_download_codes, &QPushButton::clicked, this, &GeckoCodeWidget::DownloadCodes); connect(m_warning, &CheatWarningWidget::OpenCheatEnableSettings, this, &GeckoCodeWidget::OpenGeneralSettings); } @@ -295,43 +289,3 @@ void GeckoCodeWidget::UpdateList() m_code_list->setDragDropMode(QAbstractItemView::InternalMove); } - -void GeckoCodeWidget::DownloadCodes() -{ - bool success; - - std::vector codes = Gecko::DownloadCodes(m_gametdb_id, &success); - - if (!success) - { - ModalMessageBox::critical(this, tr("Error"), tr("Failed to download codes.")); - return; - } - - if (codes.empty()) - { - ModalMessageBox::critical(this, tr("Error"), tr("File contained no codes.")); - return; - } - - size_t added_count = 0; - - for (const auto& code : codes) - { - auto it = std::find(m_gecko_codes.begin(), m_gecko_codes.end(), code); - - if (it == m_gecko_codes.end()) - { - m_gecko_codes.push_back(code); - added_count++; - } - } - - UpdateList(); - SaveCodes(); - - ModalMessageBox::information( - this, tr("Download complete"), - tr("Downloaded %1 codes. (added %2)") - .arg(QString::number(codes.size()), QString::number(added_count))); -} diff --git a/Source/Core/DolphinQt/Config/GeckoCodeWidget.h b/Source/Core/DolphinQt/Config/GeckoCodeWidget.h index 28fa4aeb44..828a39b6d3 100644 --- a/Source/Core/DolphinQt/Config/GeckoCodeWidget.h +++ b/Source/Core/DolphinQt/Config/GeckoCodeWidget.h @@ -50,7 +50,6 @@ private: void AddCode(); void EditCode(); void RemoveCode(); - void DownloadCodes(); void SaveCodes(); void SortAlphabetically(); @@ -68,7 +67,6 @@ private: QPushButton* m_add_code; QPushButton* m_edit_code; QPushButton* m_remove_code; - QPushButton* m_download_codes; std::vector m_gecko_codes; bool m_restart_required; };