# Black screen when working on vehicle

**URL:** <https://discourse.cataclysmdda.org/t/black-screen-when-working-on-vehicle/508>\
**Category:** The Garage\
**Created:** [March 17, 2013, 1:22pm UTC](https://discourse.cataclysmdda.org/t/black-screen-when-working-on-vehicle/508 "2013-03-17T13:22:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenoxite](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/kenoxite/32/858_2.png) [@kenoxite](https://discourse.cataclysmdda.org/u/kenoxite)\
**Post date:** [March 17, 2013, 1:22pm UTC](https://discourse.cataclysmdda.org/t/black-screen-when-working-on-vehicle/508/1 "2013-03-17T13:22:02Z")

</div>

I can’t recall the exact instance, but it happens when working on a vehicle (repairing, installing, removing) and an event asks you to stop what you’re doing (events like monster seen, becoming tired, etc). Sometimes, instead of displaying the Y/N prompt the whole screen turns black.

Knowing the probable cause I managed to bypass this by pressing Y when asked for the first time, and I’ve been doing so since then. With that said, this should be looked into, as it looks like a “crash” while it’s in fact just the screen not updating the display properly.

---

<div class="post-metadata">

**Author:** ![oohara](https://avatars.discourse-cdn.com/v4/letter/o/dbc845/32.png) [@oohara](https://discourse.cataclysmdda.org/u/oohara)\
**Post date:** [June 19, 2013, 3:08pm UTC](https://discourse.cataclysmdda.org/t/black-screen-when-working-on-vehicle/508/2 "2013-06-19T15:08:27Z")

</div>

I confirmed the bug in the version 0.5 stable.  
When I craft liquid (such as clean water), if I spot a monster  
just before crafting is done, I get a blank screen.

- game::complete\_craft() calls game::handle\_liquid()
- game::handle\_liquid() calls game::inv\_type()
- game::inv\_type() calls erase() and game::refresh\_all()
- game::refresh\_all() calls game::draw()
- game::draw() calls game::mon\_info()
- game::mon\_info() calls game::cancel\_activity\_query()
- game::cancel\_activity\_query() calls query\_yn()
- query\_yn() calls getch()
- getch() implicitly calls refresh() and erases the screen  
If there is no monster, no problem is found because game::mon\_info()  
calls refresh() (this erases the screen) and game::do\_turn() immediately  
calls game::draw() again.

The fix is:

- game::draw() calls game::mon\_info() at the end
- game::refresh\_all() calls game::draw() at the end
- game::mon\_info() calls game::cancel\_activity\_query() at the end
- game::inv\_type() calls refresh() as soon as it calls erase()

— a/game.cpp  
+++ b/game.cpp  
@@ -3028,7 +3028,6 @@  
werase(w\_terrain);  
draw\_ter();  
draw\_footsteps();

- mon\_info();  
// Draw Status  
draw\_HP();  
werase(w\_status);  
@@ -3077,6 +3076,8 @@  
wrefresh(w\_status);  
// Draw messages  
write\_msg();

- // mon\_info() must be called last because it can call cancel\_activity\_query()
- mon\_info();  
}

bool game::isBetween(int test, int down, int up)  
@@ -3142,13 +3143,14 @@  
void game::refresh\_all()  
{  
m.reset\_vehicle\_cache();

- draw();  
draw\_minimap();  
draw\_HP();  
wrefresh(w\_moninfo);  
wrefresh(w\_messages);  
werase(w\_void);  
wrefresh(w\_void);  
+// draw() must be called last because it calls mon\_info()

- draw();  
refresh();  
}

@@ -3726,21 +3728,6 @@  
}  
}

- if (newseen \> mostseen) {

- if (u.activity.type == ACT\_REFILL\_VEHICLE)

- cancel\_activity\_query(“Monster Spotted!”);

- 
- cancel\_activity\_query(“Monster spotted!”);

- turnssincelastmon = 0;

- if (run\_mode == 1)

- run\_mode = 2; // Stop movement!

- } else if (autosafemode && newseen == 0) { // Auto-safemode

- turnssincelastmon++;

- if(turnssincelastmon \>= OPTIONS[OPT\_AUTOSAFEMODETURNS] && run\_mode == 0)

- run\_mode = 1;

- }

- 
- mostseen = newseen;  
nc\_color tmpcol;  
// Print the direction headings  
// Reminder:  
@@ -3873,6 +3860,24 @@

- 

+// cancel\_activity\_query() must be called after drawing is done  
+// because it can call query\_yn()

- if (newseen \> mostseen) {
- if (u.activity.type == ACT\_REFILL\_VEHICLE)
- cancel\_activity\_query(“Monster Spotted!”);
- 
- cancel\_activity\_query(“Monster spotted!”);
- turnssincelastmon = 0;
- if (run\_mode == 1)
- run\_mode = 2; // Stop movement!
- } else if (autosafemode && newseen == 0) { // Auto-safemode
- turnssincelastmon++;
- if(turnssincelastmon \>= OPTIONS[OPT\_AUTOSAFEMODETURNS] && run\_mode == 0)
- run\_mode = 1;
- }
- 
- mostseen = newseen;  
}

void game::cleanup\_dead()  
— a/inventory\_ui.cpp  
+++ b/inventory\_ui.cpp  
@@ -281,6 +281,7 @@  
werase(w\_inv);  
delwin(w\_inv);  
erase();

- refresh();  
refresh\_all();  
return (char)ch;  
}

---

<div class="post-metadata">

**Author:** ![vultures](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/vultures/32/69_2.png) [@vultures](https://discourse.cataclysmdda.org/u/vultures)\
**Post date:** [June 22, 2013, 11:15pm UTC](https://discourse.cataclysmdda.org/t/black-screen-when-working-on-vehicle/508/3 "2013-06-22T23:15:47Z")

</div>

It looks as only the \*seen has to be taken from context. I know it’s not about refresh because there’s no refreshing at the end of it, only a query left behind the “black screen” being written about, and it’s cancelled with a simple ESC. It’s fairly similar to the buggy examine view call, it calls some functions aren’t drawn so they leave buggy pixels. For me, it’s only test & run work.
