Kaynağa Gözat

mangle(ANSI_CLS) Randomly decides to display text

  Then randomly picks text and a color and boom, bugz your uncle.
david 5 yıl önce
ebeveyn
işleme
ca091ad762
1 değiştirilmiş dosya ile 13 ekleme ve 8 silme
  1. 13 8
      mystic.c

+ 13 - 8
mystic.c

@@ -1098,8 +1098,8 @@ int mangle(int fd, char *buffer) {
       int color;
       char display[100] = "";
       const char* phrasing[] = {"HeHeHe", "Poof!", "Got U",
-                                "Anyone there?", "There Wolf", "There Castle"};
-      const char* phr;
+                                "Anyone there?",
+                                };
 
       ZF_LOGI("mangle(ANSI_CLS)");
       // sprintf( display, "^P2...");
@@ -1108,12 +1108,17 @@ int mangle(int fd, char *buffer) {
 
       // strcpy(display, "^P2^S301234^P15^S0^P2");
 
-      // Add in random text, plus color!
-      r = random() % ((sizeof(phrasing) / sizeof(char *)) - 1);
-      color = random() % 16;
-      if(color == 0){ color++; }
-      sprintf(display, "^P1^S3^C%02d%s^S0^P1", color, phrasing[r]);
-      ZF_LOGD("mangle(ANSI_CLS): Inserted (%02d) %s", color, phrasing[r]);
+      r = random() % 10;
+      if(r == 8){
+        // Add in random text, plus color!
+        r = random() % ((sizeof(phrasing) / sizeof(char *)) - 1);
+        color = random() % 16;
+        if(color == 0){ color++; }
+        sprintf(display, "^P1^S3^C%02d%s^S0^P1", color, phrasing[r]);
+        ZF_LOGI("mangle(ANSI_CLS): Inserted (%02d) %s", color, phrasing[r]);
+      } else {
+        ZF_LOGI("mangle(ANSI_CLS): Inserted Nothing");
+      }
 
       // Move the buffer so there's room for the display string.
       memmove(cp + strlen(display), cp, strlen(cp) + 1);