From 8158ca966a83a6b60f98207d2a456f87797e43b9 Mon Sep 17 00:00:00 2001 From: Noface <166717111+Jerryslang@users.noreply.github.com> Date: Mon, 2 Jun 2025 21:36:51 +0100 Subject: [PATCH] this is a fix for the "possibly null" error. dosent seem to cause runtime issues but does cause the compiler to throw an error (#1005) ## Description: this is a fix for the "possibly null" error. dosent seem to cause runtime issues but does cause the compiler to throw an error this just adds a safety check ## Please complete the following: - [x] I have added screenshots for all UI updates (No UI Updates) - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file (No Text Updates) - [x] I have added relevant tests to the test directory (No Tests to add) - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: jerryslang --- src/client/graphics/layers/TerritoryLayer.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client/graphics/layers/TerritoryLayer.ts b/src/client/graphics/layers/TerritoryLayer.ts index 550bab478..1c2dc1bf1 100644 --- a/src/client/graphics/layers/TerritoryLayer.ts +++ b/src/client/graphics/layers/TerritoryLayer.ts @@ -240,7 +240,13 @@ export class TerritoryLayer implements Layer { while (numToRender > 0) { numToRender--; - const tile = this.tileToRenderQueue.pop().tile; + + const entry = this.tileToRenderQueue.pop(); + if (!entry) { + break; + } + + const tile = entry.tile; this.paintTerritory(tile); for (const neighbor of this.game.neighbors(tile)) { this.paintTerritory(neighbor, true);