Changeset - r16249:929ddeef42a2
[Not reviewed]
master
0 4 0
frosch - 14 years ago 2010-10-17 12:14:49
frosch@openttd.org
(svn r20960) -Add: Allow setting 'minimal compatible version' via Action14. (planetmaker)
Note: Setting 'VRSN' also sets 'MINV' resulting in the Grf being only compatible to the same version. Set 'MINV' after 'VRSN' if your Grf is compatible to older versions.
4 files changed with 28 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -2400,6 +2400,7 @@ STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT
 
STR_NEWGRF_SETTINGS_FILENAME                                    :{BLACK}Filename: {SILVER}{RAW_STRING}
 
STR_NEWGRF_SETTINGS_GRF_ID                                      :{BLACK}GRF ID: {SILVER}{RAW_STRING}
 
STR_NEWGRF_SETTINGS_VERSION                                     :{BLACK}Version: {SILVER}{NUM}
 
STR_NEWGRF_SETTINGS_MIN_VERSION                                 :{BLACK}Min. compatible version: {SILVER}{NUM}
 
STR_NEWGRF_SETTINGS_MD5SUM                                      :{BLACK}MD5sum: {SILVER}{RAW_STRING}
 
STR_NEWGRF_SETTINGS_PALETTE                                     :{BLACK}Palette: {SILVER}{RAW_STRING}
 
STR_NEWGRF_SETTINGS_PARAMETER                                   :{BLACK}Parameters: {SILVER}{STRING1}
src/newgrf.cpp
Show inline comments
 
@@ -6326,11 +6326,31 @@ static bool ChangeGRFVersion(size_t len,
 
		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();
 
		/* Set min_loadable_version as well (default to minimal compatibility) */
 
		_cur_grfconfig->version = _cur_grfconfig->min_loadable_version = buf->ReadDWord();
 
	}
 
	return true;
 
}
 

	
 
/** Callback function for 'INFO'->'MINV' to the minimum compatible version of the NewGRF. */
 
static bool ChangeGRFMinVersion(size_t len, ByteReader *buf)
 
{
 
	if (len != 4) {
 
		grfmsg(2, "StaticGRFInfo: expected 4 bytes for 'INFO'->'MINV' but got " PRINTF_SIZE ", ignoring this field", len);
 
		buf->Skip(len);
 
	} else {
 
		_cur_grfconfig->min_loadable_version = buf->ReadDWord();
 
		if (_cur_grfconfig->version == 0) {
 
			grfmsg(2, "StaticGRFInfo: 'MINV' defined before 'VRSN' or 'VRSN' set to 0, ignoring this field");
 
			_cur_grfconfig->min_loadable_version = 0;
 
		}
 
		if (_cur_grfconfig->version < _cur_grfconfig->min_loadable_version) {
 
			grfmsg(2, "StaticGRFInfo: 'MINV' defined as %d, limiting it to 'VRSN'", _cur_grfconfig->min_loadable_version);
 
			_cur_grfconfig->min_loadable_version = _cur_grfconfig->version;
 
		}
 
	}
 
	return true;
 
}
 

	
 
static GRFParameterInfo *_cur_parameter; ///< The parameter which info is currently changed by the newgrf.
 

	
 
@@ -6583,6 +6603,7 @@ AllowedSubtags _tags_info[] = {
 
	AllowedSubtags('NPAR', ChangeGRFNumUsedParams),
 
	AllowedSubtags('PALS', ChangeGRFPalette),
 
	AllowedSubtags('VRSN', ChangeGRFVersion),
 
	AllowedSubtags('MINV', ChangeGRFMinVersion),
 
	AllowedSubtags('PARA', HandleParameterInfo),
 
	AllowedSubtags()
 
};
src/newgrf_config.cpp
Show inline comments
 
@@ -40,6 +40,7 @@ GRFConfig::GRFConfig(const GRFConfig &co
 
	ZeroedMemoryAllocator(),
 
	ident(config.ident),
 
	version(config.version),
 
	min_loadable_version(config.min_loadable_version),
 
	flags(config.flags & ~GCF_COPY),
 
	status(config.status),
 
	grf_bugs(config.grf_bugs),
src/newgrf_gui.cpp
Show inline comments
 
@@ -85,6 +85,10 @@ static void ShowNewGRFInfo(const GRFConf
 
		SetDParam(0, c->version);
 
		y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_VERSION);
 
	}
 
	if (_settings_client.gui.newgrf_show_old_versions && c->min_loadable_version != 0) {
 
		SetDParam(0, c->min_loadable_version);
 
		y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_MIN_VERSION);
 
	}
 

	
 
	/* Prepare and draw MD5 sum */
 
	md5sumToString(buff, lastof(buff), c->ident.md5sum);
0 comments (0 inline, 0 general)