This one has me stumped

Posted by Jach on Sun 12 Oct 2003 06:12 AM — 15 posts, 39,332 views.

USA #0
While working on creating an area tonight I was surprised to see that my compass was displaying diagonal closed exits incorrectly. This was a simple fix, however any direction NW closed exit displays in the wrong color.

Everything in code looks fine (considering it's all the same as the other exits) and ONLY the NW exits do this. Any ideas?

Jach
USA #1
Most likely, since its the first direction to be displayed, a color is bleeding into it. The last color must be doing it, so try adding a "&w" or something before the NW exit.
USA #2
That's what I thought also, and that is exactly what I did. But it didn't work. See why I'm stumped?
USA #3
Post the first part of the compass, where it displays NW, or an exit. Have you tried set_char_color( AT_WHITE, ch ); or something like that?
USA #4
Here is where we set the colors all around:


 exitcolor = "&Y";
	if( IS_SET( pexit->exit_info, EX_WINDOW ) )
	   exitcolor = "&C";
	if( IS_SET( pexit->exit_info, EX_SECRET ) )
	   exitcolor = "&b";
	if( IS_SET( pexit->exit_info, EX_CLOSED ) )
	   exitcolor = "&w";
	if( IS_SET( pexit->exit_info, EX_LOCKED ) )
	   exitcolor = "&w";


Here is the NW direction specifically:


if( pexit->vdir == DIR_NORTHWEST )
	if( !IS_SET( pexit->exit_info, EX_CLOSED ) )
		sprintf( dir_nw, "%sNW", exitcolor );
	else if( IS_SET( pexit->exit_info, EX_CLOSED ) )
		sprintf( dir_nw, "%s# ", exitcolor );
	else if( !IS_SET( pexit->exit_info, EX_LOCKED ) )
		sprintf( dir_nw, "%sNW", exitcolor );
	else if( IS_SET( pexit->exit_info, EX_LOCKED ) )
		sprintf( dir_nw, "%s# ", exitcolor );


As I said I tried adding the color code to the closed/locked display but it still didn't work.
Amended on Sun 12 Oct 2003 10:38 PM by Jach
USA #5
Try changing

sprintf( dir_nw, "%sNW", exitcolor );

to

sprintf( dir_nw, "&wNW" );


By doing this, we can narrow down whats causing the problem.
Amended on Mon 13 Oct 2003 04:45 AM by Zeno
USA #6
Just tried that and it didn't work either. Keep 'em coming though, this is gonna bug me til it's fixed.
USA #7
Can you post an exit that you know works, just for comparison's sake?

You say the exit is displaying in the wrong color; which color is that exactly and which should it be in?
USA #8
If it will help here it goes:

exitcolor = "&Y";
	if( IS_SET( pexit->exit_info, EX_WINDOW ) )
	   exitcolor = "&C";
	if( IS_SET( pexit->exit_info, EX_SECRET ) )
	   exitcolor = "&b";
	if( IS_SET( pexit->exit_info, EX_CLOSED ) )
	   exitcolor = "&w";
	if( IS_SET( pexit->exit_info, EX_LOCKED ) )
	   exitcolor = "&w";

Default color is "&Y" or Bright Yellow, but when the exit is closed/locked it should be "&w" or default grey. However the NW exit, and only the NW exit, stays Bright Yellow. (Yes the room name is Bright Yellow also, but as covered in the earlier post it's not just a bleed over issue)

Here is the NW exit code again:

if( pexit->vdir == DIR_NORTHWEST )
	if( !IS_SET( pexit->exit_info, EX_CLOSED ) )
		sprintf( dir_nw, "%sNW", exitcolor );
	else if( IS_SET( pexit->exit_info, EX_CLOSED ) )
		sprintf( dir_nw, "%s# ", exitcolor );
	else if( !IS_SET( pexit->exit_info, EX_LOCKED ) )
		sprintf( dir_nw, "%sNW", exitcolor );
	else if( IS_SET( pexit->exit_info, EX_LOCKED ) )
		sprintf( dir_nw, "%s# ", exitcolor );


Here is the SW exit code for comparison:

if( pexit->vdir == DIR_SOUTHWEST )
	if( !IS_SET( pexit->exit_info, EX_CLOSED ) )
		sprintf( dir_sw, "%sSW", exitcolor );
	else if( IS_SET( pexit->exit_info, EX_CLOSED ) )
		sprintf( dir_sw, "%s# ", exitcolor );
	else if( !IS_SET( pexit->exit_info, EX_LOCKED ) )
		sprintf( dir_sw, "%sSW", exitcolor );
	else if( IS_SET( pexit->exit_info, EX_LOCKED ) )
		sprintf( dir_sw, "%s# ", exitcolor );


As you can see the only change to the code is the change of direction name.
USA #9
Hrm... odd. How about the code that actually prints out the dir_nw, dir_sw and stuff? (instead of printing into the strings, actually sending it to the user.)
USA #10
Here it is:

if( xIS_SET( ch->act, PLR_COMPASS ) )
	{
	   send_to_char( "\n\r", ch );

	   set_char_color( AT_RMNAME, ch );
	   ch_printf( ch, "%-50s", ch->in_room->name );
 
	   strcat( dir_nw, "  " );
	   ch_printf_color( ch, "         %s", dir_nw );
	   strcat( dir_n, "  " );
	   ch_printf_color( ch, "  %s", dir_n );

I tried adding the color code to this also but it still didn't work.
USA #11
Try sticking a set_char_color (AT_PLAIN, ch) between printing the room name and printing the northwest. Or try printing north before northwest. I don't think we can quite rule out the color bleeding, even if it seems highly unlikely.
USA #12
That worked, for the most part. When I did that the NW displayed fine but it screwed up the N display, when I fixed that the NE display was wrong, and so on and so forth. I just carried the set_char_color to each direction and it's working fine now.

Thanks a bunch.
USA #13
Sounds like it's the funky-evil-color-bleed-of-doom that SMAUG has.

If you look at the routines for set_char_color, and the one that generates ANSI color codes based on the &w etc. tokens, they're not quite the same. One resets the terminal display settings before outputting the color... I think that's set_char_color. The other (make_color_sequence? or something like that) just spits out the display change codes without resetting them... and this can lead to very evil and insiduous color bleeds (such as bold colors going from one line to the next.)

I've found that there are two solutions:
1) fix the two routines
2) use set_char_color(AT_PLAIN) to reset at the beginning of every colored line
...and 2 is usually easier, if messier. :)
USA #14
Hehe, funky-evil-color-bleed-of-doom, is that an official term? Thanks again, I'll make sure I keep an eye out for this happening elsewhere.