FindClosestBuildSite and CanBuildHere in the C++ part now have counterparts FindClosestBuildSiteFacing and CanBuildHereFacing.

Build now also takes a facing parameter on the end if provided. It also does more checks on the type of units validity and tests if the structure can actually be built at the target before issuing the build order

Also shard seems to randomly fail building anything on these maps: Titan-v2, Titanduel.
Not sure why.

Edit: Did some more testing and now can rule out any mistakes:
Theres a factory on perfectly flat terrain on Titan-v2 where it never builds and the same factory on similar terrain at a slightly different position works.
Also the same factory works with the same units on all my other maps except those two and whenever i command the same factory at the same spot to build the exact same thing.

I don't think this is the problem because the same factory:
-produces a mobile unit(terrain problems should usually show up after construction is finished but it doesn't even start)
-works fine on all other maps so far
-works fine on some spots
-works fine if i enable godmode and start construction manually

edit: Pictures of the spots in case it helps
non working spots
working spots

So basically there must be a minimum distance of (12 footprint square*spacing value) between the tested position and the nearest unbuildable spot.

It's very likely that the nearest valid position is outside the radius of the search area.

Can I see your current code grabbing the location? Keep in mind that Shard relies on the engines building placement callback and what say I have in the matter is dependent on the search radius and spacing values ( which can be passed in yourself, not passing them in will use my heuristics which are far from optimal ).

It's my longterm goal to abandon the engines API closestbuildsite API call as it's a pain in the arse. Until I can do so there isn't a lot i can do to help other than advocate you use the canbuildhere APIs to do your own tests to implement your own algorithm. Shouldn't be too hard to do but i don't have a test environment right this moment ( clean machine install a week ago, no visual studio or compilers, no spring install )

I don't know. A widget that visualised this would be useful but I wouldn't know where to begin. Closestbuildsite has always been a finnicky suboptimal solution, and a replacement has long been on my todo list

It goes into why it fails so badly and what needs to be done. Right this moment I don't have a spring or development environment set up at home to test this with ( new Windows 8 install, moving flat, I don't have any dev tools installed yet, just sublimetext and an svn/git client ), but when I do I'll want to look into this