summaryrefslogtreecommitdiff
path: root/src/newgrf.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-01-15 21:13:47 +0000
committerfrosch <frosch@openttd.org>2011-01-15 21:13:47 +0000
commit6e4dd5615878c658cf687a73dc1990f9e903df86 (patch)
tree29eddd4bfb56a83ab7ba2e131372d79535fb8b79 /src/newgrf.cpp
parent4d8a93c870428d8cdffad9a453aef91a1365f97e (diff)
downloadopenttd-6e4dd5615878c658cf687a73dc1990f9e903df86.tar.xz
(svn r21814) -Fix/Add: Check GRF version from action 8, and disallow usage of GRFs with versions above 7.
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r--src/newgrf.cpp12
1 files changed, 9 insertions, 3 deletions
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()) {