const char * mfn_nearby(MFUNARGS) { dbref obj; dbref obj2; obj = mesg_dbref_raw(descr, player, what, perms, argv[0]); if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING) ABORT_MPI("NEARBY", "Match failed (arg1)."); if (obj == PERMDENIED) ABORT_MPI("NEARBY", "Permission denied (arg1)."); if (obj == HOME) obj = PLAYER_HOME(player); if (argc > 1) { obj2 = mesg_dbref_raw(descr, player, what, perms, argv[1]); if (obj2 == UNKNOWN || obj2 == AMBIGUOUS || obj2 == NOTHING) ABORT_MPI("NEARBY", "Match failed (arg2)."); if (obj2 == PERMDENIED) ABORT_MPI("NEARBY", "Permission denied (arg2)."); if (obj2 == HOME) obj2 = PLAYER_HOME(player); } else { obj2 = what; } if (!(mesgtyp & MPI_ISBLESSED) && !isneighbor(obj, what) && !isneighbor(obj2, what) && !isneighbor(obj, player) && !isneighbor(obj2, player) ) { ABORT_MPI("NEARBY", "Permission denied. Neither object is local."); } if (isneighbor(obj, obj2)) { return "1"; } else { return "0"; } }
void do_toad(int descr, dbref player, const char *name, const char *recip) { dbref victim; dbref recipient; dbref stuff; char buf[BUFFER_LEN]; if (!Wizard(player) || Typeof(player) != TYPE_PLAYER) { notify(player, "Only a Wizard player can turn a person into a toad."); return; } if ((victim = lookup_player(name)) == NOTHING) { notify(player, "That player does not exist."); return; } #ifdef GOD_PRIV if (God(victim)) { notify(player, "You cannot @toad God."); if(!God(player)) { log_status("TOAD ATTEMPT: %s(#%d) tried to toad God.",NAME(player),player); } return; } #endif if(player == victim) { /* If GOD_PRIV isn't defined, this could happen: we don't want the * last wizard to be toaded, in any case, so only someone else can * do it. */ notify(player, "You cannot toad yourself. Get someone else to do it for you."); return; } if (victim == tp_toad_default_recipient) { notify(player, "That player is part of the @toad process, and cannot be deleted."); return; } if (!*recip) { recipient = tp_toad_default_recipient; } else { if ((recipient = lookup_player(recip)) == NOTHING || recipient == victim) { notify(player, "That recipient does not exist."); return; } } if (Typeof(victim) != TYPE_PLAYER) { notify(player, "You can only turn players into toads!"); #ifdef GOD_PRIV } else if (!(God(player)) && (TrueWizard(victim))) { #else } else if (TrueWizard(victim)) { #endif notify(player, "You can't turn a Wizard into a toad."); } else { /* we're ok */ /* do it */ send_contents(descr, victim, HOME); dequeue_prog(victim, 0); /* Dequeue the programs that the player's running */ for (stuff = 0; stuff < db_top; stuff++) { if (OWNER(stuff) == victim) { switch (Typeof(stuff)) { case TYPE_PROGRAM: dequeue_prog(stuff, 0); /* dequeue player's progs */ if (TrueWizard(recipient)) { FLAGS(stuff) &= ~(ABODE | WIZARD); SetMLevel(stuff, 1); } case TYPE_ROOM: case TYPE_THING: case TYPE_EXIT: OWNER(stuff) = recipient; DBDIRTY(stuff); break; } } if (Typeof(stuff) == TYPE_THING && THING_HOME(stuff) == victim) { THING_SET_HOME(stuff, tp_lost_and_found); } } chown_macros(victim, recipient); if (PLAYER_PASSWORD(victim)) { free((void *) PLAYER_PASSWORD(victim)); PLAYER_SET_PASSWORD(victim, 0); } /* notify people */ notify(victim, "You have been turned into a toad."); snprintf(buf, sizeof(buf), "You turned %s into a toad!", NAME(victim)); notify(player, buf); log_status("TOADED: %s(%d) by %s(%d)", NAME(victim), victim, NAME(player), player); /* reset name */ delete_player(victim); snprintf(buf, sizeof(buf), "A slimy toad named %s", NAME(victim)); free((void *) NAME(victim)); NAME(victim) = alloc_string(buf); DBDIRTY(victim); boot_player_off(victim); /* Disconnect the toad */ if (PLAYER_DESCRS(victim)) { free(PLAYER_DESCRS(victim)); PLAYER_SET_DESCRS(victim, NULL); PLAYER_SET_DESCRCOUNT(victim, 0); } ignore_remove_from_all_players(victim); ignore_flush_cache(victim); FREE_PLAYER_SP(victim); ALLOC_THING_SP(victim); THING_SET_HOME(victim, PLAYER_HOME(player)); FLAGS(victim) = TYPE_THING; OWNER(victim) = player; /* you get it */ SETVALUE(victim, 1); /* don't let him keep his immense wealth */ } }
void do_teleport(int descr, dbref player, const char *arg1, const char *arg2) { dbref victim; dbref destination; const char *to; struct match_data md; /* get victim, destination */ if (*arg2 == '\0') { victim = player; to = arg1; } else { init_match(descr, player, arg1, NOTYPE, &md); match_neighbor(&md); match_possession(&md); match_me(&md); match_here(&md); match_absolute(&md); match_registered(&md); match_player(&md); if ((victim = noisy_match_result(&md)) == NOTHING) { return; } to = arg2; } #ifdef GOD_PRIV if(tp_strict_god_priv && !God(player) && God(OWNER(victim))) { notify(player, "God has already set that where He wants it to be."); return; } #endif /* get destination */ init_match(descr, player, to, TYPE_PLAYER, &md); match_possession(&md); match_me(&md); match_here(&md); match_home(&md); match_absolute(&md); match_registered(&md); if (Wizard(OWNER(player))) { match_neighbor(&md); match_player(&md); } switch (destination = match_result(&md)) { case NOTHING: notify(player, "Send it where?"); break; case AMBIGUOUS: notify(player, "I don't know which destination you mean!"); break; case HOME: switch (Typeof(victim)) { case TYPE_PLAYER: destination = PLAYER_HOME(victim); if (parent_loop_check(victim, destination)) destination = PLAYER_HOME(OWNER(victim)); break; case TYPE_THING: destination = THING_HOME(victim); if (parent_loop_check(victim, destination)) { destination = PLAYER_HOME(OWNER(victim)); if (parent_loop_check(victim, destination)) { destination = (dbref) 0; } } break; case TYPE_ROOM: destination = GLOBAL_ENVIRONMENT; break; case TYPE_PROGRAM: destination = OWNER(victim); break; default: destination = tp_player_start; /* caught in the next * switch anyway */ break; } default: switch (Typeof(victim)) { case TYPE_PLAYER: if (!controls(player, victim) || !controls(player, destination) || !controls(player, getloc(victim)) || (Typeof(destination) == TYPE_THING && !controls(player, getloc(destination)))) { notify(player, "Permission denied. (must control victim, dest, victim's loc, and dest's loc)"); break; } if (Typeof(destination) != TYPE_ROOM && Typeof(destination) != TYPE_THING) { notify(player, "Bad destination."); break; } if (!Wizard(victim) && (Typeof(destination) == TYPE_THING && !(FLAGS(destination) & VEHICLE))) { notify(player, "Destination object is not a vehicle."); break; } if (parent_loop_check(victim, destination)) { notify(player, "Objects can't contain themselves."); break; } notify(victim, "You feel a wrenching sensation..."); enter_room(descr, victim, destination, DBFETCH(victim)->location); notify(player, "Teleported."); break; case TYPE_THING: if (parent_loop_check(victim, destination)) { notify(player, "You can't make a container contain itself!"); break; } case TYPE_PROGRAM: if (Typeof(destination) != TYPE_ROOM && Typeof(destination) != TYPE_PLAYER && Typeof(destination) != TYPE_THING) { notify(player, "Bad destination."); break; } if (!((controls(player, destination) || can_link_to(player, NOTYPE, destination)) && (controls(player, victim) || controls(player, DBFETCH(victim)->location)))) { notify(player, "Permission denied. (must control dest and be able to link to it, or control dest's loc)"); break; } /* check for non-sticky dropto */ if (Typeof(destination) == TYPE_ROOM && DBFETCH(destination)->sp.room.dropto != NOTHING && !(FLAGS(destination) & STICKY)) destination = DBFETCH(destination)->sp.room.dropto; if (tp_thing_movement && (Typeof(victim) == TYPE_THING)) { enter_room(descr, victim, destination, DBFETCH(victim)->location); } else { moveto(victim, destination); } notify(player, "Teleported."); break; case TYPE_ROOM: if (Typeof(destination) != TYPE_ROOM) { notify(player, "Bad destination."); break; } if (!controls(player, victim) || !can_link_to(player, NOTYPE, destination) || victim == GLOBAL_ENVIRONMENT) { notify(player, "Permission denied. (Can't move #0, dest must be linkable, and must control victim)"); break; } if (parent_loop_check(victim, destination)) { notify(player, "Parent would create a loop."); break; } moveto(victim, destination); notify(player, "Parent set."); break; case TYPE_GARBAGE: notify(player, "That object is in a place where magic cannot reach it."); break; default: notify(player, "You can't teleport that."); break; } break; } return; }