void notify_listeners(dbref who, dbref xprog, dbref obj, dbref room, const char *msg, int isprivate) { char buf[BUFFER_LEN]; dbref ref; if (obj == NOTHING) return; if (tp_listeners && (tp_listeners_obj || Typeof(obj) == TYPE_ROOM)) { listenqueue(-1, who, room, obj, obj, xprog, "_listen", msg, tp_listen_mlev, 1, 0); listenqueue(-1, who, room, obj, obj, xprog, "~listen", msg, tp_listen_mlev, 1, 1); listenqueue(-1, who, room, obj, obj, xprog, "~olisten", msg, tp_listen_mlev, 0, 1); } if (tp_zombies && Typeof(obj) == TYPE_THING && !isprivate) { if (FLAGS(obj) & VEHICLE) { if (getloc(who) == getloc(obj)) { char pbuf[BUFFER_LEN]; const char *prefix; memset(buf,0,BUFFER_LEN); /* Make sure the buffer is zeroed */ prefix = do_parse_prop(-1, who, obj, MESGPROP_OECHO, "(@Oecho)", pbuf, sizeof(pbuf), MPI_ISPRIVATE); if (!prefix || !*prefix) prefix = "Outside>"; snprintf(buf, sizeof(buf), "%s %.*s", prefix, (int)(BUFFER_LEN - 2 - strlen(prefix)), msg); ref = DBFETCH(obj)->contents; while (ref != NOTHING) { notify_filtered(who, ref, buf, isprivate); ref = DBFETCH(ref)->next; } } } } if (Typeof(obj) == TYPE_PLAYER || Typeof(obj) == TYPE_THING) notify_filtered(who, obj, msg, isprivate); }
void next_timequeue_event(void) { struct frame *tmpfr; int tmpbl, tmpfg; timequeue lastevent, event; int maxruns = 0; int forced_pid = 0; time_t rtime; time(&rtime); lastevent = tqhead; while ((lastevent) && (rtime >= lastevent->when) && (maxruns < 10)) { lastevent = lastevent->next; maxruns++; } while (tqhead && (tqhead != lastevent) && (maxruns--)) { if (tqhead->typ == TQ_MUF_TYP && tqhead->subtyp == TQ_MUF_READ) { break; } event = tqhead; tqhead = tqhead->next; process_count--; forced_pid = event->eventnum; event->eventnum = 0; if (event->typ == TQ_MPI_TYP) { char cbuf[BUFFER_LEN]; int ival; strcpyn(match_args, sizeof(match_args), event->str3 ? event->str3 : ""); strcpyn(match_cmdname, sizeof(match_cmdname), event->command ? event->command : ""); ival = (event->subtyp & TQ_MPI_OMESG) ? MPI_ISPUBLIC : MPI_ISPRIVATE; if (event->subtyp & TQ_MPI_BLESSED) { ival |= MPI_ISBLESSED; } if (event->subtyp & TQ_MPI_LISTEN) { ival |= MPI_ISLISTENER; do_parse_mesg(event->descr, event->uid, event->trig, event->called_data, "(MPIlisten)", cbuf, sizeof(cbuf), ival); } else if ((event->subtyp & TQ_MPI_SUBMASK) == TQ_MPI_DELAY) { do_parse_mesg(event->descr, event->uid, event->trig, event->called_data, "(MPIdelay)", cbuf, sizeof(cbuf), ival); } else { do_parse_mesg(event->descr, event->uid, event->trig, event->called_data, "(MPIqueue)", cbuf, sizeof(cbuf), ival); } if (*cbuf) { if (!(event->subtyp & TQ_MPI_OMESG)) { notify_filtered(event->uid, event->uid, cbuf, 1); } else { char bbuf[BUFFER_LEN]; dbref plyr; snprintf(bbuf, sizeof(bbuf), ">> %.4000s %.*s", NAME(event->uid), (int)(4000 - strlen(NAME(event->uid))), pronoun_substitute(event->descr, event->uid, cbuf)); plyr = DBFETCH(event->loc)->contents; for (; plyr != NOTHING; plyr = DBFETCH(plyr)->next) { if (Typeof(plyr) == TYPE_PLAYER && plyr != event->uid) notify_filtered(event->uid, plyr, bbuf, 0); } } } } else if (event->typ == TQ_MUF_TYP) { if (Typeof(event->called_prog) == TYPE_PROGRAM) { if (event->subtyp == TQ_MUF_DELAY) { /* Uncomment when DBFETCH "does" something */ /* FIXME: DBFETCH(event->uid); */ tmpbl = PLAYER_BLOCK(event->uid); tmpfg = (event->fr->multitask != BACKGROUND); interp_loop(event->uid, event->called_prog, event->fr, 0); if (!tmpfg) { PLAYER_SET_BLOCK(event->uid, tmpbl); } } else if (event->subtyp == TQ_MUF_TIMER) { struct inst temp; temp.type = PROG_INTEGER; temp.data.number = event->when; event->fr->timercount--; muf_event_add(event->fr, event->called_data, &temp, 0); } else if (event->subtyp == TQ_MUF_TREAD) { handle_read_event(event->descr, event->uid, NULL); } else { strcpyn(match_args, sizeof(match_args), event->called_data ? event->called_data : ""); strcpyn(match_cmdname, sizeof(match_cmdname), event->command ? event->command : ""); tmpfr = interp(event->descr, event->uid, event->loc, event->called_prog, event->trig, BACKGROUND, STD_HARDUID, forced_pid); if (tmpfr) { interp_loop(event->uid, event->called_prog, tmpfr, 0); } } } } event->fr = NULL; free_timenode(event); } }
void propqueue(int descr, dbref player, dbref where, dbref trigger, dbref what, dbref xclude, const char *propname, const char *toparg, int mlev, int mt) { const char *tmpchar; const char *pname; dbref the_prog; char buf[BUFFER_LEN]; char exbuf[BUFFER_LEN]; the_prog = NOTHING; tmpchar = NULL; /* queue up program referred to by the given property */ if (((the_prog = get_property_dbref(what, propname)) != NOTHING) || (tmpchar = get_property_class(what, propname))) { if ((tmpchar && *tmpchar) || the_prog != NOTHING) { if (tmpchar) { if (*tmpchar == '&') { the_prog = AMBIGUOUS; } else if (*tmpchar == NUMBER_TOKEN && number(tmpchar + 1)) { the_prog = (dbref) atoi(++tmpchar); } else if (*tmpchar == REGISTERED_TOKEN) { the_prog = find_registered_obj(what, tmpchar); } else if (number(tmpchar)) { the_prog = (dbref) atoi(tmpchar); } else { the_prog = NOTHING; } } else { if (the_prog == AMBIGUOUS) the_prog = NOTHING; } if (the_prog != AMBIGUOUS) { if (the_prog < 0 || the_prog >= db_top) { the_prog = NOTHING; } else if (Typeof(the_prog) != TYPE_PROGRAM) { the_prog = NOTHING; } else if ((OWNER(the_prog) != OWNER(player)) && !(FLAGS(the_prog) & LINK_OK)) { the_prog = NOTHING; } else if (MLevel(the_prog) < mlev) { the_prog = NOTHING; } else if (MLevel(OWNER(the_prog)) < mlev) { the_prog = NOTHING; } else if (the_prog == xclude) { the_prog = NOTHING; } } if (propq_level < 8) { propq_level++; if (the_prog == AMBIGUOUS) { char cbuf[BUFFER_LEN]; int ival; strcpyn(match_args, sizeof(match_args), ""); strcpyn(match_cmdname, sizeof(match_cmdname), toparg); ival = (mt == 0) ? MPI_ISPUBLIC : MPI_ISPRIVATE; if (Prop_Blessed(what, propname)) ival |= MPI_ISBLESSED; do_parse_mesg(descr, player, what, tmpchar + 1, "(MPIqueue)", cbuf, sizeof(cbuf), ival); if (*cbuf) { if (mt) { notify_filtered(player, player, cbuf, 1); } else { char bbuf[BUFFER_LEN]; dbref plyr; snprintf(bbuf, sizeof(bbuf), ">> %.4000s", pronoun_substitute(descr, player, cbuf)); plyr = DBFETCH(where)->contents; while (plyr != NOTHING) { if (Typeof(plyr) == TYPE_PLAYER && plyr != player) notify_filtered(player, plyr, bbuf, 0); plyr = DBFETCH(plyr)->next; } } } } else if (the_prog != NOTHING) { struct frame *tmpfr; strcpyn(match_args, sizeof(match_args), toparg ? toparg : ""); strcpyn(match_cmdname, sizeof(match_cmdname), "Queued event."); tmpfr = interp(descr, player, where, the_prog, trigger, BACKGROUND, STD_HARDUID, 0); if (tmpfr) { interp_loop(player, the_prog, tmpfr, 0); } } propq_level--; } else { notify_nolisten(player, "Propqueue stopped to prevent infinite loop.", 1); } } } strcpyn(buf, sizeof(buf), propname); if (is_propdir(what, buf)) { strcatn(buf, sizeof(buf), "/"); while ((pname = next_prop_name(what, exbuf, sizeof(exbuf), buf))) { strcpyn(buf, sizeof(buf), pname); propqueue(descr, player, where, trigger, what, xclude, buf, toparg, mlev, mt); } } }