16#include "table/strings.h"
23 uint8_t grf_version = buf.
ReadByte();
27 _cur_gps.grfconfig->ident.grfid = grfid;
29 if (grf_version < 2 || grf_version > 8) {
31 Debug(grf, 0,
"{}: NewGRF \"{}\" (GRFID {:08X}) uses GRF version {}, which is incompatible with this version of OpenTTD.", _cur_gps.grfconfig->filename,
StrMakeValid(name),
std::byteswap(grfid), grf_version);
45 _cur_gps.skip_sprites = -1;
62 if (_cur_gps.stage < GLS_RESERVE && _cur_gps.grfconfig->status !=
GCS_UNKNOWN) {
63 DisableGrf(STR_NEWGRF_ERROR_MULTIPLE_ACTION_8);
67 if (_cur_gps.grffile->grfid != grfid) {
68 Debug(grf, 0,
"GRFInfo: GRFID {:08X} in FILESCAN stage does not match GRFID {:08X} in INIT/RESERVE/ACTIVATION stage",
std::byteswap(_cur_gps.grffile->grfid),
std::byteswap(grfid));
69 _cur_gps.grffile->grfid = grfid;
72 _cur_gps.grffile->grf_version = version;
76 Debug(grf, 1,
"GRFInfo: Loaded GRFv{} set {:08X} - {} (palette: {}, version: {})", version,
std::byteswap(grfid),
StrMakeValid(name), (_cur_gps.grfconfig->palette &
GRFP_USE_MASK) ?
"Windows" :
"DOS", _cur_gps.grfconfig->version);
79template <>
void GrfActionHandler<0x08>::FileScan(
ByteReader &buf) { ScanInfo(buf); }
80template <>
void GrfActionHandler<0x08>::SafetyScan(
ByteReader &) { }
81template <>
void GrfActionHandler<0x08>::LabelScan(
ByteReader &) { }
82template <>
void GrfActionHandler<0x08>::Init(
ByteReader &buf) { GRFInfo(buf); }
83template <>
void GrfActionHandler<0x08>::Reserve(
ByteReader &buf) { GRFInfo(buf); }
84template <>
void GrfActionHandler<0x08>::Activation(
ByteReader &buf) { GRFInfo(buf); }
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr enable_if_t< is_integral_v< T >, T > byteswap(T x) noexcept
Custom implementation of std::byteswap; remove once we build with C++23.
Class to read from a NewGRF file.
uint32_t ReadDWord()
Read a single DWord (32 bits).
std::string_view ReadString()
Read a NUL-terminated string.
uint8_t ReadByte()
Read a single byte (8 bits).
Functions related to debugging.
#define Debug(category, level, format_string,...)
Output a line of debugging information.
GRFError * DisableGrf(StringID message, GRFConfig *config)
Disable a GRF.
NewGRF buffer reader definition.
@ GCS_INITIALISED
GRF file has been initialised.
@ GCS_UNKNOWN
The status of this grf file is unknown.
@ GCS_ACTIVATED
GRF file has been activated.
@ Invalid
GRF is unusable with this version of OpenTTD.
@ System
GRF file is an openttd-internal system grf.
@ GRFP_USE_MASK
Bitmask to get only the use palette use states.
NewGRF internal processing state.
static void AddGRFTextToList(GRFTextList &list, uint8_t langid, std::string_view text_to_add)
Add a new text to a GRFText list.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
static void StrMakeValid(Builder &builder, StringConsumer &consumer, StringValidationSettings settings)
Copies the valid (UTF-8) characters from consumer to the builder.
Functions related to low-level strings.