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 ➜ SMAUG coding ➜ Character Creation Help

Character Creation Help

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


Posted by Palatis   (7 posts)  Bio
Date Tue 22 Aug 2006 06:21 PM (UTC)
Message
Well, i'm trying to change the way a character is created. Main thing right now is trying to add color. In some area's color works. But other areas color just doesn't seem to work. Here's one area where it doesn't work:


if( d->newstate == 0 )
{

/* No such player */
send_to_desc_color( "\n\r&RNo such player exists. Please check your spelling.\n\r", d );
send_to_desc_color( "\n\r&WEnter your character's name, or type new:", d );
d->connected = CON_GET_NAME;
d->character->desc = NULL;
free_char( d->character ); /* Big Memory Leak before --Shaddai */
d->character = NULL;
return;
}
sprintf( buf, "\n\r&zDid I get that right&R %s, &z(&RYes&z/&RNo&z) ? ", argument );
send_to_desc_color( buf, d);
d->connected = CON_CONFIRM_NEW_NAME;
return;
}
break;


I've changed sprintf to send_to_desc_color, and it still doesn't work. I'm not too sure. Altho, color does work in other functions like:

send_to_desc_color( "\n\r&zChoosing a name is one of the most important parts of this game..."
"\n\rMake sure to pick a name appropriate to the character you are going"
"\n\rto role play, and be sure that it suits a &RWARCRAFT Theme&z. If the name"
"\n\ryou select is not acceptable, you will be asked to choose another one."
"\n\r\n\rPlease choose a &RName&z for your character&W:&w\n\r", d);

There is also alot of areas including -- The game is wizlocked -- where color does not work also.

I'm using SMAUGFUSS 1.7.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Tue 22 Aug 2006 06:41 PM (UTC)
Message
Chances are that the descriptor is not being given the ANSI color flag until either the player is successfully loaded, or when a new character is created. Look for where the ANSI flag is set, and then just do the same as soon as a new connection is made.

(Of course, this might be dangerous, because if somebody connects without ANSI color support, they'll get all kinds of junk in their output. Then again, there are probably very, very few clients without ANSI color support, so maybe this isn't really something to worry about.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Palatis   (7 posts)  Bio
Date Reply #2 on Tue 22 Aug 2006 06:47 PM (UTC)
Message
Well>< I mean I said it works in other parts of the code, just not when it asks

Did I get that right, XXX, (Y|N)

Still -- How would i go about doing this?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #3 on Tue 22 Aug 2006 07:19 PM (UTC)
Message
The functions that send data over the connection strip out color codes unless the descriptor structure has the ANSI color flag set. I don't have the code handy so I can't say exactly where that normally is; but, you can look through mud.h for the flag, and then search the .c files for it (using e.g. grep). Then, if you want to force color on all the time, find the place where a descriptor is created, and set the flag there.

Sorry that I can't be more specific at the moment, as I said I don't currently have the code handy.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Palatis   (7 posts)  Bio
Date Reply #4 on Tue 22 Aug 2006 07:22 PM (UTC)
Message
Erm>< Do you know what would be the flag -- sort of new :P
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #5 on Tue 22 Aug 2006 08:51 PM (UTC)
Message
In mud.h you will find flags for the descriptors; one of them will probably have ANSI in it. If you do a text search for ANSI you will probably find the flag. If I remember correctly, it will be near a flag with 'RIP' in the name. Again, sorry for not being more specific, since I don't have the source code at hand.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #6 on Tue 22 Aug 2006 10:17 PM (UTC)
Message
Or you could just force hard coded ANSI colors.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #7 on Tue 22 Aug 2006 10:17 PM (UTC)

Amended on Tue 22 Aug 2006 10:21 PM (UTC) by Nick Gammon

Message
You need to edit save.c around line 663 in stock SMAUGfuss, inside the function load_char_obj, which is used to create a new character structure.

A little way down it sets default flags for the newly-created character, you need to add PLR_ANSI to the list, in other words, change:


   ch->act = multimeb( PLR_BLANK, PLR_COMBINE, PLR_PROMPT, -1 );


to:


   ch->act = multimeb( PLR_BLANK, PLR_COMBINE, PLR_PROMPT, PLR_ANSI, -1 );

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #8 on Tue 22 Aug 2006 10:20 PM (UTC)
Message
Also, in comm.c, function nanny (around line 2284) you need to change the sense of the changes if they say the don't want ANSI, as you have already set the bit by default. I would make it like this:



      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':
                xREMOVE_BIT(ch->act, PLR_ANSI);
               break;
            default:
               write_to_buffer( d, "Invalid selection.\r\nRIP, ANSI or NONE? ", 0 );
               return;
         }


New line in bold.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #9 on Tue 22 Aug 2006 10:25 PM (UTC)
Message
I used gdb to work this out, see my post on this:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=3653

I put a breakpoint on the send_to_desc_color function, then colorize, then colorcode, which is the actual function which works out whether to do the colour coding or not.

There is a series of tests in colorcode to work out whether to show the ANSI codes, I was interested to see which one failed.

- Nick Gammon

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

Posted by Palatis   (7 posts)  Bio
Date Reply #10 on Wed 23 Aug 2006 02:09 AM (UTC)
Message
Thanks everyone for trying to help -- Big thanks to you nick:P It works now.

<333 :P
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.


29,172 views.

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.