35 GrfMsg(1,
"StationChangeInfo: Station {} is invalid, max {}, ignoring", last,
NUM_STATIONS_PER_GRF);
40 if (_cur.
grffile->stations.size() < last) _cur.
grffile->stations.resize(last);
42 for (uint
id = first;
id < last; ++id) {
43 auto &statspec = _cur.
grffile->stations[id];
46 if (statspec ==
nullptr && prop != 0x08) {
47 GrfMsg(2,
"StationChangeInfo: Attempt to modify undefined station {}, ignoring",
id);
54 if (statspec ==
nullptr) {
55 statspec = std::make_unique<StationSpec>();
66 statspec->renderdata.clear();
67 statspec->renderdata.reserve(tiles);
69 for (uint t = 0; t < tiles; t++) {
73 if (buf.HasData(4) && buf.
PeekDWord() == 0) {
78 dts->seq.insert(dts->seq.end(), dtss.GetSequence().begin(), dtss.GetSequence().end());
86 std::vector<DrawTileSeqStruct> tmp_layout;
89 if (delta_x == 0x80)
break;
93 dtss.delta_x = delta_x;
104 dts->seq = std::move(tmp_layout);
108 if (statspec->renderdata.size() & 1) {
109 GrfMsg(1,
"StationChangeInfo: Station {} defines an odd number of sprite layouts, dropping the last item",
id);
110 statspec->renderdata.pop_back();
119 if (srcstatspec ==
nullptr) {
120 GrfMsg(1,
"StationChangeInfo: Station {} is not defined, cannot copy sprite layout to {}.", srcid,
id);
124 statspec->renderdata.clear();
125 statspec->renderdata.reserve(srcstatspec->
renderdata.size());
127 for (
const auto &it : srcstatspec->
renderdata) {
128 statspec->renderdata.emplace_back(it);
138 statspec->disallowed_platforms = buf.
ReadByte();
142 statspec->disallowed_lengths = buf.
ReadByte();
146 while (buf.HasData()) {
150 if (length == 0 || number == 0)
break;
152 const uint8_t *buf_layout = buf.ReadBytes(length * number);
156 layout.assign(buf_layout, buf_layout + length * number);
159 for (
auto &tile : layout) {
160 if ((tile & ~1U) != tile) {
161 GrfMsg(1,
"StationChangeInfo: Invalid tile {} in layout {}x{}", tile, length, number);
172 if (srcstatspec ==
nullptr) {
173 GrfMsg(1,
"StationChangeInfo: Station {} is not defined, cannot copy tile layout to {}.", srcid,
id);
177 statspec->layouts = srcstatspec->
layouts;
182 statspec->cargo_threshold = buf.
ReadWord();
187 if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
188 for (
int j = 0; j < 8; ++j) {
199 if (_cur.
grffile->grf_version >= 7) {
202 statspec->cargo_triggers = (CargoTypes)buf.
ReadDWord();
212 if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
213 for (
int j = 0; j < 8; ++j) {
225 if (statspec->tileflags.size() < 8) statspec->tileflags.resize(8);
226 for (
int j = 0; j < 8; ++j) {
237 statspec->animation.frames = buf.
ReadByte();
238 statspec->animation.status = buf.
ReadByte();
242 statspec->animation.speed = buf.
ReadByte();
246 statspec->animation.triggers = buf.
ReadWord();
253 statspec->renderdata.clear();
254 statspec->renderdata.reserve(tiles);
256 for (uint t = 0; t < tiles; t++) {
258 uint num_building_sprites = buf.
ReadByte();
264 if (statspec->renderdata.size() & 1) {
265 GrfMsg(1,
"StationChangeInfo: Station {} defines an odd number of sprite layouts, dropping the last item",
id);
266 statspec->renderdata.pop_back();
289 statspec->tileflags.assign(flags, flags + tiles);
bool ReadSpriteLayout(ByteReader &buf, uint num_building_sprites, bool use_cur_spritesets, uint8_t feature, bool allow_var10, bool no_z_position, NewGRFSpriteLayout *dts)
Read a spritelayout from the GRF.
TileLayoutFlags ReadSpriteLayoutSprite(ByteReader &buf, bool read_flags, bool invert_action1_flag, bool use_cur_spritesets, int feature, PalSpriteID *grf_sprite, uint16_t *max_sprite_offset, uint16_t *max_palette_offset)
Read a sprite and a palette from the GRF and convert them into a format suitable to OpenTTD.