Don't let me build roads on top of walls



  • I had an insidious bug today where my creeps were trying to path through walls and I determined it was because my remote mining code was building roads on some walls.

    It's really hard to see these roads in the GUI when they are built on top of walls.

    Having roads on top of walls makes building cost matrices difficult, because you can't just iterate over room.find(FIND_STRUCTURES) and set the matrix entries like the example in the docs suggests. For roads you need to do costs.set(x,y, Math.Max(1, costs.get(x,y)). This is weird!

    So it would be really cool if no one else ever had this bug and I propose that the game should not let me build roads on top of unwalkable structures. Also, building an unwalkable structure should delete any road on the tile.



  • This post is deleted!


  • Naw, nothing preventing you from placing buildings on top of roads nor should there be. I just have a script that deletes my roads under unwalkable structures. Just an optimization to be addressed



  • I always use a quick Math.max(new_value, current_value) before setting cost matrix value. It saved me a lot of hassle several times.



  • Ultimately wouldn't it just be simpler to use RoomPosition.lookFor(LOOK_STRUCTURES) and structureType != STRUCTURE_WALL before you place down your road? And just a note if you really want to organize your code for everything you can just make your own custom api for specific types of game objects and require it making it easier to update in the future.