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, Yahoo!

Members: 0
Guests: 17
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
Evoru (32)
Related Links
» SmaugMuds.org » Bugfix Lists » AFKMud Bugfix List » AFKMud Bug Archive » Bug: Rewritten "commands" and...
Forum Rules | Mark all | Recent Posts

Bug: Rewritten "commands" and "socials" commands have been left out
< Newer Topic :: Older Topic > AFKMud 1.75

Pages:<< prev 1 next >>
Post is unread #1 May 28, 2005, 11:34 am   Last edited Nov 13, 2005, 11:10 am by Samson
Go to the top of the page
Go to the bottom of the page

Xorith
The Null Value
GroupAFKMud Team
Posts254
JoinedFeb 23, 2003

Bug: Rewritten "commands" and "socials" commands have been left out
Discovered in: AFKMud 1.75
Danger: None, they never made it over to the distro
Found by: Eldrard
Fixed by: Xorith

---
** EDIT **
This is why caffiene is a good thing. I missed a very important check in the code, which is now updated below. Basically, when using 'commands' or 'socials' with no argument, a segfault would occur. This is because my little performance tweak at the top of each function never checked to make sure there was an argument to begin with.
-------------

** EDIT **
Samson pointed out that "char_data" should have been "CHAR_DATA". -- FIXED
-------------

In your act_info.c file, find do_socials. Either remove or comment it out, and paste in the following code:

/* Rewritten by Xorith. Cleaner, with sorted/all and partial name matching */
CMDF do_socials( CHAR_DATA *ch, char *argument )
{
   int col = 0, iHash = 0, count = 0;
   char letter = ' ';
   SOCIALTYPE *social;
   bool sorted = false, all = false;

   /* Bools are better on performance -- X */
   if( argument[0] != '\0' && !str_cmp( argument, "sorted" ) )
      sorted = true;
   if( argument[0] != '\0' && !str_cmp( argument, "all" ) )
      all = true;

   if( argument[0] != '\0' && !( sorted || all ) )
      pager_printf( ch, "&[plain]Socials beginning with '%s':\n\r", argument );
   else if( argument[0] != '\0' && sorted )
      send_to_pager( "&[plain]Socials -- Tabbed by Letter\n\r", ch );
   else
      send_to_pager( "&[plain]Socials -- All\n\r", ch );

   for( iHash = 0; iHash < 27; iHash++ )
      for( social = social_index[iHash]; social; social = social->next )
      {
         if( ( argument[0] != '\0' && !( sorted || all ) ) && str_prefix( argument, social->name ) )
            continue;

         if( argument[0] != '\0' && sorted && letter != social->name[0] )
         {
            letter = social->name[0];
            if( col % 5 != 0 )
               send_to_pager( "\n\r", ch );
            pager_printf( ch, "&c[ &[plain]%c &c]\n\r", toupper( letter ) );
            col = 0;
         }
         pager_printf( ch, "&[plain]%-15s ", social->name );
         count++;
         if( ++col % 5 == 0 )
            send_to_pager( "\n\r", ch );
      }

   if( col % 5 != 0 )
      send_to_pager( "\n\r", ch );

   if( count )
      pager_printf( ch, "&[plain]   %d socials found.\n\r", count );
   else
      send_to_pager( "&[plain]   No socials found.\n\r", ch );

   return;
}


In the same file, locate do_commands and comment it out or remove it. Replace it with the following:
/* Rewritten by Xorith to be cleaner, with "sorted" and "all" support. Also supports
    partial name matching. */
CMDF do_commands( CHAR_DATA *ch, char *argument )
{
   int col = 0, hash = 0, count = 0, chTrust = 0;
   char letter = ' ';
   CMDTYPE *command;
   bool sorted = false, all = false;

   /* Bools are better on performance -- X */
   if( argument[0] != '\0' && !str_cmp( argument, "sorted" ) )
      sorted = true;
   if( argument[0] != '\0' && !str_cmp( argument, "all" ) )
      all = true;
   chTrust = get_trust( ch );

   if( argument[0] != '\0' && !( sorted || all ) )
      pager_printf( ch, "&[plain]Commands beginning with '%s':\n\r", argument );
   else if( argument[0] != '\0' && sorted )
      send_to_pager( "&[plain]Commands -- Tabbed by Letter\n\r", ch );
   else
      send_to_pager( "&[plain]Commands -- All\n\r", ch );

   for( hash = 0; hash < 126; hash++ )
      for( command = command_hash[hash]; command; command = command->next )
      {
         if( command->level > LEVEL_AVATAR || command->level > chTrust || IS_SET( command->flags, CMD_MUDPROG ) )
            continue;

         if( ( argument[0] != '\0' && !( sorted || all ) ) && str_prefix( argument, command->name ) )
            continue;

         if( argument[0] != '\0' && sorted && letter != command->name[0] )
         {
            if( command->name[0] < 97 || command->name[0] > 122 )
            {
               if( !count )
                  send_to_pager( "&c[ &[plain]Misc&c ]\n\r", ch );
            }
            else
            {
               letter = command->name[0];
               if( col % 5 != 0 )
                  send_to_pager( "\n\r", ch );
               pager_printf( ch, "&c[ &[plain]%c &c]\n\r", toupper( letter ) );
               col = 0;
            }
         }
         pager_printf( ch, "&[plain]%-11s %-3d ", command->name, command->level );
         count++;
         if( ++col % 5 == 0 )
            send_to_pager( "\n\r", ch );
      }

   if( col % 5 != 0 )
      send_to_pager( "\n\r", ch );

   if( count )
      pager_printf( ch, "&[plain]  %d commands found.\n\r", count );
   else
      send_to_pager( "&[plain]  No commands found.\n\r", ch );

   return;
}


Note: You really don't need these for a functional MUD, however they are what Alsherok is using and were meant to be included. The performance is a tad better than the old ones, but the features are a lot better.
       
Pages:<< prev 1 next >>