コード例 #1
0
ファイル: speech.c プロジェクト: GlowMUCK/GlowMUCK
/* doesn't really belong here, but I couldn't figure out where else */
void 
do_page(dbref player, const char *arg1, const char *arg2)
{
    int     ignored;
    char    buf[BUFFER_LEN], buf2[BUFFER_LEN];
    dbref   target;

    if (!payfor(player, tp_lookup_cost)) {
	anotify_fmt(player, CFAIL "You don't have enough %s.", tp_pennies);
	return;
    }
    if ( strcmp(arg1, "me") ) {
	if ((target = lookup_player(arg1)) == NOTHING) {
	    anotify(player, CINFO WHO_MESG);
	    return;
	}
    } else target = player;

    if(Guest(player)) {
	if(!Mage(target)) {
	    anotify(player, CINFO "Guests can only page " NAMEWIZ "s, type 'wizzes'.");
	    return;
	}
    }

    if (FLAGS(target) & HAVEN) {
	anotify(player, CFAIL "That player is haven.");
	return;
    }

    ignored = ignoring(target, player);
    if(ignored == 1) {
	anotify(player, CFAIL "That player is ignoring you.");
	return;
    } else if(ignored == 2) {
	anotify(player, CINFO "That player is ignoring you.");
    }

    do_parse_mesg(player, player, arg2, "(page)", buf, MPI_ISPRIVATE);
    tct(buf,buf2);

    if (!*buf2) {
	sprintf(buf, CGREEN "You sense that %s is looking for you in %s.",
			PNAME(player), NAME(DBFETCH(player)->location));
    } else {
	if(buf2[0] == ':' || buf2[0] == ';') {
	    sprintf(buf, CGREEN "%s pages \"" CYELLOW "%s %.3900s" CGREEN "\"",
			PNAME(player), PNAME(player), buf2);
	} else {
	    sprintf(buf, CGREEN "%s pages \"" CYELLOW "%.3900s" CGREEN "\"",
			PNAME(player), buf2);
	}
    }
    if (anotify_from(player, target, buf))
	anotify(player, CSUCC "Your message has been sent.");
    else {
	sprintf(buf, CINFO "%s is not connected.", PNAME(target));
	anotify(player, buf);
    }
}
コード例 #2
0
ファイル: speech.c プロジェクト: CyberLeo/protomuck
void
do_wall(dbref player, const char *message)
{
    char buf[BUFFER_LEN];

    if ((Mage(player) || (POWERS(player) & POW_ANNOUNCE))
        && Typeof(player) == TYPE_PLAYER) {
        if (!*message) {
            anotify_nolisten2(player, CINFO "Shout what?");
            return;
        }
        switch (message[0]) {
            case ':':
            case ';':
                sprintf(buf, SYSWHITE MARK SYSNORMAL "%s %s", NAME(player),
                        message + 1);
                break;
            case '#':
            case '|':
                sprintf(buf, SYSWHITE MARK SYSNORMAL "%s", message + 1);
                break;
            default:
                sprintf(buf, SYSWHITE MARK SYSNORMAL "%s shouts, \"%s\"",
                        NAME(player), message);
        }
        wall_all(buf);
        /* log_status("WALL: %s(%d): %s\n", NAME(player), player, buf); */
    } else {
        anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
    }
}
コード例 #3
0
ファイル: speech.c プロジェクト: GlowMUCK/GlowMUCK
void 
do_gripe(dbref player, const char *message)
{
    dbref   loc;
    char buf[BUFFER_LEN];

    if(Guest(player)) {
	anotify(player, CFAIL NOGUEST_MESG);
	return;
    }

    if (!message || !*message) {
	if (Mage(player)) {
	    spit_file(player, LOG_GRIPE);
	} else {
	    anotify(player, CINFO "What's wrong?");
	}
	return;
    }

    loc = DBFETCH(player)->location;
    log_gripe("%s(%d) in %s(%d): %.3900s\n",
	      NAME(player), player, NAME(loc), loc, message);

    anotify(player, CINFO "Your complaint has been filed.");

    sprintf(buf, MARK "Gripe from %s: %.3900s", NAME(player), message);
    wall_wizards(buf);
}
コード例 #4
0
ファイル: speech.c プロジェクト: GlowMUCK/GlowMUCK
void 
do_wall(dbref player, const char *message)
{
    char    buf[BUFFER_LEN];

    if (Mage(player) && Typeof(player) == TYPE_PLAYER) {
	switch(message[0]) {
	    case ':':
	    case ';':
		sprintf(buf, MARK "%s %.3900s", NAME(player), message+1);
		break;
	    case '@':
		sprintf(buf, MARK "%.3900s", message+1);
		break;
	    case '\0':
	    case '#':
		notify(player, "@wall help");
		notify(player, "~~~~~");
		notify(player, "@wall message  -- Show all players 'message'");
		notify(player, "@wall :message -- Pose message to all players");
		notify(player, "@wall @message -- Spoof message to all players");
		notify(player, "@wall #        -- Show this help list");
		return;
	    default:
		sprintf(buf, MARK "%s shouts, \"%.3900s\"", NAME(player), message);
	}
	wall_all( buf );
	/* log_status("WALL: %s: %.3900s\n", unparse_object(MAN, player), buf); */
    } else {
	anotify(player, CFAIL NOPERM_MESG);
    }
}
コード例 #5
0
ファイル: speech.c プロジェクト: CyberLeo/protomuck
/* doesn't really belong here, but I couldn't figure out where else */
void
do_page(int descr, dbref player, const char *arg1, const char *arg2)
{
    char buf[BUFFER_LEN], buf2[BUFFER_LEN];
    dbref target;

    if (!payfor(player, tp_lookup_cost)) {
        anotify_fmt(player, CFAIL "You don't have enough %s.", tp_pennies);
        return;
    }
    if (strcmp(arg1, "me")) {
        if ((target = lookup_player(arg1)) == NOTHING) {
            anotify_nolisten2(player, CINFO "Who?");
            return;
        }
    } else
        target = player;

    if (Guest(player)) {
        if (!Mage(target)) {
            anotify_nolisten2(player,
                              CINFO
                              "Guests can only page wizards, type 'wizzes'.");
            return;
        }
    }

    if (FLAGS(target) & HAVEN) {
        anotify_nolisten2(player, CFAIL "That player is haven.");
        return;
    }
    if (Meeper(OWNER(player))) {
        do_parse_mesg(descr, player, player, arg2, "(page)", buf,
                      MPI_ISPRIVATE);
        tct(buf, buf2);
    } else {
        tct(arg2, buf2);
    }

    if (!*buf2) {
        sprintf(buf, CSUCC "You sense that %s is looking for you in %s.",
                PNAME(player), NAME(DBFETCH(player)->location));
    } else {
        if (buf2[0] == ':' || buf2[0] == ';') {
            sprintf(buf, SYSGREEN "%s pages \"" SYSYELLOW "%s %s" SYSGREEN "\"",
                    PNAME(player), PNAME(player), buf2);
        } else {
            sprintf(buf, SYSGREEN "%s pages \"" SYSYELLOW "%s" SYSGREEN "\"",
                    PNAME(player), buf2);
        }
    }
    if (anotify_from(player, target, buf))
        anotify_nolisten2(player, CSUCC "Your message has been sent.");
    else {
        sprintf(buf, CSUCC "%s is not connected.", PNAME(target));
        anotify_nolisten2(player, buf);
    }
}
コード例 #6
0
ファイル: game.c プロジェクト: CyberLeo/protomuck
void 
do_delta(dbref player)
{
    if (Mage(player)) {
	anotify_nolisten2(player, CINFO "Dumping deltas...");
	delta_dump_now();
	anotify_nolisten2(player, CINFO "Done.");
    } else
	anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
}
コード例 #7
0
ファイル: predicates.c プロジェクト: nekosune/protomuck
/* Given a dbref and a cost, subtracts the cost from the player's
 * pennies and returns 1. Returns 0 if the player could not afford
 * it.
 */
bool
payfor(dbref who, int cost)
{
    if (who == NOTHING)
        return 1;

    who = OWNER(who);
    if (Mage(who) || (POWERS(who) & POW_NO_PAY)) {
        return 1;

    } else if (DBFETCH(who)->sp.player.pennies >= cost) {
        DBFETCH(who)->sp.player.pennies -= cost;
        DBDIRTY(who);
        return 1;
    } else
        return 0;
}
コード例 #8
0
ファイル: predicates.c プロジェクト: nekosune/protomuck
/* determines if a player can set a flag based on permission level 
 * 0 indicates they can, 1 indicates they cannot. Only checks flagset2.
 */
bool
restricted2(dbref player, dbref thing, object_flag_type flag)
{
    switch (flag) {
        case F2GUEST:
            return (!Mage(OWNER(player)));
            break;
        case F2LOGWALL:
            return (!Arch(OWNER(player)));
        case F2HIDDEN: /* HIDDEN is now also EXTPERMS for programs */
            if (Typeof(thing) == TYPE_PROGRAM) {
                return !controls(player, thing);
            } else { 
                if (Typeof(thing) == TYPE_PLAYER)
                    return (!Arch(OWNER(player)) && !(POWERS(player) & POW_HIDE));
                else
                    return 1;
            }
        case F2ANTIPROTECT:
            if (Typeof(thing) == TYPE_PLAYER)
                return (!Boy(OWNER(player)));
            else
                return 1;
#ifdef CONTROLS_SUPPORT
        case F2CONTROLS:
            /* only by W4.  Not even by things they own. */
            if (Typeof(thing) == TYPE_PLAYER)
                return (!Boy(player));
            if (Typeof(thing) == TYPE_PROGRAM)
                return (!Wizard(player));
            /* anything else, if I truly control it. */
            return !truecontrols(player, thing);
            break;
#endif
        case F2MOBILE:
            return !(MLevel(OWNER(player)) >= tp_userflag_mlev);
            break;
        case F2SUSPECT:
            return (!Wizard(OWNER(player)));
        default:
            return 0;
            break;
    }
}
コード例 #9
0
ファイル: create.c プロジェクト: CyberLeo/protomuck
/* do_link
 *
 * Use this to link to a room that you own.  It also sets home for
 * objects and things, and drop-to's for rooms.
 * It seizes ownership of an unlinked exit, and costs 1 penny
 * plus a penny transferred to the exit owner if they aren't you
 *
 * All destinations must either be owned by you, or be LINK_OK.
 */
void
do_link(int descr, dbref player, const char *thing_name, const char *dest_name)
{
    dbref good_dest[MAX_LINKS];
    int ndest, i;
    struct match_data md;
    char buf[BUFFER_LEN];
    dbref thing, dest;

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

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

    init_match(descr, player, thing_name, TYPE_EXIT, &md);
    match_all_exits(&md);
    match_neighbor(&md);
    match_possession(&md);
    match_me(&md);
    match_here(&md);
    match_absolute(&md);
    match_registered(&md);

    if (Mage(OWNER(player)))
        match_player(&md);

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

    switch (Typeof(thing)) {
        case TYPE_EXIT:
            /* we're ok, check the usual stuff */
            if (DBFETCH(thing)->sp.exit.ndest != 0) {
                if (controls(player, thing)) {
                    if ((DBFETCH(thing)->sp.exit.dest)[0] != NIL) {
                        anotify_nolisten2(player,
                                          CINFO "That exit is already linked.");
                        return;
                    }
                } else {
                    anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
                    return;
                }
            }

            /* handle costs */
            if (OWNER(thing) == OWNER(player)) {
                if (!payfor(player, tp_link_cost)) {
                    anotify_fmt(player,
                                CFAIL "It costs %d %s to link this exit.",
                                tp_link_cost,
                                (tp_link_cost == 1) ? tp_penny : tp_pennies);
                    return;
                }
            } else {
                if (!payfor(player, tp_link_cost + tp_exit_cost)) {
                    anotify_fmt(player,
                                CFAIL "It costs %d %s to link this exit.",
                                (tp_link_cost + tp_exit_cost),
                                (tp_link_cost + tp_exit_cost ==
                                 1) ? tp_penny : tp_pennies);
                    return;
                } else if (!Builder(player)) {
                    anotify_nolisten2(player, CFAIL NOBBIT_MESG);
                    return;
                } else {
                    /* pay the owner for his loss */
                    dbref owner = OWNER(thing);

                    DBFETCH(owner)->sp.player.pennies += tp_exit_cost;
                    DBDIRTY(owner);
                }
            }

            /* link has been validated and paid for; do it */
            OWNER(thing) = OWNER(player);

            if (!
                (ndest =
                 link_exit(descr, player, thing, (char *) dest_name,
                           good_dest))) {
                anotify_nolisten2(player, CFAIL "No destinations linked.");
                DBFETCH(player)->sp.player.pennies += tp_link_cost; /* Refund! */
                DBDIRTY(player);
                break;
            }

            DBFETCH(thing)->sp.exit.ndest = ndest;
            if (DBFETCH(thing)->sp.exit.dest)
                free(DBFETCH(thing)->sp.exit.dest);

            DBFETCH(thing)->sp.exit.dest =
                (dbref *) malloc(sizeof(dbref) * ndest);
            for (i = 0; i < ndest; i++)
                (DBFETCH(thing)->sp.exit.dest)[i] = good_dest[i];
            break;
        case TYPE_THING:
        case TYPE_PLAYER:
            init_match(descr, player, dest_name, TYPE_ROOM, &md);
            match_neighbor(&md);
            match_absolute(&md);
            match_registered(&md);
            match_me(&md);
            match_here(&md);
            match_null(&md);

            if (Typeof(thing) == TYPE_THING)
                match_possession(&md);
            if ((dest = noisy_match_result(&md)) == NOTHING)
                return;
	    if (Typeof(thing) == TYPE_THING && dest == NIL) {
                anotify_fmt(player, CFAIL "%s", "You cannot HOME a THING to NIL.");
                return;		
	    }
            if (!controls(player, thing)
                || !can_link_to(player, Typeof(thing), dest)) {
                anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
                return;
            }
            if (parent_loop_check(thing, dest)) {
                anotify_nolisten2(player,
                                  CFAIL "That would cause a parent paradox.");
                return;
            }
            /* do the link */
            if (Typeof(thing) == TYPE_THING) {
                DBFETCH(thing)->sp.thing.home = dest;
            } else
                DBFETCH(thing)->sp.player.home = dest;
            sprintf(buf, CSUCC "%s's home set to %s.",
                    NAME(thing), unparse_object(player, dest));
            anotify_nolisten2(player, buf);
            break;
        case TYPE_ROOM:        /* room dropto's */
            init_match(descr, player, dest_name, TYPE_ROOM, &md);
            match_neighbor(&md);
            match_possession(&md);
            match_registered(&md);
            match_absolute(&md);
            match_home(&md);
            match_null(&md);

            if ((dest = noisy_match_result(&md)) == NOTHING)
                break;

            if (!controls(player, thing)
                || !can_link_to(player, Typeof(thing), dest)
                || (thing == dest)) {
                anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
            } else {
                DBFETCH(thing)->sp.room.dropto = dest; /* dropto */
                sprintf(buf, CSUCC "%s's dropto set to %s.",
                        NAME(thing), unparse_object(player, dest));
                anotify_nolisten2(player, buf);
            }

            break;
        case TYPE_PROGRAM:
            anotify_nolisten2(player,
                              CFAIL "You can't link programs to things!");
            break;
        default:
            anotify_nolisten2(player, CFAIL "Weird object type.");
            log_status("*BUG: weird object: Typeof(%d) = %d\n",
                       thing, Typeof(thing));
            break;
    }
    DBDIRTY(thing);
    return;
}
コード例 #10
0
ファイル: tune.c プロジェクト: CyberLeo/protomuck
void
do_tune(dbref player, char *parmname, char *parmval)
{
    int result;

    if (!Mage(player)) {
        anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
        return;
    }

    if (!Arch(player) && *parmval) {
        anotify_fmt(player, CFAIL "%s", tp_noperm_mesg);
        return;
    }

    if (*parmname && *parmval) {
        result = tune_setparm(player, parmname, parmval);
        switch (result) {
        case TUNESET_SUCCESS:
            log_status("TUNE: %s(%d) tuned %s to %s\n",
                       NAME(player), player, parmname, parmval);
            anotify_nolisten2(player, CSUCC "Parameter set.");
            tune_display_parms(player, parmname);
            break;
        case TUNESET_UNKNOWN:
            anotify_nolisten2(player, CINFO "Unknown parameter.");
            break;
        case TUNESET_SYNTAX:
            anotify_nolisten2(player, CFAIL "Bad parameter syntax.");
            break;
        case TUNESET_BADVAL:
            anotify_nolisten2(player, CFAIL "Bad parameter value.");
            break;
        case TUNESET_NOPERM:
            anotify_nolisten2(player, CFAIL "Permission denied.");
        }
        return;
    } else if (*parmname) {
        /* if (!string_compare(parmname, "save")) {
           tune_save_parmsfile();
           anotify_nolisten2(player, CSUCC "Saved parameters to configuration file.");
           } else if (!string_compare(parmname, "load")) {
           tune_load_parmsfile(player);
           anotify_nolisten2(player, CSUCC "Restored parameters from configuration file.");
           } else
         */
        if (!string_compare(parmname, "strings") ||
            !string_compare(parmname, "str"))
            tune_show_strings(player, parmname);
        else if (!string_compare(parmname, "times") ||
                 !string_compare(parmname, "time"))
            tune_show_times(player, parmname);
        else if (!string_compare(parmname, "int") ||
                 !string_compare(parmname, "ints"))
            tune_show_vals(player, parmname);
        else if (!string_compare(parmname, "ref") ||
                 !string_compare(parmname, "refs") ||
                 !string_compare(parmname, "dbrefs") ||
                 !string_compare(parmname, "dbref"))
            tune_show_refs(player, parmname);
        else if (!string_compare(parmname, "bool") ||
                 !string_compare(parmname, "bools"))
            tune_show_bool(player, parmname);
        else
            tune_display_parms(player, parmname);
        return;
    } else if (!*parmval && !*parmname) {
        tune_display_parms(player, parmname);
    } else {
        anotify_nolisten2(player, CINFO "Tune what?");
        return;
    }
}
コード例 #11
0
ファイル: msgparse.c プロジェクト: CyberLeo/protomuck
int
Mageperms(dbref what)
{
    if (Mage(what) && TMage(OWNER(what))) return 1;
    return 0;
}
コード例 #12
0
ファイル: game.c プロジェクト: CyberLeo/protomuck
void 
process_command(int descr, dbref player, char *command)
{
    char   *arg1;
    char   *arg2;
    char   *full_command, *commandline=command, *commandstuff;
    char   *p;                  /* utility */
    char    pbuf[BUFFER_LEN];
    char    xbuf[BUFFER_LEN];
    char    ybuf[BUFFER_LEN];
    const char *path;
    struct frame *tmpfr;

    if (command == 0)
	abort();

    /* robustify player */
    if (player < 0 || player >= db_top ||
	    (Typeof(player) != TYPE_PLAYER && Typeof(player) != TYPE_THING)) {
	log_status("process_command: bad player %d\n", player);
	return;
    }

    if ((tp_log_commands || (tp_log_guests && Guest(OWNER(player)))) &&
	    (!(FLAGS(player)&(INTERACTIVE | READMODE)))) {
	log_command("%s%s%s%s(%d) in %s(%d):%s %s\n",
		    Mage(OWNER(player)) ? "WIZ: " : "",
		    (Typeof(player) != TYPE_PLAYER) ? NAME(player) : "",
		    (Typeof(player) != TYPE_PLAYER) ? " by " : "",
		    NAME(OWNER(player)), (int) player,
		    NAME(DBFETCH(player)->location),
		    (int) DBFETCH(player)->location,
		    (FLAGS(player) & INTERACTIVE) ?
		    " [interactive]" : " ", command);
    }

    if (FLAGS(player) & INTERACTIVE) {
	interactive(descr, player, command);
	return;
    }
    /* eat leading whitespace */
    while (*command && isspace(*command))
	command++;

    commandstuff = command;
    /* check for single-character commands */
    if (*command == SAY_TOKEN || *command == '\'') {
	sprintf(pbuf, "say %s", command + 1);
	command = &pbuf[0];
    } else if (*command == POSE_TOKEN || *command == ';') {
	sprintf(pbuf, "pose %s", command + 1);
	command = &pbuf[0];
    } else if ((*command == '|' || (*commandstuff++ == '\\' && *commandstuff == '\\') ) && can_move(descr, player, "spoof", 0)) {
      if(*command = '\\')
         sprintf(pbuf, "spoof %s", command + 2);
      else
         sprintf(pbuf, "spoof %s", command + 1);
      command = &pbuf[0];
    }

    /* if player is a wizard, and uses overide token to start line...*/
    /* ... then do NOT run actions, but run the command they specify. */
    if (!strcmp(command, WHO_COMMAND)) {
       char xxbuf[BUFFER_LEN];

       strcpy(xxbuf, "@");
       strcat(xxbuf, WHO_COMMAND);
       strcat(xxbuf, " ");
       strcat(xxbuf, command + sizeof(WHO_COMMAND) - 1);
       if (can_move(descr, player, xxbuf, 5)) {
          do_move(descr, player, xxbuf, 5);
       } else {
          pdump_who_users(descr, command + sizeof(WHO_COMMAND) - 1);
       }
       return;
    }

    if (!( *command == OVERIDE_TOKEN && TMage(player) )) {
	if( can_move(descr, player, command, 0) ) {
	    do_move(descr, player, command, 0); /* command is exact match for exit */
	    *match_args = 0;
	    *match_cmdname = 0; 
	    return;
	}
    }

	if (*command == OVERIDE_TOKEN && TMage(player))
	    command++;

	full_command = strcpy(xbuf, command);
	for (; *full_command && !isspace(*full_command); full_command++);
	if (*full_command)
	    full_command++;

	/* find arg1 -- move over command word */
	command = strcpy(ybuf, command);
	for (arg1 = command; *arg1 && !isspace(*arg1); arg1++);
	/* truncate command */
	if (*arg1)
	    *arg1++ = '\0';

	/* remember command for programs */
	strcpy(match_cmdname, command);

	/* move over spaces */
	while (*arg1 && isspace(*arg1))
	    arg1++;

	/* find end of arg1, start of arg2 */
	for (arg2 = arg1; *arg2 && *arg2 != ARG_DELIMITER; arg2++);

	/* truncate arg1 */
	for (p = arg2 - 1; p >= arg1 && isspace(*p); p--)
	    *p = '\0';

	/* go past delimiter if present */
	if (*arg2)
	    *arg2++ = '\0';
	while (*arg2 && isspace(*arg2))
	    arg2++;

	strcpy(match_cmdname, command);
	strcpy(match_args, full_command);

	switch (command[0]) {
	    case '@':
		switch (command[1]) {
		    case 'a':
		    case 'A':
			/* @action, @attach */
			switch (command[2]) {
			    case 'c':
			    case 'C':
				Matched("@action");
				do_action(descr, player, arg1, arg2);
				break;
			    case 'r':
			    case 'R':
				if (string_compare(command, "@armageddon"))
				    goto bad;
				do_armageddon(player, full_command);
				break;
			    case 't':
			    case 'T':
				Matched("@attach");
				do_attach(descr, player, arg1, arg2);
				break;
                      case 'n':
                      case 'N':
                        Matched("@ansidescribe");
                        do_ansidescribe(descr, player, arg1, arg2);
                        break;
			    default:
				goto bad;
			}
			break;
		    case 'b':
		    case 'B':
			Matched("@boot");
			do_boot(player, arg1);
			break;
		    case 'c':
		    case 'C':
			/* chown, contents, create */
			switch (command[2]) {
			    case 'h':
			    case 'H':
				switch (command[3]) {
				    case 'l':
				    case 'L':
					Matched("@chlock");
					do_chlock(descr, player, arg1, arg2);
					break;
				    case 'o':
				    case 'O':
					Matched("@chown");
					do_chown(descr, player, arg1, arg2);
					break;
				    default:
					goto bad;
				}
				break;
			    case 'o':
			    case 'O':
				switch (command[4]) {
				    case 'l':
				    case 'L':
					Matched("@conlock");
					do_conlock(descr, player, arg1, arg2);
					break;
				    case 't':
				    case 'T':
					Matched("@contents");
					do_contents(descr, player, arg1, arg2);
					break;
				    default:
					goto bad;
				}
				break;
			    case 'r':
			    case 'R':
				if (string_compare(command, "@credits")) {
				    Matched("@create");
				    do_create(player, arg1, arg2);
				} else {
				    do_credits(player);
				}
				break;
			    default:
				goto bad;
			}
			break;
		    case 'd':
		    case 'D':
			/* describe, dequeue, dig, or dump */
			switch (command[2]) {
			    case 'b':
			    case 'B':
				Matched("@dbginfo");
				do_serverdebug(descr, player, arg1, arg2);
				break;
			    case 'e':
			    case 'E':
#ifdef DELTADUMPS
				if(command[3] == 'l' || command[3] == 'L') {
				    Matched("@delta");
				    do_delta(player);
				} else
#endif
				{
                          if( (command[3] == 's' || command[3] == 'S') &&
                              (command[4] == 't' || command[4] == 'T') ) {
                            Matched("@destroy");
 				    do_recycle(descr, player, arg1);
                          } else {
				    Matched("@describe");
				    do_describe(descr, player, arg1, arg2);
                          }
				}
				break;
			    case 'i':
			    case 'I':
				Matched("@dig");
				do_dig(descr, player, arg1, arg2);
				break;
#ifdef DELTADUMPS
			    case 'l':
			    case 'L':
				Matched("@dlt");
				do_delta(player);
				break;
#endif
			    case 'o':
			    case 'O':
				Matched("@doing");
				if (!tp_who_doing) goto bad;
				do_doing(descr, player, arg1, arg2);
				break;
			    case 'r':
			    case 'R':
				Matched("@drop");
				do_drop_message(descr, player, arg1, arg2);
				break;
			    case 'u':
			    case 'U':
				Matched("@dump");
				do_dump(player, full_command);
				break;
			    default:
				goto bad;
			}
			break;
		    case 'e':
		    case 'E':
			switch (command[2]) {
			    case 'd':
			    case 'D':
				Matched("@edit");
				do_edit(descr, player, arg1);
				break;
			    case 'n':
			    case 'N':
				Matched("@entrances");
				do_entrances(descr, player, arg1, arg2);
				break;
			    case 'x':
			    case 'X':
				Matched("@examine");
				sane_dump_object(player, arg1);
				break;
			    default:
				goto bad;
			}
			break;
		    case 'f':
		    case 'F':
			/* fail, find, force, or frob */
			switch (command[2]) {
			    case 'a':
			    case 'A':
				Matched("@fail");
				do_fail(descr, player, arg1, arg2);
				break;
			    case 'i':
			    case 'I':
				if(command[3] == 'x' || command[3] == 'X') {
				    Matched("@fixwizbits");
				    do_fixw(player, full_command);
				} else {
				    Matched("@find");
				    do_find(player, arg1, arg2);
				}
				break;
			    case 'l':
			    case 'L':
				Matched("@flock");
				do_flock(descr, player, arg1, arg2);
				break;
			    case 'o':
			    case 'O':
				Matched("@force");
				do_force(descr, player, arg1, arg2);
				break;
			    case 'r':
			    case 'R':
				if (string_compare(command, "@frob"))
				    goto bad;
				do_frob(descr, player, arg1, arg2);
				break;
			    default:
				goto bad;
			}
			break;
		    case 'h':
		    case 'H':
                  switch (command[2]) {
                     case 'T':
                     case 't':
                        Matched("@htmldescribe");
                        do_htmldescribe(descr, player, arg1, arg2);
                        break;
                     default:
 			      Matched("@hopper");
			      do_hopper(player, arg1);
                        break;
                  }
			break;
		    case 'i':
		    case 'I':
                  switch(command[2]) {
                     case 'h':
                     case 'H':
   	   		      Matched("@ihtmldescribe");
			      do_ihtmldescribe(descr, player, arg1, arg2);
			      break;
                     case 'a':
                     case 'A':
                        Matched("@iansidescribe");
                        do_iansidescribe(descr, player, arg1, arg2);
                        break;
                     default:
   			      Matched("@idescribe");
			      do_idescribe(descr, player, arg1, arg2);
			      break;
                  }
                  break;
		    case 'k':
		    case 'K':
			Matched("@kill");
			do_dequeue(descr, player, arg1);
			break;
		    case 'l':
		    case 'L':
			/* lock or link */
			switch (command[2]) {
			    case 'i':
			    case 'I':
				switch (command[3]) {
				    case 'n':
				    case 'N':
					Matched("@link");
					do_link(descr, player, arg1, arg2);
					break;
				    case 's':
				    case 'S':
					Matched("@list");
					match_and_list(descr, player, arg1, arg2, 1);
					break;
				    default:
					goto bad;
				}
				break;
			    case 'o':
			    case 'O':
				Matched("@lock");
				do_lock(descr, player, arg1, arg2);
				break;
			    default:
				goto bad;
			}
			break;
		    case 'm':
		    case 'M':
			switch (command[2]) {
			    case 'e':
			    case 'E':
				Matched("@memory");
				do_memory(player);
				break;
			    case 'c':
			    case 'C':
				switch (command[4]) {
				   case '2':
				     Matched("@mcp2muf");
				     match_and_list(descr, player, arg1, arg2, 0);
				     break;
				   default:
				     Matched("@mcp");
				     do_prog(descr, player, arg1, 1);
				     break;
				}
                     default:
                        goto bad;
			}
			break;
		    case 'n':
		    case 'N':
			/* @name or @newpassword */
			switch (command[2]) {
			    case 'a':
			    case 'A':
				Matched("@name");
				do_name(descr, player, arg1, arg2);
				break;
			    case 'e':
			    case 'E':
				if (string_compare(command, "@newpassword"))
				    goto bad;
				do_newpassword(player, arg1, arg2);
				break;
			    default:
				goto bad;
			}
			break;
		    case 'o':
		    case 'O':
			switch (command[2]) {
			    case 'd':
			    case 'D':
				Matched("@odrop");
				do_odrop(descr, player, arg1, arg2);
				break;
			    case 'e':
			    case 'E':
				Matched("@oecho");
				do_oecho(descr, player, arg1, arg2);
				break;
			    case 'f':
			    case 'F':
				Matched("@ofail");
				do_ofail(descr, player, arg1, arg2);
				break;
			    case 'p':
			    case 'P':
				Matched("@open");
				do_open(descr, player, arg1, arg2);
				break;
			    case 's':
			    case 'S':
				Matched("@osuccess");
				do_osuccess(descr, player, arg1, arg2);
				break;
			    case 'w':
			    case 'W':
				Matched("@owned");
				do_owned(player, arg1, arg2);
				break;
			    default:
				goto bad;
			}
			break;
		    case 'p':
		    case 'P':
			switch (command[2]) {
			    case 'a':
			    case 'A':
				Matched("@password");
				do_password(player, arg1, arg2);
				break;
			    case 'c':
			    case 'C':
				Matched("@pcreate");
				do_pcreate(player, arg1, arg2);
				break;
			    case 'e':
			    case 'E':
				Matched("@pecho");
				do_pecho(descr, player, arg1, arg2);
				break;
			    case 'r':
			    case 'R':
				if (string_prefix("@program", command)) {
				    do_prog(descr, player, arg1, 0);
				    break;
				} else if (string_prefix("@proginfo", command)) {
				    do_proginfo(player, arg1);
				    break;
				} else {
				    Matched("@propset");
				    do_propset(descr, player, arg1, arg2);
				    break;
				}
			    case 's':
			    case 'S':
				Matched("@ps");
				list_events(player);
				break;
			    case 'u':
			    case 'U':
				Matched("@purge");
				do_purge(descr, player, arg1, arg2);
				break;
			    default:
				goto bad;
			}
			break;
		    case 'r':
		    case 'R':
			switch (command[3]) {
			    case 'c':
			    case 'C':
				Matched("@recycle");
				do_recycle(descr, player, arg1);
				break;
			    case 's':
			    case 'S':
				if (!string_compare(command, "@restart")) {
				    do_restart(player, full_command);
				} else if (!string_compare(command, "@restrict")) {
				    do_restrict(player, arg1);
				} else {
				    goto bad;
				}
				break;
			    default:
				goto bad;
			}
			break;
		    case 's':
		    case 'S':
			/* set, shutdown, success */
			switch (command[2]) {
			    case 'a':
			    case 'A':
				if (!string_compare(command, "@sanity")) {
				    sanity(player);
				} else if (!string_compare(command, "@sanchange")) {
				    sanechange(player, full_command);
				} else if (!string_compare(command, "@sanfix")) {
				    sanfix(player);
				} else {
				    goto bad;
				}
				break;
			    case 'e':
			    case 'E':
				Matched("@set");
				do_set(descr, player, arg1, arg2);
				break;
			    case 'h':
			    case 'H':
				if (!string_compare(command, "@shout")) {
				    do_wall(player, full_command);
				    break;
				}
				if (string_compare(command, "@shutdown"))
				    goto bad;
				do_shutdown(player, arg1);
				break;
			    case 't':
			    case 'T':
				Matched("@stats");
				do_stats(player, arg1);
				break;
			    case 'u':
			    case 'U':
				Matched("@success");
				do_success(descr, player, arg1, arg2);
				break;
			    case 'w':
			    case 'W':
				Matched("@sweep");
				do_sweep(descr, player, arg1);
				break;
			    default:
				goto bad;
			}
			break;
		    case 't':
		    case 'T':
			switch (command[2]) {
			    case 'e':
			    case 'E':
				Matched("@teleport");
				do_teleport(descr, player, arg1, arg2);
				break;
                      case 'o':
                      case 'O':
				if (string_compare(command, "@toad"))
				    goto bad;
				do_frob(descr, player, arg1, arg2);
				break;
			    case 'r':
			    case 'R':
				Matched("@trace");
				do_trace(descr, player, arg1, atoi(arg2));
				break;
			    case 'u':
			    case 'U':
				Matched("@tune");
				do_tune(player, arg1, arg2);
				break;
			    default:
				goto bad;
			}
			break;
		    case 'u':
		    case 'U':
			switch (command[2]) {
			    case 'N':
			    case 'n':
				if (string_prefix(command, "@unlink")) {
				    do_unlink(descr, player, arg1);
				} else if (string_prefix(command, "@unlock")) {
				    do_unlock(descr, player, arg1);
				} else if (string_prefix(command, "@uncompile")) {
				    do_uncompile(player);
				} else {
				    goto bad;
				}
				break;

#ifndef NO_USAGE_COMMAND
			    case 'S':
			    case 's':
				Matched("@usage");
				do_usage(player);
				break;
#endif

			    default:
				goto bad;
				break;
			}
			break;
		    case 'v':
		    case 'V':
			Matched("@version");
			anotify_nolisten2(player, CRIMSON "ProtoMUCK " PROTOBASE PURPLE " (" RED VERSION WHITE " -- " AQUA NEONVER PURPLE ")" );
			break;
		    case 'w':
		    case 'W':
			if (string_compare(command, "@wall"))
			    goto bad;
			do_wall(player, full_command);
			break;
		    default:
			goto bad;
		}
		break;
          case '&':
            do_mush_set(descr, player, arg1, arg2, command);
            break;
	    case 'd':
	    case 'D':
		switch (command[1]) {
		    case 'b':
		    case 'B':
			Matched("dboot");
			do_dboot(player, arg1);
			break;
		    case 'i':
		    case 'I':
			Matched("dinfo");
			do_dinfo(player, arg1);
			break;
		    case 'r':
		    case 'R':
			Matched("drop");
			do_drop(descr, player, arg1, arg2);
			break;
		    case 'w':
		    case 'W':
			Matched("dwall");
			do_dwall(player, arg1, arg2);
			break;
		    default:
			goto bad;
		}
		break;
	    case 'e':
	    case 'E':
		switch (command[1]) {
		    case 'm':
		    case 'M':
			Matched("emote");
			do_pose(descr, player, full_command);
			break;
		    case 'x':
		    case 'X':
		    case '\0':
			Matched("examine");
			do_examine(descr, player, arg1, arg2);
			break;
		    default:
			goto bad;
		}
		break;
	    case 'g':
	    case 'G':
		/* get, give, go, or gripe */
		switch (command[1]) {
		    case 'e':
		    case 'E':
			Matched("get");
			do_get(descr, player, arg1, arg2);
			break;
		    case 'i':
		    case 'I':
			Matched("give");
			do_give(descr, player, arg1, atoi(arg2));
			break;
		    case 'o':
		    case 'O':
			Matched("goto");
			do_move(descr, player, arg1, 0);
			break;
		    case 'r':
		    case 'R':
			if(command[2]=='i' || command[2]=='I') {
				if (string_compare(command, "gripe"))
				    goto bad;
				do_gripe(player, full_command);
				break;
			}
		    default:
			goto bad;
		}
		break;
	    case 'h':
	    case 'H':
		switch (command[1]) {
		    case 'a':
		    case 'A':
			Matched("hand");
			do_drop(descr, player, arg1, arg2);
			break;
		    case 'e':
		    case 'E':
			Matched("help");
			do_help(player, arg1, arg2);
			break;
		    default:
			goto bad;
		}
		break;
	    case 'i':
	    case 'I':
		if (string_compare(command, "info")) {
		    Matched("inventory");
		    do_inventory(player);
		} else {
		    do_info(player, arg1, arg2);
		}
		break;
	    case 'l':
	    case 'L':
		if (string_prefix("look", command)) {
		    do_look_at(descr, player, arg1, arg2);
		    break;
		} else {
		    Matched("leave");
		    do_leave(descr, player);
		    break;
		}
	    case 'm':
	    case 'M':
		if (string_prefix(command, "move")) {
		    do_move(descr, player, arg1, 0);
		    break;
		} else if (!string_compare(command, "motd")) {
		    do_motd(player, full_command);
		    break;
		} else if (!string_compare(command, "mpi")) {
		    do_mpihelp(player, arg1, arg2);
		    break;
		} else {
		    if (string_compare(command, "man"))
			goto bad;
		    do_man(player, arg1, arg2);
		}
		break;
	    case 'n':
	    case 'N':
		/* news */
		Matched("news");
		do_news(player, arg1, arg2);
		break;
	    case 'p':
	    case 'P':
		switch (command[1]) {
		    case 'a':
		    case 'A':
		    case '\0':
			Matched("page");
			do_page(descr, player, arg1, arg2);
			break;
		    case 'o':
		    case 'O':
			Matched("pose");
			do_pose(descr, player, full_command);
			break;
		    case 'u':
		    case 'U':
			Matched("put");
			do_drop(descr, player, arg1, arg2);
			break;
		    default:
			goto bad;
		}
		break;
	    case 'r':
	    case 'R':
		switch (command[1]) {
		    case 'e':
		    case 'E':
			if(command[2] == 'q' || command[2] == 'Q'){
			    Matched("request");
			    request(player, NULL, commandline);
			} else {
			    Matched("read");    /* undocumented alias for look */
			    do_look_at(descr, player, arg1, arg2);
			}
			break;
		    default:
			goto bad;
		}
		break;
	    case 's':
	    case 'S':
		/* say, "score" */
		switch (command[1]) {
		    case 'a':
		    case 'A':
			Matched("say");
			do_say(descr, player, full_command);
			break;
		    case 'c':
		    case 'C':
		    case '\0':
			if( command[1] &&
			    (command[2] == 'a' || command[2] == 'A' )) {
			    Matched("scan");
			    do_sweep(descr, player, arg1);
			} else {
			    Matched("score");
			    do_score(player, 1);
			}
			break;
		    default:
			goto bad;
		}
		break;
	    case 't':
	    case 'T':
		switch (command[1]) {
		    case 'a':
		    case 'A':
			Matched("take");
			do_get(descr, player, arg1, arg2);
			break;
		    case 'h':
		    case 'H':
			Matched("throw");
			do_drop(descr, player, arg1, arg2);
			break;
		    default:
			goto bad;
		}
		break;
	    case 'w':
	    case 'W':
		switch (command[1]){
		    case 'c':
		    case 'C':
			Matched("wc");
			do_wizchat(player, full_command);
			break;
		    case 'i':
		    case 'I':
			Matched("wizchat");
			do_wizchat(player, arg1);
			break;
		    case 'h':
		    case 'H':
		    case '\0':
			Matched("whisper");
			do_whisper(descr, player, arg1, arg2);
			break;
		    default:
			goto bad;
		}
		break;
	    default:
	bad:
 		if ( Typeof(tp_huh_command) == TYPE_PROGRAM && !(player == -1)) {
			tmpfr = interp(descr, player, DBFETCH(player)->location, tp_huh_command, (dbref)-4, FOREGROUND, STD_REGUID);
			if (!tmpfr)
				goto bad2;
			(void) interp_loop(player, tp_huh_command, tmpfr, 0);
            } else {
   		   bad2:
                  anotify_fmt(player, CINFO "%s",tp_huh_mesg);
			if (tp_log_failed_commands && !controls(player, DBFETCH(player)->location)) {
		    		log_status("HUH from %s(%d) in %s(%d)[%s]: %s %s\n", NAME(player), player,
                        NAME(DBFETCH(player)->location),
			      DBFETCH(player)->location,
			      NAME(OWNER(DBFETCH(player)->location)), command,
			      full_command);
			}
		}
		break;
	}

}
コード例 #13
0
ファイル: predicates.c プロジェクト: nekosune/protomuck
bool
newcontrols(dbref who, dbref what, bool true_c)
{
    dbref index;

    /* No one controls invalid objects */
    /* if (what < 0 || what >= db_top)  -- not good enough */
    if (!OkObj(what) || !OkObj(who))
        return 0;

    /* Garbage controls nothing. */
    if (Typeof(who) == TYPE_GARBAGE)
        return 0;

    /* No one controls garbage */
    if (Typeof(what) == TYPE_GARBAGE)
        return 0;

    /* Puppets are based on owner */
    if (Typeof(who) != TYPE_PLAYER)
        who = OWNER(who);

    /* owners control their own stuff */
    /* Makes stuff faster here. -Hinoserm */
    if (who == OWNER(what))
        return 1;

    /* CONTROL_ALL controls all objects */
    if ((POWERS(who) & POW_CONTROL_ALL) && !Protect(what))
        return 1;

    /* CONTROL_MUF power controls all MUF objects */
    if ((POWERS(who) & POW_CONTROL_MUF) && (Typeof(what) == TYPE_PROGRAM)
        && (!(Protect(what))))
        return 1;

    /* Wizard controls (most) everything else */
    if (Wiz(who) && (!(Protect(what) && MLevel(OWNER(what)) >= LBOY)
                     || MLevel(who) >= LBOY))
        if (tp_fb_controls ? (MLevel(who) >= LWIZ)
            : (MLevel(who) >= MLevel(OWNER(what))))
            return 1;

    /* If realms control is enabled, the player will Control anything 
     * contained in a parent room he owns with at W1 bit or higher on it.
     * This gives him power to affect any object in his w-bitted parent room.
     */

    /* 
     *  Read the manual (help CONTROLS) about this new stuff.
     */

#ifdef CONTROLS_SUPPORT
    if (!true_c) {
        if (controlsEx(who, what))
            return 1;

        if (tp_realms_control) {
            if (!tp_wiz_realms) {
                if (Typeof(what) != TYPE_PLAYER)
                    for (index = what; index != NOTHING; index = getloc(index))
                        if ((controlsEx(who, index))
                            && (Typeof(index) == TYPE_ROOM
                                && ((FLAGS(index) & BUILDER) || Mage(index))))
                            return 1;
            } else {
                if (Typeof(what) != TYPE_PLAYER)
                    for (index = what; index != NOTHING; index = getloc(index))
                        if ((controlsEx(who, index))
                            && (Typeof(index) == TYPE_ROOM && (Mage(index))))
                            return 1;
            }
        }
    } else {
#endif

        if (tp_realms_control && (Typeof(what) != TYPE_PLAYER))
            for (index = what; index != NOTHING; index = getloc(index))
                if ((OWNER(index) == who) && (Typeof(index) == TYPE_ROOM
                                              && Mage(index)))
                    return 1;
#ifdef CONTROLS_SUPPORT
    }
#endif

    return 0;
}
コード例 #14
0
ファイル: speech.c プロジェクト: GlowMUCK/GlowMUCK
void 
do_whisper(dbref player, const char *arg1, const char *arg2)
{
    int     ignored;
    dbref   who;
    char    buf[BUFFER_LEN], buf2[BUFFER_LEN];
    struct match_data md;

    if(Guest(player)) {
	anotify(player, CFAIL NOGUEST_MESG);
	return;
    }

    init_match(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:
	case AMBIGUOUS:
	    anotify(player, CINFO WHO_MESG);
	    break;
	default:

	    ignored = ignoring(who, player);
	    if(ignored == 1) {
		anotify(player, CFAIL "That player is ignoring you.");
		return;
	    } else if(ignored == 2) {
		anotify(player, CINFO "That player is ignoring you.");
	    }

	    do_parse_mesg(player, player, arg2, "(whisper)", buf, MPI_ISPRIVATE);
	    tct(buf,buf2);

	    if (buf2[0] == ':' || buf2[0] == ';') {
		sprintf(buf, CBLUE "%s whispers, \"" CPURPLE "%s %.3900s" CBLUE "\"",
					PNAME(player), PNAME(player), buf2+1);
		if (!anotify_from(player, who, buf)) {
		    sprintf(buf, CBLUE "%s is not connected.", PNAME(who));
		    anotify(player, buf);
		    break;
		}
		sprintf(buf, CBLUE "You whisper, \"" CPURPLE "%s %.3900s" CBLUE "\" to %s.",
					 PNAME(player), buf2+1, PNAME(who));
		anotify(player, buf);
		break;
	    } else { 
		sprintf(buf, CBLUE "%s whispers, \"" CPURPLE "%.3900s" CBLUE "\"", PNAME(player), buf2);
		if (!anotify_from(player, who, buf)) {
		    sprintf(buf, CBLUE "%s is not connected.", PNAME(who));
		    anotify(player, buf);
		    break;
		}
		sprintf(buf, CBLUE "You whisper, \"" CPURPLE "%.3900s" CBLUE "\" to %s.", buf2, PNAME(who));
		anotify(player, buf);
		break;
	    }
    }
}
コード例 #15
0
ファイル: predicates.c プロジェクト: nekosune/protomuck
/* Indicates if a flag can or cannot be set.
 * Returns 1 if the flag can't be set, 0 if it can.
 * Note that this function only handles flagset 1. restricted2 for flagset2
 */
bool
restricted(dbref player, dbref thing, object_flag_type flag)
{
    switch (flag) {
        case ABODE:
            return (!Mage(OWNER(player)) && (Typeof(thing) == TYPE_PROGRAM));
            break;
        case ZOMBIE:
            if (tp_wiz_puppets)
                if (Typeof(thing) == TYPE_THING)
                    return (!Mage(OWNER(player)));
            if (Typeof(thing) == TYPE_PLAYER)
                return (!Mage(OWNER(player)));
            if ((Typeof(thing) == TYPE_THING)
                && (FLAGS(OWNER(player)) & ZOMBIE))
                return (!Mage(OWNER(player)));
            return (0);
        case VEHICLE:
            if (Typeof(thing) == TYPE_PLAYER)
                return (!Mage(OWNER(player)));
            if (tp_wiz_vehicles) {
                if (Typeof(thing) == TYPE_THING)
                    return (!Mage(OWNER(player)));
            } else {
                if ((Typeof(thing) == TYPE_THING) && (FLAGS(player) & VEHICLE))
                    return (!Mage(OWNER(player)));
            }
            return (0);
        case DARK:
            if (!Arch(OWNER(player)) && !(POWERS(player) & POW_HIDE)) {
                if (Typeof(thing) == TYPE_PLAYER)
                    return (1);
                if (!tp_exit_darking && Typeof(thing) == TYPE_EXIT)
                    return (1);
                if (!tp_thing_darking && Typeof(thing) == TYPE_THING)
                    return (1);
            }
            return (0);
            break;
        case QUELL:
            return (TMage(thing) && (thing != player) &&
                    (Typeof(thing) == TYPE_PLAYER));
            break;
        case BUILDER:
            if ((Typeof(thing) == TYPE_PLAYER)
                || (Typeof(thing) == TYPE_PROGRAM))
                return (!Mage(OWNER(player)));
            else
                return (!truecontrols(player, thing));
            break;
        case CHOWN_OK:
            if (Typeof(thing) == TYPE_PLAYER)
                return !((OWNER(thing) == player) || Mage(player));
            else
                return !truecontrols(player, thing);
            break;
        case W1:               /* We use @set to make our own rules for these */
        case W2:
        case W3:
        case W4:
            return 1;
            break;
        default:
            return 0;
            break;
    }
}
コード例 #16
0
ファイル: speech.c プロジェクト: CyberLeo/protomuck
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;
            }
    }
}
コード例 #17
0
void CODECHECK_sexActivity(Population &P)
{
	vector<double> age = vector_seq(10.0, 80.0, 200);
	vector<double> rskgrp = vector_seq(0, 2, 3);
	vector<double> nprtn = vector_seq(0, 9, 10);
	
	// --- Age

	vector<double> fage(age.size());
	
	for (int i=0; i<age.size(); i++) {
		fage[i] = P.sexAct_reduce_age(age[i]);
	}
	
	dcMatrix Mage(age);
	Mage.addColVector(fage);
	Mage.WriteToFileCSV(_DIR_VIZINPUT + "viz_input_sexact_age.out");

	
	// --- Risk
	
	vector<double> frisk(rskgrp.size());
	
	for (int i=0; i<rskgrp.size(); i++) {
		frisk[i] = P.sexAct_reduce_riskGroup((int)(rskgrp[i]));
	}
	
	dcMatrix Mrisk(rskgrp);
	Mrisk.addColVector(frisk);
	Mrisk.WriteToFileCSV(_DIR_VIZINPUT + "viz_input_sexact_risk.out");

	
	// --- Number of partners
	
	vector<double> fnp(nprtn.size());
	
	for (int i=0; i<nprtn.size(); i++) {
		fnp[i] = P.sexAct_reduce_nPartners((int)(nprtn[i]));
	}
	
	dcMatrix Mnp(nprtn);
	Mnp.addColVector(fnp);
	Mnp.WriteToFileCSV(_DIR_VIZINPUT + "viz_input_sexact_npartner.out");
	
	
	// --- Maximum number of concurrent partners
	
	vector<double> maxp(rskgrp.size());
	
	for (int i=0; i<rskgrp.size(); i++) {
		maxp[i] = P.proba_nMaxCurrSexPartner(male, (int)(rskgrp[i]));
	}
	
	dcMatrix Mmaxp(rskgrp);
	Mmaxp.addColVector(maxp);
	Mmaxp.WriteToFileCSV(_DIR_VIZINPUT + "viz_input_sexact_maxpartner_male.out");
	
	
	maxp.clear();
	maxp.resize(rskgrp.size());
	
	for (int i=0; i<rskgrp.size(); i++) {
		maxp[i] = P.proba_nMaxCurrSexPartner(female, (int)(rskgrp[i]));
	}
	
	dcMatrix Mmaxp2(rskgrp);
	Mmaxp2.addColVector(maxp);
	Mmaxp2.WriteToFileCSV(_DIR_VIZINPUT + "viz_input_sexact_maxpartner_female.out");

	
	// --- Probability sex with CSW
	
	vector<double> pcsw(rskgrp.size());
	
	for (int i=0; i<rskgrp.size(); i++) {
		pcsw[i] = P.probaSex_sexworker((int)(rskgrp[i]));
	}
	
	dcMatrix Mpcsw(rskgrp);
	Mpcsw.addColVector(pcsw);
	Mpcsw.WriteToFileCSV(_DIR_VIZINPUT + "viz_input_sexact_probacsw.out");

	
	// --- Probability sex type 0
	
	vector<double> psex0;
	vector<double> r1;
	vector<double> r2;
	
	for (int i=0; i<=rskgrp.size(); i++) {
		for (int j=0; j<=rskgrp.size(); j++) {
			r1.push_back(i);
			r2.push_back(j);
			psex0.push_back(P.probaSex_type0(i, j));
		}
	}
	
	dcMatrix Msex0(r1);
	Msex0.addColVector(r2);
	Msex0.addColVector(psex0);
	Msex0.WriteToFileCSV(_DIR_VIZINPUT + "viz_input_sexact_probatype0.out");
	
	// --- Probability sex type 1
	
	vector<double> psex1;
	r1.clear();
	r2.clear();
	
	for (int i=0; i<=rskgrp.size(); i++) {
		for (int j=0; j<=rskgrp.size(); j++) {
			r1.push_back(i);
			r2.push_back(j);
			psex1.push_back(P.probaSex_type1(i, j));
		}
	}
	
	dcMatrix Msex1(r1);
	Msex1.addColVector(r2);
	Msex1.addColVector(psex1);
	Msex1.WriteToFileCSV(_DIR_VIZINPUT + "viz_input_sexact_probatype1.out");

	
}