Mute/deaf fixes + simplify channel password logic.
authorMartin Johansson <martin@fatbob.nu>
Fri, 16 Mar 2012 19:44:17 +0000 (20:44 +0100)
committerMartin Johansson <martin@fatbob.nu>
Fri, 16 Mar 2012 19:44:17 +0000 (20:44 +0100)
src/client.c
src/messagehandler.c

index 30979e8a11b76aa69d7e8d9af3dd37a06cce5430..7322aee56ba26ff4bc3c95d81a076fedc8afeb44 100644 (file)
@@ -775,7 +775,7 @@ out:
 
 static inline void Client_send_voice(client_t *src, client_t *dst, uint8_t *data, int len, int poslen)
 {
-       if (IS_AUTH(dst) && dst != src && (!dst->deaf || !dst->self_deaf)) {
+       if (IS_AUTH(dst) && dst != src && !dst->deaf && !dst->self_deaf) {
                if (poslen > 0 && /* Has positional data */
                        src->context != NULL && dst->context != NULL && /* ...both source and destination has context */
                        strcmp(src->context, dst->context) == 0) /* ...and the contexts match */
@@ -800,7 +800,7 @@ int Client_voiceMsg(client_t *client, uint8_t *data, int len)
        channel_t *ch = (channel_t *)client->channel;
        struct dlist *itr;
        
-       if (!client->authenticated || client->mute)
+       if (!client->authenticated || client->mute || client->self_mute)
                goto out;
        
        packetsize = 20 + 8 + 4 + len;
index fc489fd392e7e1eba7fe4ef011327b2331f5d25c..2dea8588d6cca8defbf5d0c40e15eaaef0d5a7fc 100644 (file)
@@ -447,6 +447,10 @@ void Mh_handle_message(client_t *client, message_t *msg)
                }
                if (msg->payload.userState->has_self_deaf) {
                        client->self_deaf = msg->payload.userState->self_deaf;
+                       if (client->self_deaf) {
+                               msg->payload.userState->has_self_mute = true;
+                               msg->payload.userState->self_mute = true;
+                       }
                }
                if (msg->payload.userState->has_self_mute) {
                        client->self_mute = msg->payload.userState->self_mute;
@@ -485,16 +489,19 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        channelJoinResult_t chjoin_rc = Chan_userJoin_id_test(msg->payload.userState->channel_id, target);
                        
                        if (chjoin_rc != CHJOIN_OK) {
-                               if (chjoin_rc == CHJOIN_WRONGPW && target == client && !client->isAdmin) {
-                                       sendPermissionDenied(client, "Wrong channel password");
-                                       break;
+                               if (chjoin_rc == CHJOIN_WRONGPW) {
+                                       if (target == client && !client->isAdmin) {
+                                               sendPermissionDenied(client, "Wrong channel password");
+                                               break;
+                                       }
+                                       /* Tricky one: if user hasn't the password, but is moved to the channel by admin then let
+                                        * the user in. Also let admin user in regardless of channel password.
+                                        * Take no action on other errors.
+                                        */
+                                       else if (!client->isAdmin)
+                                               break;
                                }
-                               /* Tricky one: if user hasn't the password, but is moved to the channel by admin then let
-                                * the user in. Also let admin user in regardless of pchannel password.
-                                * Take no action on other errors.
-                                */
-                               else if (!(chjoin_rc == CHJOIN_WRONGPW && (target != client || client->isAdmin)))
-                                       break;
+                               else break;
                        }
                        
                        leave_id = Chan_userJoin_id(msg->payload.userState->channel_id, target);
@@ -550,7 +557,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                                        list_iterate(itr, &ch_itr->clients) {
                                                client_t *c;
                                                c = list_get_entry(itr, client_t, chan_node);
-                                               if (c != client && !c->deaf) {
+                                               if (c != client && !c->deaf && !c->self_deaf) {
                                                        Msg_inc_ref(msg);
                                                        Client_send_message(c, msg);
                                                        Log_debug("Text message to session ID %d", c->sessionId);
@@ -568,7 +575,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                                        if (!IS_AUTH(itr))
                                                continue;
                                        if (itr->sessionId == msg->payload.textMessage->session[i]) {
-                                               if (!itr->deaf) {
+                                               if (!itr->deaf && !itr->self_deaf) {
                                                        Msg_inc_ref(msg);
                                                        Client_send_message(itr, msg);
                                                        Log_debug("Text message to session ID %d", itr->sessionId);