screeps / engine

ISC License
133 stars 66 forks source link

creep.moveTo calculates new Path when creep fatigued and reusePath and visualizePathStyle is used #130

Open Xtrapat opened 4 years ago

Xtrapat commented 4 years ago

I don't know if this is intended or not, but if a creep uses moveTo over multiple Ticks while using the Options reusePath and visualizePathStyle, then every Tick the creep is fatigued when calling moveTo, a new Path is generated instead of using the one already saved in memory.

Example call over multiple Ticks: creep.moveTo(target, {reusePath: 50, visualizePathStyle: {})

I think the issue lies here: https://github.com/screeps/engine/blob/92a3fffee65d547f12f5a99940c6155d9482a254/src/game/creeps.js#L173-L175 This gets skipped when visualizePathStyle is in use, regardless of the .fatigue value. Then when getting to this Point, at the end of the reusePath Block: https://github.com/screeps/engine/blob/92a3fffee65d547f12f5a99940c6155d9482a254/src/game/creeps.js#L271-L283 var result = this.moveByPath(path); results, down the line in creep.move(), with C.ERR_TIRED, but creep.moveTo only returns on OK, thus continuing further down and generating a new Path at this.pos.findPathTo(targetPos, opts);

jorbascrumps commented 3 years ago

I've been debugging this behaviour for the last few hours before I came across this issue. Can we get confirmation on whether or not this is intended? I can't imagine why it would be.