예제 #1
0
파일: speech.c 프로젝트: GlowMUCK/GlowMUCK
int
ansi_notify_listeners(dbref who, dbref xprog, dbref obj,
		 dbref room, const char *msg, int isprivate,
		 int parseansi)
{
    const char *lmsg;
    char buf[BUFFER_LEN];
    dbref ref;

    if (obj == NOTHING)
	return 0;

    /* Gag jerks, but not wizards or selves */
    if((who != obj) && (ignoring(obj, who) == 1))
	return 0;

    if(parseansi > 0) {
	buf[0] = '\0';
	unparse_ansi(buf, msg, parseansi);
        lmsg = buf;
    } else lmsg = msg;

    if (tp_listeners && (tp_listeners_obj || Typeof(obj) == TYPE_ROOM)) {
	listenqueue(who,room,obj,obj,xprog,"@listen",lmsg, tp_listen_mlev,1,1);
	listenqueue(who,room,obj,obj,xprog,"~listen",lmsg, tp_listen_mlev,1,1);
	listenqueue(who,room,obj,obj,xprog,"~olisten",lmsg,tp_listen_mlev,0,1);
	listenqueue(who,room,obj,obj,xprog,"_listen",lmsg, tp_listen_mlev,1,tp_mortal_mpi_listen_props);
	listenqueue(who,room,obj,obj,xprog,"_olisten",lmsg,tp_listen_mlev,0,tp_mortal_mpi_listen_props);
    }

    if ((Typeof(obj) == TYPE_THING || Typeof(obj) == TYPE_PLAYER) && !isprivate) {
	if (!(FLAGS(obj) & QUELL)) {
	    if (getloc(who) == getloc(obj)) {
		char pbuf[BUFFER_LEN];
		const char *prefix;

		prefix = GETOECHO(obj);
		if (prefix && *prefix) {
		    prefix = do_parse_mesg(who, obj, prefix,
				    "(@Oecho)", pbuf, MPI_ISPRIVATE
			     );
		}
		if (!prefix || !*prefix)
		    prefix = "Outside>";
		sprintf(buf, "%s %.*s", prefix,
		    (int)(BUFFER_LEN - 2 - strlen(prefix)), msg
		);
		ref = DBFETCH(obj)->contents;
		while(ref != NOTHING) {
		    if(obj != OWNER(ref)) /* Don't tell us what we already know */
			ansi_notify_nolisten(ref, buf, isprivate, parseansi);

		    ref = DBFETCH(ref)->next;
		}
	    }
	}
    }

    if (Typeof(obj) == TYPE_PLAYER || Typeof(obj) == TYPE_THING) {
	return ansi_notify_nolisten(obj, msg, isprivate, parseansi);
    } else return 0;
}
예제 #2
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);
		}
	}
}