diff options
author | frosch <frosch@openttd.org> | 2010-01-03 19:29:56 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-01-03 19:29:56 +0000 |
commit | 666c856457ebda1a4261d0da95c11ecefc04708f (patch) | |
tree | ea9582ac8df5b3d68a9d1246f859c17c186d554f /src/newgrf.h | |
parent | f82c591022c37a2737afd040f65ab04e7af82da1 (diff) | |
download | openttd-666c856457ebda1a4261d0da95c11ecefc04708f.tar.xz |
(svn r18699) -Fix [FS#PlanetAndy]: GRF parameters were not properly initialised to zero, and not always checked for valid range.
Diffstat (limited to 'src/newgrf.h')
-rw-r--r-- | src/newgrf.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/newgrf.h b/src/newgrf.h index ea9b890a0..64b8f9172 100644 --- a/src/newgrf.h +++ b/src/newgrf.h @@ -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 { |