Changing an areas vnums from inside the game

"omar miisa" <[email protected]>
Newsgroups gmane.games.devel.mud.rom
Message-ID <[email protected]>
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® 
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® 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.