/** * Load the introduction game. * @param load_newgrfs Whether to load the NewGRFs or not. */ static void LoadIntroGame(bool load_newgrfs = true) { _game_mode = GM_MENU; if (load_newgrfs) ResetGRFConfig(false); /* Setup main window */ ResetWindowSystem(); SetupColoursAndInitialWindow(); /* Load the default opening screen savegame */ if (SaveOrLoad("opntitle.dat", SLO_LOAD, DFT_GAME_FILE, BASESET_DIR) != SL_OK) { GenerateWorld(GWM_EMPTY, 64, 64); // if failed loading, make empty world. WaitTillGeneratedWorld(); SetLocalCompany(COMPANY_SPECTATOR); } else { SetLocalCompany(COMPANY_FIRST); } _pause_mode = PM_UNPAUSED; _cursor.fix_at = false; CheckForMissingGlyphs(); MusicLoop(); // ensure music is correct }
static void LoadIntroGame() { _game_mode = GM_MENU; ResetGRFConfig(false); /* Setup main window */ ResetWindowSystem(); SetupColoursAndInitialWindow(); /* Load the default opening screen savegame */ if (SaveOrLoad("opntitle.dat", SL_LOAD, DATA_DIR) != SL_OK) { GenerateWorld(GWM_EMPTY, 64, 64); // if failed loading, make empty world. WaitTillGeneratedWorld(); SetLocalCompany(COMPANY_SPECTATOR); } else { SetLocalCompany(COMPANY_FIRST); } _pause_mode = PM_UNPAUSED; _cursor.fix_at = false; CheckForMissingSprites(); CheckForMissingGlyphsInLoadedLanguagePack(); /* Play main theme */ if (_music_driver->IsSongPlaying()) ResetMusic(); }
/** * Generate a world. * @param mode The mode of world generation (see GenWorldMode). * @param size_x The X-size of the map. * @param size_y The Y-size of the map. * @param reset_settings Whether to reset the game configuration (used for restart) */ void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings) { if (HasModalProgress()) return; _gw.mode = mode; _gw.size_x = size_x; _gw.size_y = size_y; SetModalProgress(true); _gw.abort = false; _gw.abortp = NULL; _gw.lc = _local_company; _gw.quit_thread = false; _gw.threaded = true; /* This disables some commands and stuff */ SetLocalCompany(COMPANY_SPECTATOR); InitializeGame(_gw.size_x, _gw.size_y, true, reset_settings); PrepareGenerateWorldProgress(); /* Load the right landscape stuff, and the NewGRFs! */ GfxLoadSprites(); LoadStringWidthTable(); /* Re-init the windowing system */ ResetWindowSystem(); /* Create toolbars */ SetupColoursAndInitialWindow(); SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0); if (_gw.thread != NULL) { _gw.thread->Join(); delete _gw.thread; _gw.thread = NULL; } if (!VideoDriver::GetInstance()->HasGUI() || !ThreadObject::New(&_GenerateWorld, NULL, &_gw.thread, "ottd:genworld")) { DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode"); _gw.threaded = false; _modal_progress_work_mutex->EndCritical(); _GenerateWorld(NULL); _modal_progress_work_mutex->BeginCritical(); return; } UnshowCriticalError(); /* Remove any open window */ DeleteAllNonVitalWindows(); /* Hide vital windows, because we don't allow to use them */ HideVitalWindows(); /* Don't show the dialog if we don't have a thread */ ShowGenerateWorldProgress(); /* Centre the view on the map */ if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) { ScrollMainWindowToTile(TileXY(MapSizeX() / 2, MapSizeY() / 2), true); } }