colinstall.c

colinstall.c · 2.9 KB

From the archive coloursnip.ZIP

Download the archive   « Back to the archive contents

/*Allright, this is just 'cause I though lope could do
 *with some compitition! No need for a Monopoly in the
 *mudding community, might force us to split up in two!
 **groans at the bad Bill Gates joke* Yeah, dun hate me!
 *Annnnyways. Add colour.c to your Makefile and of course
 *make sure colour.c is in your source directory. Add 
 */
 
 char *colour_string args ( (const char *txt, CHAR_DATA *ch ) );
 
 /*And the colour table declaration -- These can go in tables.h if ya want. Make sure to add
  * the #include to colour.c (provided with snippet)*/

 struct colour_type
 {
	 char * code;
	 char * name;
	 char * symbol;
 };

 extern const struct colour_type colour_table[];

 /*As well, to merc.h go to the pc_data structure and add*/

 int       colour[MAX_COLOUR];

 /* Just above the pc_data structure, add */

#define MAX_COLOUR 14;
 
 /*To your main header. Open up comm.c and in write_to_buffer make it look
  *something like */

void write_to_buffer( DESCRIPTOR_DATA *d, const char *txt, int length )
{
+	const char *tmp;
	/*
     * Find length in case caller didn't.
     */
+	tmp = colour_string(txt, d->character ? d->character : d->original );
    if ( length <= 0 )
-	length = strlen(txt);
+   length = strlen(tmp);
/* In bust_a_prompt look for*/

buf[MAX_STRING_LENGTH]; /*to*/ buf[MSL*2];

/* And in bust_a_prompt right before*/

write_to_buffer( ch->desc, buf, point - buf ); 
/*add*/
*point = '\0';

/*Do the same to void act_new(). Sooo, make buf[MAX_STRING_LENGTH]; -> buf[MSL*2]; 
 *and right before buf[0] = UPPER(buf[0] );*/
*point = '\0';
 

/*I hope thats easy to read. The + means to add that line, and the - means to remove it.
 *As well, look through the rest of write_to_buffer for "txt" and if you find one change
 *it to tmp. Now you need to write the saving protocals. So open up save.c and in fwrite_char
 *Under the the section that makes sure that the player is a PC, put*/

 fprintf(fp, "Colour " );
 for( int i = 0; i < MAX_COLOUR ; i++)
	fprintf(fp, "%s~ ", get_colour_name(ch->pcdata->colour[i] ) );
 fprintf(fp, "\n" );
 
 /* Now, in load_char_obj, you can do one of two things, set a default colour for all the
  * Pc colours, or do what I did and set them all to white. For the white, add
  */

  for( int i = 0; i < MAX_COLOUR ; i++ )
	  ch->pcdata->colour[i] = str_dup(colour_table[0].code);

/* in fread_char under case 'C': */

if(!str_cmp(word, "Colour" ) )
{	for(int i = 0; i < MAX_COLOUR ; i++ )
		ch->pcdata->colour[i] = colour_table[get_colour(fread_string(fp))].code;
	fMatch = TRUE;
	break;
}

/*Ook, my server is down, so I had to write the saving/loading on the fly. It looks right :P
 *Make sure to define prototypes, they work wonders :P. Now, I know some of the stuff for comm.c
 *might be confusing, if you can't get it to work properly send me an e-mail to davionkalhen@hotmail.com
 *and I'll do my best to help you. Anyways, have fun with this!
 *
 *Davion*/

Site Stats

Snippets: 1791
Codebases: 571