ScreepsQuorum/screeps-quorum

Caching _fillable leads to deviant behavior

Opened this issue · 0 comments

Caching fillable per room leads to cross-contamination of the filler/replenisher job pools. When it is called multiple times per tick, the _fillable attribute will be cached with the first set of stuctureTypes it is called with, leading to any subsequent calls to return that value, regardless of having a differing structureTypes parameter.

Room.prototype.getStructuresToFill = function (structureTypes) {
if (!this.__fillable) {
this.__fillable = this.find(FIND_MY_STRUCTURES, {
filter: function (structure) {
if (structureTypes.indexOf(structure.structureType) === -1) {
return false
}
if (!structure.energyCapacity) {
return false
}
return structure.energy < structure.energyCapacity
}
})
}
return this.__fillable