Beispiel #1
0
int
unset_source(dbref player, dbref loc, dbref action)
{

    dbref oldsrc;

    if ((oldsrc = DBFETCH(action)->location) == NOTHING) {
        /* old-style, sourceless exit */
        if (!member(action, DBFETCH(loc)->exits)) {
            return 0;
        }
        DBSTORE(DBFETCH(player)->location, exits,
                remove_first(DBFETCH(DBFETCH(player)->location)->exits,
                             action));
    } else {
        switch (Typeof(oldsrc)) {
            case TYPE_PLAYER:
            case TYPE_ROOM:
            case TYPE_THING:
                DBSTORE(oldsrc, exits,
                        remove_first(DBFETCH(oldsrc)->exits, action));
                break;
            default:
                log_status("PANIC: source of action #%d was type: %d.\n",
                           action, Typeof(oldsrc));
                return 0;
                /* NOTREACHED */
                break;
        }
    }
    return 1;
}
Beispiel #2
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;
}
Beispiel #3
0
void
send_contents(int descr, dbref loc, dbref dest)
{
    dbref first;
    dbref rest;

    first = DBFETCH(loc)->contents;
    DBSTORE(loc, contents, NOTHING);

    /* blast locations of everything in list */
    DOLIST(rest, first) {
        DBSTORE(rest, location, NOTHING);
    }
Beispiel #4
0
void 
moveto(dbref what, dbref where)
{
    dbref   loc;

    /* do NOT move garbage */
    if (what != NOTHING && Typeof(what) == TYPE_GARBAGE) {
	return;
    }

    if(what != NOTHING && parent_loop_check(what, where)) {
	/* Prevent stupid loop holes elsewhere */
	return;
    }

    /* remove what from old loc */
    if ((loc = DBFETCH(what)->location) != NOTHING) {
	DBSTORE(loc, contents, remove_first(DBFETCH(loc)->contents, what));
    }
    /* test for special cases */
    switch (where) {
	case NOTHING:
	    DBSTORE(what, location, NOTHING);
	    return;		/* NOTHING doesn't have contents */
	case HOME:
	    switch (Typeof(what)) {
		case TYPE_PLAYER:
		    where = DBFETCH(what)->sp.player.home;
		    break;
		case TYPE_THING:
		    where = DBFETCH(what)->sp.thing.home;
		    if (parent_loop_check(what, where))
			where = DBFETCH(OWNER(what))->sp.player.home;
		    break;
		case TYPE_ROOM:
		    where = GLOBAL_ENVIRONMENT;
		    break;
		case TYPE_PROGRAM:
		    where = OWNER(what);
		    break;
	    }
    }

    /* now put what in where */
    PUSH(what, DBFETCH(where)->contents);
    DBDIRTY(where);
    DBSTORE(what, location, where);
}
Beispiel #5
0
bool
set_password(dbref player, const char *password)
{
    int res = 0;
    char hashbuf[BUFFER_LEN];

    if (player == NOTHING)
        return 0;

    if (!password || !*password) {
        if (DBFETCH(player)->sp.player.password)
            free((void *) DBFETCH(player)->sp.player.password);

        if (!db_hash_passwords) {
            DBFETCH(player)->sp.player.password = NULL;
            return 1;
        }

        res = db_hash_password(HTYPE_NONE, hashbuf, NULL, NULL);

        if (!res)
            return 0;
        DBSTORE(player, sp.player.password, alloc_string(hashbuf));
        return 1;
    }

    if (!ok_password(password))
        return 0;

    if (DBFETCH(player)->sp.player.password)
        free((void *) DBFETCH(player)->sp.player.password);

    if (db_hash_passwords) {
        char hashbuf[BUFFER_LEN];

        res = db_hash_password(HTYPE_CURRENT, hashbuf, password, NULL);

        if (!res)
            return 0;
        DBSTORE(player, sp.player.password, alloc_string(hashbuf));
        return 1;
    }

    DBSTORE(player, sp.player.password, alloc_string(password));
    return 1;
}
void
ts_lastuseobject(dbref thing)
{
    if (thing == NOTHING)
        return;
    DBSTORE(thing, ts.lastused, current_systime);
    if (Typeof(thing) == TYPE_ROOM)
        ts_lastuseobject(DBFETCH(thing)->location);
}
Beispiel #7
0
/* remove the first occurence of what in list headed by first */
dbref
remove_first(dbref first, dbref what)
{
	dbref prev;

	/* special case if it's the first one */
	if (first == what) {
		return DBFETCH(first)->next;
	} else {
		/* have to find it */
		DOLIST(prev, first) {
			if (DBFETCH(prev)->next == what) {
				DBSTORE(prev, next, DBFETCH(what)->next);
				return first;
			}
		}
		return first;
	}
}
Beispiel #8
0
/*
 * set_source()
 *
 * This routine sets the source of an action to the specified source.
 * It is called by do_action and do_attach.
 *
 */
void
set_source(dbref player, dbref action, dbref source)
{
    switch (Typeof(source)) {
        case TYPE_ROOM:
        case TYPE_THING:
        case TYPE_PLAYER:
            PUSH(action, DBFETCH(source)->exits);
            break;
        default:
            anotify_nolisten2(player, CFAIL "Weird object type.");
            log_status("*BUG: tried to source %d to %d: type: %d\n",
                       action, source, Typeof(source));
            return;
            break;
    }
    DBDIRTY(source);
    DBSTORE(action, location, source);
    return;
}
Beispiel #9
0
void
do_password(dbref player, const char *old, const char *newobj)
{
    if(Guest(player)) {
        anotify(player, CFAIL NOGUEST_MESG);
        return;
    }

    if ((!DBFETCH(player)->sp.player.password) ||
            (!*DBFETCH(player)->sp.player.password) ||
            strcmp(old, DBFETCH(player)->sp.player.password)
       ) {
        anotify(player, CFAIL "Sorry.");
    } else if (!ok_password(newobj)) {
        anotify(player, CFAIL "Bad new password.");
    } else {
        free((void *) DBFETCH(player)->sp.player.password);
        DBSTORE(player, sp.player.password, alloc_string(newobj));
        ts_modifyobject(player);
        remove_property(player, PROP_PW);
        anotify(player, CSUCC "Password changed.");
    }
}
Beispiel #10
0
// Assumes player is valid, assumes password has been checked by ok_password
void
set_password(dbref player, const char *password)
{
    char entropy[16];
    char *newhash;
    int fd;

    // Get sone entropy
    fd = open("/dev/urandom", O_RDONLY);
    if (fd < 0) { printf("Can't open /dev/urandom\n"); abort(); };
    if (read(fd, entropy, sizeof(entropy)) != sizeof(entropy)) { printf("Not enough entropy in the universe."); abort(); };
    close(fd);

    // Make the hash 
    newhash = xcrypt(password, xcrypt_gensalt("$2a$", 12, entropy, sizeof(entropy)));

    // Trash the old password
    if (DBFETCH(player)->sp.player.password)
        free((void *) DBFETCH(player)->sp.player.password);

    // Set the password
    DBSTORE(player, sp.player.password, alloc_string(newhash));
}
void
ts_modifyobject(dbref thing)
{
    DBSTORE(thing, ts.modified, current_systime);
}
Beispiel #12
0
void
ts_modifyobject(dbref thing)
{
	DBSTORE(thing, ts.modified, time(NULL));
}