colour.c
Mor/Mor/src/colour.c · 2.9 KB
From the archive Mor.zip
Download the archive « Back to the archive contents
#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include "merc.h"
#include "interp.h"
#include "recycle.h"
#include "tables.h"
void do_colour( CHAR_DATA *ch, char *argument )
{
char arg[ MAX_STRING_LENGTH ];
argument = one_argument( argument, arg );
if( !*arg )
{
if( !IS_SET( ch->act, PLR_COLOUR ) )
{
SET_BIT( ch->act, PLR_COLOUR );
send_to_char( "{bC{ro{yl{co{mu{gr{x is now {rON{x, Way Cool!\n\r", ch );
}
else
{
send_to_char_bw( "Colour is now OFF, <sigh>\n\r", ch );
REMOVE_BIT( ch->act, PLR_COLOUR );
}
return;
}
else
{
send_to_char_bw( "Colour Configuration is unavailable in this\n\r", ch );
send_to_char_bw( "version of colour, sorry\n\r", ch );
}
return;
}
int colour( char type, CHAR_DATA *ch, char *string )
{
char code[ 20 ];
char *p = '\0';
if( IS_NPC( ch ) )
return( 0 );
switch( type )
{
default:
sprintf( code, CLEAR );
break;
case 'x':
sprintf( code, CLEAR );
break;
case 'b':
sprintf( code, C_BLUE );
break;
case 'c':
sprintf( code, C_CYAN );
break;
case 'g':
sprintf( code, C_GREEN );
break;
case 'm':
sprintf( code, C_MAGENTA );
break;
case 'r':
sprintf( code, C_RED );
break;
case 'w':
sprintf( code, C_WHITE );
break;
case 'y':
sprintf( code, C_YELLOW );
break;
case 'B':
sprintf( code, C_B_BLUE );
break;
case 'C':
sprintf( code, C_B_CYAN );
break;
case 'G':
sprintf( code, C_B_GREEN );
break;
case 'M':
sprintf( code, C_B_MAGENTA );
break;
case 'R':
sprintf( code, C_B_RED );
break;
case 'W':
sprintf( code, C_B_WHITE );
break;
case 'Y':
sprintf( code, C_B_YELLOW );
break;
case 'D':
sprintf( code, C_D_GREY );
break;
case '*':
sprintf( code, "%c", 007 );
break;
case '/':
sprintf( code, "%c", 012 );
break;
case '{':
sprintf( code, "%c", '{' );
break;
}
p = code;
while( *p != '\0' )
{
*string = *p++;
*++string = '\0';
}
return( strlen( code ) );
}
void colourconv( char *buffer, const char *txt, CHAR_DATA *ch )
{
const char *point;
int skip = 0;
if( ch->desc && txt )
{
if( IS_SET( ch->act, PLR_COLOUR ) )
{
for( point = txt ; *point ; point++ )
{
if( *point == '{' )
{
point++;
skip = colour( *point, ch, buffer );
while( skip-- > 0 )
++buffer;
continue;
}
*buffer = *point;
*++buffer = '\0';
}
*buffer = '\0';
}
else
{
for( point = txt ; *point ; point++ )
{
if( *point == '{' )
{
point++;
continue;
}
*buffer = *point;
*++buffer = '\0';
}
*buffer = '\0';
}
}
return;
}