diff options
author | rubidium <rubidium@openttd.org> | 2009-05-03 15:44:05 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-05-03 15:44:05 +0000 |
commit | d685ca0619cdbaf61623b673d26a2c9aa8b5b85e (patch) | |
tree | fa050ce2c3ba55aadcc588d3e60293e710e6b886 /src/gfx.cpp | |
parent | c29f4fd738f65678356718b8487cf18e196a2dec (diff) | |
download | openttd-d685ca0619cdbaf61623b673d26a2c9aa8b5b85e.tar.xz |
(svn r16220) -Fix [FS#2862]: possible crashes when quiting OpenTTD or forcing resizes/redraws of the screen during map generation
Diffstat (limited to 'src/gfx.cpp')
-rw-r--r-- | src/gfx.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp index 37f9a3d34..4df12e210 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -19,6 +19,7 @@ #include "landscape_type.h" #include "network/network_func.h" #include "core/smallvec_type.hpp" +#include "thread.h" #include "table/palettes.h" #include "table/sprites.h" @@ -1275,7 +1276,18 @@ void DrawDirtyBlocks() int x; int y; - if (IsGeneratingWorld() && !IsGeneratingWorldReadyForPaint()) return; + if (IsGeneratingWorld()) { + /* We are generating the world, so release our rights to the map and + * painting while we are waiting a bit. */ + _genworld_paint_mutex->EndCritical(); + _genworld_mapgen_mutex->EndCritical(); + + /* Wait a while and update _realtime_tick so we are given the rights */ + CSleep(GENWORLD_REDRAW_TIMEOUT); + _realtime_tick += GENWORLD_REDRAW_TIMEOUT; + _genworld_paint_mutex->BeginCritical(); + _genworld_mapgen_mutex->BeginCritical(); + } y = 0; do { @@ -1343,12 +1355,6 @@ void DrawDirtyBlocks() _invalid_rect.top = h; _invalid_rect.right = 0; _invalid_rect.bottom = 0; - - /* If we are generating a world, and waiting for a paint run, mark it here - * as done painting, so we can continue generating. */ - if (IsGeneratingWorld() && IsGeneratingWorldReadyForPaint()) { - SetGeneratingWorldPaintStatus(false); - } } /*! |