Re: [SPELL] Question about objects & owners. <Pine.BSI.3.95.980819154505.23994A-100000@shell1.cybercom.net>

From: Kevin Doherty (kdoherty@JURAI.NET)
Date: 08/19/98


Thus spake Ryan Gasper or Steven Arnold <dalamar@CYBERCOM.NET>:
>  Hello List.
>
>  I made a clone spell, that clones a piece of EQ or a weapon, and then
>fires off an event, and after so many minutes, it extracts the object.
>Everything works fine, but I am curious how to resolve a few things. If
>someone were to give the object to another player, how would I switch the
>ch pointer to the new owner? I need to do this because as the item fades,
>it gives messages to the caster. If the caster gives it away and quits,
>MUD will probably crash (I have not tested this because I assume thats
>what will happen). Is there a way to check to make sure the person that is
>either wielding it or in its inventory is the same as the ch pointer in
>the event structure?

While I don't have code in front of me, I believe there's a void * to the
event struct for that event within the event. That is, something like:

((struct my_clone_event *)(GET_CLONE_EVENT(clonedobj)->eventobj))->ch
  = new_ch;

Where GET_CLONE_EVENT is a macro expanding to the struct event * within
the given object. This is obviously rather ugly, I'd suggest adding a
function that would return the event struct when passed the actual event.
So something like this in event.c:

void *event_getobj(struct event *event) {
  assert(event != NULL);
  return event->eventobj;
}

Of course there's not much benefit from this except a marginal style
benefit to encourage access functions rather than fiddling with the
event's members directly.

In general, though, the line of code I wrote up top should work, though
you'll have to check the actual members of struct event.

--
Kevin Doherty, kdoherty@jurai.net
"Multiple exclamation marks are a sure sign of a diseased mind."
       -- Rincewind (from _Eric_)


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