Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
Bug in do_drag( )
Oct 8, 2017, 12:40 am
By GatewaySysop
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Beastmaster 6D sound files
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Google, Bing, Yahoo!

Members: 0
Guests: 11
Stats
Files
Topics
Posts
Members
Newest Member
476
3,704
19,231
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » [BUG] do_setclass
Forum Rules | Mark all | Recent Posts

[BUG] do_setclass
< Newer Topic :: Older Topic > Does not update class.lst on rename

Pages:<< prev 1 next >>
Post is unread #1 Dec 28, 2002, 4:01 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

In a similar vein to the do_setrace fix posted in the Chronicles section, do_setclass also does not update the class.lst file properly if you change the name of a class. To this end, I'm posting a revamp of do_setclass similar to the one done for do_setrace. Since this affects AFKMud as well, I can't be 100% sure I've reverted this fix properly for stock, it's based on what I found in a stock 1.4 with some bugfixed already applied. If it doesn't work, fix it :P

/*
 * Edit class information    	-Thoric
 */
void do_setclass( CHAR_DATA *ch, char *argument )
{
   char arg1[MIL], arg2[MIL];
   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 guild thac0 thac32\n\r",     ch );
      send_to_char( "  hpmin hpmax mana expbase mtitle ftitle\n\r", ch );
      send_to_char( "  second deficient 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++;
      sprintf( classlist, "%s%s", CLASS_DIR, CLASS_LIST );
       
      if ( ( fpList = fopen( classlist, "w";) ) == NULL )
      {
         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 );
      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" ) )
   {
	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 );
      sprintf( classlist, "%s%s", CLASS_DIR, CLASS_LIST );
       
      if ( ( fpList = fopen( classlist, "w";) ) == NULL )
      {
         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 );
	return;
   }

   if ( !str_cmp( arg2, "second" ) )
   {
      int x = get_atype( argument );
             
      if ( x < APPLY_STR || (x > APPLY_CON && x != APPLY_LCK) )
         send_to_char( "Invalid second attribute!\n\r", ch );
      else   
      {
         class->attr_second = x;
         send_to_char( "Second attribute set.\n\r", ch );
    write_class_file( cl );
      }
      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, "deficient" ) )
   {
      int x = get_atype( argument );
        
      if ( x < APPLY_STR || (x > APPLY_CON && x != APPLY_LCK) )
         send_to_char( "Invalid deficient attribute!\n\r", ch );
      else
      {
         class->attr_deficient = x;
         send_to_char( "Defficient attribute set.\n\r", ch );
    write_class_file( cl );
      }
      return;
   }

   if ( !str_cmp( arg2, "thac0" ) )
   {
      class->thac0_00 = atoi( argument );
      send_to_char( "thac0 set.\n\r", ch );
	write_class_file( cl );
      return;
   }
   if ( !str_cmp( arg2, "thac32" ) )
   {
      class->thac0_32 = atoi( argument );
      send_to_char( "thac32 set.\n\r", ch );
	write_class_file( cl );
      return;
   }

   if ( !str_cmp( arg2, "guild" ) )
   {
      class->guild = atoi( argument );
      send_to_char( "Class guild 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, "expbase" ) )
   {  
      class->exp_base = atoi( argument );
      send_to_char( "Expbase set.\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;
	}
	DISPOSE( title_table[cl][x][SEX_MALE] );
	title_table[cl][x][SEX_MALE] = str_dup( argument );
	send_to_char( "Done.\n\r", ch );
	write_class_file( cl );
	return;
   }
   if ( !str_cmp( arg2, "ftitle" ) )
   {
	char arg3[MAX_INPUT_LENGTH];
  char 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;
	}
  DISPOSE( title_table[cl][x][SEX_FEMALE] );
  /* Bug fix below -Shaddai*/
  title_table[cl][x][SEX_FEMALE] = str_dup( argument );
	send_to_char( "Done\n\r", ch );
	write_class_file( cl );
	return;
   }
   do_setclass( ch, "" );
}




<!--EDIT|Samson|Dec 29 2002, 08:30 PM-->
       
Pages:<< prev 1 next >>