/*
NOTICE: This color hack was done using Lope's Color V 1.2
and certain parts of the Color Greeting Snippet. However,
I have hacked it up as I was fed up with players being
asked if they wanted color. So this will allow everything
to be in color including the greetings.
*/
/*
In comm.c, I am using copyover and some other functions so
I will past all of the code. You only need to compare with
yours and add the new code that is defined with a Plus.. EG +
*/
// FIND THIS BLOCK IN COMM.C
#if defined(macintosh) || defined(MSDOS)
void game_loop_mac_msdos( void )
{
struct timeval last_time;
struct timeval now_time;
static DESCRIPTOR_DATA dcon;
gettimeofday( &last_time, NULL );
current_time = (time_t) last_time.tv_sec;
/*
* New_descriptor analogue.
*/
dcon.descriptor = 0;
+ dcon.ansi = TRUE;
dcon.connected = CON_GET_NAME;
dcon.host = str_dup( "localhost" );
dcon.outsize = 2000;
dcon.outbuf = alloc_mem( dcon.outsize );
dcon.next = descriptor_list;
dcon.showstr_head = NULL;
dcon.showstr_point = NULL;
dcon.pEdit = NULL; /* OLC */
dcon.pString = NULL; /* OLC */
dcon.editor = 0; /* OLC */
descriptor_list = &dcon;
+ d->ansi = TRUE;
+ if (ch->desc->ansi)
+ SET_BIT(ch->act, PLR_COLOUR);
// FURTHER DOWN IN COMM.C
/*
* Cons a new descriptor.
*/
dnew = new_descriptor(); /* new_descriptor now also allocates things */
dnew->descriptor = desc;
+ dnew->ansi = TRUE;
dnew->pEdit = NULL; /* OLC */
dnew->pString = NULL; /* OLC */
dnew->editor = 0; /* OLC */
dnew->outbuf = alloc_mem( dnew->outsize );
// JUST BELOW THE CODE ABOVE
/*
* Init descriptor data.
*/
dnew->next = descriptor_list;
descriptor_list = dnew;
/*
* Send the greeting.
*/
{
extern char * help_greeting;
if ( help_greeting[0] == '.' )
+ send_to_desc( help_greeting+1, dnew );
else
+ send_to_desc( help_greeting , dnew );
}
return;
}
#endif
// IN THE VOID NANNY FUNCTION
/*
* Deal with sockets that haven't logged in yet.
*/
void nanny( DESCRIPTOR_DATA *d, char *argument )
{
DESCRIPTOR_DATA *d_old, *d_next;
char buf[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *ch;
char *pwdnew;
char *p;
int iClass,race,i;
bool fOld;
/* Delete leading spaces UNLESS character is writing a note */
if (d->connected != CON_NOTE_TEXT)
{
while ( isspace(*argument) )
argument++;
}
ch = d->character;
+ d->ansi = TRUE;
// RIGHT BELOW THAT CODE ABOVE IN THE CHECK FOR BAN NEWBIES, QUICK HACK..
if (check_ban(d->host,BAN_NEWBIES))
{
write_to_buffer(d,
"New players are not allowed from your site.\n\r",0);
close_socket(d);
return;
}
+ SET_BIT(ch->act, PLR_COLOUR);
sprintf( buf, "Did I get that right, %s (Y/N)? ", argument );
write_to_buffer( d, buf, 0 );
d->connected = CON_CONFIRM_NEW_NAME;
return;
// MERC.H
/*
In merc.h descriptor data, add
*/
/*
* Descriptor (channel) structure.
*/
struct descriptor_data
.......
int outsize;
int outtop;
char * showstr_head;
char * showstr_point;
+ bool ansi;
/*
In merc.h right below send_to_char, add void send_to_desc
*/
/* comm.c */
void send_to_char args( ( const char *txt, CHAR_DATA *ch ) );
+ void send_to_desc args( ( const char *txt, DESCRIPTOR_DATA *d ) );
// COMM.C
/*
comm.c... Paste the following code below send_to_char
*/
void send_to_desc( const char *txt, DESCRIPTOR_DATA *d )
{
const char *point;
char *point2;
char buf[ MAX_STRING_LENGTH*4 ];
int skip = 0;
buf[0] = '\0';
point2 = buf;
if( txt && d )
{
if( d->ansi == TRUE )
{
for( point = txt ; *point ; point++ )
{
if( *point == '{' )
{
point++;
skip = colour( *point, NULL, point2 );
while( skip-- > 0 )
++point2;
continue;
}
*point2 = *point;
*++point2 = '\0';
}
*point2 = '\0';
write_to_buffer( d, buf, point2 - buf );
}
else
{
for( point = txt ; *point ; point++ )
{
if( *point == '{' )
{
point++;
continue;
}
*point2 = *point;
*++point2 = '\0';
}
*point2 = '\0';
write_to_buffer( d, buf, point2 - buf );
}
}
return;
}
/*
Now, to show color for things such as "Select a race... in comm.c
You'll need to change the write_to_buffer to send_to_desc.
*/
// EG:
write_to_buffer(d,"What is your race?",0);
// Change to
send_to_desc( "What is your race?",d);
// In some cases where a question is asked using a sprintf with a write to
// buffer below, you will probably need to change those to show color.
// EG: send_to_desc( buf, d );
sprintf( buf, "Did I get that right, %s (Y/N)? ", argument );
write_to_buffer( d, buf, 0 );
// Change to:
sprintf( buf, "Did I get that right, %s (Y/N)? ", argument );
send_to_desc( buf, d );
// You should get the idea.. Email cbunting99@gmail.com with your
// comments or ideas.