Skip to content

Commit

Permalink
fix: 修复mumu单实例时无法搜索到的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Dec 13, 2024
1 parent 2e6e93c commit 4dd30ad
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions source/MaaToolkit/AdbDevice/AdbDeviceWin32Finder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,28 @@ std::vector<std::string> AdbDeviceWin32Finder::find_mumu_serials(const std::file
return {};
}

std::vector<std::string> serials;
for (const auto& [key, obj] : jopt->as_object()) {
auto get_serial = [](const json::value& obj) -> std::optional<std::string> {
auto ip_opt = obj.find<std::string>("adb_host_ip");
auto port_opt = obj.find<int>("adb_port");
if (!ip_opt || !port_opt) {
return std::nullopt;
}
return std::format("{}:{}", *ip_opt, *port_opt);
};

std::vector<std::string> serials;
auto unique_serial_opt = get_serial(*jopt);
if (unique_serial_opt) {
serials.emplace_back(*std::move(unique_serial_opt));
return serials;
}

for (const auto& [key, obj] : jopt->as_object()) {
auto serial_opt = get_serial(obj);
if (!serial_opt) {
continue;
}
serials.emplace_back(std::format("{}:{}", *ip_opt, *port_opt));
serials.emplace_back(*std::move(serial_opt));
}
return serials;
}
Expand Down

0 comments on commit 4dd30ad

Please sign in to comment.