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:
@@ -23,8 +23,8 @@ public:
|
|||||||
void deleteUnit(unsigned int ID, bool explosion, string explosionType, bool immediate);
|
void deleteUnit(unsigned int ID, bool explosion, string explosionType, bool immediate);
|
||||||
void acquireControl(unsigned int ID);
|
void acquireControl(unsigned int ID);
|
||||||
void loadDatabases();
|
void loadDatabases();
|
||||||
Unit* getClosestUnit(Unit* unit, unsigned char coalition, vector<string> categories, double &distance);
|
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);
|
map<Unit*, double> getUnitsInRange(Unit* unit, unsigned char coalition, vector<string> categories, double range, bool airborneOnly = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
map<unsigned int, Unit*> units;
|
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;
|
Unit* closestUnit = nullptr;
|
||||||
distance = 0;
|
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 */
|
/* 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()) {
|
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 */
|
/* Compute the distance from the unit to the tested unit */
|
||||||
double dist;
|
double dist;
|
||||||
double bearing1;
|
double bearing1;
|
||||||
@@ -194,10 +197,13 @@ Unit* UnitsManager::getClosestUnit(Unit* unit, unsigned char coalition, vector<s
|
|||||||
return closestUnit;
|
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;
|
map<Unit*, double> unitsInRange;
|
||||||
|
|
||||||
for (auto const& p : units) {
|
for (auto const& p : units) {
|
||||||
|
if (airborneOnly && !p.second->getAirborne())
|
||||||
|
continue;
|
||||||
|
|
||||||
/* Check if the units category is of the correct type */
|
/* Check if the units category is of the correct type */
|
||||||
bool requestedCategory = false;
|
bool requestedCategory = false;
|
||||||
for (auto const& category : categories) {
|
for (auto const& category : categories) {
|
||||||
|
|||||||
@@ -1970,7 +1970,7 @@ export abstract class Unit extends CustomMarker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#drawRacetrack() {
|
#drawRacetrack() {
|
||||||
if (getApp().getMap().getOptions().showRacetracks) {
|
if (getApp().getMap().getOptions().showRacetracks && this.getAirborne()) {
|
||||||
let groundspeed = this.#speed;
|
let groundspeed = this.#speed;
|
||||||
|
|
||||||
// Determine racetrack length
|
// Determine racetrack length
|
||||||
|
|||||||
Reference in New Issue
Block a user