mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
fix: not airborne units no longer targeted, racetracks not drawn for airborne units
This commit is contained in:
parent
1248ffb60b
commit
2d0e10bc0b
@ -23,8 +23,8 @@ public:
|
||||
void deleteUnit(unsigned int ID, bool explosion, string explosionType, bool immediate);
|
||||
void acquireControl(unsigned int ID);
|
||||
void loadDatabases();
|
||||
Unit* getClosestUnit(Unit* unit, unsigned char coalition, vector<string> categories, double &distance);
|
||||
map<Unit*, double> getUnitsInRange(Unit* unit, unsigned char coalition, vector<string> categories, double range);
|
||||
Unit* getClosestUnit(Unit* unit, unsigned char coalition, vector<string> categories, double &distance, bool airborneOnly = true);
|
||||
map<Unit*, double> getUnitsInRange(Unit* unit, unsigned char coalition, vector<string> categories, double range, bool airborneOnly = true);
|
||||
|
||||
private:
|
||||
map<unsigned int, Unit*> units;
|
||||
|
||||
@ -151,7 +151,7 @@ void UnitsManager::deleteUnit(unsigned int ID, bool explosion, string explosionT
|
||||
}
|
||||
}
|
||||
|
||||
Unit* UnitsManager::getClosestUnit(Unit* unit, unsigned char coalition, vector<string> categories, double &distance) {
|
||||
Unit* UnitsManager::getClosestUnit(Unit* unit, unsigned char coalition, vector<string> categories, double &distance, bool airborneOnly) {
|
||||
Unit* closestUnit = nullptr;
|
||||
distance = 0;
|
||||
|
||||
@ -167,6 +167,9 @@ Unit* UnitsManager::getClosestUnit(Unit* unit, unsigned char coalition, vector<s
|
||||
|
||||
/* Check if the unit belongs to the desired coalition, is alive, and is of the category requested */
|
||||
if (requestedCategory && p.second->getCoalition() == coalition && p.second->getAlive()) {
|
||||
/* Check if the unit is airborne */
|
||||
if (airborneOnly && !p.second->getAirborne())
|
||||
continue;
|
||||
/* Compute the distance from the unit to the tested unit */
|
||||
double dist;
|
||||
double bearing1;
|
||||
@ -194,10 +197,13 @@ Unit* UnitsManager::getClosestUnit(Unit* unit, unsigned char coalition, vector<s
|
||||
return closestUnit;
|
||||
}
|
||||
|
||||
map<Unit*, double> UnitsManager::getUnitsInRange(Unit* unit, unsigned char coalition, vector<string> categories, double range) {
|
||||
map<Unit*, double> UnitsManager::getUnitsInRange(Unit* unit, unsigned char coalition, vector<string> categories, double range, bool airborneOnly) {
|
||||
map<Unit*, double> unitsInRange;
|
||||
|
||||
for (auto const& p : units) {
|
||||
if (airborneOnly && !p.second->getAirborne())
|
||||
continue;
|
||||
|
||||
/* Check if the units category is of the correct type */
|
||||
bool requestedCategory = false;
|
||||
for (auto const& category : categories) {
|
||||
|
||||
@ -1970,7 +1970,7 @@ export abstract class Unit extends CustomMarker {
|
||||
}
|
||||
|
||||
#drawRacetrack() {
|
||||
if (getApp().getMap().getOptions().showRacetracks) {
|
||||
if (getApp().getMap().getOptions().showRacetracks && this.getAirborne()) {
|
||||
let groundspeed = this.#speed;
|
||||
|
||||
// Determine racetrack length
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user