Просмотр исходного кода

* Fixed bug where hub linking with higher level hub would keep old channels
* Removed many lingering hacks to get eggdrop1.6.12 working months ago...
-Static channels support, etc..


svn: 163

Bryan Drewery 22 лет назад
Родитель
Сommit
f6b5cd4c65

+ 1 - 3
src/chan.h

@@ -245,7 +245,7 @@ struct chanset_t {
 #define CHAN_PEND           0x2000000  /* just joined; waiting for end of
                                           WHO list                           */
 #define CHAN_FLAGGED        0x4000000  /* flagged during rehash for delete   */
-#define CHAN_STATIC         0x8000000  /* channels that are NOT dynamic      */
+#define CHAN_ 		    0x8000000  /* unused      */
 #define CHAN_ASKEDBANS      0x10000000
 #define CHAN_ASKEDMODES     0x20000000 /* find out key-info on IRCu          */
 #define CHAN_JUPED          0x40000000 /* Is channel juped                   */
@@ -283,8 +283,6 @@ struct chanset_t *findchan_by_dname(const char *name);
 #define channel_dontkickops(chan) (chan->status & CHAN_DONTKICKOPS)
 #define channel_secret(chan) (chan->status & CHAN_SECRET)
 #define channel_shared(chan) (1)
-//#define channel_static(chan) (chan->status & CHAN_STATIC)
-#define channel_static(chan) (0)
 #define channel_cycle(chan) (chan->status & CHAN_CYCLE)
 #define channel_seen(chan) (1)
 #define channel_inactive(chan) (chan->status & CHAN_INACTIVE)

+ 39 - 0
src/chanprog.c

@@ -208,6 +208,41 @@ int expmem_chanprog()
   return tot;
 }
 
+/* 0 marks all channels
+ * 1 removes marked channels
+ * 2 unmarks all channels
+ */
+
+void checkchans(int which)
+{
+  struct chanset_t *chan, *chan_next;
+
+  if (which == 0 || which == 2) {
+    for (chan = chanset; chan; chan = chan->next)
+      if (which == 0)
+        chan->status |= CHAN_FLAGGED;
+      else
+        chan->statuc &= ~CHAN_FLAGGED;
+  } else if (which == 1) {
+#ifdef LEAF
+    module_entry *me;
+#endif /* LEAF */
+    for (chan = chanset; chan; chan = chan_next) {
+      chan_next = chan->next;
+      if (chan->status & CHAN_FLAGGED) {
+        putlog(LOG_MISC, "*", "No longer supporting channel %s", chan->dname);
+#ifdef LEAF
+        /* remove_channel(chan); */
+        if ((me = module_find("console", 0, 0))) {
+          Function *func = me->funcs;
+          (func[CHANNEL_REMOVE]) (chan);
+        }
+#endif /* LEAF */
+      }
+    }
+  }
+}
+
 /* Dump uptime info out to dcc (guppy 9Jan99)
  */
 void tell_verbose_uptime(int idx)
@@ -570,7 +605,9 @@ void chanprog()
   if (!userfile[0])
     fatal(MISC_NOUSERFILE2, 0);
   loading = 1;
+  checkchans(0);
   readuserfile(userfile, &userlist);
+  checkchans(1);
   loading = 0;
 #endif /* HUB */
 
@@ -657,8 +694,10 @@ void reload()
   noshare = 0;
   userlist = NULL;
   loading = 1;
+  checkchans(0);
   if (!readuserfile(userfile, &userlist))
     fatal(MISC_MISSINGUSERF, 0);
+  checkchans(1);
   loading = 0;
   reaffirm_owners();
   call_hook(HOOK_READ_USERFILE);

+ 1 - 12
src/mod/channels.mod/channels.c

@@ -11,10 +11,7 @@
 
 static Function *global		= NULL;
 
-static int  setstatic;
 static int  use_info;
-static char chanfile[121];
-static int  chan_hack;
 static int  quiet_save;
 static char glob_chanmode[64];		/* Default chanmode (drummer,990731) */
 static char *lastdeletedmask;
@@ -653,6 +650,7 @@ static void channels_report(int idx, int details)
       if (details) {
 	s[0] = 0;
 	i = 0;
+	i += my_strcpy(s + i, "dynamic ");
 	if (channel_enforcebans(chan))
 	  i += my_strcpy(s + i, "enforcebans ");
 	if (channel_dynamicbans(chan))
@@ -671,8 +669,6 @@ static void channels_report(int idx, int details)
 	  i += my_strcpy(s + i, "revengebot ");
 	if (channel_secret(chan))
 	  i += my_strcpy(s + i, "secret ");
-	if (!channel_static(chan))
-	  i += my_strcpy(s + i, "dynamic ");
 	if (channel_cycle(chan))
 	  i += my_strcpy(s + i, "cycle ");
 #ifdef S_IRCNET
@@ -873,7 +869,6 @@ static tcl_coups mychan_tcl_coups[] =
 
 static tcl_strings my_tcl_strings[] =
 {
-  {"chanfile",		chanfile,	120,	STR_PROTECT},
   {"global-chanmode",	glob_chanmode,	64,	0},
   {NULL,		NULL,		0,	0}
 };
@@ -890,7 +885,6 @@ static char *channels_close()
   rem_tcl_strings(my_tcl_strings);
   rem_tcl_ints(my_tcl_ints);
   rem_tcl_coups(mychan_tcl_coups);
-  del_hook(HOOK_SWITCH_STATIC, (Function) switch_static);
   del_hook(HOOK_USERFILE, (Function) channels_writeuserfile);
   del_hook(HOOK_MINUTELY, (Function) check_expired_bans);
 #ifdef S_IRCNET
@@ -1010,11 +1004,8 @@ char *channels_start(Function * global_funcs)
   gfld_ctcp_thr = 0;
   gfld_ctcp_time = 0;
   global_idle_kick = 0;
-  setstatic = 0;
   lastdeletedmask = 0;
   use_info = 1;
-  strcpy(chanfile, "chanfile");
-  chan_hack = 0;
   quiet_save = 0;
   strcpy(glob_chanmode, "nt");
   udef = NULL;
@@ -1048,7 +1039,6 @@ char *channels_start(Function * global_funcs)
          "-private "
 	 "-fastop ");
   module_register(MODULE_NAME, channels_table, 1, 0);
-  add_hook(HOOK_SWITCH_STATIC, (Function) switch_static);
 #ifdef LEAF
   add_hook(HOOK_MINUTELY, (Function) check_limitraise);
 #endif
@@ -1073,6 +1063,5 @@ char *channels_start(Function * global_funcs)
   my_tcl_ints[0].val = &share_greet;
   add_tcl_ints(my_tcl_ints);
   add_tcl_coups(mychan_tcl_coups);
-  setstatic = 1;
   return NULL;
 }

+ 0 - 1
src/mod/channels.mod/channels.h

@@ -70,7 +70,6 @@ static void tell_bans(int idx, int show_inact, char *match);
 static int write_bans(FILE * f, int idx);
 static int write_config (FILE * f, int idx);
 static void check_expired_bans(void);
-static void switch_static(void);
 #ifdef S_IRCNET
 static void tell_exempts (int idx, int show_inact, char * match);
 static int write_exempts (FILE * f, int idx);

+ 1 - 2
src/mod/channels.mod/cmdschan.c

@@ -1439,8 +1439,7 @@ static void cmd_chaninfo(struct userrec *u, int idx, char *par)
   if (!(chan = findchan_by_dname(chname)))
     dprintf(idx, "No such channel defined.\n");
   else {
-    dprintf(idx, "Settings for %s channel %s:\n",
-	    channel_static(chan) ? "static" : "dynamic", chan->dname);
+    dprintf(idx, "Settings for dynamic channel %s:\n", chan->dname);
     get_mode_protect(chan, work);
     dprintf(idx, "Protect modes (chanmode): %s\n", work[0] ? work : "None");
 /* Chanchar template

+ 8 - 11
src/mod/channels.mod/tclchan.c

@@ -1004,7 +1004,7 @@ static int tcl_channel STDVAR
     BADARGS(3, 999, " set channel-name ?options?");
     chan = findchan_by_dname(argv[2]);
     if (chan == NULL) {
-      if (chan_hack == 1)
+      if (loading == 1)
 	return TCL_OK;		/* Ignore channel settings for a static
 				 * channel which has been removed from
 				 * the config */
@@ -1423,14 +1423,14 @@ static int tcl_channel_modify(Tcl_Interp * irp, struct chanset_t *chan,
       }
     }
   }
-  /* If protect_readonly == 0 and chan_hack == 0 then
+  /* If protect_readonly == 0 and loading == 0 then
    * bot is now processing the configfile, so dont do anything,
    * we've to wait the channelfile that maybe override these settings
    * (note: it may cause problems if there is no chanfile!)
    * <drummer/1999/10/21>
    */
 #ifdef LEAF
-  if (protect_readonly || chan_hack) {
+  if (protect_readonly || loading) {
     if (((old_status ^ chan->status) & CHAN_INACTIVE) &&
 	module_find("irc", 0, 0)) {
       if (channel_inactive(chan) &&
@@ -1565,11 +1565,10 @@ static int tcl_isdynamic STDVAR
 
   BADARGS(2, 2, " channel");
   chan = findchan_by_dname(argv[1]);
-  if (chan != NULL)
-    if (!channel_static(chan)) {
+  if (chan != NULL) {
       Tcl_AppendResult(irp, "1", NULL);
       return TCL_OK;
-    }
+  }
   Tcl_AppendResult(irp, "0", NULL);
   return TCL_OK;
 }
@@ -1852,17 +1851,15 @@ static int tcl_channel_add(Tcl_Interp *irp, char *newname, char *options)
     /* Channel name is stored in xtra field for sharebot stuff */
     join = 1;
   }
-  if (setstatic)
-    chan->status |= CHAN_STATIC;
-  /* If chan_hack is set, we're loading the userfile. Ignore errors while
+  /* If loading is set, we're loading the userfile. Ignore errors while
    * reading userfile and just return TCL_OK. This is for compatability
    * if a user goes back to an eggdrop that no-longer supports certain
    * (channel) options.
    */
 #if (((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)) || (TCL_MAJOR_VERSION > 8))
-  if ((tcl_channel_modify(irp, chan, items, (char **)item) != TCL_OK) && !chan_hack) {
+  if ((tcl_channel_modify(irp, chan, items, (char **)item) != TCL_OK) && !loading) {
 #else
-  if ((tcl_channel_modify(irp, chan, items, item) != TCL_OK) && !chan_hack) {
+  if ((tcl_channel_modify(irp, chan, items, item) != TCL_OK) && !loading) {
 #endif
     ret = TCL_ERROR;
   }

+ 4 - 11
src/mod/channels.mod/userchan.c

@@ -1304,7 +1304,7 @@ static int write_chans(FILE *f, int idx)
        }
      }
    //insert the ending character into a string
-     sprintf(sadd, "%s\n", channel_static(chan) ? "" : "}");
+     sprintf(sadd, "}\n");
 
      if (lfprintf(f, "+ channel %s %s%schanmode %s idle-kick %d limit %d stopnethack-mode %d \
 revenge-mode %d \
@@ -1319,9 +1319,9 @@ exempt-time %d invite-time %d \
 %cdynamicexempts %cuserexempts %cdynamicinvites %cuserinvites \
 %cnodesynch \
 %cclosed %ctake %cmanop %cvoice %cfastop %s %s",
-	channel_static(chan) ? "set" : "add",
+	"add",
 	name,
-	channel_static(chan) ? " " : " { ",
+	" { ",
 	w2,
 /* Chanchar template
  *      temp,
@@ -1469,14 +1469,7 @@ static int expired_mask(struct chanset_t *chan, char *who)
   else
     return 1;
 }
-// cheap hack.
-static void switch_static(void)
-{
- if (setstatic)
-  setstatic = 0;
- else
-  setstatic = 1;
-}
+
 #ifdef LEAF
 int checklimit = 1;
 void check_limitraise() {

+ 3 - 1
src/mod/module.h

@@ -537,11 +537,13 @@
 #define hostprotocol ((int (*) (char *))global[330])
 #define sdprintf (global[331])
 #define putbot ((void (*)(char *, char *))global[332])
-/* 333 - 335 */
+/* 333 - 336 */
 #define putallbots ((void (*)(char *))global[333])
 #define ssl_link ((int (*) (int, int))global[334])
 #define dropssl ((void (*) (int))global[335])
 #define myipstr ((char*(*)(int))global[336])
+/* 337 - 340 */
+#define checkchans ((void (*) (int))global[340])
 
 /* This is for blowfish module, couldnt be bothered making a whole new .h
  * file for it ;)

+ 1 - 1
src/mod/modvals.h

@@ -56,7 +56,6 @@
 #define HOOK_DNS_IPBYHOST	113
 #define HOOK_ENCRYPT_STRING     114
 #define HOOK_DECRYPT_STRING     115
-#define HOOK_SWITCH_STATIC      116
 #define HOOK_SHAREUPDATEIN	117
 
 /* These are FIXED once they are in a release they STAY
@@ -76,6 +75,7 @@
 #define SHARE_DUMP_RESYNC	  5
 /* Channels */
 #define CHANNEL_CLEAR		 15
+#define CHANNEL_REMOVE		 45
 /* Server */
 #define SERVER_BOTNAME		  4
 #define SERVER_BOTUSERHOST	  5

+ 3 - 3
src/mod/share.mod/share.c

@@ -1807,13 +1807,14 @@ static void finish_share(int idx)
 	while (chan->exempts)
 	  u_delexempt(chan, chan->exempts->mask, 1);
 	while (chan->invites)
-  //setstatic = 0;
 	  u_delinvite(chan, chan->invites->mask, 1);
+  checkchans(0);
     }
   noshare = 0;
   ou = userlist;		/* Save old user list			*/
   userlist = (void *) -1;	/* Do this to prevent .user messups	*/
 
+    checkchans(2);
   /* Bot user pointers are updated to point to the new list, all others
    * are set to NULL. If our userfile will be overriden, just set _all_
    * to NULL directly.
@@ -1824,11 +1825,10 @@ static void finish_share(int idx)
   else
       dcc[i].user = get_user_by_handle(u, dcc[i].nick);
 
-
+  checkchans(1);
   /* Read the transferred userfile. Add entries to u, which already holds
    * the bot entries in non-override mode.
    */
-  //setstatic = 1;
   loading = 1;
   checkchans(0); /* flag all the channels.. */
 Context;

+ 2 - 1
src/modules.c

@@ -583,7 +583,8 @@ Function global_table[] =
   (Function) putallbots,
   (Function) ssl_link,
   (Function) dropssl,
-  (Function) myipstr
+  (Function) myipstr,
+  (Function) checkchans
 
 
 };

+ 1 - 0
src/proto.h

@@ -108,6 +108,7 @@ void botnet_send_cmdpass(int, char *, char *);
 #endif
 
 /* chanprog.c */
+void checkchans(int);
 void tell_verbose_uptime(int);
 void tell_verbose_status(int);
 void tell_settings(int);

+ 0 - 2
src/users.c

@@ -810,7 +810,6 @@ Context;
             Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY));
            return 0;
           }
-	 call_hook(HOOK_SWITCH_STATIC);
          }
 	} else if (!strncmp(code, "::", 2)) {
 	  /* channel-specific bans */
@@ -936,7 +935,6 @@ Context;
 	  strcpy(lasthand, code);
 	  u = NULL;
         } else if (!rfc_casecmp(code, CHANS_NAME)) {
-          call_hook(HOOK_SWITCH_STATIC);
           strcpy(lasthand, code);
           u = NULL;
         } else if (!rfc_casecmp(code, CONFIG_NAME)) {