(svn r20259) -Add: allow NewGRFs to specify their version and use that to hide old NewGRFs / to choose the newest when loading compatible NewGRFs

This commit is contained in:
rubidium
2010-07-31 14:40:50 +00:00
parent f4c46dd701
commit a777266426
7 changed files with 55 additions and 7 deletions

View File

@@ -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()
};