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); }
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))); }
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); }
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); }
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; }