void prim_force(PRIM_PROTOTYPE) { struct inst *oper1, *oper2; /* d s -- */ CHECKOP(2); oper1 = POP(); /* string to @force */ oper2 = POP(); /* player dbref */ if (mlev < LARCH) abort_interp("Arch prim"); if (fr->level > 8) abort_interp("Interp call loops not allowed"); if (oper1->type != PROG_STRING) abort_interp("Non-string argument (2)"); if (oper2->type != PROG_OBJECT) abort_interp("Non-object argument (1)"); ref = oper2->data.objref; if (ref < 0 || ref >= db_top) abort_interp("Invalid object to force (1)"); if (Typeof(ref) != TYPE_PLAYER && Typeof(ref) != TYPE_THING) abort_interp("Object to force not a thing or player (1)"); if (!oper1->data.string) abort_interp("Null string argument (2)"); if (index(oper1->data.string->data, '\r')) abort_interp("Carriage returns not allowed in command string (2)"); if (Man(oper2->data.objref) && !Man(OWNER(program))) abort_interp("Cannot force the man (1)"); force_level++; process_command(dbref_first_descr(oper2->data.objref), oper2->data.objref, oper1->data.string->data); force_level--; CLEAR(oper1); CLEAR(oper2); }
// Handles getting the contents of an object, which is often // specific to each game driver. void CHSInterface::GetContents(int loc, CSTLDbrefList & rlistDbrefs, int type) { int thing; #ifdef PENNMUSH // No change in code between versions for (thing = db[loc].contents; GoodObject(thing); thing = Next(thing)) { if (type != NOTYPE) { if (Typeof(thing) == type) { rlistDbrefs.push_back(thing); } } else { rlistDbrefs.push_back(thing); } } #endif #if defined(TM3) || defined(MUX) for (thing = Contents(loc); Good_obj(thing); thing = Next(thing)) { if (type != NOTYPE) { if (Typeof(thing) == type) rlistDbrefs.push_back(thing); } else rlistDbrefs.push_back(thing); } #endif }
const char * unparse_object(dbref player, dbref loc) { static char buf[BUFFER_LEN]; if (player == NOTHING) goto islog; if (Typeof(player) != TYPE_PLAYER) player = OWNER(player); islog: switch (loc) { case NOTHING: return "*NOTHING*"; case AMBIGUOUS: return "*AMBIGUOUS*"; case HOME: return "*HOME*"; default: if (loc < 0 || loc >= db_top) return "*INVALID*"; if ((player == NOTHING) || (!(FLAGS(player) & STICKY) && (can_link_to(player, NOTYPE, loc) || ((Typeof(loc) != TYPE_PLAYER) && (controls_link(player, loc) || (FLAGS(loc) & CHOWN_OK)))))) { /* show everything */ snprintf(buf, sizeof(buf), "%.*s(#%d%s)", (BUFFER_LEN / 2), NAME(loc), loc, unparse_flags(loc)); return buf; } else { /* show only the name */ return NAME(loc); } } }
/* 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 */ }
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)); } }
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; }
void prim_testlock(PRIM_PROTOTYPE) { struct inst *oper1 = NULL; /* prevents re-entrancy issues! */ struct inst *oper2 = NULL; /* prevents re-entrancy issues! */ /* d d - i */ CHECKOP(2); oper1 = POP(); /* boolexp lock */ oper2 = POP(); /* player dbref */ if (fr->level > 8) abort_interp("Interp call loops not allowed."); if (!valid_object(oper2)) abort_interp("Invalid argument (1)."); if (Typeof(oper2->data.objref) != TYPE_PLAYER && Typeof(oper2->data.objref) != TYPE_THING) { abort_interp("Invalid object type (1)."); } CHECKREMOTE(oper2->data.objref); if (oper1->type != PROG_LOCK) abort_interp("Invalid argument (2)."); result = eval_boolexp(fr->descr, oper2->data.objref, oper1->data.lock, tp_consistent_lock_source ? fr->trig : player); CLEAR(oper1); CLEAR(oper2); PushInt(result); }
const char * mfn_name(MFUNARGS) { char *ptr; // dbref obj = mesg_dbref_proximity(player, what, perms, argv[0]); dbref obj = mesg_dbref_raw(player, what, perms, argv[0]); if (obj == UNKNOWN) ABORT_MPI("NAME","Match failed."); if (obj == NOTHING) { strcpy(buf, "#NOTHING#"); return buf; } if (obj == AMBIGUOUS) { strcpy(buf, "#AMBIGUOUS#"); return buf; } if (obj == HOME) { strcpy(buf, "#HOME#"); return buf; } if (!(Typeof(obj) == TYPE_PLAYER) && !mesg_proximity_perms(player, perms, obj)) ABORT_MPI("NAME","Permission denied."); strcpy(buf, RNAME(obj)); if (Typeof(obj) == TYPE_EXIT) { ptr = index(buf, ';'); if (ptr) *ptr = '\0'; } return buf; }
const char *unparse_flags(dbref thing) { static 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) & WIZARD) *p++ = 'W'; 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) & BUILDER) *p++ = 'B'; if (FLAGS(thing) & CHOWN_OK) *p++ = 'C'; if (FLAGS(thing) & JUMP_OK) *p++ = 'J'; 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 (MLevRaw(thing)) { *p++ = 'M'; switch (MLevRaw(thing)) { case 1: *p++ = '1'; break; case 2: *p++ = '2'; break; case 3: *p++ = '3'; break; } } } *p = '\0'; return buf; }
/* 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); }
const char * mfn_force(MFUNARGS) { char *nxt, *ptr; dbref obj = mesg_dbref_raw(player, what, perms, argv[0]); if (obj == AMBIGUOUS || obj == UNKNOWN || obj == NOTHING || obj == HOME) ABORT_MPI("FORCE","Failed match. (arg1)"); if (obj == PERMDENIED) ABORT_MPI("FORCE","Permission denied. (arg1)"); if (Typeof(obj) != TYPE_THING && Typeof(obj) != TYPE_PLAYER) ABORT_MPI("FORCE","Bad object reference. (arg1)"); if (!*argv[1]) ABORT_MPI("FORCE","Null command string. (arg2)"); if (!tp_zombies && !Wizperms(perms)) ABORT_MPI("FORCE","Permission Denied."); if (!Wizperms(perms)) { const char *ptr = RNAME(obj); char objname[BUFFER_LEN], *ptr2; dbref loc = getloc(obj); if (Typeof(obj) == TYPE_THING) { if (FLAGS(obj) & DARK) ABORT_MPI("FORCE","Cannot force a dark puppet."); if ((FLAGS(OWNER(obj)) & ZOMBIE)) ABORT_MPI("FORCE","Permission denied."); if (loc != NOTHING && (FLAGS(loc) & ZOMBIE) && Typeof(loc) == TYPE_ROOM) ABORT_MPI("FORCE","Cannot force a Puppet in a no-puppets room."); for (ptr2 = objname; *ptr && !isspace(*ptr);) *(ptr2++) = *(ptr++); *ptr2 = '\0'; if (lookup_player(objname) != NOTHING) ABORT_MPI("FORCE","Cannot force a thing named after a player."); } if (!(FLAGS(obj) & XFORCIBLE)) { ABORT_MPI("FORCE","Permission denied: forced object not @set Xforcible."); } if (!test_lock_false_default(perms, obj, "@/flk")) { ABORT_MPI("FORCE","Permission denied: Object not force-locked to trigger."); } } if (God(obj)) ABORT_MPI("FORCE","Permission denied: You can't force God."); if (force_level) ABORT_MPI("FORCE","Permission denied: You can't force recursively."); strcpy(buf, argv[1]); ptr = buf; do { nxt = index(ptr, '\r'); if (nxt) *nxt++ = '\0'; force_level++; if (*ptr) process_command(obj, ptr); force_level--; ptr = nxt; } while (ptr); *buf = '\0'; return ""; }
/* * do_attach() * * This routine attaches a previously existing action to a source object. * The action will not do anything unless it is LINKed. * */ void do_attach(int descr, dbref player, const char *action_name, const char *source_name) { dbref action, source; dbref loc; /* player's current location */ struct match_data md; char buf[BUFFER_LEN]; if ((loc = DBFETCH(player)->location) == NOTHING) return; if (tp_db_readonly) { anotify_nolisten2(player, CFAIL DBRO_MESG); return; } if (!*action_name || !*source_name) { anotify_nolisten2(player, CINFO "You must specify an action name and a source object."); return; } init_match(descr, player, action_name, TYPE_EXIT, &md); match_all_exits(&md); match_registered(&md); match_absolute(&md); if ((action = noisy_match_result(&md)) == NOTHING) return; if (Typeof(action) != TYPE_EXIT) { anotify_nolisten2(player, CINFO "That's not an action."); return; } else if (!controls(player, action)) { anotify_fmt(player, CFAIL "%s", tp_noperm_mesg); return; } if (((source = parse_source(descr, player, source_name)) == NOTHING) || Typeof(source) == TYPE_PROGRAM) return; if (!unset_source(player, loc, action)) { return; } set_source(player, action, source); sprintf(buf, CSUCC "Action %s re-attached to %s.", unparse_object(player, action), NAME(source)); anotify_nolisten2(player, buf); if (MLevel(action)) { SetMLevel(action, 0); anotify_nolisten2(player, CINFO "Action priority Level reset to zero."); } }
void prim_force(PRIM_PROTOTYPE) { struct inst *oper1 = NULL; /* prevents re-entrancy issues! */ struct inst *oper2 = NULL; /* prevents re-entrancy issues! */ int i; /* d s -- */ CHECKOP(2); oper1 = POP(); /* string to @force */ oper2 = POP(); /* player dbref */ if (mlev < 4) abort_interp("Wizbit only primitive."); if (fr->level > 8) abort_interp("Interp call loops not allowed."); if (oper1->type != PROG_STRING) abort_interp("Non-string argument (2)."); if (oper2->type != PROG_OBJECT) abort_interp("Non-object argument (1)."); ref = oper2->data.objref; if (ref < 0 || ref >= db_top) abort_interp("Invalid object to force. (1)"); if (Typeof(ref) != TYPE_PLAYER && Typeof(ref) != TYPE_THING) abort_interp("Object to force not a thing or player. (1)"); if (0 == strcmp(DoNullInd(oper1->data.string), "")) abort_interp("Empty command argument (2)."); if (index(oper1->data.string->data, '\r')) abort_interp("Carriage returns not allowed in command string. (2)."); #ifdef GOD_PRIV if (God(oper2->data.objref) && !God(OWNER(program))) abort_interp("Cannot force god (1)."); #endif force_prog = program; force_level++; process_command(dbref_first_descr(oper2->data.objref), oper2->data.objref, oper1->data.string->data); force_level--; force_prog = NOTHING; for (i = 1; i <= fr->caller.top; i++) { if (Typeof(fr->caller.st[i]) != TYPE_PROGRAM) { #ifdef DEBUG char str[BUFFER_LEN]; snprintf(str,BUFFER_LEN,"[debug] prim_force: fr->caller.st[%d] isn't a program.",i); notify_nolisten(player,str,1); #endif /* DEBUG */ do_abort_silent(); } } CLEAR(oper1); CLEAR(oper2); }
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; }
int isneighbor(dbref d1, dbref d2) { if (d1 == d2) return 1; if (Typeof(d1) != TYPE_ROOM) if (getloc(d1) == d2) return 1; if (Typeof(d2) != TYPE_ROOM) if (getloc(d2) == d1) return 1; if (Typeof(d1) != TYPE_ROOM && Typeof(d2) != TYPE_ROOM) if (getloc(d1) == getloc(d2)) return 1; return 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; } }
void prim_awakep(PRIM_PROTOTYPE) { CHECKOP(1); oper1 = POP(); if (!valid_object(oper1)) abort_interp("invalid argument"); ref = oper1->data.objref; if (Typeof(ref) == TYPE_THING && (FLAGS(ref) & ZOMBIE)) ref = OWNER(ref); if (Typeof(ref) != TYPE_PLAYER) abort_interp("invalid argument"); result = online(ref); PushInt(result); }
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); }
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); }
const char * mfn_name(MFUNARGS) { char *ptr; dbref obj; obj = tp_compatible_mpi ? mesg_dbref_raw(player, what, perms, argv[0]) : mesg_dbref_local(player, what, perms, argv[0]) ; if (obj == UNKNOWN) ABORT_MPI("NAME","Match failed"); if (obj == PERMDENIED) ABORT_MPI("NAME",NOPERM_MESG); if (obj == NOTHING) { strcpy(buf, "#NOTHING#"); return buf; } if (obj == AMBIGUOUS) { strcpy(buf, "#AMBIGUOUS#"); return buf; } if (obj == HOME) { strcpy(buf, "#HOME#"); return buf; } strcpy(buf, RNAME(obj)); if (Typeof(obj) == TYPE_EXIT) { ptr = index(buf, ';'); if (ptr) *ptr = '\0'; } return buf; }
void do_wall(dbref player, const char *message) { char buf[BUFFER_LEN]; if ((Mage(player) || (POWERS(player) & POW_ANNOUNCE)) && Typeof(player) == TYPE_PLAYER) { if (!*message) { anotify_nolisten2(player, CINFO "Shout what?"); return; } switch (message[0]) { case ':': case ';': sprintf(buf, SYSWHITE MARK SYSNORMAL "%s %s", NAME(player), message + 1); break; case '#': case '|': sprintf(buf, SYSWHITE MARK SYSNORMAL "%s", message + 1); break; default: sprintf(buf, SYSWHITE MARK SYSNORMAL "%s shouts, \"%s\"", NAME(player), message); } wall_all(buf); /* log_status("WALL: %s(%d): %s\n", NAME(player), player, buf); */ } else { anotify_fmt(player, CFAIL "%s", tp_noperm_mesg); } }
UTF8 *txlevel_description(dbref player, dbref target) { // Allocate the return buffer. // int otype = Typeof(target); UTF8 *buff = alloc_mbuf("txlevel_description"); UTF8 *bp = buff; int i; RLEVEL tl = TxLevel(target); for (i = 0; i < mudconf.no_levels; ++i) { confdata::rlevel_def *rldef = &mudconf.reality_level[i]; if ((tl & rldef->value) == rldef->value) { safe_mb_chr(' ', buff, &bp); safe_mb_str(rldef->name, buff, &bp); } } // Terminate the string, and return the buffer to the caller. // *bp = '\0'; return buff; }
RLEVEL RxLevel(dbref thing) { const UTF8 *buff = atr_get_raw(thing, A_RLEVEL); if ( NULL == buff || strlen((char *)buff) != 17) { switch (Typeof(thing)) { case TYPE_ROOM: return(mudconf.def_room_rx); case TYPE_PLAYER: return(mudconf.def_player_rx); case TYPE_EXIT: return(mudconf.def_exit_rx); default: return(mudconf.def_thing_rx); } } int i; RLEVEL rx = 0; for (i = 0; mux_isxdigit(buff[i]); i++) { rx = 16 * rx + mux_hex2dec(buff[i]); } return rx; }
void do_newpassword(dbref player, const char *name, const char *password) { dbref victim; char buf[BUFFER_LEN]; if (!Wizard(player) || Typeof(player) != TYPE_PLAYER) { notify(player, "Only a Wizard player can newpassword someone."); return; } else if ((victim = lookup_player(name)) == NOTHING) { notify(player, "No such player."); } else if (*password != '\0' && !ok_password(password)) { /* Wiz can set null passwords, but not bad passwords */ notify(player, "Bad password"); #ifdef GOD_PRIV } else if (God(victim)) { notify(player, "You can't change God's password!"); return; } else { if (TrueWizard(victim) && !God(player)) { notify(player, "Only God can change a wizard's password."); return; } #else /* GOD_PRIV */ } else {
void delete_player(dbref who) { int result; result = free_hash(NAME(who), player_list, PLAYER_HASH_SIZE); /* Nuke the alias managed by this dbref. This will not remove any aliases * that were manually set on #0, but they should auto-clean as the lookups * are attempted. */ rotate_alias(who, 1); if (result) { int i; wall_wizards(MARK "WARNING: Playername hashtable is inconsistent. Rebuilding it."); clear_players(); for (i = db_top; i-- > 0;) { if (Typeof(i) == TYPE_PLAYER) { add_player(i); } } result = free_hash(NAME(who), player_list, PLAYER_HASH_SIZE); if (result) { wall_wizards(MARK "WARNING: Playername hashtable still inconsistent after rebuild."); } } return; }
dbref lookup_alias(const char *name, int checkname) { dbref alias; PropPtr pptr; /* It's important to make sure that an alias lookup based on the name of an * existing target never succeeds. This should *only* be possible if an * admin manually set the prop on #0 (via @propset or a program), but things * can get pretty weird fast if cases of this behavior slip through. * * Most callers to this function will have already attempted to match the * exact target name, and this can be skipped. 'checkname' is used to signal * whether or not it's safe to skip this check. */ if (checkname && find_hash(name, player_list, PLAYER_HASH_SIZE) != NULL) { return NOTHING; } sprintf(abuf, ALIASDIR_CUR "%s", name); if (*name != '\0' && (pptr = get_property(0, abuf)) && PropType(pptr) == PROP_REFTYP) { alias = PropDataRef(pptr); if (Typeof(alias) == TYPE_PLAYER) { return alias; } else { /* bogus prop, kill it */ remove_property(0, abuf); } } return NOTHING; }
void do_mcpedit(int descr, dbref player, const char *name) { dbref i; struct match_data md; McpFrame *mfr; if (!(mfr = descr_mcpframe(descr))) { do_edit(descr, player, name); return; } else 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; mcpedit_program(descr, player, i, name, mfr); }
const char * mfn_type(MFUNARGS) { dbref obj = mesg_dbref_local(player, what, perms, argv[0]); if (obj == NOTHING || obj == AMBIGUOUS || obj == UNKNOWN) return("Bad"); if (obj == HOME) return("Room"); if (obj == PERMDENIED) ABORT_MPI("TYPE",NOPERM_MESG); switch(Typeof(obj)) { case TYPE_PLAYER: return "Player"; break; case TYPE_ROOM: return "Room"; break; case TYPE_EXIT: return "Exit"; break; case TYPE_THING: return "Thing"; break; case TYPE_PROGRAM: return "Program"; break; default: return "Bad"; break; } return "Bad"; }
const char * mfn_istype(MFUNARGS) { dbref obj = mesg_dbref_raw(player, what, perms, argv[0]); if (obj == NOTHING || obj == AMBIGUOUS || obj == UNKNOWN) return(string_compare(argv[1], "Bad") ? "0" : "1"); if (obj == PERMDENIED) ABORT_MPI("TYPE",NOPERM_MESG); if (obj == HOME) return(string_compare(argv[1], "Room") ? "0" : "1"); switch(Typeof(obj)) { case TYPE_PLAYER: return(string_compare(argv[1], "Player") ? "0" : "1"); break; case TYPE_ROOM: return(string_compare(argv[1], "Room") ? "0" : "1"); break; case TYPE_EXIT: return(string_compare(argv[1], "Exit") ? "0" : "1"); break; case TYPE_THING: return(string_compare(argv[1], "Thing") ? "0" : "1"); break; case TYPE_PROGRAM: return(string_compare(argv[1], "Program") ? "0" : "1"); break; default: return(string_compare(argv[1], "Bad") ? "0" : "1"); break; } return(string_compare(argv[1], "Bad") ? "0" : "1"); }
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"; } }