Beispiel #1
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;
    }
}
Beispiel #2
0
char *
stopmidi(dbref player)
{
    static char buf[BUFFER_LEN];

    if (FLAG2(player) & F2HTML) {
        sprintf(buf,
                "<embed src=\"%s\" hidden=true autostart=false volume=0 name=\"muckmidi\" mastersound>",
                getmidi(player));
        setmidi(player, "(none)");
    } else if (FLAG2(player) & F2PUEBLO) {
        sprintf(buf, "<img xch_sound=stop device=midi>");
    }
    return (buf);
}
Beispiel #3
0
char *
commandtext(dbref player, char *command, char *text)
{
    static char buf[BUFFER_LEN];
    char buf2[BUFFER_LEN];

    strcpy(buf2, "");

    strcpy(buf, text);
    if (FLAG2(player) & F2HTML) {
        escape_url(buf2, command);
        sprintf(buf,
                "<a href=\"/webinput?id=%s&muckinput=%s\" target=\"input\">%s</a>",
                getidstring(player), buf2, text);
    } else if (FLAG2(player) & F2PUEBLO) {
        sprintf(buf, "<a xch_cmd=\"%s\">%s</a>", command, text);
    }

    return (buf);
}
Beispiel #4
0
/* removes property --- if it's not there then ignore */
void
remove_property_nofetch(dbref player, const char *type)
{
    PropPtr l;
    char buf[BUFFER_LEN];
    char *w;

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

    w = strcpy(buf, type);

    l = DBFETCH(player)->properties;
    l = propdir_delete_elem(l, w);
    DBFETCH(player)->properties = l;
    if ((FLAGS(player) & LISTENER) && !(get_property(player, "_listen") ||
                                        get_property(player, "_olisten") ||
                                        get_property(player, "~listen") ||
                                        get_property(player, "~olisten") ||
                                        get_property(player, "@olisten") ||
                                        get_property(player, "@listen") ||
                                        get_property(player, "_alisten") ||
                                        get_property(player, "_aolisten") ||
                                        get_property(player, "~alisten") ||
                                        get_property(player, "~aolisten") ||
                                        get_property(player, "@aolisten") ||
                                        get_property(player, "@alisten")
        )) {
        FLAGS(player) &= ~LISTENER;
    }
    if ((FLAG2(player) & F2COMMAND) && !(get_property(player, "_command") ||
                                         get_property(player, "_ocommand") ||
                                         get_property(player, "~command") ||
                                         get_property(player, "~ocommand") ||
                                         get_property(player, "@ocommand") ||
                                         get_property(player, "@command")
        )) {
        FLAG2(player) &= ~F2COMMAND;
    }
    DBDIRTY(player);
}
Beispiel #5
0
PropPtr
envprop_cmds(dbref *where, const char *propname, int typ)
{
    PropPtr temp;

    while (*where != NOTHING) {
        if (typ ? 1
            : ((FLAG2(*where) & F2COMMAND) && !(FLAG2(*where) & F2NO_COMMAND)
               && ((FLAGS(OWNER(*where)) & BUILDER)
                   || (MLevel(OWNER(*where)) >= LMAGE)))) {
            temp = get_property(*where, propname);
#ifdef DISKBASE
            if (temp)
                propfetch(*where, temp);
#endif
            if (temp)
                return temp;
        }
        *where = getparent(*where);
    }
    return NULL;
}
Beispiel #6
0
char *
playmidi(dbref player, char *musicurl, char *volume)
{
    static char buf[BUFFER_LEN];

    strcpy(buf, "");

    if (FLAG2(player) & F2HTML) {
        if (strcmp(getmidi(player), "(none)")) {
            sprintf(buf,
                    "<embed src=\"%s\" hidden=true autostart=false name=\"muckmidi\" volume=0 mastersound>",
                    getmidi(player));
        }
        sprintf(buf,
                "<embed src=\"%s\" hidden=true autostart=true name=\"muckmidi\" volume=%s mastersound>",
                musicurl, volume);
        setmidi(player, musicurl);
    } else if (FLAG2(player) & F2PUEBLO) {
        sprintf(buf, "<img xch_sound=play href=\"%s\" xch_volume=%s>",
                musicurl, volume);
    }

    return (buf);
}
Beispiel #7
0
dbref
create_player(const char *name, const char *password)
{
    char buf[80];
    dbref player;

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

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

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

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

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

    return player;
}
Beispiel #8
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;
}
Beispiel #9
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);
    }
}
Beispiel #10
0
void
set_property_nofetch(dbref object, const char *pname, PData * dat,
                     bool pure)
{
    char buf[BUFFER_LEN];
    char *n;
    PropPtr p;

    /* Make sure that we are passed a valid property name */
    if (!pname)
        return;

    while (*pname == PROPDIR_DELIMITER)
        pname++;

    strcpy(buf, pname);

    /* truncate propnames with a ':' in them at the ':' */
    if ((n = index(buf, PROP_DELIMITER)))
        *n = '\0';

    /* truncate propnames with a '\n' in them at the '\n' */
    if ((n = index(buf, '\n')))
        *n = '\0';

    if (!*buf)
        return;

    if ((!(FLAGS(object) & LISTENER)) &&
        (string_prefix(buf, "_listen") ||
         string_prefix(buf, "~listen") ||
         string_prefix(buf, "@listen") ||
         string_prefix(buf, "_olisten") ||
         string_prefix(buf, "~olisten") ||
         string_prefix(buf, "@olisten") ||
         string_prefix(buf, "_alisten") ||
         string_prefix(buf, "~alisten") ||
         string_prefix(buf, "@alisten") ||
         string_prefix(buf, "_aolisten") ||
         string_prefix(buf, "~aolisten") || string_prefix(buf, "@aolisten"))) {
        FLAGS(object) |= LISTENER;
    }

    if ((!(FLAG2(object) & F2COMMAND)) &&
        (string_prefix(buf, "_command") ||
         string_prefix(buf, "~command") ||
         string_prefix(buf, "@command") ||
         string_prefix(buf, "_ocommand") ||
         string_prefix(buf, "~ocommand") || string_prefix(buf, "@ocommand"))) {
        FLAG2(object) |= F2COMMAND;
    }

    p = propdir_new_elem(&(DBFETCH(object)->properties), buf);

    /* free up any old values */
    clear_propnode(p);

    SetPFlagsRaw(p, dat->flags);
    if (PropFlags(p) & PROP_ISUNLOADED) {
        SetPDataUnion(p, dat->data);
        return;
    }

    switch (PropType(p)) {
        case PROP_STRTYP:
            if (!dat->data.str || !*dat->data.str) {
                SetPType(p, PROP_DIRTYP);
                SetPDataStr(p, NULL);
                if (!PropDir(p)) {
                    remove_property_nofetch(object, pname);
                }
            } else {
#ifdef COMPRESS
                if (!pure) {
                    if (!(dat->flags & PROP_NOCOMPRESS)
                        && isascii_str(dat->data.str)) {
                        SetPDataStr(p, alloc_compressed(dat->data.str));
                    } else {
                        dat->flags |= PROP_NOCOMPRESS;
                        SetPDataStr(p, alloc_string(dat->data.str));
                    }
                    SetPFlagsRaw(p, (dat->flags | PROP_COMPRESSED));
                } else
#endif
                    SetPDataStr(p, alloc_string(dat->data.str));
            }
            break;
        case PROP_INTTYP:
            SetPDataVal(p, dat->data.val);
            if (!dat->data.val) {
                SetPType(p, PROP_DIRTYP);
                if (!PropDir(p))
                    remove_property_nofetch(object, pname);
            }
            break;
        case PROP_FLTTYP:
            SetPDataFVal(p, dat->data.fval);
            if (dat->data.fval == 0.0) {
                SetPType(p, PROP_DIRTYP);
                if (!PropDir(p))
                    remove_property_nofetch(object, pname);
            }
            break;
        case PROP_REFTYP:
            SetPDataRef(p, dat->data.ref);
            if (dat->data.ref == NOTHING) {
                SetPType(p, PROP_DIRTYP);
                SetPDataRef(p, 0);
                if (!PropDir(p))
                    remove_property_nofetch(object, pname);
            }
            break;
        case PROP_LOKTYP:
            SetPDataLok(p, dat->data.lok);
            break;
        case PROP_DIRTYP:
            SetPDataVal(p, 0);
            if (!PropDir(p))
                remove_property_nofetch(object, pname);
            break;
    }
}
Beispiel #11
0
bool
could_doit(int descr, dbref player, dbref thing)
{
    dbref source, dest, owner;

    if (Typeof(thing) == TYPE_EXIT) {
        if (DBFETCH(thing)->sp.exit.ndest == 0) {
            return 0;
        }

        owner = OWNER(thing);
        source = DBFETCH(player)->location;
        dest = *(DBFETCH(thing)->sp.exit.dest);

        if (dest == NIL)        /* unless its locked, anyone can use #-4 */
            return (eval_boolexp(descr, player, GETLOCK(thing), thing));

        if (Typeof(dest) == TYPE_PLAYER) {
            dbref destplayer = dest;

            dest = DBFETCH(dest)->location;
            if (!(FLAGS(destplayer) & JUMP_OK) || (FLAGS(dest) & BUILDER)) {
                return 0;
            }
        }
/*
    if (OkObj(thing)) if
       ( ((FLAG2(player) & F2IMMOBILE) && !(FLAG2(thing) & F2IMMOBILE)) && 
         (!(Typeof(dest) == TYPE_PROGRAM) && !(dest == NIL))
       ) {
          envpropqueue(descr, player, OkObj(player) ? getloc(player) : -1,
	              thing, thing, NOTHING, "@immobile", "Immobile", 1, 1);
    	  return 0;
         }

*/
/*        if( (dest != HOME) &&
            (Typeof(dest)==TYPE_ROOM) &&
            (FLAGS(player) & ZOMBIE) && (Typeof(player) == TYPE_THING) &&
            (FLAGS(dest) & ZOMBIE) ) 
            return 0;
 Saving this part for a revision of trigger() and this function. */
        if ((dest != HOME) && (Typeof(dest) == TYPE_ROOM) && Guest(player)
            && (tp_guest_needflag ? !(FLAG2(dest) & F2GUEST)
                : (FLAG2(dest) & F2GUEST))) {
/*	    anotify_nolisten(player, CFAIL "Guests aren't allowed there.", 1); */
            return 0;
        }

        /* for actions */
        if ((DBFETCH(thing)->location != NOTHING) &&
            (Typeof(DBFETCH(thing)->location) != TYPE_ROOM)) {

            if ((Typeof(dest) == TYPE_ROOM || Typeof(dest) == TYPE_PLAYER) &&
                (FLAGS(source) & BUILDER))
                return 0;

            if (tp_secure_teleport && Typeof(dest) == TYPE_ROOM) {
                if ((dest != HOME) && (!controls(owner, dest))
                    && ((FLAGS(dest) & JUMP_OK) == 0)) {
                    return 0;
                }
            }
        }
    }


    return (eval_boolexp(descr, player, GETLOCK(thing), thing));
}
Beispiel #12
0
const char *
unparse_flags(dbref thing, char buf[BUFFER_LEN])
{
    char *p;
    const char *type_codes = "R-EPFG";

    p = buf;
    if (Typeof(thing) != TYPE_THING)
        *p++ = type_codes[Typeof(thing)];
    if (FLAGS(thing) & ~TYPE_MASK) {
        /* print flags */
        if (FLAGS(thing) & BUILDER)
            *p++ = 'B';
        if (FLAGS(thing) & JUMP_OK)
            *p++ = 'J';
        if (FLAGS(thing) & LINK_OK)
            *p++ = 'L';
        if (FLAGS(thing) & DARK)
            *p++ = 'D';
        if (FLAGS(thing) & STICKY)
            *p++ = 'S';
        if (FLAGS(thing) & QUELL)
            *p++ = 'Q';
        if (FLAGS(thing) & CHOWN_OK)
            *p++ = 'C';
        if (FLAGS(thing) & F256COLOR)
            *p++ = '&';
        if (FLAGS(thing) & HAVEN)
            *p++ = 'H';
        if (FLAGS(thing) & ABODE)
            *p++ = 'A';
        if (FLAGS(thing) & VEHICLE)
            *p++ = 'V';
        if (FLAGS(thing) & XFORCIBLE)
            *p++ = 'X';
        if (FLAGS(thing) & ZOMBIE)
            *p++ = 'Z';
    }
    if (FLAG2(thing)) {
        if (FLAG2(thing) & F2GUEST)
            *p++ = 'G';
        if (FLAG2(thing) & F2IDLE)
            *p++ = 'I';
        if (FLAG2(thing) & F2LOGWALL)
            *p++ = '!';
        if (FLAG2(thing) & F2MUFCOUNT)
            *p++ = '+';
        if (FLAG2(thing) & F2LIGHT)
            *p++ = 'O';
        if (FLAG2(thing) & F2PARENT)
            *p++ = '%';
        if (FLAG2(thing) & F2PROTECT)
            *p++ = '*';
        if (FLAG2(thing) & F2ANTIPROTECT)
            *p++ = 'K';
        if (FLAG2(thing) & F2EXAMINE_OK)
            *p++ = 'Y';
        if (FLAG2(thing) & F2NO_COMMAND)
            *p++ = 'N';
        if (FLAG2(thing) & F2HIDDEN)
            *p++ = '#';
        if (FLAG2(thing) & F2PUEBLO)
            *p++ = '$';
        if (FLAG2(thing) & F2MOBILE)
            *p++ = '?';
        if (FLAG2(thing) & F2IMMOBILE)
            *p++ = '|';
#ifdef CONTROLS_SUPPORT
        if (FLAG2(thing) & F2CONTROLS)
            *p++ = '~';
#endif
    }
    if (thing == 1) {
        *p++ = 'W';
        *p++ = '5';
    } else {
        switch (RawMLevel(thing)) {
            case 0:
                break;
            case LMPI:
                *p++ = 'M';
                break;
            case LMAN:
                *p++ = 'W';
                *p++ = '5';
                break;
            case LBOY:
                *p++ = 'W';
                *p++ = '4';
                break;
            case LARCH:
                *p++ = 'W';
                if (tp_multi_wizlevels) {
                    *p++ = '3';
                }
                break;
            case LWIZ:
                *p++ = 'W';
                *p++ = '2';
                break;
            case LMAGE:
                *p++ = 'W';
                break;
            case LM3:
                *p++ = 'M';
                *p++ = '3';
                break;
            case LM2:
                *p++ = 'M';
                *p++ = '2';
                break;
            case LM1:
                *p++ = 'M';
                *p++ = '1';
                break;
        }
    }
    if ((Typeof(thing) == TYPE_PLAYER) && POWERS(thing)) {
        *p++ = ':';
        if (POWERS(thing) & POW_ANNOUNCE)
            *p++ = 'a';
        if (POWERS(thing) & POW_BOOT)
            *p++ = 'b';
        if (POWERS(thing) & POW_CHOWN_ANYTHING)
            *p++ = 'c';
        if (POWERS(thing) & POW_EXPANDED_WHO)
            *p++ = 'x';
        if (POWERS(thing) & POW_HIDE)
            *p++ = 'h';
        if (POWERS(thing) & POW_IDLE)
            *p++ = 'i';
        if (POWERS(thing) & POW_LINK_ANYWHERE)
            *p++ = 'l';
        if (POWERS(thing) & POW_LONG_FINGERS)
            *p++ = 'g';
        if (POWERS(thing) & POW_NO_PAY)
            *p++ = 'n';
        if (POWERS(thing) & POW_OPEN_ANYWHERE)
            *p++ = 'o';
        if (POWERS(thing) & POW_PLAYER_CREATE)
            *p++ = 'p';
        if (POWERS(thing) & POW_PLAYER_PURGE)
            *p++ = 'u';
        if (POWERS(thing) & POW_SEARCH)
            *p++ = 's';
        if (POWERS(thing) & POW_SEE_ALL)
            *p++ = 'e';
        if (POWERS(thing) & POW_TELEPORT)
            *p++ = 't';
        if (POWERS(thing) & POW_SHUTDOWN)
            *p++ = 'd';
        if (POWERS(thing) & POW_CONTROL_MUF)
            *p++ = 'f';
        if (POWERS(thing) & POW_CONTROL_ALL)
            *p++ = 'r';
        if (POWERS(thing) & POW_ALL_MUF_PRIMS)
            *p++ = 'm';
        if (POWERS(thing) & POW_STAFF)
            *p++ = 'w';
    }
    *p = '\0';
    return buf;
}
Beispiel #13
0
void
set_property_nofetch(dbref player, const char *type, int flags, PTYPE value)
{
    PropPtr p;
    char buf[BUFFER_LEN];
    char *n, *w;

    /* Make sure that we are passed a valid property name */
    if (!type)
        return;

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

    while (*type == PROPDIR_DELIMITER)
        type++;
    if ((!(FLAGS(player) & LISTENER)) &&
        (string_prefix(type, "_listen") ||
         string_prefix(type, "~listen") ||
         string_prefix(type, "@listen") ||
         string_prefix(type, "_olisten") ||
         string_prefix(type, "~olisten") ||
         string_prefix(type, "@olisten") ||
         string_prefix(type, "_alisten") ||
         string_prefix(type, "~alisten") ||
         string_prefix(type, "@alisten") ||
         string_prefix(type, "_aolisten") ||
         string_prefix(type, "~aolisten") ||
         string_prefix(type, "@aolisten"))) {
        FLAGS(player) |= LISTENER;
    }

    if ((!(FLAG2(player) & F2COMMAND)) &&
        (string_prefix(type, "_command") ||
         string_prefix(type, "~command") ||
         string_prefix(type, "@command") ||
         string_prefix(type, "_ocommand") ||
         string_prefix(type, "~ocommand") ||
         string_prefix(type, "@ocommand"))) {
        FLAG2(player) |= F2COMMAND;
    }

    w = strcpy(buf, type);

    /* truncate propnames with a ':' in them at the ':' */
    n = index(buf, PROP_DELIMITER);
    if (n)
        *n = '\0';
    if (!*buf)
        return;

    p = propdir_new_elem(&(DBFETCH(player)->properties), w);

    /* free up any old values */
    clear_propnode(p);

    SetPFlagsRaw(p, flags);
    if (PropFlags(p) & PROP_ISUNLOADED) {
        SetPDataVal(p, (int) value);
        return;
    }
    switch (PropType(p)) {
        case PROP_STRTYP:
            if (!value || !*((char *) value)) {
                SetPType(p, PROP_DIRTYP);
                SetPDataVal(p, 0);
                if (!PropDir(p))
                    remove_property_nofetch(player, type);
            } else {
                /*  char *cptr = (char *) value;
                   while (cptr) { 
                   if (*cptr == '\n')
                   *cptr = '\r';
                   ++cptr;
                   } */
                SetPDataStr(p, alloc_compressed((char *) value));
#ifdef COMPRESS
                SetPFlagsRaw(p, (flags | PROP_COMPRESSED));
#endif
            }
            break;
        case PROP_INTTYP:
            SetPDataVal(p, (int) value);
            if (!value) {
                SetPType(p, PROP_DIRTYP);
                if (!PropDir(p))
                    remove_property_nofetch(player, type);
            }
            break;
        case PROP_FLTTYP:
            SetPDataFVal(p, strtod(value, NULL));
            if (strtod(value, NULL) == 0) {
                SetPType(p, PROP_DIRTYP);
                if (!PropDir(p)) {
                    remove_property_nofetch(player, type);
                }
            }
            break;
        case PROP_REFTYP:
            if (((dbref) value) == NOTHING) {
                SetPType(p, PROP_DIRTYP);
                SetPDataVal(p, 0);
                if (!PropDir(p))
                    remove_property_nofetch(player, type);
            } else {
                SetPDataRef(p, (dbref) value);
            }
            break;
        case PROP_LOKTYP:
            SetPDataLok(p, (struct boolexp *) value);
            /*
             * if ((struct boolexp *)value == TRUE_BOOLEXP) {
             *     SetPType(p, PROP_DIRTYP);
             *     SetPDataVal(p, 0);
             *     if (!PropDir(p))
             *         remove_property_nofetch(player, type);
             * } else {
             *     SetPDataLok(p, (struct boolexp *)value);
             * }
             */
            break;
        case PROP_DIRTYP:
            SetPDataVal(p, 0);
            if (!PropDir(p))
                remove_property_nofetch(player, type);
            break;
    }
}
Beispiel #14
0
const char *
unparse_flags(dbref thing, char buf[BUFFER_LEN])
{
    char   *p;
    const char *type_codes = "R-EPFG";

    p = buf;
    if (Typeof(thing) != TYPE_THING)
	*p++ = type_codes[Typeof(thing)];
    if (FLAGS(thing) & ~TYPE_MASK) {
	/* print flags */
	if (FLAGS(thing) & BUILDER)
	    *p++ = 'B';
	if (FLAGS(thing) & JUMP_OK)
	    *p++ = 'J';
	if (FLAGS(thing) & LINK_OK)
	    *p++ = 'L';
	if (FLAGS(thing) & KILL_OK)
	    *p++ = 'K';
	if (FLAGS(thing) & DARK)
	    *p++ = 'D';
	if (FLAGS(thing) & STICKY)
	    *p++ = 'S';
	if (FLAGS(thing) & QUELL)
	    *p++ = 'Q';
	if (FLAGS(thing) & CHOWN_OK)
	    *p++ = 'C';
	if (FLAGS(thing) & HAVEN)
	    *p++ = 'H';
	if (FLAGS(thing) & ABODE)
	    *p++ = 'A';
	if (FLAGS(thing) & VEHICLE)
	    *p++ = 'V';
	if (FLAGS(thing) & XFORCIBLE)
	    *p++ = 'X';
	if (FLAGS(thing) & ZOMBIE)
	    *p++ = 'Z';
    }
    if (FLAG2(thing)) {
	if (FLAG2(thing) & F2MPI)
	    *p++ = 'M';
	if (FLAG2(thing) & F2TINKERPROOF)
	    *p++ = 'T';
	if (FLAG2(thing) & F2GUEST)
	    *p++ = 'G';
	if (FLAG2(thing) & F2IC)
	    *p++ = 'I';
	if (FLAG2(thing) & F2OFFER)
	    *p++ = 'O';
	if (FLAG2(thing) & F2PUEBLO)
	    *p++ = 'U';
    }

    if(tp_multi_wiz_levels) {
	switch(RawMLevel(thing)) {
	    case LMAGE:	*p++ = 'W';		break;
	    case LWIZ:	*p++ = 'W'; *p++ = '2'; break;
	    case LARCH:	*p++ = 'W'; *p++ = '3'; break;
	    case LBOY:	*p++ = 'W'; *p++ = '4'; break;
	}
    } else if(FLAGS(thing)&W3)
	*p++ = 'W';

    switch (RawMLevel(thing)) {
	case LM1:	*p++ = 'M'; *p++ = '1'; break;
	case LM2:	*p++ = 'M'; *p++ = '2'; break;
	case LM3:	*p++ = 'M'; *p++ = '3'; break;
    }

    *p = '\0';
    return buf;
}