Пример #1
0
void
notify_except(dbref first, dbref exception, const char *msg, dbref who)
{
	dbref room, srch;

	if (first != NOTHING) {

		srch = room = DBFETCH(first)->location;

		if (tp_listeners) {
			notify_from_echo(who, srch, msg, 0);

			if (tp_listeners_env) {
				srch = DBFETCH(srch)->location;
				while (srch != NOTHING) {
					notify_from_echo(who, srch, msg, 0);
					srch = getparent(srch);
				}
			}
		}

		DOLIST(first, first) {
			if ((Typeof(first) != TYPE_ROOM) && (first != exception)) {
				/* don't want excepted player or child rooms to hear */
				notify_from_echo(who, first, msg, 0);
			}
		}
	}
Пример #2
0
void 
prim_timestamps(PRIM_PROTOTYPE)
{
    CHECKOP(1);
    oper1 = POP();
    if (mlev < LM2)
	abort_interp("M2 prim");
    if (oper1->type != PROG_OBJECT)
	abort_interp("Non-object argument (1)");
    ref = oper1->data.objref;
    if (ref >= db_top || ref <= NOTHING)
      abort_interp("Dbref is not an object nor garbage.");
/*    if (!valid_object(oper1))
	abort_interp("Invalid object"); */
/*    CHECKREMOTE(oper1->data.objref); */
    CHECKREMOTE(ref);
    CHECKOFLOW(4);
/*    ref = oper1->data.objref; */
    CLEAR(oper1);
    result = DBFETCH(ref)->ts.created;
    PushInt(result);
    result = DBFETCH(ref)->ts.modified;
    PushInt(result);
    result = DBFETCH(ref)->ts.lastused;
    PushInt(result);
    result = DBFETCH(ref)->ts.usecount;
    PushInt(result);
}
Пример #3
0
/* exit_loop_check()
 *
 * Recursive check for loops in destinations of exits.  Checks to see
 * if any circular references are present in the destination chain.
 * Returns 1 if circular reference found, 0 if not.
 */
bool
exit_loop_check(dbref source, dbref dest)
{

    int i;

    if (source == dest)
        return 1;               /* That's an easy one! */

    if (dest == NIL)            /* NIL itself cant HAVE loops */
        return 0;

    if (Typeof(dest) != TYPE_EXIT)
        return 0;

    for (i = 0; i < DBFETCH(dest)->sp.exit.ndest; i++) {
        if ((DBFETCH(dest)->sp.exit.dest)[i] == source) {
            return 1;           /* Found a loop! */
        }
	if (OkObj((DBFETCH(dest)->sp.exit.dest)[i])) {
    	    if (Typeof((DBFETCH(dest)->sp.exit.dest)[i]) == TYPE_EXIT) {
        	if (exit_loop_check(source, (DBFETCH(dest)->sp.exit.dest)[i])) {
            	    return 1;       /* Found one recursively */
        	}
    	    }
	} else {
	    return 0;
	}
    }

    return 0;                   /* No loops found */
}
Пример #4
0
void
mcpedit_program(int descr, dbref player, dbref prog, const char *name,
                McpFrame *mfr)
{
    char namestr[BUFFER_LEN];
    char refstr[BUFFER_LEN];
    struct line *curr;
    McpMesg msg;
    McpVer supp;

    supp = mcp_frame_package_supported(mfr, "dns-org-mud-moo-simpleedit");
    if (supp.verminor == 0 && supp.vermajor == 0) {
        do_prog(descr, player, name);
        return;
    }

    FLAGS(prog) |= INTERNAL;

    snprintf(refstr, sizeof(refstr), "%d.prog.", prog);
    snprintf(namestr, sizeof(namestr), "a program named %s(%d)", NAME(prog),
             prog);
    mcp_mesg_init(&msg, "dns-org-mud-moo-simpleedit", "content");
    mcp_mesg_arg_append(&msg, "reference", refstr);
    mcp_mesg_arg_append(&msg, "type", "muf-code");
    mcp_mesg_arg_append(&msg, "name", namestr);
    for (curr = DBFETCH(prog)->sp.program.first; curr; curr = curr->next)
        mcp_mesg_arg_append(&msg, "content", DoNull(curr->this_line));

    mcp_frame_output_mesg(mfr, &msg);
    mcp_mesg_clear(&msg);

    free_prog_text(DBFETCH(prog)->sp.program.first);
    DBFETCH(prog)->sp.program.first = NULL;
}
Пример #5
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);
	}
}
Пример #6
0
void 
check_common(dbref obj)
{
    printf("\nObject %s\n", unparse_object(me, obj));
    printf("Name: %s\n", uncompress(DBFETCH(obj)->name));
    if (GETDESC(obj))
	printf("Desc: %s\n", uncompress(GETDESC(obj)));
    printf("Loc: #%s\n", unparse_object(me, DBFETCH(obj)->location));
    printf("Owner: #%d\n", unparse_object(me, DBFETCH(obj)->owner));
    printf("First contents: #%d\n", unparse_object(me, DBFETCH(obj)->contents));
    printf("Next item: #%d\n", unparse_object(me, DBFETCH(obj)->next));
    printf("Key: %s\n", unparse_boolexp(me, GETLOCK(obj)), 1);
    if (GETFAIL(obj))
	printf("Fail: %s\n", uncompress(GETFAIL(obj)));
    if (GETSUCC(obj))
	printf("Succ: %s\n", uncompress(GETSUCC(obj)));
    if (GETDROP(obj))
	printf("Drop: %s\n", uncompress(GETDROP(obj)));
    if (GETOFAIL(obj))
	printf("Ofail: %s\n", uncompress(GETOFAIL(obj)));
    if (GETOSUCC(obj))
	printf("Osucc: %s\n", uncompress(GETOSUCC(obj)));
    if (GETODROP(obj))
	printf("Odrop: %s\n", uncompress(GETODROP(obj)));
    printf("Properties:\n");
    check_properties("/", obj);
    printf("End of properties.\n");
}
Пример #7
0
void 
check_thing(dbref obj)
{
    printf("Home: %s\n", unparse_object(me, DBFETCH(obj)->sp.thing.home));
    printf("First action: %s\n", unparse_object(me, DBFETCH(obj)->exits));
    printf("Value: %d\n", DBFETCH(obj)->sp.thing.value);
}
Пример #8
0
dbref
next_ringqueue_obj(struct pload_Q * ref, dbref obj)
{
    if (DBFETCH(obj)->nextold == ref->obj)
        return NOTHING;
    return (DBFETCH(obj)->nextold);
}
Пример #9
0
/* removes property list --- if it's not there then ignore */
void
remove_property_list(dbref player, int all)
{
    PropPtr l;
    PropPtr p;
    PropPtr n;

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

#ifdef DISKBASE
    fetchprops(player);
#endif

    if ((l = DBFETCH(player)->properties)) {
        p = first_node(l);
        while (p) {
            n = next_node(l, PropName(p));
            remove_proplist_item(player, p, all);
            l = DBFETCH(player)->properties;
            p = n;
        }
    }
#ifdef DISKBASE
    dirtyprops(player);
#endif

    DBDIRTY(player);
}
Пример #10
0
const char *
mfn_controls(MFUNARGS)
{

dbref   obj;
    dbref   obj2;
    
    obj = mesg_dbref_raw(player, what, perms, argv[0]);
    if (obj == AMBIGUOUS || obj == NOTHING || obj == UNKNOWN)
	ABORT_MPI("CONTROLS","Match failed. (1)");
    if (obj == PERMDENIED)
	ABORT_MPI("CONTROLS","Permission denied. (1)");
    if (obj == HOME) obj = DBFETCH(player)->sp.player.home;
    if (argc > 1) {
	obj2 = mesg_dbref_raw(player, what, perms, argv[1]);
	if (obj2 == AMBIGUOUS || obj2 == NOTHING || obj2 == UNKNOWN)
	    ABORT_MPI("CONTROLS","Match failed. (2)");
	if (obj2 == PERMDENIED)
	    ABORT_MPI("CONTROLS","Permission denied. (2)");
	if (obj2 == HOME) obj2 = DBFETCH(player)->sp.player.home;
	if (Typeof(obj2) != TYPE_PLAYER) obj2 = OWNER(obj2);
    } else {
	obj2 = OWNER(perms);
    }
    if (controls(obj2, obj)) {
	return "1";
    } else {
	return "0";
    }
}
Пример #11
0
/*
  Use this to create a program.
  First, find a program that matches that name.  If there's one,
  then we put him into edit mode and do it.
  Otherwise, we create a new object for him, and call it a program.
  */
void
do_prog(int descr, dbref player, const char *name)
{
    dbref i;
    struct match_data md;

    if (Typeof(player) != TYPE_PLAYER) {
        anotify_nolisten2(player, CFAIL "Only players can edit programs.");
        return;
    } else if (!Mucker(player)) {
        anotify_nolisten2(player, CFAIL NOMBIT_MESG);
        return;
    } else if (!tp_building || tp_db_readonly) {
        anotify_nolisten2(player, CFAIL NOBUILD_MESG);
        return;
    } else if (!*name) {
        anotify_nolisten2(player, CINFO "No program name given.");
        return;
    }

    init_match(descr, player, name, TYPE_PROGRAM, &md);
    match_possession(&md);
    match_neighbor(&md);
    match_registered(&md);
    match_absolute(&md);

    if ((i = match_result(&md)) == NOTHING) {
        i = new_program(OWNER(player), name);
        FLAGS(i) |= INTERNAL;
        DBFETCH(player)->sp.player.curr_prog = i;

        anotify_fmt(player, CSUCC "Program %s created with number %d.", name,
                    i);
        anotify_nolisten2(player, CINFO "Entering editor.");
    } else if (i == AMBIGUOUS) {
        anotify_nolisten2(player, CINFO "I don't know which one you mean!");
        return;
    } else {
        if ((Typeof(i) != TYPE_PROGRAM) || !controls(player, i)) {
            anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
            return;
        } else if (FLAGS(i) & INTERNAL) {
            anotify_nolisten2(player, CFAIL NOEDIT_MESG);
            return;
        }

        DBFETCH(i)->sp.program.first = read_program(i);
        FLAGS(i) |= INTERNAL;
        DBFETCH(player)->sp.player.curr_prog = i;
        anotify_fmt(player, CINFO "Entering editor for %s.",
                    unparse_object(player, i));
        /* list current line */
        do_list(player, i, 0, 0, 0);
        DBDIRTY(i);
    }

    FLAGS(player) |= INTERACTIVE;
    DBDIRTY(player);
}
Пример #12
0
char *
show_line_prims(struct frame *fr, dbref program, struct inst *pc,
                int maxprims, int markpc)
{
    static char buf[BUFFER_LEN];
    static char buf2[BUFFER_LEN];
    int maxback;
    int thisline = pc->line;
    struct inst *code, *end, *linestart, *lineend;

    code = DBFETCH(program)->sp.program.code;
    end = code + DBFETCH(program)->sp.program.siz;
    buf[0] = '\0';

    for (linestart = pc, maxback = maxprims; linestart > code &&
         linestart->line == thisline && linestart->type != PROG_FUNCTION &&
         --maxback; --linestart) ;
    if (linestart->line < thisline)
        ++linestart;

    for (lineend = pc + 1, maxback = maxprims; lineend < end &&
         lineend->line == thisline && lineend->type != PROG_FUNCTION
         && --maxback; ++lineend) ;
    if (lineend >= end || lineend->line > thisline
        || lineend->type == PROG_FUNCTION)
        --lineend;

    if (lineend - linestart >= maxprims) {
        if (pc - (maxprims - 1) / 2 > linestart)
            linestart = pc - (maxprims - 1) / 2;
        if (linestart + maxprims - 1 < lineend)
            lineend = linestart + maxprims - 1;
    }

    if (linestart > code && (linestart - 1)->line == thisline)
        strcpy(buf, "...");
    maxback = maxprims;
    while (linestart <= lineend) {
        if (strlen(buf) < BUFFER_LEN / 2) {
            if (*buf)
                strcat(buf, " ");
            if (pc == linestart && markpc) {
                strcat(buf, " {{");
                strcat(buf, insttotext(NULL, 0, linestart, buf2, sizeof(buf2),
                                       30, program));
                strcat(buf, "}} ");
            } else {
                strcat(buf, insttotext(NULL, 0, linestart, buf2, sizeof(buf2),
                                       30, program));
            }
        } else {
            break;
        }
        linestart++;
    }
    if (lineend < end && (lineend + 1)->line == thisline)
        strcat(buf, " ...");
    return buf;
}
Пример #13
0
void 
check_player(dbref obj)
{
    printf("Home: %s\n", unparse_object(me, DBFETCH(obj)->sp.player.home));
    printf("First action: %s\n", unparse_object(me, DBFETCH(obj)->exits));
    printf("%s: %d\n", tp_cpennies, DBFETCH(obj)->sp.player.pennies);
    printf("Password: %s\n", DBFETCH(obj)->sp.player.password);
}
Пример #14
0
	DOLIST(list, list) {
		if (list == thing)
			return 1;
		if ((DBFETCH(list)->contents)
			&& (member(thing, DBFETCH(list)->contents))) {
			return 1;
		}
	}
Пример #15
0
void 
check_exit(dbref obj)
{
    int     i, j;

    printf("Dest#: %d\n", j = DBFETCH(obj)->sp.exit.ndest);
    for (i = 0; i < j; i++) {
	printf("Link #%d: %s\n", i + 1, unparse_object(me, DBFETCH(obj)->sp.exit.dest[i]));
    }
}
Пример #16
0
int
fetchprops_priority(dbref obj, int mode, const char *pdir)
{
	const char *s;
	int hitflag = 0;

	/* update fetched timestamp */
	DBFETCH(obj)->propstime = time(NULL);

	/* if in memory, don't try to reload. */
	if (DBFETCH(obj)->propsmode != PROPS_UNLOADED) {

		/* but do update the queue position */
		addobject_ringqueue(obj, DBFETCH(obj)->propsmode);
		if (!pdir)
			pdir = "/";
		while ((s = propdir_unloaded(DBFETCH(obj)->properties, pdir))) {
			propcache_misses++;
			hitflag++;
			if (!mode)
				update_fetchstats();
			if (FLAGS(obj) & SAVED_DELTA) {
				getproperties(delta_infile, obj, s);
			} else {
				getproperties(input_file, obj, s);
			}
		}
		if (hitflag) {
			return 1;
		} else {
			propcache_hits++;
			return 0;
		}
	}

	propcache_misses++;

	housecleanprops();

	/* actually load in root properties from the appropriate file */
	if (FLAGS(obj) & SAVED_DELTA) {
		getproperties(delta_infile, obj, "/");
	} else {
		getproperties(input_file, obj, "/");
	}

	/* update fetch statistics */
	if (!mode)
		update_fetchstats();

	/* add object to appropriate queue */
	addobject_ringqueue(obj, ((mode) ? PROPS_PRIORITY : PROPS_LOADED));

	return 1;
}
Пример #17
0
int
disposeprops_notime(dbref obj)
{
    if (DBFETCH(obj)->propsmode == PROPS_UNLOADED)
        return 0;
    if (DBFETCH(obj)->propsmode == PROPS_CHANGED)
        return 0;

    unloadprops_with_prejudice(obj);
    return 1;
}
Пример #18
0
void
ts_useobject(dbref thing)
{
    if (thing == NOTHING)
        return;
    DBFETCH(thing)->ts.lastused = current_systime;
    DBFETCH(thing)->ts.usecount++;
    DBDIRTY(thing);
    if (Typeof(thing) == TYPE_ROOM)
        ts_useobject(DBFETCH(thing)->location);
}
Пример #19
0
const char *
mfn_contents(MFUNARGS)
{
    char buf2[50];
    int list_limit = MAX_MFUN_LIST_LEN;
    dbref obj = mesg_dbref_local(player, what, perms, argv[0]);
    int typchk, ownroom;
    int outlen, nextlen;

    if (obj == AMBIGUOUS || obj == UNKNOWN || obj == NOTHING || obj == HOME)
	ABORT_MPI("CONTENTS","Match failed");
    if (obj == PERMDENIED)
	ABORT_MPI("CONTENTS",NOPERM_MESG);

    typchk = NOTYPE;
    if (argc > 1) {
	if (!string_compare(argv[1], "Room")) {
	    typchk = TYPE_ROOM;
	} else if (!string_compare(argv[1], "Exit")) {
	    typchk = TYPE_EXIT;  /* won't find any, though */
	} else if (!string_compare(argv[1], "Player")) {
	    typchk = TYPE_PLAYER;
	} else if (!string_compare(argv[1], "Program")) {
	    typchk = TYPE_PROGRAM;
	} else if (!string_compare(argv[1], "Thing")) {
	    typchk = TYPE_THING;
	} else {
	    ABORT_MPI("CONTENTS","Type must be 'player', 'room', 'thing', 'program', or 'exit'. (2)");
	}
    }
    strcpy(buf, "");
    outlen = 0;
    ownroom = controls(perms, obj);
    obj = DBFETCH(obj)->contents;
    while (obj != NOTHING && list_limit) {
	if ((typchk == NOTYPE || Typeof(obj) == typchk) &&
		(ownroom || controls(perms, obj) ||
		!((FLAGS(obj) & DARK) || (FLAGS(getloc(obj)) & DARK) ||
		(Typeof(obj) == TYPE_PROGRAM && !(FLAGS(obj) & LINK_OK)))) &&
		!(Typeof(obj) == TYPE_ROOM && typchk != TYPE_ROOM)) {
	    ref2str(obj, buf2);
	    nextlen = strlen(buf2);
	    if ((outlen + nextlen) >= (BUFFER_LEN - 3))
		break;
	    if (outlen) strcat((buf+(outlen++)), "\r");
	    strcat((buf + outlen), buf2);
	    outlen += nextlen;
	    list_limit--;
	}
	obj = DBFETCH(obj)->next;
    }
    return buf;
}
Пример #20
0
bool
can_doit(int descr, dbref player, dbref thing,
         const char *default_fail_msg)
{
    dbref loc;

    if ((loc = getloc(player)) == NOTHING)
        return 0;

    if (OkObj(thing)) {
        dbref dest = Typeof(thing) == TYPE_EXIT ? (DBFETCH(thing)->sp.exit.ndest ? DBFETCH(thing)->sp.exit.dest[0] : NOTHING) : NOTHING;

        if (((FLAG2(player) & F2IMMOBILE) && !(FLAG2(thing) & F2IMMOBILE)) &&
            (!OkObj(dest) || Typeof(dest) != TYPE_PROGRAM)
            ) {
            envpropqueue(descr, player, OkObj(player) ? getloc(player) : -1,
                         thing, thing, NOTHING, "@immobile", "Immobile", 1, 1);
            return 0;
        }
    }
    if (!TMage(OWNER(player)) && Typeof(player) == TYPE_THING &&
        (FLAGS(thing) & ZOMBIE)) {
        notify(player, "Sorry, but zombies can't do that.");
        return 0;
    }
    if (!could_doit(descr, player, thing)) {
        /* can't do it */
        if (GETFAIL(thing)) {
            exec_or_notify(descr, player, thing, GETFAIL(thing), "(@Fail)");
        } else if (default_fail_msg) {
            notify(player, default_fail_msg);
        }
        if (GETOFAIL(thing) && !Dark(player)) {
            parse_omessage(descr, player, loc, thing, GETOFAIL(thing),
                           PNAME(player), "(@Ofail)");
        }
        return 0;
    } else {
        /* can do it */
/* I moved these to the 'trigger()' function. -Akari */
/*	if (GETSUCC(thing)) {
	    exec_or_notify(descr, player, thing, GETSUCC(thing), "(@Succ)");
	}
	if (GETOSUCC(thing) && !Dark(player)) {
	    parse_omessage(descr, player, loc, thing, GETOSUCC(thing),
			    NAME(player), "(@Osucc)");
	}
 */
        return 1;
    }
}
Пример #21
0
void
undirtyprops(dbref obj)
{
    if (DBFETCH(obj)->propsmode == PROPS_UNLOADED)
        return;

    if (DBFETCH(obj)->propsmode != PROPS_CHANGED) {
        disposeprops(obj);
        return;
    }

    addobject_ringqueue(obj, PROPS_LOADED);
    disposeprops(obj);
}
Пример #22
0
struct inst *
linenum_to_pc(dbref program, int whatline)
{
    int i, siz;
    struct inst *code;
    code = DBFETCH(program)->sp.program.code;
    siz = DBFETCH(program)->sp.program.siz;
    for (i = 0; i < siz; i++) {
	if (code[i].line == whatline) {
	    return (code + i);
	}
    }
    return(NULL);
}
Пример #23
0
dbref 
create_player(const char *name, const char *password)
{
    dbref   player;

    if (!ok_player_name(name) || !ok_password(password))
	return NOTHING;

    /* else he doesn't already exist, create him */
    player = new_object();

    /* initialize everything */
    NAME(player) = alloc_string(name);
    DBFETCH(player)->location = tp_player_start;	/* home */
    FLAGS(player) = TYPE_PLAYER | PCREATE_FLAGS;
    OWNER(player) = player;
    DBFETCH(player)->sp.player.home = tp_player_start;
    DBFETCH(player)->exits = NOTHING;
    DBFETCH(player)->sp.player.pennies = tp_start_pennies;
    DBFETCH(player)->sp.player.password = NULL; // handle this last
    DBFETCH(player)->sp.player.curr_prog = NOTHING;
    DBFETCH(player)->sp.player.insert_mode = 0;

    /* link him to tp_player_start */
    PUSH(player, DBFETCH(tp_player_start)->contents);
    add_player(player);
    DBDIRTY(player);
    DBDIRTY(tp_player_start);
    set_password(player, password);

    return player;
}
Пример #24
0
void
unloadprops_with_prejudice(dbref obj)
{
    PropPtr l;

    if ((l = DBFETCH(obj)->properties)) {
        /* if it has props, then dispose */
        delete_proplist(l);
        DBFETCH(obj)->properties = NULL;
    }
    removeobj_ringqueue(obj);
    DBFETCH(obj)->propsmode = PROPS_UNLOADED;
    DBFETCH(obj)->propstime = 0;
}
Пример #25
0
struct inst *
funcname_to_pc(dbref program, const char *name)
{
    int i, siz;
    struct inst *code;
    code = DBFETCH(program)->sp.program.code;
    siz = DBFETCH(program)->sp.program.siz;
    for (i = 0; i < siz; i++) {
	if ((code[i].type == PROG_FUNCTION) &&
		!string_compare(name, code[i].data.string->data)) {
	    return (code + i);
	}
    }
    return(NULL);
}
Пример #26
0
const char *
mfn_links(MFUNARGS)
{
    char buf2[BUFFER_LEN];
    dbref   obj;
    int i, cnt;

    obj = mesg_dbref(player, what, perms, argv[0]);
    if (obj == AMBIGUOUS || obj == UNKNOWN || obj == NOTHING || obj == HOME)
	ABORT_MPI("LINKS","Match failed");
    if (obj == PERMDENIED)
	ABORT_MPI("LINKS",NOPERM_MESG);
    switch (Typeof(obj)) {
	case TYPE_ROOM:
	    obj = DBFETCH(obj)->sp.room.dropto;
	    break;
	case TYPE_PLAYER:
	    obj = DBFETCH(obj)->sp.player.home;
	    break;
	case TYPE_THING:
	    obj = DBFETCH(obj)->sp.thing.home;
	    break;
	case TYPE_EXIT: {
	    dbref obj2;
	    *buf = '\0';
	    cnt = DBFETCH(obj)->sp.exit.ndest;
	    if (cnt) {
		for (i = 0; i < cnt; i++) {
		    obj2 = DBFETCH(obj)->sp.exit.dest[i];
		    ref2str(obj2, buf2);
		    if (strlen(buf) + strlen(buf2) + 2 < BUFFER_LEN) {
			if (*buf) strcat(buf, "\r");
			strcat(buf, buf2);
		    } else break;
		}
		return buf;
	    } else {
		return "#-1";
	    }
	    break;
	}
	case TYPE_PROGRAM:
	default:
	    return "#-1";
	    break;
    }
    return ref2str(obj, buf);
}
Пример #27
0
void
do_edit(int descr, dbref player, const char *name)
{
    dbref i;
    struct match_data md;

    if (Typeof(player) != TYPE_PLAYER) {
        anotify_nolisten2(player, CFAIL "Only players can edit programs.");
        return;
    } else if (!Mucker(player)) {
        anotify_nolisten2(player, CFAIL NOMBIT_MESG);
        return;
    } else if (tp_db_readonly) {
        anotify_nolisten2(player, CFAIL DBRO_MESG);
        return;
    } else if (!*name) {
        anotify_nolisten2(player, CINFO "No program name given.");
        return;
    }

    init_match(descr, player, name, TYPE_PROGRAM, &md);
    match_possession(&md);
    match_neighbor(&md);
    match_registered(&md);
    match_absolute(&md);

    if ((i = noisy_match_result(&md)) == NOTHING || i == AMBIGUOUS)
        return;

    if ((Typeof(i) != TYPE_PROGRAM) || !controls(player, i)) {
        anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
        return;
    } else if (FLAGS(i) & INTERNAL) {
        anotify_nolisten2(player, CFAIL NOEDIT_MESG);
        return;
    }

    FLAGS(i) |= INTERNAL;
    DBFETCH(i)->sp.program.first = read_program(i);
    DBFETCH(player)->sp.player.curr_prog = i;
    anotify_fmt(player, CINFO "Entering editor for %s.",
                unparse_object(player, i));
    /* list current line */
    do_list(player, i, 0, 0, 0);
    FLAGS(player) |= INTERACTIVE;
    DBDIRTY(i);
    DBDIRTY(player);
}
Пример #28
0
void 
prim_descriptors(PRIM_PROTOTYPE)
{
    int  mydescr, mycount = 0;
    int  di, dcount, descr;
    int* darr;

    CHECKOP(1);
    oper1 = POP();
    if (mlev < LM3)
	abort_interp("M3 prim");
    if (oper1->type != PROG_OBJECT)
	abort_interp("Argument not a dbref");
    if (oper1->data.objref != NOTHING && !valid_object(oper1))
	abort_interp("Bad dbref");
    ref = oper1->data.objref;
    if ((ref != NOTHING) && (!valid_player(oper1)))
	abort_interp("Non-player argument");
    CLEAR(oper1);
    CHECKOP(0);

    if (ref == NOTHING) {
        for (result = pcount(); result; result--) {
            CHECKOFLOW(1);
            mydescr = pdescr(result);
            PushInt(mydescr);
            mycount++;
        }
    } else {
        if (Typeof(ref) == TYPE_PLAYER) {
            darr   = DBFETCH(ref)->sp.player.descrs;
            dcount = DBFETCH(ref)->sp.player.descr_count;
            if (!darr)
                dcount = 0;
        } else {
            darr = NULL;
            dcount = 0;
        }
        for (di = 0; di < dcount; di++) {
            CHECKOFLOW(1);
            descr = index_descr(darr[di]);
            PushInt(descr);
            mycount++;
        }
    }
    CHECKOFLOW(1);
    PushInt(mycount);
}
Пример #29
0
void
do_gripe(dbref player, const char *message)
{
    dbref loc;
    char buf[BUFFER_LEN];

    if (Guest(player)) {
        anotify_fmt(player, CFAIL "%s", tp_noguest_mesg);
        return;
    }

    if (!message || !*message) {
        if (Wiz(player)) {
            spit_file(player, LOG_GRIPE);
        } else {
            anotify_nolisten2(player, CINFO "What's wrong?");
        }
        return;
    }

    loc = DBFETCH(player)->location;
    log_gripe("%s(%d) in %s(%d): %s\n",
              NAME(player), player, NAME(loc), loc, message);

    anotify_nolisten2(player, CINFO "Your complaint has been filed.");

    sprintf(buf, MARK "Gripe from %s: %s", NAME(player), message);
    wall_wizards(buf);
}
Пример #30
0
void
list_proglines(dbref player, dbref program, struct frame *fr, int start, int end)
{
    int     range[2];
    int     argc;
    struct line *tmpline;

    if (start == end || end == 0) {
	range[0] = start;
	range[1] = start;
	argc = 1;
    } else {
	range[0] = start;
	range[1] = end;
	argc = 2;
    }
    if (!fr->brkpt.proglines || program != fr->brkpt.lastproglisted) {
	free_prog_text(fr->brkpt.proglines);
	fr->brkpt.proglines = read_program(program);
	fr->brkpt.lastproglisted = program;
    }
    tmpline = DBFETCH(program)->sp.program.first;
    DBSTORE(program, sp.program.first, fr->brkpt.proglines);
    do_list(player, program, range, argc);
    DBSTORE(program, sp.program.first, tmpline);
    return;
}