Login
User Name:

Password:



Register

Forgot your password?
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
SWRFUSS 1.4
Author: Various
Submitted by: Samson
Users Online
AhrefsBot, Google, Bing

Members: 0
Guests: 33
Stats
Files
Topics
Posts
Members
Newest Member
488
3,788
19,631
595
Khonsu

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » General » Coding » SWR Nocorpse Crash
Forum Rules | Mark all | Recent Posts

SWR Nocorpse Crash
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Oct 4, 2013 10:51 pm   Last edited Oct 4, 2013 10:57 pm by Amras
Go to the top of the page
Go to the bottom of the page

Amras
Fledgling
GroupMembers
Posts18
JoinedAug 11, 2008

 
I have an SWR based MUD that I started with using SWRFUSS 1.0. I have applied all of the bug fixes from the SmaugMuds.org SWR forum list so hopefully I am up-to-date and didn't miss any. However, I am having a weird issue I can't seem to figure out or track down exactly why it's causing a crash. I have not done anything to the way corpses are created. I've also compared my code to SWRFUSS 1.2 and 1.3 code and it all looks the same.

Here is the situation:

Mob has nocorpse flag.
Kill mob, MUD crashes.

GDB returns this information:

(gdb) list
2027
2028          set_cur_char( victim );
2029          new_corpse = raw_kill( ch, victim );
2030          victim = NULL;
2031
2032          if( ch->tempnum != INT_MIN && !IS_NPC( ch ) && loot && new_corpse && new_corpse->item_type == ITEM_CORPSE_NPC
2033              && new_corpse->in_room == ch->in_room && can_see_obj( ch, new_corpse ) && ch->position > POS_SLEEPING )
2034          {
2035             /*
2036              * Autogold by Scryn 8/12
(gdb)


(gdb) bt
#0  0x00000000005227bc in damage (ch=0x1998a80, victim=0x0, dam=439, dt=1006)
    at fight.c:2032
#1  0x00000000005201e6 in one_hit (ch=0x1998a80, victim=0x17c3760, dt=1006)
    at fight.c:1402
#2  0x000000000051d496 in multi_hit (ch=0x1998a80, victim=0x17c3760, dt=-1)
    at fight.c:501
#3  0x0000000000526d5f in do_kill (ch=0x1998a80,
    argument=0x7fff196682d5 "toodan") at fight.c:3413
#4  0x000000000054df8b in interpret (ch=0x1998a80,
    argument=0x7fff196682d5 "toodan") at interp.c:417
#5  0x00000000004e1e83 in game_loop () at comm.c:730
#6  0x00000000004e0d1f in main (argc=6, argv=0x7fff19668828) at comm.c:304
(gdb)


*Toodan is just the name of the mob.

Before I posted this, I went back to check other corpse affecting flags for mobs, ie. NOKILL, and it worked properly.

Any help would be appreciated. Thanks.

Post is unread #2 Oct 4, 2013 11:14 pm   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,914
JoinedJul 26, 2005

 
in frame 0 any chance you can do print *new_corpse and post what it says?

Post is unread #3 Oct 5, 2013 6:21 am   
Go to the top of the page
Go to the bottom of the page

Amras
Fledgling
GroupMembers
Posts18
JoinedAug 11, 2008

 
(gdb) print *new_corpse
Cannot access memory at address 0xfdc


(gdb) print new_corpse
$3 = (OBJ_DATA *) 0xfdc

Post is unread #4 Oct 5, 2013 7:52 am   
Go to the top of the page
Go to the bottom of the page

Amras
Fledgling
GroupMembers
Posts18
JoinedAug 11, 2008

 
I managed to fix my own issue. I am guessing the problem was trying to look into a corpse that didn't exist. I looked at the SWFotE code and it had a new integer being used called nocorpse.

   OBJ_DATA *damobj;
   ch_ret retcode;
   sh_int dampmod;
   int nocorpse = 0;


      if( IS_SET( victim->act, ACT_NOCORPSE ) )
         nocorpse = 1;

      set_cur_char( victim );
      new_corpse = raw_kill( ch, victim );
      victim = NULL;

      if( ch->tempnum != INT_MIN && !IS_NPC( ch ) && loot && new_corpse && new_corpse->item_type == ITEM_CORPSE_NPC
          && new_corpse->in_room == ch->in_room && can_see_obj( ch, new_corpse ) && ch->position > POS_SLEEPING )


            if( IS_SET( ch->act, PLR_AUTOLOOT ) && nocorpse == 0 )
               do_get( ch, "all corpse" );
            else
               if( nocorpse == 0 )
                  do_look( ch, "in corpse" );
            if( !char_died( ch ) && IS_SET( ch->act, PLR_AUTOSAC ) && !obj_extracted( new_corpse )
                && new_corpse->in_room == ch->in_room && ch->position > POS_SLEEPING && can_see_obj( ch, new_corpse ) )
               do_sacrifice( ch, "corpse" );


Seemed to fix the issue.

Post is unread #5 Oct 5, 2013 10:19 am   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,914
JoinedJul 26, 2005

 
yea i figured it was getting bad data for the new_corpse. I would still advise fixing raw_kill so it sends the correct data for new_corpse etc...

Post is unread #6 Oct 6, 2013 5:20 pm   
Go to the top of the page
Go to the bottom of the page

Amras
Fledgling
GroupMembers
Posts18
JoinedAug 11, 2008

 
It was suggested to be by Sharmair that a more simple fix (and possibly better fix?) is in the raw_kill function, to change this line:

   OBJ_DATA *corpse_to_return;


to
   OBJ_DATA *corpse_to_return = NULL;

Post is unread #7 Oct 6, 2013 6:07 pm   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,914
JoinedJul 26, 2005

 
well can you post the whole raw_kill function?

Post is unread #8 Oct 6, 2013 6:32 pm   
Go to the top of the page
Go to the bottom of the page

Amras
Fledgling
GroupMembers
Posts18
JoinedAug 11, 2008

 
OBJ_DATA *raw_kill( CHAR_DATA * ch, CHAR_DATA * victim )
{
   CHAR_DATA *victmp;
   CLAN_DATA *clan;
   OBJ_DATA *corpse_to_return = NULL;
   OBJ_DATA *obj, *obj_next;
   SHIP_DATA *ship;
   PLANET_DATA *planet;
   char buf[MAX_STRING_LENGTH];
   char buf2[MAX_STRING_LENGTH];
   char arg[MAX_STRING_LENGTH];

   if( !victim )
   {
      bug( "%s: null victim!", __FUNCTION__ );
      return NULL;
   }

   strcpy( arg, victim->name );

   stop_fighting( victim, TRUE );

   if( ch && !IS_NPC( ch ) && !IS_NPC( victim ) )
      claim_disintigration( ch, victim );

   /*
    * Take care of polymorphed chars 
    */
   if( IS_NPC( victim ) && IS_SET( victim->act, ACT_POLYMORPHED ) )
   {
      char_from_room( victim->desc->original );
      char_to_room( victim->desc->original, victim->in_room );
      victmp = victim->desc->original;
      do_revert( victim, "" );
      return raw_kill( ch, victmp );
   }

   if( victim->in_room && IS_NPC( victim ) && victim->vip_flags != 0 && victim->in_room->area
       && victim->in_room->area->planet )
   {
      victim->in_room->area->planet->population--;
      victim->in_room->area->planet->population = UMAX( victim->in_room->area->planet->population, 0 );
      victim->in_room->area->planet->pop_support -= ( float )( 1 + 1 / ( victim->in_room->area->planet->population + 1 ) );
      if( victim->in_room->area->planet->pop_support < -100 )
         victim->in_room->area->planet->pop_support = -100;
   }

   if( !IS_NPC( victim ) || !IS_SET( victim->act, ACT_NOKILL ) )
      mprog_death_trigger( ch, victim );
   if( char_died( victim ) )
      return NULL;

   if( !IS_NPC( victim ) || !IS_SET( victim->act, ACT_NOKILL ) )
      rprog_death_trigger( ch, victim );
   if( char_died( victim ) )
      return NULL;

   if( !IS_NPC( victim ) || ( !IS_SET( victim->act, ACT_NOKILL ) && !IS_SET( victim->act, ACT_NOCORPSE ) ) )
      corpse_to_return = make_corpse( victim, ch );
   else
   {
      for( obj = victim->last_carrying; obj; obj = obj_next )
      {
         obj_next = obj->prev_content;
         obj_from_char( obj );
         extract_obj( obj );
      }
   }

   if( IS_NPC( victim ) )
   {
      victim->pIndexData->killed++;
      extract_char( victim, TRUE );
      victim = NULL;
      return corpse_to_return;
   }

   planet = victim->in_room->area->planet;

   if( !planet )
   {
      if( get_age( victim ) >= 50 )
      {
         sprintf( buf, "&CAn old &W%s &Cnamed &W%s&C, has just lost %s life, on &WUnknown&C!\n\r",
                  capitalize( get_race( victim ) ), victim->name,
                  victim->sex == SEX_MALE ? "his" : victim->sex == SEX_FEMALE ? "her" : "its" );
         infochan( buf );
      }
      else if( get_age( victim ) <= 49 )
      {
         sprintf( buf, "&CA young &W%s &Cnamed &W%s&C, has just lost %s life, on &WUnknown&C!\n\r",
                  capitalize( get_race( victim ) ), victim->name,
                  victim->sex == SEX_MALE ? "his" : victim->sex == SEX_FEMALE ? "her" : "its" );
         infochan( buf );
      }
      else
      {
         sprintf( buf, "&CA &W%s &Chas just lost %s life, on &WUnknown&C!\n\r", capitalize( get_race( victim ) ),
                  victim->sex == SEX_MALE ? "his" : victim->sex == SEX_FEMALE ? "her" : "its" );
         infochan( buf );
      }
   }
   else
   {
      if( get_age( victim ) >= 50 )
      {
         sprintf( buf, "&CAn old &W%s &Cnamed &W%s&C, has just lost %s life, on &W%s&C!\n\r",
                  capitalize( get_race( victim ) ), victim->name,
                  victim->sex == SEX_MALE ? "his" : victim->sex == SEX_FEMALE ? "her" : "its", planet->name );
         infochan( buf );
      }
      else if( get_age( victim ) <= 49 )
      {
         sprintf( buf, "&CA young &W%s &Cnamed &W%s&C, has just lost %s life, on &W%s&C!\n\r",
                  capitalize( get_race( victim ) ), victim->name,
                  victim->sex == SEX_MALE ? "his" : victim->sex == SEX_FEMALE ? "her" : "its", planet->name );
         infochan( buf );
      }
      else
      {
         sprintf( buf, "&CA &W%s &Chas just lost %s life, on &W%s&C!\n\r", capitalize( get_race( victim ) ),
                  victim->sex == SEX_MALE ? "his" : victim->sex == SEX_FEMALE ? "her" : "its", planet->name );
         infochan( buf );
      }

   }

   set_char_color( AT_DIEMSG, victim );
   do_help( victim, "_DIEMSG_" );

/* swreality changes begin here */

   /*
    * Check if they have an ongoing auction 
    */
   if( auction->item && ( auction->seller == victim ) )
   {
      talk_auction( "Auction has been halted." );
      obj_to_char( auction->item, auction->seller );
      auction->item = NULL;

      if( auction->buyer != NULL && auction->buyer != auction->seller )
      {
         auction->buyer->gold += auction->bet;
         send_to_char( "&YYour money has been returned.\n\r", auction->buyer );
      }
   }

   for( ship = first_ship; ship; ship = ship->next )
   {
      if( !str_cmp( ship->owner, victim->name ) )
      {
         STRFREE( ship->owner );
         ship->owner = STRALLOC( "" );
         STRFREE( ship->pilot );
         ship->pilot = STRALLOC( "" );
         STRFREE( ship->copilot );
         ship->copilot = STRALLOC( "" );

         save_ship( ship );
      }
   }

   close_accounts( victim->name );

   if( victim->plr_home )
   {
      ROOM_INDEX_DATA *room = victim->plr_home;

      STRFREE( room->name );
      room->name = STRALLOC( "An Empty Apartment" );

      if( IS_SET( room->room_flags, ROOM_PLR_HOME ) )
         REMOVE_BIT( room->room_flags, ROOM_PLR_HOME );
      SET_BIT( room->room_flags, ROOM_EMPTY_HOME );

      fold_area( room->area, room->area->filename, FALSE );
   }

   if( victim->pcdata->vendor )
      remove_vendor( victim, get_char_world( victim, victim->pcdata->vendor->player_name ) );

   clan = victim->pcdata->clan;

   if( victim->pcdata && victim->pcdata->clan )
   {
      if( !str_cmp( victim->name, victim->pcdata->clan->leader ) )
      {
         STRFREE( victim->pcdata->clan->leader );
         if( victim->pcdata->clan->number1 )
         {
            victim->pcdata->clan->leader = STRALLOC( victim->pcdata->clan->number1 );
            STRFREE( victim->pcdata->clan->number1 );
            victim->pcdata->clan->number1 = STRALLOC( "" );
         }
         else if( victim->pcdata->clan->number2 )
         {
            victim->pcdata->clan->leader = STRALLOC( victim->pcdata->clan->number2 );
            STRFREE( victim->pcdata->clan->number2 );
            victim->pcdata->clan->number2 = STRALLOC( "" );
         }
         else
            victim->pcdata->clan->leader = STRALLOC( "" );
      }

      if( !str_cmp( victim->name, victim->pcdata->clan->number1 ) )
      {
         STRFREE( victim->pcdata->clan->number1 );
         if( victim->pcdata->clan->number2 )
         {
            victim->pcdata->clan->number1 = STRALLOC( victim->pcdata->clan->number2 );
            STRFREE( victim->pcdata->clan->number2 );
            victim->pcdata->clan->number2 = STRALLOC( "" );
         }
         else
            victim->pcdata->clan->number1 = STRALLOC( "" );
      }

      if( !str_cmp( victim->name, victim->pcdata->clan->number2 ) )
      {
         STRFREE( victim->pcdata->clan->number2 );
         victim->pcdata->clan->number1 = STRALLOC( "" );
      }

      if( victim->pcdata->clanlevel == 1 )
      {
         if( clan->roster_1[0] != '\0' )
         {
            char roster_1[MAX_STRING_LENGTH];
            char *members;

            members = clan->roster_1;
            roster_1[0] = '\0';

            while( members[0] != '\0' )
            {
               members = one_argument( members, arg );
               if( str_cmp( victim->name, arg ) )
               {
                  arg[0] = UPPER( arg[0] );
                  if( roster_1[0] != '\0' )
                     strcat( roster_1, " " );
                  else
                     strcat( roster_1, "" );
                  strcat( roster_1, arg );
               }
            }
            STRFREE( clan->roster_1 );
            clan->roster_1 = STRALLOC( roster_1 );
         }
      }

      if( victim->pcdata->clanlevel == 2 )
      {
         if( clan->roster_2[0] != '\0' )
         {
            char roster_2[MAX_STRING_LENGTH];
            char *members;

            members = clan->roster_2;
            roster_2[0] = '\0';

            while( members[0] != '\0' )
            {
               members = one_argument( members, arg );
               if( str_cmp( victim->name, arg ) )
               {
                  arg[0] = UPPER( arg[0] );
                  if( roster_2[0] != '\0' )
                     strcat( roster_2, " " );
                  else
                     strcat( roster_2, "" );
                  strcat( roster_2, arg );
               }
            }
            STRFREE( clan->roster_2 );
            clan->roster_2 = STRALLOC( roster_2 );
         }
      }

      if( victim->pcdata->clanlevel == 3 )
      {
         if( clan->roster_3[0] != '\0' )
         {
            char roster_3[MAX_STRING_LENGTH];
            char *members;

            members = clan->roster_3;
            roster_3[0] = '\0';

            while( members[0] != '\0' )
            {
               members = one_argument( members, arg );
               if( str_cmp( victim->name, arg ) )
               {
                  arg[0] = UPPER( arg[0] );
                  if( roster_3[0] != '\0' )
                     strcat( roster_3, " " );
                  else
                     strcat( roster_3, "" );
                  strcat( roster_3, arg );
               }
            }
            STRFREE( clan->roster_3 );
            clan->roster_3 = STRALLOC( roster_3 );
         }
      }

      if( victim->pcdata->clanlevel == 4 )
      {
         if( clan->roster_4[0] != '\0' )
         {
            char roster_4[MAX_STRING_LENGTH];
            char *members;

            members = clan->roster_4;
            roster_4[0] = '\0';

            while( members[0] != '\0' )
            {
               members = one_argument( members, arg );
               if( str_cmp( victim->name, arg ) )
               {
                  arg[0] = UPPER( arg[0] );
                  if( roster_4[0] != '\0' )
                     strcat( roster_4, " " );
                  else
                     strcat( roster_4, "" );
                  strcat( roster_4, arg );
               }
            }
            STRFREE( clan->roster_4 );
            clan->roster_4 = STRALLOC( roster_4 );
         }
      }

      if( victim->pcdata->clanlevel == 5 )
      {
         if( clan->roster_5[0] != '\0' )
         {
            char roster_5[MAX_STRING_LENGTH];
            char *members;

            members = clan->roster_5;
            roster_5[0] = '\0';

            while( members[0] != '\0' )
            {
               members = one_argument( members, arg );
               if( str_cmp( victim->name, arg ) )
               {
                  arg[0] = UPPER( arg[0] );
                  if( roster_5[0] != '\0' )
                     strcat( roster_5, " " );
                  else
                     strcat( roster_5, "" );
                  strcat( roster_5, arg );
               }
            }
            STRFREE( clan->roster_5 );
            clan->roster_5 = STRALLOC( roster_5 );
         }
      }

      victim->pcdata->clan->members--;
   }

   if( !victim )
   {
      DESCRIPTOR_DATA *d;

      /*
       * Make sure they aren't halfway logged in. 
       */
      for( d = first_descriptor; d; d = d->next )
         if( ( victim = d->character ) && !IS_NPC( victim ) )
            break;
      if( d )
         close_socket( d, TRUE );
   }
   else
   {
      int x, y;

      quitting_char = victim;
      save_char_obj( victim );
      saving_char = NULL;
      extract_char( victim, TRUE );
      for( x = 0; x < MAX_WEAR; x++ )
         for( y = 0; y < MAX_LAYERS; y++ )
            save_equipment[x][y] = NULL;
   }

   sprintf( buf, "%s%c/%s", PLAYER_DIR, tolower( arg[0] ), capitalize( arg ) );
   sprintf( buf2, "%s%c/%s", BACKUP_DIR, tolower( arg[0] ), capitalize( arg ) );

   rename( buf, buf2 );

   sprintf( buf, "%s%c/%s.clone", PLAYER_DIR, tolower( arg[0] ), capitalize( arg ) );
   sprintf( buf2, "%s%c/%s", PLAYER_DIR, tolower( arg[0] ), capitalize( arg ) );

   rename( buf, buf2 );

   return corpse_to_return;
}

Post is unread #9 Oct 6, 2013 6:45 pm   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,914
JoinedJul 26, 2005

 
so only change you did was to add the = NULL? well looks like it should be fine to me, you should test it out some though.

Pages:<< prev 1 next >>