16#include "table/strings.h"
39 STR_NEWGRF_ERROR_VERSION_NUMBER,
40 STR_NEWGRF_ERROR_DOS_OR_WINDOWS,
41 STR_NEWGRF_ERROR_UNSET_SWITCH,
42 STR_NEWGRF_ERROR_INVALID_PARAMETER,
43 STR_NEWGRF_ERROR_LOAD_BEFORE,
44 STR_NEWGRF_ERROR_LOAD_AFTER,
45 STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER,
49 STR_NEWGRF_ERROR_MSG_INFO,
50 STR_NEWGRF_ERROR_MSG_WARNING,
51 STR_NEWGRF_ERROR_MSG_ERROR,
52 STR_NEWGRF_ERROR_MSG_FATAL
60 if (!CheckGrfLangID(lang, _cur_gps.grffile->grf_version))
return;
65 GrfMsg(7,
"GRFLoadError: Skipping non-fatal GRFLoadError in stage {}", _cur_gps.stage);
71 GrfMsg(7,
"GRFLoadError: Invalid severity id {}. Setting to 2 (non-fatal error).", severity);
73 }
else if (severity == 3) {
79 if (message_id >=
lengthof(msgstr) && message_id != 0xFF) {
80 GrfMsg(7,
"GRFLoadError: Invalid message id.");
84 if (buf.Remaining() <= 1) {
85 GrfMsg(7,
"GRFLoadError: No message data supplied.");
90 auto it = std::ranges::find(_cur_gps.grfconfig->errors, _cur_gps.nfo_line, &
GRFError::nfo_line);
91 if (it == std::end(_cur_gps.grfconfig->errors)) {
92 it = _cur_gps.grfconfig->errors.emplace(it, sevstr[severity], _cur_gps.nfo_line);
97 if (message_id == 0xFF) {
104 GrfMsg(7,
"GRFLoadError: No custom message supplied.");
108 error.
message = msgstr[message_id];
116 GrfMsg(7,
"GRFLoadError: No message data supplied.");
121 for (uint i = 0; i < error.
param_value.size() && buf.HasData(); i++) {
123 error.
param_value[i] = _cur_gps.grffile->GetParam(param_number);
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
Class to read from a NewGRF file.
std::string_view ReadString()
Read a NUL-terminated string.
uint8_t ReadByte()
Read a single byte (8 bits).
Functions related to debugging.
Information about languages and their files.
const LanguageMetadata * _current_language
The currently loaded language.
GRFError * DisableGrf(StringID message, GRFConfig *config)
Disable a GRF.
@ Init
Second step of NewGRF loading; load all actions into memory.
NewGRF buffer reader definition.
NewGRF internal processing state.
std::string TranslateTTDPatchCodes(uint32_t grfid, uint8_t language_id, bool allow_newlines, std::string_view str, StringControlCode byte80)
Translate TTDPatch string codes into something OpenTTD can handle (better).
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Information about why GRF had problems during initialisation.
std::array< uint32_t, 2 > param_value
Values of GRF parameters to show for message and custom_message.
uint32_t nfo_line
Line within NewGRF of error.
StringID message
Default message.
std::string custom_message
Custom message (if present).
std::string data
Additional data for message and custom_message.
static void FileScan(ByteReader &buf)
Implementation of the GrfLoadingStage::FileScan stage of this action.
static void SafetyScan(ByteReader &buf)
Implementation of the GrfLoadingStage::SafetyScan stage of this action.
static void Reserve(ByteReader &buf)
Implementation of the GrfLoadingStage::Reserve stage of this action.
static void Activation(ByteReader &buf)
Implementation of the GrfLoadingStage::Activation stage of this action.
static void Init(ByteReader &buf)
Implementation of the GrfLoadingStage::Init stage of this action.
static void LabelScan(ByteReader &buf)
Implementation of the GrfLoadingStage::LabelScan stage of this action.