(svn r20601) -Feature: [NewGRF] Add 'DEFA' field to set parameter defaults with action 14

This commit is contained in:
yexo
2010-08-23 21:47:07 +00:00
parent 8ce06a09b9
commit a36159614a
4 changed files with 32 additions and 1 deletions

View File

@@ -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()
};