15#include "table/strings.h"
17#include "../safeguards.h"
38 STR_NEWGRF_ERROR_VERSION_NUMBER,
39 STR_NEWGRF_ERROR_DOS_OR_WINDOWS,
40 STR_NEWGRF_ERROR_UNSET_SWITCH,
41 STR_NEWGRF_ERROR_INVALID_PARAMETER,
42 STR_NEWGRF_ERROR_LOAD_BEFORE,
43 STR_NEWGRF_ERROR_LOAD_AFTER,
44 STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER,
48 STR_NEWGRF_ERROR_MSG_INFO,
49 STR_NEWGRF_ERROR_MSG_WARNING,
50 STR_NEWGRF_ERROR_MSG_ERROR,
51 STR_NEWGRF_ERROR_MSG_FATAL
59 if (!CheckGrfLangID(lang, _cur.
grffile->grf_version))
return;
63 if (!
HasBit(severity, 7) && _cur.
stage == GLS_INIT) {
64 GrfMsg(7,
"GRFLoadError: Skipping non-fatal GRFLoadError in stage {}", _cur.
stage);
70 GrfMsg(7,
"GRFLoadError: Invalid severity id {}. Setting to 2 (non-fatal error).", severity);
72 }
else if (severity == 3) {
81 if (message_id >=
lengthof(msgstr) && message_id != 0xFF) {
82 GrfMsg(7,
"GRFLoadError: Invalid message id.");
86 if (buf.Remaining() <= 1) {
87 GrfMsg(7,
"GRFLoadError: No message data supplied.");
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++) {
debug_inline 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 string.
uint8_t ReadByte()
Read a single byte (8 bits).
GRFError * DisableGrf(StringID message, GRFConfig *config)
Disable a GRF.
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).
#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.
std::optional< GRFError > error
NOSAVE: Error/Warning during GRF loading (Action 0x0B)
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.
StringID message
Default message.
std::string custom_message
Custom message (if present)
std::string data
Additional data for message and custom_message.
uint32_t GetParam(uint number) const
Get GRF Parameter with range checking.
GRFFile * grffile
Currently processed GRF file.
GRFConfig * grfconfig
Config of the currently processed GRF file.
GrfLoadingStage stage
Current loading stage.