2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file newgrf_config.cpp Finding NewGRFs and configuring them. */
12 #include "3rdparty/md5/md5.h"
14 #include "network/network_func.h"
16 #include "newgrf_text.h"
17 #include "window_func.h"
19 #include "video/video_driver.hpp"
20 #include "string_func.h"
21 #include "strings_func.h"
22 #include "textfile_gui.h"
24 #include "newgrf_config.h"
25 #include "newgrf_text.h"
27 #include "fileio_func.h"
30 #include "safeguards.h"
34 * Create a new GRFConfig.
35 * @param filename Set the filename of this GRFConfig to filename.
37 GRFConfig::GRFConfig(const std::string
&filename
) :
38 filename(filename
), num_valid_params(ClampTo
<uint8_t>(GRFConfig::param
.size()))
43 * Create a new GRFConfig that is a deep copy of an existing config.
44 * @param config The GRFConfig object to make a copy of.
46 GRFConfig::GRFConfig(const GRFConfig
&config
) :
47 ZeroedMemoryAllocator(),
49 original_md5sum(config
.original_md5sum
),
50 filename(config
.filename
),
55 version(config
.version
),
56 min_loadable_version(config
.min_loadable_version
),
57 flags(config
.flags
& ~(1 << GCF_COPY
)),
58 status(config
.status
),
59 grf_bugs(config
.grf_bugs
),
61 num_params(config
.num_params
),
62 num_valid_params(config
.num_valid_params
),
63 palette(config
.palette
),
64 param_info(config
.param_info
),
65 has_param_defaults(config
.has_param_defaults
)
69 void GRFConfig::SetParams(const std::vector
<uint32_t> &pars
)
71 this->num_params
= static_cast<uint8_t>(std::min(this->param
.size(), pars
.size()));
72 std::copy(pars
.begin(), pars
.begin() + this->num_params
, this->param
.begin());
76 * Return whether this NewGRF can replace an older version of the same NewGRF.
78 bool GRFConfig::IsCompatible(uint32_t old_version
) const
80 return this->min_loadable_version
<= old_version
&& old_version
<= this->version
;
84 * Copy the parameter information from the \a src config.
85 * @param src Source config.
87 void GRFConfig::CopyParams(const GRFConfig
&src
)
89 this->num_params
= src
.num_params
;
90 this->param
= src
.param
;
94 * Get the name of this grf. In case the name isn't known
95 * the filename is returned.
96 * @return The name of filename of this grf.
98 const char *GRFConfig::GetName() const
100 const char *name
= GetGRFStringFromGRFText(this->name
);
101 return StrEmpty(name
) ? this->filename
.c_str() : name
;
106 * @return A string with a description of this grf.
108 const char *GRFConfig::GetDescription() const
110 return GetGRFStringFromGRFText(this->info
);
115 * @return A string with an url of this grf.
117 const char *GRFConfig::GetURL() const
119 return GetGRFStringFromGRFText(this->url
);
122 /** Set the default value for all parameters as specified by action14. */
123 void GRFConfig::SetParameterDefaults()
125 this->num_params
= 0;
128 if (!this->has_param_defaults
) return;
130 for (uint i
= 0; i
< this->param_info
.size(); i
++) {
131 if (!this->param_info
[i
]) continue;
132 this->param_info
[i
]->SetValue(this, this->param_info
[i
]->def_value
);
137 * Set the palette of this GRFConfig to something suitable.
138 * That is either the setting coming from the NewGRF or
139 * the globally used palette.
141 void GRFConfig::SetSuitablePalette()
144 switch (this->palette
& GRFP_GRF_MASK
) {
145 case GRFP_GRF_DOS
: pal
= PAL_DOS
; break;
146 case GRFP_GRF_WINDOWS
: pal
= PAL_WINDOWS
; break;
147 default: pal
= _settings_client
.gui
.newgrf_default_palette
== 1 ? PAL_WINDOWS
: PAL_DOS
; break;
149 SB(this->palette
, GRFP_USE_BIT
, 1, pal
== PAL_WINDOWS
? GRFP_USE_WINDOWS
: GRFP_USE_DOS
);
153 * Finalize Action 14 info after file scan is finished.
155 void GRFConfig::FinalizeParameterInfo()
157 for (auto &info
: this->param_info
) {
158 if (!info
.has_value()) continue;
163 GRFConfig
*_all_grfs
;
164 GRFConfig
*_grfconfig
;
165 GRFConfig
*_grfconfig_newgame
;
166 GRFConfig
*_grfconfig_static
;
167 uint _missing_extra_graphics
= 0;
170 * Construct a new GRFError.
171 * @param severity The severity of this error.
172 * @param message The actual error-string.
174 GRFError::GRFError(StringID severity
, StringID message
) : message(message
), severity(severity
)
179 * Create a new empty GRFParameterInfo object.
180 * @param nr The newgrf parameter that is changed.
182 GRFParameterInfo::GRFParameterInfo(uint nr
) :
185 type(PTYPE_UINT_ENUM
),
187 max_value(UINT32_MAX
),
193 complete_labels(false)
197 * Get the value of this user-changeable parameter from the given config.
198 * @param config The GRFConfig to get the value from.
199 * @return The value of this parameter.
201 uint32_t GRFParameterInfo::GetValue(struct GRFConfig
*config
) const
203 /* GB doesn't work correctly with nbits == 32, so handle that case here. */
204 if (this->num_bit
== 32) return config
->param
[this->param_nr
];
205 return GB(config
->param
[this->param_nr
], this->first_bit
, this->num_bit
);
209 * Set the value of this user-changeable parameter in the given config.
210 * @param config The GRFConfig to set the value in.
211 * @param value The new value.
213 void GRFParameterInfo::SetValue(struct GRFConfig
*config
, uint32_t value
)
215 /* SB doesn't work correctly with nbits == 32, so handle that case here. */
216 if (this->num_bit
== 32) {
217 config
->param
[this->param_nr
] = value
;
219 SB(config
->param
[this->param_nr
], this->first_bit
, this->num_bit
, value
);
221 config
->num_params
= std::max
<uint
>(config
->num_params
, this->param_nr
+ 1);
222 SetWindowDirty(WC_GAME_OPTIONS
, WN_GAME_OPTIONS_NEWGRF_STATE
);
226 * Finalize Action 14 info after file scan is finished.
228 void GRFParameterInfo::Finalize()
230 this->complete_labels
= true;
231 for (uint32_t value
= this->min_value
; value
<= this->max_value
; value
++) {
232 if (this->value_names
.count(value
) == 0) {
233 this->complete_labels
= false;
240 * Update the palettes of the graphics from the config file.
241 * Called when changing the default palette in advanced settings.
243 void UpdateNewGRFConfigPalette(int32_t)
245 for (GRFConfig
*c
= _grfconfig_newgame
; c
!= nullptr; c
= c
->next
) c
->SetSuitablePalette();
246 for (GRFConfig
*c
= _grfconfig_static
; c
!= nullptr; c
= c
->next
) c
->SetSuitablePalette();
247 for (GRFConfig
*c
= _all_grfs
; c
!= nullptr; c
= c
->next
) c
->SetSuitablePalette();
251 * Get the data section size of a GRF.
253 * @return Size of the data section or SIZE_MAX if the file has no separate data section.
255 size_t GRFGetSizeOfDataSection(FileHandle
&f
)
257 extern const uint8_t _grf_cont_v2_sig
[];
258 static const uint header_len
= 14;
260 uint8_t data
[header_len
];
261 if (fread(data
, 1, header_len
, f
) == header_len
) {
262 if (data
[0] == 0 && data
[1] == 0 && MemCmpT(data
+ 2, _grf_cont_v2_sig
, 8) == 0) {
263 /* Valid container version 2, get data section size. */
264 size_t offset
= (static_cast<size_t>(data
[13]) << 24) | (static_cast<size_t>(data
[12]) << 16) | (static_cast<size_t>(data
[11]) << 8) | static_cast<size_t>(data
[10]);
265 if (offset
>= 1 * 1024 * 1024 * 1024) {
266 Debug(grf
, 0, "Unexpectedly large offset for NewGRF");
267 /* Having more than 1 GiB of data is very implausible. Mostly because then
268 * all pools in OpenTTD are flooded already. Or it's just Action C all over.
269 * In any case, the offsets to graphics will likely not work either. */
272 return header_len
+ offset
;
280 * Calculate the MD5 sum for a GRF, and store it in the config.
281 * @param config GRF to compute.
282 * @param subdir The subdirectory to look in.
283 * @return MD5 sum was successfully computed
285 static bool CalcGRFMD5Sum(GRFConfig
*config
, Subdirectory subdir
)
288 uint8_t buffer
[1024];
292 auto f
= FioFOpenFile(config
->filename
, "rb", subdir
, &size
);
293 if (!f
.has_value()) return false;
295 long start
= ftell(*f
);
296 size
= std::min(size
, GRFGetSizeOfDataSection(*f
));
298 if (start
< 0 || fseek(*f
, start
, SEEK_SET
) < 0) {
302 /* calculate md5sum */
303 while ((len
= fread(buffer
, 1, (size
> sizeof(buffer
)) ? sizeof(buffer
) : size
, *f
)) != 0 && size
!= 0) {
305 checksum
.Append(buffer
, len
);
307 checksum
.Finish(config
->ident
.md5sum
);
314 * Find the GRFID of a given grf, and calculate its md5sum.
315 * @param config grf to fill.
316 * @param is_static grf is static.
317 * @param subdir the subdirectory to search in.
318 * @return Operation was successfully completed.
320 bool FillGRFDetails(GRFConfig
*config
, bool is_static
, Subdirectory subdir
)
322 if (!FioCheckFileExists(config
->filename
, subdir
)) {
323 config
->status
= GCS_NOT_FOUND
;
327 /* Find and load the Action 8 information */
328 LoadNewGRFFile(config
, GLS_FILESCAN
, subdir
, true);
329 config
->SetSuitablePalette();
330 config
->FinalizeParameterInfo();
332 /* Skip if the grfid is 0 (not read) or if it is an internal GRF */
333 if (config
->ident
.grfid
== 0 || HasBit(config
->flags
, GCF_SYSTEM
)) return false;
336 /* Perform a 'safety scan' for static GRFs */
337 LoadNewGRFFile(config
, GLS_SAFETYSCAN
, subdir
, true);
339 /* GCF_UNSAFE is set if GLS_SAFETYSCAN finds unsafe actions */
340 if (HasBit(config
->flags
, GCF_UNSAFE
)) return false;
343 return CalcGRFMD5Sum(config
, subdir
);
348 * Clear a GRF Config list, freeing all nodes.
349 * @param config Start of the list.
350 * @post \a config is set to \c nullptr.
352 void ClearGRFConfigList(GRFConfig
**config
)
355 for (c
= *config
; c
!= nullptr; c
= next
) {
364 * Copy a GRF Config list
365 * @param dst pointer to destination list
366 * @param src pointer to source list values
367 * @param init_only the copied GRF will be processed up to GLS_INIT
368 * @return pointer to the last value added to the destination list
370 GRFConfig
**CopyGRFConfigList(GRFConfig
**dst
, const GRFConfig
*src
, bool init_only
)
372 /* Clear destination as it will be overwritten */
373 ClearGRFConfigList(dst
);
374 for (; src
!= nullptr; src
= src
->next
) {
375 GRFConfig
*c
= new GRFConfig(*src
);
377 ClrBit(c
->flags
, GCF_INIT_ONLY
);
378 if (init_only
) SetBit(c
->flags
, GCF_INIT_ONLY
);
388 * Removes duplicates from lists of GRFConfigs. These duplicates
389 * are introduced when the _grfconfig_static GRFs are appended
390 * to the _grfconfig on a newgame or savegame. As the parameters
391 * of the static GRFs could be different that the parameters of
392 * the ones used non-statically. This can result in desyncs in
393 * multiplayers, so the duplicate static GRFs have to be removed.
395 * This function _assumes_ that all static GRFs are placed after
396 * the non-static GRFs.
398 * @param list the list to remove the duplicates from
400 static void RemoveDuplicatesFromGRFConfigList(GRFConfig
*list
)
405 if (list
== nullptr) return;
407 for (prev
= list
, cur
= list
->next
; cur
!= nullptr; prev
= cur
, cur
= cur
->next
) {
408 if (cur
->ident
.grfid
!= list
->ident
.grfid
) continue;
410 prev
->next
= cur
->next
;
412 cur
= prev
; // Just go back one so it continues as normal later on
415 RemoveDuplicatesFromGRFConfigList(list
->next
);
419 * Appends the static GRFs to a list of GRFs
420 * @param dst the head of the list to add to
422 void AppendStaticGRFConfigs(GRFConfig
**dst
)
424 GRFConfig
**tail
= dst
;
425 while (*tail
!= nullptr) tail
= &(*tail
)->next
;
427 CopyGRFConfigList(tail
, _grfconfig_static
, false);
428 RemoveDuplicatesFromGRFConfigList(*dst
);
432 * Appends an element to a list of GRFs
433 * @param dst the head of the list to add to
434 * @param el the new tail to be
436 void AppendToGRFConfigList(GRFConfig
**dst
, GRFConfig
*el
)
438 GRFConfig
**tail
= dst
;
439 while (*tail
!= nullptr) tail
= &(*tail
)->next
;
442 RemoveDuplicatesFromGRFConfigList(*dst
);
446 /** Reset the current GRF Config to either blank or newgame settings. */
447 void ResetGRFConfig(bool defaults
)
449 CopyGRFConfigList(&_grfconfig
, _grfconfig_newgame
, !defaults
);
450 AppendStaticGRFConfigs(&_grfconfig
);
455 * Check if all GRFs in the GRF config from a savegame can be loaded.
456 * @param grfconfig GrfConfig to check
457 * @return will return any of the following 3 values:<br>
459 * <li> GLC_ALL_GOOD: No problems occurred, all GRF files were found and loaded
460 * <li> GLC_COMPATIBLE: For one or more GRF's no exact match was found, but a
461 * compatible GRF with the same grfid was found and used instead
462 * <li> GLC_NOT_FOUND: For one or more GRF's no match was found at all
465 GRFListCompatibility
IsGoodGRFConfigList(GRFConfig
*grfconfig
)
467 GRFListCompatibility res
= GLC_ALL_GOOD
;
469 for (GRFConfig
*c
= grfconfig
; c
!= nullptr; c
= c
->next
) {
470 const GRFConfig
*f
= FindGRFConfig(c
->ident
.grfid
, FGCM_EXACT
, &c
->ident
.md5sum
);
471 if (f
== nullptr || HasBit(f
->flags
, GCF_INVALID
)) {
472 /* If we have not found the exactly matching GRF try to find one with the
473 * same grfid, as it most likely is compatible */
474 f
= FindGRFConfig(c
->ident
.grfid
, FGCM_COMPATIBLE
, nullptr, c
->version
);
476 Debug(grf
, 1, "NewGRF {:08X} ({}) not found; checksum {}. Compatibility mode on", BSWAP32(c
->ident
.grfid
), c
->filename
, FormatArrayAsHex(c
->ident
.md5sum
));
477 if (!HasBit(c
->flags
, GCF_COMPATIBLE
)) {
478 /* Preserve original_md5sum after it has been assigned */
479 SetBit(c
->flags
, GCF_COMPATIBLE
);
480 c
->original_md5sum
= c
->ident
.md5sum
;
483 /* Non-found has precedence over compatibility load */
484 if (res
!= GLC_NOT_FOUND
) res
= GLC_COMPATIBLE
;
488 /* No compatible grf was found, mark it as disabled */
489 Debug(grf
, 0, "NewGRF {:08X} ({}) not found; checksum {}", BSWAP32(c
->ident
.grfid
), c
->filename
, FormatArrayAsHex(c
->ident
.md5sum
));
491 c
->status
= GCS_NOT_FOUND
;
495 Debug(grf
, 1, "Loading GRF {:08X} from {}", BSWAP32(f
->ident
.grfid
), f
->filename
);
496 /* The filename could be the filename as in the savegame. As we need
497 * to load the GRF here, we need the correct filename, so overwrite that
498 * in any case and set the name and info when it is not set already.
499 * When the GCF_COPY flag is set, it is certain that the filename is
500 * already a local one, so there is no need to replace it. */
501 if (!HasBit(c
->flags
, GCF_COPY
)) {
502 c
->filename
= f
->filename
;
503 c
->ident
.md5sum
= f
->ident
.md5sum
;
507 c
->version
= f
->version
;
508 c
->min_loadable_version
= f
->min_loadable_version
;
509 c
->num_valid_params
= f
->num_valid_params
;
510 c
->param_info
= f
->param_info
;
511 c
->has_param_defaults
= f
->has_param_defaults
;
520 /** Set this flag to prevent any NewGRF scanning from being done. */
521 int _skip_all_newgrf_scanning
= 0;
523 /** Helper for scanning for files with GRF as extension */
524 class GRFFileScanner
: FileScanner
{
525 std::chrono::steady_clock::time_point next_update
; ///< The next moment we do update the screen.
526 uint num_scanned
; ///< The number of GRFs we have scanned.
529 GRFFileScanner() : num_scanned(0)
531 this->next_update
= std::chrono::steady_clock::now();
534 bool AddFile(const std::string
&filename
, size_t basepath_length
, const std::string
&tar_filename
) override
;
536 /** Do the scan for GRFs. */
539 if (_skip_all_newgrf_scanning
> 0) {
540 if (_skip_all_newgrf_scanning
== 1) _skip_all_newgrf_scanning
= 0;
545 int ret
= fs
.Scan(".grf", NEWGRF_DIR
);
546 /* The number scanned and the number returned may not be the same;
547 * duplicate NewGRFs and base sets are ignored in the return value. */
548 _settings_client
.gui
.last_newgrf_count
= fs
.num_scanned
;
553 bool GRFFileScanner::AddFile(const std::string
&filename
, size_t basepath_length
, const std::string
&)
555 /* Abort if the user stopped the game during a scan. */
556 if (_exit_game
) return false;
558 GRFConfig
*c
= new GRFConfig(filename
.c_str() + basepath_length
);
561 if (FillGRFDetails(c
, false)) {
562 if (_all_grfs
== nullptr) {
565 /* Insert file into list at a position determined by its
566 * name, so the list is sorted as we go along */
569 for (pd
= &_all_grfs
; (d
= *pd
) != nullptr; pd
= &d
->next
) {
570 if (c
->ident
.grfid
== d
->ident
.grfid
&& c
->ident
.md5sum
== d
->ident
.md5sum
) added
= false;
571 /* Because there can be multiple grfs with the same name, make sure we checked all grfs with the same name,
572 * before inserting the entry. So insert a new grf at the end of all grfs with the same name, instead of
573 * just after the first with the same name. Avoids doubles in the list. */
574 if (StrCompareIgnoreCase(c
->GetName(), d
->GetName()) <= 0) {
591 const char *name
= nullptr;
592 if (c
->name
!= nullptr) name
= GetGRFStringFromGRFText(c
->name
);
593 if (name
== nullptr) name
= c
->filename
.c_str();
594 UpdateNewGRFScanStatus(this->num_scanned
, name
);
595 VideoDriver::GetInstance()->GameLoopPause();
598 /* File couldn't be opened, or is either not a NewGRF or is a
599 * 'system' NewGRF or it's already known, so forget about it. */
607 * Simple sorter for GRFS
608 * @param c1 the first GRFConfig *
609 * @param c2 the second GRFConfig *
610 * @return true if the name of first NewGRF is before the name of the second.
612 static bool GRFSorter(GRFConfig
* const &c1
, GRFConfig
* const &c2
)
614 return StrNaturalCompare(c1
->GetName(), c2
->GetName()) < 0;
618 * Really perform the scan for all NewGRFs.
619 * @param callback The callback to call after the scanning is complete.
621 void DoScanNewGRFFiles(NewGRFScanCallback
*callback
)
623 ClearGRFConfigList(&_all_grfs
);
624 TarScanner::DoScan(TarScanner::NEWGRF
);
626 Debug(grf
, 1, "Scanning for NewGRFs");
627 uint num
= GRFFileScanner::DoScan();
629 Debug(grf
, 1, "Scan complete, found {} files", num
);
630 if (num
!= 0 && _all_grfs
!= nullptr) {
631 /* Sort the linked list using quicksort.
632 * For that we first have to make an array, then sort and
633 * then remake the linked list. */
634 std::vector
<GRFConfig
*> to_sort
;
637 for (GRFConfig
*p
= _all_grfs
; p
!= nullptr; p
= p
->next
, i
++) {
638 to_sort
.push_back(p
);
640 /* Number of files is not necessarily right */
643 std::sort(to_sort
.begin(), to_sort
.end(), GRFSorter
);
645 for (i
= 1; i
< num
; i
++) {
646 to_sort
[i
- 1]->next
= to_sort
[i
];
648 to_sort
[num
- 1]->next
= nullptr;
649 _all_grfs
= to_sort
[0];
651 NetworkAfterNewGRFScan();
654 /* Yes... these are the NewGRF windows */
655 InvalidateWindowClassesData(WC_SAVELOAD
, 0, true);
656 InvalidateWindowData(WC_GAME_OPTIONS
, WN_GAME_OPTIONS_NEWGRF_STATE
, GOID_NEWGRF_RESCANNED
, true);
657 if (!_exit_game
&& callback
!= nullptr) callback
->OnNewGRFsScanned();
659 CloseWindowByClass(WC_MODAL_PROGRESS
);
660 SetModalProgress(false);
661 MarkWholeScreenDirty();
665 * Scan for all NewGRFs.
666 * @param callback The callback to call after the scanning is complete.
668 void ScanNewGRFFiles(NewGRFScanCallback
*callback
)
670 /* First set the modal progress. This ensures that it will eventually let go of the paint mutex. */
671 SetModalProgress(true);
672 /* Only then can we really start, especially by marking the whole screen dirty. Get those other windows hidden!. */
673 MarkWholeScreenDirty();
675 DoScanNewGRFFiles(callback
);
679 * Find a NewGRF in the scanned list.
680 * @param grfid GRFID to look for,
681 * @param mode Restrictions for matching grfs
682 * @param md5sum Expected MD5 sum
683 * @param desired_version Requested version
684 * @return The matching grf, if it exists in #_all_grfs, else \c nullptr.
686 const GRFConfig
*FindGRFConfig(uint32_t grfid
, FindGRFConfigMode mode
, const MD5Hash
*md5sum
, uint32_t desired_version
)
688 assert((mode
== FGCM_EXACT
) != (md5sum
== nullptr));
689 const GRFConfig
*best
= nullptr;
690 for (const GRFConfig
*c
= _all_grfs
; c
!= nullptr; c
= c
->next
) {
691 /* if md5sum is set, we look for an exact match and continue if not found */
692 if (!c
->ident
.HasGrfIdentifier(grfid
, md5sum
)) continue;
693 /* return it, if the exact same newgrf is found, or if we do not care about finding "the best" */
694 if (md5sum
!= nullptr || mode
== FGCM_ANY
) return c
;
695 /* Skip incompatible stuff, unless explicitly allowed */
696 if (mode
!= FGCM_NEWEST
&& HasBit(c
->flags
, GCF_INVALID
)) continue;
697 /* check version compatibility */
698 if (mode
== FGCM_COMPATIBLE
&& !c
->IsCompatible(desired_version
)) continue;
699 /* remember the newest one as "the best" */
700 if (best
== nullptr || c
->version
> best
->version
) best
= c
;
707 * Retrieve a NewGRF from the current config by its grfid.
708 * @param grfid grf to look for.
709 * @param mask GRFID mask to allow for partial matching.
710 * @return The grf config, if it exists, else \c nullptr.
712 GRFConfig
*GetGRFConfig(uint32_t grfid
, uint32_t mask
)
716 for (c
= _grfconfig
; c
!= nullptr; c
= c
->next
) {
717 if ((c
->ident
.grfid
& mask
) == (grfid
& mask
)) return c
;
724 /** Build a string containing space separated parameter values, and terminate */
725 std::string
GRFBuildParamList(const GRFConfig
*c
)
728 for (uint i
= 0; i
< c
->num_params
; i
++) {
729 if (!result
.empty()) result
+= ' ';
730 result
+= std::to_string(c
->param
[i
]);
736 * Search a textfile file next to this NewGRF.
737 * @param type The type of the textfile to search for.
738 * @return The filename for the textfile.
740 std::optional
<std::string
> GRFConfig::GetTextfile(TextfileType type
) const
742 return ::GetTextfile(type
, NEWGRF_DIR
, this->filename
);