summaryrefslogtreecommitdiff
path: root/src/newgrf_config.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-10-17 12:12:52 +0000
committerfrosch <frosch@openttd.org>2010-10-17 12:12:52 +0000
commite805919fe9f8becadbc0e41dd018173a9c18a99f (patch)
tree9e23c445fcee51857db6b2887a6d73a012867c6d /src/newgrf_config.cpp
parent3972c790c2cba8c4c01ac6536e8675808f6e1c4d (diff)
downloadopenttd-e805919fe9f8becadbc0e41dd018173a9c18a99f.tar.xz
(svn r20958) -Add: the concept of min-loadable-version to NewGRFs when choosing compatbile NewGRFs. (planetmaker)
Diffstat (limited to 'src/newgrf_config.cpp')
-rw-r--r--src/newgrf_config.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index 6e32fe054..b951ebfe2 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -448,7 +448,7 @@ GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
/* If we have not found the exactly matching GRF try to find one with the
* same grfid, as it most likely is compatible */
- f = FindGRFConfig(c->ident.grfid, FGCM_COMPATIBLE);
+ f = FindGRFConfig(c->ident.grfid, FGCM_COMPATIBLE, NULL, c->version);
if (f != NULL) {
md5sumToString(buf, lastof(buf), c->ident.md5sum);
DEBUG(grf, 1, "NewGRF %08X (%s) not found; checksum %s. Compatibility mode on", BSWAP32(c->ident.grfid), c->filename, buf);
@@ -485,6 +485,7 @@ compatible_grf:
if (c->info == NULL) c->info = DuplicateGRFText(f->info);
c->error = NULL;
c->version = f->version;
+ c->min_loadable_version = f->min_loadable_version;
c->num_valid_params = f->num_valid_params;
c->has_param_defaults = f->has_param_defaults;
for (uint i = 0; i < f->param_info.Length(); i++) {
@@ -616,9 +617,10 @@ void ScanNewGRFFiles()
* @param grfid GRFID to look for,
* @param mode Restrictions for matching grfs
* @param md5sum Expected MD5 sum
+ * @param desired_version Requested version
* @return The matching grf, if it exists in #_all_grfs, else \c NULL.
*/
-const GRFConfig *FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum)
+const GRFConfig *FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum, uint32 desired_version)
{
assert((mode == FGCM_EXACT) != (md5sum == NULL));
const GRFConfig *best = NULL;
@@ -627,6 +629,8 @@ const GRFConfig *FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8
if (!c->ident.HasGrfIdentifier(grfid, md5sum)) continue;
/* return it, if the exact same newgrf is found, or if we do not care about finding "the best" */
if (md5sum != NULL || mode == FGCM_ANY) return c;
+ /* check version compatibility */
+ if (mode == FGCM_COMPATIBLE && (c->version < desired_version || c->min_loadable_version > desired_version)) continue;
/* remember the newest one as "the best" */
if (best == NULL || c->version > best->version) best = c;
}