From 380307e386f52900049a4d4964e6877febd89486 Mon Sep 17 00:00:00 2001 From: Ryan Barlow <7389646+ryanbarlow97@users.noreply.github.com> Date: Fri, 31 Oct 2025 18:32:30 +0000 Subject: [PATCH] SAM Sites bugfix: due to ownership changes (#2342) ## Description: There was a small bug when ownership was updated (annexed territory) and it wasn't redrawing the radiuses. Complements #2307 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: w.o.n --- src/client/graphics/layers/SAMRadiusLayer.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/client/graphics/layers/SAMRadiusLayer.ts b/src/client/graphics/layers/SAMRadiusLayer.ts index 12aec63ce..db1af04b1 100644 --- a/src/client/graphics/layers/SAMRadiusLayer.ts +++ b/src/client/graphics/layers/SAMRadiusLayer.ts @@ -13,7 +13,7 @@ import { Layer } from "./Layer"; export class SAMRadiusLayer implements Layer { private readonly canvas: HTMLCanvasElement; private readonly context: CanvasRenderingContext2D; - private readonly samLaunchers: Set = new Set(); // Track SAM launcher IDs + private readonly samLaunchers: Map = new Map(); // Track SAM launcher IDs -> ownerSmallID private needsRedraw = true; // track whether the stroke should be shown due to hover or due to an active build ghost private hoveredShow: boolean = false; @@ -78,6 +78,7 @@ export class SAMRadiusLayer implements Layer { if (unit && unit.type() === UnitType.SAMLauncher) { const wasTracked = this.samLaunchers.has(update.id); const shouldTrack = unit.isActive(); + const owner = unit.owner().smallID(); if (wasTracked && !shouldTrack) { // SAM was destroyed @@ -85,8 +86,15 @@ export class SAMRadiusLayer implements Layer { hasChanges = true; } else if (!wasTracked && shouldTrack) { // New SAM was built - this.samLaunchers.add(update.id); + this.samLaunchers.set(update.id, owner); hasChanges = true; + } else if (wasTracked && shouldTrack) { + // SAM still exists; check if owner changed + const prevOwner = this.samLaunchers.get(update.id); + if (prevOwner !== owner) { + this.samLaunchers.set(update.id, owner); + hasChanges = true; + } } } } @@ -131,7 +139,9 @@ export class SAMRadiusLayer implements Layer { // Update our tracking set this.samLaunchers.clear(); - samLaunchers.forEach((sam) => this.samLaunchers.add(sam.id())); + samLaunchers.forEach((sam) => + this.samLaunchers.set(sam.id(), sam.owner().smallID()), + ); // Draw union of SAM radiuses. Collect circle data then draw union outer arcs only const circles = samLaunchers.map((sam) => {