diff --git a/CMakeLists.txt b/CMakeLists.txt index 6477cb9ca..b17b79b00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,7 +130,7 @@ set_property(CACHE DEVILUTIONX_DEFAULT_RESAMPLER PROPERTY STRINGS ${_resamplers} option(DISABLE_LTO "Disable link-time optimization (by default enabled in release mode)" OFF) option(PIE "Generate position-independent code" OFF) cmake_dependent_option(DEVILUTIONX_DISABLE_RTTI "Disable RTTI" ON "NONET" OFF) -cmake_dependent_option(DEVILUTIONX_DISABLE_EXCEPTIONS "Disable exceptions" ON "NONET" OFF) +cmake_dependent_option(DEVILUTIONX_DISABLE_EXCEPTIONS "Disable exceptions" ON "DISABLE_ZERO_TIER" OFF) RELEASE_OPTION(DEVILUTIONX_STATIC_CXX_STDLIB "Link C++ standard library statically (if available)") option(DEVILUTIONX_PROFILE_GENERATE "Build a binary that generates the profile for PGO" OFF) option(DEVILUTIONX_PROFILE_USE "Build with PGO using the given profile file" OFF) diff --git a/Source/dvlnet/abstract_net.cpp b/Source/dvlnet/abstract_net.cpp index 17f9d50fb..a4260ee89 100644 --- a/Source/dvlnet/abstract_net.cpp +++ b/Source/dvlnet/abstract_net.cpp @@ -1,17 +1,20 @@ #include "dvlnet/abstract_net.h" +#include "dvlnet/loopback.h" #include "utils/stubs.h" + #ifndef NONET -#include "dvlnet/base_protocol.h" #include "dvlnet/cdwrap.h" + #ifndef DISABLE_ZERO_TIER +#include "dvlnet/base_protocol.h" #include "dvlnet/protocol_zt.h" #endif + #ifndef DISABLE_TCP #include "dvlnet/tcp_client.h" #endif #endif -#include "dvlnet/loopback.h" namespace devilution::net { diff --git a/Source/dvlnet/base_protocol.h b/Source/dvlnet/base_protocol.h index 8a4702a4f..cf0145066 100644 --- a/Source/dvlnet/base_protocol.h +++ b/Source/dvlnet/base_protocol.h @@ -274,32 +274,27 @@ tl::expected base_protocol

::SendTo(plr_t player, packet &p template void base_protocol

::recv() { - try { - buffer_t pkt_buf; - endpoint_t sender; - while (proto.recv(sender, pkt_buf)) { // read until kernel buffer is empty? - tl::expected result - = pktfty->make_packet(pkt_buf) - .and_then([&](std::unique_ptr &&pkt) { - return recv_decrypted(*pkt, sender); - }); - if (!result.has_value()) { - // drop packet - proto.disconnect(sender); - Log("{}", result.error().what()); - } + buffer_t pkt_buf; + endpoint_t sender; + while (proto.recv(sender, pkt_buf)) { // read until kernel buffer is empty? + tl::expected result + = pktfty->make_packet(pkt_buf) + .and_then([&](std::unique_ptr &&pkt) { + return recv_decrypted(*pkt, sender); + }); + if (!result.has_value()) { + // drop packet + proto.disconnect(sender); + Log("{}", result.error().what()); } - while (proto.get_disconnected(sender)) { - for (plr_t i = 0; i < Players.size(); ++i) { - if (peers[i].endpoint == sender) { - DisconnectNet(i); - break; - } + } + while (proto.get_disconnected(sender)) { + for (plr_t i = 0; i < Players.size(); ++i) { + if (peers[i].endpoint == sender) { + DisconnectNet(i); + break; } } - } catch (std::exception &e) { - Log("{}", e.what()); - return; } }