Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 Couple bugs
Yesterday, 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!, Google

Members: 0
Guests: 15
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 » Codebases » SWR FUSS » move_char bug with positions
Forum Rules | Mark all | Recent Posts

move_char bug with positions
< Newer Topic :: Older Topic >

Pages:<< prev 1, 2 next >>
Post is unread #1 Jul 11, 2010, 12:45 pm   Last edited Jul 11, 2010, 12:46 pm by Banner
Go to the top of the page
Go to the bottom of the page

Banner
Magician
GroupMembers
Posts169
JoinedNov 29, 2005

It's possible to go through a flagged AUTO/HIDDEN exit while stunned, fighting, incapitated, resting, or sitting. This is possible as positions are checked in the direction commands, but not in the actual function move_char(). This bug exists in both smaugfuss and swrfuss.

act_move.cpp, move_char():
Somewhere with these ifchecks:
   }   

   if( IS_SET( pexit->exit_info, EX_NOMOB ) && IS_NPC( ch ) )
   {                
      act( AT_PLAIN, "Mobs can't enter there.", ch, NULL, NULL, TO_CHAR );      
      return rNONE;
   }

   if( IS_SET( to_room->room_flags, ROOM_NO_MOB ) && IS_NPC( ch ) )
   {                  
      act( AT_PLAIN, "Mobs can't enter there.", ch, NULL, NULL, TO_CHAR );
      return rNONE;
   } 




Add:
  if( ch->position ==  POS_INCAP || ch->position == POS_STUNNED )
  {
     send_to_char( "&RNo way, you're too stunned for that!\r\n", ch );
     return rNONE;
  }
  if( ch->position == POS_SLEEPING )
  {
      send_to_char( "In your dreams, or what?\r\n", ch );
      return rNONE;
  }
  if( ch->position == POS_SITTING || ch->position == POS_RESTING )
  {
     send_to_char( "You can't do that sitting down.\r\n", ch );
     return rNONE;
  }
  if( ch->position == POS_FIGHTING )
  {
     send_to_char( "&RNo wait, you're still fighting!\r\n", ch );
     return rNONE;
  }     
       
Post is unread #2 Jul 11, 2010, 2:40 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Looks like a good catch. Almost makes me want to break the various things that can stop movement into a can_go() function and have move_char() call that, so that can_go() can be fixed/tweaked as needed without disturbing the rest. Also looks cleaner, but hardly necessary for fixing the actual problem.
       
Post is unread #3 Jul 11, 2010, 3:52 pm   Last edited Jul 11, 2010, 3:58 pm by Banner
Go to the top of the page
Go to the bottom of the page

Banner
Magician
GroupMembers
Posts169
JoinedNov 29, 2005

Yeah, it's kind of funny being able to go through those exits while in the middle of a fight or sleeping. Indeed, move_char() could do with a bit of cleanup and house cleaning. I don't particularly like those large stock functions that could be broken down, like nanny(), for instance.
       
Post is unread #4 Jul 12, 2010, 2:03 pm   Last edited Jul 12, 2010, 2:03 pm by ayuri
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

Stupid question but here it goes since I don't have access to any of the source at the moment, I can't look this up myself. Will this updated code with the POS_INCAP prevent someone from dragging someone if they are knocked out?

ayuri
       
Post is unread #5 Jul 12, 2010, 2:11 pm   Last edited Jul 12, 2010, 2:13 pm by Banner
Go to the top of the page
Go to the bottom of the page

Banner
Magician
GroupMembers
Posts169
JoinedNov 29, 2005

ayuri said:

Stupid question but here it goes since I don't have access to any of the source at the moment, I can't look this up myself. Will this updated code with the POS_INCAP prevent someone from dragging someone if they are knocked out?

ayuri

It shouldn't. The position is changed to POS_DRAG while they are moved and then switched back to stunned/incapacitated afterwards.

EDIT: This would affect fleeing, however, a position could be added and modified with flee the same way drag does it.
       
Post is unread #6 Jul 12, 2010, 4:55 pm   Last edited Jul 12, 2010, 4:58 pm by ayuri
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

Ahh, didn't think about fleeing. Good catch on that one.

ayuri
       
Post is unread #7 Jul 12, 2010, 5:23 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Just started a new job, so I'm a little behind, I'll poke at this when I have time. Which should be this weekend. Hopefully.
       
Post is unread #8 Jul 12, 2010, 6:53 pm
Go to the top of the page
Go to the bottom of the page

Conner
Sorcerer
GroupMembers
Posts870
JoinedMay 8, 2005

Banner said:

EDIT: This would affect fleeing

You know, that was my first thought when I saw this thread initially too, but I didn't say anything because Samson had essentially endorsed the proposed fix so I thought I must've been mistaken. Guess it just goes to show that you really shouldn't go second guessing yourself. :lol:
       
Post is unread #9 Jul 12, 2010, 6:54 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Or assume that just because I said it was a good fix meant I had taken everything into consideration. Fleeing wasn't even on my mind when I first looked at it.
       
Post is unread #10 Jul 13, 2010, 6:50 pm
Go to the top of the page
Go to the bottom of the page

Conner
Sorcerer
GroupMembers
Posts870
JoinedMay 8, 2005

I suppose there is that aspect to consider too. I think this was a case of my believing "better coders than I have already approved it so who am I to question it". :shrug:
       
Post is unread #11 Jul 14, 2010, 7:01 am
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

You know the game 'Simon Says'? How about we play 'Samson Says' instead. :biggrin:
       
Post is unread #12 Jul 18, 2010, 6:57 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Due to my forgetting about the baby shower this weekend, I didn't have time to look into this yet. However, I should have time tomorrow after work to look into this.
       
Post is unread #13 Jul 19, 2010, 6:24 pm   Last edited Jul 19, 2010, 7:03 pm by Kayle
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Had a chance to look this over, and wouldn't adding a call to check_pos() in the interpreter section for auto exits fix this without disrupting flee?

Something like:
   /*
    * Look for command in skill and socials table.
    */
   if( !found )
   {
      if( !check_skill( ch, command, argument ) && !check_ability( ch, command, argument )   // Racial Abilities Support - Kayle 7-8-07
          && !rprog_command_trigger( ch, origarg )
          && !mprog_command_trigger( ch, origarg )
          && !oprog_command_trigger( ch, origarg )
          && !check_social( ch, command, argument ) && !news_cmd_hook( ch, command, argument )
#ifdef IMC
          && !imc_command_hook( ch, command, argument )
#endif
          )
      {
         EXIT_DATA *pexit;

         /*
          * check for an auto-matic exit command 
          */
         if( ( pexit = find_door( ch, command, TRUE ) ) != NULL && IS_SET( pexit->exit_info, EX_xAUTO ) && check_pos( ch, POS_STANDING )
         {
            if( IS_SET( pexit->exit_info, EX_CLOSED )
                && ( !IS_AFFECTED( ch, AFF_PASS_DOOR ) || IS_SET( pexit->exit_info, EX_NOPASSDOOR ) ) )
            {
               if( !IS_SET( pexit->exit_info, EX_SECRET ) )
                  act( AT_PLAIN, "The $d is closed.", ch, NULL, pexit->keyword, TO_CHAR );
               else
                  send_to_char( "You cannot do that here.\r\n", ch );
               return;
            }
            move_char( ch, pexit, 0 );
            return;
         }
         send_to_char( "Huh?\r\n", ch );
      }
      return;
   }


[Edit:] Someone try this for me while I'm working and let me know if it works. (working 40 hours a week really takes a lot out of your day...)
       
Post is unread #14 Jul 20, 2010, 1:51 pm
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

(working 40 hours a week really takes a lot out of your day...)

Tell me about it :wink:
       
Post is unread #15 Jul 20, 2010, 7:08 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

DavidHaley said:


Tell me about it :wink:


You can at least get on MUDs from work. :P
       
Post is unread #16 Jul 22, 2010, 10:11 pm
Go to the top of the page
Go to the bottom of the page

Keirath
Magician
GroupMembers
Posts144
JoinedJan 24, 2008

Ha, be thankful for work. I lost my job so I've got nothing to do BUT MUD.
       
Post is unread #17 Jul 24, 2010, 6:45 am
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

I'd like to go back to the days where I could just do nothing but MUD. But I do like the influx of cash. So.. Maybe I'll just deal with this whole working thing.

Anyway, has anyone tested my solution, or have an easy way for me to test the solution on my own?
       
Post is unread #18 Aug 1, 2010, 6:51 am
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

I'd like to get this taken care of, but I don't have an easy way to test if this works if no one volunteers any information on a way to test it by my lonesome.
       
Post is unread #19 Aug 1, 2010, 4:34 pm
Go to the top of the page
Go to the bottom of the page

Conner
Sorcerer
GroupMembers
Posts870
JoinedMay 8, 2005

Sorry, Kayle, I'm pretty much in the same boat over here. If I put it in, I've still got to try to test it somehow by my lonesome too. My mud's not exactly been crowded to capacity since my move to the country that mandated switching to this damn laggy satellite feed. :(
       
Post is unread #20 Aug 1, 2010, 6:53 pm
Go to the top of the page
Go to the bottom of the page

Sharmair
Fledgling
GroupMembers
Posts7
JoinedApr 19, 2010

Looking at my code from just before I changed how positions work, I see that I fixed this by putting
some checks in the auto-exit handling section of the interpret() function in interp.cpp (probably .c in
most SMAUGs though):
            if((pexit = find_door(ch, command, TRUE)) != NULL && IS_SET(pexit->exit_info, EX_xAUTO)){
                if(IS_SET(pexit->exit_info, EX_CLOSED) && (!IS_AFFECTED(ch, AFF_PASS_DOOR) || IS_SET(pexit->exit_info, EX_NOPASSDOOR))){
                    if(!IS_SET(pexit->exit_info, EX_SECRET) && IS_AWAKE(ch))
                        act(AT_PLAIN, "The $d is closed.", ch, NULL, NULL, TO_CHAR, pexit->keyword);
                    else
                        send_to_char("Huh?\r\n", ch);//WAS "You cannot do that here." but did not want to give a hint to secret
                    return;
                }
                if(check_pos(ch, POS_STANDING))
                    move_char(ch, pexit, 0);
                return;
            }
            send_to_char("Huh?\r\n", ch);

I put the position check right before the actual move as that is what is actually affected
by the position. I also added a check to see if you are awake in the closed door section.
The idea there was if the character was awake, they could see the door was closed even
if in a position that they could not move to it (note that since this code, I have added extra
support for blindness and dark rooms in this visibility check). As a note if someone tries
to use this code: I had fully hardened the act() function for any format string and function
input. I moved the string based inputs to two defaulted arguments at the end of the input
list, so to use in a more stock system, the last argument should be moved to where the
2nd NULL is now.

It would seem if you put the position check in the if that is checking for the auto-exit, you
would get the bad position message from check_pos() and then get the huh? from the fall
through. This though is still much better then putting the checks in move_char(), which
is conceptually wrong.
       
Pages:<< prev 1, 2 next >>