Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
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
Bug in do_drag( )
Oct 8, 2017, 12:40 am
By GatewaySysop
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
Beastmaster 6D sound files
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, DotBot

Members: 0
Guests: 5
Stats
Files
Topics
Posts
Members
Newest Member
476
3,704
19,231
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SmaugFUSS Bugfix List » [Bug] Pets wearing equipment ...
Forum Rules | Mark all | Recent Posts

[Bug] Pets wearing equipment cause player equipment to be stripped
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Dec 30, 2006, 7:38 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: Pets wearing equipment cause player equipment to be stripped
Danger: Low - Incredibly annoying, but no data loss or other problems
Found by: Kayle, and oh so long ago, Tarl.
Fixed by: Kayle, and also oh so long ago, Tarl.

---

mud.h

Locate:
extern OBJ_DATA *save_equipment[MAX_WEAR][MAX_LAYERS];


Below that, add:
extern OBJ_DATA *mob_save_equipment[MAX_WEAR][MAX_LAYERS];


handler.c, obj_to_char

Locate:
   if( loading_char == ch )
   {
      int x, y;
      for( x = 0; x < MAX_WEAR; x++ )
         for( y = 0; y < MAX_LAYERS; y++ )
            if( save_equipment[x][y] == obj )
            {
               skipgroup = TRUE;
               break;
            }
   }


Change to:
   if( loading_char == ch )
   {
      int x, y;
      for( x = 0; x < MAX_WEAR; x++ )
      {
         for( y = 0; y < MAX_LAYERS; y++ )
         {
            if( IS_NPC( ch ) )
            {
               if( mob_save_equipment[x][y] == obj )
               {
                  skipgroup = TRUE;
                  break;
               }
            }
            else
            {
               if( save_equipment[x][y] == obj )
               {
                  skipgroup = TRUE;
                  break;
               }
            }
         }
      }
   }


handler.c, can_carry_n

Locate and remove:
   if( IS_NPC( ch ) && xIS_SET( ch->act, ACT_PET ) )
      return 0;


handler.c, can_carry_w

Locate and remove:
   if( IS_NPC( ch ) && xIS_SET( ch->act, ACT_PET ) )
      return 0;


save.c

Locate:
OBJ_DATA *save_equipment[MAX_WEAR][MAX_LAYERS];


Below that, add:
OBJ_DATA *mob_save_equipment[MAX_WEAR][MAX_LAYERS];


save.c, de_equip_char

Locate:
   for( x = 0; x < MAX_WEAR; x++ )
      for( y = 0; y < MAX_LAYERS; y++ )
         save_equipment[x][y] = NULL;


Change to:
   for( x = 0; x < MAX_WEAR; x++ )
   {
      for( y = 0; y < MAX_LAYERS; y++ )
      {
         if( IS_NPC( ch ) )
            mob_save_equipment[x][y] = NULL;
         else
            save_equipment[x][y] = NULL;
      }
   }


Locate:
            for( x = 0; x < MAX_LAYERS; x++ )
               if( !save_equipment[obj->wear_loc][x] )
               {
                  save_equipment[obj->wear_loc][x] = obj;
                  break;
               }


Change to:
            for( x = 0; x < MAX_LAYERS; x++ )
            {
               if( IS_NPC( ch ) )
               {
                  if( !mob_save_equipment[obj->wear_loc][x] )
                  {
                     mob_save_equipment[obj->wear_loc][x] = obj;
                     break;
                  }
               }
               else
               {
                  if( !save_equipment[obj->wear_loc][x] )
                  {
                     save_equipment[obj->wear_loc][x] = obj;
                     break;
                  }
               }
            }


save.c, re_equip_char

Replace the function with:
void re_equip_char( CHAR_DATA * ch )
{
   int x, y;

   for( x = 0; x < MAX_WEAR; x++ )
   {
      for( y = 0; y < MAX_LAYERS; y++ )
      {
         if( IS_NPC( ch ) )
         {
            if( mob_save_equipment[x][y] != NULL )
            {
               if( quitting_char != ch )
                  equip_char( ch, mob_save_equipment[x][y], x );
               mob_save_equipment[x][y] = NULL;
            }
            else
               break;
         }
         else
         {
            if( save_equipment[x][y] != NULL )
            {
               if( quitting_char != ch )
                  equip_char( ch, save_equipment[x][y], x );
               save_equipment[x][y] = NULL;
            }
            else
               break;
         }
      }
   }
}


save.c, fwrite_obj

Locate:
   for( wear = 0; wear < MAX_WEAR; wear++ )
      for( x = 0; x < MAX_LAYERS; x++ )
         if( obj == save_equipment[wear][x] )
         {
            wear_loc = wear;
            break;
         }
         else if( !save_equipment[wear][x] )
            break;


Change to:
   for( wear = 0; wear < MAX_WEAR; wear++ )
   {
      for( x = 0; x < MAX_LAYERS; x++ )
      {
         if( ch )
         {
            if( IS_NPC( ch ) )
            {
               if( obj == mob_save_equipment[wear][x] )
               {
                  wear_loc = wear;
                  break;
               }
               else if( !mob_save_equipment[wear][x] )
                  break;
            }
            else
            {
               if( obj == save_equipment[wear][x] )
               {
                  wear_loc = wear;
                  break;
               }
               else if( !save_equipment[wear][x] )
                  break;
            }
         }
      }
   }


save.c, fread_obj

Locate:
                        for( x = 0; x < MAX_LAYERS; x++ )
                           if( !save_equipment[wear_loc][x] )
                           {
                              save_equipment[wear_loc][x] = obj;
                              slot = x;
                              reslot = TRUE;
                              break;
                           }


Change to:
                        for( x = 0; x < MAX_LAYERS; x++ )
                        {
                           if( IS_NPC( ch ) )
                           {
                              if( !mob_save_equipment[wear_loc][x] )
                              {
                                 mob_save_equipment[wear_loc][x] = obj;
                                 slot = x;
                                 reslot = TRUE;
                                 break;
                              }
                           }
                           else
                           {
                              if( !save_equipment[wear_loc][x] )
                              {
                                 save_equipment[wear_loc][x] = obj;
                                 slot = x;
                                 reslot = TRUE;
                                 break;
                              }
                           }
                        }


Locate:
                     if( reslot && slot != -1 )
                        save_equipment[wear_loc][slot] = obj;


Change to:
                     if( reslot && slot != -1 )
                     {
                        if( IS_NPC( ch ) )
                           mob_save_equipment[wear_loc][slot] = obj;
                        else
                           save_equipment[wear_loc][slot] = obj;
                     }


save.c, load_char_obj

Locate:
   for( x = 0; x < MAX_WEAR; x++ )
      for( i = 0; i < MAX_LAYERS; i++ )
         save_equipment[x][i] = NULL;


Change to:
   for( x = 0; x < MAX_WEAR; x++ )
      for( i = 0; i < MAX_LAYERS; i++ )
      {
         save_equipment[x][i] = NULL;
         mob_save_equipment[x][i] = NULL;
      }


save.c, fwrite_mobile

Locate:
   if( !IS_NPC( mob ) || !fp )
      return;


Below that, add:
   de_equip_char( mob );


Locate and remove:
/* Might need these later --Shaddai
  de_equip_char( mob );
  re_equip_char( mob );
  */


Locate:
   if( mob->first_carrying )
      fwrite_obj( mob, mob->last_carrying, fp, 0, OS_CARRY, FALSE );
   fprintf( fp, "EndMobile\n" );


Below that, add:
   re_equip_char( mob );


save.c, fread_mobile

Locate:
         case '#':
            if( !str_cmp( word, "#OBJECT" ) )
               fread_obj( mob, fp, OS_CARRY );
            break;


Change to:
         case '#':
            if( !str_cmp( word, "#OBJECT" ) )
            {
               fread_obj( mob, fp, OS_CARRY );
               fMatch = TRUE;
               break;
            }
            break;


Locate:
               char_to_room( mob, pRoomIndex );


Below that, add:
               re_equip_char( mob );


The above huge mess completes a feature the Smaugdevs had apparently intended to have working all along but never got around to. Pets being able to carry, use, and keep inventory that is given to them by their masters. But without all of the extra support code for it, the results would be hazardous at best. So care should be taken while applying this.
       
Pages:<< prev 1 next >>