17#include "table/strings.h"
34 GrfMsg(7,
"TranslateGRFStrings: GRFID 0x{:08X} unknown, skipping action 13",
std::byteswap(grfid));
43 error->
data =
GetString(STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE);
53 uint8_t language = _cur_gps.grffile->grf_version >= 8 ? buf.
ReadByte() : 0x7F;
54 uint8_t num_strings = buf.
ReadByte();
57 if (!((first_id >= 0xD000 && first_id + num_strings <= 0xD400) || (first_id >= 0xD800 && first_id + num_strings <= 0xE000))) {
58 GrfMsg(7,
"TranslateGRFStrings: Attempting to set out-of-range string IDs in action 13 (first: 0x{:04X}, number: 0x{:02X})", first_id, num_strings);
62 for (uint i = 0; i < num_strings && buf.HasData(); i++) {
66 GrfMsg(7,
"TranslateGRFString: Ignoring empty string.");
74template <>
void GrfActionHandler<0x13>::FileScan(
ByteReader &) { }
75template <>
void GrfActionHandler<0x13>::SafetyScan(
ByteReader &) { }
76template <>
void GrfActionHandler<0x13>::LabelScan(
ByteReader &) { }
77template <>
void GrfActionHandler<0x13>::Init(
ByteReader &) { }
78template <>
void GrfActionHandler<0x13>::Reserve(
ByteReader &) { }
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).
uint16_t ReadWord()
Read a single Word (16 bits).
std::string_view ReadString()
Read a NUL-terminated string.
uint8_t ReadByte()
Read a single byte (8 bits).
Functions related to debugging.
GRFError * DisableGrf(StringID message, GRFConfig *config)
Disable a GRF.
static void TranslateGRFStrings(ByteReader &buf)
Action 0x13.
NewGRF buffer reader definition.
GRFConfig * GetGRFConfig(uint32_t grfid, uint32_t mask)
Retrieve a NewGRF from the current config by its grfid.
@ GCS_INITIALISED
GRF file has been initialised.
@ GCS_ACTIVATED
GRF file has been activated.
NewGRF internal processing state.
StringID AddGRFString(uint32_t grfid, GRFStringID stringid, uint8_t langid_to_add, bool new_scheme, bool allow_newlines, std::string_view text_to_add, StringID def_string)
Add the new read string into our structure.
Header of Action 04 "universal holder" structure and functions.
StrongType::Typedef< uint32_t, struct GRFStringIDTag, StrongType::Compare, StrongType::Integer > GRFStringID
Type for GRF-internal string IDs.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Functions related to OTTD's strings.
Information about GRF, used in the game and (part of it) in savegames.
GRFStatus status
NOSAVE: GRFStatus, enum.
Information about why GRF had problems during initialisation.
std::string data
Additional data for message and custom_message.