[CODE] Events - My ch pointer has been violated! :)

From: Chuck Reed (creed@I-55.COM)
Date: 05/06/98


It seems that my *ch pointer gets dereferenced somewhere in my new event
type.  This is a complete copy of the event and all the code that goes with
it.  SOO, I'm warning you, if you don't feel like reading a little, delete
this message now.  Here we go:

ALL OF THIS IS AT THE BOTTOM OF EVENTS.C:

struct death_trap_type {
   struct char_data *ch;
}

EVENTFUNC(timed_dt)
{
  struct death_trap_type *dt = (struct death_trap_type *) event_obj;
  struct char_data *ch;
  void die(struct char_data *ch, struct char_data *killer);

  ch = dt->ch;

  GET_TIMED_DT(ch) = NULL;

  act("The gas in the room takes it's toll on you and you die!", FALSE,
       ch, 0, 0, TO_CHAR);
  act("$n drops dead from harmful toxins.", FALSE, ch, 0, 0, TO_NOTVICT);
  die(ch, NULL);
  if(event_obj)
    free(event_obj);
  return 0;
}

void call_timed_dt(struct char_data *ch)
{
   struct death_trap_type *dt;

   CREATE(dt, struct death_trap_type, 1);
   dt->ch = ch;
   GET_TIMED_DT(ch) = event_create(timed_dt, dt, 4);

}

Now, in events.h:

#define GET_TIMED_DT(ch)       ((ch)->timed_dt) /* I put it in the struct,
don't feel like writing it.*/

Now, in act.movement.c (do_simple_move) i called

   if(ch->in_room == certain_room)
      call_timed_dt(ch);

Any idea where the hell ch could be dereferenced?  Thanks for any help.


Chuck Reed     | "Jesus saves . . . . he passes to Moses.  |
creed@i-55.com |  Moses shoots, HE SCORES!"    -Unknown    |

     +------------------------------------------------------------+
     | 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