# Basement crashing bug and solution

**URL:** https://discourse.cataclysmdda.org/t/basement-crashing-bug-and-solution/1054
**Category:** The Garage
**Created:** [April 29, 2013, 12:02am UTC](https://discourse.cataclysmdda.org/t/basement-crashing-bug-and-solution/1054 "2013-04-29T00:02:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![LazyCat](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@LazyCat](https://discourse.cataclysmdda.org/u/LazyCat)
#### Post date: [April 29, 2013, 12:02am UTC](https://discourse.cataclysmdda.org/t/basement-crashing-bug-and-solution/1054/1 "2013-04-29T00:02:59Z")

</div>

There are actually two bugs, two ways this bug can manifest. More obvious one is that monsters will not follow the character down and up the basement stairs, but instead spawn at seemingly random place. And more rarely, mostly when the house is facing East, simply going up the stairs will crash the game.

Why? Because while houses are rotated to face one of four compass directions the basements all have one orientation where the stairs are placed at the South end of it. To fix all this simply put this piece of code at the end of ‘case ot\_basement:’ block.

```auto
case ot_basement:
.
.
.

//CAT-mgs: prevent crashing bug
  if(t_above == ot_house_east || t_above == ot_house_base_east)
   rotate(1);
  if(t_above == ot_house_south || t_above == ot_house_base_south)
   rotate(2);
  if(t_above == ot_house_west || t_above == ot_house_base_west)
   rotate(3);

break;
```

This will also bring a little variety to how basements look like. Unfortunately it doesn’t quite fix monsters using stairs, but it’s much better, and what’s really important the game will not crash. I think monsters not using stairs has to do with random placement of stairs leading down and the problem seem proportional to the difference in position of down-stairs and up-stairs. Ideally down-stairs should be right on top of up-stairs.

---

<div class="post-metadata">

### Author: ![LazyCat](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@LazyCat](https://discourse.cataclysmdda.org/u/LazyCat)
#### Post date: [April 29, 2013, 4:12pm UTC](https://discourse.cataclysmdda.org/t/basement-crashing-bug-and-solution/1054/2 "2013-04-29T16:12:56Z")

</div>

Actually it’s “void game::update\_stair\_monsters()” in game.cpp that is flawed and responsible for monsters not always using the stairs. That a little bit more complicated to fix than just with a few lines of code, let me know if you are interested.
