fix: Fixed multiple errors in scenic AAA modes

This commit is contained in:
Davide Passoni
2025-03-14 16:45:46 +01:00
parent 5acc0e8ac5
commit f0826bbdba
17 changed files with 437 additions and 160 deletions

View File

@@ -507,11 +507,6 @@ export class Map extends L.Map {
altKey: false,
ctrlKey: false,
});
/* Periodically check if the camera control endpoint is available */
this.#cameraControlTimer = window.setInterval(() => {
this.#checkCameraPort();
}, 1000);
}
setLayerName(layerName: string) {
@@ -1298,33 +1293,6 @@ export class Map extends L.Map {
return minimapBoundaries;
}
#setSlaveDCSCameraAvailable(newSlaveDCSCameraAvailable: boolean) {
this.#slaveDCSCameraAvailable = newSlaveDCSCameraAvailable;
}
/* Check if the camera control plugin is available. Right now this will only change the color of the button, no changes in functionality */
#checkCameraPort() {
if (this.#cameraOptionsXmlHttp?.readyState !== 4) this.#cameraOptionsXmlHttp?.abort();
this.#cameraOptionsXmlHttp = new XMLHttpRequest();
/* Using 127.0.0.1 instead of localhost because the LuaSocket version used in DCS only listens to IPv4. This avoids the lag caused by the
browser if it first tries to send the request on the IPv6 address for localhost */
this.#cameraOptionsXmlHttp.open("OPTIONS", `http://127.0.0.1:${this.#cameraControlPort}`);
this.#cameraOptionsXmlHttp.onload = (res: any) => {
if (this.#cameraOptionsXmlHttp !== null && this.#cameraOptionsXmlHttp.status == 204) this.#setSlaveDCSCameraAvailable(true);
else this.#setSlaveDCSCameraAvailable(false);
};
this.#cameraOptionsXmlHttp.onerror = (res: any) => {
this.#setSlaveDCSCameraAvailable(false);
};
this.#cameraOptionsXmlHttp.ontimeout = (res: any) => {
this.#setSlaveDCSCameraAvailable(false);
};
this.#cameraOptionsXmlHttp.timeout = 500;
this.#cameraOptionsXmlHttp.send("");
}
#drawIPToTargetLine() {
if (this.#targetPoint && this.#IPPoint) {
if (!this.#IPToTargetLine) {

View File

@@ -188,6 +188,8 @@ export abstract class Unit extends CustomMarker {
#targetingRange: number = 0;
#aimMethodRange: number = 0;
#acquisitionRange: number = 0;
#totalAmmo: number = 0;
#previousTotalAmmo: number = 0;
/* Inputs timers */
#debounceTimeout: number | null = null;
@@ -654,6 +656,8 @@ export abstract class Unit extends CustomMarker {
break;
case DataIndexes.ammo:
this.#ammo = dataExtractor.extractAmmo();
this.#previousTotalAmmo = this.#totalAmmo;
this.#totalAmmo = this.#ammo.reduce((prev: number, ammo: Ammo) => prev + ammo.quantity, 0);
break;
case DataIndexes.contacts:
this.#contacts = dataExtractor.extractContacts();

View File

@@ -43,6 +43,7 @@ export abstract class Weapon extends CustomMarker {
static getConstructor(type: string) {
if (type === "Missile") return Missile;
if (type === "Bomb") return Bomb;
if (type === "Shell") return Shell;
}
constructor(ID: number) {
@@ -330,3 +331,40 @@ export class Bomb extends Weapon {
};
}
}
export class Shell extends Weapon {
constructor(ID: number) {
super(ID);
}
getCategory() {
return "Shell";
}
getMarkerCategory() {
if (this.belongsToCommandedCoalition() || this.getDetectionMethods().includes(VISUAL) || this.getDetectionMethods().includes(OPTIC)) return "shell";
else return "aircraft";
}
getIconOptions() {
return {
showState: false,
showVvi:
!this.belongsToCommandedCoalition() &&
!this.getDetectionMethods().some((value) => [VISUAL, OPTIC].includes(value)) &&
this.getDetectionMethods().some((value) => [RADAR, IRST, DLINK].includes(value)),
showHealth: false,
showHotgroup: false,
showUnitIcon: this.belongsToCommandedCoalition() || this.getDetectionMethods().some((value) => [VISUAL, OPTIC, RADAR, IRST, DLINK].includes(value)),
showShortLabel: false,
showFuel: false,
showAmmo: false,
showSummary:
!this.belongsToCommandedCoalition() &&
!this.getDetectionMethods().some((value) => [VISUAL, OPTIC].includes(value)) &&
this.getDetectionMethods().some((value) => [RADAR, IRST, DLINK].includes(value)),
showCallsign: false,
rotateToHeading: this.belongsToCommandedCoalition() || this.getDetectionMethods().includes(VISUAL) || this.getDetectionMethods().includes(OPTIC),
};
}
}

View File

@@ -38,7 +38,7 @@ export class WeaponsManager {
/** Add a new weapon to the manager
*
* @param ID ID of the new weapon
* @param category Either "Missile" or "Bomb". Determines what class will be used to create the new unit accordingly.
* @param category Either "Missile", "Bomb" or "Shell". Determines what class will be used to create the new unit accordingly.
*/
addWeapon(ID: number, category: string) {
if (category) {