From de70321c4b3bb666c07af7b02bbb714f5db93b47 Mon Sep 17 00:00:00 2001 From: evan Date: Sat, 26 Apr 2025 09:35:47 -0700 Subject: [PATCH] bugfix: remove unit before updating tile in UnitImpl.move(). This is because if a unit moves too fast or on border, UnitGrid will not find the existing unit, causing duplicate units --- src/core/game/UnitImpl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/game/UnitImpl.ts b/src/core/game/UnitImpl.ts index 4ce55c37c..247e0eced 100644 --- a/src/core/game/UnitImpl.ts +++ b/src/core/game/UnitImpl.ts @@ -88,9 +88,9 @@ export class UnitImpl implements Unit { if (tile == null) { throw new Error("tile cannot be null"); } + this.mg.removeUnit(this); this._lastTile = this._tile; this._tile = tile; - this.mg.removeUnit(this); this.mg.addUnit(this); this.mg.addUpdate(this.toUpdate()); }