/* This routine determines if a player is editing or running an interactive command. It does it by checking the frame pointer field of the player --- if the program counter is NULL, then the player is not running anything The reason we don't just check the pointer but check the pc too is because I plan to leave the frame always on to save the time required allocating space each time a program is run. */ void interactive(int descr, dbref player, const char *command) { if (FLAGS(player) & READMODE) { /* * process command, push onto stack, and return control to forth * program */ handle_read_event(descr, player, command); } else { editor(descr, player, command); } }
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); } }