/** * Transmit the current mission index via UART1. GetCurrentMission returns a -1 if there're no missions, * so we check and only transmit valid current missions. */ void MavLinkSendCurrentMission(void) { int8_t currentMission; GetCurrentMission(¤tMission); if (currentMission != -1) { mavlink_message_t msg; mavlink_msg_mission_current_pack(mavlink_system.sysid, mavlink_system.compid, &msg, (uint16_t)currentMission); len = mavlink_msg_to_send_buffer(buf, &msg); uart1EnqueueData(buf, (uint8_t)len); } }
void MavLinkSendMissionItem(uint8_t currentMissionIndex) { Mission m; uint8_t result; GetMission(currentMissionIndex, &m, &result); if (result) { mavlink_message_t msg; int8_t missionManagerCurrentIndex; GetCurrentMission(&missionManagerCurrentIndex); mavlink_msg_mission_item_pack(mavlink_system.sysid, mavlink_system.compid, &msg, groundStationSystemId, groundStationComponentId, currentMissionIndex, m.refFrame, m.action, (currentMissionIndex == (uint8_t)missionManagerCurrentIndex), m.autocontinue, m.parameters[0], m.parameters[1], m.parameters[2], m.parameters[3], m.coordinates[0], m.coordinates[1], m.coordinates[2]); len = mavlink_msg_to_send_buffer(buf, &msg); uart1EnqueueData(buf, (uint8_t)len); } }
bool HouseExt::HasNeededFactory(HouseClass *pHouse, TechnoTypeClass *pItem) { DWORD ItemOwners = pItem->GetOwners(); eAbstractType WhatAmI = pItem->WhatAmI(); for(int i = 0; i < pHouse->Buildings.Count; ++i) { auto pBld = pHouse->Buildings[i]; if(!pBld->InLimbo && pBld->HasPower) { if(pBld->Type->Factory == WhatAmI) { if(pBld->GetCurrentMission() != mission_Selling && pBld->QueuedMission != mission_Selling) { if((pBld->Type->GetOwners() & ItemOwners) != 0) { return true; } } } } } return false; }
bool BuildingExt::cPrismForwarding::ValidateSupportTower(BuildingExt::cPrismForwarding* pTargetTower, BuildingExt::cPrismForwarding* pSlaveTower) { //MasterTower = the firing tower. This might be the same as TargetTower, it might not. //TargetTower = the tower that we are forwarding to //SlaveTower = the tower being considered to support TargetTower auto TargetTower = pTargetTower->GetOwner(); auto SlaveTower = pSlaveTower->GetOwner(); if(SlaveTower->IsAlive) { BuildingTypeClass *pSlaveType = SlaveTower->Type; BuildingTypeExt::ExtData *pSlaveTypeData = BuildingTypeExt::ExtMap.Find(pSlaveType); if(pSlaveTypeData->PrismForwarding.Enabled == BuildingTypeExt::cPrismForwarding::YES || pSlaveTypeData->PrismForwarding.Enabled == BuildingTypeExt::cPrismForwarding::FORWARD) { //building is a prism tower //get all the data we need TechnoExt::ExtData *pTechnoData = TechnoExt::ExtMap.Find(SlaveTower); //BuildingExt::ExtData *pSlaveData = BuildingExt::ExtMap.Find(SlaveTower); int SlaveMission = SlaveTower->GetCurrentMission(); //now check all the rules if(SlaveTower->ReloadTimer.Ignorable() && SlaveTower != TargetTower && !SlaveTower->DelayBeforeFiring && !SlaveTower->IsBeingDrained() && !SlaveTower->IsBeingWarpedOut() && SlaveMission != mission_Attack && SlaveMission != mission_Construction && SlaveMission != mission_Selling && pTechnoData->IsPowered() //robot control logic && pTechnoData->IsOperated() //operator logic && SlaveTower->IsPowerOnline() //base-powered or overpowerer-powered && !SlaveTower->IsUnderEMP() //EMP logic - I think this should already be checked by IsPowerOnline() but included just to be sure ) { BuildingTypeClass *pTargetType = TargetTower->Type; if(pSlaveTypeData->PrismForwarding.Targets.Contains(pTargetType)) { //valid type to forward from HouseClass *pMasterHouse = this->GetOwner()->Owner; HouseClass *pTargetHouse = TargetTower->Owner; HouseClass *pSlaveHouse = SlaveTower->Owner; if((pSlaveHouse == pTargetHouse && pSlaveHouse == pMasterHouse) || (pSlaveTypeData->PrismForwarding.ToAllies && pSlaveHouse->IsAlliedWith(pTargetHouse) && pSlaveHouse->IsAlliedWith(pMasterHouse))) { //ownership/alliance rules satisfied CellStruct tarCoords = TargetTower->GetCell()->MapCoords; CoordStruct MyPosition, curPosition; TargetTower->GetPosition_2(&MyPosition); SlaveTower->GetPosition_2(&curPosition); int Distance = (int)MyPosition.DistanceFrom(curPosition); int SupportRange = 0; int idxSupport = -1; if(SlaveTower->Veterancy.IsElite()) { idxSupport = pSlaveTypeData->PrismForwarding.EliteSupportWeaponIndex; } else { idxSupport = pSlaveTypeData->PrismForwarding.SupportWeaponIndex; } if(idxSupport != -1) { if(WeaponTypeClass * supportWeapon = pSlaveType->get_Weapon(idxSupport)) { if(Distance < supportWeapon->MinimumRange) { return false; //below minimum range } SupportRange = supportWeapon->Range; } } if(SupportRange == 0) { //not specified on SupportWeapon so use Primary + 1 cell (Marshall chose to add the +1 cell default - see manual for reason) if(WeaponTypeClass * cPrimary = pSlaveType->get_Primary()) { SupportRange = cPrimary->Range + 256; //256 leptons == 1 cell } } if(SupportRange < 0 || Distance <= SupportRange) { return true; //within range } } } } } } return false; }