Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Why is my speedwalk going backwards.

Why is my speedwalk going backwards.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Robert Powell   Australia  (367 posts)  Bio
Date Sun 10 Feb 2008 05:21 AM (UTC)
Message
I have this code which is for an ingame speedwalk, trouble is i now noticed that it goes backwards through the string and not forwards, is this due to changes in gcc4x. Anyways im not sure why its going backwards now when it used to go forwards, anyone see anything obvious thats wrong.


void do_speedwalk( CHAR_DATA * ch, char *argument )
{
   char buf[MSL];
   char arg[MIL];
   char *direction;
   bool found = FALSE;


   if( !ch->desc || NULLSTR( argument ) )
   {
      send_to_char( "You must include directions.  Read help speedwalk for more information.", ch );
      return;
   }

   buf[0] = '\0';

   while( *argument != '\0' )
   {
      argument = one_argument( argument, arg );
      strcat( buf, arg );
   }

   send_to_char( "You start to walk...", ch );


   for( direction = buf + strlen( buf ) - 1; direction >= buf; direction-- )
   {
      if( !isdigit( *direction ) )
      {

         switch ( *direction )
         {
            case 'N':
            case 'n':
               //removed for clarity sake.
            default:
               send_to_char( "Invalid direction!", ch );
               return;
         }
      }

   }
   return;
}

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Sun 10 Feb 2008 05:31 AM (UTC)

Amended on Sun 10 Feb 2008 05:32 AM (UTC) by David Haley

Message
Umm...
for( direction = buf + strlen( buf ) - 1; direction >= buf; direction-- )

Doesn't this for loop mean it's counting from the end, instead of from the beginning? :-)



By the way, doesn't this have potential for abuse? If you treat the speedwalk as an instant series of commands, a player can't get "caught" in a room by another player, because the MUD is busily zooming that player around. It also seems like a great way to basically instantly traverse the world if only you have directions to do so. :) And if rooms have movement delays, then you also wouldn't be able to take those into account unless you're doing something fancy you're not showing here.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,166 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 10 Feb 2008 05:31 AM (UTC)
Message
I would be very surprised if you told me it is going forwards.

In the for loop you start at the end of the string, and then do "direction--" (which is subtracting one each time) until you reach the start of the string.



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,166 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 10 Feb 2008 05:32 AM (UTC)
Message
Hello David, I see we replied in the exact same minute. :)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #4 on Sun 10 Feb 2008 05:37 AM (UTC)
Message
Indeed! But it appears that I beat you by just a few seconds. :-) Looks like you posted as I was editing my post.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Robert Powell   Australia  (367 posts)  Bio
Date Reply #5 on Mon 11 Feb 2008 08:09 PM (UTC)
Message
Quote:

By the way, doesn't this have potential for abuse? If you treat the speedwalk as an instant series of commands, a player can't get "caught" in a room by another player, because the MUD is busily zooming that player around. It also seems like a great way to basically instantly traverse the world if only you have directions to do so. :) And if rooms have movement delays, then you also wouldn't be able to take those into account unless you're doing something fancy you're not showing here.


Is it really any different to say Mushclients or Zmuds abilities to make speedwalks? My game is not Pk orientated so being caught by Pc's is not an issue, and the way the game plays, its not much of a bother with agro Nps's either.

With movement delays, why wouldnt those be processed, when you type north into your client, it calls move_char which is where the delay processing takes place. Not that i have tested it on my overland where there is some delays on sector types, but give me a min and i will test it now and see.

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #6 on Mon 11 Feb 2008 10:07 PM (UTC)
Message
Quote:
Is it really any different to say Mushclients or Zmuds abilities to make speedwalks? My game is not Pk orientated so being caught by Pc's is not an issue, and the way the game plays, its not much of a bother with agro Nps's either.

The difference is that a client's speedwalk will be treated as a series of commands, each processed by the interpreter loop one at a time (and therefore with potential for MUD-enforced delay) whereas a single command that does it all will do it all instantly unless you introduce delay... but see below.

Aggressive NPCs would probably stop the player since I believe those are triggered on room entry, so it would happen during a move_char call. Of course, then you'd have a whole bunch of move_char calls that would fail.

Quote:
With movement delays, why wouldnt those be processed, when you type north into your client, it calls move_char which is where the delay processing takes place. Not that i have tested it on my overland where there is some delays on sector types, but give me a min and i will test it now and see.

Yes, but the delay is introduced on a per-character basis and prevents the incoming data from being treated until some amount of time has gone by. However, in this scenario, the delay will be accumulated over the whole speedwalk, and will not intervene in between each step. So, the end result will be an "instant" travel across the world, followed by the accumulated lag for that whole travel.

If however you delay in between each step, you will be pausing the whole MUD at once unless you have some kind of scheduling going on, which you probably don't unless you're using a rather modified codebase.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


21,976 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.