Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 parse description bug
Today, 9:00 pm
By Remcon
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
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, Yandex, DotBot

Members: 0
Guests: 18
Stats
Files
Topics
Posts
Members
Newest Member
477
3,706
19,237
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SmaugFUSS Bugfix List » [Bug] "P" and "O" resets do n...
Forum Rules | Mark all | Recent Posts

[Bug] "P" and "O" resets do not properly handle counts or nesting
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Mar 5, 2005, 4:00 pm   Last edited May 11, 2005, 6:43 pm by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Bug: "P" and "O" resets do not properly handle counts or nesting.
Danger: low
Found by: Various
Fixed by: Samson
-----
[reset.c]

In edit_reset, locate:

    if ( !str_prefix( arg, "put" ) )
    {
      argument = one_argument(argument, arg);
      if ( !(reset = find_oreset(ch, pArea, aRoom, arg)) )
        return;
      pReset = reset;
      /* Put in_objects after hide and trap resets */
      while ( reset->next && (reset->next->command == 'H' ||
              reset->next->command == 'T' ||
             (reset->next->command == 'B' &&
              (reset->next->arg2 & BIT_RESET_TYPE_MASK) == BIT_RESET_OBJECT &&
              (!reset->next->arg1 || reset->next->arg1 == pReset->arg1))) )
        reset = reset->next;
/*      pReset = make_reset('P', 1, pObj->vnum, num, reset->arg1);*/
      argument = one_argument(argument, arg);
      if ( (vnum = atoi(arg)) < 1 )
        vnum = 1;
      pReset = make_reset('P', reset->extra+1, pObj->vnum, vnum, 0);
      /* Grumble.. insert puts pReset before reset, and we need it after,
         so we make a hackup and reverse all the list params.. :P.. */
      INSERT(pReset, reset, pArea->last_reset, prev, next);
      send_to_char( "Object reset in object created.\n\r", ch );
      return;
    }


And replace that section with:

    if ( !str_prefix( arg, "put" ) )
    {
      argument = one_argument(argument, arg);
      if ( !(reset = find_oreset(ch, pArea, aRoom, arg)) )
        return;
      pReset = reset;
      /* Put in_objects after hide and trap resets */
      while ( reset->next && (reset->next->command == 'H' ||
             reset->next->command == 'T' ||
            (reset->next->command == 'B' &&
             (reset->next->arg2 & BIT_RESET_TYPE_MASK) == BIT_RESET_OBJECT &&
             (!reset->next->arg1 || reset->next->arg1 == pReset->arg1))) )
        reset = reset->next;
      argument = one_argument(argument, arg);
	if( ( num = atoi( arg ) ) < 1 )
    num = 1;
	argument = one_argument( argument, arg );
      if ( (vnum = atoi(arg)) < 1 )
        vnum = 1;
      pReset = make_reset('P', reset->extra+1, pObj->vnum, num, vnum);
      /* Grumble.. insert puts pReset before reset, and we need it after,
         so we make a hackup and reverse all the list params.. :P.. */
      INSERT(pReset, reset, pArea->last_reset, prev, next);
      send_to_char( "Object reset in object created.\n\r", ch );
      return;
    }


In the reset_area function, down at the end of case 'O', find:

      obj = create_object(pObjIndex, number_fuzzy(generate_itemlevel(pArea, pObjIndex)));
      obj->level = UMIN(obj->level, LEVEL_AVATAR);
      obj->cost = 0;
      obj_to_room(obj, pRoomIndex);
      lastobj = obj;


Update it like this:

      obj = create_object(pObjIndex, number_fuzzy(generate_itemlevel(pArea, pObjIndex)));
      obj->level = UMIN(obj->level, LEVEL_AVATAR);
	obj->count = pReset->arg2; /* Added to fix object counts */
      obj->cost = 0;
      obj_to_room(obj, pRoomIndex);
      lastobj = obj;


At the end of case 'P', find:

      obj = create_object(pObjIndex, number_fuzzy(UMAX(generate_itemlevel(pArea, pObjIndex),to_obj->level)));
      obj->level = UMIN(obj->level, LEVEL_AVATAR);
      obj_to_obj(obj, to_obj);


Update it to look like this:

      obj = create_object( pObjIndex, number_fuzzy( UMAX( generate_itemlevel( pArea, pObjIndex ), to_obj->level ) ) );
      obj->level = UMIN( obj->level, LEVEL_AVATAR );
	obj->count = pReset->arg2; /* Added to fix object counts */
	obj_to_obj( obj, to_obj );


Locate the instaroom function [ not do_instaroom ] and find:

  for ( obj = pRoom->first_content; obj; obj = obj->next_content )
  {
    add_obj_reset( pArea, 'O', obj, 1, pRoom->vnum );
  }


Change it to look like this:

  for ( obj = pRoom->first_content; obj; obj = obj->next_content )
  {
    add_obj_reset( pArea, 'O', obj, obj->count, pRoom->vnum );
  }


Locate the add_obj_reset function and find:

  for ( inobj = obj->first_content; inobj; inobj = inobj->next_content )
    add_obj_reset( pArea, 'P', inobj, 1, 0 );


Change that to look like this:

  for ( inobj = obj->first_content; inobj; inobj = inobj->next_content )
    add_obj_reset( pArea, 'P', inobj, inobj->count, obj->pIndexData->vnum );


Once this is done, you should be able to go into a new room, drop any amount of an item you want on the ground, type instaroom, and have it create a reset that will then load that amount at bootup. Further, this will ALSO correct the problem of not being able to make container resets work since it also makes the items inside hold their counts. I've tested this down to 5 nesting levels deep with no problems so far. All of the container items used in my tests reloaded properly after being instaroom'ed. Also, because instazone calls instaroom, you can get the same affect from this area-wide.

One caveat - if you are using some form of rare item or rent code which places limits on the number of objects you can load before they will stop resetting, you will need to adjust this code appropriately.

Edited 8/3: Ntanel located a bug in one of the lines. An extra NULL had been included in an obj_to_room call that should not have been there.

Edit May 11 05: This fix is not required if you apply the Reset system fix from the downloads page.
       
Pages:<< prev 1 next >>