diff --git a/src/core/execution/PlayerExecution.ts b/src/core/execution/PlayerExecution.ts index 4dcaaf40a..59a69386c 100644 --- a/src/core/execution/PlayerExecution.ts +++ b/src/core/execution/PlayerExecution.ts @@ -163,6 +163,15 @@ export class PlayerExecution implements Execution { } private removeCluster(cluster: Set) { + if ( + Array.from(cluster).some( + (t) => this.mg.ownerID(t) != this.player.smallID(), + ) + ) { + // Other removeCluster operations could change tile owners, + // so double check. + return; + } const result = new Set(); // Use Set to automatically deduplicate ownerIDs for (const t of cluster) { for (const neighbor of this.mg.neighbors(t)) { @@ -177,7 +186,7 @@ export class PlayerExecution implements Execution { } const firstTile = cluster.values().next().value; const filter = (_, t: TileRef): boolean => - this.mg.ownerID(t) == this.mg.ownerID(firstTile); + this.mg.ownerID(t) == this.player.smallID(); const tiles = this.mg.bfs(firstTile, filter); const modePlayer = this.mg.playerBySmallID(mode);