Merge branches 'crashlog_improvements', 'save_ext' into jgrpp
# Conflicts: # Makefile.src.in # projects/openttd_vs140.vcxproj # projects/openttd_vs140.vcxproj.filters # projects/openttd_vs141.vcxproj # projects/openttd_vs141.vcxproj.filters # projects/openttd_vs142.vcxproj # projects/openttd_vs142.vcxproj.filters # src/core/smallstack_type.hpp # src/linkgraph/linkgraphjob.cpp # src/linkgraph/linkgraphjob.h # src/misc.cpp # src/network/network_udp.cpp # src/openttd.cpp # src/saveload/saveload.cpp
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
#include "video/video_driver.hpp"
|
||||
#include "strings_func.h"
|
||||
#include "textfile_gui.h"
|
||||
#include "thread.h"
|
||||
#include "newgrf_config.h"
|
||||
|
||||
#include "fileio_func.h"
|
||||
#include "fios.h"
|
||||
@@ -684,18 +686,18 @@ bool GRFFileScanner::AddFile(const char *filename, size_t basepath_length, const
|
||||
|
||||
this->num_scanned++;
|
||||
if (this->next_update <= _realtime_tick) {
|
||||
_modal_progress_work_mutex->EndCritical();
|
||||
_modal_progress_paint_mutex->BeginCritical();
|
||||
_modal_progress_work_mutex.unlock();
|
||||
_modal_progress_paint_mutex.lock();
|
||||
|
||||
const char *name = NULL;
|
||||
if (c->name != NULL) name = GetGRFStringFromGRFText(c->name->text);
|
||||
if (name == NULL) name = c->filename;
|
||||
UpdateNewGRFScanStatus(this->num_scanned, name);
|
||||
|
||||
_modal_progress_work_mutex->BeginCritical();
|
||||
_modal_progress_paint_mutex->EndCritical();
|
||||
_modal_progress_work_mutex.lock();
|
||||
_modal_progress_paint_mutex.unlock();
|
||||
|
||||
this->next_update = _realtime_tick + 200;
|
||||
this->next_update = _realtime_tick + MODAL_PROGRESS_REDRAW_TIMEOUT;
|
||||
}
|
||||
|
||||
if (!added) {
|
||||
@@ -725,9 +727,9 @@ static int CDECL GRFSorter(GRFConfig * const *p1, GRFConfig * const *p2)
|
||||
* Really perform the scan for all NewGRFs.
|
||||
* @param callback The callback to call after the scanning is complete.
|
||||
*/
|
||||
void DoScanNewGRFFiles(void *callback)
|
||||
void DoScanNewGRFFiles(NewGRFScanCallback *callback)
|
||||
{
|
||||
_modal_progress_work_mutex->BeginCritical();
|
||||
std::unique_lock<std::mutex> lock_work(_modal_progress_work_mutex);
|
||||
|
||||
ClearGRFConfigList(&_all_grfs);
|
||||
TarScanner::DoScan(TarScanner::NEWGRF);
|
||||
@@ -762,18 +764,17 @@ void DoScanNewGRFFiles(void *callback)
|
||||
NetworkAfterNewGRFScan();
|
||||
}
|
||||
|
||||
_modal_progress_work_mutex->EndCritical();
|
||||
_modal_progress_paint_mutex->BeginCritical();
|
||||
lock_work.unlock();
|
||||
std::lock_guard<std::mutex> lock_paint(_modal_progress_paint_mutex);
|
||||
|
||||
/* Yes... these are the NewGRF windows */
|
||||
InvalidateWindowClassesData(WC_SAVELOAD, 0, true);
|
||||
InvalidateWindowData(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE, GOID_NEWGRF_RESCANNED, true);
|
||||
if (callback != NULL) ((NewGRFScanCallback*)callback)->OnNewGRFsScanned();
|
||||
if (callback != NULL) callback->OnNewGRFsScanned();
|
||||
|
||||
DeleteWindowByClass(WC_MODAL_PROGRESS);
|
||||
SetModalProgress(false);
|
||||
MarkWholeScreenDirty();
|
||||
_modal_progress_paint_mutex->EndCritical();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -787,12 +788,12 @@ void ScanNewGRFFiles(NewGRFScanCallback *callback)
|
||||
/* Only then can we really start, especially by marking the whole screen dirty. Get those other windows hidden!. */
|
||||
MarkWholeScreenDirty();
|
||||
|
||||
if (!VideoDriver::GetInstance()->HasGUI() || !ThreadObject::New(&DoScanNewGRFFiles, callback, NULL, "ottd:newgrf-scan")) {
|
||||
_modal_progress_work_mutex->EndCritical();
|
||||
_modal_progress_paint_mutex->EndCritical();
|
||||
if (!UseThreadedModelProgress() || !VideoDriver::GetInstance()->HasGUI() || !StartNewThread(NULL, "ottd:newgrf-scan", &DoScanNewGRFFiles, (NewGRFScanCallback *)callback)) { // Without the seemingly superfluous cast, strange compiler errors ensue.
|
||||
_modal_progress_work_mutex.unlock();
|
||||
_modal_progress_paint_mutex.unlock();
|
||||
DoScanNewGRFFiles(callback);
|
||||
_modal_progress_paint_mutex->BeginCritical();
|
||||
_modal_progress_work_mutex->BeginCritical();
|
||||
_modal_progress_paint_mutex.lock();
|
||||
_modal_progress_work_mutex.lock();
|
||||
} else {
|
||||
UpdateNewGRFScanStatus(0, NULL);
|
||||
}
|
||||
|
Reference in New Issue
Block a user