From cf54fd6d1d933377b88d46476a00b011a67c099f Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Sat, 9 Sep 2023 01:52:28 +0300 Subject: [PATCH] Fail and warn if an amiibo is loaded at the wrong time --- include/fs/archive_ext_save_data.hpp | 5 +++++ src/core/services/nfc.cpp | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/include/fs/archive_ext_save_data.hpp b/include/fs/archive_ext_save_data.hpp index fec923b4..adba568f 100644 --- a/include/fs/archive_ext_save_data.hpp +++ b/include/fs/archive_ext_save_data.hpp @@ -18,6 +18,11 @@ public: FileDescriptor openFile(const FSPath& path, const FilePerms& perms) override; std::optional readFile(FileSession* file, u64 offset, u32 size, u32 dataPointer) override; + Rust::Result getFormatInfo(const FSPath& path) override { + Helpers::warn("Stubbed ExtSaveData::GetFormatInfo"); + return Ok(FormatInfo{.size = 1_GB, .numOfDirectories = 255, .numOfFiles = 255, .duplicateData = false}); + } + // Takes in a binary ExtSaveData path, outputs a combination of the backing folder with the low and high save entries of the path // Used for identifying the archive format info files std::string getExtSaveDataPathFromBinary(const FSPath& path); diff --git a/src/core/services/nfc.cpp b/src/core/services/nfc.cpp index 9d9a37d7..bac99007 100644 --- a/src/core/services/nfc.cpp +++ b/src/core/services/nfc.cpp @@ -48,6 +48,13 @@ void NFCService::handleSyncRequest(u32 messagePointer) { bool NFCService::loadAmiibo(const std::filesystem::path& path) { IOFile file(path, "rb"); + if (!initialized || tagStatus != TagStatus::Scanning) { + Helpers::warn("It's not the correct time to load an amiibo! Make sure to load amiibi when the game is searching for one!"); + file.close(); + + return false; + } + if (!file.isOpen()) { printf("Failed to open Amiibo file"); file.close();