|
@@ -50,15 +50,6 @@ void harry_idle_event(int fd) {
|
|
|
buffer << "^CS^S2^C" << std::setfill('0') << std::setw(2) << color
|
|
|
<< phrases[r] << "^P2^CR^D" << std::setw(2) << strlen(phrases[r]);
|
|
|
|
|
|
- /*
|
|
|
- slen = snprintf(buffer, sizeof(buffer), "^S2^C%02d%s^P2^CR^D%02d", color, cp,
|
|
|
- (int)strlen(cp));
|
|
|
- if (slen >= sizeof(buffer)) {
|
|
|
- ZF_LOGE("snprintf %d > size %d", slen, (int)sizeof(buffer));
|
|
|
- buffer[0] = 0;
|
|
|
- }
|
|
|
- */
|
|
|
-
|
|
|
std::string str = buffer.str();
|
|
|
ZF_LOGD("harry_event: render(%d, \"%s\")", fd, str.c_str());
|
|
|
render(fd, str);
|
|
@@ -83,16 +74,8 @@ int mangle_clrscr(std::string &buffer, std::string &work, size_t pos) {
|
|
|
return 0;
|
|
|
|
|
|
if (ANSI_CLS_count > 1) {
|
|
|
- /*
|
|
|
- // get the restore color value
|
|
|
- struct console_details temp_console;
|
|
|
- memcpy(&temp_console, &console, sizeof(console));
|
|
|
- console_receive(&temp_console, buffer.substr(0, pos));
|
|
|
- std::string restore_color;
|
|
|
- restore_color.assign(color_restore(&temp_console));
|
|
|
- */
|
|
|
-
|
|
|
- //if (random_activate((level + 1) / 2)) {
|
|
|
+
|
|
|
+ // if (random_activate((level + 1) / 2)) {
|
|
|
if (random_activate(level * 5)) {
|
|
|
std::ostringstream display;
|
|
|
int needs_cls = 0;
|
|
@@ -132,9 +115,6 @@ int mangle_clrscr(std::string &buffer, std::string &work, size_t pos) {
|
|
|
// reset display
|
|
|
display.str(std::string());
|
|
|
display.clear();
|
|
|
-
|
|
|
- // render image, home cursor
|
|
|
- // slen = snprintf(fgoto, sizeof(fgoto), "^f%02d%02d\x1b[1;1H", x, y);
|
|
|
} else {
|
|
|
fgoto.assign("^CS^F");
|
|
|
}
|
|
@@ -154,9 +134,6 @@ int mangle_clrscr(std::string &buffer, std::string &work, size_t pos) {
|
|
|
|
|
|
display << (needs_cls ? "\x1b[2J" : "") << fgoto << "^CR^P3";
|
|
|
|
|
|
- // slen = snprintf(display, sizeof(display), "%s%s%s^P3",
|
|
|
- // needs_cls ? "\x1b[2J" : "", fgoto, restore_color);
|
|
|
-
|
|
|
std::string display_output = display.str();
|
|
|
|
|
|
ZF_LOGI("mangle(ANSI_CLS): %d file inserted %s", r,
|
|
@@ -167,7 +144,7 @@ int mangle_clrscr(std::string &buffer, std::string &work, size_t pos) {
|
|
|
work.insert(pos, std::string(display_output.size(), ' '));
|
|
|
return 1; // need_render = 1;
|
|
|
} else {
|
|
|
- //if (random_activate((level + 1) / 2)) {
|
|
|
+ // if (random_activate((level + 1) / 2)) {
|
|
|
if (random_activate(level * 5)) {
|
|
|
int r;
|
|
|
std::ostringstream display;
|
|
@@ -209,22 +186,14 @@ int mangle_clrscr(std::string &buffer, std::string &work, size_t pos) {
|
|
|
if (strncmp(phrasing[r], "^G", 2) == 0) {
|
|
|
display << "^CS^S3^P1" << phrasing[r] << "^S0^R0^CR^P1^G0101";
|
|
|
// This starts with a GOTO, so don't use our random position
|
|
|
- // slen = snprintf(display, sizeof(display),
|
|
|
- // "^S3^P1%s^S0^R0%s^P1^G0101",
|
|
|
- // phrasing[r], restore_color);
|
|
|
} else {
|
|
|
display << "^CS^G" << std::setw(2) << std::setfill('0') << x
|
|
|
<< std::setw(2) << y << "^S3^C" << std::setw(2) << color
|
|
|
<< "^P1" << phrasing[r] << "^S0^R0^CR^P1^G0101";
|
|
|
- // slen = snprintf(display, sizeof(display),
|
|
|
- // "^G%02d%02d^S3^C%02d^P1%s^S0^R0%s^P1^G0101", x, y,
|
|
|
- // color, phrasing[r], restore_color);
|
|
|
};
|
|
|
|
|
|
std::string display_output = display.str();
|
|
|
|
|
|
- // sprintf(display, "^P1^S3^C%02d%s^S0^R0%s^P1", color, phrasing[r],
|
|
|
- // restore_color);
|
|
|
// Added debug statement so we can identify what was sent... color,
|
|
|
// number picked and what that is
|
|
|
ZF_LOGD("mangle(ANSI_CLS): Inserted color=%02d r=%d phrase='%s'", color,
|
|
@@ -322,7 +291,7 @@ int mangle(int fd, std::string &buffer) {
|
|
|
|
|
|
replace(buffer, old_string, new_string);
|
|
|
replace(work, old_string, new_string);
|
|
|
- level = 0; // turn off the manglers! ;)
|
|
|
+ level = 0; // temp turn off the manglers! ;)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -410,6 +379,8 @@ int mangle(int fd, std::string &buffer) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Control buffer debugging output.
|
|
|
+#ifndef NO_BUFFER_DEBUG
|
|
|
// ZF_LOGV_LR("mangle:", buffer);
|
|
|
ZF_LOGV_LR("Buffer:", buffer);
|
|
|
ZF_LOGV_LR("Work:", work);
|
|
@@ -446,6 +417,7 @@ int mangle(int fd, std::string &buffer) {
|
|
|
// reset oss (if we need it)
|
|
|
oss.str(std::string());
|
|
|
oss.clear();
|
|
|
+#endif
|
|
|
|
|
|
// Begin the mangle process 2.0
|
|
|
if (level) {
|