ソースを参照

* Fixed many color system bugs

svn: 1043
Bryan Drewery 22 年 前
コミット
99d73d0d63
9 ファイル変更51 行追加32 行削除
  1. 1 0
      doc/UPDATES
  2. 1 8
      src/botnet.c
  3. 4 4
      src/chanprog.c
  4. 3 4
      src/cmds.c
  5. 3 1
      src/dcc.c
  6. 4 3
      src/dccutil.c
  7. 30 12
      src/misc.c
  8. 1 0
      src/misc.h
  9. 4 0
      src/mod/share.mod/share.c

+ 1 - 0
doc/UPDATES

@@ -24,6 +24,7 @@ This is a summary of ChangeLog basically.
 20.Removed cmd_botinfo.
 20.Removed cmd_botinfo.
 21.Unrolled some loops in the botlink encrypt.
 21.Unrolled some loops in the botlink encrypt.
 22.Added server 005 support, fixes many potential bugs.
 22.Added server 005 support, fixes many potential bugs.
+23.Fixed many bugs with color system, including color over relay/botcmd.
 
 
 1.1.7
 1.1.7
 
 

+ 1 - 8
src/botnet.c

@@ -1415,7 +1415,7 @@ static void dcc_relay(int idx, char *buf, int j)
      escape sequences. */
      escape sequences. */
   if (!(dcc[j].status & STAT_TELNET)) {
   if (!(dcc[j].status & STAT_TELNET)) {
     while (*p != 0) {
     while (*p != 0) {
-      while (*p != 255 && (*p != '\033' || *(p + 1) != '[') && *p != '\r' && *p)
+      while (*p && *p != 255 && *p != '\r')
 	p++;			/* Search for IAC, escape sequences and CR. */
 	p++;			/* Search for IAC, escape sequences and CR. */
       if (*p == 255) {
       if (*p == 255) {
 	mark = 2;
 	mark = 2;
@@ -1427,13 +1427,6 @@ static void dcc_relay(int idx, char *buf, int j)
 	    mark = 2;		/* Bogus */
 	    mark = 2;		/* Bogus */
 	}
 	}
 	strcpy((char *) p, (char *) (p + mark));
 	strcpy((char *) p, (char *) (p + mark));
-      } else if (*p == '\033') {
-	unsigned char	*e;
-
-	/* Search for the end of the escape sequence. */
-	for (e = p + 2; *e != 'm' && *e; e++)
-	  ;
-	strcpy((char *) p, (char *) (e + 1));
       } else if (*p == '\r')
       } else if (*p == '\r')
 	strcpy((char *) p, (char *) (p + 1));
 	strcpy((char *) p, (char *) (p + 1));
     }
     }

+ 4 - 4
src/chanprog.c

@@ -707,10 +707,10 @@ chans_delbot(const char *bot, struct chanset_t *chan)
 
 
 int shouldjoin(struct chanset_t *chan)
 int shouldjoin(struct chanset_t *chan)
 {
 {
-//  if (!strncmp(conf.bot->nick, "wtest", 5) && !strcmp(chan->dname, "#wraith"))
-//    return 1;
-//  else if (!strncmp(conf.bot->nick, "wtest", 4)) /* use 5 for all */
-//    return 0; 
+  if (!strncmp(conf.bot->nick, "wtest", 5) && !strcmp(chan->dname, "#wraith"))
+    return 1;
+  else if (!strncmp(conf.bot->nick, "wtest", 4)) /* use 5 for all */
+    return 0; 
 #ifdef G_BACKUP
 #ifdef G_BACKUP
   struct flag_record fr = { FR_CHAN | FR_GLOBAL, 0, 0};
   struct flag_record fr = { FR_CHAN | FR_GLOBAL, 0, 0};
   struct userrec *u = NULL;
   struct userrec *u = NULL;

+ 3 - 4
src/cmds.c

@@ -2855,12 +2855,11 @@ static void cmd_color(struct userrec *u, int idx, char *par)
 
 
   putlog(LOG_CMDS, "*", "#%s# color %s", dcc[idx].nick, par);
   putlog(LOG_CMDS, "*", "#%s# color %s", dcc[idx].nick, par);
 
 
-  if ((idx && ((dcc[idx].type != &DCC_RELAYING) && (dcc[idx].status & STAT_TELNET))) || !backgrd)
-    ansi++;
+  ansi = coloridx(idx);
   if (!par[0]) {
   if (!par[0]) {
     dprintf(idx, "Usage: color <on/off>\n");
     dprintf(idx, "Usage: color <on/off>\n");
-    if (dcc[idx].status & STAT_COLOR) 
-      dprintf(idx, "Color is currently on. (%s)\n", ansi ? "ANSI" : "mIRC");
+    if (ansi)
+      dprintf(idx, "Color is currently on. (%s)\n", ansi == 1 ? "ANSI" : "mIRC");
     else
     else
       dprintf(idx, "Color is currently off.\n");
       dprintf(idx, "Color is currently off.\n");
     return;
     return;

+ 3 - 1
src/dcc.c

@@ -1170,6 +1170,7 @@ static void dcc_chat(int idx, char *buf, int i)
 static void display_dcc_chat(int idx, char *buf)
 static void display_dcc_chat(int idx, char *buf)
 {
 {
   size_t i;
   size_t i;
+  int colori = 0;
 
 
   i = simple_sprintf(buf, "chat  flags: ");
   i = simple_sprintf(buf, "chat  flags: ");
   buf[i++] = dcc[idx].status & STAT_CHAT ? 'C' : 'c';
   buf[i++] = dcc[idx].status & STAT_CHAT ? 'C' : 'c';
@@ -1177,7 +1178,8 @@ static void display_dcc_chat(int idx, char *buf)
   buf[i++] = dcc[idx].status & STAT_TELNET ? 'T' : 't';
   buf[i++] = dcc[idx].status & STAT_TELNET ? 'T' : 't';
   buf[i++] = dcc[idx].status & STAT_ECHO ? 'E' : 'e';
   buf[i++] = dcc[idx].status & STAT_ECHO ? 'E' : 'e';
   buf[i++] = dcc[idx].status & STAT_PAGE ? 'P' : 'p';
   buf[i++] = dcc[idx].status & STAT_PAGE ? 'P' : 'p';
-  buf[i++] = dcc[idx].status & STAT_COLOR ? 'K' : 'k';
+  if ((colori = coloridx(idx)))
+    buf[i++] = colori == 1 ? 'A' : 'M';
 #ifdef USE_IPV6
 #ifdef USE_IPV6
   if (sockprotocol(dcc[idx].sock) == AF_INET6 && dcc[idx].addr6[0])
   if (sockprotocol(dcc[idx].sock) == AF_INET6 && dcc[idx].addr6[0])
     buf[i++] = '6';
     buf[i++] = '6';

+ 4 - 3
src/dccutil.c

@@ -119,7 +119,7 @@ void dprintf(int idx, const char *format, ...)
     }
     }
     return;
     return;
   } else { /* normal chat text */
   } else { /* normal chat text */
-    if ((dcc[idx].status & STAT_COLOR) && (dcc[idx].type == &DCC_CHAT)) {
+    if (!dcc[idx].simul && coloridx(idx)) {
       int i;
       int i;
       char buf3[1024] = "", buf2[1024] = "", c = 0;
       char buf3[1024] = "", buf2[1024] = "", c = 0;
 
 
@@ -234,6 +234,9 @@ void dcc_chatter(int idx)
   int i, j;
   int i, j;
   struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0};
   struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0};
 
 
+  strcpy(dcc[idx].u.chat->con_chan, "***");
+  check_bind_chon(dcc[idx].nick, idx);
+
   get_user_flagrec(dcc[idx].user, &fr, NULL);
   get_user_flagrec(dcc[idx].user, &fr, NULL);
   dprintf(idx, "Connected to %s, running %s\n", conf.bot->nick, version);
   dprintf(idx, "Connected to %s, running %s\n", conf.bot->nick, version);
   show_banner(idx);
   show_banner(idx);
@@ -254,8 +257,6 @@ void dcc_chatter(int idx)
   }
   }
 
 
   j = dcc[idx].sock;
   j = dcc[idx].sock;
-  strcpy(dcc[idx].u.chat->con_chan, "***");
-  check_bind_chon(dcc[idx].nick, idx);
   dcc[idx].u.chat->channel = 234567;
   dcc[idx].u.chat->channel = 234567;
   /* Still there? */
   /* Still there? */
 
 

+ 30 - 12
src/misc.c

@@ -458,7 +458,7 @@ void show_motd(int idx)
 #else /* !S_UTCTIME */
 #else /* !S_UTCTIME */
     egg_strftime(date, sizeof date, "%c %Z", localtime(&when));
     egg_strftime(date, sizeof date, "%c %Z", localtime(&when));
 #endif /* S_UTCTIME */
 #endif /* S_UTCTIME */
-    dprintf(idx, "Motd set by \002%s\002 (%s)\n", who, date);
+    dprintf(idx, "Motd set by %s%s%s (%s)\n", BOLD(idx), who, BOLD_END(idx), date);
     dumplots(idx, "* ", replace(buf, "\\n", "\n"));
     dumplots(idx, "* ", replace(buf, "\\n", "\n"));
     dprintf(idx, " \n");
     dprintf(idx, " \n");
     free(buf_ptr);
     free(buf_ptr);
@@ -1209,6 +1209,31 @@ void shuffle(char *string, char *delim)
   string[strlen(string)] = 0;
   string[strlen(string)] = 0;
 }
 }
 
 
+/* returns
+   1: use ANSI
+   2: use mIRC
+   0: neither
+ */
+
+int
+coloridx(int idx)
+{
+  if (idx == -1) {		/* who cares, just show color! */
+    return 1;	/* ANSI */
+  } else if (idx == -2) {
+    return 2;	/* mIRC */
+  /* valid idx and NOT relaying */
+  } else if (idx >= 0 && (dcc[idx].status & STAT_COLOR) && (dcc[idx].type && dcc[idx].type != &DCC_RELAYING)) {
+    /* telnet probably wants ANSI, even though it might be a relay from an mIRC client; fuck`em */
+    if (dcc[idx].status & STAT_TELNET)
+      return 1;
+    /* non-telnet is probably a /dcc-chat, most irc clients support mIRC codes... */
+    else
+      return 2;
+  } 
+  return 0;
+}
+
 char *color(int idx, int type, int which)
 char *color(int idx, int type, int which)
 {
 {
   int ansi = 0;
   int ansi = 0;
@@ -1216,18 +1241,11 @@ char *color(int idx, int type, int which)
   /* if user is connected over TELNET or !backgrd, show ANSI
   /* if user is connected over TELNET or !backgrd, show ANSI
    * if they are relaying, they are most likely on an IRC client and should have mIRC codes
    * if they are relaying, they are most likely on an IRC client and should have mIRC codes
    */
    */
-
-  if (idx == -1) {		/* who cares, just show color! */
-    ansi++;
-  } else if (idx && dcc[idx].status & STAT_COLOR) {
-    /* over telnet but not relaying */
-    if (dcc[idx].type != &DCC_RELAYING && dcc[idx].status & STAT_TELNET)
-      ansi++;
-    /* else: use mIRC color codes. */
-  } else {
+ 
+  if ((ansi = coloridx(idx)) == 0)
     return "";
     return "";
-  }
-
+  if (ansi == 2)
+    ansi = 0;
   if (type == BOLD_OPEN) {
   if (type == BOLD_OPEN) {
     return ansi ? "\033[1m" : "\002";
     return ansi ? "\033[1m" : "\002";
   } else if (type == BOLD_CLOSE) {
   } else if (type == BOLD_CLOSE) {

+ 1 - 0
src/misc.h

@@ -29,6 +29,7 @@
 #define KICK_BOGUSKEY 		15
 #define KICK_BOGUSKEY 		15
 
 
 char *wbanner();
 char *wbanner();
+int coloridx(int);
 char *color(int, int, int);
 char *color(int, int, int);
 void shuffle(char *, char *);
 void shuffle(char *, char *);
 void showhelp(int, struct flag_record *, char *);
 void showhelp(int, struct flag_record *, char *);

+ 4 - 0
src/mod/share.mod/share.c

@@ -792,7 +792,9 @@ share_pls_exempt(int idx, char *par)
   int flags = 0;
   int flags = 0;
 
 
   if (dcc[idx].status & STAT_SHARE) {
   if (dcc[idx].status & STAT_SHARE) {
+#ifdef LEAF
     struct chanset_t *chan = NULL;
     struct chanset_t *chan = NULL;
+#endif /* LEAF */
     int stick = 0;
     int stick = 0;
 
 
     shareout_but(NULL, idx, "+e %s\n", par);
     shareout_but(NULL, idx, "+e %s\n", par);
@@ -871,7 +873,9 @@ share_pls_invite(int idx, char *par)
   int flags = 0;
   int flags = 0;
 
 
   if (dcc[idx].status & STAT_SHARE) {
   if (dcc[idx].status & STAT_SHARE) {
+#ifdef LEAF
     struct chanset_t *chan = NULL;
     struct chanset_t *chan = NULL;
+#endif /* LEAF */
     int stick = 0;
     int stick = 0;
 
 
     shareout_but(NULL, idx, "+inv %s\n", par);
     shareout_but(NULL, idx, "+inv %s\n", par);