Login
User Name:

Password:



Register

Forgot your password?
 Smaug muds with a Player Base
Jul 10, 2025 2:21 am
By TomBrooks
Overland with Bitmaps
Jul 4, 2025 11:57 pm
By Samson
void nanny_get_new_race -- comm.c
Mar 13, 2025 7:08 am
By Elwood
IPv6
Jan 25, 2025 10:45 pm
By Samson
mudstrlcpy and mudstrlcat
Jan 18, 2025 5:23 pm
By Samson
SWFotEFUSS 1.5.3
Author: Various
Submitted by: Samson
SWRFUSS 1.4.3
Author: Various
Submitted by: Samson
SmaugFUSS 1.9.8
Author: Various
Submitted by: Samson
AFKMud 2.5.2
Author: AFKMud Team
Submitted by: Samson
SmaugFUSS 1.9.7
Author: Various
Submitted by: Samson
Users Online
Anthropic, AhrefsBot, DotBot, Meta

Members: 0
Guests: 10
Stats
Files
Topics
Posts
Members
Newest Member
507
3,812
19,726
597
WallaceCav

» 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,708
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 >>