bencbartlett / Overmind

AI for Screeps, a multiplayer programming strategy game
MIT License
545 stars 155 forks source link

PowerMining Directive Exception #166

Closed OverlordQ closed 4 years ago

OverlordQ commented 4 years ago

Issue summary

Throwing exception when trying to clean up PowerMining Directives

Steps to reproduce:

  1. Spawn
  2. Wait for RCL8
  3. Wait for PM Directives to be expire

Error message:

[2:49:58 PM][shard2]TypeError: Cannot read property 'roomName' of undefined
    at DirectivePowerMine.get print [as print] (main:13792:71)
    at new Directive (main:13740:58)
    at new DirectivePowerMine (main:31722:9)
    at DirectiveWrapper (main:33219:28)
    at _Overmind.registerDirectives (main:35243:15559)
    at _Overmind.build (main:35243:11168)
    at Object.main [as loop] (main:36117:18)
    at __mainLoop:1:52
    at __mainLoop:2:3
// Offending line:
return '<a href="#!/room/' + Game.shard.name + '/' + this.pos.roomName + '">[' + this.name + ']</a>';

Suggested fix (optional):

Other information:

‣ Version:        Overmind v0.5.2
‣ Checksum:       0x0
‣ Assimilated:    No (clearance code: null) [WIP]
‣ Operating mode: automatic

Commit: c1cccf3

MatthewARoy commented 4 years ago

@OverlordQ Was this with an automatically created directive or a manually placed one? Did you delete the directive?

MatthewARoy commented 4 years ago

Also is this on master or dev branch?

OverlordQ commented 4 years ago

Automatic.

No.

Dev.

I threw a try/catch around log.alert(`Removing expired directive ${this.print}!`); in the Directive constructor and it seems to have moved on.

Of note, this was on the PTR, and might be related to the CPU sub's weekly reset, so things might have gone wonky when the max CPU was chopped to 20CPU.

So whatever cleanup was being done may have only half executed.

This is probably and edge case, but it may or may not crop up again if somebody bangs up against the CPU limit.