Bryan Drewery 22 лет назад
Родитель
Сommit
86b66c1ef3
3 измененных файлов с 7 добавлено и 8 удалено
  1. 1 1
      src/eggdrop.h
  2. 3 4
      src/makeres.c
  3. 3 3
      src/response.c

+ 1 - 1
src/eggdrop.h

@@ -104,7 +104,7 @@
  * modulo would probably be sufficient but on systems lacking random(),
  * the function will be just renamed rand().
  */
-#define randint(n) (unsigned long) (random() / (RAND_MAX + 1.0) * ((n) < 0 ? (-(n)) : (n)))
+#define randint(n) (unsigned long) (random() / (RAND_MAX + 1.0) * n)
 
 
 /***********************************************************************/

+ 3 - 4
src/makeres.c

@@ -136,9 +136,7 @@ int parse_res(char *in, char *out, char *outs) {
 #ifndef _RESPONSE_H\n\
 #define _RESPONSE_H\n\
 \n\
-char *response(int);\n\
-void init_responses();\n\n\
-enum {\n");
+typedef enum {\n");
 
   fprintf(outsf, "/* DO NOT EDIT THIS FILE. */\n\
 #ifndef _RESPONSES_H\n\
@@ -174,7 +172,8 @@ typedef char * res_t;\n\n");
           fprintf(outsf, "static res_t res_%s[] = {\n", cmd);
           sprintf(lower_resps, "%s,\n\tres_%s", lower_resps, cmd);
         } else {			/* END */
-          fprintf(outf, "\tRES_END\n};\n\n#define RES_TYPES %d\n\n#endif /* !_RESPONSE_H */\n", total_responses);
+          fprintf(outf, "\tRES_END\n} response_t;\n\n#define RES_TYPES %d\n", total_responses);
+          fprintf(outf, "char *response(response_t);\nvoid init_responses();\n\n#endif /* !_RESPONSE_H */\n");
           fprintf(outsf, "static res_t *res[] = {\n\tNULL%s\n};\n#endif /* !_RESPONSES_H */\n", lower_resps);
         }
       } else {				/* NEXT RES TEXT */

+ 3 - 3
src/response.c

@@ -10,7 +10,7 @@
 #include "main.h"
 #include "responses.h"
 
-static int response_totals[RES_TYPES + 1];
+static response_t response_totals[RES_TYPES + 1];
 
 void
 init_responses()
@@ -22,7 +22,7 @@ init_responses()
 }
 
 static void
-count_responses(int type)
+count_responses(response_t type)
 {
   unsigned int total = 0;
 
@@ -34,7 +34,7 @@ count_responses(int type)
 }
 
 char *
-response(int type)
+response(response_t type)
 {
   if (!type)
     type = randint(RES_TYPES) + 1;