From 74310a5ad3a322ad7b528b4a0d5ba82dd60fbea0 Mon Sep 17 00:00:00 2001 From: Pax1601 Date: Mon, 27 Nov 2023 21:26:48 +0100 Subject: [PATCH 1/2] Fixed installation prompt about passwords --- installer/olympus.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/olympus.iss b/installer/olympus.iss index bf8a38a9..8f28f7d1 100644 --- a/installer/olympus.iss +++ b/installer/olympus.iss @@ -409,7 +409,7 @@ begin Width := ScaleX(340); Height := ScaleY(13); WordWrap := True; - Caption := 'Passwords can be changed in the future by editing the file "olympus.json". For more information, see the DCS Olympus Wiki'; + Caption := 'Passwords can be changed in the future by using the DCS Olympus configurator. For more information, see the DCS Olympus Wiki'; end; with Page do From e3dffb8245b945769402d71d1b7d3776c442bf4c Mon Sep 17 00:00:00 2001 From: Pax1601 Date: Tue, 28 Nov 2023 16:41:43 +0100 Subject: [PATCH 2/2] Fixed error in lead calculation code --- client/src/constants/constants.ts | 1 + client/src/interfaces.ts | 1 + client/src/unit/unit.ts | 6 +++++- scripts/OlympusCommand.lua | 12 +++++++++++- src/core/include/datatypes.h | 1 + src/core/include/unit.h | 3 +++ src/core/src/groundunit.cpp | 2 +- src/core/src/unit.cpp | 4 ++++ 8 files changed, 27 insertions(+), 3 deletions(-) diff --git a/client/src/constants/constants.ts b/client/src/constants/constants.ts index d1f96605..b2dec3ce 100644 --- a/client/src/constants/constants.ts +++ b/client/src/constants/constants.ts @@ -243,6 +243,7 @@ export enum DataIndexes { horizontalVelocity, verticalVelocity, heading, + track, isActiveTanker, isActiveAWACS, onOff, diff --git a/client/src/interfaces.ts b/client/src/interfaces.ts index c12e5c5f..16f3ec57 100644 --- a/client/src/interfaces.ts +++ b/client/src/interfaces.ts @@ -156,6 +156,7 @@ export interface UnitData { horizontalVelocity: number; verticalVelocity: number; heading: number; + track: number; isActiveTanker: boolean; isActiveAWACS: boolean; onOff: boolean; diff --git a/client/src/unit/unit.ts b/client/src/unit/unit.ts index 65c49207..11238d66 100644 --- a/client/src/unit/unit.ts +++ b/client/src/unit/unit.ts @@ -45,6 +45,7 @@ export abstract class Unit extends CustomMarker { #horizontalVelocity: number = 0; #verticalVelocity: number = 0; #heading: number = 0; + #track: number = 0; #isActiveTanker: boolean = false; #isActiveAWACS: boolean = false; #onOff: boolean = true; @@ -127,6 +128,7 @@ export abstract class Unit extends CustomMarker { getHorizontalVelocity() { return this.#horizontalVelocity }; getVerticalVelocity() { return this.#verticalVelocity }; getHeading() { return this.#heading }; + getTrack() { return this.#track }; getIsActiveAWACS() { return this.#isActiveAWACS }; getIsActiveTanker() { return this.#isActiveTanker }; getOnOff() { return this.#onOff }; @@ -278,6 +280,7 @@ export abstract class Unit extends CustomMarker { case DataIndexes.horizontalVelocity: this.#horizontalVelocity = dataExtractor.extractFloat64(); break; case DataIndexes.verticalVelocity: this.#verticalVelocity = dataExtractor.extractFloat64(); break; case DataIndexes.heading: this.#heading = dataExtractor.extractFloat64(); updateMarker = true; break; + case DataIndexes.track: this.#track = dataExtractor.extractFloat64(); updateMarker = true; break; case DataIndexes.isActiveTanker: this.#isActiveTanker = dataExtractor.extractBool(); break; case DataIndexes.isActiveAWACS: this.#isActiveAWACS = dataExtractor.extractBool(); break; case DataIndexes.onOff: this.#onOff = dataExtractor.extractBool(); break; @@ -355,6 +358,7 @@ export abstract class Unit extends CustomMarker { horizontalVelocity: this.#horizontalVelocity, verticalVelocity: this.#verticalVelocity, heading: this.#heading, + track: this.#track, isActiveTanker: this.#isActiveTanker, isActiveAWACS: this.#isActiveAWACS, onOff: this.#onOff, @@ -1167,7 +1171,7 @@ export abstract class Unit extends CustomMarker { /* Rotate elements according to heading */ element.querySelectorAll("[data-rotate-to-heading]").forEach(el => { - const headingDeg = rad2deg(this.#heading); + const headingDeg = rad2deg(this.#track); let currentStyle = el.getAttribute("style") || ""; el.setAttribute("style", currentStyle + `transform:rotate(${headingDeg}deg);`); }); diff --git a/scripts/OlympusCommand.lua b/scripts/OlympusCommand.lua index 9c07f5ee..3f186e90 100644 --- a/scripts/OlympusCommand.lua +++ b/scripts/OlympusCommand.lua @@ -992,7 +992,7 @@ function Olympus.setUnitsData(arg, time) local position = unit:getPosition() local heading = math.atan2( position.x.z, position.x.x ) local velocity = unit:getVelocity(); - + -- Fill the data table table["name"] = unit:getTypeName() table["coalitionID"] = unit:getCoalition() @@ -1004,6 +1004,16 @@ function Olympus.setUnitsData(arg, time) table["horizontalVelocity"] = math.sqrt(velocity.x * velocity.x + velocity.z * velocity.z) table["verticalVelocity"] = velocity.y table["heading"] = heading + + -- Track angles are wrong because of weird reference systems, approximate it using latitude and longitude differences + if Olympus.unitsData["units"][ID] ~= nil and Olympus.unitsData["units"][ID]["position"] ~= nil and Olympus.unitsData["units"][ID]["position"]["lat"] ~= nil and Olympus.unitsData["units"][ID]["position"]["lng"] ~= nil then + local latDifference = lat - Olympus.unitsData["units"][ID]["position"]["lat"] + local lngDifference = lng - Olympus.unitsData["units"][ID]["position"]["lng"] + table["track"] = math.atan2(lngDifference * math.cos(lat / 57.29577), latDifference) + else + table["track"] = math.atan2(velocity.z, velocity.x) + end + table["isAlive"] = unit:isExist() and unit:isActive() and unit:getLife() >= 1 local group = unit:getGroup() diff --git a/src/core/include/datatypes.h b/src/core/include/datatypes.h index 8928ab20..6dd44e85 100644 --- a/src/core/include/datatypes.h +++ b/src/core/include/datatypes.h @@ -22,6 +22,7 @@ namespace DataIndex { horizontalVelocity, verticalVelocity, heading, + track, isActiveTanker, isActiveAWACS, onOff, diff --git a/src/core/include/unit.h b/src/core/include/unit.h index a4ee4744..d60f6c36 100644 --- a/src/core/include/unit.h +++ b/src/core/include/unit.h @@ -80,6 +80,7 @@ public: virtual void setHorizontalVelocity(double newValue) { updateValue(horizontalVelocity, newValue, DataIndex::horizontalVelocity); } virtual void setVerticalVelocity(double newValue) { updateValue(verticalVelocity, newValue, DataIndex::verticalVelocity); } virtual void setHeading(double newValue) { updateValue(heading, newValue, DataIndex::heading); } + virtual void setTrack(double newValue) { updateValue(track, newValue, DataIndex::track); } virtual void setIsActiveTanker(bool newValue); virtual void setIsActiveAWACS(bool newValue); virtual void setOnOff(bool newValue, bool force = false) { updateValue(onOff, newValue, DataIndex::onOff); }; @@ -126,6 +127,7 @@ public: virtual double getHorizontalVelocity() { return horizontalVelocity; } virtual double getVerticalVelocity() { return verticalVelocity; } virtual double getHeading() { return heading; } + virtual double getTrack() { return track; } virtual bool getIsActiveTanker() { return isActiveTanker; } virtual bool getIsActiveAWACS() { return isActiveAWACS; } virtual bool getOnOff() { return onOff; }; @@ -174,6 +176,7 @@ protected: double horizontalVelocity = NULL; double verticalVelocity = NULL; double heading = NULL; + double track = NULL; bool isActiveTanker = false; bool isActiveAWACS = false; bool onOff = true; diff --git a/src/core/src/groundunit.cpp b/src/core/src/groundunit.cpp index e66a8622..f6449d0e 100644 --- a/src/core/src/groundunit.cpp +++ b/src/core/src/groundunit.cpp @@ -371,7 +371,7 @@ void GroundUnit::AIloop() double aimDistance = target->getHorizontalVelocity() * aimTime + scatterDistance; double aimLat = 0; double aimLng = 0; - Geodesic::WGS84().Direct(target->getPosition().lat, target->getPosition().lng, target->getHeading() * 57.29577, aimDistance, aimLat, aimLng); /* TODO make util to convert degrees and radians function */ + Geodesic::WGS84().Direct(target->getPosition().lat, target->getPosition().lng, target->getTrack() * 57.29577, aimDistance, aimLat, aimLng); /* TODO make util to convert degrees and radians function */ double aimAlt = target->getPosition().alt + target->getVerticalVelocity() * aimTime + distance * tan(shotsBaseScatter * (ShotsScatter::LOW - shotsScatter) / 57.29577) * RANDOM_ZERO_TO_ONE; // Force to always miss high never low /* Send the command */ diff --git a/src/core/src/unit.cpp b/src/core/src/unit.cpp index 8331b665..11e3a4f1 100644 --- a/src/core/src/unit.cpp +++ b/src/core/src/unit.cpp @@ -66,6 +66,9 @@ void Unit::update(json::value json, double dt) if (json.has_number_field(L"heading")) setHeading(json[L"heading"].as_number().to_double()); + if (json.has_number_field(L"track")) + setTrack(json[L"track"].as_number().to_double()); + if (json.has_number_field(L"speed")) setSpeed(json[L"speed"].as_number().to_double()); @@ -261,6 +264,7 @@ void Unit::getData(stringstream& ss, unsigned long long time) case DataIndex::horizontalVelocity: appendNumeric(ss, datumIndex, horizontalVelocity); break; case DataIndex::verticalVelocity: appendNumeric(ss, datumIndex, verticalVelocity); break; case DataIndex::heading: appendNumeric(ss, datumIndex, heading); break; + case DataIndex::track: appendNumeric(ss, datumIndex, track); break; case DataIndex::isActiveTanker: appendNumeric(ss, datumIndex, isActiveTanker); break; case DataIndex::isActiveAWACS: appendNumeric(ss, datumIndex, isActiveAWACS); break; case DataIndex::onOff: appendNumeric(ss, datumIndex, onOff); break;