Fix: [NewGRF] Ensure that stations always have an even number of sprite layouts.

The drawing code has a special fallbacks for zero layouts, but fails hard for one layout.
(odd numbers >= 3 are weird, but do not fail as badly as 1)
pull/434/head
frosch 2 years ago committed by frosch
parent 5c66de860d
commit e2c46fda3f

@ -1948,6 +1948,12 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte
}
dts->Clone(tmp_layout.data());
}
/* Number of layouts must be even, alternating X and Y */
if (statspec->renderdata.size() & 1) {
grfmsg(1, "StationChangeInfo: Station %u defines an odd number of sprite layouts, dropping the last item", stid + i);
statspec->renderdata.pop_back();
}
break;
}
@ -2070,6 +2076,12 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte
/* On error, bail out immediately. Temporary GRF data was already freed */
if (ReadSpriteLayout(buf, num_building_sprites, false, GSF_STATIONS, true, false, dts)) return CIR_DISABLED;
}
/* Number of layouts must be even, alternating X and Y */
if (statspec->renderdata.size() & 1) {
grfmsg(1, "StationChangeInfo: Station %u defines an odd number of sprite layouts, dropping the last item", stid + i);
statspec->renderdata.pop_back();
}
break;
}

Loading…
Cancel
Save