[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  Running the server
. . -> [Subject]  ANSI bleeding

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: ANSI bleeding
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  

Posted by Marowi   (61 posts)  [Biography] bio
Date Fri 02 Apr 2004 05:40 AM (UTC)  quote  ]
Message
Alright. I got some sleep and some sense and finished it. Sorry for wasting your forum space and time.

Thanks,
Marowi
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Wed 31 Mar 2004 06:16 AM (UTC)  quote  ]
Message
Quote:

I think a 'delete' post button is needed.. ignore the last three.


If you log onto the forum when posting, there is indeed a "delete" link on every post that you make.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Wed 31 Mar 2004 06:16 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Marowi   (61 posts)  [Biography] bio
Date Sun 28 Mar 2004 09:44 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Marowi   (61 posts)  [Biography] bio
Date Sun 28 Mar 2004 08:56 AM (UTC)  quote  ]
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.
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Tue 23 Mar 2004 02:28 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Marowi   (61 posts)  [Biography] bio
Date Tue 23 Mar 2004 10:46 AM (UTC)  quote  ]
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?
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Mon 22 Mar 2004 04:03 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Marowi   (61 posts)  [Biography] bio
Date Mon 22 Mar 2004 08:45 AM (UTC)  quote  ]
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...
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Sun 21 Mar 2004 05:54 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Marowi   (61 posts)  [Biography] bio
Date Sun 21 Mar 2004 05:36 PM (UTC)  quote  ]
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...
[Go to top] top

Posted by Marowi   (61 posts)  [Biography] bio
Date Sun 21 Mar 2004 04:21 PM (UTC)  quote  ]
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?
[Go to top] top

Posted by Meerclar   USA  (554 posts)  [Biography] bio
Date Wed 10 Mar 2004 08:29 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Wed 10 Mar 2004 04:12 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Marowi   (61 posts)  [Biography] bio
Date Wed 10 Mar 2004 03:24 AM (UTC)  quote  ]
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?
[Go to top] 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.


3,408 views.

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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]