Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ Running the server ➜ ANSI bleeding

ANSI bleeding

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Marowi   (65 posts)  Bio
Date Sun 07 Mar 2004 10:50 AM (UTC)
Message
My ANSI colour bleeds. Sometimes this is considered a good thing, but at the moment, I can't get the '&r' token to display correctly unless I place a reset colour token ('&W') in the same output.

For example, '&r Hey' will display 'Hey' using the '&R' colour, but '&W&r Hey' displays 'Hey' using the correct '&r' colour.

How can I prevent this from happening?
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #1 on Sun 07 Mar 2004 08:33 PM (UTC)
Message
Best solution: install samson's custom color code. stock color is horrible, and virtually impossible to fix.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Marowi   (65 posts)  Bio
Date Reply #2 on Wed 10 Mar 2004 03:24 AM (UTC)
Message
I read that solution elsewhere, and have spent 24 hours searching for the damned download. I couldn't find it on his site, but it could be there..

If someone could link to it or a mirror from here, please do.

Also, I did find one color code (not sure if it's Samson's), but it had a seperate color.c and color.h; can this be avoided?
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #3 on Wed 10 Mar 2004 04:12 AM (UTC)
Message
Try this:
http://www.afkmud.com/downloads.php?cat=multi

The snippet is called: Customizable ANSI Color v3.0

You CAN do without the seperate files, but trust me, later of, you'll find the more files the bettter.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #4 on Wed 10 Mar 2004 08:29 AM (UTC)
Message
Modularization of code is your friend. Can (and will) save you much headache if you can look at a filename and know exactly whats in it and where to look for it so you can change it easily.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Marowi   (65 posts)  Bio
Date Reply #5 on Sun 21 Mar 2004 04:21 PM (UTC)
Message
Ok, I'd have to agree. The modularisation of files DOES make things easier.

The snippet works/worked, but I restored from a backup over the top. I love the fact that it works, and it's easy to customise.. but i'd love it more if it were a global immortal-sets-the-colours thing.

Any earlier releases, or ideas to remedy the individual colour schemes?
Top

Posted by Marowi   (65 posts)  Bio
Date Reply #6 on Sun 21 Mar 2004 05:36 PM (UTC)
Message
Ok, had another idea. Suppose I install the same snippet, but set the required level for the command to 105 (65 for smaug). Users wouldn't be able to change the colour. Could I then alter the code so I can change it to save to a colors.dat file or something - so it doesn't save in EVERY pfile? Hmm. 3:30am. Not making much sense; i'll try again.

Using Samson's Color V3.0 snippet, could I alter it so the colours saved to a file other than every pfile. Colours would only be customisable by the immortals with the level it gets set to. Ok, that made more sense.

Please give me a hand, or seven...
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #7 on Sun 21 Mar 2004 05:54 PM (UTC)
Message
yeah, it possible. I had been discussing it with my coders, but decided to opt for a more personalize option. However, its not really THAT hard. You need to do several things: remove the saving to pfiles part, set up a system to store the info(a globally declared array would probably work, lie the skill table), create functions to both read and write the file to color.dat in your system directory, and change colorcode(I think) in the snippet to read the global variables, not the individuals. That should be all thats required.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Marowi   (65 posts)  Bio
Date Reply #8 on Mon 22 Mar 2004 08:45 AM (UTC)
Message
"not that hard".. for someone with how much experience :-P

I've coded the load_colours and save_colours functions, and they seem to be ok..

"You need to do several things: remove the saving to pfiles part, set up a system to store the info(a globally declared array would probably work, lie the skill table), create functions to both read and write the file to color.dat in your system directory, and change colorcode(I think) in the snippet to read the global variables, not the individuals."
I figured out that much myself.. just don't know where to go after the load and save colour functions.

By the individual's thing, I presume you mean 'ch->colours' - and removing the 'ch->', then declaring 'colors' as something, somewhere...
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #9 on Mon 22 Mar 2004 04:03 PM (UTC)
Message
Heh, what I was refering to was the process, not nessecarily the actual coding, but your right, its all relative to the coder. Here is what I would do: I beleive ch->color is a very simple int array, something like "int color[MAX_COLOR];" I would take this, and declare it globally(const.c, maybe?). Put an extern declaration in mud.h so it can referenced anywhere. Then, you read/write the color file into/out of this variable, and reference it there. If you've got the reading/writing part done already, your almost there, just change references in color.c to color instead of ch->color, yeah.

Hope that helps some, seems you've done a good job with it so far.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Marowi   (65 posts)  Bio
Date Reply #10 on Tue 23 Mar 2004 10:46 AM (UTC)
Message
Uhh.. 'extern int color[MAX_COLOR];' ?

Thanks for your help by the way. When I get the time, i'll see how it goes... Oh yeah, do I just declare the colors.dat file in mud.h or whatnot? Is there any command or function similar so I could cross-reference to make sure i'm on the right track?
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #11 on Tue 23 Mar 2004 02:28 PM (UTC)
Message
If you alredy have it reading/writing from color.dat then, your basically doen. I would define COLOR_FILE in mud.h with the other file declarations, yes.

The extern is simple an instruction to the compiler that when it sees a variable "color", but doesn't recognize it as a local variable, to look globally through the other files for it while linking the files.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Marowi   (65 posts)  Bio
Date Reply #12 on Sun 28 Mar 2004 08:56 AM (UTC)
Message
I have function reading and writing, and I got it to load once (..with no color, unless defined by the & token) - but I get a recurrent error message: "undefined reference to 'colors'" At the line it calls to, I have tried to read from 'colors[count]' (the colors array). I defined the colors array at the bottom of the color.h file as 'extern int colors[MAX_COLORS];' and am really lost as to what I can do. Please write back as soon as possible.
Top

Posted by Marowi   (65 posts)  Bio
Date Reply #13 on Sun 28 Mar 2004 09:44 AM (UTC)
Message
I think a 'delete' post button is needed.. ignore the last three.

Here's the ACTUAL functions (not the functions I wrote on the bus a week ago..)


void load_colors()
{
	char colorfile[MAX_STRING_LENGTH];
	FILE *color_fp;
	FILE *fp;
	int x, y;

    sprintf( colorfile, "%s%s", SYSTEM_DIR, COLOR_FILE );

    if ( ( color_fp = fopen( colorfile, "r" ) ) == NULL )
	{
		memcpy( &colors, &default_set, sizeof(default_set) );
		return;
	}
	else
		for ( x = 0; x < MAX_COLORS; x++ )
		{
			y = fread_number( fp );
			colors[x] = y;
		}
	fclose( color_fp );
	return;
}


..and the other..


void save_colors()
{
	char colorfile[MAX_STRING_LENGTH];
	FILE *color_fp;
	FILE *fp;
	int x;

    sprintf( colorfile, "%s%s", SYSTEM_DIR, COLOR_FILE );

    color_fp = fopen( colorfile, "w" );
	for ( x = 0; x < MAX_COLORS ; x++ )
		fprintf( fp, "%d ", colors[x] );
	fprintf( fp, "\n" );
	fclose( color_fp );
	return;
}


Thanks =S
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #14 on Wed 31 Mar 2004 06:16 AM (UTC)
Message
Are SYSTEM_DIR and COLOR_FILE defines? If so, you can simplify it a bit:


if ( ( color_fp = fopen( SYSTEM_DIR COLOR_FILE , "r" ) ) == NULL )


Don't need to sprintf just to concatenate two literal strings.

Anyway I am a bit worried about this code:


color_fp = fopen( colorfile, "w" );
 for ( x = 0; x < MAX_COLORS ; x++ )
  fprintf( fp, "%d ", colors[x] );
 fprintf( fp, "\n" );
 fclose( color_fp );
 return;


Apart from the fact that you don't need the "return" at the end - it will return anyway - I would check that the file can be opened. What if the disk is full? Or if you don't have write permissions?

After the fopen you should check if color_fp is NULL or not.

Then what are you doing writing to "fp" after opening "color_fp"? This bound to fail, is it not?


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


41,823 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.