Construction site blocked by walkable object
-
I believe I've found an edge case that's been overlooked in one of the checks that return ERR_INVALID_TARGET for Creep.build.
Normally when you try to build a Spawn, Extension or Constructed Wall with a non-walkable object on the same tile, you will receive ERR_INVALID_TARGET.
However, this is not the case in the following situation:
- You have safe mode activated in the room you are trying to build in.
- A hostile creep is on the same tile as the construction site being built.
Since the hostile creep is walkable to the owner of the room in safe mode, I feel like it shouldn't be considered an obstacle capable of blocking the owner from building those three structures.
-
I recently made a PR to address this. http://screeps.com/forum/topic/293/-pull-request-Client-side-validation-of-Creep-build
-
While that PR does look necessary for constancy sake between what the client returns to the player code and what intent is actually registered, it doesn't doesn't address this problem.
The problem is coming from the sole reliance of C.OBSTACLE_OBJECT_TYPES to check for non-walkable objects in second part of the if statement (taken from here, although it also occurs here in a similar fashion):
if(_.contains(C.OBSTACLE_OBJECT_TYPES, target.structureType) && (_.any(roomObjects, (i) => i.x == target.x && i.y == target.y && _.contains(C.OBSTACLE_OBJECT_TYPES, i.type)))) { return; }
Earlier in Screeps development everything of a type listed in the C.OBSTACLE_OBJECT_TYPES constant was always non-walkable and thus an obstacle, but that's not true anymore.
Now you need an additional check to see if a creep (one of the types listed in C.OBSTACLE_OBJECT_TYPES) is walkable or not, because a creep can be walkable when it's a hostile creep in a room you've activated safe mode in.