diff options
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 { |