(svn r16220) -Fix [FS#2862]: possible crashes when quiting OpenTTD or forcing resizes/redraws of the screen during map generation

This commit is contained in:
rubidium
2009-05-03 15:44:05 +00:00
parent c29f4fd738
commit d685ca0619
5 changed files with 48 additions and 44 deletions

View File

@@ -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);
}
}
/*!