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

Members: 0
Guests: 6
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] r/m/o/delete do not wor...
Forum Rules | Mark all | Recent Posts

[Bug] r/m/o/delete do not work as expected and sometimes crash
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Mar 5, 2005, 4:02 pm   Last edited May 11, 2005, 6:49 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: r/m/o/delete do not work as expected and sometimes crash.
Bug2: close_area is full of redundant code, and also crashes when used.
Found by: Samson
Fixed by: Samson

This is a lengthy fix, mainly because of the size of the functions involved.

In mud.h, find delete_room, delete_obj, and delete_mob.
Change the declarations from "bool" to "void".

In db.c, find delete_room, delete_obj, and delete_mob.
Replace them with the following new functions:

/*************************************************************/
/* Function to delete a room index.  Called from do_rdelete in build.c
   Narn, May/96
   Don't ask me why they return bool.. :).. oh well.. -- Alty
   Don't ask me either, so I changed it to void. - Samson
*/
void delete_room( ROOM_INDEX_DATA *room )
{
  int hash;
   ROOM_INDEX_DATA *prev, *limbo = get_room_index( ROOM_VNUM_LIMBO );
  OBJ_DATA *o;
  CHAR_DATA *ch;
  EXTRA_DESCR_DATA *ed;
  EXIT_DATA *ex;
  MPROG_ACT_LIST *mpact;
  MPROG_DATA *mp;
  
   while( ( ch = room->first_person ) != NULL )
  {
      if( !IS_NPC(ch) )
    {
         char_from_room( ch );
      char_to_room( ch, limbo );
    }
    else
         extract_char( ch, TRUE );
  }
   while( ( o = room->first_content ) != NULL )
      extract_obj( o );
   while( ( ed = room->first_extradesc ) != NULL )
  {
    room->first_extradesc = ed->next;
      STRFREE( ed->keyword );
      STRFREE( ed->description );
      DISPOSE( ed );
    --top_ed;
  }
   while( ( ex = room->first_exit ) != NULL )
      extract_exit( room, ex );
   while( ( mpact = room->mpact ) != NULL )
  {
    room->mpact = mpact->next;
      DISPOSE( mpact->buf );
      DISPOSE( mpact );
  }
   while( ( mp = room->mudprogs ) != NULL )
  {
    room->mudprogs = mp->next;
      STRFREE( mp->arglist );
      STRFREE( mp->comlist );
      DISPOSE( mp );
   }
   STRFREE( room->name );
   STRFREE( room->description );
  
   hash = room->vnum % MAX_KEY_HASH;
   if( room == room_index_hash[hash] )
    room_index_hash[hash] = room->next;
  else
  {
      for( prev = room_index_hash[hash]; prev; prev = prev->next )
         if( prev->next == room )
        break;
      if( prev )
      prev->next = room->next;
    else
         bug( "delete_room: room %d not in hash bucket %d.", room->vnum, hash );
  }
   DISPOSE( room );
  --top_room;
   return;
}

/* See comment on delete_room. */
void delete_obj( OBJ_INDEX_DATA *obj )
{
  int hash;
  OBJ_INDEX_DATA *prev;
  OBJ_DATA *o, *o_next;
  EXTRA_DESCR_DATA *ed;
  AFFECT_DATA *af;
  MPROG_DATA *mp;
  
  /* Remove references to object index */
   for( o = first_object; o; o = o_next )
  {
    o_next = o->next;
      if( o->pIndexData == obj )
         extract_obj( o );
  }
   while( ( ed = obj->first_extradesc ) != NULL )
  {
    obj->first_extradesc = ed->next;
      STRFREE( ed->keyword );
      STRFREE( ed->description );
      DISPOSE( ed );
    --top_ed;
  }
   while( ( af = obj->first_affect ) != NULL )
  {
    obj->first_affect = af->next;
      DISPOSE( af );
    --top_affect;
  }
   while( ( mp = obj->mudprogs ) != NULL )
  {
    obj->mudprogs = mp->next;
      STRFREE( mp->arglist );
      STRFREE( mp->comlist );
      DISPOSE( mp );
   }
   STRFREE( obj->name );
   STRFREE( obj->short_descr );
   STRFREE( obj->description );
   STRFREE( obj->action_desc );
  
  hash = obj->vnum%MAX_KEY_HASH;
   if( obj == obj_index_hash[hash] )
    obj_index_hash[hash] = obj->next;
  else
  {
      for( prev = obj_index_hash[hash]; prev; prev = prev->next )
         if( prev->next == obj )
        break;
      if( prev )
      prev->next = obj->next;
    else
         bug( "delete_obj: object %d not in hash bucket %d.", obj->vnum, hash );
  }
   DISPOSE( obj );
  --top_obj_index;
   return;
}

/* See comment on delete_room. */
void delete_mob( MOB_INDEX_DATA *mob )
{
  int hash;
  MOB_INDEX_DATA *prev;
  CHAR_DATA *ch, *ch_next;
  MPROG_DATA *mp;
  
   for( ch = first_char; ch; ch = ch_next )
  {
    ch_next = ch->next;
      if( ch->pIndexData == mob )
         extract_char( ch, TRUE );
  }
   while( ( mp = mob->mudprogs ) != NULL )
  {
    mob->mudprogs = mp->next;
      STRFREE( mp->arglist );
      STRFREE( mp->comlist );
      DISPOSE( mp );
  }
  
   if( mob->pShop )
  {
      UNLINK( mob->pShop, first_shop, last_shop, next, prev );
      DISPOSE( mob->pShop );
    --top_shop;
  }
  
   if( mob->rShop )
  {
      UNLINK( mob->rShop, first_repair, last_repair, next, prev );
      DISPOSE( mob->rShop );
    --top_repair;
  }
  
   STRFREE( mob->player_name );
   STRFREE( mob->short_descr );
   STRFREE( mob->long_descr );
   STRFREE( mob->description );
  
   hash = mob->vnum % MAX_KEY_HASH;
   if( mob == mob_index_hash[hash] )
    mob_index_hash[hash] = mob->next;
  else
  {
      for( prev = mob_index_hash[hash]; prev; prev = prev->next )
         if( prev->next == mob )
        break;
      if( prev )
      prev->next = mob->next;
    else
         bug( "delete_mob: mobile %d not in hash bucket %d.", mob->vnum, hash );
  }
   DISPOSE( mob );
  --top_mob_index;
   return;
}


In act_wiz.c, near the top, add:
extern ROOM_INDEX_DATA *room_index_hash[MAX_KEY_HASH];

Below the other lines that look like it.

Then, find close_area and replace it with the following:

/*
 * This could have other applications too.. move if needed. -- Altrag
 */
void close_area( AREA_DATA *pArea )
{
   CHAR_DATA *ech, *ech_next;
   OBJ_DATA *eobj, *eobj_next;
   ROOM_INDEX_DATA *rid, *rid_next;
   OBJ_INDEX_DATA *oid, *oid_next;
   MOB_INDEX_DATA *mid, *mid_next;
   RESET_DATA *ereset, *ereset_next;
   NEIGHBOR_DATA *neighbor, *neighbor_next;
  int icnt;
  
   for( ech = first_char; ech; ech = ech_next )
  {
    ech_next = ech->next;
    
      if( ech->fighting )
      stop_fighting( ech, TRUE );
      if( IS_NPC(ech) )
    {
      /* if mob is in area, or part of area. */
         if( URANGE( pArea->low_m_vnum, ech->pIndexData->vnum, pArea->hi_m_vnum ) == ech->pIndexData->vnum 
      || ( ech->in_room && ech->in_room->area == pArea ) )
            extract_char( ech, TRUE );
      continue;
    }
      if( ech->in_room && ech->in_room->area == pArea )
      do_recall( ech, "" );
  }
   for( eobj = first_object; eobj; eobj = eobj_next )
  {
    eobj_next = eobj->next;
    /* if obj is in area, or part of area. */
      if( URANGE( pArea->low_o_vnum, eobj->pIndexData->vnum, pArea->hi_o_vnum ) == eobj->pIndexData->vnum
        || ( eobj->in_room && eobj->in_room->area == pArea ) )
      extract_obj( eobj );
  }
   for( icnt = 0; icnt < MAX_KEY_HASH; icnt++ )
  {
      for( rid = room_index_hash[icnt]; rid; rid = rid_next )
    {
      rid_next = rid->next;
      
         if( rid->area != pArea )
        continue;
         delete_room( rid );
    }
    
      for( mid = mob_index_hash[icnt]; mid; mid = mid_next )
    {
      mid_next = mid->next;
      
         if( mid->vnum < pArea->low_m_vnum || mid->vnum > pArea->hi_m_vnum )
        continue;
         delete_mob( mid );
    }
    
      for( oid = obj_index_hash[icnt]; oid; oid = oid_next )
    {
      oid_next = oid->next;
      
         if( oid->vnum < pArea->low_o_vnum || oid->vnum > pArea->hi_o_vnum )
        continue;
         delete_obj( oid );
    }
  }
   for( ereset = pArea->first_reset; ereset; ereset = ereset_next )
  {
    ereset_next = ereset->next;
      UNLINK( ereset, pArea->first_reset, pArea->last_reset, next, prev );
      DISPOSE( ereset );
  }
   if( pArea->weather )
   {
      for( neighbor = pArea->weather->first_neighbor; neighbor; neighbor = neighbor_next )
      {
         neighbor_next = neighbor->next;
         UNLINK( neighbor, pArea->weather->first_neighbor, pArea->weather->last_neighbor, next, prev );
         STRFREE( neighbor->name );
         DISPOSE( neighbor );
      }
      DISPOSE( pArea->weather );
   }
   DISPOSE( pArea->name );
   DISPOSE( pArea->filename );
   DISPOSE( pArea->resetmsg );
   STRFREE( pArea->author );
   UNLINK( pArea, first_area, last_area, next, prev );
   UNLINK( pArea, first_build, last_build, next, prev );
   UNLINK( pArea, first_asort, last_asort, next_sort, prev_sort );
   UNLINK( pArea, first_bsort, last_bsort, next_sort, prev_sort );
   DISPOSE( pArea );
}


That's it. With that, your close_area function will work, and your r/m/o/delete functions will work.
       
Pages:<< prev 1 next >>