summaryrefslogtreecommitdiff
path: root/src/newgrf.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-01-03 19:29:56 +0000
committerfrosch <frosch@openttd.org>2010-01-03 19:29:56 +0000
commit666c856457ebda1a4261d0da95c11ecefc04708f (patch)
treeea9582ac8df5b3d68a9d1246f859c17c186d554f /src/newgrf.h
parentf82c591022c37a2737afd040f65ab04e7af82da1 (diff)
downloadopenttd-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.h9
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 {