[CODE][HELP] Portal Spell crashes when portal fades

From: Brian (brian@IMI-BOTTLING.COM)
Date: 03/20/98


I've used the portal code from the snippet site, but had to modify it to
work properly (It wasn't creating the Values correctly to be used correctly
by the "enter portal" command).

Anyways,  here's what happens.  I cast portal at a person or mob.  It opens
a portal at both ends, and I can enter each side and be moved to the other.
Everything's fine.  I stat the portal and see it's got a timer value of 5
(I'm a 54 level Imp).  However, it crashes the next tick after the portal
is created.  Using GDB, it crashes in limits.c when it's checking to
extract the portal.  It shouldn't be TRYING to extract the portal until 5
ticks have gone by, but... well, here's some info maybe someone can help me
with...

Here's the GDB output:

 -------------------------------------

GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.16 (i586-unknown-linux), Copyright 1996 Free Software Foundation,
Inc...
Core was generated by `bin/circle 2001'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libc.so.5.3.12...done.
Reading symbols from /lib/ld-linux.so.1...done.
#0  0x804be40 in act (str=0x80b2036 "A glowing portal fades from
existence.",
    hide_invisible=1, ch=0x2dffe, obj=0x83205a0, vict_obj=0x0, type=1)
    at comm.c:1947
1947      if (ch && ch->in_room != NOWHERE)
(gdb) info locals
ch = (char_data *) 0x2dffe
type = 1
to = (char_data *) 0x0
sleep = 0
(gdb)

---------------------------------------------------------------------------
----------------

Looks like the "to" is null... but I don't know how to fix it. :(

It's also calling line 1947 in comm.c.  I don't know why, but here's that
area of code:

-------------------------------------- comm.c in void
act() ----------------------------------------

   if (type == TO_VICT) {
    if ((to = (struct char_data *) vict_obj) && SENDOK(to))
      perform_act(str, ch, obj, vict_obj, to);
    return;
  }
  /* ASSUMPTION: at this point we know type must be TO_NOTVICT or TO_ROOM
*/

  if (ch && ch->in_room != NOWHERE) /********* This is line 1947 ********/
    to = world[ch->in_room].people;
  else if (obj && obj->in_room != NOWHERE)
    to = world[obj->in_room].people;
  else {
    log("SYSERR: no valid target to act()!");
    return;
  }

---------------------------------------------------------------------------
---------------------

Here's the section of code in limits.c to extract the portals:

------------------------------------------
limits.c -----------------------------------------

    /* portal */

    if (GET_OBJ_TYPE(j) == ITEM_PORTAL) {
      if (GET_OBJ_TIMER(j) > 0)
          GET_OBJ_TIMER(j)--;
      if (!GET_OBJ_TIMER(j)) {
        act("A glowing portal fades from existance.",
             TRUE, world[j->in_room].people, j, 0, TO_ROOM);
        act("A glowing portal fades from existance.",
             TRUE, world[j->in_room].people, j, 0, TO_CHAR);
        extract_obj(j);
      }
    }

------------------------------------------ In
spells.c ---------------------------------------
ASPELL(spell_portal)
{
  struct obj_data *portal, *tportal;
  struct extra_descr_data *new_descr, *new_tdescr;
   sh_int location;
  char buf[80];
  location = world[victim->in_room].number;
  tportal = read_object(PORTAL_OBJ, VIRTUAL);

  if (ch == NULL || victim == NULL)
    return;

  /* create the portal */
  portal = read_object(PORTAL_OBJ, VIRTUAL);

/*  This following code worked fine on my FreeBSD setup, but not on the
actual
 *  Server running Linux... So it's commented out here.....

  if (ROOM_FLAGGED(location, ROOM_TUNNEL)) {
    send_to_char("There is no room in here to conjure a portal!\n\r", ch);
    extract_obj(tportal);
    extract_obj(portal);
     return;
  }
  if (ROOM_FLAGGED(location, ROOM_NOMAGIC)) {
    send_to_char("Your magic is foiled by an anti-magic barrier.\n\r", ch);
    extract_obj(tportal);
    extract_obj(portal);
    return;
  }

  if (MOB_FLAGGED(victim, MOB_NOPORTAL)) {
    send_to_char("You can not conjure a complete image of your
target.\r\n", ch$
    extract_obj(tportal);
    extract_obj(portal);
    return;
   }
*/

  GET_OBJ_VAL(portal, 0) = -1;
  GET_OBJ_VAL(portal, 1) = world[victim->in_room].number;
  GET_OBJ_TIMER(portal) = (int) (GET_LEVEL(ch) / 10);
  CREATE(new_descr, struct extra_descr_data, 1);
  new_descr->keyword = str_dup("portal gate gateway");
  sprintf(buf, "You can barely make out %s.", world[victim->in_room].name);
  new_descr->description = str_dup(buf);
  new_descr->next = portal->ex_description;
  portal->ex_description = new_descr;
  obj_to_room(portal, ch->in_room);
  act("$n conjures a portal out of thin air.",
       TRUE, ch, 0, 0, TO_ROOM);
  act("You conjure a portal out of thin air.",
       TRUE, ch, 0, 0, TO_CHAR);

   /* create the portal at the other end */
  tportal = read_object(PORTAL_OBJ, VIRTUAL);
  GET_OBJ_VAL(tportal, 0) = -1;
  GET_OBJ_VAL(tportal, 1) = world[ch->in_room].number;
  GET_OBJ_TIMER(tportal) = (int) (GET_LEVEL(ch) / 10);
  CREATE(new_tdescr, struct extra_descr_data, 1);
  new_tdescr->keyword = str_dup("portal gate gateway");
  sprintf(buf, "You can barely make out %s.", world[ch->in_room].name);
  new_tdescr->description = str_dup(buf);
  new_tdescr->next = tportal->ex_description;
  tportal->ex_description = new_tdescr;
  obj_to_room(tportal, victim->in_room);
  act("A glowing portal appears out of thin air.",
       TRUE, victim, 0, 0, TO_ROOM);
  act("A glowing portal opens here for you.",
       TRUE, victim, 0, 0, TO_CHAR);
}

---------------------------------------------------------------------------
--------------------------------

As I mentioned before, all works well with the spell initially.  It's just
the tick after that makes everything go BOOM...

Anyone see anything wrong?

 - Brian


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



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