diff --git a/rpcs3/Emu/Io/Skylander.cpp b/rpcs3/Emu/Io/Skylander.cpp index b018ff59de..60e9c4dc99 100644 --- a/rpcs3/Emu/Io/Skylander.cpp +++ b/rpcs3/Emu/Io/Skylander.cpp @@ -153,27 +153,35 @@ bool sky_portal::remove_skylander(u8 sky_num) return false; } -u8 sky_portal::load_skylander(u8* buf, fs::file in_file) +u8 sky_portal::load_skylander(u8* buf, fs::file in_file, int requested_slot) { std::lock_guard lock(sky_mutex); const u32 sky_serial = read_from_ptr>(buf); u8 found_slot = 0xFF; - // mimics spot retaining on the portal - for (u8 i = 0; i < 8; i++) + if (requested_slot >= 0 && requested_slot <= 7) { - if ((skylanders[i].status & 1) == 0) + if ((skylanders[requested_slot].status & 1) == 0) + found_slot = static_cast(requested_slot); + } + else + { + // mimics spot retaining on the portal + for (u8 i = 0; i < 8; i++) { - if (skylanders[i].last_id == sky_serial) + if ((skylanders[i].status & 1) == 0) { - found_slot = i; - break; - } + if (skylanders[i].last_id == sky_serial) + { + found_slot = i; + break; + } - if (i < found_slot) - { - found_slot = i; + if (i < found_slot) + { + found_slot = i; + } } } } diff --git a/rpcs3/Emu/Io/Skylander.h b/rpcs3/Emu/Io/Skylander.h index af1c9bc4cf..2d0f49a77a 100644 --- a/rpcs3/Emu/Io/Skylander.h +++ b/rpcs3/Emu/Io/Skylander.h @@ -26,7 +26,7 @@ public: void write_block(u8 sky_num, u8 block, const u8* to_write_buf, u8* reply_buf); bool remove_skylander(u8 sky_num); - u8 load_skylander(u8* buf, fs::file in_file); + u8 load_skylander(u8* buf, fs::file in_file, int requested_slot = -1); void get_figure_info(u8 sky_num, u8& out_status, u16& out_id, u16& out_variant); protected: diff --git a/rpcs3/Emu/Io/SkylanderPortalIPC.cpp b/rpcs3/Emu/Io/SkylanderPortalIPC.cpp index d8a75126a0..26230c058a 100644 --- a/rpcs3/Emu/Io/SkylanderPortalIPC.cpp +++ b/rpcs3/Emu/Io/SkylanderPortalIPC.cpp @@ -39,7 +39,7 @@ static std::string handle_load(int slot, const std::string& path) if (sky_file.read(buf.data(), buf.size()) != buf.size()) return "error file too small\n"; - const u8 result = g_skyportal.load_skylander(buf.data(), std::move(sky_file)); + const u8 result = g_skyportal.load_skylander(buf.data(), std::move(sky_file), slot); if (result == 0xFF) return "error no free slot\n";