Channel move improvements

This commit is contained in:
WolverinDEV 2020-05-13 11:51:01 +02:00
parent 1a2dd4a008
commit e3bf46a89b
4 changed files with 13 additions and 6 deletions

@ -1 +1 @@
Subproject commit ee5090232867df795348b84f1c6d96561ea24d90
Subproject commit a8a0aabd7fca05b950de9f781a3cd6ba5b799f79

View File

@ -122,7 +122,6 @@ bool VirtualServer::initialize(bool test_properties) {
channelTree = new ServerChannelTree(self.lock(), this->sql);
channelTree->loadChannelsFromDatabase();
channelTree->deleteSemiPermanentChannels();
this->groups = new GroupManager(self.lock(), this->sql, serverInstance->getGroupManager());
if(!this->groups->loadGroupFormDatabase()){ //TODO exception etc
@ -130,6 +129,7 @@ bool VirtualServer::initialize(bool test_properties) {
return false;
}
channelTree->deleteSemiPermanentChannels();
if(channelTree->channel_count() == 0){
logMessage(this->serverId, "Creating new channel tree (Copy from server 0)");
LOG_SQL_CMD(sql::command(this->getSql(), "INSERT INTO `channels` (`serverId`, `channelId`, `type`, `parentId`) SELECT :serverId AS `serverId`, `channelId`, `type`, `parentId` FROM `channels` WHERE `serverId` = 0", variable{":serverId", this->serverId}).execute());

View File

@ -102,8 +102,6 @@ command_result ConnectedClient::handleCommandClientKick(Command &cmd) {
clients.emplace_back(std::move(client));
result.emplace_result(error::ok);
}
if (clients.empty())
return command_result{error::database_empty_result};
for(auto& client : clients) {
if (target_channel) {
@ -170,6 +168,7 @@ command_result ConnectedClient::handleCommandClientMove(Command &cmd) {
auto permission_cache = make_shared<CalculateCache>();
if(!cmd[0].has("cpw"))
cmd["cpw"] = "";
if (!channel->passwordMatch(cmd["cpw"], true))
if (!permission::v2::permission_granted(1, this->calculate_permission(permission::b_channel_join_ignore_password, channel->channelId())))
return command_result{error::channel_invalid_password};
@ -196,9 +195,17 @@ command_result ConnectedClient::handleCommandClientMove(Command &cmd) {
continue;
}
}
if(target_client->getChannel() == channel) {
result.emplace_result(error::ok);
continue;
}
if(target_client.client != this) {
if(!permission::v2::permission_granted(target_client->calculate_permission(permission::i_client_needed_move_power, 0), this->calculate_permission(permission::i_client_move_power, 0))) {
if(!permission::v2::permission_granted(target_client->calculate_permission(permission::i_client_needed_move_power, target_client->getChannelId()), this->calculate_permission(permission::i_client_move_power, target_client->getChannelId()))) {
result.emplace_result(permission::i_client_move_power);
continue;
}
if(!permission::v2::permission_granted(target_client->calculate_permission(permission::i_client_needed_move_power, channel->channelId()), this->calculate_permission(permission::i_client_move_power, channel->channelId()))) {
result.emplace_result(permission::i_client_move_power);
continue;
}

2
shared

@ -1 +1 @@
Subproject commit b60608ff94b06145bc808426392871ebd95fe9d3
Subproject commit a4febf7b5af191d41c566292958c55155128f16f