Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vacatePos & Fix autoRun() #183

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Fix vacatePos & Fix autoRun() #183

wants to merge 1 commit into from

Conversation

dev-bittlinger
Copy link

@dev-bittlinger dev-bittlinger commented Oct 12, 2020

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:

Testing checklist:

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

…ead of continue)

- causing a role to stop working in a colony if one creep of it's sort is spawning
@zGeneral
Copy link
Contributor

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?

@dev-bittlinger
Copy link
Author

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

zGeneral pushed a commit to zGeneral/Overmind that referenced this pull request Jan 4, 2021
zGeneral pushed a commit to zGeneral/Overmind that referenced this pull request Jan 4, 2021
@tiennou tiennou mentioned this pull request Feb 2, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants