prompt() and @prompt now uses a notify flag to work. This allows ansi
authorRick L Bird <nveid@yahoo.com>
Sat, 14 May 2011 01:41:05 +0000 (21:41 -0400)
committerRick L Bird <nveid@yahoo.com>
Sat, 14 May 2011 01:41:05 +0000 (21:41 -0400)
to work in prompts again with the new markup system.

hdrs/externs.h
src/notify.c
src/prog.c

index 6796ddb80dd63acce713d3db0aa99de20bed38fc..cf79caad23d0025716a5bdade4f70513f19da957 100644 (file)
@@ -151,6 +151,7 @@ void sql_shutdown(void);
 #define NA_INTERACTION  (NA_INTER_HEAR|NA_INTER_SEE|NA_INTER_PRESENCE|NA_INTER_LOCK)    /**< Message follows interaction rules */
 #define NA_SPOOF        0x8000  /**< @ns* message, overrides NOSPOOF */
 #define NA_EVALONCONTACT 0x20000
+#define NA_PROMPT       0x40000
 
 /** A notify_anything lookup function type definition */
 typedef dbref (*na_lookup) (dbref, void *);
index cbb0893f845a34ad89fa98173b3cb2b3cba712fd..724153b7b10578c2ceabfb82868880a9eb80e85c 100644 (file)
@@ -824,7 +824,10 @@ notify_anything_loc(dbref speaker, na_lookup func,
                 queue_newwrite(d, (unsigned char *) "\n", 1);
               else
                 queue_newwrite(d, (unsigned char *) "<BR>\n", 5);
-            } else {
+            } else if((flags & NA_PROMPT) && PromptConnection(d)) { 
+             /* Print IAC GOHEAD */
+             queue_newwrite(d, (unsigned char *) " \xff\xF9", 3);
+           } else {
               queue_newwrite(d, (unsigned char *) "\r\n", 2);
             }
           }
index 22ed1fabde7362fbe1a3ed28edee49d058371d89..012e46444b2718cd755bdcda1d2319373f33db0b 100644 (file)
@@ -349,9 +349,7 @@ FUNCTION(fun_quitprog)
 COMMAND(cmd_prompt)
 {
   dbref who;
-  DESC *d;
   char *prompt;
-  char *tmp;
 
   switch (who =
           match_result(player, arg_left, NOTYPE,
@@ -388,24 +386,8 @@ COMMAND(cmd_prompt)
     } else
       prompt = (char *) UNDEFINED_PROMPT;
 
-    DESC_ITER_CONN(d) {
-      if (d->player == who) {
-        if (PromptConnection(d)) {
-          if (ShowAnsiColor(d->player))
-            tmp = tprintf("%s %c%c", prompt, IAC, GOAHEAD);
-          else
-            tmp =
-                tprintf("%s %c%c", remove_markup(prompt, NULL), IAC,
-                        GOAHEAD);
-        } else {
-          if (ShowAnsiColor(d->player))
-            tmp = tprintf("%s \r\n", prompt);
-          else
-            tmp = tprintf("%s \r\n", remove_markup(prompt, NULL));
-        }
-        queue_newwrite(d, (unsigned char *) tmp, strlen(tmp));
-      }
-    }
+    notify_anything(orator, na_one, &(who), NULL, NA_PROMPT, prompt);
+
   }
 
 }
@@ -413,20 +395,15 @@ COMMAND(cmd_prompt)
 FUNCTION(fun_prompt)
 {
   dbref who;
-  DESC *d;
   char *prompt;
-  char *tmp;
 
-  switch (who =
-          match_result(executor, args[0], NOTYPE,
-                       MAT_OBJECTS | MAT_HERE | MAT_CONTAINER)) {
-  case NOTHING:
+ who = match_result(executor, args[0], NOTYPE, MAT_OBJECTS | MAT_HERE | MAT_CONTAINER); 
+
+ if(who == NOTHING) 
     safe_str(T(e_match), buff, bp);
-    break;
-  case AMBIGUOUS:
+ else if(who == AMBIGUOUS)
     safe_str(T("#-2 AMBIGUOUS MATCH"), buff, bp);
-    break;
-  default:
+ else {
     if (!CanProg(executor, who)) {
       safe_str(T(e_perm), buff, bp);
       return;
@@ -444,24 +421,7 @@ FUNCTION(fun_prompt)
     else
       prompt = (char *) UNDEFINED_PROMPT;
 
-    DESC_ITER_CONN(d) {
-      if (d->player == who) {
-        if (PromptConnection(d)) {
-          if (ShowAnsiColor(who))
-            tmp = tprintf("%s %c%c", prompt, IAC, GOAHEAD);
-          else
-            tmp =
-                tprintf("%s %c%c", remove_markup(prompt, NULL), IAC,
-                        GOAHEAD);
-        } else {
-          if (ShowAnsiColor(who))
-            tmp = tprintf("%s \r\n", prompt);
-          else
-            tmp = tprintf("%s \r\n", remove_markup(prompt, NULL));
-        }
-        queue_newwrite(d, (unsigned char *) tmp, strlen(tmp));
-      }
-    }
+    notify_anything(orator, na_one, &(who), NULL, NA_PROMPT, prompt);
   }
 }
 
@@ -661,6 +621,8 @@ prog_load_desc(DESC * d)
   d->pinfo.lock = atoi(p);
   d->input_handler = prog_handler;
   memset(wprmpt, '\0', 2);
+  /* TODO: Modify so it only goes tot he connecting port */
+
   if ((a = atr_get(d->player, "XY_PROGPROMPT"))) {
     /* program prompt */
     char rbuf[BUFFER_LEN], *tbp, *rbp;
@@ -672,36 +634,15 @@ prog_load_desc(DESC * d)
                        d->pinfo.object, d->pinfo.object, PE_DEFAULT,
                        PT_DEFAULT, (PE_Info *) NULL);
 
+
     *rbp = '\0';
-    if (PromptConnection(d)) {
-      if (ShowAnsiColor(d->player))
-        snprintf(buf, BUFFER_LEN - 1, "%s %c%c", rbuf, IAC, GOAHEAD);
-      else
-        snprintf(buf, BUFFER_LEN - 1, "%s %c%c",
-                 remove_markup(rbuf, NULL), IAC, GOAHEAD);
-    } else {
-      if (ShowAnsiColor(d->player))
-        snprintf(buf, BUFFER_LEN - 1, "%s\r\n", rbuf);
-      else
-        snprintf(buf, BUFFER_LEN - 1, "%s\r\n", remove_markup(rbuf, NULL));
-    }
+
+    notify_anything(orator, na_one, &(d->player), NULL, NA_PROMPT, rbuf);
   } else {
-    if (PromptConnection(d)) {
-      if (ShowAnsi(d->player))
-        snprintf(buf, BUFFER_LEN - 1, "%s>%s %c%c", ANSI_HILITE,
-                 ANSI_NORMAL, IAC, GOAHEAD);
-      else
-        snprintf(buf, BUFFER_LEN - 1, "> %c%c", IAC, GOAHEAD);
-    } else {
-      if (ShowAnsi(d->player))
-        snprintf(buf, BUFFER_LEN - 1, "%s>%s\r\n", ANSI_HILITE,
+    snprintf(buf, BUFFER_LEN - 1, "%s>%s", ANSI_HILITE,
                  ANSI_NORMAL);
-      else
-        snprintf(buf, BUFFER_LEN - 1, ">\r\n");
-    }
+   notify_anything(orator, na_one, &(d->player), NULL, NA_PROMPT, buf);
   }
-  queue_newwrite(d, (unsigned char *) buf, strlen(buf));
-  process_output(d);
 }
 
 void