[0.8 stable] Basements are broken

Or rather, the stairs leading down into the basement don’t generate properly. You can see this easily in debug mode by mapping the area, teleporting into a basement and taking the stairs up. I emerged in a lawn with no stairs down in either of the two nearby houses.

I’ve tracked down the stair place failure to mapgen.cpp:

do { rn = rng(lw + 1, rw - 1); attempts--; } while (ter(rn, actual_house_height - 1) != t_floor && attempts); if( ter(rn, actual_house_height - 1) != t_floor && attempts ) { ter_set(rn, actual_house_height - 1, t_stairs_down); }

The if statement is never true because it checks for inequality instead of equality (the only way to exit the do-while loop is to find a t_floor, then it checks to see if it isn’t t_floor), so the stairs down to the basement aren’t placed. However, the commit message for this change mentions trying to fix an infinite loop in map generation that I haven’t seen happen, so maybe there is more to it?

[me=Kevin Granade]wipes egg off of face, fixes a tasty crovv sandvvich.[/me]
Will fix post-haste, in some situations there was a bug where the above loop would never find a floor tile, so it would get stuck in an infinite loop, but I got the succeeding logic check wrong as you point out. When I saw your bug report initially, I thought the issue was “some basements aren’t spawning stairs”, which I consider acceptable until we can redo house generation, but it’s actually “no basements spawn stairs, ever”, which is not acceptable.