26#include "table/strings.h"
49 bool new_scheme = _cur_gps.grffile->grf_version >= 7;
52 if (feature >= GSF_END && feature != GSF_ORIGINAL_STRINGS) {
53 GrfMsg(1,
"FeatureNewName: Unsupported feature 0x{:02X}, skipping", feature);
59 bool generic =
HasBit(lang, 7);
63 }
else if (feature <= GSF_AIRCRAFT || feature == GSF_BADGES) {
71 uint16_t endid =
id + num;
73 GrfMsg(6,
"FeatureNewName: About to rename engines {}..{} (feature 0x{:02X}) in language 0x{:02X}",
74 id, endid, feature, lang);
77 uint32_t feature_overlay =
generic ? 0 : ((feature + 1) << 16);
79 for (;
id < endid && buf.HasData();
id++) {
81 GrfMsg(8,
"FeatureNewName: 0x{:04X} <- {}",
id,
StrMakeValid(name));
85 case GSF_ROADVEHICLES:
90 if (e ==
nullptr)
break;
100 auto found = _cur_gps.grffile->badge_map.find(
id);
101 if (found == std::end(_cur_gps.grffile->badge_map)) {
102 GrfMsg(1,
"FeatureNewName: Attempt to name undefined badge 0x{:X}, ignoring",
id);
119 switch (
GB(
id, 8, 8)) {
121 if (
GB(
id, 0, 8) >= _cur_gps.grffile->stations.size() || _cur_gps.grffile->stations[
GB(
id, 0, 8)] ==
nullptr) {
122 GrfMsg(1,
"FeatureNewName: Attempt to name undefined station 0x{:X}, ignoring",
GB(
id, 0, 8));
124 StationClassID class_index = _cur_gps.grffile->stations[
GB(
id, 0, 8)]->class_index;
130 if (
GB(
id, 0, 8) >= _cur_gps.grffile->stations.size() || _cur_gps.grffile->stations[
GB(
id, 0, 8)] ==
nullptr) {
131 GrfMsg(1,
"FeatureNewName: Attempt to name undefined station 0x{:X}, ignoring",
GB(
id, 0, 8));
133 _cur_gps.grffile->stations[
GB(
id, 0, 8)]->name =
AddGRFString(_cur_gps.grffile->grfid,
GRFStringID{id}, lang, new_scheme,
false, name, STR_UNDEFINED);
138 if (
GB(
id, 0, 8) >= _cur_gps.grffile->airtspec.size() || _cur_gps.grffile->airtspec[
GB(
id, 0, 8)] ==
nullptr) {
139 GrfMsg(1,
"FeatureNewName: Attempt to name undefined airport tile 0x{:X}, ignoring",
GB(
id, 0, 8));
141 _cur_gps.grffile->airtspec[
GB(
id, 0, 8)]->name =
AddGRFString(_cur_gps.grffile->grfid,
GRFStringID{id}, lang, new_scheme,
false, name, STR_UNDEFINED);
146 if (
GB(
id, 0, 8) >= _cur_gps.grffile->housespec.size() || _cur_gps.grffile->housespec[
GB(
id, 0, 8)] ==
nullptr) {
147 GrfMsg(1,
"FeatureNewName: Attempt to name undefined house 0x{:X}, ignoring.",
GB(
id, 0, 8));
149 _cur_gps.grffile->housespec[
GB(
id, 0, 8)]->building_name =
AddGRFString(_cur_gps.grffile->grfid,
GRFStringID{id}, lang, new_scheme,
false, name, STR_UNDEFINED);
154 GrfMsg(7,
"FeatureNewName: Unsupported ID (0x{:04X})",
id);
162template <>
void GrfActionHandler<0x04>::FileScan(
ByteReader &) { }
163template <>
void GrfActionHandler<0x04>::SafetyScan(
ByteReader &) { }
164template <>
void GrfActionHandler<0x04>::LabelScan(
ByteReader &) { }
165template <>
void GrfActionHandler<0x04>::Init(
ByteReader &) { }
166template <>
void GrfActionHandler<0x04>::Reserve(
ByteReader &) { }
167template <>
void GrfActionHandler<0x04>::Activation(
ByteReader &buf) { FeatureNewName(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 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.
uint16_t ReadWord()
Read a single Word (16 bits).
std::string_view ReadString()
Read a NUL-terminated string.
uint16_t ReadExtendedByte()
Read a single Extended Byte (8 or 16 bits).
uint8_t ReadByte()
Read a single byte (8 bits).
StringID name
Name of this class.
static NewGRFClass * Get(StationClassID class_index)
Functions related to debugging.
Definition of HouseSpec and accessors.
constexpr bool IsInsideMM(const size_t x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Engine * GetNewEngine(const GRFFile *file, VehicleType type, uint16_t internal_id, bool static_access)
Returns the engine associated to a certain internal_id, resp.
NewGRF handling of airport tiles.
Badge * GetBadge(BadgeID index)
Get a badge if it exists.
Functions related to NewGRF badges.
Types related to NewGRF badges.
NewGRF buffer reader definition.
Cargo support for NewGRFs.
@ Static
GRF file is used statically (can be used in any MP game).
Functions for NewGRF engines.
NewGRF internal processing state.
NewGRF internal processing state for vehicles.
Header file for NewGRF stations.
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.
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.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
StringID string_id
Default name of engine.
VehicleType
Available vehicle types.