Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Majestic-12, Google

Members: 0
Guests: 6
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SmaugFUSS Bugfix List » [Bug] setclass command does n...
Forum Rules | Mark all | Recent Posts

[Bug] setclass command does not update class.lst when a class is renamed
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Mar 5, 2005, 4:04 pm   Last edited May 11, 2005, 6:51 pm by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Bug: setclass command does not update class.lst when a class is renamed.
Danger: High
Found by: ?
Fixed by: Samson

NOTE: This fix was updated on January 14, 2004 to correct for uncaught MSL/MIL usage.

act_wiz.c, find do_setclass and replace with the following:

/*
 * Edit class information    	-Thoric
 */
void do_setclass( CHAR_DATA *ch, char *argument )
{
   char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
   FILE *fpList;
   char classlist[256];
   struct class_type *class;
   int cl, value, i;

   set_char_color( AT_PLAIN, ch );

   smash_tilde( argument );
   argument = one_argument( argument, arg1 );
   argument = one_argument( argument, arg2 );
   if ( arg1[0] == '\0' )
   {
	send_to_char( "Syntax: setclass <class> <field> <value>\n\r",	ch );
  send_to_char( "Syntax: setclass <class> create\n\r",  ch );
	send_to_char( "\n\rField being one of:\n\r",  	ch );
	send_to_char( "  name prime weapon armor legwear headwear\n\r", ch );
      send_to_char( "  armwear footwear shield held basethac0 thac0gain\n\r",	ch );
	send_to_char( "  hpmin hpmax mana mtitle ftitle\n\r", ch );
  send_to_char( "  affected resist suscept skill\n\r", ch );
	return;
   }
   if( is_number(arg1) && ( cl = atoi( arg1 ) ) >= 0 && cl < MAX_CLASS )
	class = class_table[cl];
   else
   {
	class = NULL;
	for ( cl = 0; cl < MAX_CLASS && class_table[cl]; cl++ )
  {
     if ( !class_table[cl]->who_name )
  continue;
    if ( !str_cmp( class_table[cl]->who_name, arg1 ) )
    {
  class = class_table[cl];
  break;
    }
	}
   }
   if ( !str_cmp( arg2, "create" ) && class )
   {
      send_to_char( "That class already exists!\n\r", ch );
  return;
   }

   if ( !class && str_cmp( arg2, "create" ) )
   {
	send_to_char( "No such class.\n\r", ch );
	return;
   }

   if ( !str_cmp( arg2, "create" ) )
   {
      if ( MAX_PC_CLASS >= MAX_CLASS )
      {
        send_to_char("You need to up MAX_CLASS in mud and make clean.\n\r",ch);
    return;
      }
      if( ( create_new_class( MAX_PC_CLASS, arg1 ) ) == FALSE )
      {
        send_to_char( "Couldn't create a new class.\n\r", ch );
    return;
      }
      write_class_file( MAX_PC_CLASS );
      MAX_PC_CLASS++;
      snprintf( classlist, 256, "%s%s", CLASS_DIR, CLASS_LIST );
       
      if( !( fpList = fopen( classlist, "w" ) ) )
      {
         bug( "%s", "Can't open class list for writing." );
     return;
      }

      for ( i = 0; i < MAX_PC_CLASS; i++ )
     fprintf( fpList, "%s%s.class\n", CLASSDIR, class_table[i]->who_name );
      
      fprintf( fpList, "%s", "$\n" );
      fclose( fpList );
      fpList = NULL;
      send_to_char( "Done.\n\r", ch );
      return;
   }

   if ( !argument )
   {
      send_to_char( "You must specify an argument.\n\r", ch );
  return;
   }

   if ( !str_cmp( arg2, "skill" ) )
   {
      SKILLTYPE *skill;
      int sn, level, adept;

      argument = one_argument( argument, arg2 );
      if( ( sn = skill_lookup( arg2 ) ) > 0 )
      {
         skill = get_skilltype( sn );
         argument = one_argument( argument, arg2 );
         level = atoi( arg2 );
         argument = one_argument( argument, arg2 );
         adept = atoi( arg2 );
         skill->skill_level[cl] = level;
         skill->skill_adept[cl] = adept;
         write_class_file( cl );
         ch_printf( ch, "Skill \"%s\" added at level %d and %d%%.\n\r", skill->name, level, adept );
      }
      else
         ch_printf( ch, "No such skill as %s.\n\r", arg2 );
      return;
   }

   if ( !str_cmp( arg2, "name" ) )
   {
      char buf[256];

	snprintf( buf, 256, "%s%s.class", CLASSDIR, class->who_name );
	STRFREE( class->who_name );
	class->who_name = STRALLOC( capitalize( argument ) );
	ch_printf( ch, "class %s renamed to %s.\n\r", arg1, argument );
      write_class_file( cl );
	unlink( buf );
      snprintf( classlist, 256, "%s%s", CLASS_DIR, CLASS_LIST );
       
      if( !( fpList = fopen( classlist, "w";) ) )
      {
         bug( "%s", "Can't open class list for writing." );
     return;
      }

      for ( i = 0; i < MAX_PC_CLASS; i++ )
     fprintf( fpList, "%s%s.class\n", CLASSDIR, class_table[i]->who_name );
      
      fprintf( fpList, "%s", "$\n" );
      fclose( fpList );
      fpList = NULL;
	return;
   }

   if ( !str_cmp( arg2, "affected" ) )
   {
      if ( !argument || argument[0] == '\0' )
      {
         send_to_char( "Usage: setclass <class> affected <flag> [flag]...\n\r", ch );
         return;
      }
      while ( argument[0] != '\0' )
      {
         argument = one_argument( argument, arg2 );
         value = get_aflag( arg2 );
         if ( value < 0 || value > MAX_BITS )
            ch_printf( ch, "Unknown flag: %s\n\r", arg2 );
         else
            xTOGGLE_BIT( class->affected, value );
      }
      send_to_char( "Done.\n\r", ch );
	write_class_file( cl );
      return;
   }
 
   if ( !str_cmp( arg2, "resist" ) )
   {
      if ( !argument || argument[0] == '\0' )
      {
         send_to_char( "Usage: setclass <class> resist <flag> [flag]...\n\r", ch);
         return;
      }
      while ( argument[0] != '\0' )
      {
         argument = one_argument( argument, arg2 );
         value = get_risflag( arg2 );
         if ( value < 0 || value > 31 )
            ch_printf( ch, "Unknown flag: %s\n\r", arg2 );
         else
            TOGGLE_BIT( class->resist, 1 << value );
      }
      send_to_char( "Done.\n\r", ch );
	write_class_file( cl );
      return;
   }
 
   if ( !str_cmp( arg2, "suscept" ) )
   {
      if ( !argument || argument[0] == '\0' )
      {
         send_to_char( "Usage: setclass <class> suscept <flag> [flag]...\n\r", ch );
         return;
      }
      while ( argument[0] != '\0' )
      {
         argument = one_argument( argument, arg2 );
         value = get_risflag( arg2 );
         if ( value < 0 || value > 31 )
            ch_printf( ch, "Unknown flag: %s\n\r", arg2 );
         else
            TOGGLE_BIT( class->suscept, 1 << value );
      }
      send_to_char( "Done.\n\r", ch );
	write_class_file( cl );
      return;
   }

   if ( !str_cmp( arg2, "prime" ) )
   {
	int x = get_atype( argument );

	if ( x < APPLY_STR || (x > APPLY_CON && x != APPLY_LCK) )
    send_to_char( "Invalid prime attribute!\n\r", ch );
	else
	{
    class->attr_prime = x;
    send_to_char( "Prime attribute set.\n\r", ch );
    write_class_file( cl );
	}
	return;
   }
   if ( !str_cmp( arg2, "weapon" ) )
   {
	class->weapon = atoi( argument );
	send_to_char( "Starting weapon set.\n\r", ch );
	write_class_file( cl );
	return;
   }
   if ( !str_cmp( arg2, "hpmin" ) )
   {
	class->hp_min = atoi( argument );
	send_to_char( "Min HP gain set.\n\r", ch );
	write_class_file( cl );
	return;
   }
   if ( !str_cmp( arg2, "hpmax" ) )
   {
	class->hp_max = atoi( argument );
	send_to_char( "Max HP gain set.\n\r", ch );
	write_class_file( cl );
	return;
   }
   if ( !str_cmp( arg2, "mana" ) )
   {
	if ( UPPER(argument[0]) == 'Y' )
   class->fMana = TRUE;
	else
   class->fMana = FALSE;
	send_to_char( "Mana flag toggled.\n\r", ch );
	write_class_file( cl );
	return;
   }
   if ( !str_cmp( arg2, "mtitle" ) )
   {
	char arg3[MAX_INPUT_LENGTH];
	int x;

	argument = one_argument( argument, arg3 );
	if ( arg3[0] == '\0' || argument[0] == '\0' )
	{
    send_to_char( "Syntax: setclass <class> mtitle <level> <title>\n\r", ch );
    return;
	}
	if( ( x = atoi( arg3 ) ) < 0 || x > MAX_LEVEL )
	{
    send_to_char( "Invalid level.\n\r", ch );
    return;
	}
	STRFREE( title_table[cl][x][SEX_MALE] );
	title_table[cl][x][SEX_MALE] = STRALLOC( argument );
	send_to_char( "Done.\n\r", ch );
	write_class_file( cl );
	return;
   }
   if ( !str_cmp( arg2, "ftitle" ) )
   {
	char arg3[MAX_INPUT_LENGTH], arg4[MAX_INPUT_LENGTH];
  int x;

	argument = one_argument( argument, arg3 );
  argument = one_argument( argument, arg4 );
	if ( arg3[0] == '\0' || argument[0] == '\0' )
	{
     send_to_char( "Syntax: setclass <class> ftitle <level> <title>\n\r", ch );
    return;
	}
  if( ( x = atoi( arg4 ) ) < 0 || x > MAX_LEVEL )
	{
    send_to_char( "Invalid level.\n\r", ch );
    return;
	}
  STRFREE( title_table[cl][x][SEX_FEMALE] );
  /* Bug fix below -Shaddai*/
  title_table[cl][x][SEX_FEMALE] = STRALLOC( argument );
	send_to_char( "Done\n\r", ch );
	write_class_file( cl );
	return;
   }
   do_setclass( ch, "" );
}
       
Pages:<< prev 1 next >>