]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/hash.c
Fixed header comments
[irc/evilnet/x3.git] / src / hash.c
index 6e1005ff150f80b1851e0c88ffd3d7e98571ce9e..31730f14e02183dc3ac290cb2656588cc348ad99 100644 (file)
@@ -3,7 +3,7 @@
  *
  * This file is part of x3.
  *
- * srvx is free software; you can redistribute it and/or modify
+ * x3 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.
@@ -289,6 +289,8 @@ wipeout_channel(struct chanNode *cNode, time_t new_time, char **modes, unsigned
     unsigned int orig_limit;
     chan_mode_t orig_modes;
     char orig_key[KEYLEN+1];
+    char orig_apass[KEYLEN+1];
+    char orig_upass[KEYLEN+1];
     unsigned int nn, argc;
 
     /* nuke old topic */
@@ -300,6 +302,8 @@ wipeout_channel(struct chanNode *cNode, time_t new_time, char **modes, unsigned
     orig_modes = cNode->modes;
     orig_limit = cNode->limit;
     strcpy(orig_key, cNode->key);
+    strcpy(orig_upass, cNode->upass);
+    strcpy(orig_apass, cNode->apass);
     cNode->modes = 0;
     mod_chanmode(NULL, cNode, modes, modec, 0);
     cNode->timestamp = new_time;
@@ -329,6 +333,8 @@ wipeout_channel(struct chanNode *cNode, time_t new_time, char **modes, unsigned
         change->modes_set = orig_modes;
         change->new_limit = orig_limit;
         strcpy(change->new_key, orig_key);
+        strcpy(change->new_upass, orig_upass);
+        strcpy(change->new_apass, orig_apass);
         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)) {
@@ -366,7 +372,7 @@ AddChannel(const char *name, time_t time_, const char *modes, char *banlist, cha
         banList_init(&cNode->banlist);
         exemptList_init(&cNode->exemptlist);
         modeList_init(&cNode->members);
-        mod_chanmode(NULL, cNode, argv, nn, 0);
+        mod_chanmode(NULL, cNode, argv, nn, MCP_FROM_SERVER);
         dict_insert(channels, cNode->name, cNode);
         cNode->timestamp = time_;
         rel_age = 1;
@@ -374,7 +380,7 @@ AddChannel(const char *name, time_t time_, const char *modes, char *banlist, cha
         wipeout_channel(cNode, time_, argv, nn);
         rel_age = 1;
     } else if (cNode->timestamp == time_) {
-        mod_chanmode(NULL, cNode, argv, nn, 0);
+        mod_chanmode(NULL, cNode, argv, nn, MCP_FROM_SERVER);
         rel_age = 0;
     } else {
         rel_age = -1;
@@ -494,6 +500,7 @@ AddChannelUser(struct userNode *user, struct chanNode* channel)
        mNode->channel = channel;
        mNode->user = user;
        mNode->modes = 0;
+        mNode->oplevel = -1;
         mNode->idle_since = now;
 
        /* Add modeNode to channel and to user.
@@ -504,7 +511,8 @@ AddChannelUser(struct userNode *user, struct chanNode* channel)
        modeList_append(&user->channels, mNode);
 
         if (channel->members.used == 1
-            && !(channel->modes & MODE_REGISTERED))
+            && !(channel->modes & MODE_REGISTERED)
+            && !(channel->modes & MODE_APASS))
             mNode->modes |= MODE_CHANOP;
 
         for (n=0; n<jf_used; n++) {
@@ -593,7 +601,9 @@ DelChannelUser(struct userNode* user, struct chanNode* channel, const char *reas
     /* free memory */
     free(mNode);
 
-    if (!deleting && !channel->members.used && !channel->locks && !(channel->modes & MODE_REGISTERED))
+    /* A single check for APASS only should be enough here */
+    if (!deleting && !channel->members.used && !channel->locks
+        && !(channel->modes & MODE_REGISTERED) && !(channel->modes & MODE_APASS))
         DelChannel(channel);
 }