On Fri, 13 Dec 1996, Terry Valladon wrote:
> does anyone have a way for me to send OBJ's on the mud...
> IE you go to the post office and type
I just wrote this code (finished about 30 seconds ago :)) upon
reading this message. It turned out to be quite easy and quick,
so no-one should have any problems figuring it out. A few easy
tests reveal that it's working (perfectly?) correct.
Here goes:
structs.h
=========
// In struct descriptor_data, add:
sh_int mail_vnum; // mailing obj of this vnum
mail.h
======
// In struct header_data_type, add:
sh_int vnum;
// Above the struct header_data_type, find the function prototypes and
// change the following the prototypes for store_mail() and
// read_delete() to:
void store_mail(long to, long from, sh_int vnum, char *message_pointer);
char *read_delete(long recipient, int *obj_vnum);
mail.c
======
// change store_mail() to:
void store_mail(long to, long from, sh_int vnum, char *message_pointer)
{
// add this line just below "header.header_data.to = to;" in store_mail
header.header_data.vnum = vnum;
// change read_delete() to:
char *read_delete(long recipient, int *obj_vnum)
{
// add this line just before the sprintf(buf, ...); call:
*obj_vnum = header.header_data.vnum;
// in postmaster_send_mail(), add:
char buf2[256];
struct obj_data *obj;
extern struct index_data *obj_index;
// and change "one_argument(arg, buf);" to:
two_arguments(arg, buf, buf2);
// after the "if ((recipient = get_id_by_name(buf)) < 0) {...}" block,
// add:
if (*buf2 && (obj = get_obj_in_list_vis(ch, buf2, ch->carrying))) {
act("$n takes $p and readies it for packing.",
FALSE, mailman, obj, ch, TO_VICT);
extract_obj(obj);
ch->desc->mail_vnum = GET_OBJ_VNUM(obj);
}
// you might want to make it cost more money for sending objects, or
// you could even base it upon the weight (STAMP_PRICE+(weight*10))?
// I didn't bother to
// in postmaster_receive_mail(), add:
struct obj_data *sent_obj;
int obj_vnum;
// change "obj->action_description = read_delete(GET_IDNUM(ch));" to:
obj->action_description = read_delete(GET_IDNUM(ch), &obj_vnum);
// after "act("$N gives $n a piece of mail", FALSE, ch, 0, mailman,
// TO_ROOM);" add:
if (obj_vnum != NOTHING && real_object(obj_vnum) != NOTHING) {
sent_obj = read_object(real_object(obj_vnum), REAL);
obj_to_char(sent_obj, ch);
act("$n gives you $p.", FALSE, mailman, sent_obj, ch, TO_VICT);
act("$n gives $N $p.", FALSE, mailman, sent_obj, ch, TO_NOTVICT);
}
modify.c
========
// find the call to store_mail() and change it to:
store_mail(d->mail_to, GET_IDNUM(d->character), d->mail_vnum, *d->str);
That should be it. I might have forgotten something, so don't go about
mindlessly. If someone wants me to, I'll make a patch out of it, but I
don't think it's neccessary. Nothing really major, there.
BTW, as with most of the code I post to this list, this is written on
more or less the spur of the moment. I have no intention of using this
code in my current MUD project. I did bother to test this code, though,
and it worked fine transfering the items when the mail was sent and
received during the same boot, and also after a reboot. But since it's
largely up to how well you interpret what I've said and how well I've
presented this information, I can't garuantee that it'll work for you.
Hopefully you'll get it to work. If you really need a patch made, I'll
make for stock bpl11.
There is probably a hundred other ways to do this samething, but I found
this way the easiest, quickest, and smallest implementation. Good luck!
--
Daniel Koepke
dkoepke@california.com
Forgive me father, for I am sin.
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://cspo.queensu.ca/~fletcher/Circle/list_faq.html |
+-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST