diff options
-rw-r--r-- | src/newgrf.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 7e4ba801d..20408394e 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -5478,7 +5478,8 @@ static void RailTypeMapSpriteGroup(ByteReader *buf, uint8 idcount) { uint8 *railtypes = AllocaM(uint8, idcount); for (uint i = 0; i < idcount; i++) { - railtypes[i] = _cur.grffile->railtype_map[buf->ReadByte()]; + uint8 id = buf->ReadByte(); + railtypes[i] = id < RAILTYPE_END ? _cur.grffile->railtype_map[id] : INVALID_RAILTYPE; } uint8 cidcount = buf->ReadByte(); |