pos.findClosestByPath(flags) returns not a flag
-
Just received notification from this code:
var flags:<Flag[]> = ...; var flag = <Flag>creep.pos.findClosestByPath(flags); if (flag && !(flag instanceof Flag)) Game.notify("among flags " + flags + " the closest is " + flag, 1); }
notification:
among flags [flag mine-1] the closest is [source #55db326cefa8e3fe66e051a0]
Here flag mine-1 is positioned on the source #55db326cefa8e3fe66e051a0.
Usually this code works well and does not send me notifications. But sometimes sends.
-
Still observe this error:
findClosestByPath somethimes returns object with wrong type.findClosestByPath(FIND_EXIT_RIGHT)
may return extension or flag for example.
-
reproduce in console:
Game.rooms['W12S23'].getPositionAt(49, 42).findClosestByPath(3)
[9:03:09] [room W12S23 pos 49,42]
Game.rooms['W12S23'].getPositionAt(49, 42).findClosestByPath(3)
[9:03:10] [structure (extension) #5612f7dcb3c550e1219a1da9]
-
And doublet queries behave that way:
Game.rooms['W12S23'].getPositionAt(49, 42).findClosestByPath(3) Game.rooms['W12S23'].getPositionAt(49, 42).findClosestByPath(3) [room W12S23 pos 49,42] [room W12S23 pos 49,42] Game.rooms['W12S23'].getPositionAt(49, 42).findClosestByPath(3) Game.rooms['W12S23'].getPositionAt(49, 42).findClosestByPath(3) [structure (extension) #5610f4e97232cb0022417b4c] [structure (extension) #5610f4e97232cb0022417b4c] Game.rooms['W12S23'].getPositionAt(49, 42).findClosestByPath(3) Game.rooms['W12S23'].getPositionAt(49, 42).findClosestByPath(3) [room W12S23 pos 49,42] [room W12S23 pos 49,42]