Beispiel #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);
}
Beispiel #2
0
void
prim_force(PRIM_PROTOTYPE)
{
	struct inst *oper1 = NULL; /* prevents re-entrancy issues! */
	struct inst *oper2 = NULL; /* prevents re-entrancy issues! */

	int i;

	/* d s -- */
	CHECKOP(2);
	oper1 = POP();				/* string to @force */
	oper2 = POP();				/* player dbref */
	if (mlev < 4)
		abort_interp("Wizbit only primitive.");
	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 (0 == strcmp(DoNullInd(oper1->data.string), ""))
		abort_interp("Empty command argument (2).");
	if (index(oper1->data.string->data, '\r'))
		abort_interp("Carriage returns not allowed in command string. (2).");
#ifdef GOD_PRIV
	if (God(oper2->data.objref) && !God(OWNER(program)))
		abort_interp("Cannot force god (1).");
#endif
	force_prog = program;
	force_level++;
	process_command(dbref_first_descr(oper2->data.objref), oper2->data.objref,
					oper1->data.string->data);
	force_level--;
	force_prog = NOTHING;

	for (i = 1; i <= fr->caller.top; i++) {
		if (Typeof(fr->caller.st[i]) != TYPE_PROGRAM) {
#ifdef DEBUG
			char str[BUFFER_LEN];
			snprintf(str,BUFFER_LEN,"[debug] prim_force: fr->caller.st[%d] isn't a program.",i);
			notify_nolisten(player,str,1);
#endif /* DEBUG */
			do_abort_silent();
		}
	}

	CLEAR(oper1);
	CLEAR(oper2);
}
Beispiel #3
0
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;
}
Beispiel #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; 
}