License update
[srvx.git] / src / hash.c
index 8952ac0595d368ebeeca96ae388c29abd1033d6e..f5a21cddb661ef16a982bf0fe4e2c955432bd28e 100644 (file)
@@ -1,11 +1,12 @@
 /* hash.c - IRC network state database
  * Copyright 2000-2004 srvx Development Team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This file is part of srvx.
+ *
+ * srvx is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.  Important limitations are
- * listed in the COPYING file that accompanies this software.
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,7 +14,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, email srvx-maintainers@srvx.net.
+ * along with srvx; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
 #include "conf.h"
@@ -139,7 +141,7 @@ ReintroduceUser(struct userNode *user)
     unsigned int n;
        
     irc_user(user);
-    change.modes_set = change.modes_clear = 0;
+    mod_chanmode_init(&change);
     change.argc = 1;
     for (n = 0; n < user->channels.used; n++) {
         struct modeNode *mn = user->channels.list[n];
@@ -281,6 +283,11 @@ wipeout_channel(struct chanNode *cNode, time_t new_time, char **modes, unsigned
     char orig_key[KEYLEN+1];
     unsigned int nn, argc;
 
+    /* nuke old topic */
+    cNode->topic[0] = '\0';
+    cNode->topic_nick[0] = '\0';
+    cNode->topic_time = 0;
+
     /* remember the old modes, and update them with the new */
     orig_modes = cNode->modes;
     orig_limit = cNode->limit;
@@ -297,14 +304,14 @@ wipeout_channel(struct chanNode *cNode, time_t new_time, char **modes, unsigned
     /* deop anybody in the channel now, but count services to reop */
     for (nn=argc=0; nn<cNode->members.used; nn++) {
         struct modeNode *mn = cNode->members.list[nn];
-        if (mn->modes & MODE_CHANOP && IsService(mn->user) && IsLocal(mn->user))
+        if ((mn->modes & MODE_CHANOP) && IsService(mn->user) && IsLocal(mn->user))
             argc++;
     }
     if (argc) {
         extern struct userNode *opserv;
         struct mod_chanmode *change;
 
-        change = mod_chanmode_alloc(nn);
+        change = mod_chanmode_alloc(argc);
         change->modes_clear = 0;
         change->modes_set = orig_modes;
         change->new_limit = orig_limit;
@@ -317,6 +324,7 @@ wipeout_channel(struct chanNode *cNode, time_t new_time, char **modes, unsigned
                 argc++;
             }
         }
+        assert(argc == change->argc);
         if (change->argc > 0)
             mod_chanmode_announce(change->args[0].member->user, cNode, change);
         else
@@ -460,6 +468,9 @@ AddChannelUser(struct userNode *user, struct chanNode* channel)
        modeList_append(&channel->members, mNode);
        modeList_append(&user->channels, mNode);
 
+        if (channel->members.used == 1)
+            mNode->modes |= MODE_CHANOP;
+
         for (n=0; n<jf_used; n++) {
             /* Callbacks return true if they kick or kill the user,
              * and we can continue without removing mNode. */
@@ -513,8 +524,7 @@ LockChannel(struct chanNode* channel)
 void
 UnlockChannel(struct chanNode *channel)
 {
-    if (!channel->locks)
-        return;
+    assert(channel->locks > 0);
     if (!--channel->locks && !channel->members.used)
         DelChannel(channel);
 }