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, Bing, Yahoo!

Members: 0
Guests: 13
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 » SmaugFUSS Bugfix List » [Bug] Multiple problems with ...
Forum Rules | Mark all | Recent Posts

[Bug] Multiple problems with mpsleep support
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Feb 15, 2008, 10:56 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: Multiple problems with mpsleep support
Danger: Medium - None of the problems lead to crashes, but the behavior of mpsleep is eratic at best.
Found by: Many people
Fixed by: Several people on Gammon's forums

---

mud_prog.c, mprog_driver

Locate:
      for( count = 0; count <= MAX_IFS; ++count )
      {
         for( count2 = 0; count2 < DO_ELSE; ++count2 )
            ifstate[count][count2] = current_mpsleep->ifstate[count][count2];
      }


Chage to:
      for( count = 0; count < MAX_IFS; ++count )
      {
         for( count2 = 0; count2 <= DO_ELSE; ++count2 )
            ifstate[count][count2] = current_mpsleep->ifstate[count][count2];
      }


Locate:
      /*
       * mpsleep - Check if we should sleep -rkb 
       */
      one_argument( cmnd, arg );
      if( !str_prefix( "mpsleep", cmnd ) )
      {
         if( ( ifstate[iflevel][IN_IF] == ifstate[iflevel][DO_IF] )
             && ( ifstate[iflevel][IN_ELSE] == ifstate[iflevel][DO_ELSE] ) )
         {
            CREATE( mpsleep, MPSLEEP_DATA, 1 );

            /*
             * State variables 
             */
            mpsleep->ignorelevel = ignorelevel;
            mpsleep->iflevel = iflevel;

            for( count = 0; count < MAX_IFS; ++count )
            {
               for( count2 = 0; count2 < DO_ELSE; ++count2 )
                  mpsleep->ifstate[count][count2] = ifstate[count][count2];
            }
         }

         /*
          * Driver arguments 
          */
         mpsleep->com_list = STRALLOC( command_list );
         mpsleep->mob = mob;
         mpsleep->actor = actor;
         mpsleep->obj = obj;
         mpsleep->vo = vo;
         mpsleep->single_step = single_step;

         /*
          * Time to sleep 
          */
         cmnd = one_argument( cmnd, arg );
         if( cmnd[0] == '\0' )
            mpsleep->timer = 4;
         else
            mpsleep->timer = atoi( cmnd );

         if( mpsleep->timer < 1 )
         {
            progbug( "mpsleep - bad arg, using default", mob );
            mpsleep->timer = 4;
         }

         /*
          * Save type of prog, room, object or mob 
          */
         if( mpsleep->mob->pIndexData->vnum == MOB_VNUM_SUPERMOB )
         {
            if( !str_prefix( "Room", mpsleep->mob->description ) )
            {
               mpsleep->type = MP_ROOM;
               mpsleep->room = mpsleep->mob->in_room;
            }
            else if( !str_prefix( "Object", mpsleep->mob->description ) )
               mpsleep->type = MP_OBJ;
         }
         else
            mpsleep->type = MP_MOB;

         LINK( mpsleep, first_mpsleep, last_mpsleep, next, prev );
         --prog_nest;
         return;
      }


Change to:
      /*
       * mpsleep - Check if we should sleep -rkb 
       */
      one_argument( cmnd, arg );
      if( !str_cmp( arg, "mpsleep" ) )
      {
         if( ( ifstate[iflevel][IN_IF] == TRUE && ifstate[iflevel][DO_IF] == FALSE ) ||  // if we are in an if/else and we
           ( ifstate[iflevel][IN_ELSE] == TRUE && ifstate[iflevel][DO_ELSE] == FALSE ) ) // dont want to execute, dont..
         {
         }
         else
         {
            CREATE( mpsleep, MPSLEEP_DATA, 1 );

            /*
             * State variables 
             */
            mpsleep->ignorelevel = ignorelevel;
            mpsleep->iflevel = iflevel;

            for( count = 0; count < MAX_IFS; ++count )
            {
               for( count2 = 0; count2 <= DO_ELSE; ++count2 )
                  mpsleep->ifstate[count][count2] = ifstate[count][count2];
            }

            /*
             * Driver arguments 
             */
            mpsleep->com_list = STRALLOC( command_list );
            mpsleep->mob = mob;
            mpsleep->actor = actor;
            mpsleep->obj = obj;
            mpsleep->vo = vo;
            mpsleep->single_step = single_step;

            /*
             * Time to sleep 
             */
            cmnd = one_argument( cmnd, arg );
            if( cmnd[0] == '\0' )
               mpsleep->timer = 4;
            else
               mpsleep->timer = atoi( cmnd );

            if( mpsleep->timer < 1 )
            {
               progbug( "mpsleep - bad arg, using default", mob );
               mpsleep->timer = 4;
            }

            /*
             * Save type of prog, room, object or mob 
             */
            if( mpsleep->mob->pIndexData->vnum == MOB_VNUM_SUPERMOB )
            {
               if( !str_prefix( "Room", mpsleep->mob->description ) )
               {
                  mpsleep->type = MP_ROOM;
                  mpsleep->room = mpsleep->mob->in_room;
               }
               else if( !str_prefix( "Object", mpsleep->mob->description ) )
                  mpsleep->type = MP_OBJ;
            }
            else
               mpsleep->type = MP_MOB;

            LINK( mpsleep, first_mpsleep, last_mpsleep, next, prev );
            --prog_nest;
            return;
         }
      }


mud.h, struct mpsleep_data

Locate:
bool ifstate[MAX_IFS][DO_ELSE];


Change to:
bool ifstate[MAX_IFS][DO_ELSE+1];


Introduced as an official Smaug 1.8 feature, mpsleep has actually been around for quite a long time as a snippet. Over the years a few problems were discovered with it and people have piecemealed fixes for it here and there. This is an attempt to fix the whole thing in one shot. If you use mpsleep and you get progs that execute all steps while ignoring the mpsleep delay, or you get delays where none are wanted, or you get corner case crashes with it, this fix should correct all of that.
       
Pages:<< prev 1 next >>