|
|||||||
This is a discussion on "Modifying write_to_buffer" in the Top Mud Sites MUD Coding forum : I am working with the Rom2.4 codebase and have added a new menu style creation process. I would like to be able to add color into this but am unsure how I could modify the void write_to_buffer so that it will recognize the color codes (ie {RChoose Class{x will result in Choose Class being displayed in bright red text). Has anyone done something like this or is it even possible? Thanks in advance, Jaegar... |
|
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our MUD community today! If you have any problems with the registration process or your account login, please contact us. If you are a registered member of the old TMS forums, please click here
|
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 14
![]() |
I am working with the Rom2.4 codebase and have added a new menu style creation process. I would like to be able to add color into this but am unsure how I could modify the void write_to_buffer so that it will recognize the color codes (ie {RChoose Class{x will result in Choose Class being displayed in bright red text).
Has anyone done something like this or is it even possible? Thanks in advance, Jaegar |
|
|
|
|
|
#2 |
|
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) |
|
|
|
#3 |
|
Member
Join Date: Jun 2003
Posts: 113
![]() |
And that just goes to show that excessively premature optimization is far from dead in the mud world.
Personally I'd construct a new write_to_buffer_color based on send_to_char_color. You'd only need to change a few lines. |
|
|
|
|
|
#4 | |
|
Posts: n/a
|
Quote:
write_to_buffer(d,"Hll Wrld",9); I've found it's even more efficient not to run a mud at all. Still I've got problems here on my machine. Does anyone know any clever ways to optimize a system idle loop that's consuming 98% of the CPU. |
|
|
|
|
#5 | |
|
Member
|
Quote:
|
|
|
|
|
|
|
#6 |
|
Posts: n/a
|
I got it fixed. I wrote my own idleloop to kick its butt.
$ cat idleloop.c main(int c, char** a) {eff: goto eff;} For best results use gcc -O3 which puts the compiler in ninja-mode. |
|
|
|
#7 |
|
Member
Join Date: Jun 2003
Posts: 113
![]() |
Best omit the c and a parameters there, or it'll chew up cycles having to ignore them!
|
|
|
|
![]() |
| Thread Tools | |
Modifying write_to_buffer - Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Modifying mpedit_list | Jaegar | MUD Coding | 1 | 09-25-2002 12:49 PM |
|
|