View Single Post
Old 11-23-2003, 10:05 AM   #2
erdos
 
Posts: n/a
Jaegar,

color tokens are meant to make in-game custom color possible, for example in helpfiles. using them in hardcode is a profound waste of CPU time because it means the code must look up the tokens each time to find the appropriate ANSI code-- when, in the hardcode, you could just explicitly give that ANSI string instead. The downside to this, though, is that you want to take care not to transmit this code to folks who are config -ANSI.
As for your creation menus: I'm not very familiar with ROM, but if it's anything like SMAUG, the uncreated player still has a char_data, almost from the start (look in your nanny function closely to find exactly where the descriptor is given a char_data). just because the char_data is not yet initialized with all the goodies like class, race, stats, max hp, etc., does not mean you can't use it as an argument for the usual send_to_char, send_to_char_color etc.
On a sidenote, while we're on the topic of write_to_buffer, a lot of codebases include a 3rd paramater, an int, meant to specify the length of the string, or 0 if you want it to explicitly calculate that length on the fly. People lazily (and/or ignorantly) use 0 even with long, constant strings, and this wastes CPU time unnecessarily. For example a call to write_to_buffer(d,"Hello world!",0) will force it to run strlen("Hello world!"), even though that result is never ever going to change. More efficient to do write_to_buffer(d,"Hello world!", 12)
  Reply With Quote