summaryrefslogtreecommitdiff
path: root/src/newgrf.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-07-31 09:35:49 +0000
committeryexo <yexo@openttd.org>2010-07-31 09:35:49 +0000
commit75c4a2d2fb4c400eb2eef6e1e1fa1bf3573c5be0 (patch)
tree62647c7494da5efbff57de09eab31dda31ecad18 /src/newgrf.cpp
parent897818c198944e22c0df4fb132f28a8d2b2f32bb (diff)
downloadopenttd-75c4a2d2fb4c400eb2eef6e1e1fa1bf3573c5be0.tar.xz
(svn r20251) -Add: [NewGRF] allow grfs to specify the number of valid parameters
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r--src/newgrf.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 60ede9a40..5b967d5ea 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -5919,6 +5919,18 @@ static bool ChangeGRFDescription(byte langid, const char *str)
return true;
}
+/** Callback function for 'INFO'->'NPAR' to set the number of valid parameters. */
+static bool ChangeGRFNumUsedParams(size_t len, ByteReader *buf)
+{
+ if (len != 1) {
+ grfmsg(2, "StaticGRFInfo: expected only 1 byte for 'INFO'->'NPAR' but got " PRINTF_SIZE ", ignoring this field", len);
+ buf->Skip(len);
+ } else {
+ _cur_grfconfig->num_valid_params = min(buf->ReadByte(), lengthof(_cur_grfconfig->param));
+ }
+ return true;
+}
+
typedef bool (*DataHandler)(size_t, ByteReader *); ///< Type of callback function for binary nodes
typedef bool (*TextHandler)(byte, const char *str); ///< Type of callback function for text nodes
typedef bool (*BranchHandler)(ByteReader *); ///< Type of callback function for branch nodes
@@ -6005,6 +6017,7 @@ struct AllowedSubtags {
AllowedSubtags _tags_info[] = {
AllowedSubtags('NAME', ChangeGRFName),
AllowedSubtags('DESC', ChangeGRFDescription),
+ AllowedSubtags('NPAR', ChangeGRFNumUsedParams),
AllowedSubtags()
};