Enhancement: Color code allows the creation of an alternate default
Purpose: To allow people to specify a default other than what's been hardcoded
Provided by: Samson
Applies to: SmaugFUSS, SWRFUSS, SWFOTEFUSS
---
color.c
Locate the reset_colors function, and replace it with:
/*
* If the color directory has a file named "default" this will be used if possible.
* The fallback will go to the hardcoded table in color.h if the "default" file is not available.
*/
void reset_colors( CHAR_DATA * ch )
{
FILE *fp;
int max_colors = 0;
char filename[256];
snprintf( filename, 256, "%s%s", COLOR_DIR, "default" );
if( !( fp = fopen( filename, "r" ) ) )
{
memcpy( &ch->colors, &default_set, sizeof( default_set ) );
return;
}
while( !feof( fp ) )
{
char *word = fread_word( fp );
if( !str_cmp( word, "MaxColors" ) )
{
max_colors = fread_number( fp );
continue;
}
if( !str_cmp( word, "Colors" ) )
{
int x;
for( x = 0; x < max_colors; ++x )
ch->colors[x] = fread_number( fp );
continue;
}
if( !str_cmp( word, "End" ) )
{
fclose( fp );
fp = NULL;
return;
}
}
fclose( fp );
fp = NULL;
return;
}
When this enhancement is applied, immortals on the mud can then setup a color theme they like with all the defaults they want. Using the "color savetheme" option and specifying a file named "default" this will cause reset_colors to use the information in that file to do the initial color setup for new players, and for when someone does a color reset. If this file is not available or is unreadable for some reason, the code will fall back on the hardcoded table in the color.h file.