diff --git a/src/core/hle/service/nwm/nwm.cpp b/src/core/hle/service/nwm/nwm.cpp index ce4c98bce9..9fc0537c04 100644 --- a/src/core/hle/service/nwm/nwm.cpp +++ b/src/core/hle/service/nwm/nwm.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include #include "core/hle/service/nwm/nwm.h" #include "core/hle/service/nwm/nwm_cec.h" #include "core/hle/service/nwm/nwm_ext.h" @@ -10,6 +11,8 @@ #include "core/hle/service/nwm/nwm_soc.h" #include "core/hle/service/nwm/nwm_tst.h" #include "core/hle/service/nwm/nwm_uds.h" +#include "core/hle/shared_page.h" +#include "network/network.h" namespace Service { namespace NWM { @@ -21,6 +24,21 @@ void Init() { AddService(new NWM_SAP); AddService(new NWM_SOC); AddService(new NWM_TST); + + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution<> dis(0, std::numeric_limits::max()); + auto mac = SharedPage::DefaultMac; + for (int i = 3; i < sizeof(SharedPage::MacAddress); ++i) { + mac[i] = static_cast(dis(gen)); + } + if (auto room_member = Network::GetRoomMember().lock()) { + if (room_member->IsConnected()) { + mac = static_cast(room_member->GetMacAddress()); + } + } + SharedPage::SetMacAddress(mac); + SharedPage::SetWifiLinkLevel(SharedPage::WifiLinkLevel::BEST); } void InstallInterfaces(SM::ServiceManager& service_manager) { diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 19bcf87e24..d120260d42 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -593,12 +593,6 @@ void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) { node_info.push_back(current_node); } - if (auto room_member = Network::GetRoomMember().lock()) { - if (room_member->IsConnected()) { - SharedPage::SetMacAddress(static_cast(room_member->GetMacAddress())); - } - } - IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); rb.Push(RESULT_SUCCESS); rb.PushCopyObjects(connection_status_event); diff --git a/src/core/hle/shared_page.cpp b/src/core/hle/shared_page.cpp index 47e6369ef5..0102d0f5ec 100644 --- a/src/core/hle/shared_page.cpp +++ b/src/core/hle/shared_page.cpp @@ -83,9 +83,6 @@ void Init() { update_time_event = CoreTiming::RegisterEvent("SharedPage::UpdateTimeCallback", UpdateTimeCallback); CoreTiming::ScheduleEvent(0, update_time_event); - - SetWifiLinkLevel(WifiLinkLevel::POOR); - SetMacAddress(DefaultMac); } void SetMacAddress(const MacAddress& addr) { @@ -96,4 +93,4 @@ void SetWifiLinkLevel(WifiLinkLevel level) { shared_page.wifi_link_level = static_cast(level); } -} // namespace +} // namespace SharedPage diff --git a/src/core/hle/shared_page.h b/src/core/hle/shared_page.h index 181932c4b9..1e2fce6b7a 100644 --- a/src/core/hle/shared_page.h +++ b/src/core/hle/shared_page.h @@ -39,13 +39,14 @@ union BatteryState { using MacAddress = std::array; -// Default MAC address in the nintendo 3ds range -constexpr MacAddress DefaultMac = { 0x40, 0xF4, 0x07, 0x00, 0x00, 0x00 }; +// Default MAC address in the Nintendo 3DS range +constexpr MacAddress DefaultMac = {0x40, 0xF4, 0x07, 0x00, 0x00, 0x00}; enum class WifiLinkLevel : u8 { - POOR = 0, - GOOD = 1, - BEST = 2, + OFF = 0, + POOR = 1, + GOOD = 2, + BEST = 3, }; struct SharedPageDef { @@ -81,4 +82,4 @@ void SetMacAddress(const MacAddress&); void SetWifiLinkLevel(WifiLinkLevel); -} // namespace +} // namespace SharedPage