Skip to content

Commit 008e32b

Browse files
committed
fix some funny bugs
Signed-off-by: Octol1ttle <[email protected]>
1 parent 00ec157 commit 008e32b

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/main/kotlin/ru/octol1ttle/flightassistant/impl/alert/gpws/BelowGlideSlopeWarningAlert.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class BelowGlideSlopeWarningAlert(computers: ComputerBus) : Alert(computers), Ce
2626
return false
2727
}
2828

29-
val altitudeAboveGround = computers.data.altitude - (computers.gpws.groundY ?: return false)
29+
val altitudeAboveGround = computers.data.altitude - computers.gpws.groundOrVoidY
3030
val glideSlopeDeviation = computers.plan.getCurrentGlideSlopeTarget()!! - computers.data.altitude
3131
return altitudeAboveGround < glideSlopeDeviation
3232
}

src/main/kotlin/ru/octol1ttle/flightassistant/impl/alert/gpws/TooLowTerrainAlert.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TooLowTerrainAlert(computers: ComputerBus) : Alert(computers), CenteredAle
3030
maxRadarAltitude = 0.0
3131
return false
3232
}
33-
val altitudeAboveGround = computers.data.altitude - (computers.gpws.groundY ?: return false)
33+
val altitudeAboveGround = computers.data.altitude - computers.gpws.groundOrVoidY
3434
maxRadarAltitude = max(maxRadarAltitude, altitudeAboveGround)
3535
if (maxRadarAltitude < 15.0) {
3636
return false

src/main/kotlin/ru/octol1ttle/flightassistant/impl/computer/safety/GroundProximityComputer.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,19 @@ class GroundProximityComputer(computers: ComputerBus) : Computer(computers), Fli
9696
}
9797

9898
private fun computeGroundY(): Double? {
99+
if (!computers.chunk.isCurrentLoaded) {
100+
return groundY
101+
}
99102
val playerBoundingBox = computers.data.player.boundingBox
100103
val minY: Double = computers.data.level.bottomY.toDouble().coerceAtLeast(computers.data.altitude - 2500.0)
101104
val diffFromMinY = Vec3(0.0, minY - playerBoundingBox.minY, 0.0)
102105
val collisionResult = Entity.collideBoundingBox(computers.data.player, diffFromMinY, playerBoundingBox, computers.data.level, emptyList())
103-
if (collisionResult == diffFromMinY) {
104-
return null
106+
107+
val groundY = collisionResult.y + playerBoundingBox.minY
108+
if (collisionResult.y + playerBoundingBox.maxY == minY || collisionResult == diffFromMinY) {
109+
return if (groundY > computers.data.level.bottomY) Double.MAX_VALUE else null
105110
}
106-
return collisionResult.y + playerBoundingBox.minY
111+
return groundY
107112
}
108113

109114
private fun computeGroundImpactTime(data: AirDataComputer): Double {

0 commit comments

Comments
 (0)