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"; } }
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"; } }
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 * mfn_fullname(MFUNARGS) { 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)); return buf; }
const char * mfn_holds(MFUNARGS) { dbref obj1 = mesg_dbref_raw(descr, player, what, perms, argv[0]); dbref obj2 = player; if (argc > 1) obj2 = mesg_dbref_local(descr, player, what, perms, argv[1], mesgtyp); if (obj1 == UNKNOWN || obj1 == AMBIGUOUS || obj1 == NOTHING || obj1 == HOME) ABORT_MPI("HOLDS", "Match failed (1)."); if (obj1 == PERMDENIED) ABORT_MPI("HOLDS", "Permission Denied (1)."); if (obj2 == UNKNOWN || obj2 == AMBIGUOUS || obj2 == NOTHING || obj2 == HOME) ABORT_MPI("HOLDS", "Match failed (2)."); if (obj2 == PERMDENIED) ABORT_MPI("HOLDS", "Permission Denied (2)."); if (obj2 == getloc(obj1)) { return "1"; } else { return "0"; } }
const char * mfn_type(MFUNARGS) { dbref obj = mesg_dbref_raw(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","Permission Denied."); 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_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; }
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_dbeq(MFUNARGS) { dbref obj1 = mesg_dbref_raw(descr, player, what, perms, argv[0]); dbref obj2 = mesg_dbref_raw(descr, player, what, perms, argv[1]); if (obj1 == UNKNOWN || obj1 == PERMDENIED) ABORT_MPI("DBEQ", "Match failed (1)."); if (obj2 == UNKNOWN || obj2 == PERMDENIED) ABORT_MPI("DBEQ", "Match failed (2)."); if (obj1 == obj2) { return "1"; } else { return "0"; } }
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 ""; }
const char * mfn_muf(MFUNARGS) { char *ptr; struct inst *rv = NULL; dbref obj = mesg_dbref_raw(player, what, perms, argv[0]); if (obj == UNKNOWN) ABORT_MPI("MUF","Match failed"); if (obj <= NOTHING || Typeof(obj) != TYPE_PROGRAM) ABORT_MPI("MUF","Bad program reference"); if (!(FLAGS(obj) & LINK_OK) && !controls(perms,obj)) ABORT_MPI("MUF",NOPERM_MESG); if ((mesgtyp & (MPI_ISLISTENER | MPI_ISLOCK)) && (MLevel(obj) < LM3)) ABORT_MPI("MUF",NOPERM_MESG); if (++mpi_muf_call_levels > 18) ABORT_MPI("MUF","Too many call levels"); strcpy(match_args, argv[1]); ptr = get_mvar("how"); strcpy(match_cmdname, ptr); strcat(match_cmdname, "(MPI)"); rv = interp(player, DBFETCH(player)->location, obj, perms, PREEMPT, STD_HARDUID, 1); mpi_muf_call_levels--; if (!rv) return ""; switch(rv->type) { case PROG_STRING: if (rv->data.string) { strcpy(buf, rv->data.string->data); CLEAR(rv); return buf; } else { CLEAR(rv); return ""; } break; case PROG_INTEGER: sprintf(buf, "%d", rv->data.number); CLEAR(rv); return buf; break; case PROG_OBJECT: ptr = ref2str(rv->data.objref, buf); CLEAR(rv); return ptr; break; default: CLEAR(rv); return ""; break; } return ""; }
dbref mesg_dbref_proximity(dbref player, dbref what, dbref perms, char *buf) { dbref obj = mesg_dbref_raw(player, what, perms, buf); if (obj == UNKNOWN) return obj; if (!mesg_proximity_perms(player, perms, obj)) { obj = PERMDENIED; } return obj; }
dbref mesg_dbref_strict(int descr, dbref player, dbref what, dbref perms, char *buf) { dbref obj = mesg_dbref_raw(descr, player, what, perms, buf); if (obj == UNKNOWN) return obj; if (!Wizperms(perms) && OWNER(perms) != OWNER(obj)) { obj = PERMDENIED; } return obj; }
dbref mesg_dbref_local(int descr, dbref player, dbref what, dbref perms, char *buf) { dbref obj = mesg_dbref_raw(descr, player, what, perms, buf); if (obj == UNKNOWN) return obj; if (!mesg_local_perms(player, perms, obj)) { obj = PERMDENIED; } return obj; }
dbref mesg_dbref_strict(int descr, dbref player, dbref what, dbref perms, char *buf, int mesgtyp) { dbref obj = mesg_dbref_raw(descr, player, what, perms, buf); if (obj == UNKNOWN) return obj; if (!(mesgtyp & MPI_ISBLESSED) && OWNER(perms) != OWNER(obj)) { obj = PERMDENIED; } return obj; }
dbref mesg_dbref(int descr, dbref player, dbref what, dbref perms, char *buf, int mesgtyp) { dbref obj = mesg_dbref_raw(descr, player, what, perms, buf); if (obj == UNKNOWN) return obj; if (!mesg_read_perms(player, perms, obj, mesgtyp)) { obj = PERMDENIED; } return obj; }
dbref mesg_dbref_write(dbref player, dbref what, dbref perms, char *buf) { dbref obj = mesg_dbref_raw(player, what, perms, buf); if (obj == UNKNOWN) return obj; if (!Wizperms(perms) && !controls_nowizperm(OWNER(perms), obj)) { obj = PERMDENIED; } return obj; }
const char * mfn_owner(MFUNARGS) { dbref obj; obj = mesg_dbref_raw(player, what, perms, argv[0]); if (obj == AMBIGUOUS || obj == NOTHING || obj == UNKNOWN) ABORT_MPI("OWNER","Failed match"); if (obj == PERMDENIED) ABORT_MPI("OWNER",NOPERM_MESG); if (obj == HOME) obj = DBFETCH(player)->sp.player.home; return ref2str(OWNER(obj), buf); }
const char * mfn_otell(MFUNARGS) { char buf2[BUFFER_LEN]; char *ptr, *ptr2; dbref obj = getloc(player); dbref eobj = player; dbref thing; if (argc > 1) obj = mesg_dbref_local(descr, player, what, perms, argv[1], mesgtyp); if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME) ABORT_MPI("OTELL", "Match failed."); if (obj == PERMDENIED) ABORT_MPI("OTELL", "Permission denied."); if ((mesgtyp & MPI_ISLISTENER) && (Typeof(what) != TYPE_ROOM)) ABORT_MPI("OTELL", "Permission denied."); if (argc > 2) eobj = mesg_dbref_raw(descr, player, what, perms, argv[2]); strcpyn(buf2, sizeof(buf2), argv[0]); for (ptr = buf2; *ptr; ptr = ptr2) { ptr2 = index(ptr, '\r'); if (ptr2) { *ptr2 = '\0'; } else { ptr2 = ptr + strlen(ptr); } if (((OWNER(what) == OWNER(obj) || isancestor(what, obj)) && (Typeof(what) == TYPE_ROOM || (Typeof(what) == TYPE_EXIT && Typeof(getloc(what)) == TYPE_ROOM))) || string_prefix(argv[0], NAME(player))) { strcpyn(buf, buflen, ptr); } else { snprintf(buf, BUFFER_LEN, "%.16s%s%.4078s", NAME(player), ((*argv[0] == '\'' || isspace(*argv[0])) ? "" : " "), ptr); } thing = DBFETCH(obj)->contents; while (thing != NOTHING) { if (thing != eobj) { notify_from_echo(player, thing, buf, 0); } thing = DBFETCH(thing)->next; } } return argv[0]; }
const char * mfn_idle(MFUNARGS) { dbref obj = mesg_dbref_raw(descr, player, what, perms, argv[0]); int conn; if (obj == PERMDENIED) ABORT_MPI("IDLE", "Permission denied."); if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME) return "-1"; if (Typeof(obj) != TYPE_PLAYER) obj = OWNER(obj); conn = least_idle_player_descr(obj); if (!conn) return "-1"; snprintf(buf, BUFFER_LEN, "%d", pidle(conn)); return buf; }
const char * mfn_ref(MFUNARGS) { dbref obj; char *p; for (p = argv[0]; *p && isspace(*p); p++); if (*p == '#' && number(p+1)) { obj = atoi(p+1); } else { obj = mesg_dbref_raw(player, what, perms, argv[0]); if (obj == PERMDENIED) ABORT_MPI("REF","Permission denied."); if (obj == UNKNOWN) obj = NOTHING; } sprintf(buf, "#%d", obj); return buf; }