|
@@ -15,6 +15,8 @@
|
|
|
#include <vector>
|
|
|
|
|
|
extern struct console_details console;
|
|
|
+extern std::string username;
|
|
|
+extern std::string fullname;
|
|
|
|
|
|
#define BSIZE 512
|
|
|
|
|
@@ -32,23 +34,52 @@ void harry_idle_event(int fd) {
|
|
|
if (!level)
|
|
|
return;
|
|
|
|
|
|
+ // If the username is something, we have their info!
|
|
|
+ bool have_userinfo = !username.empty();
|
|
|
+
|
|
|
// This is no where near finished, BUT!
|
|
|
// Do not put any ^ codes in these -- the strlen() would be wrong.
|
|
|
- const char *phrases[] = {"Hahaha", "Snicker, snicker", "Boo!",
|
|
|
- "MeOW", "I see U", "Arrooo!",
|
|
|
- "Ahh-wooo!", "Aaaooo!"};
|
|
|
+ const char *phrases[] = {
|
|
|
+ "Hahaha", "Snicker, snicker", "Boo!", "Arrooo!", "Ahh-wooo!",
|
|
|
+ "Aaaooo!", "Sorry, I forgot!", "Knock-Knock...",
|
|
|
+ };
|
|
|
+ const int total_phrases = sizeof(phrases) / sizeof(char *);
|
|
|
+
|
|
|
+ const char *user_phrases[] = {
|
|
|
+ "Is USER really here?",
|
|
|
+ "What is a NICK?",
|
|
|
+ "Here lies USER, rest in peace.",
|
|
|
+ "Don't be scared, NICK.",
|
|
|
+ };
|
|
|
+ const int total_user_phrases = sizeof(user_phrases) / sizeof(char *);
|
|
|
|
|
|
static LastSeen last_seen_harry_event(2);
|
|
|
|
|
|
+ int total_possible =
|
|
|
+ have_userinfo ? total_phrases + total_user_phrases : total_phrases;
|
|
|
+
|
|
|
+ ZF_LOGD("%d total %d console @ %d,%d", have_userinfo, total_possible,
|
|
|
+ console.posx, console.posy);
|
|
|
do {
|
|
|
- r = randint((sizeof(phrases) / sizeof(char *)));
|
|
|
+ r = randint(total_possible);
|
|
|
} while (last_seen_harry_event.seen_before(r));
|
|
|
|
|
|
+ std::string selected;
|
|
|
+ if (r > total_phrases) {
|
|
|
+ selected = user_phrases[r - total_phrases];
|
|
|
+ replace(selected, "USER", fullname);
|
|
|
+ replace(selected, "NICK", username);
|
|
|
+ } else
|
|
|
+ selected = phrases[r];
|
|
|
+
|
|
|
int color = randint(15) + 1;
|
|
|
// %02d = std::setfill('0') << std::setw(2) << (int)
|
|
|
-
|
|
|
+ /*
|
|
|
buffer << "^CS^S2^C" << std::setfill('0') << std::setw(2) << color
|
|
|
<< phrases[r] << "^P2^CR^D" << std::setw(2) << strlen(phrases[r]);
|
|
|
+ */
|
|
|
+ buffer << "^CS^S2^C" << std::setfill('0') << std::setw(2) << color << selected
|
|
|
+ << "^P2^CR^D" << std::setw(2) << selected.size();
|
|
|
|
|
|
std::string str = buffer.str();
|
|
|
ZF_LOGD("harry_event: render(%d, \"%s\")", fd, str.c_str());
|
|
@@ -272,7 +303,8 @@ int mangle(int fd, std::string &buffer) {
|
|
|
"NeXTSTEP", "MINIX", "Solaris",
|
|
|
"Plan 9", "FreeBSD", "Windows 95",
|
|
|
"Palm OS", "Mac OS X", "Windows XP",
|
|
|
- "DESQview",
|
|
|
+ "DESQview", "EMACS",
|
|
|
+ // EMACS *should* be an OS!
|
|
|
};
|
|
|
|
|
|
int r = randint(sizeof(bbs_systems) / sizeof(char *));
|