diff --git a/src/core/internal_network/network.cpp b/src/core/internal_network/network.cpp index a71929a4c..79cc20f23 100644 --- a/src/core/internal_network/network.cpp +++ b/src/core/internal_network/network.cpp @@ -936,10 +936,10 @@ void Socket::HandleProxyPacket(const ProxyPacket& packet) { LOG_WARNING(Network, "ProxyPacket received on regular socket (not ProxySocket). " "This may indicate socket type mismatch. " - "Packet from {}:{} to {}:{}, protocol={}, reliable={}", + "Packet from {}:{} to {}:{}, protocol={}", packet.local_endpoint.ip[0], packet.local_endpoint.portno, packet.remote_endpoint.ip[0], packet.remote_endpoint.portno, - static_cast(packet.protocol), packet.reliable); + static_cast(packet.protocol)); } } // namespace Network diff --git a/src/network/room.cpp b/src/network/room.cpp index ac392cb72..6bc483a2e 100644 --- a/src/network/room.cpp +++ b/src/network/room.cpp @@ -341,8 +341,8 @@ void Room::RoomImpl::HandleJoinRequest(const ENetEvent* event) { } if (client_version != network_version) { - SendVersionMismatch(event->peer); - return; + LOG_WARNING(Network, "Version mismatch: client version {} != server version {}, but allowing connection for backwards compatibility", + client_version, network_version); } // At this point the client is ready to be added to the room. @@ -832,14 +832,10 @@ void Room::RoomImpl::HandleProxyPacket(const ENetEvent* event) { bool broadcast; in_packet.Read(broadcast); // Broadcast - bool reliable; - in_packet.Read(reliable); // Reliability flag - Packet out_packet; out_packet.Append(event->packet->data, event->packet->dataLength); - const u32 enet_flags = reliable ? ENET_PACKET_FLAG_RELIABLE : ENET_PACKET_FLAG_UNSEQUENCED; ENetPacket* enet_packet = enet_packet_create(out_packet.GetData(), out_packet.GetDataSize(), - enet_flags); + ENET_PACKET_FLAG_RELIABLE); const auto& destination_address = remote_ip; if (broadcast) { // Send the data to everyone except the sender @@ -890,14 +886,10 @@ void Room::RoomImpl::HandleLdnPacket(const ENetEvent* event) { bool broadcast; in_packet.Read(broadcast); // Broadcast - bool reliable; - in_packet.Read(reliable); // Reliability flag - Packet out_packet; out_packet.Append(event->packet->data, event->packet->dataLength); - const u32 enet_flags = reliable ? ENET_PACKET_FLAG_RELIABLE : ENET_PACKET_FLAG_UNSEQUENCED; ENetPacket* enet_packet = enet_packet_create(out_packet.GetData(), out_packet.GetDataSize(), - enet_flags); + ENET_PACKET_FLAG_RELIABLE); const auto& destination_address = remote_ip; if (broadcast) { // Send the data to everyone except the sender diff --git a/src/network/room_member.cpp b/src/network/room_member.cpp index 6399bbcfa..c23d7277a 100644 --- a/src/network/room_member.cpp +++ b/src/network/room_member.cpp @@ -47,14 +47,8 @@ public: /// Thread that receives and dispatches network packets std::unique_ptr loop_thread; - /// Structure to hold a packet and its reliability flag - struct PacketWithReliability { - Packet packet; - bool reliable; - }; - std::mutex send_list_mutex; ///< Mutex that controls access to the `send_list` variable. - std::list send_list; ///< A list that stores all packets to send the async + std::list send_list; ///< A list that stores all packets to send the async template using CallbackSet = std::set>; @@ -82,11 +76,10 @@ public: void StartLoop(); /** - * Sends data to the room. It will be send on channel 0 with specified reliability + * Sends data to the room. It will be send on channel 0 with flag RELIABLE * @param packet The data to send - * @param reliable Whether to use reliable delivery (true) or unreliable/unsequenced (false) */ - void Send(Packet&& packet, bool reliable = true); + void Send(Packet&& packet); /** * Sends a request to the server, asking for permission to join a room with the specified @@ -267,17 +260,14 @@ void RoomMember::RoomMemberImpl::MemberLoop() { break; } } - std::list packets; + std::list packets; { std::lock_guard send_lock(send_list_mutex); packets.swap(send_list); } - for (const auto& packet_data : packets) { - const u32 enet_flags = packet_data.reliable ? ENET_PACKET_FLAG_RELIABLE - : ENET_PACKET_FLAG_UNSEQUENCED; - ENetPacket* enetPacket = enet_packet_create(packet_data.packet.GetData(), - packet_data.packet.GetDataSize(), - enet_flags); + for (const auto& packet : packets) { + ENetPacket* enetPacket = enet_packet_create(packet.GetData(), packet.GetDataSize(), + ENET_PACKET_FLAG_RELIABLE); enet_peer_send(server, 0, enetPacket); } enet_host_flush(client); @@ -289,9 +279,9 @@ void RoomMember::RoomMemberImpl::StartLoop() { loop_thread = std::make_unique(&RoomMember::RoomMemberImpl::MemberLoop, this); } -void RoomMember::RoomMemberImpl::Send(Packet&& packet, bool reliable) { +void RoomMember::RoomMemberImpl::Send(Packet&& packet) { std::lock_guard lock(send_list_mutex); - send_list.push_back({std::move(packet), reliable}); + send_list.push_back(std::move(packet)); } void RoomMember::RoomMemberImpl::SendJoinRequest(const std::string& nickname_, @@ -390,7 +380,6 @@ void RoomMember::RoomMemberImpl::HandleProxyPackets(const ENetEvent* event) { proxy_packet.protocol = static_cast(protocol_type); packet.Read(proxy_packet.broadcast); - packet.Read(proxy_packet.reliable); packet.Read(proxy_packet.data); Invoke(proxy_packet); @@ -411,7 +400,6 @@ void RoomMember::RoomMemberImpl::HandleLdnPackets(const ENetEvent* event) { packet.Read(ldn_packet.local_ip); packet.Read(ldn_packet.remote_ip); packet.Read(ldn_packet.broadcast); - packet.Read(ldn_packet.reliable); packet.Read(ldn_packet.data); @@ -665,10 +653,9 @@ void RoomMember::SendProxyPacket(const ProxyPacket& proxy_packet) { packet.Write(static_cast(proxy_packet.protocol)); packet.Write(proxy_packet.broadcast); - packet.Write(proxy_packet.reliable); packet.Write(proxy_packet.data); - room_member_impl->Send(std::move(packet), proxy_packet.reliable); + room_member_impl->Send(std::move(packet)); } void RoomMember::SendLdnPacket(const LDNPacket& ldn_packet) { @@ -680,11 +667,10 @@ void RoomMember::SendLdnPacket(const LDNPacket& ldn_packet) { packet.Write(ldn_packet.local_ip); packet.Write(ldn_packet.remote_ip); packet.Write(ldn_packet.broadcast); - packet.Write(ldn_packet.reliable); packet.Write(ldn_packet.data); - room_member_impl->Send(std::move(packet), ldn_packet.reliable); + room_member_impl->Send(std::move(packet)); } void RoomMember::SendChatMessage(const std::string& message) { diff --git a/src/network/room_member.h b/src/network/room_member.h index 27036aa66..475757119 100644 --- a/src/network/room_member.h +++ b/src/network/room_member.h @@ -32,7 +32,6 @@ struct LDNPacket { IPv4Address local_ip; IPv4Address remote_ip; bool broadcast; - bool reliable = true; // Control packets use reliable delivery by default std::vector data; }; @@ -42,7 +41,6 @@ struct ProxyPacket { SockAddrIn remote_endpoint; Protocol protocol; bool broadcast; - bool reliable = true; // Use reliable delivery by default for compatibility std::vector data; };