diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index f6242e4f5d..6610183c2c 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -575,6 +575,10 @@ compatible_grf: return res; } + +/** Set this flag to prevent any NewGRF scanning from being done. */ +int _skip_all_newgrf_scanning = 0; + /** Helper for scanning for files with GRF as extension */ class GRFFileScanner : FileScanner { std::chrono::steady_clock::time_point next_update; ///< The next moment we do update the screen. @@ -591,6 +595,11 @@ public: /** Do the scan for GRFs. */ static uint DoScan() { + if (_skip_all_newgrf_scanning > 0) { + if (_skip_all_newgrf_scanning == 1) _skip_all_newgrf_scanning = 0; + return 0; + } + GRFFileScanner fs; int ret = fs.Scan(".grf", NEWGRF_DIR); /* The number scanned and the number returned may not be the same; diff --git a/src/openttd.cpp b/src/openttd.cpp index 2e11380d8c..e2cedd5775 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -201,6 +201,8 @@ static void ShowHelp() " -x = Never save configuration changes to disk\n" " -X = Don't use global folders to search for files\n" " -q savegame = Write some information about the savegame and exit\n" + " -Q = Don't scan for/load NewGRF files on startup\n" + " -QQ = Disable NewGRF scanning/loading entirely\n" "\n", lastof(buf) ); @@ -512,6 +514,7 @@ static const OptionData _options[] = { GETOPT_SHORT_NOVAL('X'), GETOPT_SHORT_VALUE('q'), GETOPT_SHORT_NOVAL('h'), + GETOPT_SHORT_NOVAL('Q'), GETOPT_END() }; @@ -640,6 +643,11 @@ int openttd_main(int argc, char *argv[]) WriteSavegameInfo(title); return ret; } + case 'Q': { + extern int _skip_all_newgrf_scanning; + _skip_all_newgrf_scanning += 1; + break; + } case 'G': scanner->generation_seed = strtoul(mgo.opt, nullptr, 10); break; case 'c': _config_file = mgo.opt; break; case 'x': scanner->save_config = false; break;