From 6e4dd5615878c658cf687a73dc1990f9e903df86 Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 15 Jan 2011 21:13:47 +0000 Subject: (svn r21814) -Fix/Add: Check GRF version from action 8, and disallow usage of GRFs with versions above 7. --- src/newgrf.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/newgrf.cpp') diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 4fb8fa78e..4a4f55213 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -5313,15 +5313,21 @@ static void SkipIf(ByteReader *buf) /* Action 0x08 (GLS_FILESCAN) */ static void ScanInfo(ByteReader *buf) { - buf->ReadByte(); - uint32 grfid = buf->ReadDWord(); + uint8 grf_version = buf->ReadByte(); + uint32 grfid = buf->ReadDWord(); + const char *name = buf->ReadString(); _cur_grfconfig->ident.grfid = grfid; + /* TODO We are incompatible to grf_version < 2 as well, but due to broken GRFs out there, we accept these till the next stable */ + if (/*grf_version < 2 || */grf_version > 7) { + SetBit(_cur_grfconfig->flags, GCF_INVALID); + DEBUG(grf, 0, "%s: NewGRF \"%s\" (GRFID %08X) uses GRF version %d, which is incompatible with this version of OpenTTD.", _cur_grfconfig->filename, name, BSWAP32(grfid), grf_version); + } + /* GRF IDs starting with 0xFF are reserved for internal TTDPatch use */ if (GB(grfid, 24, 8) == 0xFF) SetBit(_cur_grfconfig->flags, GCF_SYSTEM); - const char *name = buf->ReadString(); AddGRFTextToList(&_cur_grfconfig->name, 0x7F, grfid, name); if (buf->HasData()) { -- cgit v1.2.3-54-g00ecf