Quellcode durchsuchen

* Moved check_expired_* to check_expired_masks()
* Started on channels_timers


svn: 1182

Bryan Drewery vor 22 Jahren
Ursprung
Commit
8a9f3107a4
3 geänderte Dateien mit 47 neuen und 26 gelöschten Zeilen
  1. 39 23
      src/mod/channels.mod/channels.c
  2. 1 3
      src/mod/channels.mod/channels.h
  3. 7 0
      src/mod/channels.mod/userchan.c

+ 39 - 23
src/mod/channels.mod/channels.c

@@ -396,6 +396,44 @@ static void channels_10secondly() {
   }
 }
 
+#ifdef LEAF
+static void 
+check_limitraise(struct chanset_t *chan) {
+  /* only check every other time for now */
+  static int checklimit = 0;
+
+  checklimit++;
+  if (checklimit == 2) {
+    checklimit = 0;
+    if (chan->limitraise && dolimit(chan))
+      raise_limit(chan);
+  }
+}
+#endif /* LEAF */
+
+static void
+channels_timers()
+{
+  static int cnt = 0;
+  struct chanset_t *chan = NULL;
+
+  cnt += 10;		/* function is called every 10 seconds */
+
+  for (chan = chanset; chan; chan = chan->next) {
+    if ((cnt % 10) == 0) {
+      /* 10 seconds */
+    }
+    if ((cnt % 30) == 0) {
+      /* 30 seconds */
+    }
+    if ((cnt % 60) == 0) {
+      /* 60 seconds */
+      cnt = 0;
+      check_limitraise(chan);
+    }
+  }
+}
+
 static void got_sj(int idx, char *code, char *par) 
 {
   char *chname = NULL;
@@ -877,23 +915,6 @@ cmd_t channels_bot[] = {
   {NULL, 	NULL, 	NULL, 			NULL}
 };
 
-#ifdef LEAF
-static void check_limitraise() {
-  int i = 0;
-  static int checklimit = 1;
-  struct chanset_t *chan = NULL;
-
-  for (chan = chanset; chan; chan = chan->next, i++) {
-    if (i % 2 == checklimit && chan->limitraise && dolimit(chan))
-          raise_limit(chan);
-  }
-  if (checklimit)
-    checklimit = 0;
-  else
-    checklimit = 1;
-}
-#endif /* LEAF */
-
 
 void channels_init()
 {
@@ -937,13 +958,8 @@ void channels_init()
 	 "-voice "
          "-private "
 	 "-fastop ");
-#ifdef LEAF
-  timer_create_secs(60, "check_limitraise", (Function) check_limitraise);
-#endif /* LEAF */
   /* FIXME: combine all of these into one function, check_expired_masks('e') */
-  timer_create_secs(60, "check_expired_bans", (Function) check_expired_bans);
-  timer_create_secs(60, "check_expired_exempts", (Function) check_expired_exempts);
-  timer_create_secs(60, "check_expired_invites", (Function) check_expired_invites);
+  timer_create_secs(60, "check_expired_masks", (Function) check_expired_masks);
 #ifdef HUB
   timer_create_secs(30, "rebalance_roles", (Function) rebalance_roles);
   timer_create_secs(30, "check_should_close", (Function) check_should_close);

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

@@ -17,9 +17,7 @@
 
 static void tell_bans(int idx, int show_inact, char *match);
 
-static void check_expired_bans(void);
-static void check_expired_exempts(void);
-static void check_expired_invites(void);
+static void check_expired_masks(void);
 static void tell_exempts (int idx, int show_inact, char * match);
 static void tell_invites (int idx, int show_inact, char * match);
 static void get_mode_protect(struct chanset_t *chan, char *s);

+ 7 - 0
src/mod/channels.mod/userchan.c

@@ -1317,3 +1317,10 @@ static void check_expired_invites(void)
     }
   }
 }
+
+void check_expired_masks()
+{
+  check_expired_bans();
+  check_expired_exempts();
+  check_expired_invites();
+}