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 ""; }
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; }