Exemple #1
0
const char *
mfn_lexec(MFUNARGS)
{
	dbref trg = (dbref) 0, obj = what;
	char *pname;
	const char *ptr;
	int blessed = 0;

	pname = argv[0];
	if (argc == 2) {
		obj = mesg_dbref(descr, player, what, perms, argv[1], mesgtyp);
	}
	if (obj == PERMDENIED)
		ABORT_MPI("LEXEC", "Permission denied.");
	if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME)
		ABORT_MPI("LEXEC", "Match failed.");
	while (*pname == PROPDIR_DELIMITER)
		pname++;
	ptr = get_concat_list(player, what, perms, obj, (char *)pname, buf, BUFFER_LEN, 2, mesgtyp, &blessed);
	if (!ptr)
		ptr = "";
	trg = what;
	if (blessed) {
		mesgtyp |= MPI_ISBLESSED;
	} else {
		mesgtyp &= ~MPI_ISBLESSED;
	}
	if (Prop_ReadOnly(pname) || Prop_Private(pname) || Prop_SeeOnly(pname) || Prop_Hidden(pname))
		trg = obj;
	ptr = mesg_parse(descr, player, obj, trg, ptr, buf, BUFFER_LEN, mesgtyp);
	CHECKRETURN(ptr, "LEXEC", "listval");
	return ptr;
}
Exemple #2
0
const char *
mfn_rand(MFUNARGS)
{
	int num = 0;
	dbref trg = (dbref) 0, obj = what;
	const char *pname, *ptr;
	int blessed = 0;

	pname = argv[0];
	if (argc == 2) {
		obj = mesg_dbref(descr, player, what, perms, argv[1], mesgtyp);
	}
	if (obj == PERMDENIED)
		ABORT_MPI("RAND", "Permission denied.");
	if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME)
		ABORT_MPI("RAND", "Match failed.");
	num = get_list_count(what, obj, perms, (char *)pname, mesgtyp, &blessed);
	if (!num)
		ABORT_MPI("RAND", "Failed list read.");
	ptr = get_list_item(what, obj, perms, (char *)pname, (((RANDOM() / 256) % num) + 1), mesgtyp, &blessed);
	if (!ptr)
		ABORT_MPI("RAND", "Failed list read.");
	trg = what;
	if (blessed) {
		mesgtyp |= MPI_ISBLESSED;
	} else {
		mesgtyp &= ~MPI_ISBLESSED;
	}
	if (Prop_ReadOnly(ptr) || Prop_Private(ptr) || Prop_SeeOnly(ptr) || Prop_Hidden(ptr))
		trg = obj;
	ptr = mesg_parse(descr, player, obj, trg, ptr, buf, BUFFER_LEN, mesgtyp);
	CHECKRETURN(ptr, "RAND", "listval");
	return ptr;
}
Exemple #3
0
int
safeputprop(dbref obj, dbref perms, char *buf, char *val, int mesgtyp)
{
	char *ptr;

	if (!buf)
		return 0;
	while (*buf == PROPDIR_DELIMITER)
		buf++;
	if (!*buf)
		return 0;

	/* disallow CR's and :'s in prop names. */
	for (ptr = buf; *ptr; ptr++)
		if (*ptr == '\r' || *ptr == PROP_DELIMITER)
			return 0;

	if (Prop_System(buf))
		return 0;
	
	if (!(mesgtyp & MPI_ISBLESSED)) {
		if (Prop_Hidden(buf))
			return 0;
		if (Prop_SeeOnly(buf))
			return 0;
		if (string_prefix(buf, "_msgmacs/"))
			return 0;
	}
	if (val == NULL) {
		remove_property(obj, buf, 0);
	} else {
		add_property(obj, buf, val, 0);
	}
	return 1;
}
Exemple #4
0
int
safeputprop(dbref obj, dbref perms, char *buf, char *val)
{
    char *ptr;
    if (!buf) return 0;
    while (*buf == PROPDIR_DELIMITER) buf++;
    if (!*buf) return 0;
    if (tp_db_readonly) return 0;

    /* disallow CR's and :'s in prop names. */
    for (ptr = buf; *ptr; ptr++)
        if (*ptr == '\r' || *ptr == PROP_DELIMITER) return 0;

    if (!Archperms(perms)) {
        if (Prop_Hidden(buf)) return 0;
    }
    if (!Wizperms(perms)) {
        if (Prop_SeeOnly(buf)) return 0;
    }
    if (!val) {
        remove_property(obj, buf);
    } else {
	add_property(obj, buf, val, 0);
    }
    return 1;
}
Exemple #5
0
int
prop_write_perms(dbref player, dbref obj, const char *name, int mlev)
{
	if (Prop_System(name))
		return 0;

	if (mlev < 3) {
		if (!permissions(player, obj)) {
			if (Prop_Private(name))
				return 0;
			if (Prop_ReadOnly(name))
				return 0;
			if (!string_compare(name, "sex"))
				return 0;
		}
		if (string_prefix(name, "_msgmacs/"))
			return 0;
	}
	if (mlev < 4) {
		if (Prop_SeeOnly(name))
			return 0;
		if (Prop_Hidden(name))
			return 0;
	}
	return 1;
}
Exemple #6
0
const char *
mfn_timesub(MFUNARGS)
{
	int num = 0;
	dbref trg = (dbref) 0, obj = what;
	const char *pname, *ptr;
	int period = 0, offset = 0;
	int blessed = 0;

	period = atoi(argv[0]);
	offset = atoi(argv[1]);
	pname = argv[2];
	if (argc == 4) {
		obj = mesg_dbref(descr, player, what, perms, argv[3], mesgtyp);
	}
	if (obj == PERMDENIED)
		ABORT_MPI("TIMESUB", "Permission denied.");
	if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME)
		ABORT_MPI("TIMESUB", "Match failed.");
	num = get_list_count(what, obj, perms, (char *)pname, mesgtyp, &blessed);
	if (!num)
		ABORT_MPI("TIMESUB", "Failed list read.");
	if (period < 1)
		ABORT_MPI("TIMESUB", "Time period too short.");
	offset = (int)((((long) time(NULL) + offset) % period) * num) / period;
	if (offset < 0)
		offset = -offset;
	ptr = get_list_item(what, obj, perms, (char *)pname, offset + 1, mesgtyp, &blessed);
	if (!ptr)
		ABORT_MPI("TIMESUB", "Failed list read.");
	trg = what;
	if (blessed) {
		mesgtyp |= MPI_ISBLESSED;
	} else {
		mesgtyp &= ~MPI_ISBLESSED;
	}
	if (Prop_ReadOnly(ptr) || Prop_Private(ptr) || Prop_SeeOnly(ptr) || Prop_Hidden(ptr))
		trg = obj;
	ptr = mesg_parse(descr, player, obj, trg, ptr, buf, BUFFER_LEN, mesgtyp);
	CHECKRETURN(ptr, "TIMESUB", "listval");
	return ptr;
}
Exemple #7
0
const char *
mfn_indexbang(MFUNARGS)
{
	dbref trg = (dbref) 0, obj = what;
	dbref tmpobj = (dbref) 0;
	const char *pname, *ptr;
	int blessed = 0;

	pname = argv[0];
	if (argc == 2) {
		obj = mesg_dbref(descr, player, what, perms, argv[1], mesgtyp);
	}
	if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME)
		ABORT_MPI("INDEX!", "Match failed.");
	if (obj == PERMDENIED)
		ABORT_MPI("INDEX!", "Permission denied.");
	tmpobj = obj;
	ptr = safegetprop_strict(player, obj, perms, pname, mesgtyp, &blessed);
	if (!ptr)
		ABORT_MPI("INDEX!", "Failed read.");
	if (!*ptr)
		return "";
	obj = tmpobj;
	ptr = safegetprop_strict(player, obj, perms, ptr, mesgtyp, &blessed);
	if (!ptr)
		ABORT_MPI("INDEX!", "Failed read.");
	trg = what;
	if (blessed) {
		mesgtyp |= MPI_ISBLESSED;
	} else {
		mesgtyp &= ~MPI_ISBLESSED;
	}
	if (Prop_ReadOnly(ptr) || Prop_Private(ptr) || Prop_SeeOnly(ptr) || Prop_Hidden(ptr))
		trg = obj;
	ptr = mesg_parse(descr, player, obj, trg, ptr, buf, BUFFER_LEN, mesgtyp);
	CHECKRETURN(ptr, "INDEX!", "listval");
	return ptr;
}
Exemple #8
0
void
remove_proplist_item(dbref player, PropPtr p, int allp)
{
    const char *ptr;

    /* if( tp_db_readonly ) return; *//* Why did we remove this? */

    if (!p)
        return;
    ptr = PropName(p);
    if (!allp) {
        if (Prop_SeeOnly(ptr))
            return;
        if (Prop_Hidden(ptr))
            return;

        if (ptr[0] == '_' && ptr[1] == '\0')
            return;
        if (PropFlags(p) & PROP_SYSPERMS)
            return;
    }
    /* notify(player, ptr); *//* Why did we put this here? */
    remove_property(player, ptr);
}