(svn r22786) -Codechange: rename genworld mutices to model_progress mutices

This commit is contained in:
rubidium 2011-08-21 12:47:24 +00:00
parent 37415b9cf7
commit 7b7869fba7
5 changed files with 25 additions and 25 deletions

View File

@ -54,10 +54,10 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
*/
GenWorldInfo _gw;
/** Rights for the map generation */
ThreadMutex *_genworld_mapgen_mutex = ThreadMutex::New();
/** Rights for the painting */
ThreadMutex *_genworld_paint_mutex = ThreadMutex::New();
/** Rights for the performing work. */
ThreadMutex *_modal_progress_work_mutex = ThreadMutex::New();
/** Rights for the painting. */
ThreadMutex *_modal_progress_paint_mutex = ThreadMutex::New();
/** Whether we are generating the map or not. */
bool _generating_world;
@ -101,7 +101,7 @@ static void _GenerateWorld(void *)
try {
_generating_world = true;
_genworld_mapgen_mutex->BeginCritical();
_modal_progress_work_mutex->BeginCritical();
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 */
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);
CleanupGeneration();
_genworld_mapgen_mutex->EndCritical();
_modal_progress_work_mutex->EndCritical();
ShowNewGRFError();
@ -192,7 +192,7 @@ static void _GenerateWorld(void *)
} catch (...) {
if (_cur_company.IsValid()) _cur_company.Restore();
_generating_world = false;
_genworld_mapgen_mutex->EndCritical();
_modal_progress_work_mutex->EndCritical();
throw;
}
}
@ -225,15 +225,15 @@ void WaitTillGeneratedWorld()
{
if (_gw.thread == NULL) return;
_genworld_mapgen_mutex->EndCritical();
_genworld_paint_mutex->EndCritical();
_modal_progress_work_mutex->EndCritical();
_modal_progress_paint_mutex->EndCritical();
_gw.quit_thread = true;
_gw.thread->Join();
delete _gw.thread;
_gw.thread = NULL;
_gw.threaded = false;
_genworld_mapgen_mutex->BeginCritical();
_genworld_paint_mutex->BeginCritical();
_modal_progress_work_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)) {
DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode");
_gw.threaded = false;
_genworld_mapgen_mutex->EndCritical();
_modal_progress_work_mutex->EndCritical();
_GenerateWorld(NULL);
_genworld_mapgen_mutex->BeginCritical();
_modal_progress_work_mutex->BeginCritical();
return;
}

View File

@ -101,8 +101,8 @@ void StartNewGameWithoutGUI(uint seed);
void ShowCreateScenario();
void StartScenarioEditor();
extern class ThreadMutex *_genworld_mapgen_mutex;
extern class ThreadMutex *_genworld_paint_mutex;
extern class ThreadMutex *_modal_progress_work_mutex;
extern class ThreadMutex *_modal_progress_paint_mutex;
extern bool _generating_world;
#endif /* GENWORLD_H */

View File

@ -1396,10 +1396,10 @@ static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uin
* 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 */
_genworld_mapgen_mutex->EndCritical();
_genworld_paint_mutex->BeginCritical();
_genworld_mapgen_mutex->BeginCritical();
_genworld_paint_mutex->EndCritical();
_modal_progress_work_mutex->EndCritical();
_modal_progress_paint_mutex->BeginCritical();
_modal_progress_work_mutex->BeginCritical();
_modal_progress_paint_mutex->EndCritical();
_gws.timer = _realtime_tick;
}

View File

@ -1557,14 +1557,14 @@ void DrawDirtyBlocks()
if (HasModalProgress()) {
/* 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();
_modal_progress_paint_mutex->EndCritical();
_modal_progress_work_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();
_modal_progress_paint_mutex->BeginCritical();
_modal_progress_work_mutex->BeginCritical();
}
y = 0;

View File

@ -653,8 +653,8 @@ int ttd_main(int argc, char *argv[])
IConsoleCmdExec("exec scripts/autoexec.scr 0");
/* Take our initial lock on whatever we might want to do! */
_genworld_paint_mutex->BeginCritical();
_genworld_mapgen_mutex->BeginCritical();
_modal_progress_paint_mutex->BeginCritical();
_modal_progress_work_mutex->BeginCritical();
GenerateWorld(GWM_EMPTY, 64, 64); // Make the viewport initialization happy
WaitTillGeneratedWorld();