Top Mud Sites Forum Return to TopMudSites.com
Go Back   Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Click here to Register

Reply
 
Thread Tools
Old 11-23-2003, 03:30 AM   #1
Jaegar
New Member
 
Join Date: Apr 2002
Posts: 14
Jaegar is on a distinguished road
Unhappy

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
Jaegar is offline   Reply With Quote
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
Old 11-23-2003, 11:18 AM   #3
Kylotan
Member
 
Join Date: Jun 2003
Location: Nottingham, UK
Home MUD: Abattoir (Smaug)
Home MUD: ex-Jellybean (Smaug)
Home MUD: ex-Dark Chambers (Merc)
Posts: 174
Kylotan is on a distinguished road
Send a message via ICQ to Kylotan Send a message via AIM to Kylotan Send a message via MSN to Kylotan Send a message via Yahoo to Kylotan
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.
Kylotan is offline   Reply With Quote
Old 11-24-2003, 09:01 AM   #4
 
Posts: n/a
  Reply With Quote
Old 11-25-2003, 08:51 AM   #5
Kastagaar
Member
 
Join Date: Apr 2002
Location: Hampshire, UK
Posts: 117
Kastagaar is on a distinguished road
Send a message via Yahoo to Kastagaar
I ran a benchmarking suite on my computer the other day, and I measured my CPU efficiency at 100% - no pesky idle loop. I can thus reason that you need a better computer.
Kastagaar is offline   Reply With Quote
Old 11-30-2003, 08:22 PM   #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.
  Reply With Quote
Old 12-01-2003, 12:59 PM   #7
Kylotan
Member
 
Join Date: Jun 2003
Location: Nottingham, UK
Home MUD: Abattoir (Smaug)
Home MUD: ex-Jellybean (Smaug)
Home MUD: ex-Dark Chambers (Merc)
Posts: 174
Kylotan is on a distinguished road
Send a message via ICQ to Kylotan Send a message via AIM to Kylotan Send a message via MSN to Kylotan Send a message via Yahoo to Kylotan
Best omit the c and a parameters there, or it'll chew up cycles having to ignore them!
Kylotan is offline   Reply With Quote
Reply




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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -4. The time now is 07:56 AM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Style based on a design by Essilor
Copyright Top Mud Sites.com 2022