mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r22786) -Codechange: rename genworld mutices to model_progress mutices
This commit is contained in:
parent
37415b9cf7
commit
7b7869fba7
|
@ -54,10 +54,10 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
|
||||||
*/
|
*/
|
||||||
GenWorldInfo _gw;
|
GenWorldInfo _gw;
|
||||||
|
|
||||||
/** Rights for the map generation */
|
/** Rights for the performing work. */
|
||||||
ThreadMutex *_genworld_mapgen_mutex = ThreadMutex::New();
|
ThreadMutex *_modal_progress_work_mutex = ThreadMutex::New();
|
||||||
/** Rights for the painting */
|
/** Rights for the painting. */
|
||||||
ThreadMutex *_genworld_paint_mutex = ThreadMutex::New();
|
ThreadMutex *_modal_progress_paint_mutex = ThreadMutex::New();
|
||||||
|
|
||||||
/** Whether we are generating the map or not. */
|
/** Whether we are generating the map or not. */
|
||||||
bool _generating_world;
|
bool _generating_world;
|
||||||
|
@ -101,7 +101,7 @@ static void _GenerateWorld(void *)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_generating_world = true;
|
_generating_world = true;
|
||||||
_genworld_mapgen_mutex->BeginCritical();
|
_modal_progress_work_mutex->BeginCritical();
|
||||||
if (_network_dedicated) DEBUG(net, 0, "Generating map, please wait...");
|
if (_network_dedicated) DEBUG(net, 0, "Generating map, please wait...");
|
||||||
/* Set the Random() seed to generation_seed so we produce the same map with the same seed */
|
/* Set the Random() seed to generation_seed so we produce the same map with the same seed */
|
||||||
if (_settings_game.game_creation.generation_seed == GENERATE_NEW_SEED) _settings_game.game_creation.generation_seed = _settings_newgame.game_creation.generation_seed = InteractiveRandom();
|
if (_settings_game.game_creation.generation_seed == GENERATE_NEW_SEED) _settings_game.game_creation.generation_seed = _settings_newgame.game_creation.generation_seed = InteractiveRandom();
|
||||||
|
@ -177,7 +177,7 @@ static void _GenerateWorld(void *)
|
||||||
IncreaseGeneratingWorldProgress(GWP_GAME_START);
|
IncreaseGeneratingWorldProgress(GWP_GAME_START);
|
||||||
|
|
||||||
CleanupGeneration();
|
CleanupGeneration();
|
||||||
_genworld_mapgen_mutex->EndCritical();
|
_modal_progress_work_mutex->EndCritical();
|
||||||
|
|
||||||
ShowNewGRFError();
|
ShowNewGRFError();
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ static void _GenerateWorld(void *)
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
if (_cur_company.IsValid()) _cur_company.Restore();
|
if (_cur_company.IsValid()) _cur_company.Restore();
|
||||||
_generating_world = false;
|
_generating_world = false;
|
||||||
_genworld_mapgen_mutex->EndCritical();
|
_modal_progress_work_mutex->EndCritical();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,15 +225,15 @@ void WaitTillGeneratedWorld()
|
||||||
{
|
{
|
||||||
if (_gw.thread == NULL) return;
|
if (_gw.thread == NULL) return;
|
||||||
|
|
||||||
_genworld_mapgen_mutex->EndCritical();
|
_modal_progress_work_mutex->EndCritical();
|
||||||
_genworld_paint_mutex->EndCritical();
|
_modal_progress_paint_mutex->EndCritical();
|
||||||
_gw.quit_thread = true;
|
_gw.quit_thread = true;
|
||||||
_gw.thread->Join();
|
_gw.thread->Join();
|
||||||
delete _gw.thread;
|
delete _gw.thread;
|
||||||
_gw.thread = NULL;
|
_gw.thread = NULL;
|
||||||
_gw.threaded = false;
|
_gw.threaded = false;
|
||||||
_genworld_mapgen_mutex->BeginCritical();
|
_modal_progress_work_mutex->BeginCritical();
|
||||||
_genworld_paint_mutex->BeginCritical();
|
_modal_progress_paint_mutex->BeginCritical();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -318,9 +318,9 @@ void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_setti
|
||||||
!ThreadObject::New(&_GenerateWorld, NULL, &_gw.thread)) {
|
!ThreadObject::New(&_GenerateWorld, NULL, &_gw.thread)) {
|
||||||
DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode");
|
DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode");
|
||||||
_gw.threaded = false;
|
_gw.threaded = false;
|
||||||
_genworld_mapgen_mutex->EndCritical();
|
_modal_progress_work_mutex->EndCritical();
|
||||||
_GenerateWorld(NULL);
|
_GenerateWorld(NULL);
|
||||||
_genworld_mapgen_mutex->BeginCritical();
|
_modal_progress_work_mutex->BeginCritical();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,8 +101,8 @@ void StartNewGameWithoutGUI(uint seed);
|
||||||
void ShowCreateScenario();
|
void ShowCreateScenario();
|
||||||
void StartScenarioEditor();
|
void StartScenarioEditor();
|
||||||
|
|
||||||
extern class ThreadMutex *_genworld_mapgen_mutex;
|
extern class ThreadMutex *_modal_progress_work_mutex;
|
||||||
extern class ThreadMutex *_genworld_paint_mutex;
|
extern class ThreadMutex *_modal_progress_paint_mutex;
|
||||||
extern bool _generating_world;
|
extern bool _generating_world;
|
||||||
|
|
||||||
#endif /* GENWORLD_H */
|
#endif /* GENWORLD_H */
|
||||||
|
|
|
@ -1396,10 +1396,10 @@ static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uin
|
||||||
* paint thread. The 'other' thread already has the paint thread rights so
|
* 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
|
* this ensures us that we are waiting until the paint thread is done
|
||||||
* before we reacquire the mapgen rights */
|
* before we reacquire the mapgen rights */
|
||||||
_genworld_mapgen_mutex->EndCritical();
|
_modal_progress_work_mutex->EndCritical();
|
||||||
_genworld_paint_mutex->BeginCritical();
|
_modal_progress_paint_mutex->BeginCritical();
|
||||||
_genworld_mapgen_mutex->BeginCritical();
|
_modal_progress_work_mutex->BeginCritical();
|
||||||
_genworld_paint_mutex->EndCritical();
|
_modal_progress_paint_mutex->EndCritical();
|
||||||
|
|
||||||
_gws.timer = _realtime_tick;
|
_gws.timer = _realtime_tick;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1557,14 +1557,14 @@ void DrawDirtyBlocks()
|
||||||
if (HasModalProgress()) {
|
if (HasModalProgress()) {
|
||||||
/* We are generating the world, so release our rights to the map and
|
/* We are generating the world, so release our rights to the map and
|
||||||
* painting while we are waiting a bit. */
|
* painting while we are waiting a bit. */
|
||||||
_genworld_paint_mutex->EndCritical();
|
_modal_progress_paint_mutex->EndCritical();
|
||||||
_genworld_mapgen_mutex->EndCritical();
|
_modal_progress_work_mutex->EndCritical();
|
||||||
|
|
||||||
/* Wait a while and update _realtime_tick so we are given the rights */
|
/* Wait a while and update _realtime_tick so we are given the rights */
|
||||||
CSleep(GENWORLD_REDRAW_TIMEOUT);
|
CSleep(GENWORLD_REDRAW_TIMEOUT);
|
||||||
_realtime_tick += GENWORLD_REDRAW_TIMEOUT;
|
_realtime_tick += GENWORLD_REDRAW_TIMEOUT;
|
||||||
_genworld_paint_mutex->BeginCritical();
|
_modal_progress_paint_mutex->BeginCritical();
|
||||||
_genworld_mapgen_mutex->BeginCritical();
|
_modal_progress_work_mutex->BeginCritical();
|
||||||
}
|
}
|
||||||
|
|
||||||
y = 0;
|
y = 0;
|
||||||
|
|
|
@ -653,8 +653,8 @@ int ttd_main(int argc, char *argv[])
|
||||||
IConsoleCmdExec("exec scripts/autoexec.scr 0");
|
IConsoleCmdExec("exec scripts/autoexec.scr 0");
|
||||||
|
|
||||||
/* Take our initial lock on whatever we might want to do! */
|
/* Take our initial lock on whatever we might want to do! */
|
||||||
_genworld_paint_mutex->BeginCritical();
|
_modal_progress_paint_mutex->BeginCritical();
|
||||||
_genworld_mapgen_mutex->BeginCritical();
|
_modal_progress_work_mutex->BeginCritical();
|
||||||
|
|
||||||
GenerateWorld(GWM_EMPTY, 64, 64); // Make the viewport initialization happy
|
GenerateWorld(GWM_EMPTY, 64, 64); // Make the viewport initialization happy
|
||||||
WaitTillGeneratedWorld();
|
WaitTillGeneratedWorld();
|
||||||
|
|
Loading…
Reference in New Issue