Skip to content

Commit

Permalink
Bug fix for stack overflow, clear FamilyWithListener array
Browse files Browse the repository at this point in the history
  • Loading branch information
Bombbird2001 committed Aug 15, 2023
1 parent a4d21f3 commit 91a3997
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class FamilyWithListener private constructor(private val family: Family, private
for (i in 0 until allServerFamilies.size) {
allServerFamilies[i].removeEngineListener(engine)
}
allServerFamilies.clear()
FileLog.info("FamilyWithListener", "Cleared all server family entity listeners")
}

Expand All @@ -67,6 +68,7 @@ class FamilyWithListener private constructor(private val family: Family, private
for (i in 0 until allClientFamilies.size) {
allClientFamilies[i].removeEngineListener(engine)
}
allClientFamilies.clear()
FileLog.info("FamilyWithListener", "Cleared all client family entity listeners")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,17 @@ private fun amendAltForNearbyTraffic(currSpawnAlt: Float, posX: Float, posY: Flo
val minDistNm = 7f
val gs = GAME.gameServer ?: return currSpawnAlt
val entitiesToCheck = gs.engine.getSystem<TrafficSystemInterval>().getEntitiesWithinArrivalSpawnAltitude(currSpawnAlt, lowerRange, upperRange)
val svcCeil = arrival[AircraftInfo.mapper]?.aircraftPerf?.maxAlt ?: return currSpawnAlt
for (i in 0 until entitiesToCheck.size) {
val entity = entitiesToCheck[i]
if (entity == arrival) continue
val pos = entity[Position.mapper] ?: continue
val alt = entity[Altitude.mapper]?.altitudeFt ?: continue
if (calculateDistanceBetweenPoints(posX, posY, pos.x, pos.y) < nmToPx(minDistNm) &&
(currSpawnAlt - lowerRange < alt || currSpawnAlt + upperRange > alt)) {
return amendAltForNearbyTraffic(alt + upperRange, posX, posY, arrival)
val newAlt = alt + upperRange * 2
if (newAlt > svcCeil) return svcCeil.toFloat()
return amendAltForNearbyTraffic(newAlt, posX, posY, arrival)
}
}

Expand Down

0 comments on commit 91a3997

Please sign in to comment.