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

* Removed an excess loop, moved enforce_closed(chan) check to channels_10secondly()

svn: 570
Bryan Drewery 22 лет назад
Родитель
Сommit
a31f88c12c
3 измененных файлов с 14 добавлено и 11 удалено
  1. 12 3
      src/mod/channels.mod/channels.c
  2. 1 8
      src/mod/irc.mod/irc.c
  3. 1 0
      src/mod/irc.mod/irc.h

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

@@ -8,8 +8,9 @@
 #define MAKING_CHANNELS
 #define MAKING_CHANNELS
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include "src/mod/module.h"
 #include "src/mod/module.h"
+#include "irc.mod/irc.h"
 
 
-static Function *global		= NULL;
+static Function *global = NULL, *irc_funcs = NULL;
 
 
 static int 			use_info;
 static int 			use_info;
 static int			quiet_save;
 static int			quiet_save;
@@ -301,7 +302,7 @@ void rebalance_roles()
 #endif /* HUB */
 #endif /* HUB */
 
 
 /* FIXME: needs more testing */
 /* FIXME: needs more testing */
-static void channels_checkslowjoin() {
+static void channels_10secondly() {
   struct chanset_t *chan;
   struct chanset_t *chan;
   for (chan = chanset; chan; chan = chan->next) {
   for (chan = chanset; chan; chan = chan->next) {
     /* slowpart */
     /* slowpart */
@@ -321,6 +322,8 @@ static void channels_checkslowjoin() {
       if (shouldjoin(chan) && !channel_active(chan))
       if (shouldjoin(chan) && !channel_active(chan))
         dprintf(DP_MODE, "JOIN %s %s\n", chan->name, chan->key_prot);
         dprintf(DP_MODE, "JOIN %s %s\n", chan->name, chan->key_prot);
 #endif /* LEAF */
 #endif /* LEAF */
+    } else if (channel_closed(chan)) {
+      enforce_closed(chan);
     }
     }
   }
   }
 }
 }
@@ -1016,6 +1019,7 @@ char *channels_start(Function * global_funcs)
 {
 {
   global = global_funcs;
   global = global_funcs;
 
 
+
   gfld_chan_thr = 0;
   gfld_chan_thr = 0;
   gfld_chan_time = 0;
   gfld_chan_time = 0;
   gfld_deop_thr = 8;
   gfld_deop_thr = 8;
@@ -1059,6 +1063,11 @@ char *channels_start(Function * global_funcs)
          "-private "
          "-private "
 	 "-fastop ");
 	 "-fastop ");
   module_register(MODULE_NAME, channels_table, 1, 0);
   module_register(MODULE_NAME, channels_table, 1, 0);
+  if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 1, 0))) {
+    module_undepend(MODULE_NAME);
+    return "This module requires irc module 1.0 or later.";
+  }
+
 #ifdef LEAF
 #ifdef LEAF
   add_hook(HOOK_MINUTELY, (Function) check_limitraise);
   add_hook(HOOK_MINUTELY, (Function) check_limitraise);
 #endif /* LEAF */
 #endif /* LEAF */
@@ -1069,7 +1078,7 @@ char *channels_start(Function * global_funcs)
   add_hook(HOOK_MINUTELY, (Function) check_expired_exempts);
   add_hook(HOOK_MINUTELY, (Function) check_expired_exempts);
   add_hook(HOOK_MINUTELY, (Function) check_expired_invites);
   add_hook(HOOK_MINUTELY, (Function) check_expired_invites);
   add_hook(HOOK_USERFILE, (Function) channels_writeuserfile);
   add_hook(HOOK_USERFILE, (Function) channels_writeuserfile);
-  add_hook(HOOK_10SECONDLY, (Function) channels_checkslowjoin);
+  add_hook(HOOK_10SECONDLY, (Function) channels_10secondly);
   add_builtins(H_chon, my_chon);
   add_builtins(H_chon, my_chon);
   add_builtins(H_dcc, C_dcc_irc);
   add_builtins(H_dcc, C_dcc_irc);
   add_builtins(H_bot, channels_bot);
   add_builtins(H_bot, channels_bot);

+ 1 - 8
src/mod/irc.mod/irc.c

@@ -1549,13 +1549,6 @@ static void getin_5secondly()
   }
   }
 }
 }
 
 
-static void irc_10secondly() {
-  struct chanset_t *chan;
-  for (chan = chanset; chan; chan = chan->next)
-    if (channel_closed(chan))
-      enforce_closed(chan);
-}
-
 EXPORT_SCOPE char *irc_start();
 EXPORT_SCOPE char *irc_start();
 
 
 static Function irc_table[] =
 static Function irc_table[] =
@@ -1590,6 +1583,7 @@ static Function irc_table[] =
   (Function) check_this_user,
   (Function) check_this_user,
   (Function) me_voice,
   (Function) me_voice,
   (Function) raise_limit,
   (Function) raise_limit,
+  (Function) enforce_closed,
 };
 };
 
 
 void irc_describe(struct cfg_entry *cfgent, int idx)
 void irc_describe(struct cfg_entry *cfgent, int idx)
@@ -1718,7 +1712,6 @@ char *irc_start(Function * global_funcs)
   add_hook(HOOK_ADD_MODE, (Function) real_add_mode);
   add_hook(HOOK_ADD_MODE, (Function) real_add_mode);
   add_hook(HOOK_IDLE, (Function) flush_modes);
   add_hook(HOOK_IDLE, (Function) flush_modes);
   add_hook(HOOK_5SECONDLY, (Function) getin_5secondly);
   add_hook(HOOK_5SECONDLY, (Function) getin_5secondly);
-  add_hook(HOOK_10SECONDLY, (Function) irc_10secondly);
 #ifdef S_AUTOLOCK
 #ifdef S_AUTOLOCK
   add_hook(HOOK_MINUTELY, (Function) check_netfight);
   add_hook(HOOK_MINUTELY, (Function) check_netfight);
 #endif /* S_AUTOLOCK */
 #endif /* S_AUTOLOCK */

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

@@ -71,6 +71,7 @@ void raise_limit(struct chanset_t *);
 #define check_this_user ((void(*)(char *, int, char *))irc_funcs[21])
 #define check_this_user ((void(*)(char *, int, char *))irc_funcs[21])
 #define me_voice ((int(*)(struct chanset_t *))irc_funcs[22])
 #define me_voice ((int(*)(struct chanset_t *))irc_funcs[22])
 #define raise_limit ((void (*)(struct chanset_t *))irc_funcs[23])
 #define raise_limit ((void (*)(struct chanset_t *))irc_funcs[23])
+#define enforce_closed ((void (*)(struct chanset_t *))irc_funcs[24])
 //#define getchanmode ((char *(*)(struct chanset_t *))irc_funcs[23])
 //#define getchanmode ((char *(*)(struct chanset_t *))irc_funcs[23])
 
 
 #endif				/* MAKING_IRC */
 #endif				/* MAKING_IRC */