Exemple #1
0
void showNetworkTargets(dbref player, MECH * mech, int tIsC3)
{
	MAP *objMap = getMap(mech->mapindex);
	int i, j, wTemp, bearing;
	MECH *otherMech;
	float realRange, c3Range;
	char buff[100];
	char *mech_name;
	char move_type[30];
	char cStatus1, cStatus2, cStatus3, cStatus4, cStatus5;
	char weaponarc;
	int losFlag;
	int arc;
	int wSeeTarget = TARG_LOS_NONE;
	int wC3SeeTarget = TARG_LOS_NONE;
	int tShowStatusInfo = 0;
	char bufflist[MAX_MECHS_PER_MAP][120];
	float rangelist[MAX_MECHS_PER_MAP];
	int buffindex = 0;
	int sbuff[MAX_MECHS_PER_MAP];
	int networkSize;
	dbref myNetwork[C3_NETWORK_SIZE];
	dbref c3Ref;

	buildTempNetwork(mech, myNetwork, &networkSize, 1, 1, 0, tIsC3);

	/*
	 * Send then a 'contacts' style report. This is different from the
	 * normal contacts since it has a 'physical' range in it too.
	 */
	notify_printf(player, "%s Contacts:", tIsC3 ? "C3" : "C3i");

	for(i = 0; i < objMap->first_free; i++) {
		if(!(objMap->mechsOnMap[i] != mech->mynum &&
			 objMap->mechsOnMap[i] != -1))
			continue;

		otherMech = (MECH *) FindObjectsData(objMap->mechsOnMap[i]);

		if(!otherMech)
			continue;

		if(!Good_obj(otherMech->mynum))
			continue;

		tShowStatusInfo = 0;
		realRange = FlMechRange(objMap, mech, otherMech);
		losFlag =
			InLineOfSight(mech, otherMech, MechX(otherMech),
						  MechY(otherMech), realRange);

		/*
		 * If we do see them, let's make sure it's not just a 'something'
		 */
		if(losFlag) {
			if(InLineOfSight_NB(mech, otherMech, MechX(otherMech),
								MechY(otherMech), 0.0))
				wSeeTarget = TARG_LOS_CLEAR;
			else
				wSeeTarget = TARG_LOS_SOMETHING;
		} else
			wSeeTarget = TARG_LOS_NONE;

		/*
		 * If I don't see it, let's see if someone else in the network does
		 */
		if(wSeeTarget != TARG_LOS_CLEAR)
			wC3SeeTarget = mechSeenByNetwork(mech, otherMech, tIsC3);

		/* If noone sees it, we continue */
		if(!wSeeTarget && !wC3SeeTarget)
			continue;

		/* Get our network range */
		c3Range =
			findC3RangeWithNetwork(mech, otherMech, realRange, myNetwork,
								   networkSize, &c3Ref);

		/* Figure out if we show the info or not... ie, do we actually 'see' it */
		if((wSeeTarget != TARG_LOS_CLEAR) && (wC3SeeTarget != TARG_LOS_CLEAR)) {
			tShowStatusInfo = 0;
			mech_name = "something";
		} else {
			tShowStatusInfo = 1;
			mech_name = silly_atr_get(otherMech->mynum, A_MECHNAME);
		}

		bearing =
			FindBearing(MechFX(mech), MechFY(mech), MechFX(otherMech),
						MechFY(otherMech));
		strcpy(move_type, GetMoveTypeID(MechMove(otherMech)));

		/* Get our weapon arc */
		arc = InWeaponArc(mech, MechFX(otherMech), MechFY(otherMech));
		weaponarc = getWeaponArc(mech, arc);

		/* Now get our status chars */
		if(!tShowStatusInfo) {
			cStatus1 = ' ';
			cStatus2 = ' ';
			cStatus3 = ' ';
			cStatus4 = ' ';
			cStatus5 = ' ';
		} else {
			cStatus1 = getStatusChar(mech, otherMech, 1);
			cStatus2 = getStatusChar(mech, otherMech, 2);
			cStatus3 = getStatusChar(mech, otherMech, 3);
			cStatus4 = getStatusChar(mech, otherMech, 4);
			cStatus5 = getStatusChar(mech, otherMech, 5);
		}

		/* Now, build the string */
		sprintf(buff,
				"%s%c%c%c[%s]%c %-11.11s x:%3d y:%3d z:%3d r:%4.1f c:%4.1f b:%3d s:%5.1f h:%3d S:%c%c%c%c%c%s",
				otherMech->mynum == MechTarget(mech) ? "%ch%cr" :
				(tShowStatusInfo &&
				 !MechSeemsFriend(mech, otherMech)) ? "%ch%cy" : "",
				(losFlag & MECHLOSFLAG_SEESP) ? 'P' : ' ',
				(losFlag & MECHLOSFLAG_SEESS) ? 'S' : ' ', weaponarc,
				MechIDS(otherMech, MechSeemsFriend(mech, otherMech) ||
						!tShowStatusInfo), move_type[0], mech_name,
				MechX(otherMech), MechY(otherMech), MechZ(otherMech),
				realRange, c3Range, bearing, MechSpeed(otherMech),
				MechVFacing(otherMech), cStatus1, cStatus2, cStatus3,
				cStatus4, cStatus5, (otherMech->mynum == MechTarget(mech)
									 || !MechSeemsFriend(mech,
														 otherMech)) ? "%c" :
				"");

		rangelist[buffindex] = realRange;
		rangelist[buffindex] +=
			(MechStatus(otherMech) & DESTROYED) ? 10000 : 0;
		strcpy(bufflist[buffindex++], buff);
	}

	for(i = 0; i < buffindex; i++)
		sbuff[i] = i;

	/* print a sorted list of detected mechs */
	/* use the ever-popular bubble sort */
	for(i = 0; i < (buffindex - 1); i++)
		for(j = (i + 1); j < buffindex; j++)
			if(rangelist[sbuff[j]] > rangelist[sbuff[i]]) {
				wTemp = sbuff[i];
				sbuff[i] = sbuff[j];
				sbuff[j] = wTemp;
			}

	for(i = 0; i < buffindex; i++)
		notify(player, bufflist[sbuff[i]]);

	notify_printf(player, "End %s Contact List", tIsC3 ? "C3" : "C3i");
}
Exemple #2
0
UTF8 *decode_flags(dbref player, FLAGSET *fs)
{
    UTF8 *buf, *bp;
    buf = bp = alloc_sbuf("decode_flags");
    *bp = '\0';

    if (!Good_obj(player))
    {
        mux_strncpy(buf, T("#-2 ERROR"), SBUF_SIZE-1);
        return buf;
    }
    int flagtype = fs->word[FLAG_WORD1] & TYPE_MASK;
    bool bNeedColon = true;
    if (object_types[flagtype].lett != ' ')
    {
        safe_sb_chr(object_types[flagtype].lett, buf, &bp);
        bNeedColon = false;
    }

    FLAGNAMEENT *fp;
    for (fp = gen_flag_names; fp->flagname; fp++)
    {
        FLAGBITENT *fbe = fp->fbe;
        if (  !fp->bPositive
           || fbe->flaglett == ' ')
        {
            // Only look at positive-sense entries that have non-space flag
            // letters.
            //
            continue;
        }
        if (fs->word[fbe->flagflag] & fbe->flagvalue)
        {
            if (  (  (fbe->listperm & CA_STAFF)
                  && !Staff(player))
               || (  (fbe->listperm & CA_ADMIN)
                  && !WizRoy(player))
               || (  (fbe->listperm & CA_WIZARD)
                  && !Wizard(player))
               || (  (fbe->listperm & CA_GOD)
                  && !God(player)))
            {
                continue;
            }

            // Don't show CONNECT on dark wizards to mortals
            //
            if (  flagtype == TYPE_PLAYER
               && fbe->flagflag == FLAG_WORD2
               && fbe->flagvalue == CONNECTED
               && (fs->word[FLAG_WORD1] & (WIZARD | DARK)) == (WIZARD | DARK)
               && !See_Hidden(player))
            {
                continue;
            }

            if (  bNeedColon
               && mux_isdigit(fbe->flaglett))
            {
                // We can't allow numerical digits at the beginning.
                //
                safe_sb_chr(':', buf, &bp);
            }
            safe_sb_chr(fbe->flaglett, buf, &bp);
            bNeedColon = false;
        }
    }
    *bp = '\0';
    return buf;
}
Exemple #3
0
/*
 * ---------------------------------------------------------------------------
 * * Return an lbuf pointing to the object name and possibly the db# and flags
 */
UTF8 *unparse_object(dbref player, dbref target, bool obey_myopic, bool bAddColor)
{
    UTF8 *buf = alloc_lbuf("unparse_object");
    if (NOPERM <= target && target < 0)
    {
        mux_strncpy(buf, aszSpecialDBRefNames[-target], LBUF_SIZE-1);
    }
    else if (!Good_obj(target))
    {
        mux_sprintf(buf, LBUF_SIZE, T("*ILLEGAL*(#%d)"), target);
    }
    else
    {
        bool exam;
        if (obey_myopic)
        {
            exam = MyopicExam(player, target);
        }
        else
        {
            exam = Examinable(player, target);
        }

        // Leave and extra 100 bytes for the dbref and flags at the end and
        // color at the beginning if necessary..
        //
        mux_field fldName = StripTabsAndTruncate( Moniker(target), buf,
                                                  LBUF_SIZE-100, LBUF_SIZE-100);
        UTF8 *bp = buf + fldName.m_byte;

#if defined(FIRANMUX)
        if (  fldName.m_column == fldName.m_byte
           && bAddColor)
        {
            // There is no color in the name, so look for @color, or highlight.
            //
            UTF8 *buf2 = alloc_lbuf("unparse_object.color");
            UTF8 *bp2  = buf2;

            UTF8 *pLetters = AcquireColorLetters(player, target);
            if (NULL != pLetters)
            {
                safe_str(LettersToBinary(pLetters), buf2, &bp2);
                free_lbuf(pLetters);
                pLetters = NULL;
            }
            else
            {
                safe_str((UTF8 *)COLOR_INTENSE, buf2, &bp2);
            }

            *bp = '\0';
            safe_str(buf, buf2, &bp2);
            safe_str((UTF8 *)COLOR_RESET, buf2, &bp2);

            // Swap buffers.
            //
            free_lbuf(buf);
            buf = buf2;
            bp  = bp2;
        }
#else
        UNUSED_PARAMETER(bAddColor);
#endif // FIRANMUX

        if (  exam
           || (Flags(target) & (CHOWN_OK | JUMP_OK | LINK_OK | DESTROY_OK))
           || (Flags2(target) & ABODE))
        {
            // Show everything.
            //
            UTF8 *fp = decode_flags(player, &(db[target].fs));

            safe_str(T("(#"), buf, &bp);
            safe_ltoa(target, buf, &bp);
            safe_str(fp, buf, &bp);
            safe_chr(')', buf, &bp);

            free_sbuf(fp);
        }
        *bp = '\0';
    }
    return buf;
}
Exemple #4
0
char *unparse_flags( dbref player, dbref thing ) {
    char *buf, *bp, *s;

    FLAGENT *fp;

    int flagtype;

    FLAG fv, flagword, flag2word, flag3word;

    buf = bp = s = alloc_sbuf( "unparse_flags" );
    *bp = '\0';

    if( !Good_obj( player ) || !Good_obj( thing ) ) {
        strcpy( buf, "#-2 ERROR" );
        return buf;
    }
    flagword = Flags( thing );
    flag2word = Flags2( thing );
    flag3word = Flags3( thing );
    flagtype = ( flagword & TYPE_MASK );
    if( object_types[flagtype].lett != ' ' ) {
        safe_sb_chr( object_types[flagtype].lett, buf, &bp );
    }

    for( fp = gen_flags; fp->flagname; fp++ ) {
        if( fp->flagflag & FLAG_WORD3 ) {
            fv = flag3word;
        } else if( fp->flagflag & FLAG_WORD2 ) {
            fv = flag2word;
        } else {
            fv = flagword;
        }
        if( fv & fp->flagvalue ) {

            if( ( fp->listperm & CA_WIZARD ) && !Wizard( player ) ) {
                continue;
            }
            if( ( fp->listperm & CA_GOD ) && !God( player ) ) {
                continue;
            }

            /*
             * don't show CONNECT on dark wizards to mortals
             */

            if( ( flagtype == TYPE_PLAYER ) && isConnFlag( fp ) &&
                    Can_Hide( thing ) && Hidden( thing ) &&
                    !See_Hidden( player ) ) {
                continue;
            }

            /*
             * Check if this is a marker flag and we're at the
             * beginning of a buffer. If so, we need to insert a
             * separator character first so we don't end up
             * running the dbref number into the flags.
             */
            if( ( s == bp ) && isMarkerFlag( fp ) ) {
                safe_sb_chr( MARK_FLAG_SEP, buf, &bp );
            }

            safe_sb_chr( fp->flaglett, buf, &bp );
        }
    }

    *bp = '\0';
    return buf;
}
Exemple #5
0
void do_quota
(
    dbref executor,
    dbref caller,
    dbref enactor,
    int   eval,
    int   key,
    int   nargs,
    UTF8 *arg1,
    UTF8 *arg2,
    const UTF8 *cargs[],
    int ncargs
)
{
    UNUSED_PARAMETER(caller);
    UNUSED_PARAMETER(enactor);
    UNUSED_PARAMETER(eval);
    UNUSED_PARAMETER(nargs);
    UNUSED_PARAMETER(cargs);
    UNUSED_PARAMETER(ncargs);

    if (!(mudconf.quotas || Quota(executor)))
    {
        notify_quiet(executor, T("Quotas are not enabled."));
        return;
    }
    if ((key & QUOTA_TOT) && (key & QUOTA_REM))
    {
        notify_quiet(executor, T("Illegal combination of switches."));
        return;
    }

    dbref who;
    int value = 0, i;
    bool set = false;

    // Show or set all quotas if requested.
    //
    if (key & QUOTA_ALL)
    {
        if (arg1 && *arg1)
        {
            value = mux_atol(arg1);
            set = true;
        }
        else if (key & (QUOTA_SET | QUOTA_FIX))
        {
            value = 0;
            set = true;
        }
        if (set)
        {
            STARTLOG(LOG_WIZARD, "WIZ", "QUOTA");
            log_name(executor);
            log_text(T(" changed everyone\xE2\x80\x99s quota"));
            ENDLOG;
        }
        DO_WHOLE_DB(i)
        {
            if (isPlayer(i))
            {
                if (set)
                {
                    mung_quotas(i, key, value);
                }
                show_quota(executor, i);
            }
        }
        return;
    }

    // Find out whose quota to show or set.
    //
    if (!arg1 || *arg1 == '\0')
    {
        who = Owner(executor);
    }
    else
    {
        who = lookup_player(executor, arg1, true);
        if (!Good_obj(who))
        {
            notify_quiet(executor, T("Not found."));
            return;
        }
    }

    // Make sure we have permission to do it.
    //
    if (!Quota(executor))
    {
        if (arg2 && *arg2)
        {
            notify_quiet(executor, NOPERM_MESSAGE);
            return;
        }
        if (Owner(executor) != who)
        {
            notify_quiet(executor, NOPERM_MESSAGE);
            return;
        }
    }
    if (arg2 && *arg2)
    {
        set = true;
        value = mux_atol(arg2);
    }
    else if (key & QUOTA_FIX)
    {
        set = true;
        value = 0;
    }
    if (set)
    {
        STARTLOG(LOG_WIZARD, "WIZ", "QUOTA");
        log_name(executor);
        log_text(T(" changed the quota of "));
        log_name(who);
        ENDLOG;
        mung_quotas(who, key, value);
    }
    show_quota(executor, who);
}
Exemple #6
0
static void promote_match(dbref what, int confidence)
{
#ifdef REALITY_LVLS
    // Check is the object is visible.
    //
    if (  Good_obj(what)
       && (confidence & CON_LOCAL)
       && !IsReal(md.player, what)
       && what != Location(md.player))
    {
        return;
    }
#endif // REALITY_LVLS
    // Check for type and locks, if requested.
    //
    if (md.pref_type != NOTYPE)
    {
        if (  Good_obj(what)
           && Typeof(what) == md.pref_type)
        {
            confidence |= CON_TYPE;
        }
    }
    if (md.check_keys)
    {
        MSTATE save_md;

        save_match_state(&save_md);
        if (  Good_obj(what)
           && could_doit(md.player, what, A_LOCK))
        {
            confidence |= CON_LOCK;
        }
        restore_match_state(&save_md);
    }

    // If nothing matched, take it.
    //
    if (md.count == 0)
    {
        md.match = what;
        md.confidence = confidence;
        md.count = 1;
        return;
    }

    // If confidence is lower, ignore.
    //
    if (confidence < md.confidence)
    {
        return;
    }

    // If confidence is higher, replace.
    //
    if (confidence > md.confidence)
    {
        md.match = what;
        md.confidence = confidence;
        md.count = 1;
        return;
    }

    // Equal confidence, pick randomly.
    //
    md.count++;
    if (RandomINT32(1,md.count) == 1)
    {
        md.match = what;
    }
    return;
}