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, Sogou, Bing, DotBot

Members: 0
Guests: 8
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 » 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 2, 2006, 11:07 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: 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 >>