Skip to content

Commit

Permalink
Update core, format, and string_viewify loader
Browse files Browse the repository at this point in the history
  • Loading branch information
piepie62 committed Apr 10, 2024
1 parent 386edb7 commit e3074a9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
6 changes: 4 additions & 2 deletions 3ds/source/gui/screen/BagScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,10 @@ std::span<const int> 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 {};
}

Expand Down
16 changes: 9 additions & 7 deletions 3ds/source/gui/screen/CloudScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>();
} 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<int>());
}
}


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<std::string&>());

Expand Down
6 changes: 3 additions & 3 deletions 3ds/source/titles/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion 3ds/source/utils/TextParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion core

0 comments on commit e3074a9

Please sign in to comment.