Example #1
0
void 
do_parent(dbref player, dbref cause, int key, char *tname, char *pname)
{
    dbref thing, parent, curr;
    int lev;

    /* get victim */

    init_match(player, tname, NOTYPE);
    match_everything(0);
    thing = noisy_match_result();
    if (thing == NOTHING)
	return;

    /* Make sure we can do it */

    if ( NoMod(thing) && !WizMod(player) ) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    if (!Controls(player, thing) &&
        !could_doit(player,thing,A_LTWINK, 0, 0)) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    if ( Backstage(player) && NoBackstage(thing) ) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    /* Find out what the new parent is */

    if (*pname) {
	init_match(player, pname, Typeof(thing));
	match_everything(0);
	parent = noisy_match_result();
	if (parent == NOTHING)
	    return;

	/* Make sure we have rights to set parent */

	if (!Parentable(player, parent)) {
	    notify_quiet(player, "Permission denied.");
	    return;
	}
	/* Verify no recursive reference */

	ITER_PARENTS(parent, curr, lev) {
	    if (curr == thing) {
		notify_quiet(player,
			     "You can't have yourself as a parent!");
		return;
	    }
	}
    } else {
Example #2
0
void
do_whisper(int descr, dbref player, const char *arg1, const char *arg2)
{
	dbref who;
	char buf[BUFFER_LEN];
	struct match_data md;

	init_match(descr, player, arg1, TYPE_PLAYER, &md);
	match_neighbor(&md);
	match_me(&md);
	if (Wizard(player) && Typeof(player) == TYPE_PLAYER) {
		match_absolute(&md);
		match_player(&md);
	}
	switch (who = match_result(&md)) {
	case NOTHING:
		notify(player, "Whisper to whom?");
		break;
	case AMBIGUOUS:
		notify(player, "I don't know who you mean!");
		break;
	default:
		snprintf(buf, sizeof(buf), "%s whispers, \"%s\"", NAME(player), arg2);
		if (!notify_from(player, who, buf)) {
			snprintf(buf, sizeof(buf), "%s is not connected.", NAME(who));
			notify(player, buf);
			break;
		}
		snprintf(buf, sizeof(buf), "You whisper, \"%s\" to %s.", arg2, NAME(who));
		notify(player, buf);
		break;
	}
}
Example #3
0
void
do_mcpedit(int descr, dbref player, const char *name)
{
    dbref i;
    struct match_data md;
    McpFrame *mfr;

    if (!(mfr = descr_mcpframe(descr))) {
        do_edit(descr, player, name);
        return;
    } else if (Typeof(player) != TYPE_PLAYER) {
        anotify_nolisten2(player, CFAIL "Only players can edit programs.");
        return;
    } else if (!Mucker(player)) {
        anotify_nolisten2(player, CFAIL NOMBIT_MESG);
        return;
    } else if (tp_db_readonly) {
        anotify_nolisten2(player, CFAIL DBRO_MESG);
        return;
    } else if (!*name) {
        anotify_nolisten2(player, CINFO "No program name given.");
        return;
    }

    init_match(descr, player, name, TYPE_PROGRAM, &md);
    match_possession(&md);
    match_neighbor(&md);
    match_registered(&md);
    match_absolute(&md);

    if ((i = noisy_match_result(&md)) == NOTHING || i == AMBIGUOUS)
        return;

    mcpedit_program(descr, player, i, name, mfr);
}
Example #4
0
static dbref 
parse_linkable_room(dbref player, char *room_name)
{
    dbref room;

    init_match(player, room_name, NOTYPE);
    match_everything(MAT_NO_EXITS | MAT_NUMERIC | MAT_HOME);
    room = match_result();

    /* HOME is always linkable */

    if (room == HOME)
	return HOME;

    /* Make sure we can link to it */

    if (!Good_obj(room)) {
	notify_quiet(player, "That's not a valid object.");
	return NOTHING;
    } else if (!Has_contents(room) || !Linkable(player, room)) {
	notify_quiet(player, "You can't link to that.");
	return NOTHING;
    } else {
	return room;
    }
}
Example #5
0
File: wiz.c Project: hyena/fuzzball
void
do_unbless(int descr, dbref player, const char *what, const char *propname)
{
	dbref victim;
	struct match_data md;
	char buf[BUFFER_LEN];
	int cnt;

	if (!Wizard(player) || Typeof(player) != TYPE_PLAYER) {
		notify(player, "Only Wizard players may use this command.");
		return;
	}

	if (!propname || !*propname) {
		notify(player, "Usage is @unbless object=propname.");
		return;
	}

	/* get victim */
	init_match(descr, player, what, NOTYPE, &md);
	match_everything(&md);
	if ((victim = noisy_match_result(&md)) == NOTHING) {
		return;
	}

	if (!Wizard(OWNER(player))) {
		notify(player, "Permission denied. (You're not a wizard)");
		return;
	}

	cnt = blessprops_wildcard(player, victim, "", propname, 0);
	snprintf(buf, sizeof(buf), "%d propert%s unblessed.", cnt, (cnt == 1)? "y" : "ies");
	notify(player, buf);
}
Example #6
0
/*
  Use this to create a program.
  First, find a program that matches that name.  If there's one,
  then we put him into edit mode and do it.
  Otherwise, we create a new object for him, and call it a program.
  */
void
do_prog(int descr, dbref player, const char *name)
{
    dbref i;
    struct match_data md;

    if (Typeof(player) != TYPE_PLAYER) {
        anotify_nolisten2(player, CFAIL "Only players can edit programs.");
        return;
    } else if (!Mucker(player)) {
        anotify_nolisten2(player, CFAIL NOMBIT_MESG);
        return;
    } else if (!tp_building || tp_db_readonly) {
        anotify_nolisten2(player, CFAIL NOBUILD_MESG);
        return;
    } else if (!*name) {
        anotify_nolisten2(player, CINFO "No program name given.");
        return;
    }

    init_match(descr, player, name, TYPE_PROGRAM, &md);
    match_possession(&md);
    match_neighbor(&md);
    match_registered(&md);
    match_absolute(&md);

    if ((i = match_result(&md)) == NOTHING) {
        i = new_program(OWNER(player), name);
        FLAGS(i) |= INTERNAL;
        DBFETCH(player)->sp.player.curr_prog = i;

        anotify_fmt(player, CSUCC "Program %s created with number %d.", name,
                    i);
        anotify_nolisten2(player, CINFO "Entering editor.");
    } else if (i == AMBIGUOUS) {
        anotify_nolisten2(player, CINFO "I don't know which one you mean!");
        return;
    } else {
        if ((Typeof(i) != TYPE_PROGRAM) || !controls(player, i)) {
            anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
            return;
        } else if (FLAGS(i) & INTERNAL) {
            anotify_nolisten2(player, CFAIL NOEDIT_MESG);
            return;
        }

        DBFETCH(i)->sp.program.first = read_program(i);
        FLAGS(i) |= INTERNAL;
        DBFETCH(player)->sp.player.curr_prog = i;
        anotify_fmt(player, CINFO "Entering editor for %s.",
                    unparse_object(player, i));
        /* list current line */
        do_list(player, i, 0, 0, 0);
        DBDIRTY(i);
    }

    FLAGS(player) |= INTERACTIVE;
    DBDIRTY(player);
}
Example #7
0
/*
 * do_attach()
 *
 * This routine attaches a previously existing action to a source object.
 * The action will not do anything unless it is LINKed.
 *
 */
void
do_attach(int descr, dbref player, const char *action_name,
          const char *source_name)
{
    dbref action, source;
    dbref loc;                  /* player's current location */
    struct match_data md;
    char buf[BUFFER_LEN];

    if ((loc = DBFETCH(player)->location) == NOTHING)
        return;

    if (tp_db_readonly) {
        anotify_nolisten2(player, CFAIL DBRO_MESG);
        return;
    }

    if (!*action_name || !*source_name) {
        anotify_nolisten2(player,
                          CINFO
                          "You must specify an action name and a source object.");
        return;
    }
    init_match(descr, player, action_name, TYPE_EXIT, &md);
    match_all_exits(&md);
    match_registered(&md);
    match_absolute(&md);

    if ((action = noisy_match_result(&md)) == NOTHING)
        return;

    if (Typeof(action) != TYPE_EXIT) {
        anotify_nolisten2(player, CINFO "That's not an action.");
        return;
    } else if (!controls(player, action)) {
        anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
        return;
    }
    if (((source = parse_source(descr, player, source_name)) == NOTHING)
        || Typeof(source) == TYPE_PROGRAM)
        return;

    if (!unset_source(player, loc, action)) {
        return;
    }
    set_source(player, action, source);
    sprintf(buf, CSUCC "Action %s re-attached to %s.",
            unparse_object(player, action), NAME(source));
    anotify_nolisten2(player, buf);
    if (MLevel(action)) {
        SetMLevel(action, 0);
        anotify_nolisten2(player, CINFO "Action priority Level reset to zero.");
    }
}
Example #8
0
void
do_edit(int descr, dbref player, const char *name)
{
    dbref i;
    struct match_data md;

    if (Typeof(player) != TYPE_PLAYER) {
        anotify_nolisten2(player, CFAIL "Only players can edit programs.");
        return;
    } else if (!Mucker(player)) {
        anotify_nolisten2(player, CFAIL NOMBIT_MESG);
        return;
    } else if (tp_db_readonly) {
        anotify_nolisten2(player, CFAIL DBRO_MESG);
        return;
    } else if (!*name) {
        anotify_nolisten2(player, CINFO "No program name given.");
        return;
    }

    init_match(descr, player, name, TYPE_PROGRAM, &md);
    match_possession(&md);
    match_neighbor(&md);
    match_registered(&md);
    match_absolute(&md);

    if ((i = noisy_match_result(&md)) == NOTHING || i == AMBIGUOUS)
        return;

    if ((Typeof(i) != TYPE_PROGRAM) || !controls(player, i)) {
        anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
        return;
    } else if (FLAGS(i) & INTERNAL) {
        anotify_nolisten2(player, CFAIL NOEDIT_MESG);
        return;
    }

    FLAGS(i) |= INTERNAL;
    DBFETCH(i)->sp.program.first = read_program(i);
    DBFETCH(player)->sp.player.curr_prog = i;
    anotify_fmt(player, CINFO "Entering editor for %s.",
                unparse_object(player, i));
    /* list current line */
    do_list(player, i, 0, 0, 0);
    FLAGS(player) |= INTERACTIVE;
    DBDIRTY(i);
    DBDIRTY(player);
}
Example #9
0
File: wiz.c Project: hyena/fuzzball
void
do_bless(int descr, dbref player, const char *what, const char *propname)
{
	dbref victim;
	struct match_data md;
	char buf[BUFFER_LEN];
	int cnt;

	if (force_level) {
		notify(player, "Can't @force an @bless.");
		return;
	}


	if (!Wizard(player) || Typeof(player) != TYPE_PLAYER) {
		notify(player, "Only Wizard players may use this command.");
		return;
	}

	if (!propname || !*propname) {
		notify(player, "Usage is @bless object=propname.");
		return;
	}

	/* get victim */
	init_match(descr, player, what, NOTYPE, &md);
	match_everything(&md);
	if ((victim = noisy_match_result(&md)) == NOTHING) {
		return;
	}

#ifdef GOD_PRIV
	if(tp_strict_god_priv && !God(player) && God(OWNER(victim))) {
		notify(player, "Only God may touch God's stuff.");
		return;
	}
#endif

	if (!Wizard(OWNER(player))) {
		notify(player, "Permission denied. (you're not a wizard)");
		return;
	}

	cnt = blessprops_wildcard(player, victim, "", propname, 1);
	snprintf(buf, sizeof(buf), "%d propert%s blessed.", cnt, (cnt == 1)? "y" : "ies");
	notify(player, buf);
}
Example #10
0
void
do_rob(int descr, dbref player, const char *what)
{
	dbref thing;
	char buf[BUFFER_LEN];
	struct match_data md;

	init_match(descr, player, what, TYPE_PLAYER, &md);
	match_neighbor(&md);
	match_me(&md);
	if (Wizard(OWNER(player))) {
		match_absolute(&md);
		match_player(&md);
	}
	thing = match_result(&md);

	switch (thing) {
	case NOTHING:
		notify(player, "Rob whom?");
		break;
	case AMBIGUOUS:
		notify(player, "I don't know who you mean!");
		break;
	default:
		if (Typeof(thing) != TYPE_PLAYER) {
			notify(player, "Sorry, you can only rob other players.");
		} else if (GETVALUE(thing) < 1) {
			snprintf(buf, sizeof(buf), "%s has no %s.", NAME(thing), tp_pennies);
			notify(player, buf);
			snprintf(buf, sizeof(buf),
					"%s tried to rob you, but you have no %s to take.",
					NAME(player), tp_pennies);
			notify(thing, buf);
		} else if (can_doit(descr, player, thing, "Your conscience tells you not to.")) {
			/* steal a penny */
			SETVALUE(OWNER(player), GETVALUE(OWNER(player)) + 1);
			DBDIRTY(player);
			SETVALUE(thing, GETVALUE(thing) - 1);
			DBDIRTY(thing);
			notify_fmt(player, "You stole a %s.", tp_penny);
			snprintf(buf, sizeof(buf), "%s stole one of your %s!", NAME(player), tp_pennies);
			notify(thing, buf);
		}
		break;
	}
}
Example #11
0
void do_give(dbref player, dbref cause, int key, char *who, char *amnt)
{
  dbref	recipient;

	/* check recipient */

	init_match(player, who, TYPE_PLAYER);
	match_neighbor();
	match_possession();
	match_me();
	if (Privilaged(player) || HasPriv(player,NOTHING,POWER_LONG_FINGERS,POWER3,NOTHING)) {
		match_player();
		match_absolute();
	}

	recipient = match_result();
	switch (recipient) {
	case NOTHING:
		notify(player, "Give to whom?");
		return;
	case AMBIGUOUS:
		notify(player, "I don't know who you mean!");
		return;
	}

	if (DePriv(player,recipient,DP_GIVE,POWER7,POWER_LEVEL_SPC)) {
		notify(player, "Permission denied.");
		return;
	}
	if (DePriv(recipient,player,DP_RECEIVE,POWER7,POWER_LEVEL_SPC)) {
		notify(player, "Permission denied.");
		return;
	}
	if (is_number(amnt)) {
		give_money(player, recipient, key, atoi(amnt));
	} else if(Guest(recipient)) {
		notify(player, "Guest really doesn't need money or anything.");
		return;
	} else {
            if ( Typeof(player) != TYPE_ROOM )
		give_thing(player, recipient, key, amnt);
            else
                notify(player, "Command incompatible with invoker type.");
	}
}
Example #12
0
void		wait_event_pvp(t_var var)
{
  SDL_Event	event;
  t_match	*match;
  int		in_prog;

  match = NULL;
  in_prog = 1;
  match = init_match(match);
  SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
  aff_bwall(&var);
  aff_match(&var, match);
  xSDL_Flip(var.screen);
  while (in_prog == 1)
    in_prog = catch_event_pvp(&match, &var, in_prog, event);
  aff_match(&var, match);
  free_all(match, &var);
  SDL_Quit();
  exit(EXIT_SUCCESS);
}
Example #13
0
// Specifically matches an exit for a given game driver
HS_DBREF CHSInterface::NoisyMatchExit(HS_DBREF player, char *name)
{
    HS_DBREF exit_m;

#ifdef PENNMUSH                 // No change in code between versions
    exit_m = match_result(player, name, TYPE_EXIT, MAT_EXIT);
#endif

#if defined(TM3) || defined(MUX)
    init_match(player, name, TYPE_EXIT);
    match_exit();
    match_absolute();
    exit_m = noisy_match_result();
#endif

    if (exit_m == AMBIGUOUS)
        exit_m = NOTHING;

    return exit_m;
}
Example #14
0
static dbref
parse_linkable_dest(int descr, dbref player, dbref exit, const char *dest_name)
{
    dbref dobj;        /* destination room/player/thing/link */
    char buf[BUFFER_LEN];
    struct match_data md;

    init_match(descr, player, dest_name, NOTYPE, &md);
    match_absolute(&md);
    match_everything(&md);
    match_home(&md);
    match_null(&md);

    if ((dobj = match_result(&md)) == NOTHING || dobj == AMBIGUOUS) {
        sprintf(buf, CINFO "I couldn't find '%s'.", dest_name);
        anotify_nolisten2(player, buf);
        return NOTHING;

    }

    if (!tp_teleport_to_player && Typeof(dobj) == TYPE_PLAYER) {
        sprintf(buf,
                CFAIL "You can't link to players.  Destination %s ignored.",
                unparse_object(player, dobj));
        anotify_nolisten2(player, buf);
        return NOTHING;
    }

    if (!can_link(player, exit)) {
        anotify_nolisten2(player, CFAIL "You can't link that.");
        return NOTHING;
    }

    if (!can_link_to(player, Typeof(exit), dobj)) {
        sprintf(buf, CFAIL "You can't link to %s.",
                unparse_object(player, dobj));
        anotify_nolisten2(player, buf);
        return NOTHING;
    } else
        return dobj;
}
Example #15
0
HS_DBREF CHSInterface::NoisyMatchRoom(HS_DBREF player, char *name)
{
    HS_DBREF room;

#ifdef PENNMUSH                 // No change in code between versions
    room = noisy_match_result(player, name, TYPE_ROOM,
                              MAT_ABSOLUTE | MAT_HERE);
#endif

#if defined(TM3) || defined(MUX)
    init_match(player, name, TYPE_ROOM);
    match_absolute();
    match_here();
    room = noisy_match_result();
#endif

    if (room == AMBIGUOUS)
        room = NOTHING;

    return room;
}
Example #16
0
dbref
mesg_dbref_raw(int descr, dbref player, dbref what, dbref perms, const char *buf)
{
	struct match_data md;
	dbref obj = UNKNOWN;

	if (buf && *buf) {
		if (!string_compare(buf, "this")) {
			obj = what;
		} else if (!string_compare(buf, "me")) {
			obj = player;
		} else if (!string_compare(buf, "here")) {
			obj = getloc(player);
		} else if (!string_compare(buf, "home")) {
			obj = HOME;
		} else {
			init_match(descr, player, buf, NOTYPE, &md);
			match_absolute(&md);
			match_all_exits(&md);
			match_neighbor(&md);
			match_possession(&md);
			match_registered(&md);
			obj = match_result(&md);
			if (obj == NOTHING) {
				init_match_remote(descr, player, what, buf, NOTYPE, &md);
				match_player(&md);
				match_all_exits(&md);
				match_neighbor(&md);
				match_possession(&md);
				match_registered(&md);
				obj = match_result(&md);
			}
		}
	}

	if (obj < 0 || obj >= db_top || Typeof(obj) == TYPE_GARBAGE)
		obj = UNKNOWN;
	return obj;
}
Example #17
0
/*
 * parse_source()
 *
 * This is a utility used by do_action and do_attach.  It parses
 * the source string into a dbref, and checks to see that it
 * exists.
 *
 * The return value is the dbref of the source, or NOTHING if an
 * error occurs.
 *
 */
dbref
parse_source(int descr, dbref player, const char *source_name)
{
    dbref source;
    struct match_data md;

    init_match(descr, player, source_name, NOTYPE, &md); /* source type can be
                                                          * any */
    match_neighbor(&md);
    match_me(&md);
    match_here(&md);
    match_possession(&md);
    match_registered(&md);
    match_absolute(&md);
    source = noisy_match_result(&md);

    if (source == NOTHING)
        return NOTHING;

    /* You can only attach actions to things you control */
    if (!controls(player, source)) {
        anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
        return NOTHING;
    }
    if (Typeof(source) == TYPE_EXIT) {
        anotify_nolisten2(player,
                          CFAIL "You can't attach an action to an action.");
        return NOTHING;
    }
    if (Typeof(source) == TYPE_PROGRAM) {
        anotify_nolisten2(player,
                          CFAIL "You can't attach an action to a program.");
        return NOTHING;
    }
    return source;
}
Example #18
0
void 
do_link(dbref player, dbref cause, int key, char *what, char *where)
{
    dbref thing, room;
    char *buff;
    int nomtest;

    if ( (key & SIDEEFFECT) && !SideFX(player) ) {
       notify(player, "#-1 FUNCTION DISABLED");
       return;
    }

    /* Find the thing to link */

    init_match(player, what, TYPE_EXIT);
    match_everything(0);
    thing = noisy_match_result();
    if (thing == NOTHING)
	return;

    nomtest = ((NoMod(thing) && !WizMod(player)) || (DePriv(player,Owner(thing),DP_MODIFY,POWER7,NOTHING) && (Owner(thing) != Owner(player))) || (Backstage(player) && NoBackstage(thing) && !Immortal(player)));
    /* Allow unlink if where is not specified */

    if (!where || !*where) {
      if (!nomtest)
	do_unlink(player, cause, key, what);
      else
	notify(player,"Permission denied.");
      return;
    }
    switch (Typeof(thing)) {
    case TYPE_EXIT:

	/* Set destination */

	room = parse_linkable_room(player, where);
	if (room != NOTHING) {
	  if (!nomtest)
	    link_exit(player, thing, room, key);
	  else
	    notify(player,"Permission denied.");
	}
	break;
    case TYPE_PLAYER:
    case TYPE_THING:

	/* Set home */

	if (!Controls(player, thing) || nomtest) {
	    notify_quiet(player, "Permission denied.");
	    break;
	}
	init_match(player, where, NOTYPE);
	match_everything(MAT_NO_EXITS);
	room = noisy_match_result();
	if (!Good_obj(room))
	    break;
	if (!Has_contents(room)) {
	    notify_quiet(player, "Can't link to an exit.");
	    break;
	}
	if (!can_set_home(player, thing, room) ||
	    !could_doit(player, room, A_LLINK, 1, 0)) {
	    notify_quiet(player, "Permission denied.");
	} else if (room == HOME) {
	    notify_quiet(player, "Can't set home to home.");
	} else {
	    s_Home(thing, room);
	    if (!(Quiet(player) || (key & SIDEEFFECT)) )
		notify_quiet(player, "Home set.");
	}
	break;
    case TYPE_ROOM:

	/* Set dropto */

	if (!Controls(player, thing) || nomtest) {
	    notify_quiet(player, "Permission denied.");
	    break;
	}
	room = parse_linkable_room(player, where);
	if (!Good_obj(room) && (room != HOME)) {
	    notify_quiet(player, "Permission denied.");
	    break;
	}

	if ((room != HOME) && !isRoom(room)) {
	    notify_quiet(player, "That is not a room!");
	} else if ((room != HOME) &&
		   ((!controls(player, room) && !Link_ok(room)) ||
		    !could_doit(player, room, A_LLINK, 1, 0))) {
	    notify_quiet(player, "Permission denied.");
	} else {
	    s_Dropto(thing, room);
	    if (!Quiet(player))
		notify_quiet(player, "Dropto set.");
	}
	break;
    default:
	STARTLOG(LOG_BUGS, "BUG", "OTYPE")
	    buff = alloc_mbuf("do_link.LOG.badtype");
	sprintf(buff, "Strange object type: object #%d = %d",
		thing, Typeof(thing));
	log_text(buff);
	free_mbuf(buff);
	ENDLOG
    }
}
Example #19
0
void
match_and_list(int descr, dbref player, const char *name, char *linespec)
{
	dbref thing;
	char *p;
	char *q;
	int range[2];
	int argc;
	struct match_data md;
	struct line *tmpline;

	init_match(descr, player, name, TYPE_PROGRAM, &md);
	match_neighbor(&md);
	match_possession(&md);
	match_registered(&md);
	match_absolute(&md);
	if ((thing = noisy_match_result(&md)) == NOTHING)
		return;
	if (Typeof(thing) != TYPE_PROGRAM) {
		notify(player, "You can't list anything but a program.");
		return;
	}
/*	if (!(controls(player, thing) || Linkable(thing))) { */
	if (!(controls(player, thing) || (FLAGS(thing) & VEHICLE))) {
		notify(player, "Permission denied. (You don't control the program, and it's not set Viewable)");
		return;
	}
	if (!*linespec) {
		range[0] = 1;
		range[1] = -1;
		argc = 2;
	} else {
		q = p = linespec;
		while (*p) {
			while (*p && !isspace(*p))
				*q++ = *p++;
			while (*p && isspace(*++p)) ;
		}
		*q = '\0';

		argc = 1;
		if (isdigit(*linespec)) {
			range[0] = atoi(linespec);
			while (*linespec && isdigit(*linespec))
				linespec++;
		} else {
			range[0] = 1;
		}
		if (*linespec) {
			argc = 2;
			while (*linespec && !isdigit(*linespec))
				linespec++;
			if (*linespec)
				range[1] = atoi(linespec);
			else
				range[1] = -1;
		}
	}
	tmpline = PROGRAM_FIRST(thing);
	PROGRAM_SET_FIRST(thing, read_program(thing));
	do_list(player, thing, range, argc);
	free_prog_text(PROGRAM_FIRST(thing));
	PROGRAM_SET_FIRST(thing, tmpline);
	return;
}
static action_list *
complete_action_list( void ) {
  action_list *ac_list = init_action_list();

//  expect_value( mock_is_valid_port_no, port_no, PORT_NO );
  action *ac_output = create_action_output( PORT_NO, MAX_LEN );
  append_action( ac_list, ac_output );

  const uint32_t group_id = GROUP_ID;
  action *ac_group = create_action_group( group_id );
  append_action( ac_list, ac_group );
  
  const uint32_t queue_id = QUEUE_ID;
  action *ac_set_queue = create_action_set_queue( queue_id );
  append_action( ac_list, ac_set_queue );
  
  const uint8_t mpls_ttl = MPLS_TTL;
  action *ac_set_mpls_ttl = create_action_set_mpls_ttl( mpls_ttl );
  append_action( ac_list, ac_set_mpls_ttl );
  
  action *ac_dec_mpls_ttl = create_action_dec_mpls_ttl();
  append_action( ac_list, ac_dec_mpls_ttl );
  
  const uint8_t nw_ttl = NW_TTL;
  action *ac_set_ipv4_ttl = create_action_set_ipv4_ttl( nw_ttl );
  append_action( ac_list, ac_set_ipv4_ttl );
  

  action *ac_dec_ipv4_ttl = create_action_dec_ipv4_ttl();
  append_action( ac_list, ac_dec_ipv4_ttl );
  
  action *ac_copy_ttl_out = create_action_copy_ttl_out();
  append_action( ac_list, ac_copy_ttl_out );
  
  action *ac_copy_ttl_in = create_action_copy_ttl_in();
  append_action( ac_list, ac_copy_ttl_in );
  
  const uint16_t ether_type = VLAN_ETHERTYPE;
  action *ac_action_push_vlan = create_action_push_vlan( ether_type );
  append_action( ac_list, ac_action_push_vlan );
  

  const uint16_t mpls_type = MPLS_ETHERTYPE;
  action *ac_action_push_mpls = create_action_push_mpls( mpls_type );
  append_action( ac_list, ac_action_push_mpls );
  

  const uint16_t pbb_type = PBB_ETHERTYPE;
  action *ac_action_push_pbb = create_action_push_pbb( pbb_type );
  append_action( ac_list, ac_action_push_pbb );


  action *ac_action_pop_vlan = create_action_pop_vlan();
  append_action( ac_list, ac_action_pop_vlan );
  
  action *ac_action_pop_mpls = create_action_pop_mpls( mpls_type );
  append_action( ac_list, ac_action_pop_mpls );

  action *ac_action_pop_pbb = create_action_pop_pbb();
  append_action( ac_list, ac_action_pop_pbb );
  
  match *match = init_match();
  action *ac_action_set_field = create_action_set_field( match );
  append_action( ac_list, ac_action_set_field );
  return ac_list;
}
Example #21
0
void
do_kill(int descr, dbref player, const char *what, int cost)
{
	dbref victim;
	char buf[BUFFER_LEN];
	struct match_data md;

	init_match(descr, player, what, TYPE_PLAYER, &md);
	match_neighbor(&md);
	match_me(&md);
	if (Wizard(OWNER(player))) {
		match_player(&md);
		match_absolute(&md);
	}
	victim = match_result(&md);

	switch (victim) {
	case NOTHING:
		notify(player, "I don't see that player here.");
		break;
	case AMBIGUOUS:
		notify(player, "I don't know who you mean!");
		break;
	default:
		if (Typeof(victim) != TYPE_PLAYER) {
			notify(player, "Sorry, you can only kill other players.");
		} else {
			/* go for it */
			/* set cost */
			if (cost < tp_kill_min_cost)
				cost = tp_kill_min_cost;

			if (FLAGS(DBFETCH(player)->location) & HAVEN) {
				notify(player, "You can't kill anyone here!");
				break;
			}

			if (tp_restrict_kill) {
				if (!(FLAGS(player) & KILL_OK)) {
					notify(player, "You have to be set Kill_OK to kill someone.");
					break;
				}
				if (!(FLAGS(victim) & KILL_OK)) {
					notify(player, "They don't want to be killed.");
					break;
				}
			}

			/* see if it works */
			if (!payfor(player, cost)) {
				notify_fmt(player, "You don't have enough %s.", tp_pennies);
			} else if ((RANDOM() % tp_kill_base_cost) < cost && !Wizard(OWNER(victim))) {
				/* you killed him */
				if (GETDROP(victim))
					/* give him the drop message */
					notify(player, GETDROP(victim));
				else {
					snprintf(buf, sizeof(buf), "You killed %s!", NAME(victim));
					notify(player, buf);
				}

				/* now notify everybody else */
				if (GETODROP(victim)) {
					snprintf(buf, sizeof(buf), "%s killed %s! ", NAME(player), NAME(victim));
					parse_oprop(descr, player, getloc(player), victim,
								   MESGPROP_ODROP, buf, "(@Odrop)");
				} else {
					snprintf(buf, sizeof(buf), "%s killed %s!", NAME(player), NAME(victim));
				}
				notify_except(DBFETCH(DBFETCH(player)->location)->contents, player, buf,
							  player);

				/* maybe pay off the bonus */
				if (GETVALUE(victim) < tp_max_pennies) {
					snprintf(buf, sizeof(buf), "Your insurance policy pays %d %s.",
							tp_kill_bonus, tp_pennies);
					notify(victim, buf);
					SETVALUE(victim, GETVALUE(victim) + tp_kill_bonus);
					DBDIRTY(victim);
				} else {
					notify(victim, "Your insurance policy has been revoked.");
				}
				/* send him home */
				send_home(descr, victim, 1);

			} else {
				/* notify player and victim only */
				notify(player, "Your murder attempt failed.");
				snprintf(buf, sizeof(buf), "%s tried to kill you!", NAME(player));
				notify(victim, buf);
			}
			break;
		}
	}
}
Example #22
0
lzo2a_999_compress_callback ( const lzo_byte *in , lzo_uint  in_len,
                                    lzo_byte *out, lzo_uintp out_len,
                                    lzo_voidp wrkmem,
                                    lzo_progress_callback_t cb,
                                    lzo_uint max_chain )
{
	lzo_byte *op;
	lzo_byte *bitp = 0;
	lzo_uint m_len, m_off;
	LZO_COMPRESS_T cc;
	LZO_COMPRESS_T * const c = &cc;
	lzo_swd_t * const swd = (lzo_swd_t *) wrkmem;
	int r;

	lzo_uint32 b = 0;		/* bit buffer */
	unsigned k = 0;			/* bits in bit buffer */

#if defined(__LZO_QUERY_COMPRESS)
	if (__LZO_IS_COMPRESS_QUERY(in,in_len,out,out_len,wrkmem))
		return __LZO_QUERY_COMPRESS(in,in_len,out,out_len,wrkmem,1,lzo_sizeof(lzo_swd_t));
#endif

	/* sanity check */
	if (!lzo_assert(LZO2A_999_MEM_COMPRESS >= lzo_sizeof(lzo_swd_t)))
		return LZO_E_ERROR;

	c->init = 0;
	c->ip = c->in = in;
	c->in_end = in + in_len;
	c->cb = cb;
	c->m1 = c->m2 = c->m3 = c->m4 = 0;

	op = out;

	r = init_match(c,swd,NULL,0,0);
	if (r != 0)
		return r;
	if (max_chain > 0)
		swd->max_chain = max_chain;

	r = find_match(c,swd,0,0);
	if (r != 0)
		return r;
	while (c->look > 0)
	{
		int lazy_match_min_gain = 0;
		int extra1 = 0;
		int extra2 = 0;
		lzo_uint ahead = 0;

		LZO_UNUSED(extra1);

		m_len = c->m_len;
		m_off = c->m_off;

#if (N >= 8192)
		if (m_off >= 8192)
		{
			if (m_len < M3_MIN_LEN)
				m_len = 0;
			else
				lazy_match_min_gain = 1;
		}
		else
#endif
		if (m_len >= M1_MIN_LEN && m_len <= M1_MAX_LEN && m_off <= 256)
		{
			lazy_match_min_gain = 2;
			extra1 = 3;
			extra2 = 2;
		}
		else if (m_len >= 10)
			lazy_match_min_gain = 1;
		else if (m_len >= 3)
		{
			lazy_match_min_gain = 1;
			extra1 = 1;
		}
		else
			m_len = 0;


		/* try a lazy match */
		if (lazy_match_min_gain > 0 && c->look > m_len)
		{
			int lit = swd->b_char;

			r = find_match(c,swd,1,0);
			assert(r == 0);
			assert(c->look > 0);

#if (N >= 8192)
			if (m_off < 8192 && c->m_off >= 8192)
				lazy_match_min_gain += extra1;
			else
#endif
			if (m_len >= M1_MIN_LEN && m_len <= M1_MAX_LEN && m_off <= 256)
			{
				if (!(c->m_len >= M1_MIN_LEN &&
				      c->m_len <= M1_MAX_LEN && c->m_off <= 256))
					lazy_match_min_gain += extra2;
			}
			if (c->m_len >= M1_MIN_LEN &&
			    c->m_len <= M1_MAX_LEN && c->m_off <= 256)
			{
					lazy_match_min_gain -= 1;
			}

			if (lazy_match_min_gain < 1)
				lazy_match_min_gain = 1;

			if (c->m_len >= m_len + lazy_match_min_gain)
			{
				c->lazy++;
#if !defined(NDEBUG)
				m_len = c->m_len;
				m_off = c->m_off;
				assert(lzo_memcmp(c->ip - c->look, c->ip - c->look - m_off,
			                      m_len) == 0);
				assert(m_len >= 3 || (m_len >= 2 && m_off <= 256));
#endif
				/* code literal */
				putbit(0);
				putbyte(lit);
				c->lit_bytes++;
				continue;
			}
			else
				ahead = 1;
			assert(m_len > 0);
		}


		if (m_len == 0)
		{
			/* a literal */
			putbit(0);
			putbyte(swd->b_char);
			c->lit_bytes++;
			r = find_match(c,swd,1,0);
			assert(r == 0);
		}
		else
		{
			assert(m_len >= M1_MIN_LEN);
			assert(m_off > 0);
			assert(m_off <= N);

			/* 2 - code match */
			if (m_len >= M1_MIN_LEN && m_len <= M1_MAX_LEN && m_off <= 256)
			{
				putbit(1);
				putbit(0);
				putbits(2,m_len - M1_MIN_LEN);
				putbyte(m_off - 1);
				c->m1++;
			}
#if (N >= 8192)
			else if (m_off >= 8192)
			{
				unsigned len = m_len;
				assert(m_len >= M3_MIN_LEN);
				putbit(1);
				putbit(1);
				putbyte(m_off & 31);
				putbyte(m_off >> 5);
				putbit(1);
				len -= M3_MIN_LEN - 1;
				while (len > 255)
				{
					len -= 255;
					putbyte(0);
				}
				putbyte(len);
				c->m4++;
			}
#endif
			else
			{
				assert(m_len >= 3);

				putbit(1);
				putbit(1);
				if (m_len <= 9)
				{
					putbyte(((m_len - 2) << 5) | (m_off & 31));
					putbyte(m_off >> 5);
					c->m2++;
				}
				else
				{
Example #23
0
/*
 * do_dig
 *
 * Use this to create a room.
 */
void
do_dig(int descr, dbref player, const char *name, const char *pname)
{
    char *rname, *qname;
    dbref newparent;
    char rbuf[BUFFER_LEN];
    char qbuf[BUFFER_LEN];
    char buf[BUFFER_LEN];
    dbref room;
    struct match_data md;
    dbref parent;

    if (!Builder(player) && !tp_all_can_build_rooms) {
        anotify_nolisten2(player, CFAIL NOBBIT_MESG);
        return;
    }

    if (!tp_building || tp_db_readonly) {
        anotify_nolisten2(player, CFAIL NOBUILD_MESG);
        return;
    }

    if (*name == '\0') {
        anotify_nolisten2(player, CINFO "You need name for the room.");
        return;
    }

    if (!ok_name(name)) {
        anotify_nolisten2(player, CINFO "That's a silly name for a room!");
        return;
    }

    if (!payfor(player, tp_room_cost)) {
        anotify_fmt(player, CFAIL "You don't have enough %s to dig a room.",
                    tp_pennies);
        return;
    }
    room = new_object(player);

    /* Initialize everything */
    newparent = DBFETCH(DBFETCH(player)->location)->location;
    while ((OkObj(newparent)) && !(FLAGS(newparent) & ABODE)
           && !(FLAG2(newparent) & F2PARENT))
        newparent = DBFETCH(newparent)->location;
    if (!OkObj(newparent)) {
        if (OkObj(tp_default_parent))
            newparent = tp_default_parent;
        else
            newparent = GLOBAL_ENVIRONMENT;
    }

    NAME(room) = alloc_string(name);
    DBFETCH(room)->location = newparent;
    OWNER(room) = OWNER(player);
    DBFETCH(room)->exits = NOTHING;
    DBFETCH(room)->sp.room.dropto = NOTHING;
    FLAGS(room) = TYPE_ROOM | (FLAGS(player) & JUMP_OK);
    PUSH(room, DBFETCH(newparent)->contents);
    DBDIRTY(room);
    DBDIRTY(newparent);

    sprintf(buf, CSUCC "Room %s created.", unparse_object(player, room));
    anotify_nolisten2(player, buf);

    strcpy(buf, pname);
    for (rname = buf; (*rname && (*rname != '=')); rname++) ;
    qname = rname;
    if (*rname)
        *(rname++) = '\0';
    while ((qname > buf) && (isspace(*qname)))
        *(qname--) = '\0';
    qname = buf;
    for (; *rname && isspace(*rname); rname++) ;
    rname = strcpy(rbuf, rname);
    qname = strcpy(qbuf, qname);

    if (*qname) {
        anotify_nolisten2(player, CNOTE "Trying to set parent...");
        init_match(descr, player, qname, TYPE_ROOM, &md);
        match_absolute(&md);
        match_registered(&md);
        match_here(&md);
        if ((parent = noisy_match_result(&md)) == NOTHING
            || parent == AMBIGUOUS) {
            anotify_nolisten2(player, CINFO "Parent set to default.");
        } else {
            if ((!can_link_to(player, Typeof(room), parent)
                 && !(FLAG2(parent) & F2PARENT)) || room == parent) {
                anotify_nolisten2(player,
                                  CFAIL
                                  "Permission denied.  Parent set to default.");
            } else {
                moveto(room, parent);
                sprintf(buf, CSUCC "Parent set to %s.",
                        unparse_object(player, parent));
                anotify_nolisten2(player, buf);
            }
        }
    }

    if (*rname) {
        PData pdat;

        sprintf(buf, "_reg/%s", rname);
        pdat.flags = PROP_REFTYP;
        pdat.data.ref = room;
        set_property(player, buf, &pdat);
        sprintf(buf, CINFO "Room registered as $%s", rname);
        anotify_nolisten2(player, buf);
    }
}
Example #24
0
static void give_thing (dbref giver, dbref recipient, int key, char *what)
{
dbref	thing, loc;
char	*str, *sp;

	init_match(giver, what, TYPE_THING);
	match_possession();
	match_me();
	thing = match_result();

	switch (thing) {
	case NOTHING:
		notify(giver, "You don't have that!");
		return;
	case AMBIGUOUS:
		notify(giver, "I don't know which you mean!");
		return;
	}

	if (thing == giver) {
		notify(giver, "You can't give yourself away!");
		return;
	}

	if (((Typeof(thing) != TYPE_THING) &&
	     (Typeof(thing) != TYPE_PLAYER)) ||
	    !(Enter_ok(recipient) || controls(giver, recipient))) {
		notify(giver, "Permission denied.");
		return;
	}
	if ((Flags3(thing) & NOMOVE) && !Wizard(giver)) {
		notify(giver, "Permission denied.");
		return;
	}

	if (!could_doit(giver, thing, A_LGIVE,1)) {
		sp = str = alloc_lbuf("do_give.gfail");
		safe_str((char *)"You can't give ", str, &sp);
		safe_str(Name(thing), str, &sp);
		safe_str((char *)" away.", str, &sp);
		*sp = '\0';

		did_it(giver, thing, A_GFAIL, str, A_OGFAIL, NULL,
			A_AGFAIL, (char **)NULL, 0);
		free_lbuf(str);
		return;
	}
	if (!could_doit(thing, recipient, A_LRECEIVE,1)) {
		sp = str = alloc_lbuf("do_give.rfail");
		safe_str(Name(recipient), str, &sp);
		safe_str((char *)" doesn't want ", str, &sp);
		safe_str(Name(thing), str, &sp);
		safe_chr('.', str, &sp);
		*sp = '\0';

		did_it(giver, recipient, A_RFAIL, str, A_ORFAIL, NULL,
			A_ARFAIL, (char **)NULL, 0);
		free_lbuf(str);
		return;
	}
	loc = Location(giver);
	if ( !Good_obj(loc) || loc == NOTHING || loc == AMBIGUOUS || Recover(loc) || Going(loc) )
           loc = giver;
	if (!could_doit(giver, loc, A_LGIVETO, 1)) {
		sp = str = alloc_lbuf("do_giveto.rfail");
		safe_str((char *)"You can not give ", str, &sp);
		safe_str(Name(thing), str, &sp);
		safe_str((char *)" away at this location.", str, &sp);
		*sp = '\0';
		notify(giver, str);
		free_lbuf(str);
		return;
	}

	move_via_generic(thing, recipient, giver, 0);
	divest_object(thing);
	
	if (!(key & GIVE_QUIET)) {
		str = alloc_lbuf("do_give.thing.ok");
		strcpy(str, Name(giver));
		notify_with_cause(recipient, giver,
			unsafe_tprintf("%s gave you %s.", str, Name(thing)));
		notify(giver, "Given.");
		notify_with_cause(thing, giver,
			unsafe_tprintf("%s gave you to %s.", str, Name(recipient)));
		free_lbuf(str);
	}
	else {
		notify(giver, "Given. (quiet)");
	}
	did_it(giver, thing, A_DROP, NULL, A_ODROP, NULL, A_ADROP,
		(char **)NULL, 0);
	did_it(recipient, thing, A_SUCC, NULL, A_OSUCC, NULL, A_ASUCC,
		(char **)NULL, 0);
}
Example #25
0
void do_kill (dbref player, dbref cause, int key, char *what, char *costchar)
{
dbref	victim;
char	*buf1, *buf2;
int	cost;

	init_match(player, what, TYPE_PLAYER);
	match_neighbor();
	match_me();
	match_here();
	if (Wizard(player)) {
		match_player();
		match_absolute();
	}
	victim = match_result();

	switch (victim) {
	case NOTHING:
		notify(player, "I don't see that player here.");
		break;
	case AMBIGUOUS:
		notify(player, "I don't know who you mean!");
		break;
	default:
		if ((Typeof(victim) != TYPE_PLAYER) &&
		    (Typeof(victim) != TYPE_THING)) {
			notify(player,
				"Sorry, you can only kill players and things.");
			break;
		}
		if ((Haven(Location(victim)) && !Wizard(player)) ||
		    (controls(victim, Location(victim)) &&
		     !controls(player, Location(victim))) ||
		    Immortal(victim)) {
			notify(player, "Sorry.");
			break;
		}
		if (key == KILL_SLAY) {
		  if (Builder(player) && Builder(victim)) {
			notify(player, "Sorry.");
			break;
		  }
		}

		/* go for it */

		cost = atoi(costchar);
		if (key == KILL_KILL) {
			if (HasPriv(victim,player,POWER_NOKILL,POWER4,NOTHING)) {
			  notify(player, "Sorry.");
			  break;
			}
			if (cost < mudconf.killmin)
				cost = mudconf.killmin;
			if (cost > mudconf.killmax)
				cost = mudconf.killmax;

			/* see if it works */

			if (!payfor(player, cost)) {
				notify(player,
					unsafe_tprintf("You don't have enough %s.",
						mudconf.many_coins));
				return;
			}
		} else {
			cost = 0;
		}

		if (!(((random() % mudconf.killguarantee) < cost) ||
		      (key == KILL_SLAY)) ||
		    Wizard(victim)) {

			/* Failure: notify player and victim only */

			notify(player, "Your murder attempt failed.");
			buf1 = alloc_lbuf("do_kill.failed");
			sprintf(buf1, "%s tried to kill you!", Name(player));
			notify_with_cause(victim, player, buf1);
			if (Suspect(player)) {
				strcpy(buf1, Name(player));
				if (player == Owner(player)) {
					raw_broadcast(0, WIZARD,
						"[Suspect] %s tried to kill %s(#%d).",
						buf1, Name(victim), victim);
				} else {
					buf2 = alloc_lbuf("do_kill.SUSP.failed");
					strcpy(buf2, Name(Owner(player)));
					raw_broadcast(0, WIZARD,
						"[Suspect] %s <via %s(#%d)> tried to kill %s(#%d).",
						buf2, buf1, player,
						Name(victim), victim);
					free_lbuf(buf2);
				}
			}
			free_lbuf(buf1);
			break;
		}

		/* Success!  You killed him */

		buf1 = alloc_lbuf("do_kill.succ.1");
		buf2 = alloc_lbuf("do_kill.succ.2");
		if (Suspect(player)) {
			strcpy(buf1, Name(player));
			if (player == Owner(player)) {
				raw_broadcast(0, WIZARD,
					"[Suspect] %s killed %s(#%d).",
					buf1, Name(victim), victim);
			} else {
				strcpy(buf2, Name(Owner(player)));
				raw_broadcast(0, WIZARD,
					"[Suspect] %s <via %s(#%d)> killed %s(#%d).",
					buf2, buf1, player, Name(victim),
					victim);
			}
		}
		sprintf(buf1, "You killed %s!", Name(victim));
		sprintf(buf2, "killed %s!", Name(victim));
		if (Typeof(victim) != TYPE_PLAYER)
			if (halt_que(NOTHING, victim) > 0)
				if (!Quiet(victim))
					notify(Owner(victim), "Halted.");
		did_it(player, victim, A_KILL, buf1, A_OKILL, buf2, A_AKILL,
			(char **)NULL, 0);

		/* notify victim */

		sprintf(buf1, "%s killed you!", Name(player));
		notify_with_cause(victim, player, buf1);

		/* Pay off the bonus */

		if (key == KILL_KILL) {
			cost /= 2; 	/* victim gets half */
			if (Pennies(Owner(victim)) < mudconf.paylimit) {
				sprintf(buf1,
					"Your insurance policy pays %d %s.",
					cost, mudconf.many_coins);
				notify(victim, buf1);
				giveto(Owner(victim), cost, NOTHING);
			} else {
				notify(victim,
					"Your insurance policy has been revoked.");
			}
		}
		free_lbuf(buf1);
		free_lbuf(buf2);

		/* send him home */

		move_via_generic(victim, HOME, NOTHING, 0);
		divest_object(victim);
		break;
	}
}
Example #26
0
void do_notify
(
    dbref executor,
    dbref caller,
    dbref enactor,
    int   key,
    int   nargs,
    char *what,
    char *count
)
{
    UNUSED_PARAMETER(caller);
    UNUSED_PARAMETER(enactor);
    UNUSED_PARAMETER(nargs);

    char *obj = parse_to(&what, '/', 0);
    init_match(executor, obj, NOTYPE);
    match_everything(0);

    dbref thing = noisy_match_result();
    if (!Good_obj(thing))
    {
        return;
    }
    if (!Controls(executor, thing) && !Link_ok(thing))
    {
        notify(executor, NOPERM_MESSAGE);
    }
    else
    {
        int atr = A_SEMAPHORE;
        if (  what
           && what[0] != '\0')
        {
            int i = mkattr(executor, what);
            if (0 < i)
            {
                atr = i;
                if (atr != A_SEMAPHORE)
                {
                    // Do they have permission to set this attribute?
                    //
                    ATTR *ap = (ATTR *)anum_get(atr);
                    if (!bCanSetAttr(executor, thing, ap))
                    {
                        notify_quiet(executor, NOPERM_MESSAGE);
                        return;
                    }
                }
            }
        }

        int loccount;
        if (  count
           && count[0] != '\0')
        {
            loccount = mux_atol(count);
        }
        else
        {
            loccount = 1;
        }
        if (loccount > 0)
        {
            nfy_que(thing, atr, key, loccount);
            if (  (!(Quiet(executor) || Quiet(thing)))
               && key != NFY_QUIET)
            {
                if (key == NFY_DRAIN)
                {
                    notify_quiet(executor, "Drained.");
                }
                else
                {
                    notify_quiet(executor, "Notified.");
                }
            }
        }
    }
}
Example #27
0
void
do_zone(dbref player, dbref cause, int key, char *tname, char *pname)
{
  dbref thing, zonemaster;

  switch( key ) {
    case ZONE_ADD: /* or default */
      if( *tname && !*pname ) {
        init_match(player, tname, NOTYPE);
        match_everything(0);
        thing = noisy_match_result();
        if( thing == NOTHING )
          return;
        if( !Examinable(player, thing) ) {
          notify_quiet(player, "You can't do that.");
          return;
        }
        viewzonelist(player, thing);
        return;
      }
       
      if( !*tname || !*pname ) {
        notify_quiet(player, "This switch expects two arguments.");
        return;
      }
     
      init_match(player, tname, NOTYPE);
      match_everything(0);
      thing = noisy_match_result();
      if( thing == NOTHING )
        return;

      /* Make sure we can do it */

      if ( (NoMod(thing) && !WizMod(player)) ||
           (Backstage(player) && NoBackstage(thing)) ) {
        notify_quiet(player, "Permission denied.");
        return;
      }
      if (!Controls(player, thing)) {
        notify_quiet(player, "Permission denied.");
        return;
      }

      if( ZoneMaster(thing) ) {
        notify_quiet(player, "You can't zone a Zone Master.");
        return;
      }
      /* Find out what the new zone is */

      init_match(player, pname, NOTYPE);
      match_everything(0);
      zonemaster = noisy_match_result();
      if (zonemaster == NOTHING)
        return;
 
      if( !ZoneMaster(zonemaster) ) {
        notify_quiet(player, "That's not a Zone Master.");
        return;
      }

      if(!Controls(player, zonemaster) && 
        !could_doit(player, zonemaster, A_LZONETO, 0, 0) &&
        !could_doit(player, zonemaster, A_LZONEWIZ, 0, 0)) {
        notify_quiet(player, "Permission denied.");
        return;
      }

      if( zlist_inlist(thing, zonemaster) ) {
        notify_quiet(player, "Object is already in that zone.");
        return;
      }

      zlist_add(thing, zonemaster);
      zlist_add(zonemaster, thing);

      notify_quiet(player, "Zone Master added to object.");
      break;
    case ZONE_DELETE:
      if( !*tname || !*pname ) {
        notify_quiet(player, "This switch expects two arguments.");
        return;
      }
      /* Find out what the zone is */

      init_match(player, pname, NOTYPE);
      match_everything(0);
      zonemaster = noisy_match_result();
      if (zonemaster == NOTHING)
        return;
     
      init_match(player, tname, NOTYPE);
      match_everything(0);
      thing = noisy_match_result();
      if( thing == NOTHING )
        return;

      if(!zlist_inlist(thing, zonemaster)) {
        notify_quiet(player, "That is not one of this object's Zone Masters.");
        return;
      }

      /* only need to control zmo or be zonewiz to delete 
         or control object */

      if(!Controls(player, thing) &&
         !Controls(player, zonemaster) && 
         !could_doit(player, zonemaster, A_LZONEWIZ, 0, 0)
         ) {
        notify_quiet(player, "Permission denied.");
        return;
      }

      if ( (NoMod(thing) && !WizMod(player)) ||
           (Backstage(player) && NoBackstage(thing)) ) {
        notify_quiet(player, "Permission denied.");
        return;
      }

      zlist_del(thing, zonemaster);
      zlist_del(zonemaster, thing);

      notify_quiet(player, "Deleted.");
      break;
    case ZONE_PURGE:
      if( !*tname || *pname) {
        notify_quiet(player, "This switch expects one argument.");
        return;
      }
      /* Find out what the zone is */

      init_match(player, tname, NOTYPE);
      match_everything(0);
      thing = noisy_match_result();
      if (thing == NOTHING)
        return;

      if( ZoneMaster(thing) ) {
        if(!Controls(player, thing) && 
          !could_doit(player, thing, A_LZONEWIZ, 0, 0)) {
          notify_quiet(player, "Permission denied.");
          return;
        }
        if ( (NoMod(thing) && !WizMod(player)) ||
             (Backstage(player) && NoBackstage(thing)) ) {
          notify_quiet(player, "Permission denied.");
          return;
        }
        zlist_destroy(thing);
        notify_quiet(player, "All objects removed from zone.");
      }
      else {
        if(!Controls(player, thing)) {
          notify_quiet(player, "Permission denied.");
          return;
        }
        if ( (NoMod(thing) && !WizMod(player)) ||
             (Backstage(player) && NoBackstage(thing)) ) {
          notify_quiet(player, "Permission denied.");
          return;
        }
        zlist_destroy(thing);

        notify_quiet(player, "Object removed from all zones.");
      }
      break;
    default:
      notify_quiet(player, "Unknown switch!");
      break;
  }
  return;
}
Example #28
0
void
do_whisper(int descr, dbref player, const char *arg1, const char *arg2)
{
    dbref who;
    char buf[BUFFER_LEN], buf2[BUFFER_LEN];
    struct match_data md;

    if (Guest(player)) {
        anotify_fmt(player, CFAIL "%s", tp_noguest_mesg);
        return;
    }

    init_match(descr, player, arg1, TYPE_PLAYER, &md);
    match_neighbor(&md);
    match_me(&md);
    if (Mage(player) && Typeof(player) == TYPE_PLAYER) {
        match_absolute(&md);
        match_player(&md);
    }
    switch (who = match_result(&md)) {
        case NOTHING:
            anotify_nolisten2(player, CINFO "Who?");
            break;
        case AMBIGUOUS:
            anotify_nolisten2(player, CINFO "I don't know who you mean!");
            break;
        default:
            if (Meeper(OWNER(player))) {
                do_parse_mesg(descr, player, player, arg2, "(whisper)", buf,
                              MPI_ISPRIVATE);
                tct(buf, buf2);
            } else {
                tct(arg2, buf2);
            }

            if (buf2[0] == ':' || buf2[0] == ';') {
                sprintf(buf, SYSBLUE "%s whispers, \"" SYSPURPLE "%s %s"
                        SYSBLUE "\"", PNAME(player), PNAME(player), buf2 + 1);
                if (!anotify_from(player, who, buf)) {
                    sprintf(buf, SYSBLUE "%s is not connected.", PNAME(who));
                    anotify_nolisten2(player, buf);
                    break;
                }
                sprintf(buf, SYSBLUE "You whisper, \"" SYSPURPLE "%s %s"
                        SYSBLUE "\" to %s.", PNAME(player), buf2 + 1,
                        PNAME(who));
                anotify(player, buf);
                break;
            } else {
                sprintf(buf, SYSBLUE "%s whispers, \"" SYSPURPLE "%s" SYSBLUE
                        "\"", PNAME(player), buf2);
                if (!anotify_from(player, who, buf)) {
                    sprintf(buf, SYSBLUE "%s is not connected.", PNAME(who));
                    anotify_nolisten2(player, buf);
                    break;
                }
                sprintf(buf, SYSBLUE "You whisper, \"" SYSPURPLE "%s" SYSBLUE
                        "\" to %s.", buf2, PNAME(who));
                anotify(player, buf);
                break;
            }
    }
}
Example #29
0
// ---------------------------------------------------------------------------
// do_wait: Command interface to wait_que
//
void do_wait
(
    dbref executor,
    dbref caller,
    dbref enactor,
    int   eval,
    int key,
    char *event,
    char *cmd,
    char *cargs[],
    int ncargs
)
{
    CLinearTimeAbsolute ltaWhen;
    CLinearTimeDelta    ltd;

    // If arg1 is all numeric, do simple (non-sem) timed wait.
    //
    if (is_rational(event))
    {
        if (key & WAIT_UNTIL)
        {
            ltaWhen.SetSecondsString(event);
        }
        else
        {
            ltaWhen.GetUTC();
            ltd.SetSecondsString(event);
            ltaWhen += ltd;
        }
        wait_que(executor, caller, enactor, eval, true, ltaWhen, NOTHING, 0,
            cmd,
            ncargs, cargs,
            mudstate.global_regs);
        return;
    }

    // Semaphore wait with optional timeout.
    //
    char *what = parse_to(&event, '/', 0);
    init_match(executor, what, NOTYPE);
    match_everything(0);

    dbref thing = noisy_match_result();
    if (!Good_obj(thing))
    {
        return;
    }
    else if (!Controls(executor, thing) && !Link_ok(thing))
    {
        notify(executor, NOPERM_MESSAGE);
    }
    else
    {
        // Get timeout, default 0.
        //
        int atr = A_SEMAPHORE;
        bool bTimed = false;
        if (event && *event)
        {
            if (is_rational(event))
            {
                if (key & WAIT_UNTIL)
                {
                    ltaWhen.SetSecondsString(event);
                }
                else
                {
                    ltaWhen.GetUTC();
                    ltd.SetSecondsString(event);
                    ltaWhen += ltd;
                }
                bTimed = true;
            }
            else
            {
                ATTR *ap = atr_str(event);
                if (!ap)
                {
                    atr = mkattr(executor, event);
                    if (atr <= 0)
                    {
                        notify_quiet(executor, "Invalid attribute.");
                        return;
                    }
                    ap = atr_num(atr);
                }
                else
                {
                    atr = ap->number;
                }
                if (!bCanSetAttr(executor, thing, ap))
                {
                    notify_quiet(executor, NOPERM_MESSAGE);
                    return;
                }
            }
        }

        int num = add_to(thing, 1, atr);
        if (num <= 0)
        {
            // Thing over-notified, run the command immediately.
            //
            thing = NOTHING;
            bTimed = false;
        }
        wait_que(executor, caller, enactor, eval, bTimed, ltaWhen, thing, atr,
            cmd,
            ncargs, cargs,
            mudstate.global_regs);
    }
}
Example #30
0
void
do_give(int descr, dbref player, const char *recipient, int amount)
{
	dbref who;
	char buf[BUFFER_LEN];
	struct match_data md;

	/* do amount consistency check */
	if (amount < 0 && !Wizard(OWNER(player))) {
		notify(player, "Try using the \"rob\" command.");
		return;
	} else if (amount == 0) {
		notify_fmt(player, "You must specify a positive number of %s.", tp_pennies);
		return;
	}
	/* check recipient */
	init_match(descr, player, recipient, TYPE_PLAYER, &md);
	match_neighbor(&md);
	match_me(&md);
	if (Wizard(OWNER(player))) {
		match_player(&md);
		match_absolute(&md);
	}
	switch (who = match_result(&md)) {
	case NOTHING:
		notify(player, "Give to whom?");
		return;
	case AMBIGUOUS:
		notify(player, "I don't know who you mean!");
		return;
	default:
		if (!Wizard(OWNER(player))) {
			if (Typeof(who) != TYPE_PLAYER) {
				notify(player, "You can only give to other players.");
				return;
			} else if (GETVALUE(who) + amount > tp_max_pennies) {
				notify_fmt(player, "That player doesn't need that many %s!", tp_pennies);
				return;
			}
		}
		break;
	}

	/* try to do the give */
	if (!payfor(player, amount)) {
		notify_fmt(player, "You don't have that many %s to give!", tp_pennies);
	} else {
		/* he can do it */
		switch (Typeof(who)) {
		case TYPE_PLAYER:
			SETVALUE(who, GETVALUE(who) + amount);
			if(amount >= 0) {
				snprintf(buf, sizeof(buf), "You give %d %s to %s.",
						amount, amount == 1 ? tp_penny : tp_pennies, NAME(who));
				notify(player, buf);
				snprintf(buf, sizeof(buf), "%s gives you %d %s.",
						NAME(player), amount, amount == 1 ? tp_penny : tp_pennies);
				notify(who, buf);
			} else {
				snprintf(buf, sizeof(buf), "You take %d %s from %s.",
						-amount, amount == -1 ? tp_penny : tp_pennies, NAME(who));
				notify(player, buf);
				snprintf(buf, sizeof(buf), "%s takes %d %s from you!",
						NAME(player), -amount, -amount == 1 ? tp_penny : tp_pennies);
				notify(who, buf);
			}
			break;
		case TYPE_THING:
			SETVALUE(who, (GETVALUE(who) + amount));
			snprintf(buf, sizeof(buf), "You change the value of %s to %d %s.",
					NAME(who),
					GETVALUE(who), GETVALUE(who) == 1 ? tp_penny : tp_pennies);
			notify(player, buf);
			break;
		default:
			notify_fmt(player, "You can't give %s to that!", tp_pennies);
			break;
		}
		DBDIRTY(who);
	}
}