示例#1
0
bool
can_see(dbref player, dbref thing, bool can_see_loc)
{
    if (!OkObj(player) || !OkObj(thing))
        return 0;

    if (player == thing || Typeof(thing) == TYPE_EXIT
        || Typeof(thing) == TYPE_ROOM)
        return 0;

    if (Light(thing))
        return 1;

    if (can_see_loc) {
        switch (Typeof(thing)) {
            case TYPE_PROGRAM:
                return ((FLAGS(thing) & LINK_OK) || controls(player, thing)
                        || (POWERS(player) & POW_SEE_ALL));
            case TYPE_PLAYER:
                if (tp_dark_sleepers) {
                    return (!Dark(thing) || online(thing)
                            || (POWERS(player) & POW_SEE_ALL));
                }
            default:
                return (!Dark(thing) || (POWERS(player) & POW_SEE_ALL) ||
                        (controls(player, thing) && !(FLAGS(player) & STICKY)));

        }
    } else {
        /* can't see loc */
        return (controls(player, thing) && !(FLAGS(player) & STICKY));
    }
}
示例#2
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;
    }
}
示例#3
0
bool
can_link_to(dbref who, object_flag_type what_type,
            dbref where)
{
    if (where == HOME)
        return 1;

    if (where == NIL)
        return 1;

    if (!OkObj(who) || !OkObj(where))
        return 0;

    switch (what_type) {
        case TYPE_EXIT:
            return (controls(who, where) || (FLAGS(where) & LINK_OK)
                    || (POWERS(who) & POW_LINK_ANYWHERE));
            /* NOTREACHED */
            break;
        case TYPE_PLAYER:
            return (Typeof(where) == TYPE_ROOM && (controls(who, where)
                                                   || Linkable(where)
                                                   || (POWERS(who) &
                                                       POW_LINK_ANYWHERE)));
            /* NOTREACHED */
            break;
        case TYPE_ROOM:
            return ((Typeof(where) == TYPE_ROOM || Typeof(where) == TYPE_THING)
                    && (controls(who, where) || Linkable(where)
                        || (POWERS(who) & POW_LINK_ANYWHERE)));
            /* NOTREACHED */
            break;
        case TYPE_THING:
            return ((Typeof(where) == TYPE_ROOM || Typeof(where) == TYPE_PLAYER
                     || Typeof(where) == TYPE_THING)
                    && (controls(who, where) || Linkable(where)
                        || (POWERS(who) & POW_LINK_ANYWHERE)));
            /* NOTREACHED */
            break;
        case NOTYPE:
            return (controls(who, where) || (FLAGS(where) & LINK_OK)
                    || (POWERS(who) & POW_LINK_ANYWHERE)
                    || (Typeof(where) != TYPE_THING && (FLAGS(where) & ABODE)));
            /* NOTREACHED */
            break;
    }

    return 0;
}
示例#4
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 */
}
示例#5
0
void
prim_armageddon(PRIM_PROTOTYPE)
{
    char buf[BUFFER_LEN];

    /* ( s<message> -- ) */

    CHECKOP(1);
    oper1 = POP();

    if (mlev < LBOY)
        abort_interp("W4 primitive.");
    if (oper1->type != PROG_STRING)
        abort_interp("String expected.");

    sprintf(buf, "\r\nImmediate shutdown by %s.\r\n", NAME(PSafe));
    if (oper1->data.string) {
        strcat(buf, SYSWHITE MARK SYSNORMAL);
        strcat(buf, oper1->data.string->data);
        strcat(buf, "\r\n");
    }

    CLEAR(oper1);
    log_status("DDAY(MUF: %d): by %s(%d)\n", program,
               OkObj(player) ? NAME(player) : "(login)", player);
    fprintf(stderr, "DDAY(MUF: %d): by %s(%d)\n", program,
            OkObj(player) ? NAME(player) : "(login)", player);
    close_sockets(buf);

#ifdef SPAWN_HOST_RESOLVER
    kill_resolver();
#endif
#ifdef USE_RESLVD
    reslvd_close();
#endif

    exit(1);
}
示例#6
0
const char *
unparse_object(dbref player, dbref loc)
{
    char tbuf[BUFFER_LEN];

    if (Typeof(player) != TYPE_PLAYER)
	player = OWNER(player);
    switch (loc) {
	case NOTHING:
	    return "*NOTHING*";
	case AMBIGUOUS:
	    return "*AMBIGUOUS*";
	case HOME:
	    return "*HOME*";
	default:
	    if (!OkObj(loc))
#ifdef SANITY
	    {
		sprintf(upb, "*INVALID*(#%d)", loc);
		return upb;
	    }
#else
		return "*INVALID*";
#endif
#ifndef SANITY
	    if (!(FLAGS(player) & STICKY) &&
		    (TMage(player) ||
		     can_link_to(player, NOTYPE, loc) ||
		     controls_link(player, loc) ||
		     ((Typeof(loc) != TYPE_PLAYER) &&
		     (FLAGS(loc) & CHOWN_OK))
		    )) {
		/* show everything */
#endif
		sprintf(upb, "%s(#%d%s)", NAME(loc), loc, unparse_flags(loc, tbuf));
		return upb;
#ifndef SANITY
	    } else {
		/* show only the name */
		return NAME(loc);
	    }
#endif
    }
}
示例#7
0
dbref
connect_player(const char *name, const char *password)
{
    dbref   player, i;

    if (*name == '#' && number(name+1) && atoi(name+1)) {
        player = (dbref) atoi(name + 1);
        if ((!OkObj(player)) || (Typeof(player) != TYPE_PLAYER))
            player = NOTHING;
    } else {
        player = lookup_player(name);
    }
    if (player == NOTHING) {
        /* Check for a player not in the hashtable */
        for(i = (db_top - 1); i > NOTHING; i--) {
            if(Typeof(i) == TYPE_PLAYER) {
                if(!string_compare(name, NAME(i))) {
                    /* Oooga, found a player that lookup didn't! */
                    log_status(HASH1_MSG);
                    wall_wizards(MARK HASH1_MSG);
                    refresh_players();
                    player = lookup_player(name);
                    if(player == NOTHING) {
                        log_status(HASH2_MSG);
                        wall_wizards(MARK HASH2_MSG);
                    }
                    break;
                }
            }
        }
        if(player == NOTHING)
            return NOTHING;
    }
    if (DBFETCH(player)->sp.player.password
            && *DBFETCH(player)->sp.player.password
            && strcmp(DBFETCH(player)->sp.player.password, password))
        return NOTHING;

    return player;
}
示例#8
0
void
prim_setsysparm(PRIM_PROTOTYPE)
{
    CHECKOP(2);
    oper1 = POP();              /* string: new parameter value */
    oper2 = POP();              /* string: parameter to tune */

    if (mlev < 6)
        abort_interp("Archwizards or higher only.");
    if (oper2->type != PROG_STRING)
        abort_interp("Invalid argument. (1)");
    if (!oper2->data.string)
        abort_interp("Null string argument. (1)");
    if (oper1->type != PROG_STRING)
        abort_interp("Invalid argument. (2)");
    if (!oper1->data.string)
        abort_interp("Null string argument. (2)");

    result = tune_setparm(program, oper2->data.string->data,
                          oper1->data.string->data);

    switch (result) {
        case 0:                /* TUNESET_SUCCESS */
            log_status("TUNED (MUF): %s(%d) tuned %s to %s\n",
                       OkObj(player) ? NAME(player) : "(Login)", player,
                       oper2->data.string->data, oper1->data.string->data);
            break;
        case 1:                /* TUNESET_UNKNOWN */
            abort_interp("Unknown parameter. (1)");
            break;
        case 2:                /* TUNESET_SYNTAX */
            abort_interp("Bad parameter syntax. (2)");
            break;
        case 3:                /* TUNESET_BADVAL */
            abort_interp("Bad parameter value. (2)");
            break;
    }
    CLEAR(oper1);
    CLEAR(oper2);
}
示例#9
0
dbref
lookup_player_noalias(const char *name)
{
    hash_data *hd;

    if (*name == '#') {
        name++;
        if (!OkObj(atoi(name)) || Typeof(atoi(name)) != TYPE_PLAYER)
            return NOTHING;
        else
            return atoi(name);
    } else {
        if (*name == '*')
            name++;

        if ((hd = find_hash(name, player_list, PLAYER_HASH_SIZE)) == NULL) {
            return NOTHING;
        } else {
            return (hd->dbval);
        }
    }
}
示例#10
0
const char *
ansi_unparse_object(dbref player, dbref loc)
{
    char tbuf[BUFFER_LEN], tbuf2[BUFFER_LEN];

    if (Typeof(player) != TYPE_PLAYER)
	player = OWNER(player);
    switch (loc) {
	case NOTHING:
	    return CGLOOM "*NOTHING*";
	case AMBIGUOUS:
	    return CPURPLE "*AMBIGUOUS*";
	case HOME:
	    return CWHITE "*HOME*";
	default:
	    if (!OkObj(loc))
		return CRED "*INVALID*";
#ifndef SANITY
	    if (!(FLAGS(player) & STICKY) &&
		    (TMage(player) ||
		     can_link_to(player, NOTYPE, loc) ||
		     controls_link(player, loc) ||
		     ((Typeof(loc) != TYPE_PLAYER) &&
		     (FLAGS(loc) & CHOWN_OK))
		    )) {
#endif
		/* show everything */
		sprintf(upb, "%s" CYELLOW "(#%d%s)",
		    ansiname(loc, tbuf), loc, unparse_flags(loc, tbuf2));
		return upb;
#ifndef SANITY
	    } else {
		/* show only the name */
		return ansiname(loc, upb);
	    }
#endif
    }
}
示例#11
0
dbref
lookup_player(const char *name)
{
    hash_data *hd;

    if (*name == '#') {
        name++;
        if (!OkObj(atoi(name)) || Typeof(atoi(name)) != TYPE_PLAYER)
            return NOTHING;
        else
            return atoi(name);
    } else {
        if (*name == '*')
            name++;

        if ((hd = find_hash(name, player_list, PLAYER_HASH_SIZE)) == NULL) {
            /* secondary check - is there an exact @alias? this will return
             * NOTHING if no alias was found. */
            return lookup_alias(name, 0);
        } else {
            return (hd->dbval);
        }
    }
}
示例#12
0
void
prim_restart(PRIM_PROTOTYPE)
{
    /* (s<message> -- ) */
    CHECKOP(1);
    oper1 = POP();
    if (mlev < LBOY)
        abort_interp("W4 primitive.");
    if (oper1->type != PROG_STRING)
        abort_interp("String expected.");

    log_status("RESTART(MUF: %d): by %s(%d)\n", program,
               OkObj(player) ? NAME(player) : "(login)", player);
    shutdown_flag = 1;
    restart_flag = 1;

    if (oper1->data.string) {
        strcat(restart_message, SYSWHITE MARK SYSNORMAL);
        strcat(restart_message, oper1->data.string->data);
        strcat(restart_message, "\r\n");
    }

    CLEAR(oper1);
}
示例#13
0
dbref
create_player(dbref creator, const char *name, const char *password)
{
    char buf[BUFFER_LEN];

    struct object *newp;

    dbref player;

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

    /* remove any existing alias with this name */
    clear_alias(0, name);

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

    /* initialize everything */
    NAME(player) = alloc_string(name);
    FLAGS(player) = TYPE_PLAYER;

    if (OkObj(tp_player_prototype)
        && (Typeof(tp_player_prototype) == TYPE_PLAYER)) {
        FLAGS(player) = FLAGS(tp_player_prototype);
        FLAG2(player) = FLAG2(tp_player_prototype);

        if (tp_pcreate_copy_props) {
            newp->properties = copy_prop(tp_player_prototype);
#ifdef DISKBASE
            newp->propsfpos = 0;
            newp->propsmode = PROPS_UNLOADED;
            newp->propstime = 0;
            newp->nextold = NOTHING;
            newp->prevold = NOTHING;
            dirtyprops(player);
#endif
        }
    }

    if (OkObj(tp_player_start)) {
        DBFETCH(player)->location = tp_player_start;
        DBFETCH(player)->sp.player.home = tp_player_start;
    } else {
        DBFETCH(player)->location = GLOBAL_ENVIRONMENT;
        DBFETCH(player)->sp.player.home = GLOBAL_ENVIRONMENT;
    }

    OWNER(player) = player;
    newp->exits = NOTHING;
    newp->sp.player.pennies = tp_start_pennies;
    newp->sp.player.password = NULL; /* this has to stay here. -hinoserm */
    newp->sp.player.curr_prog = NOTHING;
    newp->sp.player.insert_mode = 0;
#ifdef IGNORE_SUPPORT
    newp->sp.player.ignoretime = 0;
#endif /* IGNORE_SUPPORT */

    /* set password */
    set_password(player, password);

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

    sprintf(buf, CNOTE "%s is born!", NAME(player));
    anotify_except(DBFETCH(tp_player_start)->contents, NOTHING, buf, player);

    return player;
}
示例#14
0
/*
 * do_dig
 *
 * Use this to create a room.
 */
void
do_dig(int descr, dbref player, const char *name, const char *pname)
{
    char *rname, *qname;
    dbref newparent;
    char rbuf[BUFFER_LEN];
    char qbuf[BUFFER_LEN];
    char buf[BUFFER_LEN];
    dbref room;
    struct match_data md;
    dbref parent;

    if (!Builder(player) && !tp_all_can_build_rooms) {
        anotify_nolisten2(player, CFAIL NOBBIT_MESG);
        return;
    }

    if (!tp_building || tp_db_readonly) {
        anotify_nolisten2(player, CFAIL NOBUILD_MESG);
        return;
    }

    if (*name == '\0') {
        anotify_nolisten2(player, CINFO "You need name for the room.");
        return;
    }

    if (!ok_name(name)) {
        anotify_nolisten2(player, CINFO "That's a silly name for a room!");
        return;
    }

    if (!payfor(player, tp_room_cost)) {
        anotify_fmt(player, CFAIL "You don't have enough %s to dig a room.",
                    tp_pennies);
        return;
    }
    room = new_object(player);

    /* Initialize everything */
    newparent = DBFETCH(DBFETCH(player)->location)->location;
    while ((OkObj(newparent)) && !(FLAGS(newparent) & ABODE)
           && !(FLAG2(newparent) & F2PARENT))
        newparent = DBFETCH(newparent)->location;
    if (!OkObj(newparent)) {
        if (OkObj(tp_default_parent))
            newparent = tp_default_parent;
        else
            newparent = GLOBAL_ENVIRONMENT;
    }

    NAME(room) = alloc_string(name);
    DBFETCH(room)->location = newparent;
    OWNER(room) = OWNER(player);
    DBFETCH(room)->exits = NOTHING;
    DBFETCH(room)->sp.room.dropto = NOTHING;
    FLAGS(room) = TYPE_ROOM | (FLAGS(player) & JUMP_OK);
    PUSH(room, DBFETCH(newparent)->contents);
    DBDIRTY(room);
    DBDIRTY(newparent);

    sprintf(buf, CSUCC "Room %s created.", unparse_object(player, room));
    anotify_nolisten2(player, buf);

    strcpy(buf, pname);
    for (rname = buf; (*rname && (*rname != '=')); rname++) ;
    qname = rname;
    if (*rname)
        *(rname++) = '\0';
    while ((qname > buf) && (isspace(*qname)))
        *(qname--) = '\0';
    qname = buf;
    for (; *rname && isspace(*rname); rname++) ;
    rname = strcpy(rbuf, rname);
    qname = strcpy(qbuf, qname);

    if (*qname) {
        anotify_nolisten2(player, CNOTE "Trying to set parent...");
        init_match(descr, player, qname, TYPE_ROOM, &md);
        match_absolute(&md);
        match_registered(&md);
        match_here(&md);
        if ((parent = noisy_match_result(&md)) == NOTHING
            || parent == AMBIGUOUS) {
            anotify_nolisten2(player, CINFO "Parent set to default.");
        } else {
            if ((!can_link_to(player, Typeof(room), parent)
                 && !(FLAG2(parent) & F2PARENT)) || room == parent) {
                anotify_nolisten2(player,
                                  CFAIL
                                  "Permission denied.  Parent set to default.");
            } else {
                moveto(room, parent);
                sprintf(buf, CSUCC "Parent set to %s.",
                        unparse_object(player, parent));
                anotify_nolisten2(player, buf);
            }
        }
    }

    if (*rname) {
        PData pdat;

        sprintf(buf, "_reg/%s", rname);
        pdat.flags = PROP_REFTYP;
        pdat.data.ref = room;
        set_property(player, buf, &pdat);
        sprintf(buf, CINFO "Room registered as $%s", rname);
        anotify_nolisten2(player, buf);
    }
}
示例#15
0
bool
newcontrols(dbref who, dbref what, bool true_c)
{
    dbref index;

    /* No one controls invalid objects */
    /* if (what < 0 || what >= db_top)  -- not good enough */
    if (!OkObj(what) || !OkObj(who))
        return 0;

    /* Garbage controls nothing. */
    if (Typeof(who) == TYPE_GARBAGE)
        return 0;

    /* No one controls garbage */
    if (Typeof(what) == TYPE_GARBAGE)
        return 0;

    /* Puppets are based on owner */
    if (Typeof(who) != TYPE_PLAYER)
        who = OWNER(who);

    /* owners control their own stuff */
    /* Makes stuff faster here. -Hinoserm */
    if (who == OWNER(what))
        return 1;

    /* CONTROL_ALL controls all objects */
    if ((POWERS(who) & POW_CONTROL_ALL) && !Protect(what))
        return 1;

    /* CONTROL_MUF power controls all MUF objects */
    if ((POWERS(who) & POW_CONTROL_MUF) && (Typeof(what) == TYPE_PROGRAM)
        && (!(Protect(what))))
        return 1;

    /* Wizard controls (most) everything else */
    if (Wiz(who) && (!(Protect(what) && MLevel(OWNER(what)) >= LBOY)
                     || MLevel(who) >= LBOY))
        if (tp_fb_controls ? (MLevel(who) >= LWIZ)
            : (MLevel(who) >= MLevel(OWNER(what))))
            return 1;

    /* If realms control is enabled, the player will Control anything 
     * contained in a parent room he owns with at W1 bit or higher on it.
     * This gives him power to affect any object in his w-bitted parent room.
     */

    /* 
     *  Read the manual (help CONTROLS) about this new stuff.
     */

#ifdef CONTROLS_SUPPORT
    if (!true_c) {
        if (controlsEx(who, what))
            return 1;

        if (tp_realms_control) {
            if (!tp_wiz_realms) {
                if (Typeof(what) != TYPE_PLAYER)
                    for (index = what; index != NOTHING; index = getloc(index))
                        if ((controlsEx(who, index))
                            && (Typeof(index) == TYPE_ROOM
                                && ((FLAGS(index) & BUILDER) || Mage(index))))
                            return 1;
            } else {
                if (Typeof(what) != TYPE_PLAYER)
                    for (index = what; index != NOTHING; index = getloc(index))
                        if ((controlsEx(who, index))
                            && (Typeof(index) == TYPE_ROOM && (Mage(index))))
                            return 1;
            }
        }
    } else {
#endif

        if (tp_realms_control && (Typeof(what) != TYPE_PLAYER))
            for (index = what; index != NOTHING; index = getloc(index))
                if ((OWNER(index) == who) && (Typeof(index) == TYPE_ROOM
                                              && Mage(index)))
                    return 1;
#ifdef CONTROLS_SUPPORT
    }
#endif

    return 0;
}