Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
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
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
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yahoo!, Yandex, DotBot, Bing

Members: 0
Guests: 15
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SmaugFUSS Bugfix List » [Bug] The setrace command was...
Forum Rules | Mark all | Recent Posts

[Bug] The setrace command was the victim of a bad cut/paste
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 4, 2005, 10:06 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Bug: The setrace command was the victim of a bad cut/paste
Danger: Low - Blocks access to one of the settings
Found by: Samson
Fixed by: Samson

---

act_wiz.c

Locate the do_setrace function and replace it with:
/* Modified by Samson to allow setting language by name - 8-6-98 */
void do_setrace( CHAR_DATA * ch, char *argument )
{
   RACE_TYPE *race;
   char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH], arg3[MAX_INPUT_LENGTH];
   FILE *fpList;
   char racelist[256];
   int value, v2, ra, i;

   set_char_color( AT_PLAIN, ch );

   smash_tilde( argument );
   argument = one_argument( argument, arg1 );
   argument = one_argument( argument, arg2 );
   if( arg1[0] == '\0' || arg2[0] == '\0' )
   {
      send_to_char( "Syntax: setrace <race> <field> <value>\n\r", ch );
      send_to_char( "Syntax: setrace <race> create	     \n\r", ch );
      send_to_char( "\n\rField being one of:\n\r", ch );
      send_to_char( "  name classes strplus dexplus wisplus\n\r", ch );
      send_to_char( "  intplus conplus chaplus lckplus hit\n\r", ch );
      send_to_char( "  mana affected resist suscept language\n\r", ch );
      send_to_char( "  attack defense alignment acplus \n\r", ch );
      send_to_char( "  minalign maxalign height weight      \n\r", ch );
      send_to_char( "  hungermod thirstmod expmultiplier    \n\r", ch );
      send_to_char( "  saving_poison_death saving_wand      \n\r", ch );
      send_to_char( "  saving_para_petri saving_breath      \n\r", ch );
      send_to_char( "  saving_spell_staff race_recall       \n\r", ch );
      send_to_char( "  mana_regen hp_regen                  \n\r", ch );
      return;
   }
   if( is_number( arg1 ) && ( ra = atoi( arg1 ) ) >= 0 && ra < MAX_RACE )
      race = race_table[ra];
   else
   {
      race = NULL;
      for( ra = 0; ra < MAX_RACE && race_table[ra]; ra++ )
      {
         if( !race_table[ra]->race_name )
            continue;

         if( !str_cmp( race_table[ra]->race_name, arg1 ) )
         {
            race = race_table[ra];
            break;
         }
      }
   }

   if( !str_cmp( arg2, "create" ) && race )
   {
      send_to_char( "That race already exists!\n\r", ch );
      return;
   }
   else if( !race && str_cmp( arg2, "create" ) )
   {
      send_to_char( "No such race.\n\r", ch );
      return;
   }

   if( !str_cmp( arg2, "create" ) )
   {
      if( MAX_PC_RACE >= MAX_RACE )
      {
         send_to_char( "You need to up MAX_RACE in mud.h and make clean.\n\r", ch );
         return;
      }
      if( ( create_new_race( MAX_PC_RACE, arg1 ) ) == FALSE )
      {
         send_to_char( "Couldn't create a new race.\n\r", ch );
         return;
      }
      write_race_file( MAX_PC_RACE );
      MAX_PC_RACE++;
      snprintf( racelist, 256, "%s%s", RACEDIR, RACE_LIST );
      if( !( fpList = fopen( racelist, "w" ) ) )
      {
         bug( "%s", "Error opening racelist." );
         return;
      }
      for( i = 0; i < MAX_PC_RACE; i++ )
         fprintf( fpList, "%s%s.race\n", RACEDIR, race_table[i]->race_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, "name" ) )
   {
      char buf[256];

      snprintf( buf, 256, "%s%s.race", RACEDIR, race->race_name );
      snprintf( race->race_name, 16, "%s", capitalize( argument ) );
      write_race_file( ra );
      unlink( buf );
      snprintf( racelist, 256, "%s%s", RACEDIR, RACE_LIST );
      if( !( fpList = fopen( racelist, "w" ) ) )
      {
         bug( "%s", "Error opening racelist." );
         return;
      }
      for( i = 0; i < MAX_PC_RACE; i++ )
         fprintf( fpList, "%s%s.race\n", RACEDIR, race_table[i]->race_name );
      fprintf( fpList, "%s", "$\n" );
      fclose( fpList );
      fpList = NULL;
      send_to_char( "Race name set.\n\r", ch );
      return;
   }

   if( !str_cmp( arg2, "strplus" ) )
   {
      race->str_plus = ( short )atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "dexplus" ) )
   {
      race->dex_plus = ( short )atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "wisplus" ) )
   {
      race->wis_plus = ( short )atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "intplus" ) )
   {
      race->int_plus = ( short )atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "conplus" ) )
   {
      race->con_plus = ( short )atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "chaplus" ) )
   {
      race->cha_plus = ( short )atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "lckplus" ) )
   {
      race->lck_plus = ( short )atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "hit" ) )
   {
      race->hit = ( short )atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "mana" ) )
   {
      race->mana = ( short )atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "affected" ) )
   {
      if( !argument || argument[0] == '\0' )
      {
         send_to_char( "Usage: setrace <race> affected <flag> [flag]...\n\r", ch );
         return;
      }
      while( argument[0] != '\0' )
      {
         argument = one_argument( argument, arg3 );
         value = get_aflag( arg3 );
         if( value < 0 || value > MAX_BITS )
            ch_printf( ch, "Unknown flag: %s\n\r", arg3 );
         else
            xTOGGLE_BIT( race->affected, value );
      }
      write_race_file( ra );
      send_to_char( "Racial affects set.\n\r", ch );
      return;
   }

   if( !str_cmp( arg2, "resist" ) )
   {
      if( !argument || argument[0] == '\0' )
      {
         send_to_char( "Usage: setrace <race> resist <flag> [flag]...\n\r", ch );
         return;
      }
      while( argument[0] != '\0' )
      {
         argument = one_argument( argument, arg3 );
         value = get_risflag( arg3 );
         if( value < 0 || value > 31 )
            ch_printf( ch, "Unknown flag: %s\n\r", arg3 );
         else
            TOGGLE_BIT( race->resist, 1 << value );
      }
      write_race_file( ra );
      send_to_char( "Racial resistances set.\n\r", ch );
      return;
   }

   if( !str_cmp( arg2, "suscept" ) )
   {
      if( !argument || argument[0] == '\0' )
      {
         send_to_char( "Usage: setrace <race> suscept <flag> [flag]...\n\r", ch );
         return;
      }
      while( argument[0] != '\0' )
      {
         argument = one_argument( argument, arg3 );
         value = get_risflag( arg3 );
         if( value < 0 || value > 31 )
            ch_printf( ch, "Unknown flag: %s\n\r", arg3 );
         else
            TOGGLE_BIT( race->suscept, 1 << value );
      }
      write_race_file( ra );
      send_to_char( "Racial susceptabilities set.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "language" ) )
   {
      argument = one_argument( argument, arg3 );
      value = get_langflag( arg3 );
      if( value == LANG_UNKNOWN )
         ch_printf( ch, "Unknown language: %s\n\r", arg3 );
      else
      {
         if( !( value &= VALID_LANGS ) )
            ch_printf( ch, "Player races may not speak %s.\n\r", arg3 );
      }

      v2 = get_langnum( arg3 );
      if( v2 == -1 )
         ch_printf( ch, "Unknown language: %s\n\r", arg3 );
      else
         TOGGLE_BIT( race->language, 1 << v2 );

      write_race_file( ra );
      send_to_char( "Racial language set.\n\r", ch );
      return;
   }

   if( !str_cmp( arg2, "classes" ) )
   {
      for( i = 0; i < MAX_CLASS; i++ )
      {
         if( !str_cmp( argument, class_table[i]->who_name ) )
         {
            TOGGLE_BIT( race->class_restriction, 1 << i );  /* k, that's boggling */
            write_race_file( ra );
            send_to_char( "classes set.\n\r", ch );
            return;
         }
      }
      send_to_char( "No such class.\n\r", ch );
      return;
   }

   if( !str_cmp( arg2, "acplus" ) )
   {
      race->ac_plus = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }

   if( !str_cmp( arg2, "alignment" ) )
   {
      race->alignment = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }

   /*
    * not implemented 
    */
   if( !str_cmp( arg2, "defense" ) )
   {
      if( !argument || argument[0] == '\0' )
      {
         send_to_char( "Usage: setrace <race> defense <flag> [flag]...\n\r", ch );
         return;
      }
      while( argument[0] != '\0' )
      {
         argument = one_argument( argument, arg3 );
         value = get_defenseflag( arg3 );
         if( value < 0 || value > MAX_BITS )
            ch_printf( ch, "Unknown flag: %s\n\r", arg3 );
         else
            xTOGGLE_BIT( race->defenses, value );
      }
      write_race_file( ra );
      return;
   }

   /*
    * not implemented 
    */
   if( !str_cmp( arg2, "attack" ) )
   {
      if( !argument || argument[0] == '\0' )
      {
         send_to_char( "Usage: setrace <race> attack <flag> [flag]...\n\r", ch );
         return;
      }
      while( argument[0] != '\0' )
      {
         argument = one_argument( argument, arg3 );
         value = get_attackflag( arg3 );
         if( value < 0 || value > MAX_BITS )
            ch_printf( ch, "Unknown flag: %s\n\r", arg3 );
         else
            xTOGGLE_BIT( race->attacks, value );
      }
      write_race_file( ra );
      return;
   }

   if( !str_cmp( arg2, "minalign" ) )
   {
      race->minalign = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "maxalign" ) )
   {
      race->maxalign = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "height" ) )
   {
      race->height = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "weight" ) )
   {
      race->weight = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "thirstmod" ) )
   {
      race->thirst_mod = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "hungermod" ) )
   {
      race->hunger_mod = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "expmultiplier" ) )
   {
      race->exp_multiplier = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "saving_poison_death" ) )
   {
      race->saving_poison_death = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "saving_wand" ) )
   {
      race->saving_wand = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "saving_para_petri" ) )
   {
      race->saving_para_petri = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "saving_breath" ) )
   {
      race->saving_breath = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "saving_spell_staff" ) )
   {
      race->saving_spell_staff = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   /*
    * unimplemented stuff follows 
    */
   if( !str_cmp( arg2, "mana_regen" ) )
   {
      race->mana_regen = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "hp_regen" ) )
   {
      race->hp_regen = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "race_recall" ) )
   {
      race->race_recall = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
#ifdef NEW_RACE_STUFF
   if( !str_cmp( arg2, "carry_weight" ) )
   {
      race->acplus = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
   if( !str_cmp( arg2, "carry_number" ) )
   {
      race->acplus = atoi( argument );
      write_race_file( ra );
      send_to_char( "Done.\n\r", ch );
      return;
   }
#endif
   do_setrace( ch, "" );
}


The setrace command was also a copy/paste of the fixed version in AFKMud but didn't suffer nearly the same losses as the setclass command. But missing options are missing options, so.....
       
Pages:<< prev 1 next >>