Changeset - r26246:b0a57fae662a
[Not reviewed]
master
0 2 0
Niels Martin Hansen - 2 years ago 2022-05-06 08:35:47
nielsm@indvikleren.dk
Add: Commandline option to skip NewGRF scanning
2 files changed with 17 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/newgrf_config.cpp
Show inline comments
 
@@ -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;
src/openttd.cpp
Show inline comments
 
@@ -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;
0 comments (0 inline, 0 general)