Re: [CODE][BUGGY CODE :P][OBJPURGE ------[fixed]

From: Invincibill (bill@longboys.net)
Date: 01/13/99


Ronny Iversen wrote:
>
> Wrote a function to extract all objects of certain virtual number,
> only problem is it goes loco whenever the objects r extracted, if I
> comment out
> the extract(i) it works fine, can anybody tell me why? :)

I rewrote it, made a couple mods for readability. it works just fine on
mine.

replace the PCOMM with ACMD and the OBJECT with struct obj_data
PCOMM(do_purge_obj) {
  OBJECT *i;
  int number, r_num;
  bool found = FALSE;

  one_argument(argument, arg);

  if(!*arg) {
    send_to_char("I need an object to purge.\n\r", ch);
    return;
  }

  if (!isdigit(*arg)) {
    send_to_char("Usage: objpurge [vnum]\r\n", ch);
    return;
  }

  if ( (number = atoi(arg)) < 0) {
    send_to_char("A NEGATIVE number??\r\n", ch);
    return;
  }

  for (i = object_list; i; i = i->next) {
    if (GET_OBJ_VNUM(i) != number)
      continue;
    if (i->carried_by)
      act("$p burns into fine ashes and slips through your fingers.",
           FALSE, i->carried_by, i, 0, TO_CHAR);
    if ((i->in_room != NOWHERE) &&
        (world[i->in_room].people)) {
      act("$p is burned into fine ashes and slips through $n's
fingers.",
           TRUE, world[i->in_room].people, i, 0, TO_ROOM);
      act("$p is burned into fine ashes and slips through your
fingers.",
           TRUE, world[i->in_room].people, i, 0, TO_CHAR);
    }
    if (i->worn_by) {
      act("$p burns into fine ashes and is taken by the breeze.",
           FALSE, i->worn_by, i, 0, TO_CHAR);
      act("Your $p burns into fine ashes and is taken by the breeze.",
           FALSE, i->worn_by, i, 0, TO_ROOM);
    }

    extract_obj(i);
    found = TRUE;
  }
  if (found) {
    sprintf(buf, "%s objpurges all objects with vnum %d",
            GET_NAME(ch), number);
    mudlog(buf, BRF, LVL_GRGOD, TRUE);
  }
}
--
Weather forecast for today: Sunny & Mild
Weather forecast for tomorrow : Sunny & Mild
www.giftsgalore.com : www.longboys.net
telnet://undying.longboys.net:4000 http://undying.longboys.net


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST