diff --git a/src/js/changelog.js b/src/js/changelog.js index fe398aae..e915e831 100644 --- a/src/js/changelog.js +++ b/src/js/changelog.js @@ -8,6 +8,7 @@ export const CHANGELOG = [ "Added confirmation when deleting more than 500 buildings at a time", "Added background to toolbar to increase contrast", "Allow placing extractors anywhere again, but they don't work at all if not placed on a resource", + "Fix cycling through keybindings selecting locked buildings as well", ], }, { diff --git a/src/js/game/game_system_with_filter.js b/src/js/game/game_system_with_filter.js index 24a719fb..d1fddc7f 100644 --- a/src/js/game/game_system_with_filter.js +++ b/src/js/game/game_system_with_filter.js @@ -160,6 +160,14 @@ export class GameSystemWithFilter extends GameSystem { refreshCaches() { this.allEntities.sort((a, b) => a.uid - b.uid); + + // Remove all entities which are queued for destroy + for (let i = 0; i < this.allEntities.length; ++i) { + const entity = this.allEntities[i]; + if (entity.queuedForDestroy || entity.destroyed) { + this.allEntities.splice(i, 1); + } + } } /** @@ -187,6 +195,10 @@ export class GameSystemWithFilter extends GameSystem { * @param {Entity} entity */ internalPopEntityIfMatching(entity) { + if (this.root.bulkOperationRunning) { + // We do this in refreshCaches afterwards + return; + } const index = this.allEntities.indexOf(entity); if (index >= 0) { arrayDelete(this.allEntities, index);