From e3074a94619f37f31fd38fb71979f8bbb769f365 Mon Sep 17 00:00:00 2001 From: Chris Feger Date: Wed, 10 Apr 2024 13:10:33 -0400 Subject: [PATCH] Update core, format, and string_viewify loader --- 3ds/source/gui/screen/BagScreen.cpp | 6 ++++-- 3ds/source/gui/screen/CloudScreen.cpp | 16 +++++++++------- 3ds/source/titles/loader.cpp | 6 +++--- 3ds/source/utils/TextParse.cpp | 2 +- core | 2 +- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/3ds/source/gui/screen/BagScreen.cpp b/3ds/source/gui/screen/BagScreen.cpp index 7743cfe6..6905b397 100644 --- a/3ds/source/gui/screen/BagScreen.cpp +++ b/3ds/source/gui/screen/BagScreen.cpp @@ -620,8 +620,10 @@ std::span BagScreen::itemsForPouch(pksm::Sav::Pouch pouch) const const auto found = std::find_if(allowedItems.begin(), allowedItems.end(), [s = pouch](const auto& i) { return i.first == s; }); - if (found->second.size() > 1000 || found->second.size() == 0) { - // Should a match fail to be found, we don't want the app freaking out, so return an empty array. + if (found->second.size() > 1000 || found->second.size() == 0) + { + // Should a match fail to be found, we don't want the app freaking out, so return an empty + // array. return {}; } diff --git a/3ds/source/gui/screen/CloudScreen.cpp b/3ds/source/gui/screen/CloudScreen.cpp index 8df0d3e8..d3b08523 100644 --- a/3ds/source/gui/screen/CloudScreen.cpp +++ b/3ds/source/gui/screen/CloudScreen.cpp @@ -928,23 +928,25 @@ void CloudScreen::shareReceive() } nlohmann::json retJson = nlohmann::json::parse(retData, nullptr, false); - + std::string generation = ""; - if (retJson.contains("generation")) { - if(retJson["generation"].is_string()) { + if (retJson.contains("generation")) + { + if (retJson["generation"].is_string()) + { generation = retJson["generation"].get(); - } else if(retJson["generation"].is_number()) { + } + else if (retJson["generation"].is_number()) + { // convert the number to a string generation = std::to_string(retJson["generation"].get()); } } - if (retJson.is_object() && generation != "" && retJson.contains("pokemon") && retJson["pokemon"].is_string()) { - pksm::Generation gen = - pksm::Generation::fromString(generation); + pksm::Generation gen = pksm::Generation::fromString(generation); auto retData = base64_decode(retJson["pokemon"].get_ref()); diff --git a/3ds/source/titles/loader.cpp b/3ds/source/titles/loader.cpp index dd8dec50..d83b37f5 100644 --- a/3ds/source/titles/loader.cpp +++ b/3ds/source/titles/loader.cpp @@ -98,7 +98,7 @@ namespace pksm::GameVersion::MN, pksm::GameVersion::US, pksm::GameVersion::UM, pksm::GameVersion::GP, pksm::GameVersion::GE, pksm::GameVersion::SW, pksm::GameVersion::SH}; - std::string idToSaveName(const std::string& id) + std::string idToSaveName(std::string_view id) { if (id.size() == 3 || id.size() == 4) { @@ -160,7 +160,7 @@ namespace return "main"; } - std::string idToSaveName(const std::u16string& id) + std::string idToSaveName(std::u16string_view id) { if (id.size() == 3 || id.size() == 4) { @@ -537,7 +537,7 @@ void TitleLoader::backupSave(const std::string& id) path += std::format("/{0:d}-{1:d}-{2:d}_{3:d}-{4:d}-{5:d}/", now.year(), now.month(), now.day(), now.hour(), now.minute(), now.second()); mkdir(path.c_str(), 777); - path += idToSaveName(id); + path += idToSaveName(id); FILE* out = fopen(path.c_str(), "wb"); if (out) { diff --git a/3ds/source/utils/TextParse.cpp b/3ds/source/utils/TextParse.cpp index a6508dc5..2c1885ec 100644 --- a/3ds/source/utils/TextParse.cpp +++ b/3ds/source/utils/TextParse.cpp @@ -75,7 +75,7 @@ namespace TextParse for (auto& glyph : word.first) { glyph.xPos += lineWidths.back(); - glyph.line = lines(); + glyph.line = lines(); } lineWidths[lines() - 1] += word.second.front(); } diff --git a/core b/core index 3f94ced9..74eb4c7a 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 3f94ced9ed97d202983d25cd750cd7b8cbbfa0dc +Subproject commit 74eb4c7a6577cb16d3626bdc3878d552dd4a14db