void do_whisper(int descr, dbref player, const char *arg1, const char *arg2) { dbref who; char buf[BUFFER_LEN]; struct match_data md; init_match(descr, player, arg1, TYPE_PLAYER, &md); match_neighbor(&md); match_me(&md); if (Wizard(player) && Typeof(player) == TYPE_PLAYER) { match_absolute(&md); match_player(&md); } switch (who = match_result(&md)) { case NOTHING: notify(player, "Whisper to whom?"); break; case AMBIGUOUS: notify(player, "I don't know who you mean!"); break; default: snprintf(buf, sizeof(buf), "%s whispers, \"%s\"", NAME(player), arg2); if (!notify_from(player, who, buf)) { snprintf(buf, sizeof(buf), "%s is not connected.", NAME(who)); notify(player, buf); break; } snprintf(buf, sizeof(buf), "You whisper, \"%s\" to %s.", arg2, NAME(who)); notify(player, buf); break; } }
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); }
/* 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); }
/* * 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 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); }
void do_rob(int descr, dbref player, const char *what) { dbref thing; char buf[BUFFER_LEN]; struct match_data md; init_match(descr, player, what, TYPE_PLAYER, &md); match_neighbor(&md); match_me(&md); if (Wizard(OWNER(player))) { match_absolute(&md); match_player(&md); } thing = match_result(&md); switch (thing) { case NOTHING: notify(player, "Rob whom?"); break; case AMBIGUOUS: notify(player, "I don't know who you mean!"); break; default: if (Typeof(thing) != TYPE_PLAYER) { notify(player, "Sorry, you can only rob other players."); } else if (GETVALUE(thing) < 1) { snprintf(buf, sizeof(buf), "%s has no %s.", NAME(thing), tp_pennies); notify(player, buf); snprintf(buf, sizeof(buf), "%s tried to rob you, but you have no %s to take.", NAME(player), tp_pennies); notify(thing, buf); } else if (can_doit(descr, player, thing, "Your conscience tells you not to.")) { /* steal a penny */ SETVALUE(OWNER(player), GETVALUE(OWNER(player)) + 1); DBDIRTY(player); SETVALUE(thing, GETVALUE(thing) - 1); DBDIRTY(thing); notify_fmt(player, "You stole a %s.", tp_penny); snprintf(buf, sizeof(buf), "%s stole one of your %s!", NAME(player), tp_pennies); notify(thing, buf); } break; } }
void do_give(dbref player, dbref cause, int key, char *who, char *amnt) { dbref recipient; /* check recipient */ init_match(player, who, TYPE_PLAYER); match_neighbor(); match_possession(); match_me(); if (Privilaged(player) || HasPriv(player,NOTHING,POWER_LONG_FINGERS,POWER3,NOTHING)) { match_player(); match_absolute(); } recipient = match_result(); switch (recipient) { case NOTHING: notify(player, "Give to whom?"); return; case AMBIGUOUS: notify(player, "I don't know who you mean!"); return; } if (DePriv(player,recipient,DP_GIVE,POWER7,POWER_LEVEL_SPC)) { notify(player, "Permission denied."); return; } if (DePriv(recipient,player,DP_RECEIVE,POWER7,POWER_LEVEL_SPC)) { notify(player, "Permission denied."); return; } if (is_number(amnt)) { give_money(player, recipient, key, atoi(amnt)); } else if(Guest(recipient)) { notify(player, "Guest really doesn't need money or anything."); return; } else { if ( Typeof(player) != TYPE_ROOM ) give_thing(player, recipient, key, amnt); else notify(player, "Command incompatible with invoker type."); } }
// Specifically matches an exit for a given game driver HS_DBREF CHSInterface::NoisyMatchExit(HS_DBREF player, char *name) { HS_DBREF exit_m; #ifdef PENNMUSH // No change in code between versions exit_m = match_result(player, name, TYPE_EXIT, MAT_EXIT); #endif #if defined(TM3) || defined(MUX) init_match(player, name, TYPE_EXIT); match_exit(); match_absolute(); exit_m = noisy_match_result(); #endif if (exit_m == AMBIGUOUS) exit_m = NOTHING; return exit_m; }
static dbref parse_linkable_dest(int descr, dbref player, dbref exit, const char *dest_name) { dbref dobj; /* destination room/player/thing/link */ char buf[BUFFER_LEN]; struct match_data md; init_match(descr, player, dest_name, NOTYPE, &md); match_absolute(&md); match_everything(&md); match_home(&md); match_null(&md); if ((dobj = match_result(&md)) == NOTHING || dobj == AMBIGUOUS) { sprintf(buf, CINFO "I couldn't find '%s'.", dest_name); anotify_nolisten2(player, buf); return NOTHING; } if (!tp_teleport_to_player && Typeof(dobj) == TYPE_PLAYER) { sprintf(buf, CFAIL "You can't link to players. Destination %s ignored.", unparse_object(player, dobj)); anotify_nolisten2(player, buf); return NOTHING; } if (!can_link(player, exit)) { anotify_nolisten2(player, CFAIL "You can't link that."); return NOTHING; } if (!can_link_to(player, Typeof(exit), dobj)) { sprintf(buf, CFAIL "You can't link to %s.", unparse_object(player, dobj)); anotify_nolisten2(player, buf); return NOTHING; } else return dobj; }
HS_DBREF CHSInterface::NoisyMatchRoom(HS_DBREF player, char *name) { HS_DBREF room; #ifdef PENNMUSH // No change in code between versions room = noisy_match_result(player, name, TYPE_ROOM, MAT_ABSOLUTE | MAT_HERE); #endif #if defined(TM3) || defined(MUX) init_match(player, name, TYPE_ROOM); match_absolute(); match_here(); room = noisy_match_result(); #endif if (room == AMBIGUOUS) room = NOTHING; return room; }
dbref mesg_dbref_raw(int descr, dbref player, dbref what, dbref perms, const char *buf) { struct match_data md; dbref obj = UNKNOWN; if (buf && *buf) { if (!string_compare(buf, "this")) { obj = what; } else if (!string_compare(buf, "me")) { obj = player; } else if (!string_compare(buf, "here")) { obj = getloc(player); } else if (!string_compare(buf, "home")) { obj = HOME; } else { init_match(descr, player, buf, NOTYPE, &md); match_absolute(&md); match_all_exits(&md); match_neighbor(&md); match_possession(&md); match_registered(&md); obj = match_result(&md); if (obj == NOTHING) { init_match_remote(descr, player, what, buf, NOTYPE, &md); match_player(&md); match_all_exits(&md); match_neighbor(&md); match_possession(&md); match_registered(&md); obj = match_result(&md); } } } if (obj < 0 || obj >= db_top || Typeof(obj) == TYPE_GARBAGE) obj = UNKNOWN; return obj; }
/* * parse_source() * * This is a utility used by do_action and do_attach. It parses * the source string into a dbref, and checks to see that it * exists. * * The return value is the dbref of the source, or NOTHING if an * error occurs. * */ dbref parse_source(int descr, dbref player, const char *source_name) { dbref source; struct match_data md; init_match(descr, player, source_name, NOTYPE, &md); /* source type can be * any */ match_neighbor(&md); match_me(&md); match_here(&md); match_possession(&md); match_registered(&md); match_absolute(&md); source = noisy_match_result(&md); if (source == NOTHING) return NOTHING; /* You can only attach actions to things you control */ if (!controls(player, source)) { anotify_fmt(player, CFAIL "%s", tp_noperm_mesg); return NOTHING; } if (Typeof(source) == TYPE_EXIT) { anotify_nolisten2(player, CFAIL "You can't attach an action to an action."); return NOTHING; } if (Typeof(source) == TYPE_PROGRAM) { anotify_nolisten2(player, CFAIL "You can't attach an action to a program."); return NOTHING; } return source; }
void do_whisper(int descr, dbref player, const char *arg1, const char *arg2) { dbref who; char buf[BUFFER_LEN], buf2[BUFFER_LEN]; struct match_data md; if (Guest(player)) { anotify_fmt(player, CFAIL "%s", tp_noguest_mesg); return; } init_match(descr, player, arg1, TYPE_PLAYER, &md); match_neighbor(&md); match_me(&md); if (Mage(player) && Typeof(player) == TYPE_PLAYER) { match_absolute(&md); match_player(&md); } switch (who = match_result(&md)) { case NOTHING: anotify_nolisten2(player, CINFO "Who?"); break; case AMBIGUOUS: anotify_nolisten2(player, CINFO "I don't know who you mean!"); break; default: if (Meeper(OWNER(player))) { do_parse_mesg(descr, player, player, arg2, "(whisper)", buf, MPI_ISPRIVATE); tct(buf, buf2); } else { tct(arg2, buf2); } if (buf2[0] == ':' || buf2[0] == ';') { sprintf(buf, SYSBLUE "%s whispers, \"" SYSPURPLE "%s %s" SYSBLUE "\"", PNAME(player), PNAME(player), buf2 + 1); if (!anotify_from(player, who, buf)) { sprintf(buf, SYSBLUE "%s is not connected.", PNAME(who)); anotify_nolisten2(player, buf); break; } sprintf(buf, SYSBLUE "You whisper, \"" SYSPURPLE "%s %s" SYSBLUE "\" to %s.", PNAME(player), buf2 + 1, PNAME(who)); anotify(player, buf); break; } else { sprintf(buf, SYSBLUE "%s whispers, \"" SYSPURPLE "%s" SYSBLUE "\"", PNAME(player), buf2); if (!anotify_from(player, who, buf)) { sprintf(buf, SYSBLUE "%s is not connected.", PNAME(who)); anotify_nolisten2(player, buf); break; } sprintf(buf, SYSBLUE "You whisper, \"" SYSPURPLE "%s" SYSBLUE "\" to %s.", buf2, PNAME(who)); anotify(player, buf); break; } } }
void do_kill (dbref player, dbref cause, int key, char *what, char *costchar) { dbref victim; char *buf1, *buf2; int cost; init_match(player, what, TYPE_PLAYER); match_neighbor(); match_me(); match_here(); if (Wizard(player)) { match_player(); match_absolute(); } victim = match_result(); switch (victim) { case NOTHING: notify(player, "I don't see that player here."); break; case AMBIGUOUS: notify(player, "I don't know who you mean!"); break; default: if ((Typeof(victim) != TYPE_PLAYER) && (Typeof(victim) != TYPE_THING)) { notify(player, "Sorry, you can only kill players and things."); break; } if ((Haven(Location(victim)) && !Wizard(player)) || (controls(victim, Location(victim)) && !controls(player, Location(victim))) || Immortal(victim)) { notify(player, "Sorry."); break; } if (key == KILL_SLAY) { if (Builder(player) && Builder(victim)) { notify(player, "Sorry."); break; } } /* go for it */ cost = atoi(costchar); if (key == KILL_KILL) { if (HasPriv(victim,player,POWER_NOKILL,POWER4,NOTHING)) { notify(player, "Sorry."); break; } if (cost < mudconf.killmin) cost = mudconf.killmin; if (cost > mudconf.killmax) cost = mudconf.killmax; /* see if it works */ if (!payfor(player, cost)) { notify(player, unsafe_tprintf("You don't have enough %s.", mudconf.many_coins)); return; } } else { cost = 0; } if (!(((random() % mudconf.killguarantee) < cost) || (key == KILL_SLAY)) || Wizard(victim)) { /* Failure: notify player and victim only */ notify(player, "Your murder attempt failed."); buf1 = alloc_lbuf("do_kill.failed"); sprintf(buf1, "%s tried to kill you!", Name(player)); notify_with_cause(victim, player, buf1); if (Suspect(player)) { strcpy(buf1, Name(player)); if (player == Owner(player)) { raw_broadcast(0, WIZARD, "[Suspect] %s tried to kill %s(#%d).", buf1, Name(victim), victim); } else { buf2 = alloc_lbuf("do_kill.SUSP.failed"); strcpy(buf2, Name(Owner(player))); raw_broadcast(0, WIZARD, "[Suspect] %s <via %s(#%d)> tried to kill %s(#%d).", buf2, buf1, player, Name(victim), victim); free_lbuf(buf2); } } free_lbuf(buf1); break; } /* Success! You killed him */ buf1 = alloc_lbuf("do_kill.succ.1"); buf2 = alloc_lbuf("do_kill.succ.2"); if (Suspect(player)) { strcpy(buf1, Name(player)); if (player == Owner(player)) { raw_broadcast(0, WIZARD, "[Suspect] %s killed %s(#%d).", buf1, Name(victim), victim); } else { strcpy(buf2, Name(Owner(player))); raw_broadcast(0, WIZARD, "[Suspect] %s <via %s(#%d)> killed %s(#%d).", buf2, buf1, player, Name(victim), victim); } } sprintf(buf1, "You killed %s!", Name(victim)); sprintf(buf2, "killed %s!", Name(victim)); if (Typeof(victim) != TYPE_PLAYER) if (halt_que(NOTHING, victim) > 0) if (!Quiet(victim)) notify(Owner(victim), "Halted."); did_it(player, victim, A_KILL, buf1, A_OKILL, buf2, A_AKILL, (char **)NULL, 0); /* notify victim */ sprintf(buf1, "%s killed you!", Name(player)); notify_with_cause(victim, player, buf1); /* Pay off the bonus */ if (key == KILL_KILL) { cost /= 2; /* victim gets half */ if (Pennies(Owner(victim)) < mudconf.paylimit) { sprintf(buf1, "Your insurance policy pays %d %s.", cost, mudconf.many_coins); notify(victim, buf1); giveto(Owner(victim), cost, NOTHING); } else { notify(victim, "Your insurance policy has been revoked."); } } free_lbuf(buf1); free_lbuf(buf2); /* send him home */ move_via_generic(victim, HOME, NOTHING, 0); divest_object(victim); break; } }
void do_kill(int descr, dbref player, const char *what, int cost) { dbref victim; char buf[BUFFER_LEN]; struct match_data md; init_match(descr, player, what, TYPE_PLAYER, &md); match_neighbor(&md); match_me(&md); if (Wizard(OWNER(player))) { match_player(&md); match_absolute(&md); } victim = match_result(&md); switch (victim) { case NOTHING: notify(player, "I don't see that player here."); break; case AMBIGUOUS: notify(player, "I don't know who you mean!"); break; default: if (Typeof(victim) != TYPE_PLAYER) { notify(player, "Sorry, you can only kill other players."); } else { /* go for it */ /* set cost */ if (cost < tp_kill_min_cost) cost = tp_kill_min_cost; if (FLAGS(DBFETCH(player)->location) & HAVEN) { notify(player, "You can't kill anyone here!"); break; } if (tp_restrict_kill) { if (!(FLAGS(player) & KILL_OK)) { notify(player, "You have to be set Kill_OK to kill someone."); break; } if (!(FLAGS(victim) & KILL_OK)) { notify(player, "They don't want to be killed."); break; } } /* see if it works */ if (!payfor(player, cost)) { notify_fmt(player, "You don't have enough %s.", tp_pennies); } else if ((RANDOM() % tp_kill_base_cost) < cost && !Wizard(OWNER(victim))) { /* you killed him */ if (GETDROP(victim)) /* give him the drop message */ notify(player, GETDROP(victim)); else { snprintf(buf, sizeof(buf), "You killed %s!", NAME(victim)); notify(player, buf); } /* now notify everybody else */ if (GETODROP(victim)) { snprintf(buf, sizeof(buf), "%s killed %s! ", NAME(player), NAME(victim)); parse_oprop(descr, player, getloc(player), victim, MESGPROP_ODROP, buf, "(@Odrop)"); } else { snprintf(buf, sizeof(buf), "%s killed %s!", NAME(player), NAME(victim)); } notify_except(DBFETCH(DBFETCH(player)->location)->contents, player, buf, player); /* maybe pay off the bonus */ if (GETVALUE(victim) < tp_max_pennies) { snprintf(buf, sizeof(buf), "Your insurance policy pays %d %s.", tp_kill_bonus, tp_pennies); notify(victim, buf); SETVALUE(victim, GETVALUE(victim) + tp_kill_bonus); DBDIRTY(victim); } else { notify(victim, "Your insurance policy has been revoked."); } /* send him home */ send_home(descr, victim, 1); } else { /* notify player and victim only */ notify(player, "Your murder attempt failed."); snprintf(buf, sizeof(buf), "%s tried to kill you!", NAME(player)); notify(victim, buf); } break; } } }
void do_give(int descr, dbref player, const char *recipient, int amount) { dbref who; char buf[BUFFER_LEN]; struct match_data md; /* do amount consistency check */ if (amount < 0 && !Wizard(OWNER(player))) { notify(player, "Try using the \"rob\" command."); return; } else if (amount == 0) { notify_fmt(player, "You must specify a positive number of %s.", tp_pennies); return; } /* check recipient */ init_match(descr, player, recipient, TYPE_PLAYER, &md); match_neighbor(&md); match_me(&md); if (Wizard(OWNER(player))) { match_player(&md); match_absolute(&md); } switch (who = match_result(&md)) { case NOTHING: notify(player, "Give to whom?"); return; case AMBIGUOUS: notify(player, "I don't know who you mean!"); return; default: if (!Wizard(OWNER(player))) { if (Typeof(who) != TYPE_PLAYER) { notify(player, "You can only give to other players."); return; } else if (GETVALUE(who) + amount > tp_max_pennies) { notify_fmt(player, "That player doesn't need that many %s!", tp_pennies); return; } } break; } /* try to do the give */ if (!payfor(player, amount)) { notify_fmt(player, "You don't have that many %s to give!", tp_pennies); } else { /* he can do it */ switch (Typeof(who)) { case TYPE_PLAYER: SETVALUE(who, GETVALUE(who) + amount); if(amount >= 0) { snprintf(buf, sizeof(buf), "You give %d %s to %s.", amount, amount == 1 ? tp_penny : tp_pennies, NAME(who)); notify(player, buf); snprintf(buf, sizeof(buf), "%s gives you %d %s.", NAME(player), amount, amount == 1 ? tp_penny : tp_pennies); notify(who, buf); } else { snprintf(buf, sizeof(buf), "You take %d %s from %s.", -amount, amount == -1 ? tp_penny : tp_pennies, NAME(who)); notify(player, buf); snprintf(buf, sizeof(buf), "%s takes %d %s from you!", NAME(player), -amount, -amount == 1 ? tp_penny : tp_pennies); notify(who, buf); } break; case TYPE_THING: SETVALUE(who, (GETVALUE(who) + amount)); snprintf(buf, sizeof(buf), "You change the value of %s to %d %s.", NAME(who), GETVALUE(who), GETVALUE(who) == 1 ? tp_penny : tp_pennies); notify(player, buf); break; default: notify_fmt(player, "You can't give %s to that!", tp_pennies); break; } DBDIRTY(who); } }
void do_whisper(dbref player, const char *arg1, const char *arg2) { int ignored; dbref who; char buf[BUFFER_LEN], buf2[BUFFER_LEN]; struct match_data md; if(Guest(player)) { anotify(player, CFAIL NOGUEST_MESG); return; } init_match(player, arg1, TYPE_PLAYER, &md); match_neighbor(&md); match_me(&md); if (Mage(player) && Typeof(player) == TYPE_PLAYER) { match_absolute(&md); match_player(&md); } switch (who = match_result(&md)) { case NOTHING: case AMBIGUOUS: anotify(player, CINFO WHO_MESG); break; default: ignored = ignoring(who, player); if(ignored == 1) { anotify(player, CFAIL "That player is ignoring you."); return; } else if(ignored == 2) { anotify(player, CINFO "That player is ignoring you."); } do_parse_mesg(player, player, arg2, "(whisper)", buf, MPI_ISPRIVATE); tct(buf,buf2); if (buf2[0] == ':' || buf2[0] == ';') { sprintf(buf, CBLUE "%s whispers, \"" CPURPLE "%s %.3900s" CBLUE "\"", PNAME(player), PNAME(player), buf2+1); if (!anotify_from(player, who, buf)) { sprintf(buf, CBLUE "%s is not connected.", PNAME(who)); anotify(player, buf); break; } sprintf(buf, CBLUE "You whisper, \"" CPURPLE "%s %.3900s" CBLUE "\" to %s.", PNAME(player), buf2+1, PNAME(who)); anotify(player, buf); break; } else { sprintf(buf, CBLUE "%s whispers, \"" CPURPLE "%.3900s" CBLUE "\"", PNAME(player), buf2); if (!anotify_from(player, who, buf)) { sprintf(buf, CBLUE "%s is not connected.", PNAME(who)); anotify(player, buf); break; } sprintf(buf, CBLUE "You whisper, \"" CPURPLE "%.3900s" CBLUE "\" to %s.", buf2, PNAME(who)); anotify(player, buf); break; } } }
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; }
/* * 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); } }
/* do_link * * Use this to link to a room that you own. It also sets home for * objects and things, and drop-to's for rooms. * It seizes ownership of an unlinked exit, and costs 1 penny * plus a penny transferred to the exit owner if they aren't you * * All destinations must either be owned by you, or be LINK_OK. */ void do_link(int descr, dbref player, const char *thing_name, const char *dest_name) { dbref good_dest[MAX_LINKS]; int ndest, i; struct match_data md; char buf[BUFFER_LEN]; dbref thing, dest; if (tp_db_readonly) { anotify_nolisten2(player, CFAIL DBRO_MESG); return; } if (Guest(player)) { anotify_fmt(player, CFAIL "%s", tp_noguest_mesg); return; } init_match(descr, player, thing_name, TYPE_EXIT, &md); match_all_exits(&md); match_neighbor(&md); match_possession(&md); match_me(&md); match_here(&md); match_absolute(&md); match_registered(&md); if (Mage(OWNER(player))) match_player(&md); if ((thing = noisy_match_result(&md)) == NOTHING) return; switch (Typeof(thing)) { case TYPE_EXIT: /* we're ok, check the usual stuff */ if (DBFETCH(thing)->sp.exit.ndest != 0) { if (controls(player, thing)) { if ((DBFETCH(thing)->sp.exit.dest)[0] != NIL) { anotify_nolisten2(player, CINFO "That exit is already linked."); return; } } else { anotify_fmt(player, CFAIL "%s", tp_noperm_mesg); return; } } /* handle costs */ if (OWNER(thing) == OWNER(player)) { if (!payfor(player, tp_link_cost)) { anotify_fmt(player, CFAIL "It costs %d %s to link this exit.", tp_link_cost, (tp_link_cost == 1) ? tp_penny : tp_pennies); return; } } else { if (!payfor(player, tp_link_cost + tp_exit_cost)) { anotify_fmt(player, CFAIL "It costs %d %s to link this exit.", (tp_link_cost + tp_exit_cost), (tp_link_cost + tp_exit_cost == 1) ? tp_penny : tp_pennies); return; } else if (!Builder(player)) { anotify_nolisten2(player, CFAIL NOBBIT_MESG); return; } else { /* pay the owner for his loss */ dbref owner = OWNER(thing); DBFETCH(owner)->sp.player.pennies += tp_exit_cost; DBDIRTY(owner); } } /* link has been validated and paid for; do it */ OWNER(thing) = OWNER(player); if (! (ndest = link_exit(descr, player, thing, (char *) dest_name, good_dest))) { anotify_nolisten2(player, CFAIL "No destinations linked."); DBFETCH(player)->sp.player.pennies += tp_link_cost; /* Refund! */ DBDIRTY(player); break; } DBFETCH(thing)->sp.exit.ndest = ndest; if (DBFETCH(thing)->sp.exit.dest) free(DBFETCH(thing)->sp.exit.dest); DBFETCH(thing)->sp.exit.dest = (dbref *) malloc(sizeof(dbref) * ndest); for (i = 0; i < ndest; i++) (DBFETCH(thing)->sp.exit.dest)[i] = good_dest[i]; break; case TYPE_THING: case TYPE_PLAYER: init_match(descr, player, dest_name, TYPE_ROOM, &md); match_neighbor(&md); match_absolute(&md); match_registered(&md); match_me(&md); match_here(&md); match_null(&md); if (Typeof(thing) == TYPE_THING) match_possession(&md); if ((dest = noisy_match_result(&md)) == NOTHING) return; if (Typeof(thing) == TYPE_THING && dest == NIL) { anotify_fmt(player, CFAIL "%s", "You cannot HOME a THING to NIL."); return; } if (!controls(player, thing) || !can_link_to(player, Typeof(thing), dest)) { anotify_fmt(player, CFAIL "%s", tp_noperm_mesg); return; } if (parent_loop_check(thing, dest)) { anotify_nolisten2(player, CFAIL "That would cause a parent paradox."); return; } /* do the link */ if (Typeof(thing) == TYPE_THING) { DBFETCH(thing)->sp.thing.home = dest; } else DBFETCH(thing)->sp.player.home = dest; sprintf(buf, CSUCC "%s's home set to %s.", NAME(thing), unparse_object(player, dest)); anotify_nolisten2(player, buf); break; case TYPE_ROOM: /* room dropto's */ init_match(descr, player, dest_name, TYPE_ROOM, &md); match_neighbor(&md); match_possession(&md); match_registered(&md); match_absolute(&md); match_home(&md); match_null(&md); if ((dest = noisy_match_result(&md)) == NOTHING) break; if (!controls(player, thing) || !can_link_to(player, Typeof(thing), dest) || (thing == dest)) { anotify_fmt(player, CFAIL "%s", tp_noperm_mesg); } else { DBFETCH(thing)->sp.room.dropto = dest; /* dropto */ sprintf(buf, CSUCC "%s's dropto set to %s.", NAME(thing), unparse_object(player, dest)); anotify_nolisten2(player, buf); } break; case TYPE_PROGRAM: anotify_nolisten2(player, CFAIL "You can't link programs to things!"); break; default: anotify_nolisten2(player, CFAIL "Weird object type."); log_status("*BUG: weird object: Typeof(%d) = %d\n", thing, Typeof(thing)); break; } DBDIRTY(thing); return; }
void do_force(int descr, dbref player, const char *what, char *command) { dbref victim, loc; struct match_data md; assert(what != NULL); assert(command != NULL); assert(player > 0); if (force_level > (tp_max_force_level - 1)) { notify(player, "Can't force recursively."); return; } if (!tp_zombies && (!Wizard(player) || Typeof(player) != TYPE_PLAYER)) { notify(player, "Zombies are not enabled here."); return; #ifdef DEBUG } else { notify(player, "[debug] Zombies are not enabled for nonwizards -- force succeeded."); #endif } /* get victim */ init_match(descr, player, what, 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) { #ifdef DEBUG notify(player, "[debug] do_force: unable to find your target!"); #endif /* DEBUG */ return; } if (Typeof(victim) != TYPE_PLAYER && Typeof(victim) != TYPE_THING) { notify(player, "Permission Denied -- Target not a player or thing."); return; } #ifdef GOD_PRIV if (God(victim)) { notify(player, "You cannot force God to do anything."); return; } #endif /* GOD_PRIV */ /* if (!controls(player, victim)) { * notify(player, "Permission denied. (you're not a wizard!)"); * return; * } */ if (!Wizard(player) && !(FLAGS(victim) & XFORCIBLE)) { notify(player, "Permission denied: forced object not @set Xforcible."); return; } if (!Wizard(player) && !test_lock_false_default(descr, player, victim, MESGPROP_FLOCK)) { notify(player, "Permission denied: Object not force-locked to you."); return; } loc = getloc(victim); if (!Wizard(player) && Typeof(victim) == TYPE_THING && loc != NOTHING && (FLAGS(loc) & ZOMBIE) && Typeof(loc) == TYPE_ROOM) { notify(player, "Sorry, but that's in a no-puppet zone."); return; } if (!Wizard(OWNER(player)) && Typeof(victim) == TYPE_THING) { const char *ptr = NAME(victim); char objname[BUFFER_LEN], *ptr2; if ((FLAGS(player) & ZOMBIE)) { notify(player, "Permission denied -- you cannot use zombies."); return; } if (FLAGS(victim) & DARK) { notify(player, "Permission denied -- you cannot force dark zombies."); return; } for (ptr2 = objname; *ptr && !isspace(*ptr);) *(ptr2++) = *(ptr++); *ptr2 = '\0'; if (lookup_player(objname) != NOTHING) { notify(player, "Puppet cannot share the name of a player."); return; } } log_status("FORCED: %s(%d) by %s(%d): %s", NAME(victim), victim, NAME(player), player, command); /* force victim to do command */ force_prog=NOTHING; force_level++; process_command(dbref_first_descr(victim), victim, command); force_level--; force_prog=NOTHING; }
void match_and_list(int descr, dbref player, const char *name, char *linespec) { dbref thing; char *p; char *q; int range[2]; int argc; struct match_data md; struct line *tmpline; init_match(descr, player, name, TYPE_PROGRAM, &md); match_neighbor(&md); match_possession(&md); match_registered(&md); match_absolute(&md); if ((thing = noisy_match_result(&md)) == NOTHING) return; if (Typeof(thing) != TYPE_PROGRAM) { notify(player, "You can't list anything but a program."); return; } /* if (!(controls(player, thing) || Linkable(thing))) { */ if (!(controls(player, thing) || (FLAGS(thing) & VEHICLE))) { notify(player, "Permission denied. (You don't control the program, and it's not set Viewable)"); return; } if (!*linespec) { range[0] = 1; range[1] = -1; argc = 2; } else { q = p = linespec; while (*p) { while (*p && !isspace(*p)) *q++ = *p++; while (*p && isspace(*++p)) ; } *q = '\0'; argc = 1; if (isdigit(*linespec)) { range[0] = atoi(linespec); while (*linespec && isdigit(*linespec)) linespec++; } else { range[0] = 1; } if (*linespec) { argc = 2; while (*linespec && !isdigit(*linespec)) linespec++; if (*linespec) range[1] = atoi(linespec); else range[1] = -1; } } tmpline = PROGRAM_FIRST(thing); PROGRAM_SET_FIRST(thing, read_program(thing)); do_list(player, thing, range, argc); free_prog_text(PROGRAM_FIRST(thing)); PROGRAM_SET_FIRST(thing, tmpline); return; }
void do_dequeue(int descr, dbref player, const char *arg1) { char buf[BUFFER_LEN]; int count; dbref match; struct match_data md; timequeue tmp, ptr = tqhead; if (*arg1 == '\0') { notify_nolisten(player, "What event do you want to dequeue?", 1); } else { if (!string_compare(arg1, "all")) { if (!Wizard(OWNER(player))) { notify_nolisten(player, "Permission denied", 1); return; } while (ptr) { tmp = ptr; tqhead = ptr = ptr->next; free_timenode(tmp); process_count--; } tqhead = NULL; muf_event_dequeue(NOTHING, 0); notify_nolisten(player, "Time queue cleared.", 1); } else { if (!number(arg1)) { init_match(descr, player, arg1, NOTYPE, &md); match_absolute(&md); match_everything(&md); match = noisy_match_result(&md); if (match == NOTHING) { notify_nolisten(player, "I don't know what you want to dequeue!", 1); return; } if (!valid_objref(match)) { notify_nolisten(player, "I don't recognize that object.", 1); return; } if ((!Wizard(OWNER(player))) && (OWNER(match) != OWNER(player))) { notify_nolisten(player, "Permission denied.", 1); return; } count = dequeue_prog(match, 0); if (!count) { notify_nolisten(player, "That program wasn't in the time queue.", 1); return; } if (count > 1) { snprintf(buf, sizeof(buf), "%d processes dequeued.", count); } else { snprintf(buf, sizeof(buf), "Process dequeued."); } notify_nolisten(player, buf, 1); } else { if ((count = atoi(arg1))) { if (!(control_process(player, count))) { notify_nolisten(player, "Permission denied.", 1); return; } if (!(dequeue_process(count))) { notify_nolisten(player, "No such process!", 1); return; } process_count--; notify_nolisten(player, "Process dequeued.", 1); } else { notify_nolisten(player, "What process do you want to dequeue?", 1); } } } } return; }