Fix Bahamut assertion failure; move BURST to more "natural" place
[srvx.git] / src / proto-bahamut.c
index 4b82d7fccd35a487dea84cc2cc493b920a71f9a1..d79f247e4f0917830eae7c08512fa63db8480544 100644 (file)
@@ -1,11 +1,12 @@
 /* proto-bahamut.c - IRC protocol output
  * 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 "proto-common.c"
@@ -169,7 +171,7 @@ AddUser(struct server* uplink, const char *nick, const char *ident, const char *
 }
 
 struct userNode *
-AddService(const char *nick, const char *desc) {
+AddService(const char *nick, const char *desc, const char *hostname) {
     time_t timestamp = now;
     struct userNode *old_user = GetUserH(nick);
     struct in_addr ipaddr = { INADDR_LOOPBACK };
@@ -178,7 +180,9 @@ AddService(const char *nick, const char *desc) {
             return old_user;
         timestamp = old_user->timestamp - 1;
     }
-    return AddUser(self, nick, nick, self->name, "+oikr", desc, timestamp, ipaddr, 0);
+    if (!hostname)
+        hostname = self->name;
+    return AddUser(self, nick, nick, hostname, "+oikr", desc, timestamp, ipaddr, 0);
 }
 
 struct userNode *
@@ -305,11 +309,6 @@ irc_svinfo() {
     putsock("SVINFO 3 3 0 :"FMT_TIME_T, now);
 }
 
-void
-irc_burst() {
-    putsock("BURST");
-}
-
 void
 irc_introduce(const char *passwd) {
     extern time_t burst_begin;
@@ -367,6 +366,11 @@ irc_notice(struct userNode *from, const char *to, const char *message) {
     putsock(":%s NOTICE %s :%s", from->nick, to, message);
 }
 
+void
+irc_notice_user(struct userNode *from, struct userNode *to, const char *message) {
+    putsock(":%s NOTICE %s :%s", from->nick, to->nick, message);
+}
+
 void
 irc_wallchops(UNUSED_ARG(struct userNode *from), UNUSED_ARG(const char *to), UNUSED_ARG(const char *message)) {
 }
@@ -693,7 +697,6 @@ static CMD_FUNC(cmd_server) {
         AddServer(GetServerH(origin), argv[1], atoi(argv[2]), 0, now, 0, argv[3]);
     } else {
         self->uplink = AddServer(self, argv[1], atoi(argv[2]), 0, now, 0, argv[3]);
-        send_burst();
     }
     return 1;
 }
@@ -702,6 +705,7 @@ static CMD_FUNC(cmd_svinfo) {
     if (argc < 5) return 0;
     if ((atoi(argv[1]) < 3) || (atoi(argv[2]) > 3)) return 0;
     /* TODO: something with the timestamp we get from the other guy */
+    send_burst();
     return 1;
 }
 
@@ -1264,9 +1268,13 @@ mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, un
                 ch_arg++;
             break;
         }
+        default:
+            if (!(flags & MCP_FROM_SERVER))
+                goto error;
+            break;
         }
     }
-    change->argc = argc; /* in case any turned out to be ignored */
+    change->argc = ch_arg; /* in case any turned out to be ignored */
     if (change->modes_set & MODE_SECRET) {
         change->modes_set &= ~(MODE_PRIVATE);
         change->modes_clear |= MODE_PRIVATE;