Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Yandex, Google

Members: 0
Guests: 14
Stats
Files
Topics
Posts
Members
Newest Member
481
3,734
19,366
618
Micheal64X
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » AFKMud Bugfix List » AFKMud Bug Archive » [Bug] showliquid command has ...
Forum Rules | Mark all | Recent Posts

[Bug] showliquid command has numerous crashes and corruptions
< Newer Topic :: Older Topic > AFKMud 1.63

Pages:<< prev 1 next >>
Post is unread #1 Oct 2, 2004, 12:29 pm   Last edited Nov 13, 2005, 12:12 pm by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,643
JoinedJan 1, 2002

Bug: showliquid command crashes on NULL entries.
showliquid command improperly exits if the first table entry is NULL.
save_liquids command corrupts the liquids.dat file with NULL entries
setliquid command improperly deletes entries when specified by name instead of vnum
Discovered in: AFKMud 1.63
Danger: Extreme - Crash bug + Data storage corruption
Found by: Cernos
Fixed by: Samson and Xorith

liquids.c, save_liquids

Find:
   fprintf( fp, "%s", "#VERSION 3\n" );
   for( i = 0; i < top_liquid; i++ )
   {
      liq = liquid_table[i];

      fprintf( fp, "%s", "#LIQUID\n" );
      fprintf( fp, "Name      %s~\n", liq->name );
      fprintf( fp, "Shortdesc %s~\n", liq->shortdesc );
      fprintf( fp, "Color     %s~\n", liq->color );
      fprintf( fp, "Type      %d\n", liq->type );
      fprintf( fp, "Vnum      %d\n", liq->vnum );
      fprintf( fp, "Mod       %d %d %d\n", liq->mod[COND_DRUNK], liq->mod[COND_FULL], liq->mod[COND_THIRST] );
      fprintf( fp, "%s", "End\n\n" );
   }


Make it look like:
   fprintf( fp, "%s", "#VERSION 3\n" );
   for( i = 0; i < top_liquid; i++ )
   {
      if( !liquid_table[i] )
         continue;

      liq = liquid_table[i];

      fprintf( fp, "%s", "#LIQUID\n" );
      fprintf( fp, "Name      %s~\n", liq->name );
      fprintf( fp, "Shortdesc %s~\n", liq->shortdesc );
      fprintf( fp, "Color     %s~\n", liq->color );
      fprintf( fp, "Type      %d\n", liq->type );
      fprintf( fp, "Vnum      %d\n", liq->vnum );
      fprintf( fp, "Mod       %d %d %d\n", liq->mod[COND_DRUNK], liq->mod[COND_FULL], liq->mod[COND_THIRST] );
      fprintf( fp, "%s", "End\n\n" );
   }


liquids.c, do_showliquid

Find and remove:
   if( !liquid_table[0] )
   {
      ch->Send( "There are currently no liquids loaded.\n\r" );
      ch->Send( "WARNING:\n\rHaving no liquids loaded will result in no drinks providing\n\r"
         "nurishment. This includes water. The default set of liquids\n\r"
         "should always be backed up.\n\r" );
      return;
   }


Find:
   pager_printf( ch, "&G[&gVnum&G] [&gName&G]\n\r" );
   for( i = 0; i <= top_liquid; i++ )
   {
      pager_printf( ch, "  %-7d %s\n\r", liquid_table[i]->vnum, liquid_table[i]->name );
   }
   send_to_char( "Use 'showliquid [vnum]' to view individual liquids.\n\r", ch );
   send_to_char( "Use 'showmixture' to view the mixturetable.\n\r", ch );


Change to:
   send_to_pager( "&G[&gVnum&G] [&gName&G]\n\r", ch );
   for( i = 0; i <= top_liquid; i++ )
   {
      if( !liquid_table[i] )
         continue;
      pager_printf( ch, "  %-7d %s\n\r", liquid_table[i]->vnum, liquid_table[i]->name );
   }
   send_to_pager( "Use 'showliquid [vnum]' to view individual liquids.\n\r", ch );
   send_to_pager( "Use 'showmixture' to view the mixturetable.\n\r", ch );


liquids.c, do_setliquid

Find:
   else if( !str_cmp( arg, "delete" ) )
	{
      LIQ_TABLE *liq = NULL;
      int i = atoi( argument );

      if( NULLSTR( argument ) )
   {
         send_to_char( "Syntax: setliquid delete <vnum>\n\r", ch );
	return;
   }

      if( ( liq = get_liq_vnum( i ) ) == NULL )
   {
         send_to_char( "No such vnum. Use 'setliquid list' to gain the vnums.\n\r", ch );
	return;
   }

         STRFREE( liq->name );
         STRFREE( liq->color );
         STRFREE( liq->shortdesc );
      if( liq->vnum >= top_liquid )
   {
         int j;

         for( j = 0; j != liq->vnum; j++ )
            if( j > top_liquid )
         top_liquid = j;
      }
      liquid_table[liq->vnum] = NULL;
      liq_count--;
      DISPOSE( liq );
	send_to_char( "Done.\n\r", ch );
      save_liquids( );
	return;
   }


Replace with:
   else if( !str_cmp( arg, "delete" ) )
   {
      LIQ_TABLE *liq = NULL;

      if( NULLSTR( argument ) )
      {
         send_to_char( "Syntax: setliquid delete <vnum>\n\r", ch );
         return;
      }

      if( !is_number( argument ) )
      {
         if( !( liq = get_liq( argument ) ) )
         {
            send_to_char( "No such liquid type. Use 'showliquid' to get a valid list.\n\r", ch );
            return;
         }
      }
      else
      {
         int i = atoi( argument );

         if( !( liq = get_liq_vnum( i ) ) )
         {
            send_to_char( "No such vnum. Use 'showliquid' to get the vnum.\n\r", ch );
            return;
         }
      }

      STRFREE( liq->name );
      STRFREE( liq->color );
      STRFREE( liq->shortdesc );
      if( liq->vnum >= top_liquid )
      {
         int j;

         for( j = 0; j != liq->vnum; j++ )
            if( j > top_liquid )
         top_liquid = j;
      }
      liquid_table[liq->vnum] = NULL;
      liq_count--;
      DISPOSE( liq );
      send_to_char( "Done.\n\r", ch );
      save_liquids( );
      return;
   }


This is more or less a nightmare of unseen problems that could have been avoided by proper testing before release. It's bad enough when an unfound bug simply crashes the game, but when removing entries from the middle of a table can effectively destroy the entire table, that's just inexcusable. Apologies to anyone this may have caused damage to.
       
Pages:<< prev 1 next >>