Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only enable exceptions for builds with ZeroTier #6824

Merged
merged 2 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions Source/dvlnet/abstract_net.cpp
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
41 changes: 18 additions & 23 deletions Source/dvlnet/base_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,32 +274,27 @@ tl::expected<void, PacketError> base_protocol<P>::SendTo(plr_t player, packet &p
template <class P>
void base_protocol<P>::recv()
{
try {
buffer_t pkt_buf;
endpoint_t sender;
while (proto.recv(sender, pkt_buf)) { // read until kernel buffer is empty?
tl::expected<void, PacketError> result
= pktfty->make_packet(pkt_buf)
.and_then([&](std::unique_ptr<packet> &&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<void, PacketError> result
= pktfty->make_packet(pkt_buf)
.and_then([&](std::unique_ptr<packet> &&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;
}
}

Expand Down