]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanfix/chanfix.c
gline playground
[irc/quakenet/newserv.git] / chanfix / chanfix.c
index d24b2a55c96dcb1dfa87bcd41cfc079c338d0c3e..79cace4566c6b034bf2b0b725239ec2cc78b22ed 100644 (file)
@@ -20,7 +20,7 @@ extern nick *mynick;
 
 int cfext;
 int cfnext;
-int failedinit;
+int cffailedinit;
 
 /* user accessible commands */
 int cfcmd_debug(void *source, int cargc, char **cargv);
@@ -63,29 +63,29 @@ void _init() {
 
   if (cfext < 0 || cfnext < 0) {
     Error("chanfix", ERR_ERROR, "Couldn't register channel and/or nick extension");
-    failedinit = 1;
+    cffailedinit = 1;
   } else {
     schedulerecurring(time(NULL), 0, CFSAMPLEINTERVAL, &cfsched_dosample, NULL);
     schedulerecurring(time(NULL), 0, CFEXPIREINTERVAL, &cfsched_doexpire, NULL);
     schedulerecurring(time(NULL), 0, CFAUTOSAVEINTERVAL, &cfsched_dosave, NULL);
 
-    registercontrolcmd("cfdebug", 10, 1, &cfcmd_debug);
-    registercontrolcmd("cfhistogram", 10, 1, &cfcmd_debughistogram);
+    registercontrolhelpcmd("cfdebug", NO_DEVELOPER, 1, &cfcmd_debug, "Display Debug Information on chanfix data for channel");
+    registercontrolhelpcmd("cfhistogram", NO_DEVELOPER, 1, &cfcmd_debughistogram, "Display Debug Histogram of chanfix data for channel");
 #if CFDEBUG
-    registercontrolcmd("cfsample", 10, 1, &cfcmd_debugsample);
-    registercontrolcmd("cfexpire", 10, 1, &cfcmd_debugexpire);
+    registercontrolhelpcmd("cfsample", NO_DEVELOPER, &cfcmd_debugsample, "DEBUG Command - must not be loaded on live instances");
+    registercontrolhelpcmd("cfexpire", NO_DEVELOPER, 1, &cfcmd_debugexpire, "DEBUG Command - must not be loaded on live instances");
 #endif
-    registercontrolcmd("chanopstat", 10, 1, &cfcmd_chanopstat);
-    registercontrolcmd("chanoplist", 10, 1, &cfcmd_chanoplist);
+    registercontrolhelpcmd("chanopstat", NO_OPER, 1, &cfcmd_chanopstat, "Shows chanop statistics for a given channel");
+    registercontrolhelpcmd("chanoplist", NO_OPER, 1, &cfcmd_chanoplist, "Shows lists of known chanops, including scores");
 
-    registercontrolcmd("chanfix", 10, 1, &cfcmd_chanfix);
-    registercontrolcmd("showregs", 10, 1, &cfcmd_showregs);
+    registercontrolhelpcmd("chanfix", NO_OPER, 1, &cfcmd_chanfix, "Perform a chanfix on a channel to op known users only");
+    registercontrolhelpcmd("showregs", NO_OPER, 1, &cfcmd_showregs, "Show regular ops known on a channel (including services)");
 #if CFDEBUG
     /* should we disable this in the 'final' build? */
-//    registercontrolcmd("requestop", 0, 2, &cfcmd_requestop);
+    /* registercontrolcmd("requestop", 0, 2, &cfcmd_requestop); */
 #endif
-    registercontrolcmd("cfsave", 10, 0, &cfcmd_save);
-    registercontrolcmd("cfload", 10, 0, &cfcmd_load);
+    registercontrolhelpcmd("cfsave", NO_DEVELOPER, 0, &cfcmd_save, "Force save of chanfix data");
+    registercontrolhelpcmd("cfload", NO_DEVELOPER, 0, &cfcmd_load, "Force load of chanfix data");
 
 #if CFAUTOFIX
     registerhook(HOOK_CHANNEL_DEOPPED, &cfhook_autofix);
@@ -100,7 +100,7 @@ void _init() {
 
     cf_loadchanfix();
 
-    failedinit = 0;
+    cffailedinit = 0;
   }
 }
 
@@ -108,7 +108,7 @@ void _fini() {
   int i;
   nick *nip;
 
-  if (failedinit == 0) {
+  if (cffailedinit == 0) {
     deleteschedule(NULL, &cfsched_dosample, NULL);
     deleteschedule(NULL, &cfsched_doexpire, NULL);
     deleteschedule(NULL, &cfsched_dosave, NULL);
@@ -925,7 +925,7 @@ void cfhook_statsreport(int hook, void *arg) {
   nick *nip;
   chanfix *cf;
 
-  if ((int)arg > 2) {
+  if ((long)arg > 2) {
     memory = rc = mc = 0;
 
     for (i=0; i<CHANNELHASHSIZE; i++) {
@@ -1201,7 +1201,7 @@ int cf_fixchannel(channel *cp) {
     if(cp->users->content[a] != nouser) {
       np = getnickbynumeric(cp->users->content[a]);
 
-      if (IsService(np)) {
+      if (IsService(np) && (np->nick[1] == '\0')) {
         localdosetmode_nick(&changes, np, MC_OP);
         count++;
       } else
@@ -1225,13 +1225,13 @@ int cf_fixchannel(channel *cp) {
     if (count >= CFMAXOPS || rolist[i]->score < rolist[0]->score / 2)
       break;
 
-    if (rolist[i]->score < CFMINSCORE)
+    if (rolist[i]->score < CFMINSCORE && i != 0 )
       continue;
 
     np = cf_findnick(rolist[i], cp->index);
 
     /* only if it's not a service, so we don't screw up 'count' */
-    if (np && !IsService(np)) {
+    if (np && !(IsService(np) && np->nick[1] == '\0')) {
       localdosetmode_nick(&changes, np, MC_OP);
 
       count++;