Преглед изворни кода

* Another cmd_botcmd fix.

svn: 936
Bryan Drewery пре 22 година
родитељ
комит
5404b47f70
2 измењених фајлова са 5 додато и 5 уклоњено
  1. 1 0
      doc/UPDATES
  2. 4 5
      src/cmds.c

+ 1 - 0
doc/UPDATES

@@ -12,6 +12,7 @@ This is a summary of ChangeLog basically.
 8.Fixed msg_invite spamming the password for non-users.
 8.Fixed msg_invite spamming the password for non-users.
 9.Removed cmd_vbottree (cmd_bottree now shows the information).
 9.Removed cmd_vbottree (cmd_bottree now shows the information).
 10.Fixed msgc_voice, was checking for +v instead of +q.
 10.Fixed msgc_voice, was checking for +v instead of +q.
+11.Fixed cmd_botcmd not matching '?' correctly again!
 
 
 1.1.5
 1.1.5
 
 

+ 4 - 5
src/cmds.c

@@ -1560,7 +1560,7 @@ static void cmd_chsecpass(struct userrec *u, int idx, char *par)
 static void cmd_botcmd(struct userrec *u, int idx, char *par)
 static void cmd_botcmd(struct userrec *u, int idx, char *par)
 {
 {
   tand_t *tbot = NULL;
   tand_t *tbot = NULL;
-  int cnt = 0, rleaf = (-1), tbots = 0, found = 0;
+  int cnt = 0, rleaf = -1, tbots = 0, found = 0;
   char *botm = NULL, *cmd = NULL;
   char *botm = NULL, *cmd = NULL;
   
   
   botm = newsplit(&par);
   botm = newsplit(&par);
@@ -1586,18 +1586,17 @@ static void cmd_botcmd(struct userrec *u, int idx, char *par)
         tbots++;
         tbots++;
     }
     }
     if (tbots)
     if (tbots)
-      rleaf = randint(tbots);
+      rleaf = 1 + randint(tbots + 1);		/* 1 <--> tbots */
   }
   }
   
   
   for (tbot = tandbot; tbot; tbot = tbot->next) {
   for (tbot = tandbot; tbot; tbot = tbot->next) {
     if (!strcmp(botm, "?") && bot_hublevel(get_user_by_handle(userlist, tbot->bot)) != 999)
     if (!strcmp(botm, "?") && bot_hublevel(get_user_by_handle(userlist, tbot->bot)) != 999)
       continue;
       continue;
-
-    if ((rleaf != (-1) && (cnt - 1) == rleaf) || ((rleaf == (-1) && wild_match(botm, tbot->bot)))) {
+    cnt++;
+    if ((rleaf != -1 && cnt == rleaf) || (rleaf == -1 && wild_match(botm, tbot->bot))) {
       send_remote_simul(idx, tbot->bot, cmd, par ? par : "");
       send_remote_simul(idx, tbot->bot, cmd, par ? par : "");
       found++;
       found++;
     }
     }
-    cnt++;
   }
   }
 
 
   if (!found)
   if (!found)