Example #1
0
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);
}
Example #2
0
void 
do_dump(dbref player, const char *newfile)
{
    char    buf[BUFFER_LEN];

    if (Wiz(player)) {
	if (*newfile && Man(player)) {
	    if (dumpfile) free( (void *)dumpfile );
	    dumpfile = alloc_string(newfile);
	    sprintf(buf, CINFO "Dumping to file %s...", dumpfile);
	} else {
	    sprintf(buf, CINFO "Dumping to file %s...", dumpfile);
	}
	anotify_nolisten2(player, buf);
	dump_db_now();
	anotify_nolisten2(player, CINFO "Done.");
    } else {
	anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
    }
}
Example #3
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. (1)");
    if (obj == PERMDENIED)
	ABORT_MPI("FORCE","Permission denied. (1)");
    if (Typeof(obj) != TYPE_THING && Typeof(obj) != TYPE_PLAYER)
	ABORT_MPI("FORCE","Bad object reference. (1)");
    if (!*argv[1])
	ABORT_MPI("FORCE","Null command string. (2)");
    if (!tp_zombies && !Archperms(perms))
	ABORT_MPI("FORCE",NOPERM_MESG);
    if (!Archperms(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",NOPERM_MESG);
	    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",NOPERM_MESG);
	}
	if (!test_lock_false_default(perms, obj, "@/flk")) {
	    ABORT_MPI("FORCE",NOPERM_MESG);
	}
    }
    if (Man(obj) && !TMan(perms))
	ABORT_MPI("FORCE","You can't force " NAMEMAN);
    if (!controls(OWNER(perms),obj))
	ABORT_MPI("FORCE",NOPERM_MESG);
    if ((WLevel(OWNER(perms)) < WLevel(obj)) ||
	(WLevel(perms) < WLevel(obj))
    )	ABORT_MPI("FORCE",NOPERM_MESG);
    if (force_level)
	ABORT_MPI("FORCE","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, 0);
	force_level--;
	ptr = nxt;
    } while (ptr);
    *buf = '\0';
    return "";
}
Example #4
0
void
prim_force(PRIM_PROTOTYPE)
{
    int nFrameIndex = -1; /* -1 means it hasn't been set */
    int nCurFr = 0; /* Loop iterator */
    int wclen = -2;
    int len;
    /* 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)) && Boy(program)))
        abort_interp("Cannot force the man (1)");

    strcpy(buf, oper1->data.string->data);
    len = oper1->data.string->length;
#ifdef UTF8_SUPPORT
    wclen = oper1->data.string->wclength;
#endif
    CLEAR(oper1);
    CLEAR(oper2);
    nargs -= 2;

    force_level++;
    /* Okay, we need to store a pointer to the fr in the global stack of
     * frame pointers we need to enable ispid? and getpidinfo to be able
     * to search. */
    for ( ; nCurFr < 9; ++nCurFr )
    {
        if ( !aForceFrameStack[nCurFr] )
        {
            aForceFrameStack[nCurFr] = fr;
            nFrameIndex = nCurFr;
            break;
        }
    }
    
    if ( nFrameIndex == -1 )
    {
        abort_interp( "Internal error trying to cache frame pointer." );
    }

    fr->level++;
    interp_set_depth(fr);
    process_command(dbref_first_descr(ref), ref, buf, len, wclen);
    fr->level--;
    interp_set_depth(fr);
    force_level--;

    /* Now remove our pointer from the end of the array */
    aForceFrameStack[nFrameIndex] = NULL; 
}