Need Some help with Ansi\RIP Colors

Posted by Toy on Thu 29 Jan 2004 06:36 AM — 21 posts, 77,977 views.

#0
OK, I've been peeking around in the code and the mud, and I noticed that once a newbie logged in, if you chose either ANSI or RIP, only a blank screen would appear. Baffled, I moved my cursor over the screen, and relized that there was no color on the screen, the words being in black. SO I've tried to edit the ANS file and RIP file in the system folder with a &w before everything, and it's still all black. so I hunted down the part of the code in comm.c under the nanny function. Can someone gimme some help on how to fix this?


	set_pager_color( AT_PLAIN, ch );
	if ( xIS_SET(ch->act, PLR_RIP) )
	  send_rip_screen(ch);
	if ( xIS_SET(ch->act, PLR_ANSI) )
	  send_to_pager( "\033[2J", ch );
	else
	  send_to_pager( "\014", ch );
	if ( IS_IMMORTAL(ch) )
	  do_help( ch, "imotd" );
	if ( ch->level < 50 && ch->level > 0 )
	  do_help( ch, "motd" );
	if ( ch->level == 0 )
	  do_help( ch, "nmotd" );
	send_to_pager( "\n\rPress [ENTER] ", ch );
        d->connected = CON_READ_MOTD;
        break;


Mind you, if you hit no color support, everything works fine.

-Alexander
Amended on Sun 01 Feb 2004 03:56 AM by Nick Gammon
USA #1
This has actually been covered (and solved) fairly recently. The exact fix escapes me(I don't code SMAUG) but a forum search for "ansi color" should find the related threads. Believe it was a problem with the send_to function not having the proper support for colors and needing to be changed to another function though.
Australia Forum Administrator #2
Yes, this one might be it ...

http://www.gammon.com.au/forum/?bbsubject_id=3416
#3
Well, I looked at the post you sent me Nick. I added the lines and changed the calls, but still, all the other colors work fine, there is still two black screens though were the ANS file and the MOTD are supposed to be after you choose ansi support. All the color works after that point, so do you have any other ideas?

-Alexander
Australia Forum Administrator #4
I seem to get a colour screen - in your mudtitle.ans file (is this the one you are looking at?) do you see something like this? ...


^[[2J

              DRAW YOUR ^[[1;36mANSI^[[m TITLE SCREEN IN HERE...................


                                [Press Enter]
~

#5
No. Maybe that's the issue. A long time ago I replaced that message with one I found. mine looks more like this:
========================================================
.

(ansi picture)

blah blah blah

[PRESS ENTER]
========================================================

Is the original stuff from the ANS file necessary to have color in it?

-Alexander
Australia Forum Administrator #6
Well, no.

I tried a mudtitle.ans file with just straight text in it, and it came out fine, white on black, like everything else.

Somewhere you must be sending down a control code to switch to black on black.

What I suggest doing is set "packet debug" in MUSHclient, wait for the title screen to appear, and then look in the packets window to see what code is being sent.

Then, search for the code that sets that code.
USA #7
Are you using SmaugFUSS, or normal Smaug? I have this same problem. New char, lvl 0, mudtitle is totally black. I use SmaugFUSS.
Australia Forum Administrator #8
Well, I worked it out, but it wasn't simple. :)

The same thing happened with a fresh compile of SMAUG FUSS, so it isn't anything you did.

It was a straight bug. :)

In nanny in comm.c, in the section CON_GET_WANT_RIPANSI, around line 1986 is this code:


 ch->position = POS_STANDING;
 d->connected = CON_PRESS_ENTER;
 set_pager_color( AT_PLAIN, ch );

... and a little further on ...

 if ( IS_IMMORTAL(ch) )
   do_help( ch, "imotd" );
 if ( ch->level == 50)
   do_help( ch, "amotd" );
 if ( ch->level < 50 && ch->level > 0 )
   do_help( ch, "motd" );
 if ( ch->level == 0 )
   do_help( ch, "nmotd" );
 send_to_pager( "\n\rPress [ENTER] ", ch );



This is supposed to set the colour for the NMOTD help topic to AT_PLAIN (grey), however inside set_pager_color is:


   ch->desc->pagecolor = ch->colors[AType];


If you look at the variable "ch" at this point (in gdb) you see this:


(gdb) p *ch
$1 = {next = 0x0, prev = 0x0, next_in_room = 0x0, prev_in_room = 0x0,
  master = 0x0, leader = 0x0, fighting = 0x0, reply = 0x0, retell = 0x0,
  switched = 0x0, mount = 0x0, hunting = 0x0, fearing = 0x0, hating = 0x0,
  spec_fun = 0, mpact = 0x0, mpactnum = 0, mpscriptpos = 0, pIndexData = 0x0,
  desc = 0x8580ed0, first_affect = 0x0, last_affect = 0x0, pnote = 0x0,
  comments = 0x0, first_carrying = 0x0, last_carrying = 0x0, in_room = 0x0,
  was_in_room = 0x0, pcdata = 0x8583268, last_cmd = 0, prev_cmd = 0,
  dest_buf = 0x0, alloc_ptr = 0x0, spare_ptr = 0x0, tempnum = 0, editor = 0x0,
  first_timer = 0x0, last_timer = 0x0, morph = 0x0, name = 0x8520ac8 "myname",
  short_descr = 0x821ab18 "", long_descr = 0x821ab18 "",
  description = 0x821ab18 "", num_fighting = 0, substate = 0, sex = 1,
  class = 0, race = 0, level = 0, trust = 0, played = 0, logon = 1075606456,
  save_time = 0, timer = 0, wait = 0, hit = 20, max_hit = 20, mana = 100,
  max_mana = 100, move = 100, max_move = 100, practice = 0, numattacks = 0,
  gold = 0, exp = 0, act = {bits = {33556032, 0, 0, 0}}, affected_by = {
    bits = {0, 0, 0, 0}}, no_affected_by = {bits = {0, 0, 0, 0}},
  carry_weight = 0, carry_number = 0, xflags = 0, no_immune = 0,
  no_resistant = 0, no_susceptible = 0, immune = 0, resistant = 0,
  susceptible = 0, attacks = {bits = {0, 0, 0, 0}}, defenses = {bits = {0, 0,
      0, 0}}, speaks = 1, speaking = 1, saving_poison_death = 0,
  saving_wand = 0, saving_para_petri = 0, saving_breath = 0,
  saving_spell_staff = 0, alignment = 0, barenumdie = 1, baresizedie = 4,
  mobthac0 = 0, hitroll = 0, damroll = 0, hitplus = 0, damplus = 0,
  position = 12, defposition = 0, style = 2, height = 72, weight = 180,
  armor = 100, wimpy = 0, deaf = 0, perm_str = 13, perm_int = 13,
  perm_wis = 13, perm_dex = 13, perm_con = 13, perm_cha = 13, perm_lck = 13,
  mod_str = 0, mod_int = 0, mod_wis = 0, mod_dex = 0, mod_con = 0,
  mod_cha = 0, mod_lck = 0, mental_state = -10, emotional_state = 0,
  retran = 0, regoto = 0, mobinvis = 0, colors = {0 <repeats 96 times>}}



Important part in bold. In other words, we are sending AT_PLAIN to the player however the player's colours are not set up yet (all 96 are zero). Thus we send black-on-black as the colour for the help text.

The solution appears to be to set up the default colours when clearing the character data. I did this:


void clear_char( CHAR_DATA *ch )
{

... other stuff here ...

    reset_colors (ch);
    return;
}


That sets default colours along with other character defaults.

Then, the NMOTD screen appears properly.

Amended on Sun 01 Feb 2004 03:58 AM by Nick Gammon
Australia Forum Administrator #9
Looking a bit harder, I see this in comm.c:


  reset_colors( ch );
  name_stamp_stats( ch );
  ch->level   = 1;
  ch->exp     = 0;
  ch->max_hit    += race_table[ch->race]->hit;
  ch->max_mana   += race_table[ch->race]->mana;


However this is in CON_READ_MOTD (in nanny) *after* the message-of-the-day is sent. Right code, wrong place, IMHO.
Amended on Sun 01 Feb 2004 05:40 AM by Nick Gammon
#10
SWEET! It works now. Thanks alot for your hard working in helping me Nick. Glad to know it wasn't my error. :)

-Alexander the Happy
Australia Forum Administrator #11
Looking further, it seems to me that my earlier fix does not necessarily show the correct colours. When I did it I say the NMOTD but in green, not the full colour.

I have now tried this, in comm.c:


    case CON_GET_WANT_RIPANSI:
        switch ( argument[0] )
        {
        case 'r': case 'R':
            xSET_BIT(ch->act,PLR_RIP);
            xSET_BIT(ch->act,PLR_ANSI);
            break;
        case 'a': case 'A': xSET_BIT(ch->act,PLR_ANSI);  break;
        case 'n': case 'N': break;
        default:
            write_to_buffer( d, "Invalid selection.\n\rRIP, ANSI or NONE? ", 0 );
            return;
        }
      reset_colors( ch );


That seems to work better.
#12
OK, I just ran across another color problem. When I altered the ANS file before the word "Fear" I used &R, to make the color show red. Not only did the color not show, but when I logged in a newbie it read "&RFEAR". I know I've run into this color issue before when trying to alter things like do_score. Is there any fix to that?

-Alexander
Australia Forum Administrator #13
First, I think the mudtitle.ans file does not process the &R codes, judging by its contents you need to put the actual code in (eg. ESC[35m or whatever it is).

As for the score command, you probably need to change "send_to_char" to "send_to_char_color" in certain places. The documents in the doc directory explain that bit.
USA #14
Heh, thanks Nick, I never really attempted to try to fix that problem, since it was only for new chars.
Australia Forum Administrator #15
I know what you mean, but it is nice to give a good impression to new players.

Admittedly you tend to forget about it, as you never log on as a new player yourself.
#16
OK, one last thing. I was attempting to get color into the ANS file so I tried this based on what you said:

^[[1;31m^[[FEAR^[[1;32m^[[

This was an attempt to go from red to green, but instead that's what it showed upon log in, not the colors, just fear with all the jargon around it. What am I doing wrong here?

-Alexander
Australia Forum Administrator #17
The ^[ character you see there is really "escape" (namely hex 1B from memory). It is a bit hard to key into a text editor. You can use vi to get it in (CTRL+V and then Esc) or an editor like UltraEdit, and use Hex mode to enter the 1B.

If you literally type ^[ then you will just see that on the screen.
#18
OK, I'm slowly getting this, I think. I got UltraEdit, loaded the ANS file and altered the HEX in the right spots, now it shows this:

\e[1;31mFEAR\e1;32m

ok, the color for red is "\e[1;31m" and the color for green is "\e[1;32m". the little boxes represent the 1B I changed in the HEX. Now when you log in in shows this:

e[1;31mFEARe1;32m

I don't get it..

-Toy, formerly Alexander
Australia Forum Administrator #19
Quote:

e[1;31mFEARe1;32m


For a start, you have left off a square bracket, it should be:

e[1;31mFEARe[1;32m

However also the "e"s should be Esc, since you are seeing "e" it hasn't been entered properly, for some reason. I tried doing that exact thing using vi (type Ctrl+V Esc to enter an escape) and it worked, the word FEAR came out in red.

You can check it out in UltraEdit "hex" mode. If you have Cygwin, try hexdump, like this:

 hexdump -C ../system/mudtitle.ans
00000000  1b 5b 32 4a 0d 0a 0d 0a  0d 0a 0d 0a 20 20 20 20  |.[2J........    |
00000010  20 20 20 20 20 20 20 20  20 20 44 52 41 57 20 59  |          DRAW Y|
00000020  4f 55 52 20 1b 5b 31 3b  33 36 6d 41 4e 53 49 1b  |OUR .[1;36mANSI.|
00000030  5b 6d 20 54 49 54 4c 45  20 53 43 52 45 45 4e 20  |[m TITLE SCREEN |
00000040  49 4e 20 48 45 52 45 2e  2e 2e 2e 2e 2e 2e 2e 2e  |IN HERE.........|
00000050  2e 2e 2e 2e 2e 2e 2e 2e  2e 2e 0d 0a 0d 0a 0d 0a  |................|
00000060  0d 0a 0d 0a 1b 5b 31 3b  33 31 6d 46 45 41 52 1b  |.....[1;31mFEAR.|
00000070  5b 31 3b 33 32 6d 0d 0a  0d 0a 0d 0a 0d 0a 0d 0a  |[1;32m..........|
00000080  0d 0a 0d 0a 0d 0a 0d 0a  0d 0a 0d 0a 20 20 20 20  |............    |
00000090  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000000a0  20 20 20 20 20 20 20 20  20 20 20 20 5b 50 72 65  |            [Pre|
000000b0  73 73 20 45 6e 74 65 72  5d 20 0d 0a              |ss Enter] ..|
000000bc

Amended on Mon 02 Feb 2004 09:25 PM by Nick Gammon
#20
Cool. Got it working now. Thanks again Nick.

-Toy