# \[0.8 stable\] Basements are broken

**URL:** <https://discourse.cataclysmdda.org/t/0-8-stable-basements-are-broken/3118>\
**Category:** The Garage\
**Created:** [September 19, 2013, 4:15pm UTC](https://discourse.cataclysmdda.org/t/0-8-stable-basements-are-broken/3118 "2013-09-19T16:15:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Let\_it\_end\_in\_hellfi](https://avatars.discourse-cdn.com/v4/letter/l/a183cd/32.png) [@Let\_it\_end\_in\_hellfi](https://discourse.cataclysmdda.org/u/Let_it_end_in_hellfi)\
**Post date:** [September 19, 2013, 4:15pm UTC](https://discourse.cataclysmdda.org/t/0-8-stable-basements-are-broken/3118/1 "2013-09-19T16:15:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Let\_it\_end\_in\_hellfi](https://avatars.discourse-cdn.com/v4/letter/l/a183cd/32.png) [@Let\_it\_end\_in\_hellfi](https://discourse.cataclysmdda.org/u/Let_it_end_in_hellfi)\
**Post date:** [October 1, 2013, 5:16pm UTC](https://discourse.cataclysmdda.org/t/0-8-stable-basements-are-broken/3118/2 "2013-10-01T17:16:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kevin.granade](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/kevin.granade/32/1316_2.png) [@kevin.granade](https://discourse.cataclysmdda.org/u/kevin.granade)\
**Post date:** [October 1, 2013, 5:39pm UTC](https://discourse.cataclysmdda.org/t/0-8-stable-basements-are-broken/3118/3 "2013-10-01T17:39:45Z")

</div>

[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.
