From 0e78b7559bed42ea2c9a894af19eaecb74bce4ee Mon Sep 17 00:00:00 2001 From: PeekabooSteam Date: Wed, 6 Dec 2023 15:27:05 +0000 Subject: [PATCH] Robots are no longer considered for waypoints --- client/src/map/map.ts | 4 ++-- client/src/unit/unitsmanager.ts | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/client/src/map/map.ts b/client/src/map/map.ts index f6694b71..fac9be3f 100644 --- a/client/src/map/map.ts +++ b/client/src/map/map.ts @@ -791,7 +791,7 @@ export class Map extends L.Map { #showDestinationCursors() { const singleCursor = !this.#shiftKey; - const selectedUnitsCount = getApp().getUnitsManager().getSelectedUnits({ excludeHumans: true, onlyOnePerGroup: true }).length; + const selectedUnitsCount = getApp().getUnitsManager().getSelectedUnits({ excludeHumans: true, excludeProtected: true, onlyOnePerGroup: true }).length; if (singleCursor) { this.#hideDestinationCursors(); } @@ -817,7 +817,7 @@ export class Map extends L.Map { } #updateDestinationCursors() { - const selectedUnitsCount = getApp().getUnitsManager().getSelectedUnits({ excludeHumans: true, onlyOnePerGroup: true }).length; + const selectedUnitsCount = getApp().getUnitsManager().getSelectedUnits({ excludeHumans: true, excludeProtected: true, onlyOnePerGroup: true }).length; if (selectedUnitsCount > 1) { const groupLatLng = this.#computeDestinationRotation && this.#destinationRotationCenter != null ? this.#destinationRotationCenter : this.getMouseCoordinates(); if (this.#destinationPreviewCursors.length == 1) diff --git a/client/src/unit/unitsmanager.ts b/client/src/unit/unitsmanager.ts index 31c5059a..2f65986f 100644 --- a/client/src/unit/unitsmanager.ts +++ b/client/src/unit/unitsmanager.ts @@ -138,6 +138,10 @@ export class UnitsManager { return; const messageText = (numOfProtectedUnits === 1) ? `Unit is protected` : `All selected units are protected`; (getApp().getPopupsManager().get("infoPopup") as Popup).setText(messageText); + // Cheap way for now until we use more locks + let lock = document.querySelector("#unit-visibility-control button.lock"); + lock.classList.add("prompt"); + setTimeout(() => lock.classList.remove("prompt"), 4000); } /** Update the data of all the units. The data is directly decoded from the binary buffer received from the REST Server. This is necessary for performance and bandwidth reasons. @@ -301,13 +305,8 @@ export class UnitsManager { } } if (options) { - if (options.showProtectionReminder === true && numProtectedUnits > selectedUnits.length && selectedUnits.length === 0) { + if (options.showProtectionReminder === true && numProtectedUnits > selectedUnits.length && selectedUnits.length === 0) this.showProtectedUnitsPopup(numProtectedUnits); - // Cheap way for now until we use more locks - let lock = document.querySelector("#unit-visibility-control button.lock"); - lock.classList.add("prompt"); - setTimeout(() => lock.classList.remove("prompt"), 4000); - } if (options.onlyOnePerGroup) { var temp: Unit[] = []; @@ -1148,6 +1147,14 @@ export class UnitsManager { if (units === null) units = this.getSelectedUnits({ excludeHumans: true, excludeProtected: true, onlyOnePerGroup: true }); + const segregatedUnits = this.segregateUnits(units); + if (segregatedUnits.controllable.length === 0) { + this.showProtectedUnitsPopup(segregatedUnits.dcsProtected.length); + return {}; + } + + units = segregatedUnits.controllable; + if (units.length === 0) return {};