From 875eae2c07fd490a577112856136602eff1e5fd2 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Tue, 13 Sep 2022 08:10:53 +0200 Subject: [PATCH] early-access version 2948 --- README.md | 2 +- src/core/hle/service/ldn/lan_discovery.cpp | 29 +++++++------------ src/core/hle/service/ldn/lan_discovery.h | 13 +++++---- src/core/hle/service/ldn/ldn.cpp | 2 -- src/core/hle/service/ldn/ldn_types.h | 8 +---- .../internal_network/network_interface.cpp | 4 +-- src/network/room_member.cpp | 2 +- .../configuration/configure_input_player.cpp | 2 +- 8 files changed, 24 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 326096f05..0c251d834 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2947. +This is the source code for early-access 2948. ## Legal Notice diff --git a/src/core/hle/service/ldn/lan_discovery.cpp b/src/core/hle/service/ldn/lan_discovery.cpp index b04c99077..c8eb2b507 100755 --- a/src/core/hle/service/ldn/lan_discovery.cpp +++ b/src/core/hle/service/ldn/lan_discovery.cpp @@ -35,12 +35,9 @@ void LanStation::OverrideInfo() { LANDiscovery::LANDiscovery(Network::RoomNetwork& room_network_) : stations({{{1, this}, {2, this}, {3, this}, {4, this}, {5, this}, {6, this}, {7, this}}}), - room_network{room_network_} { - LOG_INFO(Service_LDN, "LANDiscovery"); -} + room_network{room_network_} {} LANDiscovery::~LANDiscovery() { - LOG_INFO(Service_LDN, "~LANDiscovery"); if (inited) { Result rc = Finalize(); LOG_INFO(Service_LDN, "Finalize: {}", rc.raw); @@ -62,7 +59,7 @@ void LANDiscovery::InitNetworkInfo() { } void LANDiscovery::InitNodeStateChange() { - for (auto& node_update : nodeChanges) { + for (auto& node_update : node_changes) { node_update.state_change = NodeStateChange::None; } for (auto& node_state : node_last_states) { @@ -97,8 +94,8 @@ Result LANDiscovery::GetNetworkInfo(NetworkInfo& out_network, if (state == State::AccessPointCreated || state == State::StationConnected) { std::memcpy(&out_network, &network_info, sizeof(network_info)); for (std::size_t i = 0; i < buffer_count; i++) { - out_updates[i].state_change = nodeChanges[i].state_change; - nodeChanges[i].state_change = NodeStateChange::None; + out_updates[i].state_change = node_changes[i].state_change; + node_changes[i].state_change = NodeStateChange::None; } return ResultSuccess; } @@ -168,9 +165,9 @@ Result LANDiscovery::Scan(std::vector& networks, u16& count, return ResultSuccess; } -Result LANDiscovery::SetAdvertiseData(std::vector& data) { +Result LANDiscovery::SetAdvertiseData(std::span data) { std::scoped_lock lock{packet_mutex}; - std::size_t size = data.size(); + const std::size_t size = data.size(); if (size > AdvertiseDataSizeMax) { return ResultAdvertiseDataTooLarge; } @@ -328,7 +325,7 @@ Result LANDiscovery::Disconnect() { return ResultSuccess; } -Result LANDiscovery::Initialize(LanEventFunc lan_event, bool listening) { +Result LANDiscovery::Initialize(LanEventFunc lan_event_, bool listening) { std::scoped_lock lock{packet_mutex}; if (inited) { return ResultSuccess; @@ -341,7 +338,7 @@ Result LANDiscovery::Initialize(LanEventFunc lan_event, bool listening) { } connected_clients.clear(); - LanEvent = lan_event; + LanEvent = lan_event_; SetState(State::Initialized); @@ -439,7 +436,6 @@ void LANDiscovery::SendPacket(Network::LDNPacketType type, const Data& data, packet.local_ip = GetLocalIp(); packet.remote_ip = remote_ip; - packet.data.clear(); packet.data.resize(sizeof(data)); std::memcpy(packet.data.data(), &data, sizeof(data)); SendPacket(packet); @@ -453,7 +449,6 @@ void LANDiscovery::SendPacket(Network::LDNPacketType type, Ipv4Address remote_ip packet.local_ip = GetLocalIp(); packet.remote_ip = remote_ip; - packet.data.clear(); SendPacket(packet); } @@ -465,7 +460,6 @@ void LANDiscovery::SendBroadcast(Network::LDNPacketType type, const Data& data) packet.broadcast = true; packet.local_ip = GetLocalIp(); - packet.data.clear(); packet.data.resize(sizeof(data)); std::memcpy(packet.data.data(), &data, sizeof(data)); SendPacket(packet); @@ -478,7 +472,6 @@ void LANDiscovery::SendBroadcast(Network::LDNPacketType type) { packet.broadcast = true; packet.local_ip = GetLocalIp(); - packet.data.clear(); SendPacket(packet); } @@ -581,9 +574,9 @@ bool LANDiscovery::IsNodeStateChanged() { for (int i = 0; i < NodeCountMax; i++) { if (nodes[i].is_connected != node_last_states[i]) { if (nodes[i].is_connected) { - nodeChanges[i].state_change |= NodeStateChange::Connect; + node_changes[i].state_change |= NodeStateChange::Connect; } else { - nodeChanges[i].state_change |= NodeStateChange::Disconnect; + node_changes[i].state_change |= NodeStateChange::Disconnect; } node_last_states[i] = nodes[i].is_connected; changed = true; @@ -598,7 +591,7 @@ bool LANDiscovery::IsFlagSet(ScanFilterFlag flag, ScanFilterFlag search_flag) co return (flag_value & search_flag_value) == search_flag_value; } -int LANDiscovery::GetStationCount() { +int LANDiscovery::GetStationCount() const { int count = 0; for (const auto& station : stations) { if (station.GetStatus() != NodeStatus::Disconnected) { diff --git a/src/core/hle/service/ldn/lan_discovery.h b/src/core/hle/service/ldn/lan_discovery.h index 255342456..e64e89424 100755 --- a/src/core/hle/service/ldn/lan_discovery.h +++ b/src/core/hle/service/ldn/lan_discovery.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -44,7 +45,7 @@ protected: class LANDiscovery { public: - typedef std::function LanEventFunc; + using LanEventFunc = std::function; LANDiscovery(Network::RoomNetwork& room_network_); ~LANDiscovery(); @@ -58,7 +59,7 @@ public: DisconnectReason GetDisconnectReason() const; Result Scan(std::vector& networks, u16& count, const ScanFilter& filter); - Result SetAdvertiseData(std::vector& data); + Result SetAdvertiseData(std::span data); Result OpenAccessPoint(); Result CloseAccessPoint(); @@ -74,7 +75,7 @@ public: u16 local_communication_version); Result Disconnect(); - Result Initialize(LanEventFunc lan_event = empty_func, bool listening = true); + Result Initialize(LanEventFunc lan_event_ = empty_func, bool listening = true); Result Finalize(); void ReceivePacket(const Network::LDNPacket& packet); @@ -94,7 +95,7 @@ protected: bool IsNodeStateChanged(); bool IsFlagSet(ScanFilterFlag flag, ScanFilterFlag search_flag) const; - int GetStationCount(); + int GetStationCount() const; MacAddress GetFakeMac() const; Result GetNodeInfo(NodeInfo& node, const UserConfig& user_config, u16 local_communication_version); @@ -114,7 +115,7 @@ protected: bool inited{}; std::mutex packet_mutex; std::array stations; - std::array nodeChanges{}; + std::array node_changes{}; std::array node_last_states{}; std::unordered_map scan_results{}; NodeInfo node_info{}; @@ -124,7 +125,7 @@ protected: // TODO (flTobi): Should this be an std::set? std::vector connected_clients; - std::optional host_ip = std::nullopt; + std::optional host_ip; LanEventFunc LanEvent; diff --git a/src/core/hle/service/ldn/ldn.cpp b/src/core/hle/service/ldn/ldn.cpp index 6537f49cf..ea3e7e55a 100755 --- a/src/core/hle/service/ldn/ldn.cpp +++ b/src/core/hle/service/ldn/ldn.cpp @@ -205,8 +205,6 @@ public: } void GetIpv4Address(Kernel::HLERequestContext& ctx) { - LOG_CRITICAL(Service_LDN, "called"); - const auto network_interface = Network::GetSelectedNetworkInterface(); if (!network_interface) { diff --git a/src/core/hle/service/ldn/ldn_types.h b/src/core/hle/service/ldn/ldn_types.h index d6609fff5..de3cd6b76 100755 --- a/src/core/hle/service/ldn/ldn_types.h +++ b/src/core/hle/service/ldn/ldn_types.h @@ -31,13 +31,7 @@ enum class NodeStateChange : u8 { DisconnectAndConnect, }; -inline NodeStateChange operator|(NodeStateChange a, NodeStateChange b) { - return static_cast(static_cast(a) | static_cast(b)); -} - -inline NodeStateChange operator|=(NodeStateChange& a, NodeStateChange b) { - return a = a | b; -} +DECLARE_ENUM_FLAG_OPERATORS(NodeStateChange) enum class ScanFilterFlag : u32 { None = 0, diff --git a/src/core/internal_network/network_interface.cpp b/src/core/internal_network/network_interface.cpp index 858ae1cfb..057fd3661 100755 --- a/src/core/internal_network/network_interface.cpp +++ b/src/core/internal_network/network_interface.cpp @@ -188,7 +188,7 @@ std::vector GetAvailableNetworkInterfaces() { std::optional GetSelectedNetworkInterface() { const auto& selected_network_interface = Settings::values.network_interface.GetValue(); const auto network_interfaces = Network::GetAvailableNetworkInterfaces(); - if (network_interfaces.size() == 0) { + if (network_interfaces.empty()) { LOG_ERROR(Network, "GetAvailableNetworkInterfaces returned no interfaces"); return std::nullopt; } @@ -209,7 +209,7 @@ std::optional GetSelectedNetworkInterface() { void SelectFirstNetworkInterface() { const auto network_interfaces = Network::GetAvailableNetworkInterfaces(); - if (network_interfaces.size() == 0) { + if (network_interfaces.empty()) { return; } diff --git a/src/network/room_member.cpp b/src/network/room_member.cpp index 572e55a5b..b94cb24ad 100755 --- a/src/network/room_member.cpp +++ b/src/network/room_member.cpp @@ -716,7 +716,7 @@ RoomMember::CallbackHandle RoomMember::BindOnProxyPacketReceived( RoomMember::CallbackHandle RoomMember::BindOnLdnPacketReceived( std::function callback) { - return room_member_impl->Bind(callback); + return room_member_impl->Bind(std::move(callback)); } RoomMember::CallbackHandle RoomMember::BindOnRoomInformationChanged( diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 9b4f765ce..9e5a40fe7 100755 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -1417,7 +1417,7 @@ void ConfigureInputPlayer::HandleClick( ui->controllerFrame->BeginMappingAnalog(button_id); } - timeout_timer->start(2500); // Cancel after 2.5 seconds + timeout_timer->start(4000); // Cancel after 4 seconds poll_timer->start(25); // Check for new inputs every 25ms }