/** Take an action on an object and trigger attributes. * \verbatim * executes the @attr, @oattr, @aattr for a command - gives a message * to the enactor and others in the room with the enactor, and executes * an action. We optionally load pe_regs into the queue. * \endverbatim * * \param player the enactor. * \param thing object being triggered. * \param what message attribute for enactor. * \param def default message to enactor. * \param owhat message attribute for others. * \param odef default message to others. * \param awhat action attribute to trigger. * \param loc location in which action is taking place. * \param pe_regs the pe_regs arguments for the evaluation/queueing * \param flags flags controlling type of interaction involved. * \retval 0 no attributes were present, only defaults were used if given. * \retval 1 some attributes were evaluated and used. */ int real_did_it(dbref player, dbref thing, const char *what, const char *def, const char *owhat, const char *odef, const char *awhat, dbref loc, PE_REGS *pe_regs, int flags, int an_flags) { char buff[BUFFER_LEN], *bp; int attribs_used = 0; NEW_PE_INFO *pe_info = NULL; ufun_attrib ufun; if (!pe_info) { pe_info = make_pe_info("pe_info-real_did_it2"); } loc = (loc == NOTHING) ? Location(player) : loc; /* only give messages if the location is good */ if (GoodObject(loc)) { /* message to player */ if (what && *what) { if (fetch_ufun_attrib (what, thing, &ufun, UFUN_LOCALIZE | UFUN_REQUIRE_ATTR | UFUN_IGNORE_PERMS)) { attribs_used = 1; if (!call_ufun(&ufun, buff, thing, player, pe_info, pe_regs) && buff[0]) notify_by(thing, player, buff); } else if (def && *def) notify_by(thing, player, def); } /* message to neighbors */ if (!DarkLegal(player)) { if (owhat && *owhat && fetch_ufun_attrib(owhat, thing, &ufun, UFUN_LOCALIZE | UFUN_REQUIRE_ATTR | UFUN_IGNORE_PERMS | UFUN_NAME)) { attribs_used = 1; if (!call_ufun_int (&ufun, buff, thing, player, pe_info, pe_regs, (void *) AName(player, an_flags, NULL)) && buff[0]) notify_except2(player, loc, player, thing, buff, flags); } else if (odef && *odef) { bp = buff; safe_format(buff, &bp, "%s %s", AName(player, an_flags, NULL), odef); *bp = '\0'; notify_except2(player, loc, player, thing, buff, flags); } } } if (pe_info) { free_pe_info(pe_info); } if (awhat && *awhat) attribs_used = queue_attribute_base(thing, awhat, player, 0, pe_regs, 0) || attribs_used; return attribs_used; }
static void process_leave_loc(dbref thing, dbref dest, dbref cause, int canhear, int hush) { dbref loc; int quiet, pattr, oattr, aattr; loc = Location(thing); if((loc == NOTHING) || (loc == dest)) return; if(dest == HOME) dest = Home(thing); /* * Run the LEAVE attributes in the current room if we meet any of * * * * * * * following criteria: * - The current room has wizard privs. * * - * * * Neither the current room nor the moving object are dark. * * - The * * * moving object can hear and does not hav wizard * privs. * EXCEPT * if * * we were called with the HUSH_LEAVE key. */ quiet = (!(Wizard(loc) || (!Dark(thing) && !Dark(loc)) || (canhear && !(Wizard(thing) && Dark (thing))))) || (hush & HUSH_LEAVE); oattr = quiet ? 0 : A_OLEAVE; aattr = quiet ? 0 : A_ALEAVE; pattr = (!mudconf.terse_movemsg && Terse(thing)) ? 0 : A_LEAVE; did_it(thing, loc, pattr, NULL, oattr, NULL, aattr, (char **) NULL, 0); /* * Do OXENTER for receiving room */ if((dest != NOTHING) && !quiet) did_it(thing, dest, 0, NULL, A_OXENTER, NULL, 0, (char **) NULL, 0); /* * Display the 'has left' message if we meet any of the following * * * * * * * criteria: * - Neither the current room nor the moving * object are * * * dark. * - The object can hear and is not a dark * wizard. */ if(!quiet) if((!Dark(thing) && !Dark(loc)) || (canhear && !(Wizard(thing) && Dark(thing)))) { notify_except2(loc, thing, thing, cause, tprintf("%s has left.", Name(thing))); } }
/* * --------------------------------------------------------------------------- * * process_enter_loc: Generate messages and actions resulting from entering * * a place. */ static void process_enter_loc(dbref thing, dbref src, dbref cause, int canhear, int hush) { dbref loc; int quiet, pattr, oattr, aattr; loc = Location(thing); if((loc == NOTHING) || (loc == src)) return; /* * Run the ENTER attributes in the current room if we meet any of * * * * * * * following criteria: * - The current room has wizard privs. * * - * * * Neither the current room nor the moving object are dark. * * - The * * * moving object can hear and does not hav wizard * privs. * EXCEPT * if * * we were called with the HUSH_ENTER key. */ quiet = (!(Wizard(loc) || (!Dark(thing) && !Dark(loc)) || (canhear && !(Wizard(thing) && Dark (thing))))) || (hush & HUSH_ENTER); oattr = quiet ? 0 : A_OENTER; aattr = quiet ? 0 : A_AENTER; pattr = (!mudconf.terse_movemsg && Terse(thing)) ? 0 : A_ENTER; did_it(thing, loc, pattr, NULL, oattr, NULL, aattr, (char **) NULL, 0); /* * Do OXLEAVE for sending room */ if((src != NOTHING) && !quiet) did_it(thing, src, 0, NULL, A_OXLEAVE, NULL, 0, (char **) NULL, 0); /* * Display the 'has arrived' message if we meet all of the following * * * * * criteria: * - The moving object can hear. * - The object * is * * not * a dark wizard. */ if(!quiet && canhear && !(Dark(thing) && Wizard(thing))) { notify_except2(loc, thing, thing, cause, tprintf("%s has arrived.", Name(thing))); } }