On Thu, 1 Aug 2002, Mathew Earle Reuther wrote: > [snip] - snprintf(buf, sizeof(buf), "$n says, '%s'", argument); + snprintf(buf, sizeof(buf), "$n says, '%s&w'", argument); - send_to_char(ch, "You say, '%s'\r\n", argument); + send_to_char(ch, "You say, '%s&w'\r\n", argument); > As you can see here, where it is dropping argument there needs to be > some sort of a check to reset the color to normal. There's no need to check. Just always reset it to normal. The worst that can happen is you add a couple of bytes unnecessarily. If you want to completely prohibit players from using color, a simple solution is to double every '&' you encounter in their input. CircleMUD already does this for '$' -- see process_input(). There are two main situations that arise as a result of such doubling. The easiest to deal with is when the user's input is (at least in part) going to be used verbatim as output, as in most communication commands, titles, etc. This is easy to deal with because we don't actually need to do anything beyond the doubling. The output functions already call the interpret_colors() function, which smashes the consecutive '&' into a single ampersand for us. Thus: > say &rDark &Rred&w. You say, '&rDark &Rred&w.' making it appear to the user that there's no special processing of '&' going on. The other case is not much more difficult to deal with. Sometimes, you will want to process the user's input as typed, either because you're expecting arguments with an ampersand in it, are writing the input to a file or some other place where interpret_colors() won't be called on it and the doubling will be unattractive, or want to let the user use color in this particular situation. In that case, you should make a manual call to interpret_colors() to smash the doubling. For example, you may want to let immortals use color in say, and thus would do something like: else { char buf[MAX_INPUT_LENGTH + 12]; + if (GET_LEVEL(ch) >= LVL_IMMORT) { + /* Smash doubled '&', letting immortals use colors. */ + argument = interpret_colors(argument, FALSE); + } snprintf(buf, sizeof(buf), "$n says, '%s'", argument); -dak -- +---------------------------------------------------------------+ | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html | | Newbie List: http://groups.yahoo.com/group/circle-newbies/ | +---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/25/03 PDT