File diff r18402:1f4ab80cb227 → r18403:c5ec10907d18
src/newgrf_config.cpp
Show inline comments
 
@@ -825,29 +825,37 @@ static const uint32 OPENTTD_GRAPHICS_BAS
 

	
 
/**
 
 * Checks whether this GRF is a OpenTTD base graphic GRF.
 
 * @return true if and only if it is a base GRF.
 
 */
 
bool GRFConfig::IsOpenTTDBaseGRF() const
 
{
 
	return (this->ident.grfid & 0x00FFFFFF) == OPENTTD_GRAPHICS_BASE_GRF_ID;
 
}
 

	
 
/**
 
 * Search a textfile file next to this NewGRF.
 
 * @param type The type of the textfile to search for.
 
 * @return The filename for the textfile, \c NULL otherwise.
 
 */
 
const char *GRFConfig::GetTextfile() const
 
const char *GRFConfig::GetTextfile(TextfileType type) const
 
{
 
	static const char prefix[] = "readme";
 
	static const char * const prefixes[] = {
 
		"readme",
 
		"changelog",
 
		"license",
 
	};
 
	assert_compile(lengthof(prefixes) == TFT_END);
 

	
 
	const char *prefix = prefixes[type];
 

	
 
	if (this->filename == NULL) return NULL;
 

	
 
	static char file_path[MAX_PATH];
 
	strecpy(file_path, this->filename, lastof(file_path));
 

	
 
	char *slash = strrchr(file_path, PATHSEPCHAR);
 
	if (slash == NULL) return NULL;
 

	
 
	seprintf(slash + 1, lastof(file_path), "%s_%s.txt", prefix, GetCurrentLanguageIsoCode());
 
	if (FioCheckFileExists(file_path, NEWGRF_DIR)) return file_path;