TypeError: room.drops[resourceType] is not iterable
xyzzy529 opened this issue · 1 comments
xyzzy529 commented
Issue summary
Installed fresh 0.5.2.1 and received below error
Description of issue:
The room was stuck not harvesting or upgrading.
https://screeps.com/a/#!/room/shard0/W12S22
I re-copied the 0.5.2.1 release and it gave error.
Steps to reproduce:
AFAIK, just copy/paste the 0.5.2.1 version into main and commit it in screeps/scripts. Then error appears.
The room was previously built out.
Error message:
[11:21:45 AM][shard0]drops: 0 [ruin (link) #626426ae1fdb0a4b034f6fae]
[11:21:45 AM][shard0]TypeError: room.drops[resourceType] is not iterable
at Overseer.registerLogisticsRequests (main:23745:44)
at Overseer.init (main:23952:18)
at _Overmind.init (main:24061:6199)
at main (main:24313:14)
at Object.wrap (main:969:16)
at Object.loop (main:24322:21)
at __mainLoop:1:52
at __mainLoop:2:3
at Object.exports.evalCode (<runtime>:15845:76)
registerLogisticsRequests(colony) {
// Register logistics requests for all dropped resources and tombstones
for (let room of colony.rooms) {
// Pick up all nontrivial dropped resources
for (let resourceType in room.drops) {
console.log("drops:", resourceType, room.drops[resourceType]); // <--- Added for Debug
for (let drop of room.drops[resourceType]) { // <--- throws error
if (drop.amount > LogisticsNetwork.settings.droppedEnergyThreshold
|| drop.resourceType != RESOURCE_ENERGY) {
colony.logisticsNetwork.requestOutput(drop);
}
}
}
}
Suggested fix (optional):
unknown
Other information:
‣ Version: Overmind v0.5.2
‣ Checksum: 0x2bf8f766f8e
‣ Assimilated: No (clearance code: null) [WIP]
‣ Operating mode: automatic
xyzzy529 commented
Here is what seems to work as a fix:
registerLogisticsRequests(colony) {
// Register logistics requests for all dropped resources and tombstones
for (let room of colony.rooms) {
// Pick up all nontrivial dropped resources
console.log("drops ALL:", JSON.stringify(room.drops,null,4) );
for (let dropIdx in room.drops) { // <--- Added new level of room.drops
for (let resourceType in room.drops[dropIdx]) {
try {
for (let drop of room.drops[dropIdx][resourceType]) {
if (drop.amount > LogisticsNetwork.settings.droppedEnergyThreshold
|| drop.resourceType != RESOURCE_ENERGY) {
colony.logisticsNetwork.requestOutput(drop);
console.log("process drop: ", JSON.stringify(drop.pos), drop.amount );
}
}
} catch (error) {
console.log("drops-error:", dropIdx, resourceType, error);
}
}
}
}
// Place a logistics request directive for every tombstone with non-empty store that isn't on a container