17std::map<GRFLocation, std::pair<SpriteID, uint16_t>> _grm_sprites;
18GRFLineToSpriteOverride _grf_line_to_action6_sprite_override;
36 size_t pos = file.
GetPos();
42 GrfMsg(2,
"CfgApply: Ignoring (next sprite is real, unsupported)");
45 file.
SeekTo(pos, SEEK_SET);
50 GRFLocation location(_cur_gps.grfconfig->ident.grfid, _cur_gps.nfo_line + 1);
51 std::vector<uint8_t> &preload_sprite = _grf_line_to_action6_sprite_override[location];
54 if (preload_sprite.empty()) {
55 preload_sprite.resize(num);
56 file.
ReadBlock(preload_sprite.data(), num);
60 file.
SeekTo(pos, SEEK_SET);
72 if (param_num == 0xFF)
break;
80 add_value =
HasBit(param_size, 7);
81 param_size =
GB(param_size, 0, 7);
88 if (param_num < 0x80 && (param_num + (param_size - 1) / 4) >= std::size(_cur_gps.grffile->param)) {
89 GrfMsg(2,
"CfgApply: Ignoring (param {} not set)", (param_num + (param_size - 1) / 4));
93 GrfMsg(8,
"CfgApply: Applying {} bytes from parameter 0x{:02X} at offset 0x{:04X}", param_size, param_num, offset);
96 for (i = 0; i < param_size && offset + i < num; i++) {
97 uint32_t value = GetParamVal(param_num + i / 4,
nullptr);
100 if (i % 4 == 0) carry =
false;
103 uint new_value = preload_sprite[offset + i] +
GB(value, (i % 4) * 8, 8) + (carry ? 1 : 0);
104 preload_sprite[offset + i] =
GB(new_value, 0, 8);
106 carry = new_value >= 256;
108 preload_sprite[offset + i] =
GB(value, (i % 4) * 8, 8);
114template <>
void GrfActionHandler<0x06>::FileScan(
ByteReader &) { }
115template <>
void GrfActionHandler<0x06>::SafetyScan(
ByteReader &) { }
116template <>
void GrfActionHandler<0x06>::LabelScan(
ByteReader &) { }
117template <>
void GrfActionHandler<0x06>::Init(
ByteReader &buf) { CfgApply(buf); }
118template <>
void GrfActionHandler<0x06>::Reserve(
ByteReader &buf) { CfgApply(buf); }
119template <>
void GrfActionHandler<0x06>::Activation(
ByteReader &buf) { CfgApply(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.
Class to read from a NewGRF file.
uint16_t ReadExtendedByte()
Read a single Extended Byte (8 or 16 bits).
uint8_t ReadByte()
Read a single byte (8 bits).
void ReadBlock(void *ptr, size_t size)
Read a block.
size_t GetPos() const
Get position in the file.
void SeekTo(size_t pos, int mode)
Seek in the current file.
uint8_t ReadByte()
Read a byte from the file.
uint32_t ReadDword()
Read a double word (32 bits) from the file (in low endian format).
uint16_t ReadWord()
Read a word (16 bits) from the file (in low endian format).
RandomAccessFile with some extra information specific for sprite files.
uint8_t GetContainerVersion() const
Get the version number of container type used by the file.
Functions related to debugging.
NewGRF buffer reader definition.
NewGRF internal processing state.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.