Пример #1
0
const char *
safegetprop_strict(dbref player, dbref what, dbref perms, const char *inbuf)
{
    const char *ptr;
    char  bbuf[BUFFER_LEN];
    static char  vl[32];

    if (!inbuf) {
        notify_nolisten(player, "PropFetch: Propname required.", 1);
        return NULL;
    }
    while (*inbuf == PROPDIR_DELIMITER)
        inbuf++;
    if (!*inbuf) {
        notify_nolisten(player, "PropFetch: Propname required.", 1);
        return NULL;
    }
    strcpy(bbuf, inbuf);
    ptr = get_property_class(what, bbuf);
    if (!ptr) {
        int i;

	i = get_property_value(what, bbuf);
	if (!i) {
	    dbref dd;

	    dd = get_property_dbref(what, bbuf);
	    if (dd == NOTHING) {
		*vl = '\0';
		ptr = vl;
		return ptr;
	    } else {
		sprintf(vl, "#%d", dd);
		ptr = vl;
	    }
	} else {
	    sprintf(vl, "%d", i);
	    ptr = vl;
	}
    }

#ifdef COMPRESS
    ptr = uncompress(ptr);
#endif

    if (!Wizperms(perms)) {
        if (Prop_Hidden(bbuf)) {
            notify_nolisten(player, "PropFetch: Permission denied.", 1);
            return NULL;
        }
//        if (Prop_Private(bbuf) && OWNER(perms) != OWNER(what)) {
        if (Prop_Private(bbuf) && !controls_nowizperm(OWNER(perms), what)) {
            notify_nolisten(player, "PropFetch: Permission denied.", 1);
            return NULL;
        }
    }
    return ptr;
}
Пример #2
0
const char *
safegetprop_strict(dbref player, dbref what, dbref perms, const char *inbuf, int mesgtyp, int* blessed)
{
	const char *ptr;
	char bbuf[BUFFER_LEN];
	static char vl[32];

	*blessed = 0;

	if (!inbuf) {
		notify_nolisten(player, "PropFetch: Propname required.", 1);
		return NULL;
	}
	while (*inbuf == PROPDIR_DELIMITER)
		inbuf++;
	if (!*inbuf) {
		notify_nolisten(player, "PropFetch: Propname required.", 1);
		return NULL;
	}
	strcpyn(bbuf, sizeof(bbuf), inbuf);

	if (Prop_System(bbuf))
	{
		notify_nolisten(player, "PropFetch: Permission denied.", 1);
		return NULL;
	}

	if (!(mesgtyp & MPI_ISBLESSED)) {
		if (Prop_Hidden(bbuf)) {
			notify_nolisten(player, "PropFetch: Permission denied.", 1);
			return NULL;
		}
		if (Prop_Private(bbuf) && OWNER(perms) != OWNER(what)) {
			notify_nolisten(player, "PropFetch: Permission denied.", 1);
			return NULL;
		}
	}

	ptr = get_property_class(what, bbuf);
	if (!ptr) {
		int i;

		i = get_property_value(what, bbuf);
		if (!i) {
			dbref dd;

			dd = get_property_dbref(what, bbuf);
			if (dd == NOTHING) {
				*vl = '\0';
				ptr = vl;
				return ptr;
			} else {
				snprintf(vl, sizeof(vl), "#%d", dd);
				ptr = vl;
			}
		} else {
			snprintf(vl, sizeof(vl), "%d", i);
			ptr = vl;
		}
	}

	if (ptr) {
		if (Prop_Blessed(what, bbuf)) {
			*blessed = 1;
		}
	}
	return ptr;
}
Пример #3
0
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);
		}
	}
}
Пример #4
0
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);
		}
	}
}