diff --git a/similar/main/net_udp.cpp b/similar/main/net_udp.cpp index fffe271fc..8d2d309d7 100644 --- a/similar/main/net_udp.cpp +++ b/similar/main/net_udp.cpp @@ -637,6 +637,14 @@ public: } }; +constexpr std::array udp_response_version_deny{{ + UPID_VERSION_DENY, + DXX_CONST_INIT_LE16(DXX_VERSION_MAJORi), + DXX_CONST_INIT_LE16(DXX_VERSION_MINORi), + DXX_CONST_INIT_LE16(DXX_VERSION_MICROi), + DXX_CONST_INIT_LE16(MULTI_PROTO_VERSION), +}}; + static const char *dxx_ntop(const _sockaddr &sa, typename _sockaddr::presentation_buffer &dbuf) { #ifdef WIN32 @@ -808,6 +816,11 @@ static game_info_request_result net_udp_check_game_info_request(const uint8_t *c return net_udp_check_game_info_request(data); } +static void net_udp_send_version_deny(const _sockaddr &sender_addr) +{ + dxx_sendto(UDP_Socket[0], udp_response_version_deny, 0, sender_addr); +} + } } @@ -2706,17 +2719,6 @@ void dispatch_table::send_endlevel_packet() const namespace { -static void net_udp_send_version_deny(const _sockaddr &sender_addr) -{ - std::array buf; - buf[0] = UPID_VERSION_DENY; - PUT_INTEL_SHORT(&buf[1], DXX_VERSION_MAJORi); - PUT_INTEL_SHORT(&buf[3], DXX_VERSION_MINORi); - PUT_INTEL_SHORT(&buf[5], DXX_VERSION_MICROi); - PUT_INTEL_SHORT(&buf[7], MULTI_PROTO_VERSION); - dxx_sendto(UDP_Socket[0], buf, 0, sender_addr); -} - static void net_udp_process_version_deny(const uint8_t *const data, const _sockaddr &) { Netgame.protocol.udp.program_iver[0] = GET_INTEL_SHORT(&data[1]);