(svn r18699) -Fix [FS#PlanetAndy]: GRF parameters were not properly initialised to zero, and not always checked for valid range.

This commit is contained in:
frosch
2010-01-03 19:29:56 +00:00
parent f82c591022
commit 666c856457
3 changed files with 27 additions and 11 deletions

View File

@@ -118,6 +118,15 @@ struct GRFFile {
uint32 grf_features; ///< Bitset of GrfSpecFeature the grf uses
PriceMultipliers price_base_multipliers; ///< Price base multipliers as set by the grf.
/** Get GRF Parameter with range checking */
uint32 GetParam(uint number) const
{
/* Note: We implicitly test for number < lengthof(this->param) and return 0 for invalid parameters.
* In fact this is the more important test, as param is zeroed anyway. */
assert(this->param_end <= lengthof(this->param));
return (number < this->param_end) ? this->param[number] : 0;
}
};
enum ShoreReplacement {