summaryrefslogtreecommitdiff
path: root/src/newgrf.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-07-31 14:40:50 +0000
committerrubidium <rubidium@openttd.org>2010-07-31 14:40:50 +0000
commitac280af8bc75f89223238a77f871b1a610014219 (patch)
treef11e8dde3c5e08a29824a11429eb573a3373302a /src/newgrf.cpp
parent5a2862814ac310e5e4629e0242def8ebf3a6da1c (diff)
downloadopenttd-ac280af8bc75f89223238a77f871b1a610014219.tar.xz
(svn r20259) -Add: allow NewGRFs to specify their version and use that to hide old NewGRFs / to choose the newest when loading compatible NewGRFs
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r--src/newgrf.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index bb5f63660..bd4c913e2 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -4869,7 +4869,7 @@ static void GRFInfo(ByteReader *buf)
_cur_grfconfig->status = _cur_stage < GLS_RESERVE ? GCS_INITIALISED : GCS_ACTIVATED;
/* Do swap the GRFID for displaying purposes since people expect that */
- DEBUG(grf, 1, "GRFInfo: Loaded GRFv%d set %08X - %s (palette: %s)", version, BSWAP32(grfid), name, (_cur_grfconfig->palette & GRFP_USE_MASK) ? "Windows" : "DOS");
+ DEBUG(grf, 1, "GRFInfo: Loaded GRFv%d set %08X - %s (palette: %s, version: %i)", version, BSWAP32(grfid), name, (_cur_grfconfig->palette & GRFP_USE_MASK) ? "Windows" : "DOS", _cur_grfconfig->version);
}
/* Action 0x0A */
@@ -5952,6 +5952,18 @@ static bool ChangeGRFPalette(size_t len, ByteReader *buf)
return true;
}
+/** Callback function for 'INFO'->'VRSN' to the version of the NewGRF. */
+static bool ChangeGRFVersion(size_t len, ByteReader *buf)
+{
+ if (len != 4) {
+ grfmsg(2, "StaticGRFInfo: expected 4 bytes for 'INFO'->'VRSN' but got " PRINTF_SIZE ", ignoring this field", len);
+ buf->Skip(len);
+ } else {
+ _cur_grfconfig->version = buf->ReadDWord();
+ }
+ return true;
+}
+
static GRFParameterInfo *_cur_parameter; ///< The parameter which info is currently changed by the newgrf.
@@ -6190,6 +6202,7 @@ AllowedSubtags _tags_info[] = {
AllowedSubtags('DESC', ChangeGRFDescription),
AllowedSubtags('NPAR', ChangeGRFNumUsedParams),
AllowedSubtags('PALS', ChangeGRFPalette),
+ AllowedSubtags('VRSN', ChangeGRFVersion),
AllowedSubtags('PARA', HandleParameterInfo),
AllowedSubtags()
};