|
@@ -45,6 +45,8 @@ static void file_output_open(const char *const log_path) {
|
|
|
|
|
|
// END LOGGING
|
|
// END LOGGING
|
|
|
|
|
|
|
|
+#include "lastseen.h"
|
|
|
|
+
|
|
/*
|
|
/*
|
|
What is the name of the actual, real Mystic executable
|
|
What is the name of the actual, real Mystic executable
|
|
that we'll be executing and mangling?
|
|
that we'll be executing and mangling?
|
|
@@ -946,43 +948,9 @@ void init_have_seen(int *list, int len) {
|
|
|
|
|
|
*/
|
|
*/
|
|
|
|
|
|
-class LastSeen {
|
|
|
|
-private:
|
|
|
|
- int *tracker;
|
|
|
|
- int max;
|
|
|
|
-
|
|
|
|
-public:
|
|
|
|
- LastSeen(int max_nondups);
|
|
|
|
- ~LastSeen();
|
|
|
|
- bool seen_before(int this_one);
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-LastSeen::LastSeen(int max_nondups) {
|
|
|
|
- this->max = max_nondups;
|
|
|
|
- this->tracker = new int[max_nondups];
|
|
|
|
- for (int i = 0; i < max_nondups; i++) {
|
|
|
|
- this->tracker[i] = -1;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-LastSeen::~LastSeen() { delete this->tracker; }
|
|
|
|
-
|
|
|
|
-bool LastSeen::seen_before(int this_one) {
|
|
|
|
- int i;
|
|
|
|
- for (i = 0; i < this->max; i++) {
|
|
|
|
- if (this->tracker[i] == this_one)
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- // Ok, it hasn't been seen before.
|
|
|
|
- for (i = 0; i < this->max - 1; i++) {
|
|
|
|
- this->tracker[i] = this->tracker[i + 1];
|
|
|
|
- };
|
|
|
|
- this->tracker[i] = this_one;
|
|
|
|
- return false;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-#define MAX_HARRY_EVENT_DUPS 2
|
|
|
|
-int last_seen_harry_event[MAX_HARRY_EVENT_DUPS];
|
|
|
|
|
|
+// #define MAX_HARRY_EVENT_DUPS 2
|
|
|
|
+// int last_seen_harry_event[MAX_HARRY_EVENT_DUPS];
|
|
|
|
+LastSeen last_seen_harry_event(2);
|
|
|
|
|
|
#ifdef CPP_MADMAN_STL_CODE
|
|
#ifdef CPP_MADMAN_STL_CODE
|
|
|
|
|
|
@@ -1019,9 +987,10 @@ void harry_idle_event(int fd) {
|
|
|
|
|
|
do {
|
|
do {
|
|
r = random() % ((sizeof(phrases) / sizeof(char *)) - 1);
|
|
r = random() % ((sizeof(phrases) / sizeof(char *)) - 1);
|
|
- } while (have_seen(last_seen_harry_event, MAX_HARRY_EVENT_DUPS, r));
|
|
|
|
|
|
+ } while (!last_seen_harry_event.seen_before(r));
|
|
|
|
|
|
- ZF_LOGD("%d => %d %d", r, last_seen_harry_event[0], last_seen_harry_event[1]);
|
|
|
|
|
|
+ // ZF_LOGD("%d => %d %d", r, last_seen_harry_event[0],
|
|
|
|
+ // last_seen_harry_event[1]);
|
|
|
|
|
|
cp = phrases[r];
|
|
cp = phrases[r];
|
|
int color = random() % 16;
|
|
int color = random() % 16;
|
|
@@ -1037,7 +1006,7 @@ void harry_idle_event(int fd) {
|
|
}
|
|
}
|
|
|
|
|
|
void init_harry() {
|
|
void init_harry() {
|
|
- init_have_seen(last_seen_harry_event, MAX_HARRY_EVENT_DUPS);
|
|
|
|
|
|
+ // init_have_seen(last_seen_harry_event, MAX_HARRY_EVENT_DUPS);
|
|
// ZF_LOGD("init => %d %d", last_seen_harry_event[0],
|
|
// ZF_LOGD("init => %d %d", last_seen_harry_event[0],
|
|
// last_seen_harry_event[1]);
|
|
// last_seen_harry_event[1]);
|
|
console_init(&console);
|
|
console_init(&console);
|