From fefe550805311f321518a13bb661754914210f34 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Wed, 19 May 2021 11:42:10 +0200 Subject: [PATCH] Fixed a client disconnect bug --- git-teaspeak | 2 +- server/src/client/command_handler/channel.cpp | 38 ++++++++++++++----- shared | 2 +- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/git-teaspeak b/git-teaspeak index cf3e1ed..b1565e4 160000 --- a/git-teaspeak +++ b/git-teaspeak @@ -1 +1 @@ -Subproject commit cf3e1ed1069fca6f8bb657f96f851b5de4c8b033 +Subproject commit b1565e43b01349fb9c66eb876711c115214cd823 diff --git a/server/src/client/command_handler/channel.cpp b/server/src/client/command_handler/channel.cpp index b5800fd..b81fc2f 100644 --- a/server/src/client/command_handler/channel.cpp +++ b/server/src/client/command_handler/channel.cpp @@ -1430,7 +1430,7 @@ ts::command_result ConnectedClient::execute_channel_edit(ChannelId& channel_id, } } - std::deque> child_channel_type_updates{}; + std::deque, std::vector>> child_channel_type_updates{}; /* updating all child channels */ { @@ -1446,10 +1446,34 @@ ts::command_result ConnectedClient::execute_channel_edit(ChannelId& channel_id, } if (child->channelType() < target_channel_type) { - child->setChannelType(target_channel_type); + std::vector channel_property_updates{}; + channel_property_updates.reserve(16); + + child->updateChannelType(channel_property_updates, target_channel_type); + if(target_channel_type == ChannelType::temporary) { + if(child->properties()[property::CHANNEL_FLAG_MAXCLIENTS_UNLIMITED].update_value(true)) { + channel_property_updates.push_back(property::CHANNEL_FLAG_MAXCLIENTS_UNLIMITED); + } + + if(child->properties()[property::CHANNEL_FLAG_MAXFAMILYCLIENTS_INHERITED].update_value(false)) { + channel_property_updates.push_back(property::CHANNEL_FLAG_MAXFAMILYCLIENTS_INHERITED); + } + + if(child->properties()[property::CHANNEL_MAXCLIENTS].update_value(-1)) { + channel_property_updates.push_back(property::CHANNEL_MAXCLIENTS); + } + + if(child->properties()[property::CHANNEL_MAXFAMILYCLIENTS].update_value(-1)) { + channel_property_updates.push_back(property::CHANNEL_MAXFAMILYCLIENTS); + } + + if(child->properties()[property::CHANNEL_FLAG_MAXFAMILYCLIENTS_UNLIMITED].update_value(true)) { + channel_property_updates.push_back(property::CHANNEL_FLAG_MAXFAMILYCLIENTS_UNLIMITED); + } + } children_left.push_back(child); - child_channel_type_updates.push_back(child); + child_channel_type_updates.push_back(std::make_tuple(child, channel_property_updates)); } } } @@ -1524,10 +1548,6 @@ ts::command_result ConnectedClient::execute_channel_edit(ChannelId& channel_id, assert(linked_previous_channel || channel->previousChannelId() == 0); } - std::vector child_channel_type_property_updates{ - property::CHANNEL_FLAG_PERMANENT, - property::CHANNEL_FLAG_SEMI_PERMANENT - }; std::vector default_channel_property_updates{ property::CHANNEL_FLAG_DEFAULT, }; @@ -1551,8 +1571,8 @@ ts::command_result ConnectedClient::execute_channel_edit(ChannelId& channel_id, } std::unique_lock client_tree_lock{client->channel_tree_mutex}; - for(const auto& child_channel : child_channel_type_updates) { - client->notifyChannelEdited(child_channel, child_channel_type_property_updates, self_ref, false); + for(const auto& [ child_channel, updates ] : child_channel_type_updates) { + client->notifyChannelEdited(child_channel, updates, self_ref, false); } if(is_channel_create) { diff --git a/shared b/shared index 616149d..b155bf8 160000 --- a/shared +++ b/shared @@ -1 +1 @@ -Subproject commit 616149d5dddf1fa2545922a1d97c438a9e51da3d +Subproject commit b155bf8d5f587b3b8970ef8ff81e0deb3b5bdf10