Actually, you could try something like this to just rebuild all the
hash tables after you change the vnums around (untested code written
by a lazy person follows...)

void rebuild_hash_tables()
{
  int i = 0;
  ROOM_INDEX_DATA *new_room_hash[MAX_KEY_HASH];
  MOB_INDEX_DATA *new_mob_hash[MAX_KEY_HASH];
  OBJ_INDEX_DATA *new_obj_hash[MAX_KEY_HASH];
  for (i = 0; i < MAX_KEY_HASH; i++)
  {
    new_room_hash[i] = NULL;
    new_mob_hash[i] = NULL;
    new_obj_hash[i] = NULL;
  }
  for (i = 0; i < MAX_KEY_HASH; i++)
  {
    while (room_index_hash[i])
    {
      ROOM_INDEX_DATA *tmp = room_index_hash[i];
      room_index_hash[i] = room_index_hash[i]->next;
      tmp->next = new_room_hash[tmp->vnum % MAX_KEY_HASH];
      new_room_hash[tmp->vnum % MAX_KEY_HASH] = tmp;
    }
    while (mob_index_hash[i])
    {
      MOB_INDEX_DATA *tmp = mob_index_hash[i];
      mob_index_hash[i] = mob_index_hash[i]->next;
      tmp->next = new_mob_hash[tmp->vnum % MAX_KEY_HASH];
      new_mob_hash[tmp->vnum % MAX_KEY_HASH] = tmp;
    }
    while (obj_index_hash[i])
    {
      OBJ_INDEX_DATA *tmp = obj_index_hash[i];
      obj_index_hash[i] = obj_index_hash[i]->next;
      tmp->next = new_obj_hash[tmp->vnum % MAX_KEY_HASH];
      new_obj_hash[tmp->vnum % MAX_KEY_HASH] = tmp;
    }
  }
  memcpy(room_index_hash, new_room_hash, sizeof(new_room_hash));
  memcpy(mob_index_hash, new_mob_hash, sizeof(new_mob_hash));
  memcpy(obj_index_hash, new_obj_hash, sizeof(new_obj_hash));
}

Yeah.. I don't see any reason that wouldn't work..
--Palrich.

On 4/24/05, Michael Barton <[EMAIL PROTECTED]> wrote:
> Unfortunately, it's not that easy..
> You're going to have to move things around in room_index_hash and
> stuff.  Otherwise it'll crash one way or another before long.
> It probably crashes in asave because olc_save.c calls get_mob_index
> and get_room_index etc a lot.
> 
> On 4/24/05, omar miisa <[EMAIL PROTECTED]> wrote:
> > ive been working on tweaking aedit_vnum to automatically update every vnum
> > in the area when the vnums are changed(havent put in the if check so the
> > difference remains the same[eg 3100-3200 and 4550-4750 ->200 dif). the
> > function itself doesnt crash the game, but when i asave it crashes, and ive
> > been trying to locate where, but am having trouble.i figured perhaps someone
> > would have some good insight on how to go about this properly...anyway,
> > heres the function:
> >
> > AEDIT( aedit_vnum )
> > {
> >     AREA_DATA *pArea;
> >         ROOM_INDEX_DATA *pRoom;
> >         OBJ_INDEX_DATA *pObj;
> >         MOB_INDEX_DATA *pMob;
> >         RESET_DATA *pReset;
> >         PROG_CODE *prg;
> >     char lower[MAX_STRING_LENGTH];
> >     char upper[MAX_STRING_LENGTH];
> >     int  ilower;
> >     int  iupper;
> >         int  vnum;
> >         int  diff;
> >
> >     EDIT_AREA(ch, pArea);
> >         if( !strcmp(pArea->file_name,"limbo.are") )
> >         {
> >                 ptc(ch,"Limbo cannot be modified. It would conflict with 
> > internal
> > code.\n\r");
> >                 return FALSE;
> >         }
> >
> >     argument = one_argument( argument, lower );
> >     one_argument( argument, upper );
> >
> >     if ( !is_number( lower ) || lower[0] == '\0'
> >     || !is_number( upper ) || upper[0] == '\0' )
> >     {
> >         send_to_char( "Syntax:  vnum [#xlower] [#xupper]\n\r", ch );
> >         return FALSE;
> >     }
> >
> >     if ( ( ilower = atoi( lower ) ) > ( iupper = atoi( upper ) ) )
> >     {
> >         send_to_char( "AEdit:  Upper must be larger then lower.\n\r", ch );
> >         return FALSE;
> >     }
> >
> >     if ( !check_range( atoi( lower ), atoi( upper ) ) )
> >     {
> >         send_to_char( "AEdit:  Range must include only this area.\n\r", ch 
> > );
> >         return FALSE;
> >     }
> >
> >     if ( get_vnum_area( ilower )
> >     && get_vnum_area( ilower ) != pArea )
> >     {
> >         send_to_char( "AEdit:  Lower vnum already assigned.\n\r", ch );
> >         return FALSE;
> >     }
> >
> >     if ( get_vnum_area( iupper )
> >     && get_vnum_area( iupper ) != pArea )
> >     {
> >         send_to_char( "AEdit:  Upper vnum already assigned.\n\r", ch );
> >         return TRUE;    /* The lower value has been set. */
> >     }
> >
> >         diff = pArea->min_vnum - ilower;
> >         //update rooms
> >         for( vnum = pArea->min_vnum;vnum <= pArea->max_vnum;vnum++)
> >         {
> >                 if( !(pRoom = get_room_index(vnum)) )
> >                         continue;
> >                 pRoom->vnum -= diff;
> >                 for ( pReset = pRoom->reset_first; pReset; pReset = 
> > pReset->next )
> >                 {
> >                         if( pReset->arg3 <= pArea->max_vnum &&
> >                                 pReset->arg3 >= pArea->min_vnum )
> >                         pReset->arg3 -= diff;
> >                 }
> >         }
> >         //update progs
> >         for( vnum = pArea->min_vnum;vnum <= pArea->max_vnum;vnum++)
> >         {
> >                 if( (prg = get_prog_index(vnum,PRG_MPROG)) )
> >                         prg->vnum -= diff;
> >                 if( (prg = get_prog_index(vnum,PRG_OPROG)) )
> >                         prg->vnum -= diff;
> >                 if( (prg = get_prog_index(vnum,PRG_RPROG)) )
> >                         prg->vnum -= diff;
> >         }
> >         //update mobs
> >         for( vnum = pArea->min_vnum;vnum <= pArea->max_vnum;vnum++)
> >         {
> >                 if( !(pMob = get_mob_index(vnum)) )
> >                         continue;
> >                 pMob->vnum -= diff;
> >         }
> >         //update objects
> >         for( vnum = pArea->min_vnum;vnum <= pArea->max_vnum;vnum++)
> >         {
> >                 if( !(pObj = get_obj_index(vnum)) )
> >                         continue;
> >                 pObj->vnum -= diff;
> >         }
> >     pArea->min_vnum = ilower;
> >     send_to_char( "Lower vnum set.\n\r", ch );
> >     pArea->max_vnum = iupper;
> >     send_to_char( "Upper vnum set.\n\r", ch );
> >         SET_BIT(pArea->area_flags,AREA_CHANGED);
> >
> >     return TRUE;
> > }
> >
> > _________________________________________________________________
> > Take advantage of powerful junk e-mail filters built on patented 
> > Microsoft(r)
> > SmartScreen Technology.
> > http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
> >   Start enjoying all the benefits of MSN(r) Premium right now and get the
> > first two months FREE*.
> >
> > --
> > ROM mailing list
> > [email protected]
> > Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
> >
>

Reply via email to