コード例 #1
0
ファイル: interp.c プロジェクト: rhencke/fuzzball
dbref
find_mlev(dbref prog, struct frame * fr, int st)
{
	if ((FLAGS(prog) & STICKY) && (FLAGS(prog) & HAVEN)) {
		if ((st > 1) && (TrueWizard(OWNER(prog))))
			return (find_mlev(fr->caller.st[st - 1], fr, st - 1));
	}
	if (MLevel(prog) < MLevel(OWNER(prog))) {
		return (MLevel(prog));
	} else {
		return (MLevel(OWNER(prog)));
	}
}
コード例 #2
0
ファイル: mfuns2.c プロジェクト: GlowMUCK/GlowMUCK
const char *
mfn_muf(MFUNARGS)
{
    char *ptr;
    struct inst *rv = NULL;
    dbref obj = mesg_dbref_raw(player, what, perms, argv[0]);

    if (obj == UNKNOWN)
	ABORT_MPI("MUF","Match failed");
    if (obj <= NOTHING || Typeof(obj) != TYPE_PROGRAM)
	ABORT_MPI("MUF","Bad program reference");
    if (!(FLAGS(obj) & LINK_OK) && !controls(perms,obj))
	ABORT_MPI("MUF",NOPERM_MESG);
    if ((mesgtyp & (MPI_ISLISTENER | MPI_ISLOCK)) && (MLevel(obj) < LM3))
	ABORT_MPI("MUF",NOPERM_MESG);

    if (++mpi_muf_call_levels > 18)
	ABORT_MPI("MUF","Too many call levels");

    strcpy(match_args, argv[1]);
    ptr = get_mvar("how");
    strcpy(match_cmdname, ptr);
    strcat(match_cmdname, "(MPI)");
    rv = interp(player, DBFETCH(player)->location,
		obj, perms, PREEMPT, STD_HARDUID, 1);

    mpi_muf_call_levels--;

    if (!rv) return "";
    switch(rv->type) {
	case PROG_STRING:
	    if (rv->data.string) {
		strcpy(buf, rv->data.string->data);
		CLEAR(rv);
		return buf;
	    } else {
		CLEAR(rv);
		return "";
	    }
	    break;
	case PROG_INTEGER:
	    sprintf(buf, "%d", rv->data.number);
	    CLEAR(rv);
	    return buf;
	    break;
	case PROG_OBJECT:
	    ptr = ref2str(rv->data.objref, buf);
	    CLEAR(rv);
	    return ptr;
	    break;
	default:
	    CLEAR(rv);
	    return "";
	    break;
    }

    return "";
}
コード例 #3
0
ファイル: create.c プロジェクト: CyberLeo/protomuck
/*
 * do_attach()
 *
 * This routine attaches a previously existing action to a source object.
 * The action will not do anything unless it is LINKed.
 *
 */
void
do_attach(int descr, dbref player, const char *action_name,
          const char *source_name)
{
    dbref action, source;
    dbref loc;                  /* player's current location */
    struct match_data md;
    char buf[BUFFER_LEN];

    if ((loc = DBFETCH(player)->location) == NOTHING)
        return;

    if (tp_db_readonly) {
        anotify_nolisten2(player, CFAIL DBRO_MESG);
        return;
    }

    if (!*action_name || !*source_name) {
        anotify_nolisten2(player,
                          CINFO
                          "You must specify an action name and a source object.");
        return;
    }
    init_match(descr, player, action_name, TYPE_EXIT, &md);
    match_all_exits(&md);
    match_registered(&md);
    match_absolute(&md);

    if ((action = noisy_match_result(&md)) == NOTHING)
        return;

    if (Typeof(action) != TYPE_EXIT) {
        anotify_nolisten2(player, CINFO "That's not an action.");
        return;
    } else if (!controls(player, action)) {
        anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
        return;
    }
    if (((source = parse_source(descr, player, source_name)) == NOTHING)
        || Typeof(source) == TYPE_PROGRAM)
        return;

    if (!unset_source(player, loc, action)) {
        return;
    }
    set_source(player, action, source);
    sprintf(buf, CSUCC "Action %s re-attached to %s.",
            unparse_object(player, action), NAME(source));
    anotify_nolisten2(player, buf);
    if (MLevel(action)) {
        SetMLevel(action, 0);
        anotify_nolisten2(player, CINFO "Action priority Level reset to zero.");
    }
}
コード例 #4
0
ファイル: predicates.c プロジェクト: nekosune/protomuck
/* determines if a player can set a flag based on permission level 
 * 0 indicates they can, 1 indicates they cannot. Only checks flagset2.
 */
bool
restricted2(dbref player, dbref thing, object_flag_type flag)
{
    switch (flag) {
        case F2GUEST:
            return (!Mage(OWNER(player)));
            break;
        case F2LOGWALL:
            return (!Arch(OWNER(player)));
        case F2HIDDEN: /* HIDDEN is now also EXTPERMS for programs */
            if (Typeof(thing) == TYPE_PROGRAM) {
                return !controls(player, thing);
            } else { 
                if (Typeof(thing) == TYPE_PLAYER)
                    return (!Arch(OWNER(player)) && !(POWERS(player) & POW_HIDE));
                else
                    return 1;
            }
        case F2ANTIPROTECT:
            if (Typeof(thing) == TYPE_PLAYER)
                return (!Boy(OWNER(player)));
            else
                return 1;
#ifdef CONTROLS_SUPPORT
        case F2CONTROLS:
            /* only by W4.  Not even by things they own. */
            if (Typeof(thing) == TYPE_PLAYER)
                return (!Boy(player));
            if (Typeof(thing) == TYPE_PROGRAM)
                return (!Wizard(player));
            /* anything else, if I truly control it. */
            return !truecontrols(player, thing);
            break;
#endif
        case F2MOBILE:
            return !(MLevel(OWNER(player)) >= tp_userflag_mlev);
            break;
        case F2SUSPECT:
            return (!Wizard(OWNER(player)));
        default:
            return 0;
            break;
    }
}
コード例 #5
0
ファイル: property.c プロジェクト: CyberLeo/protomuck
PropPtr
envprop_cmds(dbref *where, const char *propname, int typ)
{
    PropPtr temp;

    while (*where != NOTHING) {
        if (typ ? 1
            : ((FLAG2(*where) & F2COMMAND) && !(FLAG2(*where) & F2NO_COMMAND)
               && ((FLAGS(OWNER(*where)) & BUILDER)
                   || (MLevel(OWNER(*where)) >= LMAGE)))) {
            temp = get_property(*where, propname);
#ifdef DISKBASE
            if (temp)
                propfetch(*where, temp);
#endif
            if (temp)
                return temp;
        }
        *where = getparent(*where);
    }
    return NULL;
}
コード例 #6
0
ファイル: tune.c プロジェクト: CyberLeo/protomuck
void
tune_show_bool(dbref player, char *name)
{
    int total = 0;
    const char *lastname = NULL;
    char buf[BUFFER_LEN + 50];
    struct tune_bool_entry *tbool = tune_bool_list;

    while (tbool->name) {
        strcpy(buf, tbool->name);
        if (MLevel(OWNER(player)) >= tbool->readmlev) {
            sprintf(buf, SYSWHITE "(bool) " SYSRED "%c" SYSGREEN "%-24s"
                    SYSRED " = " SYSBLUE "%s",
                    (WLevel(OWNER(player)) >= tbool->writemlev) ? ' ' : '-',
                    tbool->name, ((*tbool->boolv) ? "yes" : "no"));
            lastname = tbool->name;
            anotify_nolisten2(player, buf);
            total++;
        }
        tbool++;
    }
    anotify_fmt(player, CINFO "%d bool-parm%s listed.", total,
                (total == 1) ? "" : "s");
}
コード例 #7
0
ファイル: tune.c プロジェクト: CyberLeo/protomuck
void
tune_show_refs(dbref player, char *name)
{
    int total = 0;
    const char *lastname = NULL;
    char buf[BUFFER_LEN + 50];
    struct tune_ref_entry *tref = tune_ref_list;

    while (tref->name) {
        strcpy(buf, tref->name);
        if (MLevel(OWNER(player)) >= tref->readmlev) {
            sprintf(buf, SYSYELLOW "(ref)  " SYSRED "%c" SYSGREEN "%-24s"
                    SYSRED " = %s",
                    (WLevel(OWNER(player)) >= tref->writemlev) ? ' ' : '-',
                    tref->name, ansi_unparse_object(player, *tref->ref));
            lastname = tref->name;
            anotify_nolisten2(player, buf);
            total++;
        }
        tref++;
    }
    anotify_fmt(player, CINFO "%d ref-parm%s listed.", total,
                (total == 1) ? "" : "s");
}
コード例 #8
0
ファイル: tune.c プロジェクト: CyberLeo/protomuck
void
tune_show_vals(dbref player, char *name)
{
    int total = 0;
    const char *lastname = NULL;
    char buf[BUFFER_LEN + 50];
    struct tune_val_entry *tval = tune_val_list;

    while (tval->name) {
        strcpy(buf, tval->name);
        if (MLevel(OWNER(player)) >= tval->readmlev) {
            sprintf(buf, SYSGREEN "(int)  " SYSRED "%c" SYSGREEN "%-24s"
                    SYSRED " = " SYSYELLOW "%d",
                    (WLevel(OWNER(player)) >= tval->writemlev) ? ' ' : '-',
                    tval->name, *tval->val);
            lastname = tval->name;
            anotify_nolisten2(player, buf);
            total++;
        }
        tval++;
    }
    anotify_fmt(player, CINFO "%d int-parm%s listed.", total,
                (total == 1) ? "" : "s");
}
コード例 #9
0
ファイル: tune.c プロジェクト: CyberLeo/protomuck
void
tune_show_times(dbref player, char *name)
{
    int total = 0;
    const char *lastname = NULL;
    char buf[BUFFER_LEN + 50];
    struct tune_time_entry *ttim = tune_time_list;

    while (ttim->name) {
        strcpy(buf, ttim->name);
        if (MLevel(OWNER(player)) >= ttim->readmlev) {
            sprintf(buf, SYSPURPLE "(time) " SYSRED "%c" SYSGREEN "%-24s"
                    SYSRED " = " SYSPURPLE "%s",
                    (WLevel(OWNER(player)) >= ttim->writemlev) ? ' ' : '-',
                    ttim->name, timestr_full(*ttim->tim));
            lastname = ttim->name;
            anotify_nolisten2(player, buf);
            total++;
        }
        ttim++;
    }
    anotify_fmt(player, CINFO "%d time-parm%s listed.", total,
                (total == 1) ? "" : "s");
}
コード例 #10
0
ファイル: tune.c プロジェクト: CyberLeo/protomuck
void
tune_show_strings(dbref player, char *name)
{
    int total = 0;
    const char *lastname = NULL;
    char buf[BUFFER_LEN + 50], tbuf[BUFFER_LEN];
    struct tune_str_entry *tstr = tune_str_list;

    while (tstr->name) {
        strcpy(buf, tstr->name);
        if (MLevel(OWNER(player)) >= tstr->readmlev) {
            sprintf(buf, SYSCYAN "(str)  " SYSRED "%c" SYSGREEN "%-24s"
                    SYSRED " = " SYSCYAN "%.4096s",
                    (WLevel(OWNER(player)) >= tstr->writemlev) ? ' ' : '-',
                    tstr->name, tct(*tstr->str, tbuf));
            lastname = tstr->name;
            anotify_nolisten2(player, buf);
            total++;
        }
        tstr++;
    }
    anotify_fmt(player, CINFO "%d string-parm%s listed.", total,
                (total == 1) ? "" : "s");
}
コード例 #11
0
ファイル: interp.c プロジェクト: rhencke/fuzzball
struct frame *
interp(int descr, dbref player, dbref location, dbref program,
	   dbref source, int nosleeps, int whichperms, int forced_pid)
{
	struct frame *fr;
	int i;

	if (!MLevel(program) || !MLevel(OWNER(program)) ||
		((source != NOTHING) && !TrueWizard(OWNER(source)) &&
		 !can_link_to(OWNER(source), TYPE_EXIT, program))) {
		notify_nolisten(player, "Program call: Permission denied.", 1);
		return 0;
	}
	if (free_frames_list) {
		fr = free_frames_list;
		free_frames_list = fr->next;
	} else {
		fr = (struct frame *) malloc(sizeof(struct frame));
	}
	fr->next = NULL;
	fr->pid = forced_pid ? forced_pid : top_pid++;
	fr->descr = descr;
	fr->multitask = nosleeps;
	fr->perms = whichperms;
	fr->already_created = 0;
	fr->been_background = (nosleeps == 2);
	fr->trig = source;
	fr->events = NULL;
	fr->timercount = 0;
	fr->started = time(NULL);
	fr->instcnt = 0;
	fr->skip_declare = 0;
	fr->wantsblanks = 0;
	fr->caller.top = 1;
	fr->caller.st[0] = source;
	fr->caller.st[1] = program;

	fr->system.top = 1;
	fr->system.st[0].progref = 0;
	fr->system.st[0].offset = 0;

	fr->waitees = NULL;
	fr->waiters = NULL;

	fr->fors.top = 0;
	fr->fors.st = NULL;
	fr->trys.top = 0;
	fr->trys.st = NULL;

	fr->errorstr = NULL;
	fr->errorinst = NULL;
	fr->errorprog = NOTHING;
	fr->errorline = 0;

	fr->rndbuf = NULL;
	fr->dlogids = NULL;

	fr->argument.top = 0;
	fr->pc = PROGRAM_START(program);
	fr->writeonly = ((source == -1) || (Typeof(source) == TYPE_ROOM) ||
					 ((Typeof(source) == TYPE_PLAYER) && (!online(source))) ||
					 (FLAGS(player) & READMODE));
	fr->level = 0;
	fr->error.is_flags = 0;

	/* set basic local variables */

	fr->svars = NULL;
	fr->lvars = NULL;
	for (i = 0; i < MAX_VAR; i++) {
		fr->variables[i].type = PROG_INTEGER;
		fr->variables[i].data.number = 0;
	}

	fr->brkpt.force_debugging = 0;
	fr->brkpt.debugging = 0;
	fr->brkpt.bypass = 0;
	fr->brkpt.isread = 0;
	fr->brkpt.showstack = 0;
	fr->brkpt.dosyspop = 0;
	fr->brkpt.lastline = 0;
	fr->brkpt.lastpc = 0;
	fr->brkpt.lastlisted = 0;
	fr->brkpt.lastcmd = NULL;
	fr->brkpt.breaknum = -1;

	fr->brkpt.lastproglisted = NOTHING;
	fr->brkpt.proglines = NULL;

	fr->brkpt.count = 1;
	fr->brkpt.temp[0] = 1;
	fr->brkpt.level[0] = -1;
	fr->brkpt.line[0] = -1;
	fr->brkpt.linecount[0] = -2;
	fr->brkpt.pc[0] = NULL;
	fr->brkpt.pccount[0] = -2;
	fr->brkpt.prog[0] = program;

	fr->proftime.tv_sec = 0;
	fr->proftime.tv_usec = 0;
	fr->totaltime.tv_sec = 0;
	fr->totaltime.tv_usec = 0;

	fr->variables[0].type = PROG_OBJECT;
	fr->variables[0].data.objref = player;
	fr->variables[1].type = PROG_OBJECT;
	fr->variables[1].data.objref = location;
	fr->variables[2].type = PROG_OBJECT;
	fr->variables[2].data.objref = source;
	fr->variables[3].type = PROG_STRING;
	fr->variables[3].data.string = (!*match_cmdname) ? 0 : alloc_prog_string(match_cmdname);

	if (PROGRAM_CODE(program)) {
		PROGRAM_INC_PROF_USES(program);
	}
	PROGRAM_INC_INSTANCES(program);
	push(fr->argument.st, &(fr->argument.top), PROG_STRING, *match_args ?
		 MIPSCAST alloc_prog_string(match_args) : 0);
	return fr;
}
コード例 #12
0
ファイル: tune.c プロジェクト: CyberLeo/protomuck
void
tune_display_parms(dbref player, char *name)
{
    int total = 0;
    const char *lastname = NULL;
    char buf[BUFFER_LEN + 50], tbuf[BUFFER_LEN];
    struct tune_str_entry *tstr = tune_str_list;
    struct tune_time_entry *ttim = tune_time_list;
    struct tune_val_entry *tval = tune_val_list;
    struct tune_ref_entry *tref = tune_ref_list;
    struct tune_bool_entry *tbool = tune_bool_list;

    while (tstr->name) {
        strcpy(buf, tstr->name);
        if ((MLevel(OWNER(player)) >= tstr->readmlev) &&
            (!*name || equalstr(name, buf))) {
            sprintf(buf, SYSCYAN "(str)  " SYSRED "%c" SYSGREEN "%-24s"
                    SYSRED " = " SYSCYAN "%.4096s",
                    (WLevel(OWNER(player)) >= tstr->writemlev) ? ' ' : '-',
                    tstr->name, tct(*tstr->str, tbuf));
            lastname = tstr->name;
            anotify_nolisten2(player, buf);
            total++;
        }
        tstr++;
    }

    while (ttim->name) {
        strcpy(buf, ttim->name);
        if ((MLevel(OWNER(player)) >= ttim->readmlev) &&
            (!*name || equalstr(name, buf))) {
            sprintf(buf, SYSPURPLE "(time) " SYSRED "%c" SYSGREEN "%-24s"
                    SYSRED " = " SYSPURPLE "%s",
                    (WLevel(OWNER(player)) >= ttim->writemlev) ? ' ' : '-',
                    ttim->name, timestr_full(*ttim->tim));
            lastname = ttim->name;
            anotify_nolisten2(player, buf);
            total++;
        }
        ttim++;
    }

    while (tval->name) {
        strcpy(buf, tval->name);
        if ((MLevel(OWNER(player)) >= tval->readmlev) &&
            (!*name || equalstr(name, buf))) {
            sprintf(buf, SYSGREEN "(int)  " SYSRED "%c" SYSGREEN "%-24s"
                    SYSRED " = " SYSYELLOW "%d",
                    (WLevel(OWNER(player)) >= tval->writemlev) ? ' ' : '-',
                    tval->name, *tval->val);
            lastname = tval->name;
            anotify_nolisten2(player, buf);
            total++;
        }
        tval++;
    }
    while (tref->name) {
        strcpy(buf, tref->name);
        if ((MLevel(OWNER(player)) >= tref->readmlev) &&
            (!*name || equalstr(name, buf))) {
            sprintf(buf, SYSYELLOW "(ref)  " SYSRED "%c" SYSGREEN "%-24s"
                    SYSRED " = %s",
                    (WLevel(OWNER(player)) >= tref->writemlev) ? ' ' : '-',
                    tref->name, ansi_unparse_object(player, *tref->ref));
            lastname = tref->name;
            anotify_nolisten2(player, buf);
            total++;
        }
        tref++;
    }

    while (tbool->name) {
        strcpy(buf, tbool->name);
        if ((MLevel(OWNER(player)) >= tbool->readmlev) &&
            (!*name || equalstr(name, buf))) {
            sprintf(buf, SYSWHITE "(bool) " SYSRED "%c" SYSGREEN "%-24s" SYSRED
                    " = " SYSBLUE "%s",
                    (WLevel(OWNER(player)) >= tbool->writemlev) ? ' ' : '-',
                    tbool->name, ((*tbool->boolv) ? "yes" : "no"));
            lastname = tbool->name;
            anotify_nolisten2(player, buf);
            total++;
        }
        tbool++;
    }
    if ((total == 1) && lastname && *lastname) {
        do_sysparm(player, lastname);
    } else {
        anotify_fmt(player, CINFO "%d sysparm%s listed.", total,
                    (total == 1) ? "" : "s");
        anotify(player,
                SYSYELLOW
                "@tune str, time, int, ref, or bool to list by data types.");
    }
}
コード例 #13
0
ファイル: predicates.c プロジェクト: nekosune/protomuck
bool
newcontrols(dbref who, dbref what, bool true_c)
{
    dbref index;

    /* No one controls invalid objects */
    /* if (what < 0 || what >= db_top)  -- not good enough */
    if (!OkObj(what) || !OkObj(who))
        return 0;

    /* Garbage controls nothing. */
    if (Typeof(who) == TYPE_GARBAGE)
        return 0;

    /* No one controls garbage */
    if (Typeof(what) == TYPE_GARBAGE)
        return 0;

    /* Puppets are based on owner */
    if (Typeof(who) != TYPE_PLAYER)
        who = OWNER(who);

    /* owners control their own stuff */
    /* Makes stuff faster here. -Hinoserm */
    if (who == OWNER(what))
        return 1;

    /* CONTROL_ALL controls all objects */
    if ((POWERS(who) & POW_CONTROL_ALL) && !Protect(what))
        return 1;

    /* CONTROL_MUF power controls all MUF objects */
    if ((POWERS(who) & POW_CONTROL_MUF) && (Typeof(what) == TYPE_PROGRAM)
        && (!(Protect(what))))
        return 1;

    /* Wizard controls (most) everything else */
    if (Wiz(who) && (!(Protect(what) && MLevel(OWNER(what)) >= LBOY)
                     || MLevel(who) >= LBOY))
        if (tp_fb_controls ? (MLevel(who) >= LWIZ)
            : (MLevel(who) >= MLevel(OWNER(what))))
            return 1;

    /* If realms control is enabled, the player will Control anything 
     * contained in a parent room he owns with at W1 bit or higher on it.
     * This gives him power to affect any object in his w-bitted parent room.
     */

    /* 
     *  Read the manual (help CONTROLS) about this new stuff.
     */

#ifdef CONTROLS_SUPPORT
    if (!true_c) {
        if (controlsEx(who, what))
            return 1;

        if (tp_realms_control) {
            if (!tp_wiz_realms) {
                if (Typeof(what) != TYPE_PLAYER)
                    for (index = what; index != NOTHING; index = getloc(index))
                        if ((controlsEx(who, index))
                            && (Typeof(index) == TYPE_ROOM
                                && ((FLAGS(index) & BUILDER) || Mage(index))))
                            return 1;
            } else {
                if (Typeof(what) != TYPE_PLAYER)
                    for (index = what; index != NOTHING; index = getloc(index))
                        if ((controlsEx(who, index))
                            && (Typeof(index) == TYPE_ROOM && (Mage(index))))
                            return 1;
            }
        }
    } else {
#endif

        if (tp_realms_control && (Typeof(what) != TYPE_PLAYER))
            for (index = what; index != NOTHING; index = getloc(index))
                if ((OWNER(index) == who) && (Typeof(index) == TYPE_ROOM
                                              && Mage(index)))
                    return 1;
#ifdef CONTROLS_SUPPORT
    }
#endif

    return 0;
}
コード例 #14
0
ファイル: timequeue.c プロジェクト: hyena/fuzzball
void
listenqueue(int descr, dbref player, dbref where, dbref trigger, dbref what, dbref xclude,
			const char *propname, const char *toparg, int mlev, int mt, int mpi_p)
{
	const char *tmpchar;
	const char *pname, *sep, *ptr;
	dbref the_prog = NOTHING;
	char buf[BUFFER_LEN];
	char exbuf[BUFFER_LEN];
	char *ptr2;

	if (!(FLAGS(what) & LISTENER) && !(FLAGS(OWNER(what)) & ZOMBIE))
		return;

	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) {
			sep = tmpchar;
			while (*sep) {
				if (*sep == '\\') {
					sep++;
				} else if (*sep == '=') {
					break;
				}
				if (*sep)
					sep++;
			}
			if (*sep == '=') {
				for (ptr = tmpchar, ptr2 = buf; ptr < sep; *ptr2++ = *ptr++) ;
				*ptr2 = '\0';
				strcpyn(exbuf, sizeof(exbuf), toparg);
				if (!equalstr(buf, exbuf)) {
					tmpchar = NULL;
				} else {
					tmpchar = ++sep;
				}
			}
		}

		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 (the_prog == AMBIGUOUS) {
				if (mpi_p) {
					add_mpi_event(1, descr, player, where, trigger, tmpchar + 1,
								  (mt ? "Listen" : "Olisten"), toparg, 1, (mt == 0),
								  Prop_Blessed(what, propname));
				}
			} else if (the_prog != NOTHING) {
				add_muf_queue_event(descr, player, where, trigger, the_prog, toparg,
									"(_Listen)", 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))) {
			*buf = '\0';
			strcatn(buf, sizeof(buf), pname);
			listenqueue(descr, player, where, trigger, what, xclude, buf,
						toparg, mlev, mt, mpi_p);
		}
	}
}
コード例 #15
0
ファイル: timequeue.c プロジェクト: hyena/fuzzball
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);
		}
	}
}