コード例 #1
0
ファイル: mech.c3i.c プロジェクト: fstltna/Battletech-MUX
void replicateC3iNetwork(MECH * mechSrc, MECH * mechDest)
{
    int i;
    dbref otherRef;

    debugC3(tprintf("REPLICATE: %d's C3i network to %d", mechSrc->mynum,
	    mechDest->mynum));

    clearC3iNetwork(mechDest, 0);

    MechC3iNetworkElem(mechDest, 0) = mechSrc->mynum;
    MechC3iNetworkSize(mechDest) = 1;

    for (i = 0; i < C3I_NETWORK_SIZE; i++) {
	otherRef = MechC3iNetworkElem(mechSrc, i);

	if (otherRef != mechDest->mynum) {
	    MechC3iNetworkElem(mechDest, MechC3iNetworkSize(mechDest)) =
		otherRef;
	    MechC3iNetworkSize(mechDest) += 1;
	}
    }

    validateC3iNetwork(mechDest);
}
コード例 #2
0
ファイル: mech.c3i.c プロジェクト: fstltna/Battletech-MUX
void clearC3iNetwork(MECH * mech, int tClearFromOthers)
{
    MECH *otherMech;
    int i;

    debugC3(tprintf("CLEAR: %d's C3i network", mech->mynum));

    for (i = 0; i < C3I_NETWORK_SIZE; i++) {
	otherMech = getOtherMechInNetwork(mech, i, 0, 0, 0, 0);

	MechC3iNetworkElem(mech, i) = -1;

	if (tClearFromOthers) {
	    if (!otherMech)
		continue;

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

	    clearMechFromC3iNetwork(mech->mynum, otherMech);
	}
    }

    MechC3iNetworkSize(mech) = 0;
}
コード例 #3
0
ファイル: mech.c3i.c プロジェクト: fstltna/Battletech-MUX
void validateC3iNetwork(MECH * mech)
{
    MECH *otherMech;
    dbref myTempNetwork[C3I_NETWORK_SIZE];
    int i;
    int networkSize = 0;

    debugC3(tprintf("VALIDATE: %d's C3i network", mech->mynum));

    if (!HasC3i(mech) || Destroyed(mech) || C3iDestroyed(mech)) {
	clearC3iNetwork(mech, 1);

	return;
    }

    if (MechC3iNetworkSize(mech) < 0) {
	clearC3iNetwork(mech, 1);

	return;
    }

    for (i = 0; i < C3I_NETWORK_SIZE; i++) {
	otherMech = getOtherMechInNetwork(mech, i, 0, 0, 0, 0);

	if (!otherMech)
	    continue;

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

	debugC3(tprintf("VALIDATE INFO: %d is now in %d's C3i network",
		otherMech->mynum, mech->mynum));

	myTempNetwork[networkSize++] = otherMech->mynum;
    }

    clearC3iNetwork(mech, 0);

    for (i = 0; i < networkSize; i++)
	MechC3iNetworkElem(mech, i) = myTempNetwork[i];

    MechC3iNetworkSize(mech) = networkSize;

    debugC3(tprintf("VALIDATE INFO: %d's C3i network is %d elements",
	    mech->mynum, MechC3iNetworkSize(mech)));
}
コード例 #4
0
ファイル: mech.c3.misc.c プロジェクト: chazu/btmux
void buildTempNetwork(MECH * mech, dbref * myNetwork, int *networkSize,
					  int tCheckECM, int tCheckStarted, int tCheckUncon,
					  int tIsC3)
{
	int tempNetworkSize = 0;
	int baseNetworkSize;
	MECH *otherMech;
	dbref myTempNetwork[C3_NETWORK_SIZE];
	int i;

	/* Re-init the network */
	for(i = 0; i < C3_NETWORK_SIZE; i++)
		myNetwork[i] = -1;

	*networkSize = 0;

	baseNetworkSize =
		(tIsC3 ? MechC3NetworkSize(mech) : MechC3iNetworkSize(mech));

	if(baseNetworkSize == 0)
		return;

	/*
	 * Build the base netork of all the mechs that fit the criteria we passed in
	 */
	for(i = 0; i < baseNetworkSize; i++) {
		otherMech =
			getOtherMechInNetwork(mech, i, tCheckECM, tCheckStarted,
								  tCheckUncon, tIsC3);

		if(!otherMech)
			continue;

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

		myTempNetwork[tempNetworkSize] = otherMech->mynum;
		tempNetworkSize++;
	}

	/*
	 * Once we're here, we're done with the C3i stuff, but we need to make sure that this is a valid C3 network
	 * still. For example, we may have lost a master due to death or something else, so we need to make sure we
	 * have enough masters left to actually do something.
	 *
	 * A valid network is one where there are MIN((((NUM_MASTERS * 4) - NUM_MASTERS) + ((MY_MASTERS * 4) - MY_MASTERS), 11) units in the network
	 */
	if(tIsC3) {
		if(tempNetworkSize > 0)
			tempNetworkSize =
				trimC3Network(mech, myTempNetwork, tempNetworkSize);
	}

	for(i = 0; i < tempNetworkSize; i++)
		myNetwork[i] = myTempNetwork[i];

	*networkSize = tempNetworkSize;
}
コード例 #5
0
ファイル: mech.c3i.c プロジェクト: fstltna/Battletech-MUX
void addMechToC3iNetwork(MECH * mech, MECH * mechToAdd)
{
    MECH *otherMech;
    MECH *otherNotifyMech;
    dbref otherRef;
    int i;
    int wPos = -1;

    debugC3(tprintf("ADD: %d to the C3i network of %d", mechToAdd->mynum,
	    mech->mynum));

    /* Find a position to add the new mech into my network */
    wPos = getFreeC3iNetworkPos(mech, mechToAdd);

    /* If we have a number that's less than 0, then we have an invalid position. Either we're already in the network or there's not enough room */
    if (wPos < 0)
	return;

    /* Well, we have a valid position, so let's put this mech in the network */
    MechC3iNetworkElem(mech, wPos) = mechToAdd->mynum;
    MechC3iNetworkSize(mech) += 1;

    mech_notify(mech, MECHALL,
	tprintf("%s connects to your C3i network.",
	    GetMechToMechID(mech, mechToAdd)));

    /* Now let's replicate the new network across the system so that everyone has the same network settings */
    for (i = 0; i < C3I_NETWORK_SIZE; i++) {
	otherRef = MechC3iNetworkElem(mech, i);

	otherMech = getOtherMechInNetwork(mech, i, 0, 0, 0, 0);

	if (!otherMech)
	    continue;

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

	if (otherRef != mechToAdd->mynum) {
	    otherNotifyMech = getOtherMechInNetwork(mech, i, 1, 1, 1, 0);

	    if (otherNotifyMech)
		mech_notify(otherNotifyMech, MECHALL,
		    tprintf("%s connects to your C3i network.",
			GetMechToMechID(otherNotifyMech, mechToAdd)));
	}

	replicateC3iNetwork(mech, otherMech);
    }

    /* Last, but not least, one final validation of the network */
    validateC3iNetwork(mech);
}
コード例 #6
0
ファイル: mech.c3i.c プロジェクト: fstltna/Battletech-MUX
void mech_c3i_network(dbref player, MECH * mech, char *buffer)
{
    cch(MECH_USUALO);

    DOCHECK(!HasC3i(mech), "This unit is not equipped with C3i!");
    DOCHECK(C3iDestroyed(mech), "Your C3i system is destroyed!");
    DOCHECK(AnyECMDisturbed(mech),
	"Your C3i system is not currently operational!");

    validateC3iNetwork(mech);

    DOCHECK(MechC3iNetworkSize(mech) <= 0,
	"There are no other units in your C3i network!");

    showNetworkData(player, mech, 0);
}
コード例 #7
0
ファイル: mech.c3i.c プロジェクト: fstltna/Battletech-MUX
void clearMechFromC3iNetwork(dbref refToClear, MECH * mech)
{
    int i;

    debugC3(tprintf("CLEAR: %d from the C3i network of %d", refToClear,
	    mech->mynum));

    if (!MechC3iNetworkSize(mech))
	return;

    for (i = 0; i < C3I_NETWORK_SIZE; i++) {
	if (MechC3iNetworkElem(mech, i) == refToClear)
	    MechC3iNetworkElem(mech, i) = -1;
    }

    validateC3iNetwork(mech);
}
コード例 #8
0
ファイル: mech.c3i.c プロジェクト: fstltna/Battletech-MUX
void mech_c3i_message(dbref player, MECH * mech, char *buffer)
{
    cch(MECH_USUALO);

    DOCHECK(!HasC3i(mech), "This unit is not equipped with C3i!");
    DOCHECK(C3iDestroyed(mech), "Your C3i system is destroyed!");
    DOCHECK(AnyECMDisturbed(mech),
	"Your C3i system is not currently operational!");

    validateC3iNetwork(mech);

    DOCHECK(MechC3iNetworkSize(mech) <= 0,
	"There are no other units in your C3i network!");

    skipws(buffer);
    DOCHECK(!*buffer, "What do you want to send on the C3i Network?");

    sendNetworkMessage(player, mech, buffer, 0);
}
コード例 #9
0
ファイル: glue.c プロジェクト: chazu/btmux
static int
load_update1(void *key, void *data, int depth, void *arg)
{
	const dbref key_val = (dbref)key;
	XCODE *const xcode_obj = data;
	FILE *const fp = arg;

	MAP *map;
	int doh;
	char mapbuffer[MBUF_SIZE];
	MECH *mech;
	int i;
	int ctemp;

	switch (xcode_obj->type) {
	case GTYPE_MAP:
		map = (MAP *)xcode_obj;
		memset(map->mapobj, 0, sizeof(map->mapobj));
		map->map = NULL;
		strcpy(mapbuffer, map->mapname);
		doh = (map->flags & MAPFLAG_MAPO);
		if(strcmp(map->mapname, "Default Map"))
			map_loadmap(1, map, mapbuffer);
		if(!strcmp(map->mapname, "Default Map") || !map->map)
			initialize_map_empty(map, key_val);
		if(!feof(fp)) {
			load_mapdynamic(fp, map);
			if(!feof(fp))
				if(doh)
					load_mapobjs(fp, map);
		}
		if(feof(fp)) {
			map->first_free = 0;
			map->mechflags = NULL;
			map->mechsOnMap = NULL;
			map->LOSinfo = NULL;
		}
		debug_fixmap(GOD, map, NULL);
		break;

	case GTYPE_MECH:
		mech = (MECH *)xcode_obj;
		if(!(FlyingT(mech) && !Landed(mech))) {
			MechDesiredSpeed(mech) = 0;
			MechSpeed(mech) = 0;
			MechVerticalSpeed(mech) = 0;
		}
		ctemp = MechCocoon(mech);
		if(MechCocoon(mech)) {
			MechCocoon(mech) = 0;
			initiate_ood((dbref) GOD, mech, tprintf("%d %d %d", MechX(mech), MechY(mech), MechZ(mech)));
			MechCocoon(mech) = ctemp;
		}

		if(!FlyingT(mech) && Started(mech) && Jumping(mech))
			mech_Rsetxy(GOD, (void *) mech, tprintf("%d %d", MechX(mech),MechY(mech)));
	
		MechStatus(mech) &= ~(BLINDED | UNCONSCIOUS | JUMPING | TOWED);
		MechSpecials2(mech) &=
			~(ECM_ENABLED | ECM_DISTURBANCE | ECM_PROTECTED |
			  ECCM_ENABLED | ANGEL_ECM_ENABLED | ANGEL_ECCM_ENABLED |
			  ANGEL_ECM_PROTECTED | ANGEL_ECM_DISTURBED);
		MechCritStatus(mech) &= ~(JELLIED | LOAD_OK | OWEIGHT_OK | SPEED_OK);
		MechWalkXPFactor(mech) = 999;
		MechCarrying(mech) = -1;
		MechBoomStart(mech) = 0;
		MechC3iNetworkSize(mech) = -1;
		MechHeatLast(mech) = 0;
		MechCommLast(mech) = 0;
		// ClearStaggerDamage
		mech->rd.staggerDamageList = NULL;
		if(!(MechXPMod(mech)))
			MechXPMod(mech) = 1;		
		for(i = 0; i < FREQS; i++)
			if(mech->freq[i] < 0)
				mech->freq[i] = 0;
		break;
	}
	return 1;
}
コード例 #10
0
ファイル: mech.c3i.c プロジェクト: fstltna/Battletech-MUX
void mech_c3i_join_leave(dbref player, void *data, char *buffer)
{
    MECH *mech = (MECH *) data, *target;
    MAP *objMap;
    char *args[2];
    dbref refTarget;
    int LOS = 1;
    float range = 0.0;

    cch(MECH_USUALO);

    DOCHECK(mech_parseattributes(buffer, args, 2) != 1,
	"Invalid number of arguments to function!");

    DOCHECK(!HasC3i(mech), "This unit is not equipped with C3i!");
    DOCHECK(C3iDestroyed(mech), "Your C3i system is destroyed!");
    DOCHECK(AnyECMDisturbed(mech),
	"Your C3i system is not currently operational!");

    validateC3iNetwork(mech);

    /* Clear our C3i Network */
    if (!strcmp(args[0], "-")) {
	if (MechC3iNetworkSize(mech) <= 0) {
	    mech_notify(mech, MECHALL,
		"You are not connected to a C3i network!");

	    return;
	}

	clearC3iNetwork(mech, 1);

	mech_notify(mech, MECHALL, "You disconnect from the C3i network.");

	return;
    }

    /* Well, if we're here then we wanna connect to a network */
    /* Let's check to see if we're already in one... can't be in two at the same time */
    DOCHECK(MechC3iNetworkSize(mech) > 0,
	"You are already in a C3i network!");

    objMap = getMap(mech->mapindex);

    /* Find who we're trying to connect to */
    refTarget = FindTargetDBREFFromMapNumber(mech, args[0]);
    target = getMech(refTarget);

    if (target) {
	LOS =
	    InLineOfSight(mech, target, MechX(target), MechY(target),
	    range);
    } else
	refTarget = 0;

    DOCHECK((refTarget < 1) ||
	!LOS, "That is not a valid targetID. Try again.");
    DOCHECK(MechTeam(mech) != MechTeam(target),
	"You can't use the C3i network of unfriendly units!");
    DOCHECK(mech == target, "You can't connect to yourself!");
    DOCHECK(Destroyed(target), "That unit is destroyed!");
    DOCHECK(!Started(target), "That unit is not started!");
    DOCHECK(!HasC3i(target),
	"That unit does not appear to be equipped with C3i!");

    /* validate the network of our target */
    validateC3iNetwork(target);
    DOCHECK(MechC3iNetworkSize(target) >= C3I_NETWORK_SIZE,
	"That unit's C3i network is operating at maximum capacity!");

    /* Connect us up */
    mech_notify(mech, MECHALL, tprintf("You connect to %s's C3i network.",
	    GetMechToMechID(mech, target)));

    addMechToC3iNetwork(target, mech);
}
コード例 #11
0
ファイル: mech.c3.misc.c プロジェクト: chazu/btmux
MECH *getOtherMechInNetwork(MECH * mech, int wIdx, int tCheckECM,
							int tCheckStarted, int tCheckUncon, int tIsC3)
{
	MECH *tempMech;
	dbref refOtherMech;
	int networkSize;

	networkSize =
		(tIsC3 ? MechC3NetworkSize(mech) : MechC3iNetworkSize(mech));

	if((wIdx >= networkSize) || (wIdx < 0))
		return NULL;

	refOtherMech =
		(tIsC3 ? MechC3NetworkElem(mech, wIdx) : MechC3iNetworkElem(mech,
																	wIdx));

	if(refOtherMech > 0) {
		tempMech = getMech(refOtherMech);

		if(!tempMech)
			return NULL;

		if(MechTeam(tempMech) != MechTeam(mech))
			return NULL;

		if(tempMech->mapindex != mech->mapindex)
			return NULL;

		if(Destroyed(tempMech))
			return NULL;

		if(tIsC3) {
			if(!HasC3(tempMech))	/* Sanity check */
				return NULL;

			if(C3Destroyed(tempMech))
				return NULL;
		} else {
			if(!HasC3i(tempMech))	/* Sanity check */
				return NULL;

			if(C3iDestroyed(tempMech))
				return NULL;
		}

		if(tCheckECM)
			if(AnyECMDisturbed(tempMech))
				return NULL;

		if(tCheckStarted)
			if(!Started(tempMech))
				return NULL;

		if(tCheckUncon)
			if(Uncon(tempMech))
				return NULL;

		return tempMech;
	}

	return NULL;
}