From 1b1439c6af5f763dc0c21d82ad2691702d974dd0 Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Sun, 12 Aug 2018 23:47:48 +0300 Subject: [PATCH] NWM_UDS: use sizeof() instead of hard-coded type (#4093) * NWM_UDS: use sizeof() instead of hard-coded type Intend to fix #4090. ` node_map.node.second` type was changed to `u16` in #3985. However the type change wasn't reflected here. Should have used variable name instead to automatically do type change * NWM_UDS: ... and also the node.first one * NWM_UDS: ... and here * Network: bump version because we changed UDS packet layout * Update nwm_uds.cpp --- src/core/hle/service/nwm/nwm_uds.cpp | 5 +++-- src/network/room.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 5c6cca142..cb2850358 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -161,14 +161,15 @@ static void BroadcastNodeMap() { packet.type = Network::WifiPacket::PacketType::NodeMap; packet.destination_address = Network::BroadcastMac; size_t size = node_map.size(); - packet.data.resize(sizeof(size) + (sizeof(Network::MacAddress) + sizeof(u32)) * size); + using node_t = decltype(node_map)::value_type; + packet.data.resize(sizeof(size) + (sizeof(node_t::first) + sizeof(node_t::second)) * size); std::memcpy(packet.data.data(), &size, sizeof(size)); size_t offset = sizeof(size); for (const auto& node : node_map) { std::memcpy(packet.data.data() + offset, node.first.data(), sizeof(node.first)); std::memcpy(packet.data.data() + offset + sizeof(node.first), &node.second, sizeof(node.second)); - offset += sizeof(Network::MacAddress) + sizeof(u32); + offset += sizeof(node.first) + sizeof(node.second); } SendPacket(packet); diff --git a/src/network/room.h b/src/network/room.h index db54dcc7f..ded4aa1c0 100644 --- a/src/network/room.h +++ b/src/network/room.h @@ -12,7 +12,7 @@ namespace Network { -constexpr u32 network_version = 2; ///< The version of this Room and RoomMember +constexpr u32 network_version = 3; ///< The version of this Room and RoomMember constexpr u16 DefaultRoomPort = 24872;