示例#1
0
/* doesn't really belong here, but I couldn't figure out where else */
void
do_page(dbref player, const char *arg1, const char *arg2)
{
	char buf[BUFFER_LEN];
	dbref target;

	if (!payfor(player, tp_lookup_cost)) {
		notify_fmt(player, "You don't have enough %s.", tp_pennies);
		return;
	}
	if ((target = lookup_player(arg1)) == NOTHING) {
		notify(player, "I don't recognize that name.");
		return;
	}
	if (FLAGS(target) & HAVEN) {
		notify(player, "That player does not wish to be disturbed.");
		return;
	}
	if (blank(arg2))
		snprintf(buf, sizeof(buf), "You sense that %s is looking for you in %s.",
				NAME(player), NAME(DBFETCH(player)->location));
	else
		snprintf(buf, sizeof(buf), "%s pages from %s: \"%s\"", NAME(player),
				NAME(DBFETCH(player)->location), arg2);
	if (notify_from(player, target, buf))
		notify(player, "Your message has been sent.");
	else {
		snprintf(buf, sizeof(buf), "%s is not connected.", NAME(target));
		notify(player, buf);
	}
}
示例#2
0
void
diskbase_debug(dbref player)
{
	char buf[BUFFER_LEN];
	double ph, pm;

	ph = propcache_hits;
	pm = propcache_misses;
	snprintf(buf, sizeof(buf),
			"Propcache hit ratio: %.3f%% (%ld hits / %ld fetches)",
			(100.0 * ph / (ph + pm)), propcache_hits, propcache_misses);
	notify(player, buf);
	report_fetchstats(player);

	notify_fmt(player, "PropLoaded count: %d", proploaded_Q.count);
	notify_fmt(player, "PropPriority count: %d", proppri_Q.count);
	notify_fmt(player, "PropChanged count: %d", propchanged_Q.count);
	report_cachestats(player);
}
示例#3
0
文件: rob.c 项目: giveamouse/fbmuck
void
do_rob(int descr, dbref player, const char *what)
{
	dbref thing;
	char buf[BUFFER_LEN];
	struct match_data md;

	init_match(descr, player, what, TYPE_PLAYER, &md);
	match_neighbor(&md);
	match_me(&md);
	if (Wizard(OWNER(player))) {
		match_absolute(&md);
		match_player(&md);
	}
	thing = match_result(&md);

	switch (thing) {
	case NOTHING:
		notify(player, "Rob whom?");
		break;
	case AMBIGUOUS:
		notify(player, "I don't know who you mean!");
		break;
	default:
		if (Typeof(thing) != TYPE_PLAYER) {
			notify(player, "Sorry, you can only rob other players.");
		} else if (GETVALUE(thing) < 1) {
			snprintf(buf, sizeof(buf), "%s has no %s.", NAME(thing), tp_pennies);
			notify(player, buf);
			snprintf(buf, sizeof(buf),
					"%s tried to rob you, but you have no %s to take.",
					NAME(player), tp_pennies);
			notify(thing, buf);
		} else if (can_doit(descr, player, thing, "Your conscience tells you not to.")) {
			/* steal a penny */
			SETVALUE(OWNER(player), GETVALUE(OWNER(player)) + 1);
			DBDIRTY(player);
			SETVALUE(thing, GETVALUE(thing) - 1);
			DBDIRTY(thing);
			notify_fmt(player, "You stole a %s.", tp_penny);
			snprintf(buf, sizeof(buf), "%s stole one of your %s!", NAME(player), tp_pennies);
			notify(thing, buf);
		}
		break;
	}
}
示例#4
0
文件: game.c 项目: rhencke/fuzzball
void
do_restrict(dbref player, const char *arg)
{
	if (!Wizard(player)) {
		notify(player, "Permission Denied.");
		return;
	}

	if (!strcmp(arg, "on")) {
		wizonly_mode = 1;
		notify(player, "Login access is now restricted to wizards only.");
	} else if (!strcmp(arg, "off")) {
		wizonly_mode = 0;
		notify(player, "Login access is now unrestricted.");
	} else {
		notify_fmt(player, "Restricted connection mode is currently %s.",
			wizonly_mode ? "on" : "off"
		);
	}
}
示例#5
0
void
show_re_cache(dbref player) {
    muf_re* re;
    size_t tmp;
    int idx = 0;
    int patterns = 0;
    int studies = 0;
    size_t size_re = 0;
    size_t size_extra = 0;

    if (!Boy(OWNER(player))) {
        anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
        return;
    }

    anotify(player, SYSYELLOW "idx hits flags studied? pattern"); 
    while (idx <= MUF_RE_CACHE_ITEMS) {
        re = &muf_re_cache[idx];

        if (re->re) {
            patterns++;
            notify_fmt(player, "%3i %4i %5i        %i \"%s\"",
                       idx, re->hits, re->flags,
                         (re->extra != NULL), DoNullInd(re->pattern));
            pcre_fullinfo(re->re, NULL, PCRE_INFO_SIZE, &tmp);
            size_re = size_re + tmp;
            if (re->extra) {
                studies++;
                pcre_fullinfo(re->re, re->extra, PCRE_INFO_STUDYSIZE, &tmp);
                size_extra = size_extra + tmp;
            }
        }
        idx++;
    }
    anotify_fmt(player, SYSPURPLE "\n%i compiled patterns are using %zd bytes of RAM.", patterns, size_re);
    anotify_fmt(player, SYSGREEN "%i study instances are using are using %zd bytes of RAM.", studies, size_extra);
}
示例#6
0
int
muf_debugger(dbref player, dbref program, const char *text, struct frame *fr)
{
    char cmd[BUFFER_LEN];
    char buf[BUFFER_LEN];
    char *ptr, *ptr2, *arg;
    struct inst *pinst;
    int i, j, cnt;

    while (isspace(*text)) text++;
    strcpy(cmd, text);
    ptr = cmd + strlen(cmd);
    if (ptr > cmd) ptr--;
    while (ptr >= cmd && isspace(*ptr)) *ptr-- = '\0';
    for (arg = cmd; *arg && !isspace(*arg); arg++);
    if (*arg) *arg++ = '\0';
    if (!*cmd && fr->brkpt.lastcmd) {
	strcpy(cmd, fr->brkpt.lastcmd);
    } else {
	if (fr->brkpt.lastcmd)
	    free(fr->brkpt.lastcmd);
	if (*cmd)
	    fr->brkpt.lastcmd = string_dup(cmd);
    }
    /* delete triggering breakpoint, if it's only temp. */
    j = fr->brkpt.breaknum;
    if (j >= 0 && fr->brkpt.temp[j]) {
	for (j++; j < fr->brkpt.count; j++) {
	    fr->brkpt.temp[j-1]		= fr->brkpt.temp[j];
	    fr->brkpt.level[j-1]	= fr->brkpt.level[j];
	    fr->brkpt.line[j-1]		= fr->brkpt.line[j];
	    fr->brkpt.linecount[j-1]	= fr->brkpt.linecount[j];
	    fr->brkpt.pc[j-1]		= fr->brkpt.pc[j];
	    fr->brkpt.pccount[j-1]	= fr->brkpt.pccount[j];
	    fr->brkpt.prog[j-1]		= fr->brkpt.prog[j];
	}
	fr->brkpt.count--;
    }
    fr->brkpt.breaknum = -1;
    
    if (!string_compare(cmd, "cont")) {
    } else if (!string_compare(cmd, "finish")) {
	if (fr->brkpt.count >= MAX_BREAKS) {
	    anotify_nolisten(player, CFAIL "Cannot finish because there are too many breakpoints set.", 1);
	    add_muf_read_event(player, program, fr);
	    return 0;
	}
	j = fr->brkpt.count++;
	fr->brkpt.temp[j] = 1;
	fr->brkpt.level[j] = fr->system.top - 1;
	fr->brkpt.line[j] = -1;
	fr->brkpt.linecount[j] = -2;
	fr->brkpt.pc[j] = NULL;
	fr->brkpt.pccount[j] = -2;
	fr->brkpt.prog[j] = program;
	fr->brkpt.bypass = 1;
	return 0;
    } else if (!string_compare(cmd, "stepi")) {
	i = atoi(arg);
	if (!i) i = 1;
	if (fr->brkpt.count >= MAX_BREAKS) {
	    anotify_nolisten(player, CFAIL "Cannot stepi because there are too many breakpoints set.", 1);
	    add_muf_read_event(player, program, fr);
	    return 0;
	}
	j = fr->brkpt.count++;
	fr->brkpt.temp[j] = 1;
	fr->brkpt.level[j] = -1;
	fr->brkpt.line[j] = -1;
	fr->brkpt.linecount[j] = -2;
	fr->brkpt.pc[j] = NULL;
	fr->brkpt.pccount[j] = i;
	fr->brkpt.prog[j] = NOTHING;
	fr->brkpt.bypass = 1;
	return 0;
    } else if (!string_compare(cmd, "step")) {
	i = atoi(arg);
	if (!i) i = 1;
	if (fr->brkpt.count >= MAX_BREAKS) {
	    anotify_nolisten(player, CFAIL "Cannot step because there are too many breakpoints set.", 1);
	    add_muf_read_event(player, program, fr);
	    return 0;
	}
	j = fr->brkpt.count++;
	fr->brkpt.temp[j] = 1;
	fr->brkpt.level[j] = -1;
	fr->brkpt.line[j] = -1;
	fr->brkpt.linecount[j] = i;
	fr->brkpt.pc[j] = NULL;
	fr->brkpt.pccount[j] = -2;
	fr->brkpt.prog[j] = NOTHING;
	fr->brkpt.bypass = 1;
	return 0;
    } else if (!string_compare(cmd, "nexti")) {
	i = atoi(arg);
	if (!i) i = 1;
	if (fr->brkpt.count >= MAX_BREAKS) {
	    anotify_nolisten(player, CFAIL "Cannot nexti because there are too many breakpoints set.", 1);
	    add_muf_read_event(player, program, fr);
	    return 0;
	}
	j = fr->brkpt.count++;
	fr->brkpt.temp[j] = 1;
	fr->brkpt.level[j] = fr->system.top;
	fr->brkpt.line[j] = -1;
	fr->brkpt.linecount[j] = -2;
	fr->brkpt.pc[j] = NULL;
	fr->brkpt.pccount[j] = i;
	fr->brkpt.prog[j] = program;
	fr->brkpt.bypass = 1;
	return 0;
    } else if (!string_compare(cmd, "next")) {
	i = atoi(arg);
	if (!i) i = 1;
	if (fr->brkpt.count >= MAX_BREAKS) {
	    anotify_nolisten(player, CFAIL "Cannot next because there are too many breakpoints set.", 1);
	    add_muf_read_event(player, program, fr);
	    return 0;
	}
	j = fr->brkpt.count++;
	fr->brkpt.temp[j] = 1;
	fr->brkpt.level[j] = fr->system.top;
	fr->brkpt.line[j] = -1;
	fr->brkpt.linecount[j] = i;
	fr->brkpt.pc[j] = NULL;
	fr->brkpt.pccount[j] = -2;
	fr->brkpt.prog[j] = program;
	fr->brkpt.bypass = 1;
	return 0;
    } else if (!string_compare(cmd, "exec")) {
	if (fr->brkpt.count >= MAX_BREAKS) {
	    anotify_nolisten(player, CFAIL "Cannot finish because there are too many breakpoints set.", 1);
	    add_muf_read_event(player, program, fr);
	    return 0;
	}
	if (!(pinst = funcname_to_pc(program, arg))) {
	    anotify_nolisten(player, CINFO "I don't know a function by that name.", 1);
	    add_muf_read_event(player, program, fr);
	    return 0;
	}
	if (fr->system.top >= STACK_SIZE) {
	    anotify_nolisten(player, CFAIL "That would exceed the system stack size for this program.", 1);
	    add_muf_read_event(player, program, fr);
	    return 0;
	}
	fr->system.st[fr->system.top].progref = program;
	fr->system.st[fr->system.top++].offset = fr->pc;
	fr->pc = pinst;
	j = fr->brkpt.count++;
	fr->brkpt.temp[j] = 1;
	fr->brkpt.level[j] = fr->system.top - 1;
	fr->brkpt.line[j] = -1;
	fr->brkpt.linecount[j] = -2;
	fr->brkpt.pc[j] = NULL;
	fr->brkpt.pccount[j] = -2;
	fr->brkpt.prog[j] = program;
	fr->brkpt.bypass = 1;
	return 0;
    } else if (!string_compare(cmd, "prim")) {
	if (fr->brkpt.count >= MAX_BREAKS) {
	    anotify_nolisten(player, CFAIL "Cannot finish because there are too many breakpoints set.", 1);
	    add_muf_read_event(player, program, fr);
	    return 0;
	}
	if (!(i = primitive(arg))) {
	    anotify_nolisten(player, CINFO "I don't recognize that primitive.", 1);
	    add_muf_read_event(player, program, fr);
	    return 0;
	}
	if (fr->system.top >= STACK_SIZE) {
	    anotify_nolisten(player, CFAIL "That would exceed the system stack size for this program.", 1);
	    add_muf_read_event(player, program, fr);
	    return 0;
	}

	shstr.data[0] = '\0';
	shstr.links = 1;
	shstr.length= strlen(shstr.data);
	primset[0].type = PROG_FUNCTION;
	primset[0].line = 0;
	primset[0].data.string = &shstr;
	primset[1].type = PROG_PRIMITIVE;
	primset[1].line = 0;
	primset[1].data.number = i;
	primset[2].type = PROG_PRIMITIVE;
	primset[2].line = 0;
	primset[2].data.number = primitive("EXIT");

	fr->system.st[fr->system.top].progref = program;
	fr->system.st[fr->system.top++].offset = fr->pc;
	fr->pc = primset;
	j = fr->brkpt.count++;
	fr->brkpt.temp[j] = 1;
	fr->brkpt.level[j] = fr->system.top - 1;
	fr->brkpt.line[j] = -1;
	fr->brkpt.linecount[j] = -2;
	fr->brkpt.pc[j] = NULL;
	fr->brkpt.pccount[j] = -2;
	fr->brkpt.prog[j] = program;
	fr->brkpt.bypass = 1;
	return 0;
    } else if (!string_compare(cmd, "break")) {
	add_muf_read_event(player, program, fr);
	if (fr->brkpt.count >= MAX_BREAKS) {
	    anotify_nolisten(player, CFAIL "Too many breakpoints set.", 1);
	    return 0;
	}
	if (number(arg)) {
	    i = atoi(arg);
	} else {
	    if (!(pinst = funcname_to_pc(program, arg))) {
		anotify_nolisten(player, CINFO "I don't know a function by that name.", 1);
		return 0;
	    } else {
		i = pinst->line;
	    }
	}
	if (!i) i = fr->pc->line;
	j = fr->brkpt.count++;
	fr->brkpt.temp[j] = 0;
	fr->brkpt.level[j] = -1;
	fr->brkpt.line[j] = i;
	fr->brkpt.linecount[j] = -2;
	fr->brkpt.pc[j] = NULL;
	fr->brkpt.pccount[j] = -2;
	fr->brkpt.prog[j] = program;
	anotify_nolisten(player, CSUCC "Breakpoint set.", 1);
	return 0;
    } else if (!string_compare(cmd, "delete")) {
	add_muf_read_event(player, program, fr);
	i = atoi(arg);
	if (!i) {
	    anotify_nolisten(player, CINFO "Which breakpoint did you want to delete?", 1);
	    return 0;
	}
	if (i < 1 || i > fr->brkpt.count) {
	    anotify_nolisten(player, CFAIL "No such breakpoint.", 1);
	    return 0;
	}
	j = i - 1;
	for (j++; j < fr->brkpt.count; j++) {
	    fr->brkpt.temp[j-1]		= fr->brkpt.temp[j];
	    fr->brkpt.level[j-1]	= fr->brkpt.level[j];
	    fr->brkpt.line[j-1]		= fr->brkpt.line[j];
	    fr->brkpt.linecount[j-1]	= fr->brkpt.linecount[j];
	    fr->brkpt.pc[j-1]		= fr->brkpt.pc[j];
	    fr->brkpt.pccount[j-1]	= fr->brkpt.pccount[j];
	    fr->brkpt.prog[j-1]		= fr->brkpt.prog[j];
	}
	fr->brkpt.count--;
	anotify_nolisten(player, CSUCC "Breakpoint deleted.", 1);
	return 0;
    } else if (!string_compare(cmd, "breaks")) {
	anotify_nolisten(player, CINFO "Breakpoints:", 1);
	for (i = 0; i < fr->brkpt.count; i++) {
	    ptr = unparse_breakpoint(fr, i);
	    notify_nolisten(player, ptr, 1);
	}
	anotify_nolisten(player, CINFO "Done.", 1);
	add_muf_read_event(player, program, fr);
	return 0;
    } else if (!string_compare(cmd, "where")) {
	i = atoi(arg);
	muf_backtrace(player, program, i, fr);
	add_muf_read_event(player, program, fr);
	return 0;
    } else if (!string_compare(cmd, "stack")) {
	anotify_nolisten(player, CINFO "*Argument stack top*", 1);
	i = atoi(arg);
	if (!i) i = STACK_SIZE;
	ptr = "";
	for (j = fr->argument.top; j>0 && i-->0;) {
	    cnt = 0;
	    do {
		strcpy(buf, ptr);
		ptr = insttotext(&fr->argument.st[--j], 4000, program);
		cnt++;
	    } while (!string_compare(ptr, buf) && j>0);
	    if (cnt > 1)
		notify_fmt(player, "     [repeats %d times]", cnt);
	    if (string_compare(ptr, buf))
		notify_fmt(player, "%3d) %s", j+1, ptr);
	}
	anotify_nolisten(player, CINFO "Done.", 1);
	add_muf_read_event(player, program, fr);
	return 0;
    } else if (!string_compare(cmd, "list") ||
	       !string_compare(cmd, "listi")) {
	int startline, endline;
	startline = endline = 0;
	add_muf_read_event(player, program, fr);
	if ((ptr2 = (char *)index(arg, ','))) {
	    *ptr2++ = '\0';
	} else {
	    ptr2 = "";
	}
	if (!*arg) {
	    if (fr->brkpt.lastlisted) {
		startline = fr->brkpt.lastlisted + 1;
	    } else {
		startline = fr->pc->line;
	    }
	    endline = startline + 15;
	} else {
	    if (!number(arg)) {
		if (!(pinst = funcname_to_pc(program, arg))) {
		    anotify_nolisten(player, CINFO "I don't know a function by that name. (starting arg, 1)", 1);
		    return 0;
		} else {
		    startline = pinst->line;
		    endline = startline + 15;
		}
	    } else {
		if (*ptr2) {
		    endline = startline = atoi(arg);
		} else {
		    startline = atoi(arg) - 7;
		    endline = startline + 15;
		}
	    }
	}
	if (*ptr2) {
	    if (!number(ptr2)) {
		if (!(pinst = funcname_to_pc(program, ptr2))) {
		    anotify_nolisten(player, CINFO "I don't know a function by that name. (ending arg, 1)", 1);
		    return 0;
		} else {
		    endline = pinst->line;
		}
	    } else {
		endline = atoi(ptr2);
	    }
	}
	i = (DBFETCH(program)->sp.program.code +
		DBFETCH(program)->sp.program.siz - 1)->line;
	if (startline > i) {
	    anotify_nolisten(player, CFAIL "Starting line is beyond end of program.", 1);
	    return 0;
	}
	if (startline < 1) startline = 1;
	if (endline > i) endline = i;
	if (endline < startline) endline = startline;
	anotify_nolisten(player, CINFO "Listing:", 1);
	if (!string_compare(cmd, "listi")) {
	    for (i = startline; i <= endline; i++) {
		pinst = linenum_to_pc(program, i);
		if (pinst) {
		    sprintf(buf, "line %d: %s", i, (i == fr->pc->line) ?
			    show_line_prims(program, fr->pc, STACK_SIZE, 1) :
			    show_line_prims(program, pinst, STACK_SIZE, 0));
		    notify_nolisten(player, buf, 1);
		}
	    }
	} else {
	    list_proglines(player, program, fr, startline, endline);
	}
	fr->brkpt.lastlisted = endline;
	anotify_nolisten(player, CINFO "Done.", 1);
	return 0;
    } else if (!string_compare(cmd, "quit")) {
	anotify_nolisten(player, CINFO "Halting execution.", 1);
	return 1;
    } else if (!string_compare(cmd, "trace")) {
	add_muf_read_event(player, program, fr);
	if (!string_compare(arg, "on")) {
	    fr->brkpt.showstack = 1;
	    anotify_nolisten(player, CSUCC "Trace turned on.", 1);
	} else if (!string_compare(arg, "off")) {
	    fr->brkpt.showstack = 0;
	    anotify_nolisten(player, CSUCC "Trace turned off.", 1);
	} else {
	    sprintf(buf, CINFO "Trace is currently %s.",
		    fr->brkpt.showstack? "on" : "off");
	    anotify_nolisten(player, buf, 1);
	}
	return 0;
    } else if (!string_compare(cmd, "words")) {
	list_program_functions(player, program, arg);
	add_muf_read_event(player, program, fr);
	return 0;
    } else if (!string_compare(cmd, "print")) {
	debug_printvar(player, fr, arg);
	add_muf_read_event(player, program, fr);
	return 0;
    } else if (!string_compare(cmd, "push")) {
	push_arg(player, fr, arg);
	add_muf_read_event(player, program, fr);
	return 0;
    } else if (!string_compare(cmd, "pop")) {
	add_muf_read_event(player, program, fr);
	if (fr->argument.top < 1) {
	    anotify_nolisten(player, CFAIL "Nothing to pop.", 1);
	    return 0;
	}
	fr->argument.top--;
	CLEAR(fr->argument.st + fr->argument.top);
	anotify_nolisten(player, CSUCC "Stack item popped.", 1);
	return 0;
    } else if (!string_compare(cmd, "help")) {
notify_nolisten(player, "cont            continues execution until a breakpoint is hit.", 1);
notify_nolisten(player, "finish          completes execution of current function.", 1);
notify_nolisten(player, "step [NUM]      executes one (or NUM, 1) lines of muf.", 1);
notify_nolisten(player, "stepi [NUM]     executes one (or NUM, 1) muf instructions.", 1);
notify_nolisten(player, "next [NUM]      like step, except skips CALL and EXECUTE.", 1);
notify_nolisten(player, "nexti [NUM]     like stepi, except skips CALL and EXECUTE.", 1);
notify_nolisten(player, "break LINE#     sets breakpoint at given LINE number.", 1);
notify_nolisten(player, "break FUNCNAME  sets breakpoint at start of given function.", 1);
notify_nolisten(player, "breaks          lists all currently set breakpoints.", 1);
notify_nolisten(player, "delete NUM      deletes breakpoint by NUM, as listed by 'breaks'", 1);
notify_nolisten(player, "where [LEVS]    displays function call backtrace of up to num levels deep.", 1);
notify_nolisten(player, "stack [NUM]     shows the top num items on the stack.", 1);
notify_nolisten(player, "print v#        displays the value of given global variable #.", 1);
notify_nolisten(player, "print lv#       displays the value of given local variable #.", 1);
notify_nolisten(player, "trace [on|off]  turns on/off debug stack tracing.", 1);
notify_nolisten(player, "list [L1,[L2]]  lists source code of given line range.", 1);
notify_nolisten(player, "list FUNCNAME   lists source code of given function.", 1);
notify_nolisten(player, "listi [L1,[L2]] lists instructions in given line range.", 1);
notify_nolisten(player, "listi FUNCNAME  lists instructions in given function.", 1);
notify_nolisten(player, "words           lists all function word names in program.", 1);
notify_nolisten(player, "words PATTERN   lists all function word names that match PATTERN.", 1);
notify_nolisten(player, "exec FUNCNAME   calls given function with the current stack data.", 1);
notify_nolisten(player, "prim PRIMITIVE  executes given primitive with current stack data.", 1);
notify_nolisten(player, "push DATA       pushes an int, dbref, var, or string onto the stack.", 1);
notify_nolisten(player, "pop             pops top data item off the stack.", 1);
notify_nolisten(player, "help            displays this help screen.", 1);
notify_nolisten(player, "quit            stop execution here.", 1);
	add_muf_read_event(player, program, fr);
	return 0;
    } else {
	anotify_nolisten(player, CINFO "I don't understand that debugger command. Type 'help' for help.", 1);
	add_muf_read_event(player, program, fr);
	return 0;
    }
    return 0;
}
示例#7
0
文件: rob.c 项目: giveamouse/fbmuck
void
do_kill(int descr, dbref player, const char *what, int cost)
{
	dbref victim;
	char buf[BUFFER_LEN];
	struct match_data md;

	init_match(descr, player, what, TYPE_PLAYER, &md);
	match_neighbor(&md);
	match_me(&md);
	if (Wizard(OWNER(player))) {
		match_player(&md);
		match_absolute(&md);
	}
	victim = match_result(&md);

	switch (victim) {
	case NOTHING:
		notify(player, "I don't see that player here.");
		break;
	case AMBIGUOUS:
		notify(player, "I don't know who you mean!");
		break;
	default:
		if (Typeof(victim) != TYPE_PLAYER) {
			notify(player, "Sorry, you can only kill other players.");
		} else {
			/* go for it */
			/* set cost */
			if (cost < tp_kill_min_cost)
				cost = tp_kill_min_cost;

			if (FLAGS(DBFETCH(player)->location) & HAVEN) {
				notify(player, "You can't kill anyone here!");
				break;
			}

			if (tp_restrict_kill) {
				if (!(FLAGS(player) & KILL_OK)) {
					notify(player, "You have to be set Kill_OK to kill someone.");
					break;
				}
				if (!(FLAGS(victim) & KILL_OK)) {
					notify(player, "They don't want to be killed.");
					break;
				}
			}

			/* see if it works */
			if (!payfor(player, cost)) {
				notify_fmt(player, "You don't have enough %s.", tp_pennies);
			} else if ((RANDOM() % tp_kill_base_cost) < cost && !Wizard(OWNER(victim))) {
				/* you killed him */
				if (GETDROP(victim))
					/* give him the drop message */
					notify(player, GETDROP(victim));
				else {
					snprintf(buf, sizeof(buf), "You killed %s!", NAME(victim));
					notify(player, buf);
				}

				/* now notify everybody else */
				if (GETODROP(victim)) {
					snprintf(buf, sizeof(buf), "%s killed %s! ", NAME(player), NAME(victim));
					parse_oprop(descr, player, getloc(player), victim,
								   MESGPROP_ODROP, buf, "(@Odrop)");
				} else {
					snprintf(buf, sizeof(buf), "%s killed %s!", NAME(player), NAME(victim));
				}
				notify_except(DBFETCH(DBFETCH(player)->location)->contents, player, buf,
							  player);

				/* maybe pay off the bonus */
				if (GETVALUE(victim) < tp_max_pennies) {
					snprintf(buf, sizeof(buf), "Your insurance policy pays %d %s.",
							tp_kill_bonus, tp_pennies);
					notify(victim, buf);
					SETVALUE(victim, GETVALUE(victim) + tp_kill_bonus);
					DBDIRTY(victim);
				} else {
					notify(victim, "Your insurance policy has been revoked.");
				}
				/* send him home */
				send_home(descr, victim, 1);

			} else {
				/* notify player and victim only */
				notify(player, "Your murder attempt failed.");
				snprintf(buf, sizeof(buf), "%s tried to kill you!", NAME(player));
				notify(victim, buf);
			}
			break;
		}
	}
}
示例#8
0
文件: rob.c 项目: giveamouse/fbmuck
void
do_give(int descr, dbref player, const char *recipient, int amount)
{
	dbref who;
	char buf[BUFFER_LEN];
	struct match_data md;

	/* do amount consistency check */
	if (amount < 0 && !Wizard(OWNER(player))) {
		notify(player, "Try using the \"rob\" command.");
		return;
	} else if (amount == 0) {
		notify_fmt(player, "You must specify a positive number of %s.", tp_pennies);
		return;
	}
	/* check recipient */
	init_match(descr, player, recipient, TYPE_PLAYER, &md);
	match_neighbor(&md);
	match_me(&md);
	if (Wizard(OWNER(player))) {
		match_player(&md);
		match_absolute(&md);
	}
	switch (who = match_result(&md)) {
	case NOTHING:
		notify(player, "Give to whom?");
		return;
	case AMBIGUOUS:
		notify(player, "I don't know who you mean!");
		return;
	default:
		if (!Wizard(OWNER(player))) {
			if (Typeof(who) != TYPE_PLAYER) {
				notify(player, "You can only give to other players.");
				return;
			} else if (GETVALUE(who) + amount > tp_max_pennies) {
				notify_fmt(player, "That player doesn't need that many %s!", tp_pennies);
				return;
			}
		}
		break;
	}

	/* try to do the give */
	if (!payfor(player, amount)) {
		notify_fmt(player, "You don't have that many %s to give!", tp_pennies);
	} else {
		/* he can do it */
		switch (Typeof(who)) {
		case TYPE_PLAYER:
			SETVALUE(who, GETVALUE(who) + amount);
			if(amount >= 0) {
				snprintf(buf, sizeof(buf), "You give %d %s to %s.",
						amount, amount == 1 ? tp_penny : tp_pennies, NAME(who));
				notify(player, buf);
				snprintf(buf, sizeof(buf), "%s gives you %d %s.",
						NAME(player), amount, amount == 1 ? tp_penny : tp_pennies);
				notify(who, buf);
			} else {
				snprintf(buf, sizeof(buf), "You take %d %s from %s.",
						-amount, amount == -1 ? tp_penny : tp_pennies, NAME(who));
				notify(player, buf);
				snprintf(buf, sizeof(buf), "%s takes %d %s from you!",
						NAME(player), -amount, -amount == 1 ? tp_penny : tp_pennies);
				notify(who, buf);
			}
			break;
		case TYPE_THING:
			SETVALUE(who, (GETVALUE(who) + amount));
			snprintf(buf, sizeof(buf), "You change the value of %s to %d %s.",
					NAME(who),
					GETVALUE(who), GETVALUE(who) == 1 ? tp_penny : tp_pennies);
			notify(player, buf);
			break;
		default:
			notify_fmt(player, "You can't give %s to that!", tp_pennies);
			break;
		}
		DBDIRTY(who);
	}
}
示例#9
0
文件: wiz.c 项目: hyena/fuzzball
void
do_stats(dbref player, const char *name)
{
	int rooms;
	int exits;
	int things;
	int players;
	int programs;
	int garbage = 0;
	int total;
	int altered = 0;
	int oldobjs = 0;
#ifdef DISKBASE
	int loaded = 0;
	int changed = 0;
#endif
	time_t currtime = time(NULL);
	dbref i;
	dbref owner=NOTHING;
	char buf[BUFFER_LEN];

	if (!Wizard(OWNER(player)) && (!name || !*name)) {
		snprintf(buf, sizeof(buf), "The universe contains %d objects.", db_top);
		notify(player, buf);
	} else {
		total = rooms = exits = things = players = programs = 0;
		if (name != NULL && *name != '\0') {
			owner = lookup_player(name);
			if (owner == NOTHING) {
				notify(player, "I can't find that player.");
				return;
			}
			if (!Wizard(OWNER(player)) && (OWNER(player) != owner)) {
				notify(player, "Permission denied. (you must be a wizard to get someone else's stats)");
				return;
			}
			for (i = 0; i < db_top; i++) {

#ifdef DISKBASE
				if ((OWNER(i) == owner) && DBFETCH(i)->propsmode != PROPS_UNLOADED)
					loaded++;
				if ((OWNER(i) == owner) && DBFETCH(i)->propsmode == PROPS_CHANGED)
					changed++;
#endif

				/* count objects marked as changed. */
				if ((OWNER(i) == owner) && (FLAGS(i) & OBJECT_CHANGED))
					altered++;

				/* if unused for 90 days, inc oldobj count */
				if ((OWNER(i) == owner) &&
					(currtime - DBFETCH(i)->ts.lastused) > tp_aging_time) oldobjs++;

				switch (Typeof(i)) {
				case TYPE_ROOM:
					if (OWNER(i) == owner)
						total++, rooms++;
					break;

				case TYPE_EXIT:
					if (OWNER(i) == owner)
						total++, exits++;
					break;

				case TYPE_THING:
					if (OWNER(i) == owner)
						total++, things++;
					break;

				case TYPE_PLAYER:
					if (i == owner)
						total++, players++;
					break;

				case TYPE_PROGRAM:
					if (OWNER(i) == owner)
						total++, programs++;
					break;

				}
			}
		} else {
			for (i = 0; i < db_top; i++) {

#ifdef DISKBASE
				if (DBFETCH(i)->propsmode != PROPS_UNLOADED)
					loaded++;
				if (DBFETCH(i)->propsmode == PROPS_CHANGED)
					changed++;
#endif

				/* count objects marked as changed. */
				if (FLAGS(i) & OBJECT_CHANGED)
					altered++;

				/* if unused for 90 days, inc oldobj count */
				if ((currtime - DBFETCH(i)->ts.lastused) > tp_aging_time)
					oldobjs++;

				switch (Typeof(i)) {
				case TYPE_ROOM:
					total++;
					rooms++;
					break;
				case TYPE_EXIT:
					total++;
					exits++;
					break;
				case TYPE_THING:
					total++;
					things++;
					break;
				case TYPE_PLAYER:
					total++;
					players++;
					break;
				case TYPE_PROGRAM:
					total++;
					programs++;
					break;
				case TYPE_GARBAGE:
					total++;
					garbage++;
					break;
				}
			}
		}

		notify_fmt(player, "%7d room%s        %7d exit%s        %7d thing%s",
				   rooms, (rooms == 1) ? " " : "s",
				   exits, (exits == 1) ? " " : "s", things, (things == 1) ? " " : "s");

		notify_fmt(player, "%7d program%s     %7d player%s      %7d garbage",
				   programs, (programs == 1) ? " " : "s",
				   players, (players == 1) ? " " : "s", garbage);

		notify_fmt(player,
				   "%7d total object%s                     %7d old & unused",
				   total, (total == 1) ? " " : "s", oldobjs);

#ifdef DISKBASE
		if (Wizard(OWNER(player))) {
			notify_fmt(player,
					   "%7d proploaded object%s                %7d propchanged object%s",
					   loaded, (loaded == 1) ? " " : "s", changed, (changed == 1) ? "" : "s");

		}
#endif

#ifdef DELTADUMPS
		{
			char buf[BUFFER_LEN];
			struct tm *time_tm;
			time_t lasttime = (time_t) get_property_value(0, "_sys/lastdumptime");

			time_tm = MUCKTIME(lasttime);
			format_time(buf, 40, "%a %b %e %T %Z", time_tm);
			notify_fmt(player, "%7d unsaved object%s     Last dump: %s",
					   altered, (altered == 1) ? "" : "s", buf);
		}
#endif

	}
}