Login
User Name:

Password:



Register

Forgot your password?
do_owhere recursive
Author: Khonsu
Submitted by: Khonsu
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
Users Online
There are currently no members online.

Members: 0
Guests: 21
Stats
Files
Topics
Posts
Members
Newest Member
489
3,793
19,649
597
Aileenutz

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » Bugfix Lists » AFKMud Bugfix List » AFKMud Bug Archive » [Bug] Mudprog ifchecks do not...
Forum Rules | Mark all | Recent Posts

[Bug] Mudprog ifchecks do not support proper nesting
< Newer Topic :: Older Topic > AFKMud 1.77

Pages:<< prev 1 next >>
Post is unread #1 Sep 10, 2006 4:48 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
Bug: Mudprog ifchecks do not support proper nesting
Danger: Medium - Whoever enters the room first is going to get picked on more
Discovered in: AFKMud 1.77
Found by: Valcados
Fixed by: Valcados

---

mud_prog.c

Locate:
struct mpsleep_data
{
   MPSLEEP_DATA *next;
   MPSLEEP_DATA *prev;
   CHAR_DATA *mob;
   CHAR_DATA *actor;
   OBJ_DATA *obj;
   void *vo;
   ROOM_INDEX_DATA *room;  /* Room when type is MP_ROOM */
   int timer;  /* Pulses to sleep */
   mp_types type; /* Mob, Room or Obj prog */
   int ignorelevel;
   int iflevel;
   bool ifstate[MAX_IFS][DO_ELSE + 1];
   char *com_list;
   bool single_step;
};


Below that, add:
void uphold_supermob( int *curr_serial, int serial, ROOM_INDEX_DATA **supermob_room, OBJ_DATA *true_supermob_obj )
{
   if( *curr_serial != serial )
   {
      char buf[128];

      if( supermob->in_room != *supermob_room )
      {
         char_from_room( supermob );
         char_to_room( supermob, *supermob_room );
      }

      if( true_supermob_obj && true_supermob_obj != supermob_obj )
      {
          supermob_obj = true_supermob_obj;
          STRFREE( supermob->short_descr );
          STRFREE( supermob->chardesc );
          supermob->short_descr = QUICKLINK( supermob_obj->short_descr );
          snprintf( buf, 128, "Object #%d", supermob_obj->pIndexData->vnum );
          supermob->chardesc = STRALLOC( buf );
      }
      else
      {
         if( !true_supermob_obj )
            supermob_obj = NULL;
         STRFREE( supermob->short_descr );
         STRFREE( supermob->chardesc );
         supermob->short_descr = QUICKLINK( (*supermob_room)->name );
         snprintf( buf, 128, "Room #%d", (*supermob_room)->vnum );
         supermob->chardesc = STRALLOC( buf );
      }
      *curr_serial = serial;
   }
   else
      *supermob_room = supermob->in_room;
}


mud_prog.c, mprog_driver

Locate:
   bool ifstate[MAX_IFS][DO_ELSE + 1];
   static int prog_nest;
   MPSLEEP_DATA *mpsleep = NULL;
   char arg[MIL]; /* mpsleep */


Below that, add:
   static int serial;
   int curr_serial;
   ROOM_INDEX_DATA *supermob_room;
   OBJ_DATA *true_supermob_obj;
   bool rprog_oprog = ( mob == supermob );

   if( rprog_oprog )
   {
      serial++;
      supermob_room = mob->in_room;
      true_supermob_obj = supermob_obj;
   }
   else
      true_supermob_obj = NULL, supermob_room = NULL;
   curr_serial = serial;


Locate:
      /*
       * Evaluate/execute the command, check what happened. 
       */
      result = mprog_do_command( cmnd, mob, actor, obj, vo, rndm,
                                 ( ifstate[iflevel][IN_IF] && !ifstate[iflevel][DO_IF] )
                                 || ( ifstate[iflevel][IN_ELSE] && !ifstate[iflevel][DO_ELSE] ), ( ignorelevel > 0 ) );


Below that, add:
      if( rprog_oprog )
         uphold_supermob( &curr_serial, serial, &supermob_room, true_supermob_obj );


Uopn completion of the innermost block of script code, the supermob will end his duties for the program and return to his usual utility room. He should not do that as there is more prog to process.

Pages:<< prev 1 next >>