Overmind icon indicating copy to clipboard operation
Overmind copied to clipboard

Fix vacatePos & Fix autoRun()

Open dev-bittlinger opened this issue 5 years ago • 2 comments

Bugfixes

Description:

There was a logic error in the AnyZerg move() method, causing the issue in Movement.vacatePos(). The method vacatePos() sets creep.blockMovement to true, but is meant to override it with force: true. The check in AnyZerg said "!this.blockMovement && !force" Therefore this method was not working, and the creep not moving. Swapped it to "!this.blockMovement || force".

Also fixed an issue where Zergs of a role would stop working if one of their kind was spawning, there was a return instead of an continue, aborting any Zerg actions after it.

Fixed:

  • Movement.vacatePos() (to clear spawn area) (fixes #50)
  • Zergs of a role would stop working if one of their kind was spawning

Testing checklist:

  • [X] Changes are backward-compatible OR version migration code is included
  • [x] Codebase compiles with current tsconfig configuration
  • [X] Tested changes on PUBLIC server OR changes are trivial (e.g. typos)

dev-bittlinger avatar Oct 12 '20 12:10 dev-bittlinger

according to export interface MoveOptions { force?: boolean; // whether to ignore Zerg.blockMovement

so it is used to override blockMovement i.e if blockMomement is true, and you want to ignore it, then use force = true.

this is used correctly in goTo: static goTo(creep: AnyZerg, destination: HasPos | RoomPosition, opts: MoveOptions = {}): number { if (creep.blockMovement && !opts.force) { return ERR_BUSY; }

here, the default force is false, meaning, just accept blockMomement, but if blockMomevement is true and we want to ignore it, and move on, then we have to set force to true.

to use the same logic for .move(), then it should be move(direction: DirectionConstant, force = false) { if (creep.blockMovement && !force) { return ERR_BUSY; }

what do u think?

zGeneral avatar Oct 14 '20 13:10 zGeneral

I mean, that's just another way of doing the same thing. We can check for the error first, of course.

Because:

if (!creep.blockMovement || force) {
    // do it
} else {
    return ERR_BUSY
}

is the same as:

if (creep.blockMovement && !opts.force) {
    return ERR_BUSY
}
// do it

dev-bittlinger avatar Oct 14 '20 17:10 dev-bittlinger