I didn't use your function exactly, but thanks for jogging my mind.. just
needed to get it started.. here is the final function in case anyone wants
to use it.

/* ------------------------------------------------ */

bool has_reset( CHAR_DATA *ch, int vnum, char *type, bool deleteArea )
{
    AREA_DATA *pArea;
    RESET_DATA *pReset;
    MOB_INDEX_DATA *pMob = NULL;
    OBJ_INDEX_DATA *pObj;
    ROOM_INDEX_DATA *pRoom;
    char buf[MSL];
    int count = 0;
    int i;

    for (pArea = area_first; pArea; pArea = pArea->next)
    {
        if ( deleteArea && pArea == get_vnum_area( vnum ) )
            continue;

        for (i = pArea->min_vnum; i <= pArea->max_vnum; i++)
        {
            if ( ( pRoom = get_room_index(i) ) == NULL )
                continue;

            if ( !pRoom->reset_first )
                continue;

            for (pReset = pRoom->reset_first; pReset; pReset = pReset->next)
            {
                switch (pReset->command)
                {
                    case 'M':
                        if ( str_prefix( type, "mobile" ) )
                            break;

                        if ( ( pMob = get_mob_index(pReset->arg1) ) != NULL
                        && pMob->vnum == vnum )
                        {
                            if ( deleteArea && count == 0 )
                            {
                                sprintf( buf, "^&Resets for Mobile
%d^0:\n\r", vnum );
                                send_to_char( buf, ch );
                            }

                            sprintf( buf, "^![^$%d^!] ^0%s ^![^$Room
%d^!]^0\n\r",
                                ++count, pRoom->name, pRoom->vnum );
                            send_to_char( buf, ch );
                        }
                        break;

                    case 'O':
                    case 'P':
                    case 'G':
                    case 'E':
                        if ( str_prefix( type, "object" ) )
                            break;

                        if ( ( pObj = get_obj_index(pReset->arg1) ) != NULL
                        && pObj->vnum == vnum )
                        {
                            if ( deleteArea && count == 0 )
                            {
                                sprintf( buf, "^&Resets for Object
%d^0:\n\r", vnum );
                                send_to_char( buf, ch );
                            }

                            sprintf( buf, "^![^$%d^!] ^0%s ^![^$Room
%d^!]^0\n\r",
                               ++count, pRoom->name, pRoom->vnum );
                            send_to_char( buf, ch );
                        }
                        break;
                }
            }
        }
    }

    if ( count > 0 )
        return TRUE;
    else
        return FALSE;
}

/* ---------------------------------------------------------- */

- Valnir


----- Original Message ----- 
From: "Rick St Jean" <[EMAIL PROTECTED]>
To: "Valnir" <[EMAIL PROTECTED]>; <[email protected]>
Sent: Tuesday, July 27, 2004 2:47 PM
Subject: Re: Finding Resets.


> I know this is really rough, but here goes.  I tried to whip this up
> quickly, since you
> guys have been so helpful. (untested but should get you close)
>
> void do_checkreset(CHAR_DATA * ch, char *argument)
>          {
>          int vnum, lookfor;
>          AREA_DATA *pArea;
>          RESET_DATA *pReset;
>          MOB_INDEX_DATA *pMob = NULL;
>          OBJ_INDEX_DATA *pObj;
>          ROOM_INDEX_DATA *pRoom;
>          char arg1[MAX_INPUT_LENGTH];
>          char arg2[MAX_INPUT_LENGTH];
>
>          one_argument(argument, arg1);
>          one_argument(argument, arg2);
>
>          if (arg1[0] == '\0' || !is_number(arg2))
>                  {
>                  send_to_char("checkreset <obj|mob> <vnum>\n\r", ch);
>                  return;
>                  }
>
>          lookfor = atoi(arg2);
>
>          for (pArea = area_first; pArea; pArea = pArea->next)
>                  {
>                  for (vnum = pArea->min_vnum; vnum <= pArea->max_vnum;
vnum++)
>                          {
>                          if (!(pRoom = get_room_index(vnum)))
>                          continue;
>
>                          for (pReset = pRoom->reset_first; pReset; pReset
=
> pReset->next)
>                                  {
>                                  switch (pReset->command)
>                                          {
>                                          case 'M':
>                                          if ((pMob =
> get_mob_index(pReset->arg1)) && !str_cmp(arg1, "mob") && pMob->vnum ==
lookfor)
>                                                  {
>                                                  bugf("Mob reset found -
> room %d.", pRoom->vnum );
>                                                  }
>                                          break;
>
>                                          case 'O':
>                                          if ((pObj =
> get_obj_index(pReset->arg1)) !str_cmp(arg1, "obj") && pObj->vnum ==
lookfor)
>                                                  {
>                                                  bugf("Convert_objects:
> 'O': bad vnum %d.", pReset->arg1);
>                                                  }
>                                          break;
>                                          }
>                                  }
>                          }
>                  }
>          }
>
>
>
>
> At 12:49 PM 7/27/2004, Valnir wrote:
> >I have gone through and made several OLC functions for my mud, including
> >oedit->delete, redit->delete, medit->delete, and even aedit->delete. I
have
> >run into the occasional issue though where I miss a reset when deleting a
> >mob or object. Does anyone know of an easy way to find if a VNUM is reset
in
> >any loaded area?
> >
> >- Valnir
> >
> >
> >
> >--
> >ROM mailing list
> >[email protected]
> >http://www.rom.org/cgi-bin/mailman/listinfo/rom
>
>


Reply via email to