diff options
author | yexo <yexo@openttd.org> | 2010-08-23 21:47:07 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-08-23 21:47:07 +0000 |
commit | a36159614a20c19b78b524e412a69b8a6f1abaa2 (patch) | |
tree | 0569c7e5e267c15d21aa3cfe26fddf991f7fe726 /src/newgrf.cpp | |
parent | 8ce06a09b9ce561cd823793dfb8c18aee894fd76 (diff) | |
download | openttd-a36159614a20c19b78b524e412a69b8a6f1abaa2.tar.xz |
(svn r20601) -Feature: [NewGRF] Add 'DEFA' field to set parameter defaults with action 14
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r-- | src/newgrf.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 7a636ae73..30df408b2 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -6183,6 +6183,18 @@ static bool ChangeGRFParamMask(size_t len, ByteReader *buf) return true; } +/** Callback function for 'INFO'->'PARAM'->param_num->'DEFA' to set the default value. */ +static bool ChangeGRFParamDefault(size_t len, ByteReader *buf) +{ + if (len != 4) { + grfmsg(2, "StaticGRFInfo: expected 4 bytes for 'INFO'->'PARA'->'DEFA' but got " PRINTF_SIZE ", ignoring this field", len); + buf->Skip(len); + } else { + _cur_parameter->def_value = buf->ReadDWord(); + } + _cur_grfconfig->has_param_defaults = true; + 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 @@ -6310,6 +6322,7 @@ AllowedSubtags _tags_parameters[] = { AllowedSubtags('LIMI', ChangeGRFParamLimits), AllowedSubtags('MASK', ChangeGRFParamMask), AllowedSubtags('VALU', ChangeGRFParamValueNames), + AllowedSubtags('DEFA', ChangeGRFParamDefault), AllowedSubtags() }; |