From: Rick L Bird Date: Sat, 14 May 2011 01:41:05 +0000 (-0400) Subject: prompt() and @prompt now uses a notify flag to work. This allows ansi X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=031a4bfadc80b8cccfee3b1d2436f45f02ef5304;p=cobramush.git prompt() and @prompt now uses a notify flag to work. This allows ansi to work in prompts again with the new markup system. --- diff --git a/hdrs/externs.h b/hdrs/externs.h index 6796ddb..cf79caa 100644 --- a/hdrs/externs.h +++ b/hdrs/externs.h @@ -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 *); diff --git a/src/notify.c b/src/notify.c index cbb0893..724153b 100644 --- a/src/notify.c +++ b/src/notify.c @@ -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 *) "
\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); } } diff --git a/src/prog.c b/src/prog.c index 22ed1fa..012e464 100644 --- a/src/prog.c +++ b/src/prog.c @@ -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