From a697365a776e13e7f5dbc96ad0d6d79bbe3f8dbd Mon Sep 17 00:00:00 2001 From: flb Date: Sat, 17 Jul 2021 14:29:55 +0200 Subject: [PATCH] fixed crash when downloading cheats in applet mode, updated borealis submodule, passed strings as references --- Makefile | 2 +- include/ams_tab.hpp | 2 +- include/choice_page.hpp | 2 +- include/color_swapper.hpp | 12 ++++++------ include/dialogue_page.hpp | 2 +- include/download_cheats_page.hpp | 2 +- include/extract.hpp | 2 +- include/net_page.hpp | 2 +- include/tools_tab.hpp | 2 +- include/utils.hpp | 12 ++++++------ include/warning_page.hpp | 2 +- lib/borealis | 2 +- source/app_page.cpp | 3 +++ source/changelog_page.cpp | 3 +++ source/choice_page.cpp | 2 +- source/color_swapper.cpp | 14 +++++++------- source/dialogue_page.cpp | 2 +- source/download_cheats_page.cpp | 2 +- source/extract.cpp | 2 +- source/net_page.cpp | 2 +- source/tools_tab.cpp | 2 +- source/utils.cpp | 14 +++++++------- source/warning_page.cpp | 2 +- 23 files changed, 49 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index 2bb2ed9..3975c0e 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ DATA := data INCLUDES := include lib/zipper/include /lib/borealis/library/include/borealis/extern/nlohmann APP_TITLE := All-in-One Switch Updater APP_AUTHOR := HamletDuFromage -APP_VERSION := 2.11.1 +APP_VERSION := 2.11.2 TARGET := $(notdir $(CURDIR)) ROMFS := resources diff --git a/include/ams_tab.hpp b/include/ams_tab.hpp index a3c305a..6b2522f 100644 --- a/include/ams_tab.hpp +++ b/include/ams_tab.hpp @@ -26,6 +26,6 @@ class AmsTab : public brls::List class UnTogglableListItem : public brls::ToggleListItem { public: - UnTogglableListItem(std::string label, bool initialValue, std::string description = "", std::string onValue = "On", std::string offValue = "Off") : ToggleListItem(label, initialValue, description, onValue, offValue) {} + UnTogglableListItem(const std::string& label, bool initialValue, std::string description = "", std::string onValue = "On", std::string offValue = "Off") : ToggleListItem(label, initialValue, description, onValue, offValue) {} virtual bool onClick() override; }; \ No newline at end of file diff --git a/include/choice_page.hpp b/include/choice_page.hpp index 1f0281e..59b11f7 100644 --- a/include/choice_page.hpp +++ b/include/choice_page.hpp @@ -10,7 +10,7 @@ class ChoicePage: public brls::View brls::Label* label = nullptr; public: - ChoicePage(brls::StagedAppletFrame* frame, std::string text); + ChoicePage(brls::StagedAppletFrame* frame, const std::string text); void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override; void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override; brls::View* getDefaultFocus() override; diff --git a/include/color_swapper.hpp b/include/color_swapper.hpp index 7485151..5bd62d3 100644 --- a/include/color_swapper.hpp +++ b/include/color_swapper.hpp @@ -4,10 +4,10 @@ namespace JC { - int setColor(std::vector colors); + int setColor(const std::vector& colors); int backupToJSON(nlohmann::json &profiles, const std::string& path); std::vector>> getProfiles(const std::string& path); - void changeJCColor(std::vector values); + void changeJCColor(const std::vector& values); nlohmann::json backupProfile(); void backupJCColor(const std::string& path); @@ -15,10 +15,10 @@ namespace JC { namespace PC { - int setColor(std::vector colors); + int setColor(const std::vector& colors); int backupToJSON(nlohmann::json &profiles,const std::string& path); std::vector>> getProfiles(const std::string& path); - void changePCColor(std::vector values); + void changePCColor(const std::vector& values); nlohmann::json backupProfile(); void backupPCColor(const std::string& path); @@ -26,8 +26,8 @@ namespace PC { namespace ColorSwapper { - int hexToBGR(std::string hex); + int hexToBGR(const std::string& hex); std::string BGRToHex(int v); - bool isHexaAnd3Bytes(std::string str); + bool isHexaAnd3Bytes(const std::string& str); } \ No newline at end of file diff --git a/include/dialogue_page.hpp b/include/dialogue_page.hpp index 6f4d9fa..d2ef644 100644 --- a/include/dialogue_page.hpp +++ b/include/dialogue_page.hpp @@ -14,7 +14,7 @@ class DialoguePage : public brls::View bool erista = true; public: - DialoguePage(brls::StagedAppletFrame* frame, std::string text, bool erista = true); + DialoguePage(brls::StagedAppletFrame* frame, const std::string& text, bool erista = true); void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override; void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override; diff --git a/include/download_cheats_page.hpp b/include/download_cheats_page.hpp index ae7d1ae..9a2b1c3 100644 --- a/include/download_cheats_page.hpp +++ b/include/download_cheats_page.hpp @@ -27,7 +27,7 @@ class DownloadCheatsPage : public brls::AppletFrame void GetBuildIDFromDmnt(); void GetVersion(); void GetBuildIDFromFile(); - void WriteCheats(std::string cheatContent); + void WriteCheats(const std::string& cheatContent); void DeleteCheats(); typedef struct { diff --git a/include/extract.hpp b/include/extract.hpp index db4db2e..8b9266c 100644 --- a/include/extract.hpp +++ b/include/extract.hpp @@ -30,6 +30,6 @@ namespace extract { void extractCheats(const std::string& zipPath, std::vector titles, CFW cfw, bool credits = false); void extractAllCheats(const std::string& zipPath, CFW cfw); void removeCheats(); - bool isBID(std::string bid); + bool isBID(const std::string& bid); } \ No newline at end of file diff --git a/include/net_page.hpp b/include/net_page.hpp index 59f9993..71230ff 100644 --- a/include/net_page.hpp +++ b/include/net_page.hpp @@ -15,6 +15,6 @@ class NetPage : public brls::AppletFrame public: NetPage(); std::string ipToString(unsigned char* ip); - int stringToIp(std::string ip, unsigned char* out); + int stringToIp(const std::string& ip, unsigned char* out); }; \ No newline at end of file diff --git a/include/tools_tab.hpp b/include/tools_tab.hpp index bc0942f..5bb944f 100644 --- a/include/tools_tab.hpp +++ b/include/tools_tab.hpp @@ -24,6 +24,6 @@ class ToolsTab : public brls::List brls::StagedAppletFrame* stagedFrame; public: - ToolsTab(std::string tag, bool erista = true); + ToolsTab(const std::string& tag, bool erista = true); }; \ No newline at end of file diff --git a/include/utils.hpp b/include/utils.hpp index 94d16c8..c2a17d7 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -21,19 +21,19 @@ namespace util { void clearConsole(); bool isArchive(const std::string& path); - void downloadArchive(std::string url, archiveType type); - void downloadArchive(std::string url, archiveType type, long& status_code); - void extractArchive(archiveType type, std::string tag = "0"); + void downloadArchive(const std::string& url, archiveType type); + void downloadArchive(const std::string& url, archiveType type, long& status_code); + void extractArchive(archiveType type, const std::string& tag = "0"); std::string formatListItemTitle(const std::string &str, size_t maxScore = 140); std::string formatApplicationId(u64 ApplicationId); std::vector fetchPayloads(); void shutDown(bool reboot = false); void rebootToPayload(const std::string& path); - int showDialogBox(std::string text, std::string opt); - int showDialogBox(std::string text, std::string opt1, std::string opt2); + int showDialogBox(const std::string& text, const std::string& opt); + int showDialogBox(const std::string& text, const std::string& opt1, const std::string& opt2); std::string getLatestTag(const std::string& url); std::string downloadFileToString(const std::string& url); - void saveVersion(std::string version, const std::string& path); + void saveVersion(const std::string& version, const std::string& path); std::string readVersion(const std::string& path); bool isErista(); void removeSysmodulesFlags(const std::string& directory); diff --git a/include/warning_page.hpp b/include/warning_page.hpp index 2d4e513..dad4cbf 100644 --- a/include/warning_page.hpp +++ b/include/warning_page.hpp @@ -11,7 +11,7 @@ class WarningPage : public brls::View std::chrono::system_clock::time_point start = std::chrono::high_resolution_clock::now(); public: - WarningPage(std::string text); + WarningPage(const std::string& text); ~WarningPage(); void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override; diff --git a/lib/borealis b/lib/borealis index aee597a..22b62c7 160000 --- a/lib/borealis +++ b/lib/borealis @@ -1 +1 @@ -Subproject commit aee597a7a40f4a486c3a793f03e97aee12d009ef +Subproject commit 22b62c7bee7a156400d5109fcb8459bab0bee78a diff --git a/source/app_page.cpp b/source/app_page.cpp index 229f4b4..1622bc3 100644 --- a/source/app_page.cpp +++ b/source/app_page.cpp @@ -11,6 +11,8 @@ #include #include +#include + namespace i18n = brls::i18n; using namespace i18n::literals; @@ -53,6 +55,7 @@ void AppPage::PopulatePage() else { tid = GetCurrentApplicationId(); if (R_SUCCEEDED(InitControlData(&controlData)) && R_SUCCEEDED(GetControlData(tid, controlData, controlSize, name))) { + listItem = new brls::ListItem(name, "", util::formatApplicationId(tid)); this->DeclareGameListItem(name, tid, &controlData); } label = new brls::Label(brls::LabelStyle::SMALL, "menus/common/applet_mode_not_supported"_i18n, true); diff --git a/source/changelog_page.cpp b/source/changelog_page.cpp index 366d2a3..dc8eaab 100644 --- a/source/changelog_page.cpp +++ b/source/changelog_page.cpp @@ -184,6 +184,9 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true) verTitles.push_back("v2.11.1"); changes.push_back("\uE016 Added ability to view existing cheats when downloading cheat codes/sheets.\n\uE016 Fixed wrong tid for theme detection."); + verTitles.push_back("v2.11.2"); + changes.push_back("\uE016 Fixed crash when downloading cheats in applet mode.\n\uE016 Fixed progress bar percentage not showing past 10%."); + for(int i = verTitles.size() -1 ; i >= 0; i--){ listItem = new brls::ListItem(verTitles[i]); change = changes[i]; diff --git a/source/choice_page.cpp b/source/choice_page.cpp index 113f299..a3292b5 100644 --- a/source/choice_page.cpp +++ b/source/choice_page.cpp @@ -2,7 +2,7 @@ namespace i18n = brls::i18n; using namespace i18n::literals; - ChoicePage::ChoicePage(brls::StagedAppletFrame* frame, std::string text) + ChoicePage::ChoicePage(brls::StagedAppletFrame* frame, const std::string text) { this->yes = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel("yes"); this->yes->setParent(this); diff --git a/source/color_swapper.cpp b/source/color_swapper.cpp index 0791086..5c875e9 100644 --- a/source/color_swapper.cpp +++ b/source/color_swapper.cpp @@ -13,7 +13,7 @@ using json = nlohmann::json; namespace ColorSwapper { - int hexToBGR(std::string hex){ + int hexToBGR(const std::string& hex){ std::string R = hex.substr(0, 2); std::string G = hex.substr(2, 2); std::string B = hex.substr(4, 2); @@ -27,7 +27,7 @@ namespace ColorSwapper { return ss.str(); } - bool isHexaAnd3Bytes(std::string str){ + bool isHexaAnd3Bytes(const std::string& str){ if(str.size()!=6) return false; for(char const &c : str){ if(!isxdigit(c)) return false; @@ -39,7 +39,7 @@ namespace ColorSwapper { namespace JC { - int setColor(std::vector colors){ + int setColor(const std::vector& colors){ Result pads, ljc, rjc; int res = 0; s32 nbEntries; @@ -149,7 +149,7 @@ namespace JC { return res; } - void changeJCColor(std::vector values){ + void changeJCColor(const std::vector& values){ hiddbgInitialize(); hidsysInitialize(); ProgressEvent::instance().reset(); @@ -205,7 +205,7 @@ namespace JC { namespace PC { - int setColor(std::vector colors){ + int setColor(const std::vector& colors){ Result pads, pc; int res = 0; s32 nbEntries; @@ -301,14 +301,14 @@ namespace PC { return res; } - void changePCColor(std::vector values){ + void changePCColor(const std::vector& values){ hiddbgInitialize(); hidsysInitialize(); ProgressEvent::instance().reset(); ProgressEvent::instance().setStep(1); int res = setColor(values); if(res != 0){ - util::showDialogBox("Could not change the Pro-Con color. Make they're connected to P1. This feature may not work on unoffical controllers. \nError :" + std::to_string(res), "Ok"); + util::showDialogBox("Could not change the Pro-Con color. Make they're connected to P1. This feature may not work on unofficial controllers. \nError :" + std::to_string(res), "Ok"); } hiddbgExit(); hidsysExit(); diff --git a/source/dialogue_page.cpp b/source/dialogue_page.cpp index 61995f4..46ae4b7 100644 --- a/source/dialogue_page.cpp +++ b/source/dialogue_page.cpp @@ -8,7 +8,7 @@ namespace i18n = brls::i18n; using namespace i18n::literals; -DialoguePage::DialoguePage(brls::StagedAppletFrame* frame, std::string text, bool erista) : erista(erista) +DialoguePage::DialoguePage(brls::StagedAppletFrame* frame, const std::string& text, bool erista) : erista(erista) { this->button1 = (new brls::Button(brls::ButtonStyle::REGULAR))->setLabel("menus/common/yes"_i18n); this->button1->setParent(this); diff --git a/source/download_cheats_page.cpp b/source/download_cheats_page.cpp index 793b1f6..2a37339 100644 --- a/source/download_cheats_page.cpp +++ b/source/download_cheats_page.cpp @@ -128,7 +128,7 @@ void DownloadCheatsPage::GetBuildIDFromFile() { } } -void DownloadCheatsPage::WriteCheats(std::string cheatContent) { +void DownloadCheatsPage::WriteCheats(const std::string& cheatContent) { std::string path = util::getContentsPath(); std::string tidstr = util::formatApplicationId(this->tid); path += tidstr + "/cheats/"; diff --git a/source/extract.cpp b/source/extract.cpp index 39bbcc2..cc3193e 100644 --- a/source/extract.cpp +++ b/source/extract.cpp @@ -290,7 +290,7 @@ void extractAllCheats(const std::string& zipPath, CFW cfw){ ProgressEvent::instance().setStep(ProgressEvent::instance().getMax()); } -bool isBID(std::string bid) { +bool isBID(const std::string& bid) { for(char const &c : bid){ if(!isxdigit(c)) return false; } diff --git a/source/net_page.cpp b/source/net_page.cpp index d05243e..36c7849 100644 --- a/source/net_page.cpp +++ b/source/net_page.cpp @@ -193,7 +193,7 @@ std::string NetPage::ipToString(u8* ip){ return res; } -int NetPage::stringToIp(std::string ip, u8 *out){ +int NetPage::stringToIp(const std::string& ip, u8 *out){ size_t start; size_t end = 0; int i = 0; diff --git a/source/tools_tab.cpp b/source/tools_tab.cpp index 11fd801..7fce16f 100644 --- a/source/tools_tab.cpp +++ b/source/tools_tab.cpp @@ -24,7 +24,7 @@ namespace { constexpr const char AppVersion[] = APP_VERSION; } -ToolsTab::ToolsTab(std::string tag, bool erista) : brls::List() +ToolsTab::ToolsTab(const std::string& tag, bool erista) : brls::List() { if(!tag.empty() && tag != AppVersion){ updateApp = new brls::ListItem("menus/tools/update_app"_i18n + tag +")"); diff --git a/source/utils.cpp b/source/utils.cpp index 64f7bcd..d2be262 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -27,12 +27,12 @@ bool isArchive(const std::string& path){ return fileContent.find("DOCTYPE") == std::string::npos; } -void downloadArchive(std::string url, archiveType type) { +void downloadArchive(const std::string& url, archiveType type) { long status_code; - downloadArchive(url,type, status_code); + downloadArchive(url, type, status_code); } -void downloadArchive(std::string url, archiveType type, long& status_code) { +void downloadArchive(const std::string& url, archiveType type, long& status_code) { fs::createTree(DOWNLOAD_PATH); switch(type){ case archiveType::sigpatches: @@ -61,7 +61,7 @@ void downloadArchive(std::string url, archiveType type, long& status_code) { ProgressEvent::instance().setStatusCode(status_code); } -int showDialogBox(std::string text, std::string opt){ +int showDialogBox(const std::string& text, const std::string& opt){ int dialogResult = -1; int result = -1; brls::Dialog* dialog = new brls::Dialog(text); @@ -79,7 +79,7 @@ int showDialogBox(std::string text, std::string opt){ return result; } -int showDialogBox(std::string text, std::string opt1, std::string opt2){ +int showDialogBox(const std::string& text, const std::string& opt1, const std::string& opt2){ int dialogResult = -1; int result = -1; brls::Dialog* dialog = new brls::Dialog(text); @@ -102,7 +102,7 @@ int showDialogBox(std::string text, std::string opt1, std::string opt2){ return result; } -void extractArchive(archiveType type, std::string tag){ +void extractArchive(archiveType type, const std::string& tag){ int overwriteInis = 0; std::vector titles; std::string nroPath ="sdmc:" + std::string(APP_PATH); @@ -235,7 +235,7 @@ std::string downloadFileToString(const std::string& url) { return str; } -void saveVersion(std::string version, const std::string& path){ +void saveVersion(const std::string& version, const std::string& path){ std::ofstream newVersion(path); newVersion << version << std::endl; } diff --git a/source/warning_page.cpp b/source/warning_page.cpp index b636d41..fced153 100644 --- a/source/warning_page.cpp +++ b/source/warning_page.cpp @@ -8,7 +8,7 @@ namespace i18n = brls::i18n; using namespace i18n::literals; -WarningPage::WarningPage(std::string text) +WarningPage::WarningPage(const std::string& text) { fs::createTree(CONFIG_PATH); std::ofstream hiddenFile(HIDDEN_AIO_FILE);