Skip to content

fix: do not calculate new path in creep.moveTo when creep is fatigued, visualizePathStyle is set, and valid memorized path exists#152

Open
Richard-Krug wants to merge 1 commit intoscreeps:masterfrom
Richard-Krug:fix/issue-130
Open

fix: do not calculate new path in creep.moveTo when creep is fatigued, visualizePathStyle is set, and valid memorized path exists#152
Richard-Krug wants to merge 1 commit intoscreeps:masterfrom
Richard-Krug:fix/issue-130

Conversation

@Richard-Krug
Copy link

This fixes issue #130

Problem:
Usually, creep.moveTo returns C.ERR_TIRED early when the creep is fatigued. However, when visualizePathStyle is set, this does not happen because the path still needs to be visualized. If a valid path is memorized, it is used for the visualization and then for moveByPath. If moveByPath succeeds (C.OK), creep.moveTo returns before a new path is calculated. If the creep is fatigued, however, moveByPath returns C.ERR_TIRED and a new path is calculated unnecessarily which wastes a lot of CPU.

Solution:
Add C.ERR_TIRED as a reason to return after moveByPath because the memorized path is valid and the creep is just fatigued in this case.

…, visualizePathStyle is set, and valid memorized path exists
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.

1 participant