Merge branch 'master' into jgrpp

This commit is contained in:
Jonathan G Rennison
2021-04-05 17:50:39 +01:00
164 changed files with 3493 additions and 2443 deletions

View File

@@ -30,6 +30,7 @@
#include "error.h"
#include "newgrf_townname.h"
#include "townname_type.h"
#include "video/video_driver.hpp"
#include "widgets/genworld_widget.h"
@@ -1430,10 +1431,10 @@ static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uin
static_assert(lengthof(percent_table) == GWP_CLASS_COUNT + 1);
assert(cls < GWP_CLASS_COUNT);
/* Do not run this function if we aren't in a thread */
if (!IsGenerateWorldThreaded() && !_network_dedicated) return;
if (IsGeneratingWorldAborted()) HandleGeneratingWorldAbortion();
if (IsGeneratingWorldAborted()) {
HandleGeneratingWorldAbortion();
return;
}
if (total == 0) {
assert(_gws.cls == _generation_class_table[cls]);
@@ -1446,10 +1447,6 @@ static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uin
_gws.percent = percent_table[cls];
}
/* Don't update the screen too often. So update it once in every once in a while... */
if (!_network_dedicated && std::chrono::steady_clock::now() < _gws.next_update) return;
_gws.next_update = std::chrono::steady_clock::now() + std::chrono::milliseconds(MODAL_PROGRESS_REDRAW_TIMEOUT);
/* Percentage is about the number of completed tasks, so 'current - 1' */
_gws.percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (_gws.current == 0 ? 0 : _gws.current - 1) / _gws.total;
@@ -1468,21 +1465,12 @@ static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uin
DEBUG(net, 1, "Map generation percentage complete: %d", _gws.percent);
last_percent = _gws.percent;
/* Don't continue as dedicated never has a thread running */
return;
}
SetWindowDirty(WC_MODAL_PROGRESS, 0);
MarkWholeScreenDirty();
/* Release the rights to the map generator, and acquire the rights to the
* paint thread. The 'other' thread already has the paint thread rights so
* this ensures us that we are waiting until the paint thread is done
* before we reacquire the mapgen rights */
_modal_progress_work_mutex.unlock();
_modal_progress_paint_mutex.lock();
_modal_progress_work_mutex.lock();
_modal_progress_paint_mutex.unlock();
VideoDriver::GetInstance()->GameLoopPause();
}
/**