示例#1
0
const char *
mfn_kill(MFUNARGS)
{
    int i = atoi(argv[0]);
    if (i > 0) {
	if (in_timequeue(i)) {
	    if (!control_process(perms, i)) {
		ABORT_MPI("KILL",NOPERM_MESG);
	    }
	    i = dequeue_process(i);
	} else {
	    i = 0;
	}
    } else if (i == 0) {
	i = dequeue_prog(perms, 0);
    } else {
	ABORT_MPI("KILL","Invalid process ID");
    }
    sprintf(buf, "%d", i);
    return buf;
}
示例#2
0
文件: wiz.c 项目: hyena/fuzzball
void
do_toad(int descr, dbref player, const char *name, const char *recip)
{
	dbref victim;
	dbref recipient;
	dbref stuff;
	char buf[BUFFER_LEN];

	if (!Wizard(player) || Typeof(player) != TYPE_PLAYER) {
		notify(player, "Only a Wizard player can turn a person into a toad.");
		return;
	}
	if ((victim = lookup_player(name)) == NOTHING) {
		notify(player, "That player does not exist.");
		return;
	}
#ifdef GOD_PRIV
	if (God(victim)) {
		notify(player, "You cannot @toad God.");
		if(!God(player)) {
			log_status("TOAD ATTEMPT: %s(#%d) tried to toad God.",NAME(player),player);
		}
		return;
	}
#endif
	if(player == victim) {
		/* If GOD_PRIV isn't defined, this could happen: we don't want the
		 * last wizard to be toaded, in any case, so only someone else can
		 * do it. */
		notify(player, "You cannot toad yourself.  Get someone else to do it for you.");
		return;
	}

	if (victim == tp_toad_default_recipient) {
		notify(player, "That player is part of the @toad process, and cannot be deleted.");
		return;
	}

	if (!*recip) {
		recipient = tp_toad_default_recipient;
	} else {
		if ((recipient = lookup_player(recip)) == NOTHING || recipient == victim) {
			notify(player, "That recipient does not exist.");
			return;
		}
	}

	if (Typeof(victim) != TYPE_PLAYER) {
		notify(player, "You can only turn players into toads!");
#ifdef GOD_PRIV
	} else if (!(God(player)) && (TrueWizard(victim))) {
#else
	} else if (TrueWizard(victim)) {
#endif
		notify(player, "You can't turn a Wizard into a toad.");
	} else {
		/* we're ok */
		/* do it */
		send_contents(descr, victim, HOME);
		dequeue_prog(victim, 0);  /* Dequeue the programs that the player's running */
		for (stuff = 0; stuff < db_top; stuff++) {
			if (OWNER(stuff) == victim) {
				switch (Typeof(stuff)) {
				case TYPE_PROGRAM:
					dequeue_prog(stuff, 0);	/* dequeue player's progs */
					if (TrueWizard(recipient)) {
						FLAGS(stuff) &= ~(ABODE | WIZARD);
						SetMLevel(stuff, 1);
					}
				case TYPE_ROOM:
				case TYPE_THING:
				case TYPE_EXIT:
					OWNER(stuff) = recipient;
					DBDIRTY(stuff);
					break;
				}
			}
			if (Typeof(stuff) == TYPE_THING && THING_HOME(stuff) == victim) {
				THING_SET_HOME(stuff, tp_lost_and_found);
			}
		}

		chown_macros(victim, recipient);

		if (PLAYER_PASSWORD(victim)) {
			free((void *) PLAYER_PASSWORD(victim));
			PLAYER_SET_PASSWORD(victim, 0);
		}

		/* notify people */
		notify(victim, "You have been turned into a toad.");
		snprintf(buf, sizeof(buf), "You turned %s into a toad!", NAME(victim));
		notify(player, buf);
		log_status("TOADED: %s(%d) by %s(%d)", NAME(victim), victim, NAME(player), player);
		/* reset name */
		delete_player(victim);
		snprintf(buf, sizeof(buf), "A slimy toad named %s", NAME(victim));
		free((void *) NAME(victim));
		NAME(victim) = alloc_string(buf);
		DBDIRTY(victim);

		boot_player_off(victim); /* Disconnect the toad */

		if (PLAYER_DESCRS(victim)) {
			free(PLAYER_DESCRS(victim));
			PLAYER_SET_DESCRS(victim, NULL);
			PLAYER_SET_DESCRCOUNT(victim, 0);
		}

		ignore_remove_from_all_players(victim);
		ignore_flush_cache(victim);

		FREE_PLAYER_SP(victim);
		ALLOC_THING_SP(victim);
		THING_SET_HOME(victim, PLAYER_HOME(player));

		FLAGS(victim) = TYPE_THING;
		OWNER(victim) = player;	/* you get it */
		SETVALUE(victim, 1);	/* don't let him keep his immense wealth */
	}
}
示例#3
0
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;
}