void *me

From: Jeremy Elson (jelson@blaze.cs.jhu.edu)
Date: 06/19/94

Hey, I just had a great idea.  The SPECIAL() macro (and corresponding calls)
for special procedure now has 4 arguments instead of 3.  The new (2nd)
argument is void *me, which is a pointer to the mob/room/obj whose specproc
has been activated (kind of like the "this" pointer in C++).

The purpose is simply to make coding easier for specprocs such as the
receptionist and shopkeepers.  The current method is to messily search
through the room for a MOB with the appropriate spec-proc; now, you just
use the 'me' pointer instead.

As before, the value of 'ch' is a pointer to the MOB for pulse-activated
spec-procs, and the char responsible for specproc activation for
interpreter-activated specprocs.  The 'me' pointer is the MOB for
pulse-activated (just like ch); the win comes with interpreter-activated
specprocs when 'me' is a pointer to the mob.

Okay, maybe this isn't clear, so I'll demonstrate with some "before" and
"after" code:


  struct char_data *temp, *recep = NULL;

   for (temp = world[ch->in_room].people; temp&!recep; temp=temp->next_in_room)
      if (IS_MOB(temp) && mob_index[temp->nr].funct == gen_receptionist)
           recep = temp;

   if (!recep)
     log("Ingen recep");

   act("$n says hi to $N.", TRUE, recep, 0, ch, TO_ROOM);


   struct char_data *recep = (struct char_data *)me;

   act("$n says hi to $N.", TRUE, recep, 0, ch, TO_ROOM);



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