summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2021-05-02 10:47:05 +0100
committerPeterN <peter@fuzzle.org>2021-05-02 17:15:27 +0100
commit756034fa279bb6c3b81efbe13385583eb8a42d0f (patch)
tree6463e2b519907d0114c2b2d319cc095501f0ea5c
parenta3e49178d1d5d65e3ce91328d743d1642f324961 (diff)
downloadopenttd-756034fa279bb6c3b81efbe13385583eb8a42d0f.tar.xz
Codechange: Validate custom station platform layout tiles are permitted values only.
-rw-r--r--src/newgrf.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index a2671eff2..3a4fe1261 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -1991,6 +1991,14 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte
const byte *layout = buf->ReadBytes(length * number);
statspec->layouts[length - 1][number - 1].assign(layout, layout + length * number);
+
+ /* Validate tile values are only the permitted 00, 02, 04 and 06. */
+ for (auto &tile : statspec->layouts[length - 1][number - 1]) {
+ if ((tile & 6) != tile) {
+ grfmsg(1, "StationChangeInfo: Invalid tile %u in layout %ux%u", tile, length, number);
+ tile &= 6;
+ }
+ }
}
break;