-
Notifications
You must be signed in to change notification settings - Fork 6
Fix get nearest airbase list error #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MacFlorent
wants to merge
3
commits into
master
Choose a base branch
from
fix-getNearestAirbaseList-error
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ng airbases (destroyed carriers and the like)
Reviewer's GuideUpdates airbase and weather modules to safely handle missing or non-existent DCS airbases when computing nearest airbases and generating ATIS, and bumps their version numbers. Sequence diagram for updated getNearestAirbaseList handling invalid airbasessequenceDiagram
participant Caller
participant veafAirbases
participant veafAirbase
participant DcsAirbase
participant dcsUnit
participant mist_utils as mist_utils
Caller->>veafAirbases: getNearestAirbaseList(dcsUnit, iCount)
activate veafAirbases
veafAirbases->>dcsUnit: getPoint()
dcsUnit-->>veafAirbases: vec3Unit
loop for each veafAirbase in Airbases
veafAirbases->>veafAirbase: access DcsAirbase
alt veafAirbase and DcsAirbase exist and DcsAirbase:isExist()
veafAirbases->>DcsAirbase: getPoint()
DcsAirbase-->>veafAirbases: vec3Airbase
veafAirbases->>mist_utils: get2DDist(vec3Unit, vec3Airbase)
mist_utils-->>veafAirbases: iDistance
veafAirbases->>veafAirbases: try fill first nil slot in nearestList
alt nearestList slot found
veafAirbases->>veafAirbases: insert {veafAirbase, iDistance}
else no nil slot
veafAirbases->>veafAirbases: compare with farthest entry
alt iDistance is shorter
veafAirbases->>veafAirbases: replace farthest entry
else
veafAirbases->>veafAirbases: ignore current airbase
end
end
alt airbase was added or replaced
veafAirbases->>veafAirbases: table.sort(nearestList, Sort)
end
else invalid or non existent DcsAirbase
veafAirbases->>veafAirbases: skip this veafAirbase
end
end
veafAirbases-->>Caller: nearestList
deactivate veafAirbases
Updated class diagram for veafAirbases and veafWeatherAtis error handlingclassDiagram
class veafAirbases {
+string Id
+string Version
+table Airbases
+getNearestAirbaseList(dcsUnit, iCount) nearestList
}
class VeafAirbase {
+string Name
+DcsAirbase DcsAirbase
}
class DcsAirbase {
+getPoint() vec3
+isExist() bool
}
class mist_utils {
+get2DDist(vec3Unit, vec3Airbase) number
}
class veafWeatherAtis {
+table ListInEffect
+Create(veafAirbase, dateTimeZulu) veafWeatherAtis
+getAtis(veafAirbase) veafWeatherAtis
+getAtisString(veafAirbase) string
}
class veafLogger {
+trace(message) void
}
veafAirbases "*" --> "*" VeafAirbase : manages
VeafAirbase --> DcsAirbase : wraps
veafAirbases --> mist_utils : uses
veafWeatherAtis --> VeafAirbase : uses
veafWeatherAtis --> veafLogger : logs
veafWeatherAtis --> DcsAirbase : checksExistence
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- In
veafWeatherAtis.getAtis/getAtisString, consider validatingveafAirbasebefore usingveafAirbase.Nameso a nil airbase (whichCreatenow explicitly supports) does not cause a runtime error when logging or building the fallback string. - In
veafAirbases.getNearestAirbaseList, you still sortnearestListon every successful insertion; if performance becomes an issue with many airbases, you could defer sorting until after the loop or use a more incremental approach to maintain the ordered list.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `veafWeatherAtis.getAtis`/`getAtisString`, consider validating `veafAirbase` before using `veafAirbase.Name` so a nil airbase (which `Create` now explicitly supports) does not cause a runtime error when logging or building the fallback string.
- In `veafAirbases.getNearestAirbaseList`, you still sort `nearestList` on every successful insertion; if performance becomes an issue with many airbases, you could defer sorting until after the loop or use a more incremental approach to maintain the ordered list.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix for issue #302
Summary by Sourcery
Fix nearest airbase lookup and ATIS generation when airbases are missing or no longer exist.
Bug Fixes:
Enhancements: