Skip to content

Commit

Permalink
Many bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bombbird2001 committed Apr 4, 2021
1 parent bbc9cd2 commit 8eb98e6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class Departure : Aircraft {
targetHeading = clearedHeading.toDouble()
isV2set = true
//Ensure the aircraft clears at least the first waypoint restriction to prevent nuisance alerts
if (route.getWaypoint(0) != null && route.getWptMinAlt(0) != -1) {
if (!sid.isRadarDep(runway?.name) && route.getWaypoint(0) != null && route.getWptMinAlt(0) != -1) {
//Perform only if first waypoint has a minimum altitude
val wpt = route.getWaypoint(0)
val dist = if (wpt != null) pixelToNm(distanceBetween(x, y, wpt.posX.toFloat(), wpt.posY.toFloat())) else 0f //Distance in nm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ class Emergency {
aircraft.navState.clearedSpd.clear()
aircraft.navState.clearedSpd.addFirst(aircraft.clearedIas)
aircraft.navState.length = 1
aircraft.route.routeData.clear()
aircraft.route.removedPoints.clear()
aircraft.navState.updateAircraftInfo()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,9 @@ class NavState {

/** Sets the direct aircraft navigation states */
fun updateAircraftInfo() {
if (aircraft is Arrival || aircraft is Departure && (aircraft as Departure).isSidSet) {
aircraft.clearedHeading = clearedHdg.first()
}
aircraft.clearedHeading = clearedHdg.first()
aircraft.direct = clearedDirect.first()
aircraft.sidStarIndex = aircraft.direct?.name?.let { aircraft.route.findWptIndex(it) } ?: 0
aircraft.direct?.name?.let { aircraft.sidStarIndex = aircraft.route.findWptIndex(it) }
aircraft.afterWaypoint = clearedAftWpt.first()
aircraft.afterWptHdg = clearedAftWptHdg.first()
aircraft.holdWpt = clearedHold.first()
Expand Down
18 changes: 17 additions & 1 deletion core/src/com/bombbird/terminalcontrol/ui/tabs/LatTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -574,19 +574,35 @@ class LatTab(ui: Ui) : Tab(ui) {
spdMode = NavState.NO_RESTR
}
if (it is Arrival) {
if (it.navState.containsCode(latMode, NavState.AFTER_WPT_HDG, NavState.HOLD_AT) && clearedILS != Ui.NOT_CLEARED_APCH) {
val newMode = if (it.navState.containsCode(latMode, NavState.SID_STAR)) NavState.SID_STAR else NavState.VECTORS
latMode = newMode
modeButtons.mode = newMode
afterWpt = null
holdWpt = null
it.navState.updateLatModes(NavState.REMOVE_AFTERHDG_HOLD, false)
}
if (latMode == NavState.SID_STAR && clearedILS != Ui.NOT_CLEARED_APCH) {
altMode = NavState.SID_STAR_RESTR
spdMode = NavState.SID_STAR_RESTR
ui.altTab.modeButtons.mode = NavState.SID_STAR_RESTR
ui.spdTab.modeButtons.mode = NavState.SID_STAR_RESTR
it.navState.updateAltModes(NavState.REMOVE_UNRESTR, false)
it.navState.updateSpdModes(NavState.REMOVE_UNRESTR, false)
var lowestAlt = if (it.route.apchTrans == "")
it.airport.approaches[clearedILS?.substring(3)]?.getNextPossibleTransition(radarScreen.waypoints[clearedWpt], it.route)?.first?.restrictions?.let { it2 -> if (it2.size > 0) it2[it2.size - 1][0] else null }
else it.route.getWptMinAlt(it.route.size - 1)
if (lowestAlt == -1) lowestAlt = radarScreen.minAlt
if (lowestAlt != null) clearedAlt = lowestAlt
} else if (clearedILS == Ui.NOT_CLEARED_APCH) {
if (it.navState.containsCode(latMode, NavState.SID_STAR, NavState.AFTER_WPT_HDG, NavState.HOLD_AT)) {
if (latMode == NavState.SID_STAR) {
it.navState.updateLatModes(NavState.ADD_ALL_SIDSTAR, false)
it.navState.updateAltModes(NavState.ADD_SIDSTAR_RESTR_UNRESTR, false)
it.navState.updateSpdModes(NavState.ADD_SIDSTAR_RESTR_UNRESTR, false)
} else {
it.navState.updateLatModes(NavState.ADD_ALL_SIDSTAR, false)
it.navState.updateAltModes(NavState.ADD_UNRESTR_ONLY, false)
it.navState.updateSpdModes(NavState.ADD_UNRESTR_ONLY, false)
}
}
}
Expand Down

0 comments on commit 8eb98e6

Please sign in to comment.