Login
User Name:

Password:



Register

Forgot your password?
do_owhere recursive
Author: Khonsu
Submitted by: Khonsu
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
Users Online
Bing

Members: 0
Guests: 20
Stats
Files
Topics
Posts
Members
Newest Member
489
3,791
19,644
596
Elwood

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » Bugfix Lists » AFKMud Bugfix List » AFKMud Bug Archive » [Bug] Ask command has global ...
Forum Rules | Mark all | Recent Posts

[Bug] Ask command has global scope
< Newer Topic :: Older Topic > AFKMud 1.77

Pages:<< prev 1 next >>
Post is unread #1 Dec 3, 2006 1:07 am   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
Bug: Ask command has global scope
Danger: Low - Target for the ask command can be chosen from anywhere in the game.
Discovered in: AFKMud 1.77
Found by: Conner
Fixed by: Samson

---

act_comm.c, do_ask

Locate:
   if( ( victim = get_char_world( ch, arg ) ) == NULL || ( IS_NPC( victim ) && victim->in_room != ch->in_room ) )
   {
      send_to_char( "They aren't here.\n\r", ch );
      return;
   }


Change to:
   if( ( victim = get_char_room( ch, arg ) ) == NULL || ( IS_NPC( victim ) && victim->in_room != ch->in_room ) )
   {
      send_to_char( "They aren't here.\r\n", ch );
      return;
   }


Locate:
   for( vch = ch->in_room->first_person; vch; vch = vch->next_in_room )
   {
      char *sbuf = argument;

      if( vch == ch )
         continue;

      /*
       * Check to see if a player on a map is at the same coords as the recipient 
       * don't need to verify the PLR_ONMAP flags here, it's a room occupants check 
       */
      if( !is_same_map( ch, vch ) )
         continue;

      /*
       * Check to see if character is ignoring speaker 
       */
      if( is_ignoring( vch, ch ) )
      {
         /*
          * continue unless speaker is an immortal 
          */
         if( !IS_IMMORTAL( ch ) || get_trust( vch ) > get_trust( ch ) )
            continue;
         else
            ch_printf( vch, "&[ignore]You attempt to ignore %s, but are unable to do so.\n\r", ch->name );
      }
      if( speaking != -1 && ( !IS_NPC( ch ) || ch->speaking ) )
      {
         int speakswell = UMIN( knows_language( vch, ch->speaking, ch ), knows_language( ch, ch->speaking, vch ) );
         if( speakswell < 75 )
            sbuf = translate( speakswell, argument, lang_names[speaking] );
      }
      sbuf = drunk_speech( sbuf, ch );

      MOBtrigger = FALSE;
   }


Replace with:
   char *sbuf = argument;

   /*
    * Check to see if a player on a map is at the same coords as the recipient 
    * don't need to verify the PLR_ONMAP flags here, it's a room occupants check 
    */
   if( !is_same_map( ch, victim ) )
   {
      send_to_char( "They aren't here.\r\n", ch );
      return;
   }

   /*
    * Check to see if character is ignoring speaker 
    */
   if( is_ignoring( victim, ch ) )
   {
      if( !IS_IMMORTAL( ch ) || get_trust( victim ) > get_trust( ch ) )
         return;
      else
         ch_printf( victim, "&[ignore]You attempt to ignore %s, but are unable to do so.\n\r", ch->name );
   }
   if( speaking != -1 && ( !IS_NPC( ch ) || ch->speaking ) )
   {
      int speakswell = UMIN( knows_language( victim, ch->speaking, ch ), knows_language( ch, ch->speaking, victim ) );
      if( speakswell < 75 )
         sbuf = translate( speakswell, argument, lang_names[speaking] );
   }
   sbuf = drunk_speech( sbuf, ch );

   ch->act = actflags;
   MOBtrigger = FALSE;


The ask command is intended to be used to speak directly to one particular target, be they NPC or PC. The command was unnecessarily global in scope, meaning it would pick the intended target from anywhere in the game. It should only have been searching in the room the player was in, and as a result of that, did not need to loop through the occupants either.

Pages:<< prev 1 next >>